I am trying to close a singleton event handle from another process. Process explorer does this and I want to be able to achieve that too. I am getting the error
(5, 'DuplicateHandle', 'Access is denied.')
Am I passing the correct parameters?
Initial try:
win32api.DuplicateHandle(Proc, Singleton_event, win32api.GetCurrentProcess(), 1, True, 0)
Edit:
window = win32gui.FindWindow(None, "Game")
pid = win32process.GetWindowThreadProcessId(window)
print(pid)
Proc = win32api.OpenProcess(1, True, pid[1])
Singleton = win32event.CreateEvent(None, 0, 0, "singletonEvent")
dup_handle = win32api.DuplicateHandle(Proc, Singleton, win32api.GetCurrentProcess(), 0, False, win32con.DUPLICATE_SAME_ACCESS)
dup_handle.Close()
The desiredAccess parameter of DuplicateHandle is incorrect. And here is the MSDN:Example.