枚举子键 - RegistryEnumSubKeys
函数简介
枚举当前注册表键下的所有子键名称,返回JSON数组格式。
接口名称
RegistryEnumSubKeys
DLL调用
int64_t RegistryEnumSubKeys(int64_t instance, int64_t key);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| key | 长整数型 | 注册表键句柄,由 RegistryOpenKey 或 RegistryCreateKey 返回 |
示例
int64_t instance = CreateCOLAPlugInterFace();
int64_t key = RegistryOpenKey(instance, 1, "Software\\Microsoft\\Windows\\CurrentVersion");
if (key != 0) {
int64_t jsonPtr = RegistryEnumSubKeys(instance, key);
if (jsonPtr != 0) {
const char* json = (const char*)jsonPtr;
// 输出示例: ["Uninstall","Run","RunOnce","Explorer"]
FreeStringPtr(instance, jsonPtr);
}
RegistryCloseKey(instance, key);
}
DestroyCOLAPlugInterFace(instance);
返回值
长整数型。成功返回包含所有子键名称的JSON数组字符串指针,例如 ["SubKey1","SubKey2"];失败或无子键返回 0 或空数组 []。返回的字符串指针需调用 FreeStringPtr 释放内存。
注意事项
- 返回的是JSON数组格式,需要解析后使用。
- 仅返回直接子键名称,不包含子键的子键。
- 子键名称按字母顺序排列。
