首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

怎么判断注册表是否有这个项存在

2012-03-17 
如何判断注册表是否有这个项存在Private Sub Form_Load()开机自动运行---------------------------------

如何判断注册表是否有这个项存在
Private Sub Form_Load()
'开机自动运行----------------------------------------------------
Set w = CreateObject("wscript.shell")
w.regwrite "HKLM\SOFTWARE\Tencent\QQ\" & "Install", App.Path & "\" & "QQ.exe"

如何加一句判断,

如果 这段代码成功写入注册表 则
MSGBOX "自动运行设置成功"

MSGBOX "写入注册表失败,不能自运行"
END IF
End Sub


[解决办法]

VB code
Private Sub Form_Load()Dim b As StringSet w = CreateObject("wscript.shell")w.regwrite "HKLM\SOFTWARE\Tencent\QQ\" & "Install", App.Path & "\" & "QQ.exe"On Error Resume Nextb = w.RegRead("HKLM\SOFTWARE\Tencent\QQ\" & "Install", App.Path & "\" & "QQ.ex")If b = "" ThenMsgBox "自动运行设置成功"ElseMsgBox "写入注册表失败,不能自运行"End IfEnd Sub
[解决办法]
VB code
Private Sub Form_Load()    If IsRegistered("MSSOAP.SoapClient30") = False Then        Shell "regsvr32 " & App.path & "\MSSOAP30.dll /s"    End If    End SubPublic Function IsRegistered(ByVal KJname As String) As Boolean    on error resume next    Dim oCheckup As Object    Set oCheckup = CreateObject(KJname)    IsRegistered = (Err.Number = 0)End Function 

热点排行