|
在论坛上找到个例子,以下代码是这个例子的代码,(打开WINDOWS的记事本和关闭记事本),请问怎样改成打开和关闭WINDOWS的计算器??我的是WINDOWS2000系统。
Option Compare Database
Option Explicit
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)
Const WM_CLOSE = &H10
Private Sub 命令0_Click()
On Error GoTo Err_命令0_Click
Call Shell("NOTEPAD.EXE", 1)
Exit_命令0_Click:
Exit Sub
Err_命令0_Click:
MsgBox Err.Description
Resume Exit_命令0_Click
End Sub
Private Sub 命令1_Click()
On Error GoTo Err_命令1_Click
Dim hw&
hw& = FindWindow("NOTEPAD", vbNullString)
Call SendMessage&(hw&, WM_CLOSE, 0, 0)
Exit_命令1_Click:
Exit Sub
Err_命令1_Click:
MsgBox Err.Description
Resume Exit_命令1_Click
End Sub
|
|