Advertisement Jump to content
Sign in to follow this  

DLL Files

This topic is 4265 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hiya, I'm having some trouble using a DLL dynamically. I have created the DLL exporting it's function like so:
extern "C" __declspec (dllexport) VOID CALLBACK ShowMessage();
The client loads it with the following code:
typedef void (WINAPI *SHOWMESSAGE)();

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nShowCmd )
    hDLL = LoadLibrary("test.dll");

    if( !hDLL ) { handle error... }

    SHOWMESSAGE _ShowMessage = NULL;
    _ShowMessage = (SHOWMESSAGE)GetProcAddress(hDLL, TEXT("ShowMessage"));

    if( !_ShowMessage ) { handle error... }

    // etc.

The call to GetProcAddress() always seems to fail, and I'm not sure why. If anyone could suggest anything it would be much appreciated. Many thanks :)

Share this post

Link to post
Share on other sites

_ShowMessage = (SHOWMESSAGE)GetProcAddress(hDLL, TEXT("_ShowMessage@0"));

if that succeeds then you need to change the dll compilation settings so that it uses undecorated function names.

Share this post

Link to post
Share on other sites
A couple of very useful (and freely available) utilities to use when working with dlls are Dependency Walker, which makes it very easy to check out the export and import tables of dlls and which includes a profiler that tracks dynamically loaded dlls. And Process Explorer which will makes it very easy to examine the various modules loaded into a particular process.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!