读取32位整型值 - RegistryGetDword
函数简介
读取32位整型的注册表值(REG_DWORD)。
接口名称
RegistryGetDword
DLL调用
int32_t RegistryGetDword(int64_t instance, int64_t key, const char* valueName);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| key | 长整数型 | 注册表键句柄,由 RegistryOpenKey 或 RegistryCreateKey 返回 |
| valueName | 字符串 | 值名称 |
示例
int64_t instance = CreateCOLAPlugInterFace();
int64_t key = RegistryOpenKey(instance, 1, "Software\\OLAPlug\\Config");
if (key != 0) {
int32_t version = RegistryGetDword(instance, key, "Version");
int32_t enabled = RegistryGetDword(instance, key, "Enabled");
RegistryCloseKey(instance, key);
}
DestroyCOLAPlugInterFace(instance);
返回值
整数型。成功返回读取到的32位整型值,失败或不存在返回 0。
注意事项
- 如果值不存在或类型不匹配,将返回 0。
- 无法区分返回的 0 是实际值还是错误标志。
- REG_DWORD 类型为32位无符号整数。
