「他のプロセスのメインウィンドウハンドルを取得する」の編集履歴(バックアップ)一覧はこちら
追加された行は緑色になります。
削除された行は赤色になります。
宣言部
// 外部プロセスのメイン・ウィンドウを起動するためのWin32 API
[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);
// ShowWindowAsync関数のパラメータに渡す定義値
private const int SW_RESTORE = 9; // 画面を元の大きさに戻す
----
処理部
// メイン・ウィンドウが最小化されていれば元に戻す
if (IsIconic(hWnd))
{
ShowWindowAsync(hWnd, SW_RESTORE);
}
// メイン・ウィンドウを最前面に表示する
SetForegroundWindow(hWnd);
宣言部
// 外部プロセスのメイン・ウィンドウを起動するためのWin32 API
[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);
// ShowWindowAsync関数のパラメータに渡す定義値
private const int SW_RESTORE = 9; // 画面を元の大きさに戻す
----
処理部
// メイン・ウィンドウが最小化されていれば元に戻す
if (IsIconic(hWnd))
{
ShowWindowAsync(hWnd, SW_RESTORE);
}
// メイン・ウィンドウを最前面に表示する
SetForegroundWindow(hWnd);