设置64位整型值 - RegistrySetQword
函数简介
设置64位整型的注册表值(REG_QWORD),用于存储大数值型配置。
接口名称
RegistrySetQword
DLL调用
int32_t RegistrySetQword(int64_t instance, int64_t key, const char* valueName, int64_t value)
参数定义:
instance(长整型数): OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。key(长整型数): 注册表键句柄,由 RegistryOpenKey 或 RegistryCreateKey 返回valueName(字符串): 值名称value(长整型数): 要写入的64位整型值
示例:
// 创建OLA对象
int64_t instance = CreateCOLAPlugInterFace();
// 创建或打开注册表键
int64_t key = RegistryCreateKey(instance, 1, "Software\\OLAPlug\\Statistics");
if (key != 0) {
// 设置总访问次数(大数值)
int32_t result = RegistrySetQword(instance, key, "TotalVisits", 10000000000LL);
if (result == 1) {
printf("成功设置访问次数\n");
}
// 设置文件大小(字节)
result = RegistrySetQword(instance, key, "FileSize", 5368709120LL); // 5GB
// 设置时间戳(毫秒)
int64_t timestamp = 1640000000000LL;
result = RegistrySetQword(instance, key, "LastUpdate", timestamp);
// 关闭注册表键
RegistryCloseKey(instance, key);
}
// 释放资源
DestroyCOLAPlugInterFace(instance);
返回值
整型数:
- 1: 成功
- 0: 失败
注意事项
- 如果值名称已存在,将覆盖原有值
- REG_QWORD 类型为64位无符号整数,范围为 0 到 18,446,744,073,709,551,615
- 适用于存储大数值,如文件大小、时间戳、大数计数器等
- 在32位系统上也可以使用此类型
