我想通过GetComputerObjectName
尝试获得计算机的简单 DisplayName:
//Get the buffer size
bRet = GetComputerObjectName(NameDisplay, NULL, & ulSize);
if(!bRet)
{
DWORD dw = 0;
dw = GetLastError();
MessageBox(NULL, TEXT("Could not get the computer name size."), TEXT("Failure."), MB_OK | MB_ICONERROR);
exit(-1);
}
//Create a buffer large enough to contain the display name
pBuffer = new TCHAR[ulSize+1];
//Obtain the computer object name
bRet = GetComputerObjectName(NameDisplay, pBuffer, &ulSize);
if(!bRet)
{
MessageBox(NULL, TEXT("Could not get the computer name."), TEXT("Failure."), MB_OK | MB_ICONERROR);
exit(-1);
}
但是调用GetComputerObjectName
失败并显示ERROR_CANT_ACCESS_DOMAIN_INFO。
我已经尝试启用特权*SE_SECURITY_NAME* 和 *SE_SYSTEM_PROFILE_NAME*,但这也不起作用。
任何人都知道如何做到这一点?