GetProcAddress doesnt find the function in my dll

Hi all!

I've just started dealing with dll-s for two days, but I got stucked and dont see how to move on..so to make my first steps, with some searching I created a Test.dll with a function fnTest() in it. Exactly it's prototype in the header file looks like the following:

__declspec(dllexport) int fnTest(void);

If I'm using implicit linking it's ok. The trouble is on when I try to link it explicitly.

HINSTANCE Testdll;
Testdll = LoadLibrary("Test.dll");

They are still good, it finds the Test.dll, but the GetProcAddress returns with NULL, although it should work..(The dll is correct, it worked while linking implicitly):

fnTestptr importaltfnTest;

importaltfnTest = (fnTestptr)GetProcAddress(Testdll,"fnTest");

where fnTestpr is: typedef int (*fnTestptr)();

I looked at the GetLastError function, it returns 127, but I dunno what that means..

Thank you ever so much for help! I cant move on on my own..:(



Answer this question

GetProcAddress doesnt find the function in my dll

  • Jay_Vora_b4843e

    To see the real name that is exported use DEPENDS.EXE or DUMPBIN /EXPORTS

  • leonlai

    You can only see the names. There is no way to get the kind of arguments that have to be used with a function.

    You need someting like a header!



  • thea.umali

    Oh...:((( That's what I was frightened about.. isn't here someone who is capable with Labview 'cause I've got a source code in it that is using this dll, but I dunno which labview type is equal with visual c++'s type..
  • Donaghy

    This is due to name mangling. You should look at def files.

  • DragonDave

    Thanks guys! The problem was the missing "extern "C" ". I would have another question: how can I get to know of the functions in a dll I know their names but not exactly their arguments.. is there any way of it
  • Yogev

    This is due to name mangling. One way to avoid this problem is to declare the export like below:

    #ifdef __cplusplus

    extern "C" {

    #endif

    __declspec(dllexport) int fnTest(void);

    #ifdef __cplusplus

    }

    #endif

    or you can write a .DEF file to declare your exports.

    Regards



  • GetProcAddress doesnt find the function in my dll