我有以下代码:
typedef int (WINAPI* fnEngineStart)();
int __stdcall EngineStart()
{
BOOL FreeResult = 0, RunTimeLinkSuccess = 0; //variables for later use
HMODULE LibraryHandle = 0; //Here the handle to API module/dll will be stored.
fnEngineStart fn = 0;
LibraryHandle = AfxLoadLibrary(L"FlowEngine.dll"); //get the handle of our API module
//so it will now be loaded.
if (LibraryHandle != NULL) //if the library loading was successfull..
{
fn = (fnEngineStart)GetProcAddress(LibraryHandle,
"fnEngineStart");
if (RunTimeLinkSuccess = (fn != NULL)) //if operation was successful...
{
int ReturnValue = fn(); //call messageboxa function
//from user32.dll
}
else
{
MessageBox(0, L"Error", 0, 0);
}
FreeResult = FreeLibrary(LibraryHandle);
//from this process...
return FreeResult; //routine was successful
}
return EXIT_FAILURE; //else, it failed
}
此代码适用于例如 user32.dll 和 MessageBoxA 但不是我自己的 dll ......
int __declspec(dllexport) __stdcall fnEngineStart()
{
MessageBox(0, L"Succes!", 0, 0);
return 0;
}
我如何使它也适用于我自己的 dll?提前致谢。