def process__get_executable_filename(thread_pid):
# This only finds processes, not services.
GetProcessImageFileName = windll.kernel32.K32GetProcessImageFileNameW
GetProcessImageFileName.restype = wintypes.DWORD
OpenProcess = windll.kernel32.OpenProcess
# OpenProcess.restype = wintypes.HANDLE
hproc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, False, thread_pid)
if hproc is None:
raise WinError()
try:
filename = create_unicode_buffer(MAX_FILENAME_LENGTH + 1)
# For some reason, this isn't found in Windows 10.
res = GetProcessImageFileName(hproc, byref(filename), MAX_FILENAME_LENGTH + 1)
if res <= 0:
# raise ctypes.WinError()
return None
return str(filename.value[:res])
finally:
windll.kernel32.CloseHandle(hproc)
# def shell__open_start_menu():
# # In Windows 7, the start button is part of the desktop?
# desktop_hwnd = windll.user32.GetDesktopWindow()
#
# # FIXME DEBUG
# print("DEBUG desktop_hwnd: {0}".format(desktop_hwnd))
#
# # Find the "start" button on the tray window
# start_hwnd = windll.user32.FindWindowExW(desktop_hwnd, None, 'Button', 'Start')
# if (start_hwnd is None or start_hwnd == 0) and GetLastError() != 0:
# start_hwnd = windll.user32.FindWindowExW(desktop_hwnd, None, None, 'Start')
# if (start_hwnd is None or start_hwnd == 0) and GetLastError() != 0:
# # start_hwnd = windll.user32.FindWindowExW(desktop_hwnd, None, 'Button', None)
# if start_hwnd is None or start_hwnd == 0:
# raise WinError()
# print("Start button: {0}".format(start_hwnd))
#
# # Send a click message to the button
# res = windll.user32.SendMessageW(start_hwnd, BM_CLICK, 0, 0)
# if res == 0:
# raise WinError()
评论列表
文章目录