タイトル | : Re^3: sleep関数の待機について |
記事No | : 13033 |
投稿日 | : 2008/09/10(Wed) 18:24 |
投稿者 | : 花ちゃん |
そのまま使用すればよかったはずですが。
下記を貼り付けて、CAD のパスだけ書き換えて試して見て下さい。
Option Explicit
Private Declare Function OpenProcess Lib "kernel32" _ (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Boolean, _ ByVal dwProcessId As Long) As Long Private Declare Function CloseHandle Lib "kernel32" _ (ByVal hObject As Long) As Long Private Declare Function WaitForInputIdle Lib "user32" _ (ByVal hProcess As Long, ByVal dwMilliseconds As Long) As Long Private Const SYNCHRONIZE As Long = &H100000
Private Sub Command1_Click() Dim TaskID As Long Dim hProcess As Long Dim Ret As Long TaskID = Shell("C:\Program Files\CAD\***.exe", vbMaximizedFocus) hProcess = OpenProcess(SYNCHRONIZE, False, TaskID) If hProcess = 0 Then MsgBox "ハンドルが取得できません" Exit Sub End If Ret = WaitForInputIdle(hProcess, &HFFFF) Call CloseHandle(hProcess) MsgBox "表示しました" End Sub
|