Is program in use (under Windows)?
-
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
-
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
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).
-
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