Directory Services

IADsPathname::GetNumElements

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

HRESULT GetNumElements( 
  long* 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:

For more information and other return values, see ADSI Error Codes.

Return Code Description
S_OK The operation succeeded.
E_FAIL The operation failed.

Example Code [Visual Basic]

The following Visual Basic code example shows how to use GetNumElements.

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 example shows how to use GetNumElements.

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 example prints all the number of elements of a path. For more information and a code example of the GetPathnameObject function, see IADsPathname.

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

Requirements

Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension on Windows NT 4.0 SP6a and Windows 95/98/Me.
Header: Declared in Iads.h.

See Also

IADsPathname, ADSI Error Codes