重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
的完整路径写在HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
在平山等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站设计、做网站 网站设计制作定制网站设计,公司网站建设,企业网站建设,品牌网站建设,全网营销推广,成都外贸网站建设公司,平山网站建设费用合理。
就可以自启动了。
以下是我前一段时间写的防u盘自动运行的程序,里面可以找到如何操作注册表。
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 = 1
Check1.Value = 0
Check2.Value = 1
Check3.Value = 0
Check4.Value = 1
Check5.Value = 0
Check6.Value = 0
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdRecommend_Click()
Check0.Value = 1
Check1.Value = 1
Check2.Value = 1
Check3.Value = 1
Check4.Value = 1
Check5.Value = 0
Check6.Value = 1
End Sub
Private Sub cmdSet_Click()
Dim hkey As Long
Dim lvalue As Long
Dim cddata As Long
Dim retval As Long
lvalue = 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 "保存失败,错误代码:" + 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 retval 0 Then
MsgBox "打开注册表失败,错误代码:" + CStr(retval), vbExclamation, "错误"
End If
retval = RegQueryValueEx(hkey, "NoDriveTypeAutoRun", 0, REG_DWORD, lvalue, 4)
RegCloseKey hkey
If retval 0 Then
MsgBox "读取注册表失败,错误代码:" + CStr(retval), vbExclamation, "错误"
End If
ShowCheck (lvalue)
End Sub
Private Sub ShowCheck(lvalue As Long)
Check0.Value = lvalue Mod 2
lvalue = (lvalue - Check0.Value) / 2
Check1.Value = lvalue Mod 2
lvalue = (lvalue - Check1.Value) / 2
Check2.Value = lvalue Mod 2
lvalue = (lvalue - Check2.Value) / 2
Check3.Value = lvalue Mod 2
lvalue = (lvalue - Check3.Value) / 2
Check4.Value = lvalue Mod 2
lvalue = (lvalue - Check4.Value) / 2
Check5.Value = lvalue Mod 2
lvalue = (lvalue - Check5.Value) / 2
Check6.Value = lvalue Mod 2
End Sub
Private Function GetValue() As Long
GetValue = Check0.Value + Check1.Value * 2 + Check2.Value * 4 + Check3.Value * 8 + Check4.Value * 16 + Check5.Value * 32 + Check6.Value * 64 + 128
End Function
以上。
饿的老狼
创建完相应的用户名,密码控件之后,输入以下代码:
Imports System.Data.OleDb
Public Class Form1
Private Sub cmdok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdok.Click
Dim m_username As String
Dim m_userpwd As String
Dim cmd_result As MsgBoxResult
Dim m_da As New OleDbDataAdapter
Dim m_ds As New DataSet
Dim m_command As New OleDbCommand
Dim strsql As String
m_username = txtusername.Text
m_userpwd = txtuserpwd.Text
strsql = " select * from user_info where username='" m_username "' and userpwd='" m_userpwd "'"
OleDbConnection1.Open()
m_command.CommandType = CommandType.Text
m_command.CommandText = strsql
m_command.Connection = OleDbConnection1
m_da.SelectCommand = m_command
m_da.Fill(m_ds, "user_info")
If m_ds.Tables("user_info").Rows.Count 0 Then
cmd_result = MsgBox("欢迎登录", MsgBoxStyle.OKOnly, "提示")
Else
MsgBox("登录失败,请确认用户名和密码")
End If
End Sub
End Class
思路是:
读取电脑硬件的信息,用随机数加工这些信息后在注册表中做个记录,用这个记录生成注册码送回给你,你按特定的方法生成序列号,你的小程序收到序列号后还原成数据,数据比较注册表中的记录,如果正确就加入第二部分注册的信息完成注册.你的程序每次打开时,先比对硬件信息-第一注册信息-第二注册信息,看这三者是否统一,不统一的就是使用期软件.
也可以省了第一注册信息,直接发硬件信息给你生成序列号,其他的相同.
select * from t1 where name=** and password=** and style=**
如果查询到的表是空的,说明登陆错误,否则成功