Skip to content

枚举子键 - RegistryEnumSubKeys

函数简介

枚举当前注册表键下的所有子键名称,返回JSON数组格式。

接口名称

RegistryEnumSubKeys

DLL调用

cpp
int64_t RegistryEnumSubKeys(int64_t instance, int64_t key);

参数说明

参数名类型说明
instance长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
key长整数型注册表键句柄,由 RegistryOpenKeyRegistryCreateKey 返回。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
// rootKey=1 表示 HKEY_CURRENT_USER
long key = ola.RegistryOpenKey(1, "Software\\OLAPlug");
if (key != 0) {
    std::string subKeys = ola.RegistryEnumSubKeys(key);
    ola.RegistryCloseKey(key);
}
csharp
using OLAPlug;

var ola = new OLAPlugServer();
long key = ola.RegistryOpenKey(1, @"Software\OLAPlug");
if (key != 0)
{
    string subKeys = ola.RegistryEnumSubKeys(key);
    ola.RegistryCloseKey(key);
}
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
key = ola.RegistryOpenKey(1, r"Software\OLAPlug")
if key != 0:
    sub_keys = ola.RegistryEnumSubKeys(key)
    ola.RegistryCloseKey(key)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
long key = ola.RegistryOpenKey(1, "Software\\OLAPlug");
if (key != 0) {
    ola.RegistryEnumSubKeys(key);
    ola.RegistryCloseKey(key);
}
cpp
var ola = com("OlaPlug.OlaSoft")
var key = ola.RegistryOpenKey(1, "Software\\OLAPlug")
if(key) {
    ola.RegistryEnumSubKeys(key);
    ola.RegistryCloseKey(key)
}
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
key = ola.RegistryOpenKey(1, "Software\OLAPlug")
If key <> 0 Then
    ola.RegistryEnumSubKeys(key);
    ola.RegistryCloseKey(key)
End If
text
.局部变量 ola, OLAPlug
ola.创建 ()
key = ola.RegistryOpenKey (1, “Software\\OLAPlug“)
.如果真 (key ≠ 0)
    ola.RegistryEnumSubKeys(key);
    ola.RegistryCloseKey (key)
.如果真结束
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var key = ola.RegistryOpenKey(1, "Software\\OLAPlug");
if(key){
    ola.RegistryEnumSubKeys(key);
    ola.RegistryCloseKey(key);
}
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 key = ola.RegistryOpenKey(1, "Software\\OLAPlug")
如果真 (key ≠ 0)
{
    ola.RegistryEnumSubKeys(key);
    ola.RegistryCloseKey(key)
}
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
long key = ola.RegistryOpenKey(1, "Software\\OLAPlug");
if (key != 0) {
    ola.RegistryEnumSubKeys(key);
    ola.RegistryCloseKey(key);
}

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
long key = RegistryOpenKey(instance, 1, "Software\\OLAPlug");
if (key != 0) {
    RegistryEnumSubKeys(instance, key, 0);
    RegistryCloseKey(instance, key);
}
csharp
using System.Runtime.InteropServices;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();

long instance = CreateCOLAPlugInterFace();
long key = RegistryOpenKey(instance, 1, @"Software\OLAPlug");
if (key != 0)
{
    RegistryEnumSubKeys(instance, key, 0);
    RegistryCloseKey(instance, key);
}
python
from ctypes import CDLL, c_int, c_int64

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
key = ola.RegistryOpenKey(instance, 1, b"Software\\OLAPlug")
if key:
    RegistryEnumSubKeys(instance, key, 0);
    ola.RegistryCloseKey(instance, key)

返回值

返回值说明
(返回值)长整数型。成功返回包含所有子键名称的JSON数组字符串指针,例如 ["SubKey1","SubKey2"];失败或无子键返回 0 或空数组 []。返回的字符串指针需调用 FreeStringPtr 释放内存。

注意事项

项目说明
格式返回的是JSON数组格式,需要解析后使用。
返回直接子键名称仅返回直接子键名称,不包含子键的子键。
子键名称按字母顺序排列子键名称按字母顺序排列。