1999-01-03 12:48:29 +00:00
|
|
|
/*
|
|
|
|
* Win32 advapi functions
|
|
|
|
*
|
|
|
|
* Copyright 1995 Sven Verdoolaege
|
|
|
|
*/
|
|
|
|
|
1999-06-12 14:55:11 +00:00
|
|
|
#include <stdio.h>
|
1999-02-17 13:51:06 +00:00
|
|
|
#include <unistd.h>
|
1999-02-19 15:42:11 +00:00
|
|
|
#include <string.h>
|
1999-02-17 13:51:06 +00:00
|
|
|
|
1999-07-03 16:01:42 +00:00
|
|
|
#include "winbase.h"
|
1999-03-14 16:35:05 +00:00
|
|
|
#include "windef.h"
|
1999-01-03 12:48:29 +00:00
|
|
|
#include "winerror.h"
|
1999-02-17 13:51:06 +00:00
|
|
|
#include "wine/winestring.h"
|
1999-01-03 12:48:29 +00:00
|
|
|
|
1999-05-14 08:17:14 +00:00
|
|
|
#include "debugtools.h"
|
1999-02-17 13:51:06 +00:00
|
|
|
|
1999-01-03 12:48:29 +00:00
|
|
|
|
1999-01-28 13:46:25 +00:00
|
|
|
/******************************************************************************
|
2000-03-28 20:22:59 +00:00
|
|
|
* GetUserNameA [ADVAPI32.67]
|
1999-01-03 12:48:29 +00:00
|
|
|
*/
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL WINAPI
|
|
|
|
GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
|
1999-01-03 12:48:29 +00:00
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
name=getlogin();
|
|
|
|
#if 0
|
|
|
|
/* FIXME: should use getpwuid() here */
|
|
|
|
if (!name) name=cuserid(NULL);
|
|
|
|
#endif
|
|
|
|
len = name ? strlen(name) : 0;
|
|
|
|
if (!len || !lpSize || len > *lpSize) {
|
|
|
|
if (lpszName) *lpszName = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
*lpSize=len;
|
|
|
|
strcpy(lpszName, name);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1999-01-28 13:46:25 +00:00
|
|
|
/******************************************************************************
|
2000-03-28 20:22:59 +00:00
|
|
|
* GetUserNameW [ADVAPI32.68]
|
1999-01-28 13:46:25 +00:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszName []
|
|
|
|
* lpSize []
|
1999-01-03 12:48:29 +00:00
|
|
|
*/
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL WINAPI
|
|
|
|
GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
|
1999-01-03 12:48:29 +00:00
|
|
|
{
|
|
|
|
LPSTR name = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *lpSize );
|
|
|
|
DWORD size = *lpSize;
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL res = GetUserNameA(name,lpSize);
|
1999-01-03 12:48:29 +00:00
|
|
|
|
|
|
|
lstrcpynAtoW(lpszName,name,size);
|
|
|
|
HeapFree( GetProcessHeap(), 0, name );
|
|
|
|
return res;
|
|
|
|
}
|