Re: Declare in vb script?



Alvaro wrote:
I need to write a code in vb script that call a dll,

hi Alvaro,

If you are courageous enough (or foolhardy enough) to use a
third-party control, then you can use DynaWrap (or other
control) designed to call a (standard) dll. See the
"DynaWrap Boilerplate" below.

If you don't like using a 3rd-party control, you could write
one yourself (if you write it yourself, then it is a FIRST-
party control). To do this you need some compiler (like
vb classic or vb.net) which will compile objects which are
callable from script (i.e., have a COM interface). Then
what you do is declare your dll's entry points, and write
a COM wrapper for each of the entry points. For a discussion
of how to do that, you might look for a copy of Dan Appleman's
"Developing ActiveX Components with Visual Basic" in your
local civic or college library, or you can purchase it online.

And finally, as a more extreme measure, you could adopt a
scripting language that allows for direct dll calls in the
language. There are several such languages available.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)

--- <DynaWrap Boilerplate> ---
It is possible to declare-and-call an api from script,
but you must use a third-party control to do so,
or else write one yourself.

It has already been correctly pointed out that there
is no api-capability in "pure" script.

If you are willing to use a third-party control, then
one such control, called "DynaWrap", can be found on
Guenter Born's website (note: Guenter refers to it as
"DynaCall"). Here is the link to it:

http://people.freenet.de/gborn/WSHBazaar/WSHDynaCall.htm

- or -

http://ourworld.compuserve.com/homepages/Guenter_Born/WSHBazaar/WSHDynaCall.htm

On that page you will find a download for the control,
plus some code samples.

Note: you may find additional sample code by searching
the archives of the wsh and vbscript ng's.

Note also: DynaWrap does have its limitations. There are
certain things it can't do. For example, you can't call
api's "by ordinal". (I had previously asserted that you
can't use DynaWrap to call api's which take typedefs as
parameters, but I have been proven wrong on that --
although it took me about two weeks to figure out how it
was done). Regardless, Dynawrap will work for most of
"the usual suspects".

And finally, DynaWrap doesn't work entirely as advertised.
For example, it is supposed to allow for the declaration of
several api definitions in one instance of itself. I could
never get that to work (in win9x -- but others have shown
this to work as advertised under winNT). With win98, you
will need a new instance of DynaWrap for every api, or else
re-instantiate the object for every api. Someday I'm going
to learn enough c++ to fix that...

Another possibility (for calling api's from script is XNeat:

http://www.xneat.com/doc/call_win32_api.html

One other thing. While the above discussion is oriented to
calling the system api's, contained in the user32, kernel32,
gdi32 and other system dll's, you could use DynaWrap (and
other similiar utilities) to call the exported interfaces
to ANY dll.

--- </DynaWrap Boilerplate> ---


.



Relevant Pages

  • A Christmas Present (that you didnt ask for)...
    ... it is written in vbs using api's called by DynaWrap to create the graphical interface. ... It has been mentioned in the scripting ng's for years and is frequently suggested for use when somebody wishes to do something outside the realm of "pure" script. ... It is possible to declare-and-call an api from script, but you must use a third-party control to do so, or else write one yourself. ... Private Function RepaintProgBar ...
    (microsoft.public.scripting.vbscript)
  • Re: Return after AppActivate
    ... If I can terminate it then a message should be no big deal. ... from the TechNet Script library .. ... One such non-standard actX control for calling api's is called ... "DynaWrap", and that can be found on Gunter Born's website. ...
    (microsoft.public.scripting.wsh)
  • Re: Using User32.dll function from VBScript(WSH)!?
    ... use a third-party control (such as DynaWrap), ... It is possible to declare-and-call an api from script, ... but you must use a third-party control to do so, ...
    (microsoft.public.scripting.vbscript)
  • Re: Return after AppActivate
    ... from the TechNet Script library .. ... One such non-standard actX control for calling api's is called ... "DynaWrap", and that can be found on Gunter Born's website. ... It is possible to declare-and-call an api from script, ...
    (microsoft.public.scripting.wsh)
  • Re: Return after AppActivate
    ... There is a way to call api's from script, ... One such non-standard actX control for calling api's is called ... "DynaWrap", and that can be found on Gunter Born's website. ... It is possible to declare-and-call an api from script, ...
    (microsoft.public.scripting.wsh)