Skip to content

备份注册表到文件 - RegistryBackupToFile

函数简介

备份注册表键到.reg格式文件。

接口名称

RegistryBackupToFile

DLL调用

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

参数说明

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

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int ret = ola.RegistryBackupToFile(1, "Software\\OLAPlug", "backup/olaplug.reg");
csharp
using OLAPlug;

var ola = new OLAPlugServer();
int ret = ola.RegistryBackupToFile(1, @"Software\OLAPlug", "backup/olaplug.reg");
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
ret = ola.RegistryBackupToFile(1, r"Software\OLAPlug", "backup/olaplug.reg")
java
import com.olaplug.OLAPlugServer;

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

OLAPlugServer ola;
int32_t ret = ola.RegistryBackupToFile(1, "Software\\OLAPlug", "backup/olaplug.reg");

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
RegistryBackupToFile(instance, 1, "Software\\OLAPlug", "backup/olaplug.reg");
csharp
using System.Runtime.InteropServices;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
long instance = CreateCOLAPlugInterFace();
RegistryBackupToFile(instance, 1, @"Software\OLAPlug", "backup/olaplug.reg");
python
from ctypes import CDLL, c_int, c_int64

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ola.RegistryBackupToFile(instance, 1, b"Software\\OLAPlug", b"backup/olaplug.reg")

返回值

整数型。1 成功,0 失败。

注意事项

  • 文件将以标准.reg格式保存,可以使用regedit导入。
  • 备份文件包含指定键及其所有子键和值。
  • 备份系统级键可能需要管理员权限。
  • 确保目标文件路径可写。
  • 文件编码为UTF-16 LE(Windows标准.reg格式)。