Skip to content

判断注册表键是否存在 - RegistryKeyExists

函数简介

判断指定的注册表键是否存在。

接口名称

RegistryKeyExists

DLL调用

cpp
int32_t RegistryKeyExists(int64_t instance, int32_t rootKey, const char* subKey);

参数说明

参数名类型说明
instance长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
rootKey整数型根键类型:0 HKEY_CLASSES_ROOT、1 HKEY_CURRENT_USER、2 HKEY_LOCAL_MACHINE、3 HKEY_USERS、4 HKEY_CURRENT_CONFIG
subKey字符串子键路径

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int exists = ola.RegistryKeyExists(1, "Software\\OLAPlug");
if (exists == 1) {
    long key = ola.RegistryOpenKey(1, "Software\\OLAPlug");
    ola.RegistryCloseKey(key);
}
csharp
using OLAPlug;

var ola = new OLAPlugServer();
int exists = ola.RegistryKeyExists(1, @"Software\OLAPlug");
if (exists == 1)
{
    long key = ola.RegistryOpenKey(1, @"Software\OLAPlug");
    ola.RegistryCloseKey(key);
}
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
exists = ola.RegistryKeyExists(1, r"Software\OLAPlug")
if exists == 1:
    key = ola.RegistryOpenKey(1, r"Software\OLAPlug")
    ola.RegistryCloseKey(key)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
int exists = ola.RegistryKeyExists(1, "Software\\OLAPlug");
cpp
var ola = com("OlaPlug.OlaSoft")
var exists = ola.RegistryKeyExists(1, "Software\\OLAPlug")
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
exists = ola.RegistryKeyExists(1, "Software\OLAPlug")
text
.局部变量 ola, OLAPlug
ola.创建 ()
exists = ola.RegistryKeyExists (1, “Software\\OLAPlug“)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var exists = ola.RegistryKeyExists(1, "Software\\OLAPlug");
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 exists = ola.RegistryKeyExists(1, "Software\\OLAPlug")
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int32_t exists = ola.RegistryKeyExists(1, "Software\\OLAPlug");

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
int exists = RegistryKeyExists(instance, 1, "Software\\OLAPlug");
csharp
using System.Runtime.InteropServices;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();

long instance = CreateCOLAPlugInterFace();
int exists = RegistryKeyExists(instance, 1, @"Software\OLAPlug");
python
from ctypes import CDLL, c_int, c_int64

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
exists = ola.RegistryKeyExists(instance, 1, b"Software\\OLAPlug")

返回值

整数型。1 存在,0 不存在。

注意事项

  • 此函数仅判断键是否存在,不打开键。
  • 可用于在创建或打开键之前进行检查。