Skip to content

读取随机位置字符串值 - RegistryGetProtectedValue

函数简介

读取注册表随机位置保存的字符串值。随机位置由机器唯一标识和键值名称计算得出。

接口名称

RegistryGetProtectedValue

DLL调用

cpp
int64_t RegistryGetProtectedValue(int64_t instance, const char* key);

参数说明

参数名类型说明
instance长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
key字符串键值名称。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
std::string val = ola.RegistryGetProtectedValue("license_key");
csharp
using OLAPlug;

var ola = new OLAPlugServer();
string val = ola.RegistryGetProtectedValue("license_key");
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
val = ola.RegistryGetProtectedValue("license_key")
java
import com.olaplug.OLAPlugServer;

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

OLAPlugServer ola;
ola.RegistryGetProtectedValue("license_key");

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
long ptr = RegistryGetProtectedValue(instance, "license_key");
if (ptr != 0) {
    char buffer[256] = {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 RegistryGetProtectedValue(long ola, string key);

long instance = CreateCOLAPlugInterFace();
long ptr = RegistryGetProtectedValue(instance, "license_key");
if (ptr != 0) {
    StringBuilder sb = new StringBuilder(GetStringSize(ptr) + 1);
    GetStringFromPtr(ptr, sb, sb.Capacity);
    FreeStringPtr(ptr);
    string val = 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.RegistryGetProtectedValue(instance, b"license_key")

返回值

返回值说明
(返回值)长整数型。成功返回字符串内容的句柄(非0值),失败或不存在时返回 0。返回的字符串句柄需调用 FreeStringPtr 释放。

注意事项

项目说明
随机位置由机器唯一标识和键值名称共同计算得出随机位置由机器唯一标识和键值名称共同计算得出。
每个用户独立计算每个用户独立计算,互不干扰。
重启后可继续读取此前写入的值重启后可继续读取此前写入的值。