private static void AsyncCallUnsafeDelegate(string fncName, IntPtr hWnd) { FfdShowConfigureData data = null; IntPtr module = IntPtr.Zero; module = Kernel32.GetModuleHandle(ModuleName); if (module == IntPtr.Zero) { module = Kernel32.LoadLibrary(InstallLocation); } if (module != IntPtr.Zero) { IntPtr proc = Kernel32.GetProcAddress(module, fncName); if (proc != IntPtr.Zero) { try { data = new FfdShowConfigureData(proc, hWnd); } catch { data = null; } } } if (data != null) { ThreadPool.QueueUserWorkItem(new WaitCallback(CallUnsafeDelegate), data); } }
private static void CallUnsafeDelegate(object state) { try { FfdShowConfigureData data = state as FfdShowConfigureData; if (data != null && data._delegate != null) { string cwd = Directory.GetCurrentDirectory(); if (!data._isDynamicDelegate) { Directory.SetCurrentDirectory(Path.GetDirectoryName(InstallLocation)); } unsafe { Ole32.CoUninitialize(); if (data._delegate != null) { data._delegate(data._hwnd, IntPtr.Zero, string.Empty, ShowWindowStyles.SW_NORMAL); } } if (!data._isDynamicDelegate) { Directory.SetCurrentDirectory(cwd); } } } catch { } }