大网数据广告活动
域与目录服务

IADsWinNTSystemInfo Property Methods (Iads.h)

· 52CE 我爱测

The property methods of the IADsWinNTSystemInfo interface get or set the properties described in the following table. For more information, see Interface Property Methods.

The property methods of the IADsWinNTSystemInfo interface get or set the properties described in the following table. For more information, see Interface Property Methods.

Properties

ComputerName

Name of the host computer where the application is running.

Access type: Read-only

Scripting data type: BSTR

// C++ method syntax
HRESULT get_ComputerName(
  [out] BSTR* pbstrComputer
);

DomainName

Name of the domain to which the user belongs.

Access type: Read-only

Scripting data type: BSTR

// C++ method syntax
HRESULT get_DomainName(
  [out] BSTR* pbstrDomain
);

PDC

Name of the primary domain controller to which the host computer belongs.

Access type: Read-only

Scripting data type: BSTR

// C++ method syntax
HRESULT get_PDC(
  [out] BSTR* pbstrPDC
);

UserName

Name of the user account under which the WinNTSystemInfo object is created.

Access type: Read-only

Scripting data type: BSTR

// C++ method syntax
HRESULT get_UserName(
  [out] BSTR* pbstrUser
);

Examples

The following C/C++ code example retrieves the WinNT system information. For brevity, error checking is omitted.

#include <activeds.h>
#include <stdio.h>
 
int main()
{
   HRESULT hr;
 
   hr = CoInitialize(NULL);
 
    IADsWinNTSystemInfo *pNtSys;
    hr = CoCreateInstance(CLSID_WinNTSystemInfo,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IADsWinNTSystemInfo,
                          (void**)&pNTsys);
 
   BSTR bstr;
   hr = pNtSys->get_UserName(&bstr);
   if (SUCCEEDED(hr)) {
      printf("User: %S\n", bstr);
      SysFreeString(bstr);
   }
 
   hr = pNtSys->get_ComputerName(&bstr);
   if (SUCCEEDED(hr)) {
      printf("Computer: %S\n", bstr);
      SysFreeString(bstr);
   }
 
   hr = pNtSys->get_DomainName(&bstr);
   if (SUCCEEDED(hr)) {
      printf("Domain: %S\n", bstr);
      SysFreeString(bstr);
   }
 
   hr = pNtSys->get_PDC(&bstr);
   if (SUCCEEDED(hr)) {
      printf("PDC: %S\n", bstr);
      SysFreeString(bstr);
   }
 
   if(pNtSys) {
      pNtSys->Release();
   }
 
   CoUninitialize();
   return 0;
}

The following Visual Basic code example retrieves the WinNT system information.

Dim ntsys As New WinNTSystemInfo
Debug.print "User: " & ntsys.UserName
Debug.print "Computer: " & ntsys.ComputerName
Debug.print "Domain: " & ntsys.DomainName
Debug.print "PDC: " & ntsys.PDC

The following Visual Basic Scripting Edition/Active Server Pages code example retrieves the WinNT system information.

<%
Dim ntsys
Set ntsys = CreateObject("WinNTSystemInfo")
Response.Write "User: " & ntsys.UserName
Response.Write "Computer: " & ntsys.ComputerName
Response.Write "Domain: " & ntsys.DomainName
Response.Write "PDC: " & ntsys.PDC
%>

Requirements

Requirement Value
Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Header Iads.h
DLL Activeds.dll
IID IID_IADsWinNTSystemInfo is defined as 6C6D65DC-AFD1-11D2-9CB9-0000F87A369E

See also

IADsWinNTSystemInfo

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。