: I finally was able to get the dll working, but when i compile the executable that calls the dll i get the following warning message.
:
: warning C4113: 'int (__stdcall *)()' differs in parameter lists from 'int (__stdcall *)(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int )'
:
: The dll project has an entry point as well as the winmain function. I also declare the winmain in the calling program as int WINAPI WinMain(....);
: then in the calling program i load the library that contains the exported function WinMain with an alias CMyFunc.
: In the calling function i declare a function pointer as follows:
: int (WINAPI * fptr)(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpCmdLine,int nShowCmd);
: I use that function pointer to call GetProcAddress(hinst,"CMyFunc").
: That's the line that gives me the warning message. Otherwise the program works fine, it calls the DLL and it's great. Thanks, but i am concerned about the warning because i think i am doing everything correctly. Any ideas anyone ?
: Below is the code i am using in the calling program.
: hinstLib = LoadLibrary("mirpdll.dll");
: if( hinstLib != NULL)
: {
: fptr = GetProcAddress(hinstLib,"CMyFunc");
: if (fRunTimeLinkSuccess = (fptr != NULL))
: (fptr(hInst,NULL,str,0)) ;
:
: // Free the DLL module.
:
: fFreeResult = FreeLibrary(hinstLib);
:
: }
:
Answer is simple :)
GetProcAddress returns pointer of type void (__stdcall *)(void). You need to cast it to correct form. In your case like this:
fptr = (int (WINAPI *)(HINSTANCE,HINSTANCE,LPSTR,int))GetProcAddress(...)