vb注册表操作
注册表文件位置 = "HKLM\SOFTWARE\MeiLei_UG_WG\VIP"
Set HJonny = CreateObject("wscript.shell")
n = HJonny.regread(注册表文件位置) '读注册表
HJonny.regwrite 注册表文件位置, n '写注册表
=============================================
'判断文件运行次数 【读写 注册表】
Private Sub Form_Load()
On Error Resume Next '容错报错,这个是把错误跳过去
Dim HJonny
Dim n As Single
Dim 注册表文件位置 As String
注册表文件位置 = "HKLM\SOFTWARE\MeiLei_UG_WG\VIP"
Set HJonny = CreateObject("wscript.shell")
n = HJonny.regread(注册表文件位置) '读注册表
n = n + 1
HJonny.regwrite 注册表文件位置, n '写注册表
MsgBox "程序第" & n & "次运行!"
End
End Sub
=============================================
'判断注册表是否存在
Private Sub Form_Load()
On Error GoTo ErrorMsg
Dim WshShell As Object, temp As String
Set WshShell = CreateObject("wscript.shell")
temp = "HKEY_LOCAL_MACHINE\"
WshShell.RegRead (temp) '如果无法读取直接产生一个错误,进入到errormsg显示信息
MsgBox "找到:" & temp
GoTo lll:
ErrorMsg:
MsgBox "没有找到:" & temp
lll:
End
End Sub
===========================================
_____________________________________________________________________________ _
中磊UG二次开发教程 梅雷著 qq1821117007
学UG就上UG网 http://www.9sug.com/ |