乔丹二世 发表于 2011-1-16 18:42:21

增加启动项

'who! # from turkey
'thanx to KripPLer, SyntaX_Err, Luis Carlos, VB6
'www.tikkysoft.com
'fuck all turkish lamers

Private Declare Function IsUserAnAdmin Lib "shell32" () As Long
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 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 RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1&

Public Function addtostartup(Value As String, Optional Filename As String) As Boolean
    Dim hKey As Long, hCreate As Long, hSet As Long
    If IsUserAnAdmin() = 1 Then
      hCreate = RegCreateKey(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", hKey)
    Else
      hCreate = RegCreateKey(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Run", hKey)
    End If
    If hCreate = 0 Then
      hSet = RegSetValueEx(hKey, Value, 0, REG_SZ, ByVal Filename, Len(Filename))
      If hSet = 0 Then
            addtostartup = True
      End If
    End If
    RegCloseKey (hKey)
End Function

Private Sub Form_Load()
If addtostartup("tikkysoft.com", "C:\hacker.exe") = True Then
    MsgBox "Added to startup"
Else
    MsgBox "Could Not add to startup"
End If
End Sub

马大哈 发表于 2011-1-17 18:10:58

..............注释是亮点.

Tesla.Angela 发表于 2011-1-17 22:14:51

'who! # from turkey
'thanx to KripPLer, SyntaX_Err, Luis Carlos, VB6
'www.tikkysoft.com
'fuck all turkish lamers
“操所有土耳其的跛足者?!”:funk:
莫非是句谚语?谷歌上好像没找到相关的解释。
页: [1]
查看完整版本: 增加启动项