Beispiel #1
0
int main(int argc, char *argv[])
{
    qInstallMessageHandler(logMessageHandler);
    QApplication a(argc, argv);

    logFileStream.reset(new QTextStream);
    logFileFile.reset(new QFile(QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
                                                + "AppData" + QDir::separator() + "Roaming" + QDir::separator() + "tox")+QDir::separator()+"qtox.log"));
    if (logFileFile->open(QIODevice::Append))
    {
        logFileStream->setDevice(logFileFile.get());
        *logFileStream << QDateTime::currentDateTime().toString("\nyyyy-MM-dd HH:mm:ss' Updater file logger starting\n'");
    }
    else
    {
        qWarning() << "Couldn't open log file!\n";
        logFileStream.release();
    }

    long unsigned int bufsize=100;
    char buf[100];
    GetUserNameA(buf, &bufsize);
    qDebug() << "Updater running as user" << buf;

    Widget w;
    w.show();

    return a.exec();
}
void do_date(void)
{
    OSVERSIONINFOA verinfo;
    CHAR buf[128];
    time_t t = time(NULL);
    DWORD dwSize;
    CHAR szComp[MAX_PATH], szUser[MAX_PATH];

    // OS info
    verinfo.dwOSVersionInfoSize = sizeof(verinfo);
    GetVersionExA(&verinfo);
    sprintf(buf, "Microsoft Windows [Version %u.%u.%u]",
        verinfo.dwMajorVersion, verinfo.dwMinorVersion, verinfo.dwBuildNumber);
    if (nyarlathotep_p)
        do_nyarlathotep_buffer(buf);
    puts(buf);

    // computer_name - user_name
    dwSize = MAX_PATH;
    GetComputerNameA(szComp, &dwSize);
    dwSize = MAX_PATH;
    GetUserNameA(szUser, &dwSize);
    sprintf(buf, "%s - %s", szComp, szUser);
    if (nyarlathotep_p)
        do_nyarlathotep_buffer(buf);
    puts(buf);

    // Thu Nov 28 14:52:58     2013
    strftime(buf, 64, "%a %b %d %H:%M:%S     %Y", localtime(&t));
    if (nyarlathotep_p)
        do_nyarlathotep_buffer(buf);
    puts(buf);
}
Beispiel #3
0
int main(int argc, char *argv[])
{
    qInstallMessageHandler(logMessageHandler);
    QApplication a(argc, argv);
    Settings s;

    logFileStream.reset(new QTextStream);
    logFileFile.reset(new QFile(s.getSettingsDirPath()+"qtox.log"));
    if (logFileFile->open(QIODevice::Append))
    {
        logFileStream->setDevice(logFileFile.get());
        *logFileStream << QDateTime::currentDateTime().toString("\nyyyy-MM-dd HH:mm:ss' Updater file logger starting\n'");
    }
    else
    {
        qWarning() << "Couldn't open log file!\n";
        logFileStream.release();
    }

    long unsigned int bufsize=100;
    char buf[100];
    GetUserNameA(buf, &bufsize);
    qDebug() << "Updater running as user" << buf;

    Widget w(s);
    w.show();

    return a.exec();
}
const QString & getUserName()
{
    static QString userName;
    userName=getenv("USER");

    if (userName.isEmpty()) {
        userName=QObject::tr("Windows User");

#if defined (Q_WS_WIN32)
    #if defined(UNICODE)
    if (QSysInfo::WindowsVersion >= QSysInfo::WV_NT) {
        TCHAR winUserName[UNLEN + 1]; // UNLEN is defined in LMCONS.H
        DWORD winUserNameSize = sizeof(winUserName);
        GetUserNameW( winUserName, &winUserNameSize );
        userName = QString::fromStdWString( winUserName );
    } else
    #endif
    {
        char winUserName[UNLEN + 1]; // UNLEN is defined in LMCONS.H
        DWORD winUserNameSize = sizeof(winUserName);
        GetUserNameA( winUserName, &winUserNameSize );
        userName = QString::fromLocal8Bit( winUserName );
    }
#endif
    }

    return userName;
}
Beispiel #5
0
char *sys_username (char *buf, size_t length)
{
#ifdef _WIN32
	char	ts [UNLEN + 1];
	DWORD	len = sizeof (ts);

	if (!GetUserNameA (ts, &len))
		fatal_printf ("sys_username(): GetUserNameA() returned error!");

	if (len >= length)
		fatal_printf ("sys_username(): buffer too short!");

	memcpy (buf, ts, len);
	buf [len] = '\0';
#elif defined (NUTTX_RTOS)
	ARG_NOT_USED (length)
	strcpy (buf, "NuttX_username");
#else
	char	*cp = getlogin ();

	if (strlen (cp) >= length) {
		memcpy (buf, cp, length - 1);
		buf [length - 1] = '\0';
		warn_printf ("sys_username(): login name too long ('%s')!", cp);
	}
	else
		strcpy (buf, cp);
#endif
	return (buf);
}
Beispiel #6
0
BOOL Injector::createPath(std::string dllName)
{
	CHAR	userNameA[MAX_USERNAME_SIZE];
	wchar_t	userNameW[MAX_USERNAME_SIZE];
	DWORD	sizeUsername = MAX_USERNAME_SIZE;
	BOOL	check = FALSE;

	if (GetUserNameW((LPWSTR)userNameW, &sizeUsername))
	{
		std::wstring userW(userNameW);
		this->_pathHiddenFile.append(L"C:\\Users\\");
		this->_pathHiddenFile.append(userW);
		this->_pathHiddenFile.append(L"\\Documents\\Injector\\");
		check = TRUE;
	}
	if (GetUserNameA((LPSTR)userNameA, &sizeUsername))
	{
		std::string userA(userNameA);
		this->_pathDll.append("C:\\Users\\");
		this->_pathDll.append(userA);
		this->_pathDll.append("\\Documents\\Injector\\setHook.dll");
		check = TRUE;
	}
	return (check);
}
Beispiel #7
0
char *sys_username (char *buf, size_t length)
{
#ifdef _WIN32
	char	ts [UNLEN + 1];
	DWORD	len = sizeof (ts);

	if (!GetUserNameA (ts, &len))
		fatal_printf ("sys_username(): GetUserNameA() returned error!");

	if (len >= length)
		fatal_printf ("sys_username(): buffer too short!");

	memcpy (buf, ts, len);
	buf [len] = '\0';
#else
	const char	*cp = getlogin ();

	if (!cp)
		cp = sys_getenv ("LOGNAME");
	if (!cp)
		return (NULL);

	if (strlen (cp) >= length) {
		memcpy (buf, cp, length - 1);
		buf [length - 1] = '\0';
		warn_printf ("sys_username(): login name too long ('%s')!", cp);
	}
	else
		strcpy (buf, cp);
#endif
	return (buf);
}
Beispiel #8
0
/*
 * Returns the current user name.
 */
