hello,
is there an easier way to get the name of current process? i'm using
wmi module from Tim Golden. here is what i have:
def find_first_match(func, lst):
"""Find 1st item in a list that yield True for a give function."""
match = None
for i, elem in enumerate(lst):
if func(elem):
match = [i, elem]
break
return match
def get_current_process_name():
import wmi
import win32process
procList = wmi.WMI().Win32_Process()
hwnd = win32process.GetCurrentProcessId()
find = find_first_match(lambda p: int(p.Handle) == hwnd, procList)
if find:
return find[1].Name
else:
return None
if __name__ == "__main__":
print get_current_process_name()
the above code works. but it is slow. it always takes a few seconds to
get the procList. is it normal?
thanks for your help
--
Kelie
_______________________________________________
Python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32