该程序已被运行,但是MAINFORM的属性被设置为隐藏;再次运行时通过process.Id获知程序已运行并获得句柄instance.MainWindowHandle该如何利用这个句柄改变MAINFORM的属性并显示出来呢? [DllImport("User32.dll")] private static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("User32.dll")] private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
[DllImport("user32.dll")] public static extern int ShowWindow(IntPtr hwnd,int nCmdShow);这3个似乎都不行
[DllImport("User32.dll")] private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
[DllImport("user32.dll")] public static extern int ShowWindow(IntPtr hwnd,int nCmdShow);这3个似乎都不行
this.notifyIcon1.Visible=true;
Form main = Control.FromHandle(instance.MainWindowHandle) as Form;if (main != null)
{
main.WindowState = FormWindowState.Normal;
}main = null;
Form main = Control.FromHandle(instance.MainWindowHandle) as Form;if (main != null)
{
main.WindowState = FormWindowState.Normal;
}main = null;
main.Show();
//前提要将notifyIcon1设为public或用公共属性封装...
main.notifyIcon1.Visible = false;
//^o^