# Registry 操作注册表
CreateObject("Stock.Registry")
该对象封装了注册表操作的一些方法和属性。
方法
方法 | 说明 |
---|---|
Open | 打开并初始化一个注册表对象,对注册表操作之前,一定需要调用此函数来初始化该对象。 |
ReadInt | 读指定键值的整型数值。 返回值:返回读出的数据,如果失败,此值为0 |
ReadString | 读指定键值的字符串数据。 注意:如果频繁调用该属性,请注意使用完毕后释放返回值。 |
WriteInt | 写指定键值的整型数值 |
WriteString | 写指定键值的字符串数值 |
示例
Function TestRegistry()
Set registry = CreateObject("stock.registry")
Call registry.Open("software\weisoft\金字塔\vba")
result=registry.ReadInt("id")
TestRegistry = result
set registry = nothing '对象使用完要释放,负责会出现内存泄露
End Function
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8