2 * Win32 advapi functions
4 * Copyright 1995 Sven Verdoolaege
17 #include "debugtools.h"
20 /******************************************************************************
21 * GetUserNameA [ADVAPI32.@]
24 GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
29 struct passwd *pwd = getpwuid( getuid() );
32 len = name ? strlen(name) : 0;
33 if (!len || !lpSize || len > *lpSize) {
34 if (lpszName) *lpszName = 0;
38 strcpy(lpszName, name);
42 /******************************************************************************
43 * GetUserNameW [ADVAPI32.@]
50 GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
52 LPSTR name = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *lpSize );
54 BOOL res = GetUserNameA(name,lpSize);
56 /* FIXME: should set lpSize in WCHARs */
57 if (size && !MultiByteToWideChar( CP_ACP, 0, name, -1, lpszName, size ))
59 HeapFree( GetProcessHeap(), 0, name );