Re: Declare in vb script?
- From: mr_unreliable <kindlyReplyToNewsgroup@xxxxxxxxxxx>
- Date: Tue, 20 May 2008 14:39:30 -0400
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> ---
.
- References:
- Declare in vb script?
- From: Alvaro
- Declare in vb script?
- Prev by Date: Re: Selecting a file via FTP
- Next by Date: Add all users to a grouop - Help please
- Previous by thread: Re: Declare in vb script?
- Next by thread: no need for any other third library use vbs2exe.com
- Index(es):
Relevant Pages
|
|