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

Declaring and calling a DLL function

Status
Not open for further replies.

chinkybubbles

Programmer
Jun 15, 2004
2
US
What are the commands to declare and call a DLL function? Something like these VB commands:

Private Declare Function x Lib "x.dll" () As String

Private Sub
Dim s as String
s = x()
End

Thanks.
 
__declspec(dllexport) yourfunctiondeclaration;
for dll side

__declspec(dllimport) yourfunctiondeclaration;
for caller side


Ion Filipski
1c.bmp
 
Ion, I saw that in MSDN but can't figure out how to specify the DLL name. Thanks!
 
you don't have to specify the dll name. Wehn you compile the dll is generated a .lib file. Link your .exe with that .lib file. The lib contains all information needed to load the dll.

Ion Filipski
1c.bmp
 
If you don't have the .lib file, you can still link with the DLL by using the LoadLibrary() and GetProcAddress() functions. In fact, I prefer this method because then the application does not absolutely require the DLL. It can still load and provide partial functionality. On the other hand, if you use the .lib file, and you the DLL isn't found at runtime, the application will not even load at all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top