关于 VB 删注册表的问题

来源:百度知道 编辑:UC知道 时间:2024/06/08 01:43:18
Private Sub Command1_Click()
Dim strArr() As String, str1() As String, str2() As ValueType, i As Long, j As Long, m As Long, n As Long
GetKeyInfo HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2", strArr, str1, str2, i, j, m, n
Dim k As Integer, srfKey As String, srfAddKey As String
On Error GoTo err
'恢复双击硬盘功能
For k = 0 To UBound(strArr)
DoEvents
If strArr(k) <> "" Then
srfKey = GetKeyValue(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\" & strArr(k) & "\Shell\Auto\command", "", 1)
If srfKey <> "" And srfKey <> "^_*_*_^" Then
RegDeleteSubkey HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\Mount

上面那段代码的本意不是删除你说的那项的下面所有子项,而是找到类似于{1420471b-2e29-11dc-9453-0013d46b644e}这样的子项,然后如果子项下面有"Shell\Auto"或者"Shell\autorun"的话,就把"Shell\Auto"和"Shell\autorun"删掉

代码中的GetKeyInfo、GetKeyValue都是自己定义的函数吧
你提到的dim那一行,就是声明了很多变量(3个数组,4个长整型)
下面的那一行就是调用GetKeyInfo函数,后面是传给函数的参数

关于GetKeyInfo和GetKeyValue可以看看这里:
http://www.qqgb.com/Program/VB/VBJQ/Program_161808_7.html
http://www.qqgb.com/NetProgramme/ASPNet/AspNetExample/NetProgramme_120792.html