WdfRegistryAssignMultiString 函式 (wdfregistry.h)

[適用於 KMDF 和 UMDF]

WdfRegistryAssignMultiString 方法會將一組字串指派給登錄中的指定值名稱。 字串包含在架構字串物件的指定集合中。

語法

NTSTATUS WdfRegistryAssignMultiString(
  [in] WDFKEY           Key,
  [in] PCUNICODE_STRING ValueName,
  [in] WDFCOLLECTION    StringsCollection
);

參數

[in] Key

表示已開啟登錄機碼之登錄機碼物件的句柄。

[in] ValueName

包含值名稱 之UNICODE_STRING 結構的指標。

[in] StringsCollection

架構集合物件的句柄,表示架構字串物件的集合。

傳回值

如果作業成功,WdfRegistryAssignMultiString 會傳回STATUS_SUCCESS。 否則,方法可能會傳回下列其中一個值:

傳回碼 Description
STATUS_INVALID_DEVICE_REQUEST

在 IRQL = PASSIVE_LEVEL未呼叫 WdfRegistryAssignMultiString

STATUS_INVALID_PARAMETER
指定了無效的參數,或 指定 StringsCollection 參數未包含任何字串物件的集合。
STATUS_ACCESS_DENIED
驅動程式未開啟具有KEY_SET_VALUE存取權的登錄機碼。
 

這個方法也可能傳回其他 NTSTATUS值

如果驅動程式提供無效的物件句柄,就會發生錯誤檢查。

備註

如果 ValueName 參數指定的值名稱已經存在, WdfRegistryAssignMultiString 會更新值的數據。

架構會將值的數據類型設定為REG_MULTI_SZ。

StringsCollection 指定的物件集合必須只包含架構字串物件。

如需登錄機碼對象的詳細資訊,請參閱 在 Framework-Based Drivers 中使用登錄

範例

下列程式代碼範例會建立集合物件和兩個字元串物件、將字串物件新增至集合,然後將兩個字串指派給一個登錄值。

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.
}

規格需求

需求
目標平台 Universal
最小 KMDF 版本 1.0
最低UMDF版本 2.0
標頭 wdfregistry.h (包含 Wdf.h)
程式庫 Wdf01000.sys (KMDF) ;WUDFx02000.dll (UMDF)
IRQL PASSIVE_LEVEL
DDI 合規性規則 DriverCreate (kmdf) KmdfIrql (kmdf) KmdfIrql2 (kmdf) 、 KmdfIrqlExplicit (kmdf)

另請參閱

RtlInitUnicodeString

UNICODE_STRING

WdfCollectionAdd

WdfCollectionCreate

WdfObjectDelete

WdfRegistryAssignMemory

WdfRegistryAssignString

WdfRegistryAssignULong

WdfRegistryAssignUnicodeString

WdfRegistryAssignValue

WdfStringCreate