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. Other Discussions
  3. Article Writing
  4. How do I get an application's .exe name using visual C++

How do I get an application's .exe name using visual C++

Scheduled Pinned Locked Moved Article Writing
c++helpquestiontutorialworkspace
3 Posts 3 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.
  • J Offline
    J Offline
    Jennifer Pinkton
    wrote on last edited by
    #1

    I have an application, prog B, that starts minimized. Another program, let's say winamp, currently has the focus. My program - prog B should be able to retrieve the .exe name based on whichever application that currently has the focus, in this case, winamp. I'm not sure how to go about and tackle this problem. Can somebody please help me out? Environment - Windows 2000 Thanks in advance,

    P R 2 Replies Last reply
    0
    • J Jennifer Pinkton

      I have an application, prog B, that starts minimized. Another program, let's say winamp, currently has the focus. My program - prog B should be able to retrieve the .exe name based on whichever application that currently has the focus, in this case, winamp. I'm not sure how to go about and tackle this problem. Can somebody please help me out? Environment - Windows 2000 Thanks in advance,

      P Offline
      P Offline
      Paolo Messina
      wrote on last edited by
      #2

      Search for GetWindowModuleFileName on MSDN, it should work only on Win2000 though. You may use it with GetForegroundWindow to retrieve the exe filename associated with the current foreground window. Cheers, Paolo.

      1 Reply Last reply
      0
      • J Jennifer Pinkton

        I have an application, prog B, that starts minimized. Another program, let's say winamp, currently has the focus. My program - prog B should be able to retrieve the .exe name based on whichever application that currently has the focus, in this case, winamp. I'm not sure how to go about and tackle this problem. Can somebody please help me out? Environment - Windows 2000 Thanks in advance,

        R Offline
        R Offline
        reiko
        wrote on last edited by
        #3

        If you want to track application's exe name based on current focus, I recommend you write small DLL to hook some events. You may need to hook couple of them like WH_CBT and WH_SHELL using SetWindowsHookEx(). From my experience, you need serious testing to make sure your DLL is really tracing focus movement. There are many ways to move focus to another application and covering all of them may need long time work. Once you have that DLL that will attach itself to exe by hooking function, then the filename of that exe can be obtained by GetModuleFileName(). Even if GetModuleFileName() won't work right for some application, you can use very powerfull ToolHelp32 functions to; 1 enumelate all processes 2 find process ID that matches what GetCurrentProcessId() returns Just for your info, if you unfamilier with DLL which attaches itself to exe by SetWindowsHookEx(), then take a look at Matt Pietrek's article MSJ No 12 Vol 6 (MouseWheel.DLL). Have fun! reiko

        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