2 * Win32 advapi functions
4 * Copyright 1995 Sven Verdoolaege
18 #include "debugtools.h"
20 DEFAULT_DEBUG_CHANNEL(advapi);
22 /******************************************************************************
23 * GetUserNameA [ADVAPI32.@]
25 * NOTE: lpSize returns the total length of the username, including the
26 * terminating null character.
29 GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
34 struct passwd *pwd = getpwuid( getuid() );
37 ERR("Username lookup failed: %s\n", strerror(errno));
43 /* We need to include the null character when determining the size of the buffer. */
44 len = strlen(name) + 1;
47 SetLastError(ERROR_MORE_DATA);
53 strcpy(lpszName, name);
57 /******************************************************************************
58 * GetUserNameW [ADVAPI32.@]
65 GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
67 LPSTR name = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *lpSize );
69 BOOL res = GetUserNameA(name,lpSize);
71 /* FIXME: should set lpSize in WCHARs */
72 if (size && !MultiByteToWideChar( CP_ACP, 0, name, -1, lpszName, size ))
74 HeapFree( GetProcessHeap(), 0, name );