This code fails, and I have no idea why, it's been really bugging me, PLEASE HELP!!
main.cppappext.cppCode:#include <windows.h> typedef int (WINAPI *CommProt)(int); #define ReportError(x) MessageBox(0, TEXT(x), TEXT("Error"), MB_OK | MB_ICONERROR); int WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShow) { HMODULE hDLL = LoadLibrary("appext.dll"); if(hDLL == NULL) ReportError("Load of DLL failed."); CommProt CommFunc = (CommProt)GetProcAddress(hDLL,"Comm")); // This is where the error happens, the GetProcAddress() call fails. if(CommFunc == NULL) ReportError("Capture of function failed."); Comm(5); // This is where the program crashes. FreeLibrary(hDLL); hDLL = NULL; return 0; }-QuaytrixCode:#include <windows.h> int Comm(int nVar) { char szDom[MAX_PATH]; wsprintf(szDom, TEXT("Comm var %d."), nVar); MessageBox(0, szDom, TEXT("Comm"), MB_OK | MB_ICONINFORMATION); return 0; } BOOL APIENTRY DllMain(HANDLE hMod, DWORD ulCall, LPVOID lpRes) { return TRUE; }



LinkBack URL
About LinkBacks




CornedBee