The following code is put into the module.
Declare? Function? FindWindow? Lib? "user 32" Alias? “FindWindowA”? (ByVal? lpClassName? As? String,? ByVal? lpWindowName? As? String)? As? Dragon? FindWindowAPI function
Declare? Function? Leave a message? Lib? "user 32" Alias? "Post SMS"? (ByVal? hwnd? As? Dragon? ByVal? wMsg? As? Dragon? ByVal? wParam? As? Dragon? lParam? As? Any)? As? Dragon? PostMessageAPI function
Public? Const? WM_CLOSE? =? & ampH 10? Common variable definition
Program code
Dim? winHwnd? As? Dragon? Define a long integer variable winHwnd.
Dim? RetVal? As? Dragon? Define a long integer variable RetVal.
winHwnd? =? FindWindow(vbNullString,? "calculator")? The API function finds the Calculator window.
Debugging. Print? winHwnd? The display handle for this window.
What if? winHwnd? & lt& gt? 0? then what If it is not 0, the window is found.
RetVal? =? PostMessage(winHwnd,WM_CLOSE,? 0 & amp,? 0 & amp)? Send a close message to this window.
What if? RetVal? =? 0? then what If the returned information is 0, it means failure and transmission is unsuccessful.
MsgBox? "wrong? Posting? News. " ? Prompt sending failed.
End? if
other
MsgBox? "That? Calculator? Is it? Isn't it? Open. " ? Prompt that the open program cannot be found.
End? if