PDA

Click to See Complete Forum and Search --> : What api call should I use.


Help
Jan 5th, 2001, 09:38 AM
Morning,

What api calls should I use for this problem.
When users runs my *.exe I would like to see if the windows exployer is open. If windows exployer is open I would then like to exit it, and or minimize it.

Thanks.

Jan 5th, 2001, 09:57 AM
By 'Explorer' do you mean any folder that's open? If that's the case, then simply do a global hWnd search for any window of the CabinetWClass; if any is found than exit.

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 Form_Load()
If FindWindowEx(0, 0, "CabinetWClass", vbNullString) <> 0 Then Unload Me
End Sub

Help
Jan 5th, 2001, 10:25 AM
Megatron,
For somereason it is not closing windows explorer. I am on a win 95 machine right now. Does this have anything to do w. it?

THe program does not error either. Just sits there :(



[Edited by help on 01-05-2001 at 11:39 AM]

Help
Jan 5th, 2001, 11:53 AM
I still cant get the above api call to work.
However I can use this one as well.
Only down fall is that I have the know the
exact path.

After I find the window How can I close it.

My code so far

Public Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long


Private Sub cmdFind_Click()
Dim hWnd As Long
Dim retval As Long
hWnd = FindWindow(vbNullString, "exploring - (C:)")
If hWnd <> 0 Then MsgBox "Found"
end sub

Now instead of messanging me that its found how do i close it :)
THanks

Help
Jan 5th, 2001, 01:20 PM
Never mind I found out how to do it.

Dim hwnd As Long
hwnd = FindWindowEx(0, 0, "exploreWClass", vbNullString)
If hwnd <> 0 Then SendMessage hwnd, WM_CLOSE, 0, 0