Ich verwende die 'LoadLibrary' von der Windows-API. Beim Ausführen der Anwendung wird ein Fehlercode 126 ausgegeben. Ich habe gelesen, dass dies durch Abhängigkeiten verursacht werden kann. Ich habe bei einigen Anwendungen wie Dependency Walker überprüft, was nicht stimmt war in Ordnung.
LoadLibrary in der Anwendung:
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");
}
}
Der Windows-DLL-Fehler 126 kann viele Ursachen haben. . Die nützlichsten Methoden, die ich zum Debuggen gefunden habe, sind:
Dieser Fehler kann auftreten, weil einige MFC-Bibliothek (zB mfc120.dll), von der DLL abhängig ist, im Ordner windows/system32 fehlt.