static char *
get_username(void)
{
	char *ret;

#ifndef WIN32
	struct passwd *pw;

	pw = getpwuid(geteuid());
	ret = (pw ? pw->pw_name : NULL);
#else
	static char username[128];	/* remains after function execute */
	DWORD		len = sizeof(username) - 1;

	if (GetUserNameA(username, &len))
		ret = username;
	else
	{
		_dosmaperr(GetLastError());
		ret = NULL;
	}
#endif

	if (ret == NULL)
		ereport(ERROR,
			(errcode_errno(),
			 errmsg("could not get current user name: ")));
	return ret;
}
Beispiel #9
0
// References:
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365588(v=vs.85).aspx
static HANDLE
connect_pipe(const char* app_name) {
	HANDLE pipe = INVALID_HANDLE_VALUE;
	char username[UNLEN + 1];
	DWORD unlen = UNLEN + 1;
	if (GetUserNameA(username, &unlen)) {
		// add username to the pipe path so it will not clash with other users' pipes.
		char pipe_name[MAX_PATH];
		sprintf(pipe_name, "\\\\.\\pipe\\%s\\%s_pipe", username, app_name);
		const size_t buffer_size = 1024;
		// create the pipe
		pipe = CreateNamedPipeA(pipe_name,
			PIPE_ACCESS_DUPLEX,
			PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
			PIPE_UNLIMITED_INSTANCES,
			buffer_size,
			buffer_size,
			NMPWAIT_USE_DEFAULT_WAIT,
			&g_securityAttributes);

		if (pipe != INVALID_HANDLE_VALUE) {
			// try to connect to the named pipe
			// NOTE: this is a blocking call
			if (FALSE == ConnectNamedPipe(pipe, NULL)) {
				// fail to connect the pipe
				CloseHandle(pipe);
				pipe = INVALID_HANDLE_VALUE;
			}
		}
	}
	return pipe;
}
const char* os_username()
{
#ifndef WINDOWS

	struct passwd *pw;
	uid_t uid;

	uid = geteuid();
	
	if((pw = getpwuid(uid)) != NULL)
		return pw->pw_name;
	else
		return NULL;

#else

	// Only keep one string with the username here.
	// No need to free the result of os_username :)
	static char username[MAX_BUFFER];
	DWORD length = MAX_BUFFER;

	if(GetUserNameA(
		username,
		&length))
		return username;
	else
		return NULL;

#endif
}
Beispiel #11
0
char *iupdrvGetUserName(void)
{
  DWORD size = 256;
  char* str = iupStrGetMemory(size);
  GetUserNameA((LPSTR)str, &size);
  return (char*)str;
}
Beispiel #12
0
std::string getUsername(){
    inoutsize=INFO_BUFFER_SIZE;
    if( !GetUserNameA( infoBuf, &inoutsize ) ){
        return "";
    }
    std::string ret = infoBuf;
    return ret;
}
Beispiel #13
0
static __forceinline char *GetUserNameX(const char*)
{
	char result[128];
	DWORD size = _countof(result);
	if (GetUserNameA(result, &size))
		return mir_strdup(result);
	return NULL;
}
Beispiel #14
0
//---------------------------------------------------------------------------
void __fastcall TMainWindow::FormCreate(TObject *Sender)
{
    InitializeCriticalSection(&CS);
   WSADATA wsaData,*lpwsaData;
   char *domain,user[256];

		lpwsaData = &wsaData;

		WORD wVersionRequested = MAKEWORD(1, 1);
		int nResult = WSAStartup(wVersionRequested, lpwsaData);
		if (nResult != 0) {
      	Application->MessageBox("WSAStartup failed","Error",MB_OK|MB_ICONERROR);
			return;
      }

		if (LOBYTE(lpwsaData->wVersion) != 1 || HIBYTE(lpwsaData->wVersion) != 1)
		{
			WSACleanup();
         Application->MessageBox("Wrong wsock version","Error",MB_OK|MB_ICONERROR);
			return;
		}
        DWORD size=256;
        domain=getenv("USERDOMAIN");
		GetUserNameA(user,&size);
        sprintf(name,"%s/%s",domain,user);
        Application->ShowHint = true;
        Application->OnHint = ShowHint;
        ShownBefore=false;


	Servers = new CServers(FALSE);
	PluginManager.LoadPlugins();
    CreatePluginMenu();
    PluginManager.RegisterClientWindow(Handle);
    Servers->RegisterClientWindow(Handle);

    //read checked Menue items from ini-file
    BOOL retval = true;
    DWORD errcode = NO_ERROR;
    char IniFileName[1024];
    AnsiString inivalue;
    if (!GetFullExeName(IniFileName))
       strcpy(IniFileName,"RexecShell.ini");
    else
    {
          ChangeFileExt(IniFileName,".ini") ;
        }
     IniFile = new TIniFile(IniFileName);
     inivalue = IniFile->ReadString("RexecShell" , "SetRPCEncryption","Default");
     if (inivalue == FALSESTR)
        RPCEncryption->Checked = false;
     SetRPCEncryption(RPCEncryption->Checked);   

     inivalue = IniFile->ReadString("RexecShell" , "checkprofilevalidity","Default");
     if (inivalue == FALSESTR)
        checkprofilevalidity->Checked = false;
     CheckUserAccountOnChange = checkprofilevalidity->Checked;
}
Beispiel #15
0
char* getlogin()
{
/*! @todo make this reentrant!*/
	size_t size = sizeof(getlogin_buf);
	*getlogin_buf = 0;
	if (!GetUserNameA(getlogin_buf, (LPDWORD)&size))
		return 0;
	return getlogin_buf;
}
Beispiel #16
0
static BOOL WINAPI fallbackGetUserNameW(LPWSTR buf, LPDWORD len)
{
    const DWORD cplen = *len;
    char *cpstr = __PHYSFS_smallAlloc(cplen);
    BOOL retval = GetUserNameA(cpstr, len);
    if (buf != NULL)
        MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, cpstr, cplen, buf, *len);
    __PHYSFS_smallFree(cpstr);
    return(retval);
} /* fallbackGetUserNameW */
Beispiel #17
0
// retrieve the user's name.
//
void get_user_name( std::string& name ) {
#ifdef _WIN32
    CHAR  szBuffer[256];
    DWORD dwSize = sizeof(szBuffer);

    if (GetUserNameA((LPSTR)&szBuffer, &dwSize)) {
        name = szBuffer;
    }
#endif
}
Beispiel #18
0
int server_connect(const struct protocol_interface *protocol, int verify_only)
{
	char current_user[256];
	char remote_user[256];
	char tmp[32];
	unsigned char c;
	int listen_port=0;
	if(!current_server->current_root->hostname || !current_server->current_root->directory || current_server->current_root->port)
		return CVSPROTO_BADPARMS;

	if(tcp_connect_bind(current_server->current_root->hostname,"514",512,1023)<1)
		return CVSPROTO_FAIL;

#ifdef _WIN32
	{
		DWORD dwLen = 256;
		GetUserNameA(current_user,&dwLen);
	}
#else
	strncpy(current_user,getpwuid(geteuid())->pw_name,sizeof(current_user));
#endif

	if(current_server->current_root->username)
		strncpy(remote_user,current_server->current_root->username,sizeof(remote_user));
	else
		strncpy(remote_user,current_user,sizeof(remote_user));

	snprintf(tmp,sizeof(tmp),"%d",listen_port);
	if(tcp_write(tmp,strlen(tmp)+1)<1)
		return CVSPROTO_FAIL;
	if(tcp_write(current_user,strlen(current_user)+1)<1)
		return CVSPROTO_FAIL;
	if(tcp_write(remote_user,strlen(remote_user)+1)<1)
		return CVSPROTO_FAIL;

#define CMD "cvs server"

	if(tcp_write(CMD,sizeof(CMD))<1)
		return CVSPROTO_FAIL;
	
	if(tcp_read(&c,1)<1)
		return CVSPROTO_FAIL;

	if(c)
	{
		char msg[257];
		if((c=tcp_read(msg,256))<1)
			return CVSPROTO_FAIL;
		msg[c]='\0';
		server_error(0,"rsh server reported: %s",msg);
		return CVSPROTO_FAIL;
	}

	return CVSPROTO_SUCCESS_NOPROTOCOL; /* :server: doesn't need login response */
}
Beispiel #19
0
const char* system_username( void )
{
	unsigned long size = 255;
	static char username[256] = {0};
	if( username[0] )
		return username;
	strcpy( username, "<unknown>" );
	GetUserNameA( username, &size );
	username[255] = 0;
	return username;
}
Beispiel #20
0
bool CSSPIHandler::ClientStart(bool encrypt, bool& more, const char *name, const char *pwd, const char *tokenSource /* = NULL */)
{
	char username[256];
	char domain[256];
	SECURITY_STATUS rc;
	TimeStamp useBefore;

	memset(&m_nameAndPwd,0,sizeof(m_nameAndPwd));

	if (name && *name)
	{
		strncpy(username,name,sizeof(username));
		char *p = strpbrk(username,"\\/");
		if(!p)
			domain[0]='\0';
		else
		{
			*p='\0';
			strcpy(domain,username);
			strcpy(username,p+1);
		}

		
		m_nameAndPwd.Domain = (BYTE*)domain;
		m_nameAndPwd.DomainLength = (DWORD)strlen(domain);
		m_nameAndPwd.User = (BYTE*)username;
		m_nameAndPwd.UserLength = (DWORD)strlen(username);
		m_nameAndPwd.Password = (BYTE*)(pwd?pwd:"");
		m_nameAndPwd.PasswordLength = (DWORD)(pwd?strlen(pwd):0); 
		m_nameAndPwd.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
	}
	else if(m_broken_file_sharing)
	{
		m_nameAndPwd.UserLength = sizeof(username);
		GetUserNameA(username,&m_nameAndPwd.UserLength);
		m_nameAndPwd.User= (BYTE*)username;
		m_nameAndPwd.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
	}

	rc = AcquireCredentialsHandleA( NULL, (char*)m_currentProtocol.c_str(), SECPKG_CRED_OUTBOUND, NULL, m_nameAndPwd.UserLength?&m_nameAndPwd:NULL, NULL, NULL, &m_credHandle, &useBefore );
	if(rc)
	{
		m_rc = rc;
		return false;
	}

	m_haveContext = false;
	m_tokenSource = tokenSource;
	m_ctxReq = ISC_REQ_MUTUAL_AUTH | ISC_REQ_DELEGATE | ISC_REQ_STREAM | ISC_REQ_EXTENDED_ERROR;
	if(encrypt)
		m_ctxReq |= ISC_REQ_REPLAY_DETECT  | ISC_REQ_SEQUENCE_DETECT | ISC_REQ_CONFIDENTIALITY | ISC_REQ_INTEGRITY;

	return ClientStep(more,NULL,0);
}
Beispiel #21
0
/******************************************************************************
 * GetUserNameW [ADVAPI32.@]
 *
 * PARAMS
 *   lpszName []
 *   lpSize   []
 */
