level 7
暴牙归来
楼主
定义函数及模块:
Private Declare Function PostMessage Lib "User32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const WM_CLOSE = &H10
==================
执行代码:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
winHwnd = FindWindow(vbNullString, "C:\Adobe.Photoshop\Photoshop.exe")
Debug.Print(winHwnd)
If winHwnd <> 0 Then
RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
If RetVal <> 0 Then
msgbox("关闭软件成功")
End If
End If
End Sub
2016年04月05日 04点04分
1
Private Declare Function PostMessage Lib "User32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const WM_CLOSE = &H10
==================
执行代码:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
winHwnd = FindWindow(vbNullString, "C:\Adobe.Photoshop\Photoshop.exe")
Debug.Print(winHwnd)
If winHwnd <> 0 Then
RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
If RetVal <> 0 Then
msgbox("关闭软件成功")
End If
End If
End Sub