Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: win32 process name

Reply
Thread Tools

Re: win32 process name

 
 
Andrey Ivanov
Guest
Posts: n/a
 
      12-22-2004
[phil]

> 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?
> GetModuleFileNameEX?


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
example:

import sys
import win32event

STANDARD_ACCESS_READ = 131072

mutex_handle = None

try:
mutex_handle = win32event.OpenMutex(STANDARD_ACCESS_READ, False, "Test")
except:
pass

if mutex_handle:
sys.exit("Instance is already running")
else:
mutex_handle = win32event.CreateMutex(None, False, "Test")

try:
while 1:
pass
except:
pass


--
Andrey

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
win32/process Process.create failure Mike Stead Ruby 3 03-25-2010 01:15 AM
Win32/Process when create a process, how to pass data Qi Lu Ruby 0 07-14-2008 07:38 PM
win32 process information, using win32 extension Java and Swing Python 1 10-24-2005 09:13 PM
RE: win32 process information, using win32 extension Tim Golden Python 0 10-21-2005 02:18 PM
(Win32) Timing out a process while reading process' output? rtm Perl 0 09-27-2004 10:06 PM



Advertisments