Exporting a function from a DLL
-
Hello, I don't manage to export a procedure from a DLL. I created a Win32 Dynamic Link Library with a function which declaration is: __declspec(dllexport) BOOL Ping(UINT uiTimeout); When I look at the overview of my resulting dll, I can see my function 'Ping' in the export table but I can't get its address from another project. In my project, I load the dll thanks to 'AfxLoadLibrary' but when I use 'GetProcAddress' to get the address of the 'Ping' function, I get a NULL pointer: typedef BOOL (* PINGFUNCTION)(UINT); HINSTANCE hDLL = AfxLoadLibrary(m_szControl); if (hDLL) { // Get the address of the ping function FARPROC pnProc = GetProcAddress((HMODULE) hDLL, "Ping"); PINGFUNCTION MyPingFunction = (PINGFUNCTION) pnProc; if (! MyPingFunction) { return ((int) GetLastError()); } }
-
Hello, I don't manage to export a procedure from a DLL. I created a Win32 Dynamic Link Library with a function which declaration is: __declspec(dllexport) BOOL Ping(UINT uiTimeout); When I look at the overview of my resulting dll, I can see my function 'Ping' in the export table but I can't get its address from another project. In my project, I load the dll thanks to 'AfxLoadLibrary' but when I use 'GetProcAddress' to get the address of the 'Ping' function, I get a NULL pointer: typedef BOOL (* PINGFUNCTION)(UINT); HINSTANCE hDLL = AfxLoadLibrary(m_szControl); if (hDLL) { // Get the address of the ping function FARPROC pnProc = GetProcAddress((HMODULE) hDLL, "Ping"); PINGFUNCTION MyPingFunction = (PINGFUNCTION) pnProc; if (! MyPingFunction) { return ((int) GetLastError()); } }
i use: extern "C" int __declspec(dllexport) __stdcall FuncName(param 1, param 2,etc) the "int" is the data type returned from the function works for me :) "every year we invent better idiot proof systems and every year they invent better idiots"