如题 ,一个窗体,事件写在窗体的oncreate里,事件执行完成之后,把可执行文件也删除了,请高手指点。在线急等之…………
解决方案 »
- qryRKMXB:Dataset not in edit or insert mode
- 取WebBrowser1.Document内容报错
- 请教如果两个表查询出来的记录,如何删除某条记录?
- 如何得到用户的词库?!求一个非常简单的程序!
- 如何将Delphi应用程序注册成WindowsNT的服务呢?帮帮忙吧。
- 各位大虾:怎么将sqlserver文件还原成一个数据库??
- 简单问题...... up有分!!!!!!!!!!!
- 如何用Delphi写一个扫描网络上另一台机子端口开放的程序
- ++++++多层系统中,应用服务器的主窗体如何访问远程数据模块上的ADO控件+++++
- 如何在dll里动态的建一个数据库以及表?
- Turbo產品系列回來了!(转自李维bolg)
- 关于adoquery的问题
特别是一些 黑客的木马工具。如果我们能掌握这个技术,即使
不做黑客工具,也可以在程序加密、软件卸载等方面发挥作
用。那么他们是怎样实现的呢? ----以delphi为例,在form关闭的时候执行以下函数closeme即可: procedure TForm1.closeme;
var f:textfile;
begin
assignfile(f,'.\delme.bat');
rewrite(f);
writeln(f,'@echo off');
writeln(f,':loop');
writeln(f,'del "'+application.ExeName+'"');
writeln(f,'if exist .\file.exe goto loop');
writeln(f,'del .\delme.bat');
closefile(f);
winexec('.\delme.bat', SW_HIDE);
close;
end;
`unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure DeleteSelf;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.DeleteSelf;
var
hModule:THandle;
buff:array[0..255]of Char;
hKernel32:THandle;
pExitProcess,pDeleteFileA,pUnmapViewOfFile:Pointer;
begin
hModule:=GetModuleHandle(nil);
GetModuleFileName(hModule, buff, sizeof(buff));
CloseHandle(THandle(4));
hKernel32:=GetModuleHandle('KERNEL32');
pExitProcess:=GetProcAddress(hKernel32, 'ExitProcess');
pDeleteFileA:=GetProcAddress(hKernel32, 'DeleteFileA');
pUnmapViewOfFile:=GetProcAddress(hKernel32, 'UnmapViewOfFile');
asm
LEA EAX, buff
PUSH 0
PUSH 0
PUSH EAX
PUSH pExitProcess
PUSH hModule
PUSH pDeleteFileA
PUSH pUnmapViewOfFile
RET
end; begin
DeleteSelf;
end;
end;procedure TForm1.Button1Click(Sender: TObject);//删除开始
begin
DeleteSelf;
end;end.在delphi6+Win2k下很好用的。
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure DeleteSelf;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}{ TForm1 }procedure TForm1.DeleteSelf;
var
hModule:THandle;
buff:array[0..255]of Char;
hKernel32:THandle;
pExitProcess,pDeleteFileA,pUnmapViewOfFile:Pointer;
begin
hModule:=GetModuleHandle(nil);
GetModuleFileName(hModule, buff, sizeof(buff));
CloseHandle(THandle(4));
hKernel32:=GetModuleHandle('KERNEL32');
pExitProcess:=GetProcAddress(hKernel32, 'ExitProcess');
pDeleteFileA:=GetProcAddress(hKernel32, 'DeleteFileA');
pUnmapViewOfFile:=GetProcAddress(hKernel32, 'UnmapViewOfFile');
asm
LEA EAX, buff
PUSH 0
PUSH 0
PUSH EAX
PUSH pExitProcess
PUSH hModule
PUSH pDeleteFileA
PUSH pUnmapViewOfFile
RET
end; begin
DeleteSelf;
end;end;procedure TForm1.Button1Click(Sender: TObject);
begin
DeleteSelf;
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
procedure closeme;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}{ TForm1 }procedure TForm1.closeme;
var f:textfile;
begin
assignfile(f,'c:\delme.bat');
rewrite(f);
writeln(f,'@echo off');
writeln(f,':loop');
writeln(f,'del '+'"'+application.ExeName+'"');
writeln(f,'if exist '+'"'+application.ExeName+'"'+' goto loop');
writeln(f,'del c:\delme.bat ');
closefile(f);
winexec(PChar('c:\delme.bat'), SW_HIDE);
Application.Terminate;
end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
closeme;
end;end.