★★★敬请留意★★★:和微软一模一样的记事本的源代码(5)[2]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 deak 的 blog

         if displayerrormsg = true then 'if the user want errors displayed
            msgbox errormsg(rtn)        'display the error
         end if
      end if
      rtn = regclosekey(hkey) 'close the key
   else 'if there was an error opening the key
      if displayerrormsg = true then 'if the user want errors displayed
         msgbox errormsg(rtn) 'display the error
      end if
   end if
end if

end function
function getdwordvalue(subkey as string, entry as string)

call parsekey(subkey, mainkeyhandle)

if mainkeyhandle then
   rtn = regopenkeyex(mainkeyhandle, subkey, 0, key_read, hkey) 'open the key
   if rtn = error_success then 'if the key could be opened then
      rtn = regqueryvalueexa(hkey, entry, 0, reg_dword, lbuffer, 4) 'get the value from the registry
      if rtn = error_success then 'if the value could be retreived then
         rtn = regclosekey(hkey)  'close the key
         getdwordvalue = lbuffer  'return the value
      else                        'otherwise, if the value couldnt be retreived
         getdwordvalue = "error"  'return error to the user
         if displayerrormsg = true then 'if the user wants errors displayed
            msgbox errormsg(rtn)        'tell the user what was wrong
         end if
      end if
   else 'otherwise, if the key couldnt be opened
      getdwordvalue = "error"        'return error to the user
      if displayerrormsg = true then 'if the user wants errors displayed
         msgbox errormsg(rtn)        'tell the user what was wrong
      end if
   end if
end if

end function
function setbinaryvalue(subkey as string, entry as string, value as string)

call parsekey(subkey, mainkeyhandle)

if mainkeyhandle then
   rtn = regopenkeyex(mainkeyhandle, subkey, 0, key_write, hkey) 'open the key
   if rtn = error_success then 'if the key was open successfully then
      ldatasize = len(value)
      redim bytearray(ldatasize)
      for i = 1 to ldatasize
      bytearray(i) = asc(mid$(value, i, 1))
      next
      rtn = regsetvalueexb(hkey, entry, 0, reg_binary, bytearray(1), ldatasize) 'write the value
      if not rtn = error_success then   'if the was an error writting the value
         if displayerrormsg = true then 'if the user want errors displayed
            msgbox errormsg(rtn)        'display the error
         end if
      end if
      rtn = regclosekey(hkey) 'close the key
   else 'if there was an error opening the key
      if displayerrormsg = true then 'if the user wants errors displayed
         msgbox errormsg(rtn) 'display the error
      end if
   end if
end if

end function


function getbinaryvalue(subkey as string, entry as string)

call parsekey(subkey, mainkeyhandle)

if mainkeyhandle then
   rtn = regopenkeyex(mainkeyhandle, subkey, 0, key_read, hkey) 'open the key
   if rtn = error_success then 'if the key could be opened
      lbuffersize = 1
      rtn = regqueryvalueex(hkey, entry, 0, reg_binary, 0, lbuffersize) 'get the value from the registry
      sbuffer = space(lbuffersize)

本文关键:和微软一模一样的记事本
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top