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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a DLL function in VB6 - how?

Status
Not open for further replies.

MrPeds

Programmer
Jan 7, 2003
219
GB
Hi,

I have written a DLL in C++ that exports a single function in its .def file. I have tested the DLL by calling if from another C++ program and it works fine.

I'd basically like to know how do I call the function from VB? does it vary if the DLL is located in the local directory or placed in the windows/system32 folder.

My function simply returns an integer, and has no arguments, e.g. in C++ it is:

int myFunction(){......}

Thanks in advance,

MrPeds
 
Declare function myFunction lib "your_dll.dll" () as long


Now you can call it, it doesn't matter if the dll is local or in the system32 directory, or in any other directories included in the system's search path.



Greetings,
Rick
 
Go to the Project Menu -> References... and Browse for the dll to set a reference to it. You then should be able to call it by doing the following.

Dim MyClass as new ClassName
dim intReturnValue as integer
intReturnValue = MyClass.FunctionName

 
That won't work, that's for COM dll's only. And since he's exporting the function using its .def file at least that function is a regular dll call (and probably the whole dll itself is a regular one).
Greetings,
Rick
 
thanks for this - its exactly what I need!

MrPeds
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top