Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(){
- HINSTANCE lib2_handle;
- LPCWSTR lib2_name = L"../lib2.dll";
- lib2_handle = LoadLibraryW(lib2_name);
- if (!lib2_handle) {
- ErrorExit();
- return -2;
- }
- return 0;
- }
- void ErrorExit(){
- // Retrieve the system error message for the last-error code
- LPVOID msgBuf;
- DWORD errCode = GetLastError();
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS, //Flags
- NULL, //Source
- errCode, //MsgID
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //LanguageID
- (LPTSTR)&msgBuf, //BufferPointer
- 0, NULL); //MinimumBufferSize, Arguments
- // Display the error message
- printf("Process %d exitted with system error: %dn", GetCurrentProcessId(), errCode);
- printf("%sn", (LPTSTR)msgBuf);
- LocalFree(msgBuf);
- return -3;
- }
Add Comment
Please, Sign In to add comment