Thread: External DLL

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    26
    Rep Power
    0

    External DLL


    How can I call external DLL from ‘Win32 Console App’?
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,638
    Rep Power
    4247
    First declare a variable of type, pointer to function. Then use LoadLibrary() or LoadLibraryEx() to load a DLL and get a handle to the DLL. Then call GetProcAddress() and pass it the DLL handle and the function name to get the pointer to the given DLL function. Then indirect through the pointer to call the function itself. See http://msdn.microsoft.com/library/de...ic_linking.asp for an example. Hope this helps :)
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    2
    Rep Power
    0

    Dll error


    When I build my DLL , it requires a couple of files , say 1.h 2.h ..., to be included.These are listed as External Dependencies.This part is fine and I can build my Dll .
    Now when I get to the point of using the DLL in a project , I get errors like :
    error LNK2001: unresolved external symbol _htTraceInit
    These symbols I can trace to those files which were included as "External Dependencies" while building the DLL.
    Why do these errors occur , even though I include the files in question (1.h) in the project that is using the DLL.
    Do the functions in files under external dependencies have to be exported too?
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    chennai
    Posts
    4
    Rep Power
    0
    To call the function of the dll from outside you need to export the fuctions using the keyword
    _declspec(dllexport).This is also applicable when you want to use the global variables declared in the dll from outside

IMN logo majestic logo threadwatch logo seochat tools logo