他のプロセスのメインウィンドウハンドルを取得する

宣言部

[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd,int nCmdShow);
[DllImport("user32.dll")]
private static extern bool IsIconic(IntPtr hWnd);
private const int SW_RESTORE = 9; // 画面を元の大きさに戻す


処理部

if (IsIconic(hWnd))
{
 ShowWindowAsync(hWnd, SW_RESTORE);
}

SetForegroundWindow(hWnd);
最終更新:2010年06月12日 17:56