public void LoadMidiModule() { IntPtr hmod = LoadLibrary("in_midi.dll"); if (hmod == IntPtr.Zero) { throw new Win32Exception(); } IntPtr proc = GetProcAddress(hmod, "winampGetInModule2"); if (proc == IntPtr.Zero) { throw new Win32Exception(); } PluginGetter getmod = (PluginGetter)Marshal.GetDelegateForFunctionPointer(proc, typeof(PluginGetter)); Ptr = getmod(); if (Ptr == IntPtr.Zero) { throw new Exception(); } hDllInstance = hmod; config = GetDelegate <ConfigFunc>(0 * IntPtr.Size); about = GetDelegate <AbountFunc>(1 * IntPtr.Size); init = GetDelegate <InitFunc>(2 * IntPtr.Size); quit = GetDelegate <QuitFunc>(3 * IntPtr.Size); getFileInfo = GetDelegate <GetFileInfoFunc>(4 * IntPtr.Size); infoBox = GetDelegate <InfoBoxFunc>(5 * IntPtr.Size); isOurFile = GetDelegate <IsOurFileFunc>(6 * IntPtr.Size); play = GetDelegate <PlayFunc>(7 * IntPtr.Size); pause = GetDelegate <PauseFunc>(8 * IntPtr.Size); unPause = GetDelegate <UnPauseFunc>(9 * IntPtr.Size); isPaused = GetDelegate <IsPausedFunc>(10 * IntPtr.Size); stop = GetDelegate <StopFunc>(11 * IntPtr.Size); getLength = GetDelegate <GetLengthFunc>(12 * IntPtr.Size); getOutputTime = GetDelegate <GetOutputTimeFunc>(13 * IntPtr.Size); setOutputTime = GetDelegate <SetOutputTimeFunc>(14 * IntPtr.Size); setVolume = GetDelegate <SetVolumeFunc>(15 * IntPtr.Size); setPan = GetDelegate <SetPanFunc>(16 * IntPtr.Size); savsaInit = GetDelegate <SAVSAInitFunc>(17 * IntPtr.Size); savsaDeInit = GetDelegate <SAVSADeInitFunc>(18 * IntPtr.Size); saAddPCMData = GetDelegate <SAAddPCMDataFunc>(19 * IntPtr.Size); saGetMode = GetDelegate <SAGetModeFunc>(20 * IntPtr.Size); saAdd = GetDelegate <SAAddFunc>(21 * IntPtr.Size); vsaAddPCMData = GetDelegate <VSAAddPCMDataFunc>(22 * IntPtr.Size); vsaGetMode = GetDelegate <VSAGetModeFunc>(23 * IntPtr.Size); vsaAdd = GetDelegate <VSAAddFunc>(24 * IntPtr.Size); vsaSetInfo = GetDelegate <VSASetInfoFunc>(25 * IntPtr.Size); dsp_isactive = GetDelegate <DSP_isactiveFunc>(26 * IntPtr.Size); dsp_dosamples = GetDelegate <DSP_dosamplesFunc>(27 * IntPtr.Size); eqSet = GetDelegate <EQSetFunc>(28 * IntPtr.Size); setInfo = GetDelegate <SetInfoFunc>(29 * IntPtr.Size); }
static void Main(string[] args) { IntPtr hmod = LoadLibrary("in_midi.dll"); if (hmod == IntPtr.Zero) { throw new Win32Exception(); } IntPtr proc = GetProcAddress(hmod, "winampGetInModule2"); if (proc == IntPtr.Zero) { throw new Win32Exception(); } PluginGetter getmod = (PluginGetter)Marshal.GetDelegateForFunctionPointer(proc, typeof(PluginGetter)); IntPtr modptr = getmod(); if (modptr == IntPtr.Zero) { throw new Win32Exception(); } Console.WriteLine("Success"); }