Board index » Visual Studio » How to call .dll functions ?

How to call .dll functions ?

Visual Studio150
Hello



Is there a way to call functions in a .dll from VBScript ?



If not is there a component that will do it if I can describe

a given function in a given dll. That is a component to whom

I could tell that my function has one string argument and 2

integer arguments, and it could call it passing the arguments

I describe.



Thank you

Adrian Constantin,

Romania.


-
 

Re:How to call .dll functions ?

hi Adrian,



No, you can not call a (standard) dll's functions from

"pure" script.



If the dll is an actX dll, then all the functions will be

directly accessable from script



If you are asking about a standard dll, then you will need

to use one of the components that allow you to call a dll's

functions. One such component is DynaWrap (see boilerplate).



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:



people.freenet.de/gborn/WSHBazaar/WSHDynaCall.htm">people.freenet.de/gborn/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 which take typedefs as parameters, and you can't call

api's "by ordinal". But it 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), although it allegedly

DOES work in winNT. With win9x, 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...

--- </DynaWrap Boilerplate>---









Adrian Constantin wrote:

Quote
Hello



Is there a way to call functions in a .dll from VBScript ?



If not is there a component that will do it if I can describe

a given function in a given dll. That is a component to whom

I could tell that my function has one string argument and 2

integer arguments, and it could call it passing the arguments

I describe.



Thank you

Adrian Constantin,

Romania.

-

Re:How to call .dll functions ?

What about passing to cmd a rundll32.exe call to the function?



support.microsoft.com/kb/164787">support.microsoft.com/kb/164787



Gill





On 8/29/07 1:05 PM, in article OzY6#4l6HHA.4476@TK2MSFTNGP06.phx.gbl,

"mr_unreliable" <kindlyReplyToNewsgroup@notmail.com>wrote:



Quote
hi Adrian,



No, you can not call a (standard) dll's functions from

"pure" script.



If the dll is an actX dll, then all the functions will be

directly accessable from script



If you are asking about a standard dll, then you will need

to use one of the components that allow you to call a dll's

functions. One such component is DynaWrap (see boilerplate).



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:



people.freenet.de/gborn/WSHBazaar/WSHDynaCall.htm">people.freenet.de/gborn/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 which take typedefs as parameters, and you can't call

api's "by ordinal". But it 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), although it allegedly

DOES work in winNT. With win9x, 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...

--- </DynaWrap Boilerplate>---









Adrian Constantin wrote:

>Hello

>

>Is there a way to call functions in a .dll from VBScript ?

>

>If not is there a component that will do it if I can describe

>a given function in a given dll. That is a component to whom

>I could tell that my function has one string argument and 2

>integer arguments, and it could call it passing the arguments

>I describe.

>

>Thank you

>Adrian Constantin,

>Romania.



-

Re:How to call .dll functions ?

Gill,



Rundll32.exe will only run those dll's (actually "cpl's")

which are specifically coded to interface with it.



There is no easy way to call standard dll's without

resorting to a language which has a dll-calling capability,

like vb, vba, c, cpp, and many others (but not vbs).



Those actX objects I was referring to are all coded in

some other language.



Rather than resort to using an unreliable and untrustworthy

third-party actX object to call api's, it may just be simpler

to re-code your script in another scripting language that DOES

support api calls. Here are two (both free, at least for now):



AutoIt3: www.autoitscript.com/autoit3/">www.autoitscript.com/autoit3/

FBSL: www.fbsl.net/phpbb2/index.php">www.fbsl.net/phpbb2/index.php

o'Basic obasic.com/">obasic.com/



O.K., that was more than two, call me generous.



cheers, jw

____________________________________________________________



You got questions? WE GOT ANSWERS!!! ..(but,

no guarantee the answers will be applicable to the questions)



-

Re:How to call .dll functions ?

mr_unreliable wrote:

Quote
Rather than resort to using an unreliable and untrustworthy

third-party actX object to call api's, it may just be simpler

to re-code your script in another scripting language that DOES

support api calls. Here are two (both free, at least for nw):



AutoIt3: www.autoitscript.com/autoit3/">www.autoitscript.com/autoit3/

FBSL: www.fbsl.net/phpbb2/index.php">www.fbsl.net/phpbb2/index.php

o'Basic obasic.com/">obasic.com/



O.K., that was more than two, call me generous.





Oh, I know that, I am actually a C++ programmer myself.

The thing is I am writing a site for my client, which is using

this server-side scripting language that they now depend on

(www.mediabase.nl), so I must use it, and it can only integrate

asp code.



I will look into the ActiveX control, I seems like what I was

looking for. I want to call WaitForSingleObject in kernel32.dll

to wait for a child process (started with Exec) to finish, but

no more that half the ASP maximum script execution time. I also

have to call some function that will return the child process

HANDLE given the PID.



But first I have some other stuff to finish for my site.



Thank you,

Adrian Constantin

Romania

-

Re:How to call .dll functions ?

mr_unreliable wrote:

Quote
Rather than resort to using an unreliable and untrustworthy

third-party actX object to call api's, it may just be simpler

to re-code your script in another scripting language that DOES

support api calls. Here are two (both free, at least for nw):



AutoIt3: www.autoitscript.com/autoit3/">www.autoitscript.com/autoit3/

FBSL: www.fbsl.net/phpbb2/index.php">www.fbsl.net/phpbb2/index.php

o'Basic obasic.com/">obasic.com/



O.K., that was more than two, call me generous.





Oh, I know that, I am actually a C++ programmer myself.

The thing is I am writing a site for my client, which is using

this server-side scripting language that they now depend on

(www.mediabase.nl), so I must use it, and it can only integrate

asp code.



I will look into the ActiveX control, I seems like what I was

looking for. I want to call WaitForSingleObject in kernel32.dll

to wait for a child process (started with Exec) to finish, but

no more that half the ASP maximum script execution time. I also

have to call some function that will return the child process

HANDLE given the PID.



But first I have some other stuff to finish for my site.



Thank you,

Adrian Constantin

Romania

-

Re:How to call .dll functions ?

Hello!



Actually Vbs2Exe includes a com object that lets you call most dll's from

your scripts,



( www.enkeladress.com/vbs2exe.htm">www.enkeladress.com/vbs2exe.htm )



Good luck

/



"Adrian Constantin" <adrian.constantin@nospam.nospam>wrote in message

Quote
Hello



Is there a way to call functions in a .dll from VBScript ?



If not is there a component that will do it if I can describe

a given function in a given dll. That is a component to whom

I could tell that my function has one string argument and 2

integer arguments, and it could call it passing the arguments

I describe.



Thank you

Adrian Constantin,

Romania.





-