- PR -

アプリケーションから起動元アプリケーションに戻る

1
投稿者投稿内容
いっこさん
ベテラン
会議室デビュー日: 2003/07/03
投稿数: 67
投稿日時: 2004-11-11 11:15
いつもお世話になっております。

現在、以下のようなことを実現させようと思います。

1)アプリケーションA・B・Cがある
2)Aにはボタンが配置されており、それぞれを押下するとB・Cが起動する
コード:
    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
        Dim p As New Diagnostics.Process    'Process
        Dim strProc As Object
        With p.StartInfo
            .Arguments = "test command"
            .WorkingDirectory = "D:¥STEC_SRC¥WindowsApplication3¥bin"
            .FileName = "D:¥STEC_SRC¥WindowsApplication3¥bin¥WindowsApplication3.exe"
            .WindowStyle = ProcessWindowStyle.Normal
        End With

        Try
            p.Start()                   'Process開始
            p.WaitForInputIdle()        'アイドル状態になるまで待つ
        Catch ex As Exception
            Console.WriteLine(ex.ToString)
        Finally
            p.Close()
        End Try

    End Sub


3)BまたはCのアプリケーションが終了したとき、Aがアクティブになる
4)BまたはCが起動中、Aの操作は可能とする

3)のBまたはCが終了したことを判断するにはどうすればよいでしょうか。
実現方法があればご教示お願いします。

#¥は半角です。
_________________
いっこさん
ベテラン
会議室デビュー日: 2003/07/03
投稿数: 67
投稿日時: 2004-11-11 11:53
以下のような方法で実現できました。

コード:
    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
        Dim p As New Diagnostics.Process     'Process

        With p.StartInfo
            .Arguments = "test command"
            .WorkingDirectory = "D:\STEC_SRC\WindowsApplication3\bin"
            .FileName = "D:\STEC_SRC\WindowsApplication3\bin\WindowsApplication3.exe"
            .WindowStyle = ProcessWindowStyle.Normal
        End With

        Try
            p.Start()                   'Process開始
            p.WaitForInputIdle()        'アイドル状態になるまで待つ
            p.EnableRaisingEvents = True
            AddHandler p.Exited, AddressOf active
        Catch ex As Exception
            Console.WriteLine(ex.ToString)
        Finally
            'p.Close()
        End Try

    End Sub
    Private Sub active(ByVal sender As Object, ByVal e As EventArgs)
        'MessageBox.Show("AP終了")
        Me.Show()
        Me.Activate()
    End Sub

1

スキルアップ/キャリアアップ(JOB@IT)