how do you see if a dir is open or not
Printable View
how do you see if a dir is open or not
Use the FindWindow and FindWindowEx api functions.
That's to see if A folder is open. If you want to find out if a specific folder is open or not:Code:Private Declare Function FindWindow Lib "user32.dll" _
Alias "FindWindowA" (ByVal lpClassName As Any, ByVal _
lpWindowName As Any) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Sub Command1_Click()
Dim cabinetwclass As Long, shelldlldefview As Long, internetexplorerserver As Long
Dim atlshellembedding As Long, syslistview As Long
cabinetwclass = FindWindow("cabinetwclass", vbNullString)
shelldlldefview = FindWindowEx(cabinetwclass, 0&, "shelldll_defview", vbNullString)
internetexplorerserver = FindWindowEx(shelldlldefview, 0&, "internet explorer_server", vbNullString)
atlshellembedding = FindWindowEx(internetexplorerserver, 0&, "atl shell embedding", vbNullString)
syslistview = FindWindowEx(atlshellembedding, 0&, "syslistview32", vbNullString)
If cabinetwclass <> 0 Then
MsgBox "Folder open"
Else
MsgBox "Folder closed"
End If
End Sub
Code:Private Sub Command1_Click()
hWin = FindWindow(vbNullString, "Folder caption")
If hWin <> 0 Then
MsgBox "Folder open"
Else
MsgBox "Folder closed"
End If
End Sub