Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Determine if Win Explorer windows are open

Determine if Win Explorer windows are open

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    K4HVDs
    wrote on last edited by
    #1

    In VC++ and MFC: is it possible to find out that one or more Windows Explorer windows are open?

    L C 3 Replies Last reply
    0
    • K K4HVDs

      In VC++ and MFC: is it possible to find out that one or more Windows Explorer windows are open?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I think you could use the EnumProcesses() function as described in this sample[^].

      Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

      K 1 Reply Last reply
      0
      • L Lost User

        I think you could use the EnumProcesses() function as described in this sample[^].

        Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

        K Offline
        K Offline
        K4HVDs
        wrote on last edited by
        #3

        I think that normally Explorer is permanently load in memory. My interest is that it opened a window or more windows,

        _ 1 Reply Last reply
        0
        • K K4HVDs

          In VC++ and MFC: is it possible to find out that one or more Windows Explorer windows are open?

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          this might work: 1. EnumerateDesktopWindows to get a list of top-level windows 2. for each of those, use GetWindowProcessThreadId to get the process ID that owns the window. 3. follow the steps here http://stackoverflow.com/questions/4570174/how-to-get-process-name-in-c[^] to get the module name. 4. look for "explorer.exe"

          image processing toolkits | batch image processing

          1 Reply Last reply
          0
          • K K4HVDs

            I think that normally Explorer is permanently load in memory. My interest is that it opened a window or more windows,

            _ Offline
            _ Offline
            _Superman_
            wrote on last edited by
            #5

            Here is one way to do this - Use EnumProcesses to enumerate all running processes. For each process id returned, call GetProcessImageFileName to check if it belongs to explorer.exe You will need to do OpenProcess on the process id to get its handle. After you get the process id of explorer.exe, enumerate all open windows using EnumWindows. For each window handle returned, use it in the function GetWindowThreadProcessId to check if it belongs to explorer.exe This process of finding open explorer.exe windows could be time consuming. Another way to do this would be to write a Browser Helper Object (BHO) which explorer.exe windows will load on startup. In the BHO you can keep track of open explorer windows and more. Here is some more information on BHOs - Browser Helper Objects: The Browser the Way You Want It[^] Here is how to build a BHO using Visual Studio - Building Browser Helper Objects with Visual Studio 2005[^]

            «_Superman_»  _I love work. It gives me something to do between weekends.

            _Microsoft MVP (Visual C++)

            Polymorphism in C

            1 Reply Last reply
            0
            • K K4HVDs

              In VC++ and MFC: is it possible to find out that one or more Windows Explorer windows are open?

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Hi, You could create a ShellWindows object[^] and call get_Count(); Something like this:

              INT GetExplorerCount()
              {
              LONG lCount = 0;
              IShellWindowsPtr shell;
              shell.CreateInstance(__uuidof(ShellWindows));
              shell->get_Count(&lCount);
              return lCount;
              }

              Don't forget to CoInitialize. Also keep in mind that Internet Explorer and Windows Explorer are integrated... you will need to add some code to filter out instances of IE. Control panel windows are also shell windows. Best Wishes, -David Delaune

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups