Results 1 to 5 of 5

Thread: What api call should I use.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143
    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.

  2. #2
    Guest
    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.
    Code:
    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143
    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]

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143
    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
    Code:
    Public Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, _
        ByVal lpWindowName As String) As Long
    Code:
    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

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143
    Never mind I found out how to do it.
    Code:
    Dim hwnd As Long
        hwnd = FindWindowEx(0, 0, "exploreWClass", vbNullString)
        If hwnd <> 0 Then SendMessage hwnd, WM_CLOSE, 0, 0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width