Visual C#2010-Windowsフォームアプリケーションで外部プロセスを開始しようとしています。目標は、プロセスを非表示のウィンドウとして開始し、後でウィンドウを再表示することです。
進捗状況を更新しました:
//Initialization
[DllImport("user32.dll")]
private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("user32.dll")]
private static extern bool EnableWindow(IntPtr hwnd, bool enable);
[DllImport("user32.dll")]
private static extern bool MoveWindow(IntPtr handle, int x, int y, int width,
int height, bool redraw);
SW_SHOW = 5;
以下は私の主な機能に配置されました:
ProcessStartInfo info = new ProcessStartInfo("process.exe");
info.WindowStyle = ProcessWindowStyle.Hidden;
Process p = Process.Start(info);
p.WaitForInputIdle();
IntPtr HWND = p.MainWindowHandle;
System.Threading.Thread.Sleep(1000);
ShowWindow(HWND, SW_SHOW);
EnableWindow(HWND, true);
MoveWindow(HWND, 0, 0, 640, 480, true);
ただし、ウィンドウは「非表示」として開始されたため、p.MainWindowHandle = 0
。ウィンドウを正常に表示できません。私も試しHWND = p.Handle
ましたが成功しませんでした。
ウィンドウに新しいハンドルを提供する方法はありますか?これで問題が解決する可能性があります。
参照: