Article ID: 168204
Article Last Modified on 7/1/2004
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
FindWindow and Visual Basic or SendMessage and Visual Basic
112649 : How to Get a Window's Class Name and Other Window Attributes
Additional query words: kbVBp500 kbVBp600 kbdse kbDSupport kbVBp
Keywords: kbhowto KB168204