阅读:5274回复:1
怎样使用RtlQueryRegistryValues注册表函数
怎样使用这个函数呢?
我在msdn中看到如下: QueryTable Points to a table of one or more value names and subkey names in which the caller is interested. Each table entry contains a caller-supplied QueryRoutine that will be called for each value name that exists in the registry. The table must be terminated with a NULL table entry, which is a table entry with a NULL QueryRoutine and a NULL Name field. //************ The caller specifies an initial key path and a table. The table contains one or more entries that describe the key values and subkey names in which the caller is interested. RtlQueryRegistryValues starts at the initial key and enumerates the entries in the table. For each entry specifying a value name or subkey name that exists in the registry, RtlQueryRegistryValues calls the QueryRoutine associated with each table entry. *** Each entry’s caller-supplied QueryRoutine is passed the value name, type, data, and data length. *** When building the QueryTable, be sure to allocate an entry for each value being queried, plus a NULL entry at the end. Zero the table and then initialize the entries. 哪位大侠帮忙解释一下,如果我在注册表中注册了两个值怎样读? 我的程序如下: RTL_QUERY_REGISTRY_TABLE paramTable[2]; RtlZeroMemory( paramTable, sizeof(paramTable) ); //clear zero给三个内存空间清0 paramTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; paramTable[0].Name = L"Device0"; paramTable[0].EntryContext = &serialPort; paramTable[0].DefaultType = REG_SZ; paramTable[0].DefaultData = &serialPort; paramTable[0].DefaultLength = 0; status = RtlQueryRegistryValues( RTL_REGISTRY_ABSOLUTE, parameterPath.Buffer,//注册表的位置 ¶mTable[0], NULL, NULL ); 我安装了两个设备,注册表\Parameters下有两个值\Device0 "com1"和\Device1 "com2",如果驱动执行两个设备,还需要再初始化一个paramTable[1]吗?还是不用? 请大侠赐教! |
|
|
沙发#
发布于:2001-10-26 14:30
如果你想在注册表中读取2个值,你就必须定义如下:
RTL_QUERY_REGISTRY_TABLE paramTable[3]; 最后一项必须是空的,所以数组的长度是3,而不是2。第三项不用赋值,因为它自动为空。 你把defaultType置为REG_SZ,说明你要读字符串,这serialPort必须是UNICODE_STRING类型的,同时defaultData和entryContext不能赋相同的值。defaultData必须用一个已经赋值的UNICODE_STRING类的变量的指针给它赋值。 如果是在注册表的device0\com0和device1\com1下的两个值,则必须定义两个如下数组: RTL_QUERY_REGISTRY_TABLE paramTable0[2]; RTL_QUERY_REGISTRY_TABLE paramTable1[2]; |
|