def QueryInfoKey(key):
 regqueryinfokey = advapi32['RegQueryInfoKeyW']
 regqueryinfokey.restype = ctypes.c_long
 regqueryinfokey.argtypes = [ctypes.c_void_p, ctypes.c_wchar_p, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, ctypes.POINTER(FileTime)]
 null = LPDWORD()
 num_sub_keys = ctypes.wintypes.DWORD()
 num_values = ctypes.wintypes.DWORD()
 ft = FileTime()
 rc = regqueryinfokey(key.handle, ctypes.c_wchar_p(), null, null, ctypes.byref(num_sub_keys), null, null, ctypes.byref(num_values), null, null, null, ctypes.byref(ft))
 if (rc != ERROR_SUCCESS):
  raise ctypes.WinError(2)
 last_modified = (ft.dwLowDateTime | (ft.dwHighDateTime << 32))
 last_modified = ((last_modified / 10000000) - WIN_UNIX_DIFF_MSECS)
 return (num_sub_keys.value, num_values.value, last_modified)

def QueryInfoKey ( key ) : regqueryinfokey = advapi32 [ 'RegQueryInfoKeyW' ] regqueryinfokey . restype = ctypes . c_long regqueryinfokey . argtypes = [ ctypes . c_void_p , ctypes . c_wchar_p , LPDWORD , LPDWORD , LPDWORD , LPDWORD , LPDWORD , LPDWORD , LPDWORD , LPDWORD , LPDWORD , ctypes . POINTER ( FileTime ) ] null = LPDWORD ( ) num_sub_keys = ctypes . wintypes . DWORD ( ) num_values = ctypes . wintypes . DWORD ( ) ft = FileTime ( ) rc = regqueryinfokey ( key . handle , ctypes . c_wchar_p ( ) , null , null , ctypes . byref ( num_sub_keys ) , null , null , ctypes . byref ( num_values ) , null , null , null , ctypes . byref ( ft ) ) if ( rc != ERROR_SUCCESS ) : raise ctypes . WinError ( 2 ) last_modified = ( ft . dwLowDateTime | ( ft . dwHighDateTime << 32 ) ) last_modified = ( ( last_modified / 10000000 ) - WIN_UNIX_DIFF_MSECS ) return ( num_sub_keys . value , num_values . value , last_modified )
this calls the windows regqueryinfokey function in a unicode safe way .