tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,926
- Office Version
- 365
- 2019
- Platform
- Windows
According to this thread:
this code closes a session of Windows Explorer:
What I am puzzled about is this line:
FindWindow takes two arguments, so I assume CabinetWClass and vbnullstring takes care of that but what are the three remaining arguments for, ie WM_CLOSE, 0, 0?
PostMessage requires four arguments, ie hwnd, wMsg, wParam and lParam.
Thanks
EDIT SORTED:
I missed the first argument is FindWindow.
Rich (BB code):
this code closes a session of Windows Explorer:
Rich (BB code):
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
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 Const WM_CLOSE = &H10
Public Sub CloseExplorer()
CloseByClass "CabinetWClass"
End Sub
Private Sub CloseByClass(className As String)
PostMessage FindWindow("CabinetWClass", vbNullString), WM_CLOSE, 0, 0
End Sub
What I am puzzled about is this line:
Rich (BB code):
PostMessage FindWindow("CabinetWClass", vbNullString), WM_CLOSE, 0, 0
FindWindow takes two arguments, so I assume CabinetWClass and vbnullstring takes care of that but what are the three remaining arguments for, ie WM_CLOSE, 0, 0?
PostMessage requires four arguments, ie hwnd, wMsg, wParam and lParam.
Thanks
EDIT SORTED:
I missed the first argument is FindWindow.
Last edited: