Option Explicit 'SampleNo=074 WindowsXP VB6.0(SP5) 2002.05.16
'既存のプロセスオブジェクトのハンドルを取得(P665)
Private Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
'指定のプロセスの終了コードを取得(P660)
Private Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, lpExitCode As Long) As Long
'開かれているオブジェクトのハンドルを開放する(P1252)
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Const PROCESS_QUERY_INFORMATION = &H400&
Private Const STILL_ACTIVE = &H103&
Sub pcom()
Dim IDProcess As Long
Dim hProcess As Long
Dim ExitCode As Long
Dim ret As Long
' プロセスを入れる↓
IDProcess = Shell("notepad.exe")
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, 1, IDProcess)
Do
ret = GetExitCodeProcess(hProcess, ExitCode)
DoEvents
Loop While (ExitCode = STILL_ACTIVE)
ret = CloseHandle(hProcess)
End Sub
'上記を貼り付けるだけ
'動作不具合による責任は負いません
0 件のコメント:
コメントを投稿