[python-win32] Re: Memory Usage for Processes

2005-02-10 Thread Roger Upole
You'll need to use PROCESS_QUERY_INFORMATION and PROCESS_VM_READ. win32process.EnumProcessModules returns the list of module handles, with the main executable being the first one returned. Somebody also reported you can just use 0 for the module handle to get the executable. Also, on Win2k and

RE: [python-win32] Re: Memory Usage for Processes

2005-02-10 Thread Tom Haddon
Sorry, a little quick on the trigger there. I have it working as below (as you can see this is just testing code). I'm now having trouble retrieving the name of the process. I'm trying: win32process.GetModuleFileNameEx(handle, ) The module handle is escaping me. I've tried using the win32con.P

[python-win32] Re: Memory Usage for Processes

2005-02-10 Thread Roger Upole
Probably. You get that error if you pass a PID for a process that no longer exists. (if you had a process exit between the calls to EnumProcesses and OpenProcess) Roger ___ Python-win32 mailing list Python-win32@python.org http://mail.python.org/

RE: [python-win32] Re: Memory Usage for Processes

2005-02-10 Thread Tom Haddon
Hi Roger, I tried both of these but was getting the following messages. Is there any way of confirming which parameter it's refering to? Could it be my "process" parameter? Thanks, Tom Traceback (most recent call last): File "C:\test\memusage.py", line 24, in ? test = processes.listproce

[python-win32] Re: Memory Usage for Processes

2005-02-10 Thread Roger Upole
You'll need to specify more access in OpenProcess. It's 1 now, which is only PROCESS_TERMINATE. Most likely you're getting an access denied in the GetProcessMemoryInfo call. (This is why a bare except: is not generally a good thing to do) Try changing the access mode to win32con.PROCESS_QUERY_INF

[python-win32] Memory Usage for Processes

2005-02-10 Thread Tom Haddon
Hi Folks, I'm trying to get memory usage for all processes on a windows box and then later on I want to set up alerts if certain applications are using over a certain amount of memory. Here's what I have so far, but it's not working as expected. Any help appreciated. Basically it looks like my

Re: [python-win32] Re: Getting path+executable associated with a process

2005-02-10 Thread Gabriel Reis
Hi again, thanks for the tips. I didn't use EnumProcessModules, but I got the solution as shown below: import win32api, win32con, win32process def IsRunning(filename): processes = win32process.EnumProcesses()# get PID list for pid in processes: try: handle = win32