VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 打开和关闭其他应用
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:11340, 日期:2001-12-24
打开和关闭其他应用
 
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
打开应用:
Private Sub Command1_Click()
Shell "Calc.exe", vbNormalFocus
End Sub
关闭应用:
Private Sub Command2_Click()
Dim lpClassName As String
Dim lpCaption As String
Dim Handle As Long

Const NILL = 0&
Const WM_SYSCOMMAND = &H112
Const SC_CLOSE = &HF060&

lpClassName = "SciCalc"
lpCaption = "Calculator"
注释:* Determine the handle to the Calculator window.
Handle = FindWindow(lpClassName$, lpCaption$)
注释:* Post a message to Calc to end its existence.
Handle = SendMessage(Handle, WM_SYSCOMMAND, SC_CLOSE, NILL)
End Sub