Platform SDK: Active Directory, ADSI, and Directory Services

IADsPathname::GetNumElements

The IADsPathname::GetNumElements method gets the number of elements in the path.

HRESULT IADsPathname::GetNumElements(
  DWORD * dwNumPathElements
);

Parameters

dwNumPathElements
[out] The number of elements in the path.

Return Values

This method supports the standard return values, as well as the following:

S_OK
The operation is successful.
E_FAIL
The operation has failed.

For other return values, see ADSI Error Codes.

Example Code [Visual Basic]

The following Visual Basic® code snippet shows how to use GenNumElements.

dim x As New Pathname
x.Set = "LDAP://srv1/dc=dom,dc=company,dc=com",ADS_SETTYPE_FULL
y = x.GetNumElements()     ' y = 3.

Example Code [VBScript]

The following VBScript code snippet shows how to use GenNumElements.

dim x 
Const ADS_SETTYPE_FULL = 1
Set x = CreateObject("Pathname")
x.Set = "LDAP://srv1/dc=dom,dc=company,dc=com",ADS_SETTYPE_FULL
y = x.GetNumElements()     ' y = 3.

Example Code [C++]

The following C++ code snippet prints out all the number of elements of a path. See the code snippet in IADsPathname for the GetPathnameObject function.

LPWSTR adsPath=L"LDAP://server/cn=jsmith,dc=Microsoft,dc=com";
 
IADsPathname *pPath = GetPathnameObject(adsPath);
long count=0;
HRESULT hr = pPath->GetNumElements(&count);
printf("Count = %d\n",count);

Requirements

  Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with DSClient).
  Windows 95/98: Requires Windows 95 or later (with DSClient).
  Header: Declared in Iads.h.

See Also

IADsPathname, ADSI Error Codes