# Re: 如何强迫停止一个正在执行的程式??

Posted by dino on August 24, 1999 at 00:01:06:

In Reply to: 如何强迫停止一个正在执行的程式?? posted by 小甜甜.... on August 23, 1999 at 22:48:35:

Private Declare Function OSWinHelp% Lib "user32" Alias "WinHelpA" (ByVal hwnd&, ByVal HelpFile$, ByVal wCommand%, dwData As Any)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

以下去强迫关毕小算盘

Dim winHwnd As Long
Dim RetVal As Long
winHwnd = FindWindow(vbNullString, "小算盘")
Debug.Print winHwnd
If winHwnd <> 0 Then
RetVal = PostMessage(winHwnd, &H10, 0&, 0&)
'If RetVal = 0 Then
' MsgBox "Error posting message."
'End If
Else
'MsgBox "The Calculator is not open."
End If

Follow Ups: