IADsPropertyValue ::Clear, méthode (iads.h)
La méthode IADsPropertyValue ::Clear efface les valeurs actuelles de l’objet de valeur de propriété.
Syntaxe
HRESULT Clear();
Valeur de retour
Cette méthode prend en charge les valeurs de retour HRESULT standard, y compris S_OK. Pour plus d’informations et d’autres valeurs de retour, consultez Codes d’erreur ADSI.
Notes
None
Exemples
L’exemple de code suivant montre comment utiliser IADsPropertyValue ::Clear pour effacer la valeur de la propriété « description » d’une liste de propriétés.
Dim propList As IADsPropertyList
Dim propEntry As IADsPropertyEntry
Dim propVal As IADsPropertyValue
On Error GoTo Cleanup
' Get the property list.
Set propList = GetObject("LDAP://dc01/DC=Fabrikam,DC=com")
propList.GetInfo
' Get a property entry. If you know the exact type of the property,
' replace ADSTYPE_UNKNOWN with that type.
Set propEntry = propList.GetPropertyItem("description", ADSTYPE_UNKNOWN)
' Clear all the values of the property entry.
For Each v In propEntry.Values
Set propVal = v
propVal.Clear
Next
propList.SetInfo
Cleanup:
If (Err.Number<>0) Then
MsgBox("An error has occurred. " & Err.Number)
End If
Set propList = Nothing
Set propEntry = Nothing
Set propVal = Nothing
L’exemple de code suivant montre comment utiliser IADsPropertyValue ::Clear pour effacer la valeur de la propriété « description » d’une liste de propriétés.
#include <activeds.h>
#include <stdio.h>
IADsPropertyList *pList = NULL;
IADsPropertyEntry *pEntry = NULL;
IADsPropertyValue *pVal = NULL;
IADs *pObj = NULL;
VARIANT var, varItem;
BSTR valStr;
IEnumVARIANT *pEnum = NULL;
LONG lstart, lend;
VariantInit(&var);
VariantInit(&varItem);
// Bind to the directory object.
HRESULT hr = ADsGetObject(L"LDAP://dc01/DC=Fabrikam,DC=com",
IID_IADsPropertyList,
(void**)&pList);
if(FAILED(hr)){goto Cleanup;}
// Initialize the property cache.
hr = pList->QueryInterface(IID_IADs,(void**)&pObj);
if(FAILED(hr)){goto Cleanup;}
pObj->GetInfo();
pObj->Release();
// Get a property entry.
hr = pList->GetPropertyItem(CComBSTR("description"), ADSTYPE_UNKNOWN, &var);
if(FAILED(hr)){goto Cleanup;}
pList->Release();
hr = V_DISPATCH(&var)->QueryInterface(IID_IADsPropertyEntry,
(void**)&pEntry);
if(FAILED(hr)){goto Cleanup;}
VariantClear(&var);
// Get the value array of the property entry.
hr = pEntry->get_Values(&var);
if(FAILED(hr)){goto Cleanup;}
SAFEARRAY *sa = V_ARRAY( &var );
// Get the lower and upper bound, iterate, and print the values.
hr = SafeArrayGetLBound( sa, 1, &lstart );
hr = SafeArrayGetUBound( sa, 1, &lend );
printf(" Property value(s) = ");
for ( long idx=lstart; idx < lend+1; idx++ ) {
hr = SafeArrayGetElement( sa, &idx, &varItem );
hr = V_DISPATCH(&varItem)->QueryInterface(IID_IADsPropertyValue,
(void**)&pVal);
VariantClear(&varItem);
hr = pVal->Clear();
if(FAILED(hr)){goto Cleanup;}
}
pList->SetInfo();
Cleanup:
if(pList)
pList->Release();
if(pEntry)
pEntry->Release();
if(pVal)
pVal->Release();
if(pObj)
pObj->Release();
if(pEnum)
pEnum->Release();
if(valStr)
SysFreeString(valStr);
VariantClear(&var);
VariantClear(&varItem);
Configuration requise
Condition requise | Valeur |
---|---|
Client minimal pris en charge | Windows Vista |
Serveur minimal pris en charge | Windows Server 2008 |
Plateforme cible | Windows |
En-tête | iads.h |
DLL | Activeds.dll |
Voir aussi
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour