我正在编写一个加载 Winamp 输入插件的包装程序。到目前为止,我已经让它在相当多的插件上运行良好,但对于其他一些插件,当我尝试在插件的 DLL 上调用 LoadLibrary 时,我在运行时收到一条错误消息。(这似乎主要发生在 Winamp 附带的插件中。)出现一个对话框,并给我上面的错误代码和消息。例如,in_flac.dll 和 in_mp3.dll 插件(Winamp 附带)会发生这种情况。关于如何补救这种情况的任何想法?
编辑:这基本上遍历目录中的插件并尝试加载然后释放每个插件。一些插件会产生我上面提到的错误,而另一些则不会。
wstring path = GetSearchPath();
FileEnumerator e(path + L"in_*.dll");
while(e.MoveNext()) {
wstring pluginPath = path + e.GetCurrent().cFileName;
MessageBoxW(NULL, pluginPath.c_str(), L"Message", MB_OK);
HINSTANCE dll = LoadLibraryW(pluginPath.c_str());
if(!dll) {
pluginPath = wstring(L"There was an error loading \"") + wstring(e.GetCurrent().cFileName) + L"\":\n" + LastErrorToString();
MessageBoxW(NULL, pluginPath.c_str(), L"Error", MB_OK);
continue;
}
FreeLibrary(dll);
}