|
-
March 12th, 2007, 10:50 AM
#1
GetComputerNameEx problem
Hi All,
I am searching code to find out the fully qualified computername like
compi.subdomain.domain.corp
of a) the local computer and
b) a computer, which computer name (not fully qualified) I know.
I tried the following code to solve a), but it only gives me the computername, no matter which switch I use in GetComputerNameEx.
If I display the computer proberties, a domain name ( smthg.corp) is displayed and in the tcpip parameters I can also read a domain. But they are different (the latter one is location.smthg.corp).
So: what exactly is the fqdn and how do I get it?
thanks in advance,
HoM
Code:
TCHAR szBuf[MAX_PATH] ={0};
DWORD dwSize = sizeof( szBuf);
GetComputerNameEx( ComputerNameDnsDomain, szBuf, &dwSize );
cout << _T("ComputerNameDnsDomain :") << szBuf << endl;
szBuf [0] =0;
dwSize = sizeof( szBuf);
GetComputerNameEx( ComputerNameDnsFullyQualified, szBuf, &dwSize);
cout << _T("ComputerNameDnsFullyQualified :") << szBuf << endl;
szBuf [0] =0;
dwSize = sizeof( szBuf);
GetComputerNameEx( ComputerNameDnsHostname, szBuf, &dwSize );
cout << _T("ComputerNameDnsHostname :") << szBuf << endl;
szBuf [0] =0;
dwSize = sizeof( szBuf);
GetComputerNameEx( ComputerNameNetBIOS, szBuf, &dwSize );
cout << _T("ComputerNameNetBIOS :") << szBuf << endl;
szBuf [0] =0;
dwSize = sizeof( szBuf);
GetComputerNameEx( ComputerNameNetBIOS, szBuf, &dwSize );
cout << _T("ComputerNameNetBIOS :") << szBuf << endl;
szBuf [0] =0;
dwSize = sizeof( szBuf);
GetComputerNameEx( ComputerNamePhysicalDnsDomain, szBuf, &dwSize);
cout << _T("ComputerNamePhysicalDnsDomain :") << szBuf << endl;
szBuf [0] =0;
dwSize = sizeof( szBuf);
GetComputerNameEx( ComputerNamePhysicalDnsFullyQualified, szBuf, &dwSize);
cout << _T("ComputerNamePhysicalDnsFullyQualified :") << szBuf << endl;
szBuf [0] =0;
dwSize = sizeof( szBuf);
GetComputerNameEx( ComputerNamePhysicalDnsHostname, szBuf, &dwSize);
cout << _T("ComputerNamePhysicalDnsHostname :") << szBuf << endl;
szBuf [0] =0;
dwSize = sizeof( szBuf);
GetComputerNameEx( ComputerNamePhysicalNetBIOS, szBuf, &dwSize);
cout << _T("ComputerNamePhysicalNetBIOS :") << szBuf << endl;
getchar();
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|