gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 10:38:51 28 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可能有很多根本原因。
我发现调试此功能最有用的方法是:

  • 使用依赖遍历器查找任何明显的问题(
    已经完成)
  • 在尝试加载dll时,请使用Microsoft的sysinternals实用程序Process Monitor http://technet.microsoft.com/en-us/sysinternals/bb896645跟踪所有文件访问。使用此实用程序,您将看到dll尝试插入的所有内容,通常可以从那里确定问题所在。
  • 关于c++ - DLL加载库-错误代码126,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55581011/

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