求教 关闭某程序 的代码
比如关闭 正在运行的1.exe
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Sub Command1_Click()
On Error Resume Next
aa = Shell("C:\WINDOWS\CALC.EXE", 1)
End Sub
Private Sub Command2_Click()
Const NILL = 0&
Const WM_SYSCOMMAND = &H112
Const SC_CLOSE = &HF060
lpClassName$ = "SciCalc"
lpCaption$ = "cc"
Handle = FindWindow(lpClassName$, lpCaption$)
X& = SendMessage(Handle, WM_SYSCOMMAND, SC_CLOSE, NILL)
End Sub
這個我記得只能關閉應用程序
我沒調試