daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Jan 11th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top