如何判断注册表是否有这个项存在
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