MattC
asked on
Getting the machine name
Does anyone know a quick way to get the network name of the machine on which a C++ MFC program is running?
Example for putting into a CString.
CString LocalCompName;
char CompName[128];
DWORD dwSize = sizeof(CompName);
GetComputerName(CompName,& dwSize);
LocalCompName=CString(Comp Name);
CString LocalCompName;
char CompName[128];
DWORD dwSize = sizeof(CompName);
GetComputerName(CompName,&
LocalCompName=CString(Comp
ASKER
Please don't close the question, just use comments.
Jhance,
Would this work.
CString name;
GetComputerName(static_cas t(LPTSTR)n ame,sizeof (name))
Jhance,
Would this work.
CString name;
GetComputerName(static_cas
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
what header needs including to access that function?
Also what is the maximum value for a machine name is it 128 or 255??
Also what is the maximum value for a machine name is it 128 or 255??
Don't you have the Windows SDK?
Header: Declared in winbase.h; include windows.h.
Library: Use kernel32.lib.
The maximum length for a computer name is:
MAX_COMPUTERNAME_LENGTH
also defined in windows.h
Header: Declared in winbase.h; include windows.h.
Library: Use kernel32.lib.
The maximum length for a computer name is:
MAX_COMPUTERNAME_LENGTH
also defined in windows.h
ASKER
not been able to get to a PC that does recently, will try tonight...thanks
LPTSTR lpBuffer, // computer name
LPDWORD lpnSize // size of name buffer
);