主题
判断注册表键是否存在 - RegistryKeyExists
函数简介
判断指定的注册表键是否存在。
接口名称
RegistryKeyExistsDLL调用
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");go
import "github.com/ola/olaplug/olaplug"
ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
exists := ola.RegistryKeyExists(1, "Software\\OLAPlug")
if exists == 1 {
key := ola.RegistryOpenKey(1, "Software\\OLAPlug")
ola.RegistryCloseKey(key)
}rust
use olaplug::OLAPlugServer;
let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
let exists = ola.registry_key_exists(1, "Software\\OLAPlug");
if exists == 1 {
let key = ola.registry_open_key(1, "Software\\OLAPlug");
ola.registry_close_key(&key);
}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 不存在。 |
注意事项
| 项目 | 说明 |
|---|---|
| 此函数仅判断键是否存在 | 此函数仅判断键是否存在,不打开键。 |
| 可用于在创建或打开键之前进行检查 | 可用于在创建或打开键之前进行检查。 |