BOOL WINAPI
GetUserNameW( LPWSTR lpszName, LPDWORD lpSize )
{
	LPSTR name = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *lpSize );
	DWORD	size = *lpSize;
	BOOL res = GetUserNameA(name,lpSize);

        /* FIXME: should set lpSize in WCHARs */
        if (size && !MultiByteToWideChar( CP_ACP, 0, name, -1, lpszName, size ))
            lpszName[size-1] = 0;
        HeapFree( GetProcessHeap(), 0, name );
	return res;
}
Beispiel #22
0
/*
================
Sys_GetCurrentUser
================
*/
char *Sys_GetCurrentUser( void ) {
	static char s_userName[1024];
	unsigned long size = sizeof( s_userName );


	if ( !GetUserNameA( s_userName, &size ) ) {
		strcpy( s_userName, "player" );
	}

	if ( !s_userName[0] ) {
		strcpy( s_userName, "player" );
	}

	return s_userName;
}	
Beispiel #23
0
/*))
 //     Statics but usefuls
((*/
static
rc_t CC
_GetUserName ( char * Buffer, size_t BufferSize )
{
    DWORD BS;

    if ( Buffer == NULL || BufferSize == 0 ) {
        return XFS_RC ( rcNull );
    }

    BS = BufferSize;

    if ( GetUserNameA ( Buffer, & BS ) == 0 ) {
        return XFS_RC ( rcExhausted );
    }

    return 0;
}   /* _GetUserName () */
Beispiel #24
0
UserInfo::UserInfo() : username_(UNLEN, 0) {
  DWORD size = username_.size() + 1;
  TokenHandle tokenHandle;

  if (!GetUserNameA(username_.data(), &size)) {
    throw makeWin32ErrorExplicit(GetLastError(), "Failed to get the user name");
  }

  username_.resize(size - 1);

  if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, tokenHandle.set())) {
    throw makeWin32ErrorExplicit(
        GetLastError(), "Failed to get the process token");
  }

  // The profile path could be of any arbitrary length, so if we failed to get
  // with error ERROR_INSUFFICIENT_BUFFER then we retry with the right size
  // buffer.

  size = MAX_PATH;
  string profile(size - 1, 0);
  bool retry = false;

  if (!GetUserProfileDirectoryA(tokenHandle.get(), profile.data(), &size)) {
    if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
      retry = true;
    } else {
      throw makeWin32ErrorExplicit(
          GetLastError(), "Failed to get user profile directory");
    }
  }

  profile.resize(size - 1);
  if (retry) {
    if (!GetUserProfileDirectoryA(tokenHandle.get(), profile.data(), &size)) {
      throw makeWin32ErrorExplicit(
          GetLastError(), "Failed to get user profile directory");
    }
    profile.resize(size - 1);
  }

  homeDirectory_ = realpath(profile);
}
Beispiel #25
0
char *get_username(void)
{
   DWORD namelen;
   char *user;

   namelen = 0;
   if (GetUserName(NULL, &namelen) == FALSE) {
      /*
      * Apparently this doesn't work at least on Windows XP SP2.
      * Thus assume a maximum of 256. It will fail again if it
      * doesn't fit.
      */
      namelen = 256;
   }

   user = snewn(namelen, char);
   GetUserNameA(user, &namelen);

   return user;
}
Beispiel #26
0
void MachineInfo::make_info()
{
	//FunctionHooks* FH = new FunctionHooks;
	
	DWORD size;
	size = MAX_COMPUTERNAME_LENGTH + 1;
	
	GetComputerNameA(this->PC_Name, &size); // Wpisanie nazwy komputera

	size = UNLEN + 1;

	GetUserNameA(this->Username, &size); // Wpisanie nazwy u¿ytkownika

	
	/*----------------Wpisanie informacji o maksymalnym taktowaniu CPU--------------------*/
	SYSTEM_INFO sysInfo;
	GetSystemInfo(&sysInfo);
	size = sysInfo.dwNumberOfProcessors * sizeof(PROCESSOR_POWER_INFORMATION);
	LPBYTE buf = new BYTE[size];
	CallNtPowerInformation(ProcessorInformation, NULL, 0, buf, size);
	PPROCESSOR_POWER_INFORMATION cpuinfo = (PPROCESSOR_POWER_INFORMATION)buf;
	std::string full_cpu_ratio = intToStr(cpuinfo->MaxMhz) + "GHz";
	full_cpu_ratio.erase(3, 1);
	full_cpu_ratio.insert(1, ".");
	memcpy(this->CPU_clock, full_cpu_ratio.c_str(), sizeof(full_cpu_ratio));
	/*------------------------------------------------------------------------------------*/


	/*-----------------------Sprawdzenie wersji systemu Windows---------------------------*/
	if (IsWindows8Point1OrGreater())memcpy(this->OS, "Windows 8.1", sizeof("Windows 8.1"));
	else
	if (IsWindows7OrGreater())memcpy(this->OS, "Windows 7", sizeof("Windows 7"));
	else
	if (IsWindowsVistaOrGreater())memcpy(this->OS, "Windows Vista", sizeof("Windows Vista"));
	else
	if (IsWindowsXPOrGreater())memcpy(this->OS, "Windows XP", sizeof("Windows XP"));
	/*------------------------------------------------------------------------------------*/

}
Beispiel #27
0
String GetUsername()
{
	static Cache<String> Value;

	return Value.Get([]() 
	{
		char Buffer[UNLEN + 1];
		Buffer[UNLEN] = '\0';

		DWORD BufferLen = UNLEN;

		if (0 == GetUserNameA(Buffer, &BufferLen))
		{
			LogLastSystemError("GetUsername");
			return String("Unknown");
		}
		else
		{
			return String(Buffer);
		}
	});
}
Beispiel #28
0
static int
Win32_GetUserName(Jim_Interp *interp, int objc, Jim_Obj * const *objv)
{
    char name[UNLEN + 1];
    DWORD size = UNLEN;
    int r = JIM_OK;

    if (objc != 1) {
        Jim_WrongNumArgs(interp, 1, objv, "");
        return JIM_ERR;
    }

    if (GetUserNameA(name, &size)) {
        Jim_Obj *nameObj = Jim_NewStringObj(interp, name, size);
        Jim_SetResult(interp, nameObj);
    } else {
        Jim_SetResult(interp,
            Win32ErrorObj(interp, "GetUserName", GetLastError()));
        r = JIM_ERR;
    }

    return r;
}
Beispiel #29
0
static CFStringRef _CFUserName(void) {
#if defined(__MACH__) || defined(__svr4__) || defined(__hpux__) || defined(__LINUX__) || defined(__FREEBSD__)
    if (geteuid() != __CFEUID || getuid() != __CFUID)
	_CFUpdateUserInfo();
#elif defined(__WIN32__)
    if (!__CFUserName) {
	char username[1040];
	DWORD size = 1040;
	username[0] = 0;
	if (GetUserNameA(username, &size)) {
            __CFUserName = CFStringCreateWithCString(NULL, username, kCFPlatformInterfaceStringEncoding);
	} else {
	    const char *cname = getenv("USERNAME");
	    if (cname)
                __CFUserName = CFStringCreateWithCString(NULL, cname, kCFPlatformInterfaceStringEncoding);
	}
    }
#else
#error Dont know how to compute user name on this platform
#endif
    if (!__CFUserName)
        __CFUserName = CFRetain(CFSTR(""));
    return __CFUserName;
}
Beispiel #30
0
// ---- shell.OperatingSystem ---- 
void VMPI_getUserName(char *username)
{
    //DWORD bufsize = 256;
    DWORD bufsize = LOGIN_NAME_MAX;
    GetUserNameA(username, &bufsize);
}