win32 process name
ai2009 at yandex.ru
Wed Dec 22 10:27:31 CET 2004
> I need to know if a process is running.
> not just python.exe
> but python.exe myapp
> from win32all
> EnumProcesses gives me the pids, then
> OpenProcess(pid) gives me a handle.
> Then what?
It won't do the right thing for you. As far as I know,
GetModuleFileNameEx() returns the name of a particular DLL, but what
you need to know is a *commandline*. I think that this is not possible
at all. Microsoft's examples use named mutexes to test whether the
process is already running or not. It is quite easy. Here's a quick
STANDARD_ACCESS_READ = 131072
mutex_handle = None
mutex_handle = win32event.OpenMutex(STANDARD_ACCESS_READ, False, "Test")
sys.exit("Instance is already running")
mutex_handle = win32event.CreateMutex(None, False, "Test")
More information about the Python-list