C# 已知进程PID,进程托盘运行,如何打开程序主窗口
已经记录下了进程的PID,用process.MainWindowHandle获得不了托盘程序的窗口句柄,只能是最小化的任务栏的,对于托盘程序我应该如何打开程序的主窗体,求高人
------解决方案-------------------- public static void HandleRunningInstance(Process instance)
{
//Make sure the window is not minimized or maximized
ShowWindowAsync(instance.MainWindowHandle, WS_SHOWNORMAL);
//Set the real intance to foreground window
SetForegroundWindow(instance.MainWindowHandle);
}
[DllImport("User32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
[DllImport("User32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
private const int WS_SHOWNORMAL = 1;