以下為修改自動登入的VB6程式碼部分:
'宣告API
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
'宣告常數
Const REG_SZ As Long = 1
Const HKEY_LOCAL_MACHINE = &H80000002
Public s1 As String, s2 As String, s3 As String
Dim ret1 As Long
'執行
Private Sub Command1_Click()
s1 = Text1(0) : s2 = Text1(1)
ret1 = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", hKey)
If ret1 = 0 Then
s1 = "1"
sValue = "1"
sValueName = "AutoAdminLogon"
RegSetValueEx hKey, sValueName, 0, REG_SZ, ByVal sValue, Len(sValue) + 1
RegSetValueEx hKey, "AutoAdminLogon", "1", REG_SZ, ByVal s1, LenB(s1) '自動登入控制,sValue的值為1表示要設定為自動登入
RegSetValueEx hKey, "DefaultUserName", "0", REG_SZ, ByVal s2, LenB(s2) '使用者名稱
RegSetValueEx hKey, "DefaultPassword", "0", REG_SZ, ByVal s3, LenB(s3) '使用者密碼
End If
MsgBox "設定成功,Windows自動登入,使用目前使用者名稱及密碼", , "bdhiphop提示視窗"
End Sub
沒有留言:
張貼留言