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. Database & SysAdmin
  3. System Admin
  4. Is program in use (under Windows)?

Is program in use (under Windows)?

Scheduled Pinned Locked Moved System Admin
comalgorithmstutorialquestionannouncement
3 Posts 3 Posters 4 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.
  • P Offline
    P Offline
    Phil Davidson
    wrote on last edited by
    #1

    What's a simple, reliable way to determine whether a program file (.EXE or .DLL, etc.) is in use under any version of Windows? For example, attempting to delete a program file that's currently running will usually result in Access Denied. We'd like to test this condition before we start deleting files. The following article gives code to enumerate all processes and to display all the module filenames used by the processes. (Remember that a process may be using multiple DLLs.) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/psapi\_9cc3.asp You can find the article in the MSDN library by searching for the title "Enumerating All Modules For a Process". Some possible limitations with this approach: 1) Is it supported in all versions of Windows since 95? 2) When run in administrator mode (in WinNT, Win2000, WinXP Pro) will it also report files used by other logged-in users? -- Phil Davidson phil.davidson@broderbund.com phil@phildavidson.com

    M L 2 Replies Last reply
    0
    • P Phil Davidson

      What's a simple, reliable way to determine whether a program file (.EXE or .DLL, etc.) is in use under any version of Windows? For example, attempting to delete a program file that's currently running will usually result in Access Denied. We'd like to test this condition before we start deleting files. The following article gives code to enumerate all processes and to display all the module filenames used by the processes. (Remember that a process may be using multiple DLLs.) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/psapi\_9cc3.asp You can find the article in the MSDN library by searching for the title "Enumerating All Modules For a Process". Some possible limitations with this approach: 1) Is it supported in all versions of Windows since 95? 2) When run in administrator mode (in WinNT, Win2000, WinXP Pro) will it also report files used by other logged-in users? -- Phil Davidson phil.davidson@broderbund.com phil@phildavidson.com

      M Offline
      M Offline
      moliate
      wrote on last edited by
      #2

      PSAPI is only available under NT. If you would like to enumerate processes and modules under Win9x, I suggest using ToolHelp:s process-snapshot (tlhelp32.h). It seems rater reliable, but I don´t know how it will work with other logged-in users (probably won´t).

      1 Reply Last reply
      0
      • P Phil Davidson

        What's a simple, reliable way to determine whether a program file (.EXE or .DLL, etc.) is in use under any version of Windows? For example, attempting to delete a program file that's currently running will usually result in Access Denied. We'd like to test this condition before we start deleting files. The following article gives code to enumerate all processes and to display all the module filenames used by the processes. (Remember that a process may be using multiple DLLs.) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/psapi\_9cc3.asp You can find the article in the MSDN library by searching for the title "Enumerating All Modules For a Process". Some possible limitations with this approach: 1) Is it supported in all versions of Windows since 95? 2) When run in administrator mode (in WinNT, Win2000, WinXP Pro) will it also report files used by other logged-in users? -- Phil Davidson phil.davidson@broderbund.com phil@phildavidson.com

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

        how about trying to open the file in an exclusive sharing mode?

        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