2016-09-14 6 views
0

私はwinformからアプリケーションを開いています。私は開封後にそのアプリケーションに焦点を当てたい。現在、私はそれを開くと、winformの背後に開きます。誰でも私を始める方法を知っていますか?ここで私は、フォームから自分のアプリケーションを開いています方法は次のとおりです。開いているアプリケーションに焦点を当てますか?

Process.Start("C:\myapplication.exe") 
'set focus to that particular application or bring it in front of the winform application. 

答えて

0

あなたのクラス内のどこかにこの宣言を追加してみてください:

Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As IntPtr 

...とこのようプロセスを開始:

Dim p As New System.Diagnostics.Process 
p.StartInfo.FileName = "C:\myapplication.exe" 
p.StartInfo.CreateNoWindow = False 
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized 
p.Start() 
SetForegroundWindow(p.Handle) 
関連する問題