def get_process_token():
 GetCurrentProcess = ctypes.windll.kernel32.GetCurrentProcess
 GetCurrentProcess.restype = wintypes.HANDLE
 OpenProcessToken = ctypes.windll.advapi32.OpenProcessToken
 OpenProcessToken.argtypes = (wintypes.HANDLE, wintypes.DWORD, ctypes.POINTER(wintypes.HANDLE))
 OpenProcessToken.restype = wintypes.BOOL
 token = wintypes.HANDLE()
 TOKEN_ALL_ACCESS = 983551
 res = OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, token)
 if (not (res > 0)):
  raise RuntimeError("Couldn't get process token")
 return token

def get_process_token ( ) : GetCurrentProcess = ctypes . windll . kernel32 . GetCurrentProcess GetCurrentProcess . restype = wintypes . HANDLE OpenProcessToken = ctypes . windll . advapi32 . OpenProcessToken OpenProcessToken . argtypes = ( wintypes . HANDLE , wintypes . DWORD , ctypes . POINTER ( wintypes . HANDLE ) ) OpenProcessToken . restype = wintypes . BOOL token = wintypes . HANDLE ( ) TOKEN_ALL_ACCESS = 983551 res = OpenProcessToken ( GetCurrentProcess ( ) , TOKEN_ALL_ACCESS , token ) if ( not ( res > 0 ) ) : raise RuntimeError ( "Couldn't get process token" ) return token
get the current process token .