vb程序自毁源码

上传人:第*** 文档编号:38907742 上传时间:2018-05-09 格式:DOC 页数:3 大小:27KB
返回 下载 相关 举报
vb程序自毁源码_第1页
第1页 / 共3页
vb程序自毁源码_第2页
第2页 / 共3页
vb程序自毁源码_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《vb程序自毁源码》由会员分享,可在线阅读,更多相关《vb程序自毁源码(3页珍藏版)》请在金锄头文库上搜索。

1、VB 程序自毁程序自毁源码源码VB 程序自毁/删除自身(非批处理)一个模块,非原创(我修改部分代码),可以让程序退出后自毁(删除自身)。原理还特别不清楚,不过应该和 CMD 的 DEL 命令有关,但删除时没看到 CMD.EXE 进程,速度也很快成功率挺高的(我还没失败过)创建一个模块,写入代码:Const NORMAL_PRIORITY_CLASS = &H20Const REALTIME_PRIORITY_CLASS = &H100Const THREAD_PRIORITY_NORMAL = 0Const THREAD_PRIORITY_IDLE = -15Const IDLE_PRIORI

2、TY_CLASS = &H40Const DETACHED_PROCESS = &H8Const CREATE_SUSPENDED = &H4Const THREAD_PRIORITY_TIME_CRITICAL = 15Const SW_HIDE = 0Const STARTF_USESHOWWINDOW = &H1Type STARTUPINFOcb As LonglpReserved As StringlpDesktop As StringlpTitle As StringdwX As LongdwY As LongdwXSize As LongdwYSize As LongdwXCou

3、ntChars As LongdwYCountChars As LongdwFillAttribute As LongdwFlags As LongwShowWindow As IntegercbReserved2 As IntegerlpReserved2 As LonghStdInput As LonghStdOutput As LonghStdError As LongEnd TypeType PROCESS_INFORMATIONhProcess As LonghThread As LongdwProcessId As LongdwThreadId As LongEnd TypeTyp

4、e SECURITY_ATTRIBUTESnLength As LonglpSecurityDescriptor As LongbInheritHandle As LongEnd TypeDeclare Function GetModuleFileName Lib “kernel32“ Alias “GetModuleFileNameA“ (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As LongDeclare Function GetEnvironmentVariable Lib “kern

5、el32“ Alias “GetEnvironmentVariableA“ (ByVal lpName As String, ByVal lpBuffer As String, ByVal nSize As Long) As LongDeclare Function GetShortPathName Lib “kernel32“ Alias “GetShortPathNameA“ (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As LongDeclare Functi

6、on GetCurrentProcess Lib “kernel32“ () As LongDeclare Function GetCurrentThreadId Lib “kernel32“ () As LongDeclare Function SetPriorityClass Lib “kernel32“ (ByVal hProcess As Long, ByVal dwPriorityClass As Long) As LongDeclare Function SetThreadPriority Lib “kernel32“ (ByVal hThread As Long, ByVal n

7、Priority As Long) As LongDeclare Function ResumeThread Lib “kernel32“ (ByVal hThread As Long) As LongDeclare Function GetCurrentThread Lib “kernel32“ () As LongDeclare Function CreateProcess Lib “kernel32“ Alias “CreateProcessA“ (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpPr

8、ocessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As LongFunction Delete

9、Me() As BooleanDim szModule As StringDim szComspec As StringDim szParams As StringDim si As STARTUPINFODim pi As PROCESS_INFORMATIONDim sa1 As SECURITY_ATTRIBUTESDim sa2 As SECURITY_ATTRIBUTESszModule = String(512, 0)szComspec = String(512, 0)szParams = String(512, 0)/ get file path names:If (GetMod

10、uleFileName(0, szModule, 512) 0) And (GetEnvironmentVariable(“COMSPEC“, szComspec, 512) 0) Then/ set command shell parametersszComspec = Left(szComspec, InStr(szComspec, Chr(0) - 1)szModule = Left(szModule, InStr(szModule, Chr(0) - 1)szComspec = szComspec & “ /c del “ & “ & szModule & “ 这里是我(yfdyh00

11、0)修改的,支持带空格路径 szComspec = szComspec & “ /c del “ & szModule原代码/ set struct membersWith si.cb = Len(si).dwFlags = STARTF_USESHOWWINDOW.wShowWindow = SW_HIDEEnd With/ increase resource allocation to programCall SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS)Call SetThreadPriority(GetCur

12、rentThread(), THREAD_PRIORITY_TIME_CRITICAL)/ invoke command shellDebug.Print CreateProcess(vbNullString, szComspec, sa1, sa2, 0&, CREATE_SUSPENDED Or DETACHED_PROCESS, 0&, vbNullString, si, pi)If CreateProcess(vbNullString, szComspec, sa1, sa2, 0, CREATE_SUSPENDED Or DETACHED_PROCESS, 0, vbNullStri

13、ng, si, pi) Then/ suppress command shell process until program exitsCall SetPriorityClass(pi.hProcess, IDLE_PRIORITY_CLASS)Call SetThreadPriority(pi.hThread, THREAD_PRIORITY_IDLE)/ resume shell process with new low priorityCall ResumeThread(pi.hThread)/ everything seemed to workDeleteMe = TrueExit FunctionElse / if error, normalize allocationCall SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS)Call SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL)End IfEnd IfDeleteMe = FalseEnd Function

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号