VB.net2010 操作注册表vb.net查找注册表的完整路径写在HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
就可以自启动了 。
以下是我前一段时间写的防u盘自动运行的程序vb.net查找注册表,里面可以找到如何操作注册表 。
Option Explicit
Global Const REG_SZ As Long = 1
Global Const REG_DWORD As Long = 4
Global Const HKEY_CLASSES_ROOT = H80000000
Global Const HKEY_CURRENT_USER = H80000001
Global Const HKEY_LOCAL_MACHINE = H80000002
Global Const HKEY_USERS = H80000003
Global Const ERROR_NONE = 0
Global Const ERROR_BADDB = 1
Global Const ERROR_BADKEY = 2
Global Const ERROR_CANTOPEN = 3
Global Const ERROR_CANTREAD = 4
Global Const ERROR_CANTWRITE = 5
Global Const ERROR_OUTOFMEMORY = 6
Global Const ERROR_INVALID_PARAMETER = 7
Global Const ERROR_ACCESS_DENIED = 8
Global Const ERROR_INVALID_PARAMETERS = 87
Global Const ERROR_NO_MORE_ITEMS = 259
Global Const KEY_ALL_ACCESS = H3F
Global Const REG_OPTION_NON_VOLATILE = 0
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hkey As Long) As Long
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hkey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
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 Long, lpcbData As Long) As Long
Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpValue As Long, ByVal cbData As Long) As Long
Private Sub cmdAbout_Click()
MsgBox "作者wolfccb不对本软件可能造成的任何错误或损失负责,请自行承担使用风险 。", vbInformation, "About"
End Sub
Private Sub cmdDefault_Click()
Check0.Value = https://www.04ip.com/post/1
Check1.Value = https://www.04ip.com/post/0
Check2.Value = https://www.04ip.com/post/1
Check3.Value = https://www.04ip.com/post/0
Check4.Value = https://www.04ip.com/post/1
Check5.Value = https://www.04ip.com/post/0
Check6.Value = https://www.04ip.com/post/0
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdRecommend_Click()
Check0.Value = https://www.04ip.com/post/1
Check1.Value = https://www.04ip.com/post/1
Check2.Value = https://www.04ip.com/post/1
Check3.Value = https://www.04ip.com/post/1
Check4.Value = https://www.04ip.com/post/1
Check5.Value = https://www.04ip.com/post/0
Check6.Value = https://www.04ip.com/post/1
End Sub
Private Sub cmdSet_Click()
Dim hkey As Long
Dim lvalue As Long
Dim cddata As Long
Dim retval As Long
lvalue = https://www.04ip.com/post/GetValue
retval = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", 0, KEY_ALL_ACCESS, hkey)
retval = RegSetValueEx(hkey, "NoDriveTypeAutoRun", 0, REG_DWORD, lvalue, 4)
RegCloseKey hkey
If retval = 0 Then
MsgBox "设置已保存 。", vbInformation, "提示"
Else
MsgBox "保存失败,错误代码vb.net查找注册表:" + CStr(retval), vbExclamation, "错误"
End If
End Sub
Private Sub Form_Load()
Dim hkey As Long
Dim lvalue As Long
Dim cddata As Long
Dim retval As Long
retval = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", 0, KEY_ALL_ACCESS, hkey)
If retval0 Then
MsgBox "打开注册表失败,错误代码vb.net查找注册表:" + CStr(retval), vbExclamation, "错误"
End If
retval = RegQueryValueEx(hkey, "NoDriveTypeAutoRun", 0, REG_DWORD, lvalue, 4)
推荐阅读
- 鸿蒙系统崩溃进不去系统,鸿蒙系统崩溃进不去系统怎么解决
- 什么是烂代码java,代码太烂
- hbase写流程题目,hbase简答题
- chatGPT中美差距有多大,中美差距有多大知乎
- 附件下载java代码 java下载附件到本地
- WordPress感觉很慢,优化wordpress打开速度
- lucas如何线上营销,银行如何线上营销
- 显卡超频会怎么样,显卡超频危险吗
- java打开黑框没有代码 java打开黑框没有代码怎么办