Platform SDK: Active Directory, ADSI, and Directory Services

IADsWinNTSystemInfo 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 in Vtable Order

Property Description
UserName

[Visual Basic]
Access: Read
Data Type: BSTR

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

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

[Visual Basic]
Access: Read
Data Type: BSTR

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

Name of the host computer where the application is running.
DomainName

[Visual Basic]
Access: Read
Data Type: BSTR

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

Name of the domain to which the user belongs.
PDC

[Visual Basic]
Access: Read
Data Type: BSTR

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

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

Example Code [C++]

The following C++ code snippet retrieves the Windows NTŪ 4.0 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;
}

Example Code [Visual Basic]

The following Visual BasicŪ code snippet retrieves the Windows NT 4.0 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

Example Code [VBScript]

The following Visual BasicŪ Scripting Edition/Active Server Pages code snippet retrieves the Windows NT 4.0 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
%>

See Also

IADsWinNTSystemInfo