关闭注册表键 - RegistryCloseKey
函数简介
关闭注册表键句柄,释放系统资源。
接口名称
RegistryCloseKey
DLL调用
int32_t RegistryCloseKey(int64_t instance, int64_t key);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| key | 长整数型 | 注册表键句柄,由 RegistryOpenKey 或 RegistryCreateKey 返回 |
示例
int64_t instance = CreateCOLAPlugInterFace();
int64_t key = RegistryOpenKey(instance, 1, "Software\\Microsoft\\Windows");
if (key != 0) {
// 执行操作...
RegistryCloseKey(instance, key);
}
DestroyCOLAPlugInterFace(instance);
返回值
整数型。1 成功,0 失败。
注意事项
- 关闭后句柄失效,不可再使用。
- 每个打开的注册表键都必须调用此函数关闭,避免资源泄漏。
- 重复关闭同一个句柄可能导致失败。
