ComfyUI/comfy/analytics/identity_provider_nt.py
doctorpangloss 1b2ea61345 Improved API support
- Run comfyui workflows directly inside other python applications using
   EmbeddedComfyClient.
 - Optional telemetry in prompts and models using anonymity preserving
   Plausible self-hosted or hosted.
 - Better OpenAPI schema
 - Basic support for distributed ComfyUI backends. Limitations: no
   progress reporting, no easy way to start your own distributed
   backend, requires RabbitMQ as a message broker.
2024-02-07 14:20:21 -08:00

35 lines
1009 B
Python

import ctypes
from ctypes import wintypes, POINTER, byref
_windows_dll = ctypes.WinDLL('Secur32.dll')
_windows_get_user_name_ex_w_func = _windows_dll.GetUserNameExW
_windows_get_user_name_ex_w_func.argtypes = [ctypes.c_int, POINTER(wintypes.WCHAR), POINTER(wintypes.ULONG)]
_windows_get_user_name_ex_w_func.restype = wintypes.BOOL
_windows_extended_name_format = {
"NameUnknown": 0,
"NameFullyQualifiedDN": 1,
"NameSamCompatible": 2,
"NameDisplay": 3,
"NameUniqueId": 6,
"NameCanonical": 7,
"NameUserPrincipal": 8,
"NameCanonicalEx": 9,
"NameServicePrincipal": 10,
"NameDnsDomain": 12
}
def get_user_name():
size = wintypes.ULONG(0)
format_type = _windows_extended_name_format["NameDisplay"]
_windows_get_user_name_ex_w_func(format_type, None, byref(size))
name_buffer = ctypes.create_unicode_buffer(size.value)
if not _windows_get_user_name_ex_w_func(format_type, name_buffer, byref(size)):
return None
return name_buffer.value