Не срабатывает функция TerminateProcess (WinXP,Win2000) Есть идеи?
Private Declare Function TerminateProcess Lib "kernel32" _ (ByVal hProcess As Long, _ ByVal uExitCode As Long) As Long Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
Private Sub Form_Load() Dim Pid&, di&
Pid& = FindWindow(vbNullString, "Project1") If Pid& <> 0 Then di& = TerminateProcess(Pid&, 0&) End Sub
'находим id процесса Function FindProc(strPrilName As String) As Long
Dim hSnapShot As Long Dim uProcess As PROCESSENTRY32 Dim r As Long
hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&) If hSnapShot = 0 Then Exit Function End If
uProcess.dwSize = Len(uProcess) r = ProcessFirst(hSnapShot, uProcess) Do While r If InStr(1, uProcess.szExeFile, strPrilName) Then FindProc = uProcess.th32ProcessID Call CloseHandle(hSnapShot) Exit Function End If
r = ProcessNext(hSnapShot, uProcess) Loop
Call CloseHandle(hSnapShot)
End Function
Ответить
|