您的位置:程序门 -> vb ->



如何vb修改注册表设置默认浏览器


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


如何vb修改注册表设置默认浏览器
发表于:2008-01-21 21:50:53 楼主
我做了个浏览器

看到别人打开后会弹出   是否设置此浏览器为默认浏览器

如何用vb修改注册表设置默认浏览器
发表于:2008-01-22 02:32:291楼 得分:0
你用regshot1.6先扫描一次注册表,在用其他浏览器,比如tt,修改为默认浏览器,再扫描一次注册表,就可以看到修改了哪些地方
发表于:2008-01-22 08:40:122楼 得分:0
1.找到hkey_classes_root\http\shell\open\command,双击"默认",将要用浏览器的可执行文件的完全路径输入到这里,例如:输入“c:\program   files\internet   explorer\iexplore.exe”;
2.然后找到hkey_classes_root\http\shell\open\ddeEXEC\application,双击"默认",设置浏览器名,如果是firefox则输入firefox,如果是ie则输入iexplore。如果写错,在浏览器里设置为默认浏览器的时候,会提示你当前的浏览器不是默认的
发表于:2008-01-22 10:17:393楼 得分:0
楼上既然把位置找到了,我就给你提供一个模块,修改这2个位置即可完成你的要求
你仅需要修改注册表,不必创建,请适当修改

把下面的内容存成.bas(模块)文件,以后只要把这个文件加入你的工程就可以
直接用这些函数了  

'   -----------------  
'   advapi32  
'   -----------------  
'   function   prototypes,   constants,   and   type   definitions  
'   for   windows   32-bit   registry   api  

public   const   hkey_classes_root   =   &h80000000  
public   const   hkey_current_user   =   &h80000001  
public   const   hkey_local_machine   =   &h80000002  
public   const   hkey_users   =   &h80000003  
public   const   hkey_performance_data   =   &h80000004  
public   const   error_success   =   0&  

'   registry   api   prototypes  

declare   function   regclosekey   lib   "advapi32.dll"   (byval   hkey   as   long)   a
s   long  
declare   function   regcreatekey   lib   "advapi32.dll"   alias   "regcreatekeya"
  (byval   hkey   as   long,   byval   lpsubkey   as   string,   phkresult   as   long)   as  
long  
declare   function   regdeletekey   lib   "advapi32.dll"   alias   "regdeletekeya"
  (byval   hkey   as   long,   byval   lpsubkey   as   string)   as   long  
declare   function   regdeletevalue   lib   "advapi32.dll"   alias   "regdeleteval
uea"   (byval   hkey   as   long,   byval   lpvaluename   as   string)   as   long  
declare   function   regopenkey   lib   "advapi32.dll"   alias   "regopenkeya"   (by
val   hkey   as   long,   byval   lpsubkey   as   string,   phkresult   as   long)   as   long

declare   function   regqueryvalueex   lib   "advapi32.dll"   alias   "regqueryval
ueexa"   (byval   hkey   as   long,   byval   lpvaluename   as   string,   byval   lpreser
ved   as   long,   lptype   as   long,   lpdata   as   any,   lpcbdata   as   long)   as   long  

declare   function   regsetvalueex   lib   "advapi32.dll"   alias   "regsetvalueex
a"   (byval   hkey   as   long,   byval   lpvaluename   as   string,   byval   reserved   as
  long,   byval   dwtype   as   long,   lpdata   as   any,   byval   cbdata   as   long)   as   l
ong  
public   const   reg_sz   =   1                                                   '   unicode   nul   terminat
ed   string  
public   const   reg_dword   =   4                                             '   32-bit   number  

public   sub   savekey(hkey   as   long,   strpath   as   string)  
dim   keyhand&  
r   =   regcreatekey(hkey,   strpath,   keyhand&)  
r   =   regclosekey(keyhand&)  
end   sub  


public   function   getstring(hkey   as   long,   strpath   as   string,   strvalue   as
  string)   as   string  

dim   keyhand   as   long  
dim   datatype   as   long  
dim   lresult   as   long  
dim   strbuf   as   string  
dim   ldatabufsize   as   long  
dim   intzeropos   as   integer  
r   =   regopenkey(hkey,   strpath,   keyhand)  
lresult   =   regqueryvalueex(keyhand,   strvalue,   0&,   lvaluetype,   byval   0&,
  ldatabufsize)  
if   lvaluetype   =   reg_sz   then  
        strbuf   =   string(ldatabufsize,   "   ")  
        lresult   =   regqueryvalueex(keyhand,   strvalue,   0&,   0&,   byval   strbuf,
  ldatabufsize)  
        if   lresult   =   error_success   then  
                intzeropos   =   instr(strbuf,   chr$(0))  
                if   intzeropos   >   0   then  
                        getstring   =   left$(strbuf,   intzeropos   -   1)  
                else  
                        getstring   =   strbuf  
                end   if  
        end   if  
end   if  
end   function  


public   sub   savestring(hkey   as   long,   strpath   as   string,   strvalue   as   str
ing,   strdata   as   string)  
dim   keyhand   as   long  
dim   r   as   long  
r   =   regcreatekey(hkey,   strpath,   keyhand)  
r   =   regsetvalueex(keyhand,   strvalue,   0,   reg_sz,   byval   strdata,   len(str
data))  
r   =   regclosekey(keyhand)  
end   sub  


function   getdword(byval   hkey   as   long,   byval   strpath   as   string,   byval   s
trvaluename   as   string)   as   long  
dim   lresult   as   long  
dim   lvaluetype   as   long  
dim   lbuf   as   long  
dim   ldatabufsize   as   long  
dim   r   as   long  
dim   keyhand   as   long  

r   =   regopenkey(hkey,   strpath,   keyhand)  

  '   get   length/data   type  
ldatabufsize   =   4  
         
lresult   =   regqueryvalueex(keyhand,   strvaluename,   0&,   lvaluetype,   lbuf,
  ldatabufsize)  

if   lresult   =   error_success   then  
        if   lvaluetype   =   reg_dword   then  
                getdword   =   lbuf  
        end   if  
'else  
'         call   errlog("getdword-"   &   strpath,   false)  
end   if  

r   =   regclosekey(keyhand)  
         
end   function  

function   savedword(byval   hkey   as   long,   byval   strpath   as   string,   byval  
strvaluename   as   string,   byval   ldata   as   long)  
        dim   lresult   as   long  
        dim   keyhand   as   long  
        dim   r   as   long  
        r   =   regcreatekey(hkey,   strpath,   keyhand)  
        lresult   =   regsetvalueex(keyhand,   strvaluename,   0&,   reg_dword,   ldat
a,   4)  
        'if   lresult   <>   error_success   then   call   errlog("setdword",   false)  
        r   =   regclosekey(keyhand)  
end   function  

public   function   deletekey(byval   hkey   as   long,   byval   strkey   as   string)  

dim   r   as   long  
r   =   regdeletekey(hkey,   strkey)  
end   function  

public   function   deletevalue(byval   hkey   as   long,   byval   strpath   as   strin
g,   byval   strvalue   as   string)  
dim   keyhand   as   long  
r   =   regopenkey(hkey,   strpath,   keyhand)  
r   =   regdeletevalue(keyhand,   strvalue)  
r   =   regclosekey(keyhand)  
end   function  


快速检索

最新资讯
热门点击