Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling DLL function from a VBScript?

Status
Not open for further replies.

0100

Programmer
Sep 9, 2003
6
0
0
FR

hi all
please could u tell how (or give me an example)to call a DLL function, written with Visual C++, from a VBScript?

Thanks in advance
cordilly
khaled



 
khaled,
You'll need to maje sure that your DLL supports OLE/automation and you'll also need to know the name of the accessible interface in the DLL. One place to find this is using the OLE View MS Visual Studio tool. Expand the All Objects item, then look for your DLL. When you find it, exapnd the DLL item and you will see the available interfaces. Look for the ProgID field to see what to use with the CreateObject command (see below). You can double-clik each interface, select View Type Info, and you'll see the availoable properties and methods.

Once you have this, you can implement the DLL within VBScript by using the CreateObject function call.

For example, if you wanted to implement some MS Excel functions:

Code:
Dim objExcel

Set objExcel = CreateObject("Excel.Application")

Accessing the functions then depends upon their argument and return types.

You may want to check to see if there is a forum here devoted to OLE, automation or COM.

Zy
 
Thanks a lot Zymurgyst
it s more clear now

*but i didn't find my DLL using the OLE View even after using regsvr32, it says "file.dll" is loaded but "Dllregisterserver entry point is not found"
"Dllregisterserver may not be exported"

* else how could i know if the DLL supports OLE automation
especially that nothing shows in the code source that we used the OLE interface
and if it doesn't support the OLE, will i be able to use this DLL or not


many thanks
 
khaled,
Since the registration server can't find a valid OLE entry point when you register, it is not an OLE or COM DLL. You will be unable to use it.

Zy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top