case regtypestring '=&h00000003 'string
'调用实例:
'sysregcontrol reghkey_local_machine, "jadgekylin\jklpos", "pos", "1", regtypestring, regsetkeyvalue
'----------------------------------------------------------------------------------------
if vartype(keyvalue) <> vbstring then '参数不合法
rtn = error_success + 1
'exit select
else
rtn = regsetvalueex(hkey, key, 0, reg_sz, byval keyvalue, len(keyvalue)) 'write the value
end if
'----------------------------------------------------------------------------------------
end select
'}
if not rtn = error_success then 'if the was an error writting the value
rtn = regclosekey(hkey)
sysregcontrol = false '调用失败
exit function
end if
rtn = regclosekey(hkey) 'close the key
end if 'rtn = error_success
'=========================================================================================
case reggetkeyvalue '=112 '取键值
'=========================================================================================
rtn = regopenkeyex(rootkey, subkey, 0, key_read, hkey)
if rtn = error_success then 'if the key could be opened
'{
select case regkeytype
'----------------------------------------------------------------------------------------
case regtypebinary '=&h00000001 'binary
'keyvalue作为传值变量获得键值,调用示例:
'dim a as string
'sysregcontrol reghkey_local_machine, "jadgekylin\jklpos", "pos", a, regtypebinary, reggetkeyvalue
'----------------------------------------------------------------------------------------
rtn = regqueryvalueex(hkey, key, 0, reg_binary, 0, lbuffersize) 'get the value from the registry
sbuffer = space(lbuffersize)
rtn = regqueryvalueex(hkey, key, 0, reg_binary, sbuffer, lbuffersize) 'get the value from the registry
if not rtn = error_success then 'if the was an error writting the value
rtn = regclosekey(hkey)
sysregcontrol = false '调用失败
exit function
else
keyvalue = sbuffer
end if
rtn = regclosekey(hkey) 'close the key
'----------------------------------------------------------------------------------------