WdfRegistryAssignMultiString, fonction (wdfregistry.h)
[S’applique à KMDF et UMDF]
La méthode WdfRegistryAssignMultiString attribue un jeu de chaînes à un nom de valeur spécifié dans le Registre. Les chaînes sont contenues dans une collection spécifiée d’objets de chaîne d’infrastructure.
Syntaxe
NTSTATUS WdfRegistryAssignMultiString(
[in] WDFKEY Key,
[in] PCUNICODE_STRING ValueName,
[in] WDFCOLLECTION StringsCollection
);
Paramètres
[in] Key
Handle vers un objet de clé de Registre qui représente une clé de Registre ouverte.
[in] ValueName
Pointeur vers une structure UNICODE_STRING qui contient un nom de valeur.
[in] StringsCollection
Handle vers un objet de collection d’infrastructure qui représente une collection d’objets de chaîne d’infrastructure.
Valeur de retour
WdfRegistryAssignMultiString retourne STATUS_SUCCESS si l’opération réussit. Sinon, la méthode peut retourner l’une des valeurs suivantes :
Code de retour | Description |
---|---|
|
WdfRegistryAssignMultiString n’a pas été appelée à IRQL = PASSIVE_LEVEL. |
|
Un paramètre non valide a été spécifié ou la collection que le paramètre StringsCollection spécifié ne contenait aucun objet de chaîne. |
|
Le pilote n’a pas ouvert la clé de Registre avec KEY_SET_VALUE accès. |
Cette méthode peut également retourner d’autres valeurs NTSTATUS .
Une vérification de bogue se produit si le pilote fournit un handle d’objet non valide.
Remarques
Si le nom de valeur spécifié par le paramètre ValueName existe déjà, WdfRegistryAssignMultiString met à jour les données de la valeur.
L’infrastructure définit le type de données de la valeur sur REG_MULTI_SZ.
La collection d’objets qui StringsCollection spécifie doit contenir uniquement des objets de chaîne d’infrastructure.
Pour plus d’informations sur les objets de clé de Registre, consultez Utilisation du Registre dans Framework-Based Drivers.
Exemples
L’exemple de code suivant crée un objet de collection et deux objets de chaîne, ajoute les objets de chaîne à la collection, puis affecte les deux chaînes à une valeur de Registre.
WDF_OBJECT_ATTRIBUTES attributes;
WDFCOLLECTION col = NULL;
WDFSTRING string1 = NULL, string2 = NULL;
UNICODE_STRING ustring1, ustring2, valueName;
NTSTATUS status;
status = WdfCollectionCreate(
WDF_NO_OBJECT_ATTRIBUTES,
&col
);
if (!NT_SUCCESS(status) {
return status;
}
RtlInitUnicodeString(
&ustring1,
L"String1"
);
RtlInitUnicodeString(
&ustring2,
L"String2"
);
RtlInitUnicodeString(
&valueName,
L"ValueName"
);
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
attributes.ParentObject = col;
status = WdfStringCreate(
&ustring1,
&attributes,
&string1
);
if (!NT_SUCCESS(status)) {
goto exit;
}
status = WdfStringCreate(
&ustring2,
&attributes,
&string2
);
if (!NT_SUCCESS(status)) {
goto exit;
}
status = WdfCollectionAdd(
col,
string1
);
if (!NT_SUCCESS(status)) {
goto exit;
}
string1 = NULL;
status = WdfCollectionAdd(
col,
string2
);
if (!NT_SUCCESS(status)) {
goto exit;
}
string2 = NULL;
status = WdfRegistryAssignMultiString(
Key,
&valueName,
col
);
if (!NT_SUCCESS(status)) {
goto exit;
...
exit:
if (col != NULL) {
WdfObjectDelete(col); // This will empty the collection
// because the string objects are
// child objects of the collection object.
}
Spécifications
Besoin | Valeur |
---|---|
plateforme cible | Universel |
version minimale de KMDF | 1.0 |
version minimale de UMDF | 2.0 |
En-tête | wdfregistry.h (include Wdf.h) |
Bibliothèque | Wdf01000.sys (KMDF) ; WUDFx02000.dll (UMDF) |
IRQL | PASSIVE_LEVEL |
règles de conformité DDI | DriverCreate(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf) |