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

call DLL

Status
Not open for further replies.

Denyson

Programmer
Mar 20, 2001
19
BR
I made a DLL (IMPCAR.DLL) using Microsoft Visual C++ 6.0. Now, I´m trying to call the DLL from the Visual Basic 6.0.
My DLL only has an exported function:

extern "C" _declspec(dllexport) icPar *IMPCAR(icPar *ParGlobal);

where:
icPar is a struct.

Please, anybody could me give an example how to declare and call this function from the IMPCAR.DLL?

Thanks
 
I dont know if you have yet, but the DLL written in VC must have a .def file

(side note... the ; behaves like a comment in the .def file)

***************************************************
; sample .def file
LIBRARY <dll name without the .dll extention and no &quot;<&quot; or &quot;>&quot;>

CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE

EXPORTS
IMPCAR

***************************************

This will export the IMPCAR function.

NEXT, with a struct, there MAY be padding issues so make sure there is a 1 to 1 correspondence in the size of the struct defined in C++ and your TYPE defined in VB.

in VB you will want to add:

PRIVATE DECLARE FUNCTION IMPCAR LIB &quot;YOUR_DLL.dll&quot; Alias &quot;IMPCAR&quot;(byVal icPar as YOUR_TYPE) as YOUR_TYPE

*****************************

There may be a few bugs in it but this should get you well on your way into incorporating the dll into VB

Matt

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top