rtn = regqueryvalueex(hkey, entry, 0, reg_binary, sbuffer, lbuffersize) 'get the value from the registry
if rtn = error_success then 'if the value could be retreived then
rtn = regclosekey(hkey) 'close the key
getbinaryvalue = sbuffer 'return the value to the user
else 'otherwise, if the value couldnt be retreived
getbinaryvalue = "error" 'return error to the user
if displayerrormsg = true then 'if the user wants to errors displayed
msgbox errormsg(rtn) 'display the error to the user
end if
end if
else 'otherwise, if the key couldnt be opened
getbinaryvalue = "error" 'return error to the user
if displayerrormsg = true then 'if the user wants to errors displayed
msgbox errormsg(rtn) 'display the error to the user
end if
end if
end if
end function
function deletekey(keyname as string)
call parsekey(keyname, mainkeyhandle)
if mainkeyhandle then
rtn = regopenkeyex(mainkeyhandle, keyname, 0, key_write, hkey) 'open the key
if rtn = error_success then 'if the key could be opened then
rtn = regdeletekey(hkey, keyname) 'delete the key
rtn = regclosekey(hkey) 'close the key
end if
end if
end function
function getmainkeyhandle(mainkeyname as string) as long
const hkey_classes_root = &h80000000
const hkey_current_user = &h80000001
const hkey_local_machine = &h80000002
const hkey_users = &h80000003
const hkey_performance_data = &h80000004
const hkey_current_config = &h80000005
const hkey_dyn_data = &h80000006
select case mainkeyname
case "hkey_classes_root"
getmainkeyhandle = hkey_classes_root
case "hkey_current_user"
getmainkeyhandle = hkey_current_user
case "hkey_local_machine"
getmainkeyhandle = hkey_local_machine
case "hkey_users"
getmainkeyhandle = hkey_users
case "hkey_performance_data"
getmainkeyhandle = hkey_performance_data
case "hkey_current_config"
getmainkeyhandle = hkey_current_config
case "hkey_dyn_data"
getmainkeyhandle = hkey_dyn_data
end select
end function
function errormsg(lerrorcode as long) as string
'if an error does accurr, and the user wants error messages displayed, then
'display one of the following error messages
select case lerrorcode
case 1009, 1015
geterrormsg = "the registry database is corrupt!"
case 2, 1010
geterrormsg = "bad key name"
case 1011
geterrormsg = "can't open key"
case 4, 1012
geterrormsg = "can't read key"
case 5
geterrormsg = "access to this key is denied"
case 1013
geterrormsg = "can't write key"
case 8, 14