Directory Services |
The IADsPathname::GetNumElements method retrieves the number of elements in the path.
HRESULT GetNumElements( long* dwNumPathElements );
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. |
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.
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.
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);
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.