Hi iam trying to retrieve the domain name of a machine using the following code
//if(FAILED(DnsQueryConfig(
// DnsConfigPrimaryDomainName_UTF8,
// FALSE,
// NULL,
// NULL,
// cszDomainName,
// &size
// )))
//{
// //break;
//}
//LPWSTR lpcszContent = NULL;
//if(int cbMultiByte = MultiByteToWideChar(CP_UTF8, 0, cszDomainName, -1,NULL,0))
//{
// lpcszContent = new wchar_t[cbMultiByte];
//
// if(NULL!= lpcszContent)
// {
// if(0 == MultiByteToWideChar(CP_UTF8, 0, cszDomainName, -1, lpcszContent, cbMultiByte))
// {
// delete [] lpcszContent;
// break;
// }
// }
//}
//if(NULL != lpcszContent)
//{
// cstrDomainName.Format(L"%s", lpcszContent);
//
// printf("Domain name UTF-8 character: %s", lpcszContent);
// delete lpcszContent;
//}
The code works fine on an English machine. But on a machine with Brazilian OS the domain name is retrieved as junk characters.
Is there anything wrong with the code? Please help.
Thanks