Skip to content

枚举值名称 - RegistryEnumValues

函数简介

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

接口名称

RegistryEnumValues

DLL调用

cpp
int64_t RegistryEnumValues(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 values = ola.RegistryEnumValues(key);
    ola.RegistryCloseKey(key);
}
csharp
using OLAPlug;

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

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

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

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

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
long key = RegistryOpenKey(instance, 1, "Software\\OLAPlug");
if (key != 0) {
    RegistryEnumValues(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)
{
    RegistryEnumValues(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:
    RegistryEnumValues(instance, key, 0);
    ola.RegistryCloseKey(instance, key)

返回值

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

注意事项

项目说明
格式返回的是JSON数组格式,需要解析后使用。
默认值默认值(空名称)可能显示为空字符串 ""
不包含值的类型和数据不包含值的类型和数据,仅包含名称。