用VB写个隐藏磁盘分区.追+50分?
想图下那样,勾选那些盘符按确定,就隐藏那些盘.就想优化大师面里的那个功能一样,这是想用VB写.写好了,或者就发来我邮箱:yao11028@qq.com满意了我就追+50分...
想图下那样,勾选那些盘符按确定,就隐藏那些盘.
就想优化大师面里的那个功能一样,这是想用VB写.
写好了,或者就发来我邮箱:yao11028@qq.com
满意了我就追+50分.请VB高手帮帮忙.谢谢.
够牛的. 展开
就想优化大师面里的那个功能一样,这是想用VB写.
写好了,或者就发来我邮箱:yao11028@qq.com
满意了我就追+50分.请VB高手帮帮忙.谢谢.
够牛的. 展开
4个回答
展开全部
给你个思路,用VB写入注册表HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer下的NoDrives,这个键的键值就是隐藏盘符的关键了,下面是一张隐藏数值例表(二进制).
你判断一下你的复选控件如果值为true就向注册表写入数据是就了要隐藏多个要把数值相加即可
盘符 A B C D E F G H (八位分别对应八个字母(盘符)
数值 01000000 02000000 04000000 08000000 10000000 20000000 40000000 80000000
盘符 I J K L M N O P
数值 00010000 00020000 00040000 00080000 00100000 00200000 00400000 00800000
盘符 Q R S T U V W X
数值 00000100 00000200 00000400 00000800 00001000 00002000 00004000 00008000
盘符 Y Z
数值 00000001 00000002
你判断一下你的复选控件如果值为true就向注册表写入数据是就了要隐藏多个要把数值相加即可
盘符 A B C D E F G H (八位分别对应八个字母(盘符)
数值 01000000 02000000 04000000 08000000 10000000 20000000 40000000 80000000
盘符 I J K L M N O P
数值 00010000 00020000 00040000 00080000 00100000 00200000 00400000 00800000
盘符 Q R S T U V W X
数值 00000100 00000200 00000400 00000800 00001000 00002000 00004000 00008000
盘符 Y Z
数值 00000001 00000002
2009-04-17
展开全部
要重启才生效.
Option Explicit
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function PaintDesktop Lib "user32" (ByVal hdc As Long) As Long
Const ERROR_SUCCESS = 0&
Const ERROR_BADDB = 1009&
Const ERROR_BADKEY = 1010&
Const ERROR_CANTOPEN = 1011&
Const ERROR_CANTREAD = 1012&
Const ERROR_CANTWRITE = 1013&
Const ERROR_REGISTRY_RECOVERED = 1014&
Const ERROR_REGISTRY_CORRUPT = 1015&
Const ERROR_REGISTRY_IO_FAILED = 1016&
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1
Private Sub Command1_Click()
Dim retvalue As Long, result As Long
Dim KeyID As Long, keyvalue As Long
Dim subKey As String
Dim bufSize As Long
Dim regkey As String
Dim abc As Long
Dim a1 As Long
Dim hCurKey As Long
Dim lRegResult As Long
Dim s As String
Dim a As String
'check1代表a盘,.......check8代表h
If Check1.Value = 1 Then
Check1.Tag = 1
Else
Check1.Tag = 0
End If
If Check2.Value = 1 Then
Check2.Tag = 2
Else
Check2.Tag = 0
End If
If Check3.Value = 1 Then
Check3.Tag = 4
Else
Check3.Tag = 0
End If
If Check4.Value = 1 Then
Check4.Tag = 8
Else
Check4.Tag = 0
End If
If Check5.Value = 1 Then
Check5.Tag = 16
Else
Check5.Tag = 0
End If
If Check6.Value = 1 Then
Check6.Tag = 32
Else
Check6.Tag = 0
End If
If Check7.Value = 1 Then
Check7.Tag = 64
Else
Check7.Tag = 0
End If
a1 = CLng(Check1.Tag) + CLng(Check2.Tag) + CLng(Check3.Tag) _
+ CLng(Check4.Tag) + CLng(Check5.Tag) + CLng(Check6.Tag) + _
CLng(Check7.Tag)
If a1 = 0 Then
s = "Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
a = "NoDrives"
lRegResult = RegOpenKey(HKEY_CURRENT_USER, s, hCurKey)
lRegResult = RegDeleteValue(hCurKey, a)
lRegResult = RegCloseKey(hCurKey)
Else
If a1 <> 0 Then
regkey = "Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
retvalue = RegCreateKey(HKEY_CURRENT_USER, regkey, KeyID)
subKey = "NoDrives"
keyvalue = a1
retvalue = RegSetValueEx(KeyID, subKey, 0&, 4, keyvalue, 4)
End If
End If
End Sub
Private Sub Command2_Click()
Dim retvalue As Long, result As Long
Dim KeyID As Long, keyvalue As Long
Dim subKey As String
Dim bufSize As Long
Dim regkey As String
Dim abc As Long
Dim a1 As Long
Dim hCurKey As Long
Dim lRegResult As Long
Dim s As String
Dim a As String
s = "Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
a = "NoDrives"
lRegResult = RegOpenKey(HKEY_CURRENT_USER, s, hCurKey)
lRegResult = RegDeleteValue(hCurKey, a)
lRegResult = RegCloseKey(hCurKey)
End Sub
Option Explicit
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function PaintDesktop Lib "user32" (ByVal hdc As Long) As Long
Const ERROR_SUCCESS = 0&
Const ERROR_BADDB = 1009&
Const ERROR_BADKEY = 1010&
Const ERROR_CANTOPEN = 1011&
Const ERROR_CANTREAD = 1012&
Const ERROR_CANTWRITE = 1013&
Const ERROR_REGISTRY_RECOVERED = 1014&
Const ERROR_REGISTRY_CORRUPT = 1015&
Const ERROR_REGISTRY_IO_FAILED = 1016&
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1
Private Sub Command1_Click()
Dim retvalue As Long, result As Long
Dim KeyID As Long, keyvalue As Long
Dim subKey As String
Dim bufSize As Long
Dim regkey As String
Dim abc As Long
Dim a1 As Long
Dim hCurKey As Long
Dim lRegResult As Long
Dim s As String
Dim a As String
'check1代表a盘,.......check8代表h
If Check1.Value = 1 Then
Check1.Tag = 1
Else
Check1.Tag = 0
End If
If Check2.Value = 1 Then
Check2.Tag = 2
Else
Check2.Tag = 0
End If
If Check3.Value = 1 Then
Check3.Tag = 4
Else
Check3.Tag = 0
End If
If Check4.Value = 1 Then
Check4.Tag = 8
Else
Check4.Tag = 0
End If
If Check5.Value = 1 Then
Check5.Tag = 16
Else
Check5.Tag = 0
End If
If Check6.Value = 1 Then
Check6.Tag = 32
Else
Check6.Tag = 0
End If
If Check7.Value = 1 Then
Check7.Tag = 64
Else
Check7.Tag = 0
End If
a1 = CLng(Check1.Tag) + CLng(Check2.Tag) + CLng(Check3.Tag) _
+ CLng(Check4.Tag) + CLng(Check5.Tag) + CLng(Check6.Tag) + _
CLng(Check7.Tag)
If a1 = 0 Then
s = "Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
a = "NoDrives"
lRegResult = RegOpenKey(HKEY_CURRENT_USER, s, hCurKey)
lRegResult = RegDeleteValue(hCurKey, a)
lRegResult = RegCloseKey(hCurKey)
Else
If a1 <> 0 Then
regkey = "Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
retvalue = RegCreateKey(HKEY_CURRENT_USER, regkey, KeyID)
subKey = "NoDrives"
keyvalue = a1
retvalue = RegSetValueEx(KeyID, subKey, 0&, 4, keyvalue, 4)
End If
End If
End Sub
Private Sub Command2_Click()
Dim retvalue As Long, result As Long
Dim KeyID As Long, keyvalue As Long
Dim subKey As String
Dim bufSize As Long
Dim regkey As String
Dim abc As Long
Dim a1 As Long
Dim hCurKey As Long
Dim lRegResult As Long
Dim s As String
Dim a As String
s = "Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
a = "NoDrives"
lRegResult = RegOpenKey(HKEY_CURRENT_USER, s, hCurKey)
lRegResult = RegDeleteValue(hCurKey, a)
lRegResult = RegCloseKey(hCurKey)
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
给你个思路,用VB写入注册表HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer下的NoDrives,这个键的键值就是隐藏盘符的关键了,下面是一张隐藏数值例表(二进制).
你判断一下你的复选控件如果值为true就向注册表写入数据是就了要隐藏多个要把数值相加即可
盘符 A B C D E F G H (八位分别对应八个字母(盘符)
数值 01000000 02000000 04000000 08000000 10000000 20000000 40000000 80000000
盘符 I J K L M N O P
数值 00010000 00020000 00040000 00080000 00100000 00200000 00400000 00800000
盘符 Q R S T U V W X
数值 00000100 00000200 00000400 00000800 00001000 00002000 00004000 00008000
盘符 Y Z
数值 00000001 00000002
这样就可以了这是我的原创阿!!!
你判断一下你的复选控件如果值为true就向注册表写入数据是就了要隐藏多个要把数值相加即可
盘符 A B C D E F G H (八位分别对应八个字母(盘符)
数值 01000000 02000000 04000000 08000000 10000000 20000000 40000000 80000000
盘符 I J K L M N O P
数值 00010000 00020000 00040000 00080000 00100000 00200000 00400000 00800000
盘符 Q R S T U V W X
数值 00000100 00000200 00000400 00000800 00001000 00002000 00004000 00008000
盘符 Y Z
数值 00000001 00000002
这样就可以了这是我的原创阿!!!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
又是注册表。。。
如果这样,用批处理也行,只要知道具体的键值
REG ADD /? REG DELETE /?就知道了。不过黑屏。。。不够友好。。需要包装
如果这样,用批处理也行,只要知道具体的键值
REG ADD /? REG DELETE /?就知道了。不过黑屏。。。不够友好。。需要包装
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询