Guest User

Untitled

a guest
Jan 11th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. int main(){
  2. HINSTANCE lib2_handle;
  3. LPCWSTR lib2_name = L"../lib2.dll";
  4. lib2_handle = LoadLibraryW(lib2_name);
  5. if (!lib2_handle) {
  6. ErrorExit();
  7. return -2;
  8. }
  9. return 0;
  10. }
  11.  
  12. void ErrorExit(){
  13. // Retrieve the system error message for the last-error code
  14. LPVOID msgBuf;
  15. DWORD errCode = GetLastError();
  16.  
  17. FormatMessage(
  18. FORMAT_MESSAGE_ALLOCATE_BUFFER |
  19. FORMAT_MESSAGE_FROM_SYSTEM |
  20. FORMAT_MESSAGE_IGNORE_INSERTS, //Flags
  21. NULL, //Source
  22. errCode, //MsgID
  23. MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //LanguageID
  24. (LPTSTR)&msgBuf, //BufferPointer
  25. 0, NULL); //MinimumBufferSize, Arguments
  26.  
  27. // Display the error message
  28. printf("Process %d exitted with system error: %dn", GetCurrentProcessId(), errCode);
  29. printf("%sn", (LPTSTR)msgBuf);
  30.  
  31. LocalFree(msgBuf);
  32. return -3;
  33. }
Add Comment
Please, Sign In to add comment