49

I'm using the 'LoadLibrary' from the Windows API, when I run the application, it throws me an error code 126. I read that it may be caused by dependencies, I checked what's wrong with some applications like Dependency Walker, but everything was fine.

LoadLibrary in the application:

            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();
            }

Plugin code:

#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");
}
}
4

4 に答える 4

94

Windowsdllエラー126は多くの根本的な原因があります。これをデバッグするために私が見つけた最も便利な方法は次のとおりです。

  1. 依存関係ウォーカーを使用して、明らかな問題を探します(すでに行っています)
  2. MicrosoftのsysinternalsユーティリティProcessMonitorhttps://docs.microsoft.com/en-us/sysinternals/downloads/procmonを使用して dllがロードしようとしている間のすべてのファイルアクセスをトレースします。このユーティリティを使用すると、そのdllがプルしようとしているすべてのものが表示され、通常はそこから問題を特定できます。
于 2013-01-16T15:46:07.677 に答える
9

これは、DLLを読み込もうとしていて、見つからない別のDLLが必要な場合にも発生する可能性があります。

于 2020-04-07T03:40:34.127 に答える
4

このエラーは、DLLが依存している一部のMFCライブラリ(mfc120.dllなど)がwindows/system32フォルダーにないために発生する可能性があります。

于 2017-09-19T09:10:00.123 に答える
-1

これは私のために働いたVisualC++再頒布可能パッケージ

于 2020-02-07T18:23:37.430 に答える