DiegoTc
January 19th, 2010, 02:44 PM
Hi
I was wondering if someone knows how to get the user name of the computer using QT4c++
I found something, but it will on work on windows, and it for c++,not using the QT4 functions
#include <windows.h>
#include <string>
#include <iostream.h>
string GetLocalComputerName() {
TCHAR chrComputerName[MAX_COMPUTERNAME_LENGTH + 1];
string strRetVal;
DWORD dwBufferSize = MAX_COMPUTERNAME_LENGTH + 1;
if(GetComputerName(chrComputerName,&dwBufferSize)) {
// We got the name, set the return value.
strRetVal = chrComputerName;
} else {
// Failed to get the name, call GetLastError here to get
// the error code.
strRetVal = "";
}
return(strRetVal);
}
I supposed there is a way in QT4c++ in where you can get the user name that will work for linux and windows
I was wondering if someone knows how to get the user name of the computer using QT4c++
I found something, but it will on work on windows, and it for c++,not using the QT4 functions
#include <windows.h>
#include <string>
#include <iostream.h>
string GetLocalComputerName() {
TCHAR chrComputerName[MAX_COMPUTERNAME_LENGTH + 1];
string strRetVal;
DWORD dwBufferSize = MAX_COMPUTERNAME_LENGTH + 1;
if(GetComputerName(chrComputerName,&dwBufferSize)) {
// We got the name, set the return value.
strRetVal = chrComputerName;
} else {
// Failed to get the name, call GetLastError here to get
// the error code.
strRetVal = "";
}
return(strRetVal);
}
I supposed there is a way in QT4c++ in where you can get the user name that will work for linux and windows