Advertisement
PorisulkiP

PredictModule as dll

Jul 6th, 2023 (edited)
720
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | Software | 0 0
  1. void CClientLazyCache::ClearPredictModuleHandles() const
  2. {
  3.     FreeLibrary(m_predictDll);
  4. }
  5.  
  6. bool CClientLazyCache::ReloadPredictModule()
  7. {
  8.     CString sDirectory = GetModuleDirectory() + L"Predict_module.dll";
  9.     if (PathFileExists(sDirectory) == FALSE)
  10.     {
  11.         MessageBox(nullptr, GetStr(IDS_LOAD_PREDICT_ERROR), GetStr(IDS_CLIENT_ERR_CAPTION), MB_OK);
  12.         return false;
  13.     }
  14.  
  15.     ClearPredictModuleHandles();   
  16.  
  17.     m_predictDll = LoadLibrary(sDirectory);
  18.     if (!m_predictDll)
  19.     {
  20.         DWORD dw = GetLastError();
  21.         LPVOID lpMsgBuf;
  22.         FormatMessage(
  23.             FORMAT_MESSAGE_ALLOCATE_BUFFER |
  24.             FORMAT_MESSAGE_FROM_SYSTEM |
  25.             FORMAT_MESSAGE_IGNORE_INSERTS,
  26.             nullptr,
  27.             dw,
  28.             MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
  29.             (LPTSTR) &lpMsgBuf,
  30.             0, nullptr);
  31.  
  32.         // Вывести сообщение об ошибке
  33.         MessageBox(nullptr, (LPCTSTR)lpMsgBuf, TEXT("Error"), MB_OK | MB_ICONERROR);
  34.  
  35.         // Освободить буфер
  36.         LocalFree(lpMsgBuf);
  37.  
  38.         return false;
  39.     }
  40.  
  41.     return true;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement