[适用于 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。 否则,该方法可能会返回以下值之一:
| 返回代码 | 说明 |
|---|---|
|
未在 IRQL = PASSIVE_LEVEL 调用 WdfRegistryAssignMultiString。 |
|
指定了无效参数,或者指定了 StringsCollection 参数的集合不包含任何字符串对象。 |
|
驱动程序未打开具有KEY_SET_VALUE访问权限的注册表项。 |
此方法还可以 返回其他NTSTATUS 值。
如果驱动程序提供无效的对象句柄,则会发生 bug 检查。
注解
如果 ValueName 参数指定的值名称已存在,WdfRegistryAssignMultiString 更新值的数据。
框架将值的数据类型设置为REG_MULTI_SZ。
StringsCollection 指定的对象集合必须仅包含框架字符串对象。
有关注册表项对象的详细信息,请参阅 使用 Framework-Based 驱动程序中的注册表。
例子
下面的代码示例创建一个集合对象和两个字符串对象,将字符串对象添加到集合,然后将两个字符串分配给一个注册表值。
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.
}
要求
| 要求 | 价值 |
|---|---|
| 目标平台 | 普遍 |
| 最低 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) |