Skip to content

获取系统注册表路径 - RegistryGetSystemRegistryPath

函数简介

获取系统配置相关的注册表路径。

接口名称

RegistryGetSystemRegistryPath

DLL调用

cpp
int64_t RegistryGetSystemRegistryPath(int64_t instance);

参数说明

参数名类型说明
instance长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
std::string path = ola.RegistryGetSystemRegistryPath();
csharp
using OLAPlug;

var ola = new OLAPlugServer();
string path = ola.RegistryGetSystemRegistryPath();
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
path = ola.RegistryGetSystemRegistryPath()
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
ola.RegistryGetSystemRegistryPath();
cpp
var ola = com("OlaPlug.OlaSoft")
ola.RegistryGetSystemRegistryPath();
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ola.RegistryGetSystemRegistryPath();
text
.局部变量 ola, OLAPlug
ola.创建 ()
ola.RegistryGetSystemRegistryPath();
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
ola.RegistryGetSystemRegistryPath();
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
ola.RegistryGetSystemRegistryPath();
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
ola.RegistryGetSystemRegistryPath();

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
long ptr = RegistryGetSystemRegistryPath(instance);
if (ptr != 0) {
    char buffer[512] = {0};
    GetStringFromPtr(ptr, buffer, sizeof(buffer));
    FreeStringPtr(ptr);
}
csharp
using System.Runtime.InteropServices;
using System.Text;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long RegistryGetSystemRegistryPath(long ola);

long instance = CreateCOLAPlugInterFace();
long ptr = RegistryGetSystemRegistryPath(instance);
if (ptr != 0) {
    StringBuilder sb = new StringBuilder(GetStringSize(ptr) + 1);
    GetStringFromPtr(ptr, sb, sb.Capacity);
    FreeStringPtr(ptr);
    string path = sb.ToString();
}
python
from ctypes import CDLL, c_int, c_int64

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ptr = ola.RegistryGetSystemRegistryPath(instance)

返回值

长整数型。成功返回注册表路径字符串指针,失败返回 0。返回的字符串指针需调用 FreeStringPtr 释放内存。

注意事项

  • 返回的路径通常指向Windows CurrentVersion配置。
  • 该路径下包含系统版本、安装路径、卸载信息等。
  • 路径相对于 HKEY_LOCAL_MACHINE 根键。
  • 访问此路径下的某些键可能需要管理员权限。