gpt4 book ai didi

c++ - DLL 加载库 - 错误代码 126

转载 作者:IT老高 更新时间:2023-10-28 12:42:32 24 4
gpt4 key购买 nike

我正在使用 Windows API 中的“LoadLibrary”,当我运行应用程序时,它会抛出错误代码 126。我读到它可能是由依赖关系引起的,我检查了一些应用程序(如 Dependency Walker)有什么问题,但一切都很好。

应用程序中的LoadLibrary:

            HMODULE dll_mod = LoadLibrary(L"path_to_dll");
if(dll_mod==NULL){
std::stringstream error;
error << "Could not load plugin located at:\n" << file_full.toStdString() << "\n" << "Error Code: " << GetLastError();
FreeLibrary(dll_mod);
return error.str();
}

插件代码:

#include "stdafx.h"
#define DLL_EXPORT
#define PLUGIN_STREAM __declspec(dllexport)
#include <iostream>
#include <vector>
using std::vector;
using std::string;
// Init event (After the loading)
extern "C"{
PLUGIN_STREAM int onInit(char* argv){
return 0;
}
PLUGIN_STREAM void pluginInfo(vector<string> & info){
info.push_back("media_event=false");
info.push_back("status_event=false");
info.push_back("send_event=true");
info.push_back("plugin_name='RadioStream'");
info.push_back("description='This plugin was designed for that people that wants to listen to radio music.\nYou can register your radio and play it later, also we have a gallery of radios that you can check.\nThis plugin is original of Volt and it's originally implemented in the application.'");
info.push_back("success:0");
info.push_back("error:1=Could not open data file");
info.push_back("error:2=Could not prepare plugin");
info.push_back("alert:40=Could not connect to that radio");
}
}

最佳答案

Windows dll 错误 126 可能有许多根本原因。我发现的最有用的调试方法是:

  1. 使用依赖遍历器查找任何明显的问题(您已经完成了)
  2. 使用 sysinternals 实用程序进程监视器 https://learn.microsoft.com/en-us/sysinternals/downloads/procmon来自 Microsoft 以在您的 dll 尝试加载时跟踪所有文件访问。使用此实用程序,您将看到该 dll 试图引入的所有内容,并且通常可以从那里确定问题。

关于c++ - DLL 加载库 - 错误代码 126,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14361992/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com