WdfRegistryAssignMultiString, fonction (wdfregistry.h)

[S’applique à KMDF et UMDF]

La méthode WdfRegistryAssignMultiString affecte un ensemble 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 d’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 de framework.

Valeur retournée

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
STATUS_INVALID_DEVICE_REQUEST

WdfRegistryAssignMultiString n’a pas été appelé dans IRQL = PASSIVE_LEVEL.

STATUS_INVALID_PARAMETER
Un paramètre non valide a été spécifié ou la collection spécifiée par le paramètre StringsCollection ne contenait aucun objet de chaîne.
STATUS_ACCESS_DENIED
Le pilote n’a pas ouvert la clé de Registre avec accès KEY_SET_VALUE.
 

Cette méthode peut également retourner d’autres valeurs NTSTATUS.

Un bogue case activée 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 spécifiée par StringsCollection 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 les pilotes Framework-Based.

Exemples

L’exemple de code suivant crée un objet de collection et deux objets chaîne, ajoute les objets string à 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.
}

Configuration requise

Condition requise Valeur
Plateforme cible Universal
Version KMDF minimale 1.0
Version UMDF minimale 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)

Voir aussi

RtlInitUnicodeString

UNICODE_STRING

WdfCollectionAdd

WdfCollectionCreate

WdfObjectDelete

WdfRegistryAssignMemory

WdfRegistryAssignString

WdfRegistryAssignULong

WdfRegistryAssignUnicodeString

WdfRegistryAssignValue

WdfStringCreate