I am trying to load a Winamp input plugin and work with it in C#. According to the Winamp SDK, this is the proper way to load a plugin:
in_mp3_lib = LoadLibraryW(path);
if (in_mp3_lib)
{
PluginGetter pluginGetter = (PluginGetter)GetProcAddress(in_mp3_lib, "winampGetInModule2");
if (pluginGetter)
{
in_mp3 = pluginGetter();
}
}
So I've created a similar code in C#:
[DllImport("kernel32", SetLastError=true, CharSet=CharSet.Unicode)]
static extern IntPtr LoadLibrary(string lpFileName);
[DllImport("kernel32", CharSet=CharSet.Ansi, ExactSpelling=true, SetLastError=true)]
static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
delegate IntPtr PluginGetter();
IntPtr hmod = LoadLibrary("in_midi.dll");
var getmod = (PluginGetter)Marshal.GetDelegateForFunctionPointer(GetProcAddress(hmod, "winampGetInModule2"), typeof(PluginGetter));
IntPtr modptr = getmod();
However, on the line with LoadLibrary
, an error (not exception) window is shown:
---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Runtime Error!
Program: C:\Users\...
R6034
An application has made an attempt to load the C runtime library incorrectly.
Please contact the application's support team for more information.
---------------------------
OK
---------------------------
And hmod
is null.
Apparently, the plugin tries to load msvcrt90.dll, but this error keeps showing even if I have it in the directory.
Aucun commentaire:
Enregistrer un commentaire