'dll_file'可能为'0':这不符合功能'GetProcAddress'的规范]]

问题描述 投票:0回答:1

所以我想使用我创建的DLL,并且我收到了一个非常奇怪的警告,我没有看到有人检查过LoadLibray是否返回“ NULL”,但事实并非如此。

typedef DATA_BLOB(*encryption_decryption)(DATA_BLOB, bool*);
 HINSTANCE dll_file = LoadLibrary(L"dllForEncryptionNDecryptionn.dll");
  if (dll_file != NULL) {
    cout << "Library loaded!" << endl;
  }
  else {
    failed();
  }
  encryption_decryption encryption = (encryption_decryption)GetProcAddress(dll_file,"encryption");
  if(encryption != NULL)
  {
    cout << "Workded!" << endl;
  }
  else
  {
    failed();
  }
void failed() {
    cout << GetLastError() << endl;
    cout << "Faild!" << endl;
}

在第8行警告:“'dll_file'可能为'0':这不符合函数'GetProcAddress'的规范。”

一切正常,运行程序时不会显示任何错误消息。

因此,我想使用我创建的DLL,并且我收到了这个非常奇怪的警告,我没有看到有人检查过LoadLibray是否返回“ NULL”,但事实并非如此。 typedef DATA_BLOB(* ...

c++ dll getprocaddress
1个回答
0
投票

如果LoadLibrary中发生任何错误,则调用failed(),该错误会打印错误代码并返回。

© www.soinside.com 2019 - 2024. All rights reserved.