【文件属性】:
文件名称:Delphi 删除文件自己 删除程序自身.rar
文件大小:5KB
文件格式:RAR
更新时间:2022-07-30 12:46:07
Delphi源码-文件操作
Delphi 自动删除文件,也可把程序自已删除,如何删除文件自身,请详见代码,运行效果图请参见测试图片。具体的实现过程可参见以下代码,使用到的Delphi 自带函数还是挺多的:
BatchFileName := ExtractFilePath(ParamStr(0)) '_deleteme.bat';
AssignFile(BatchFile, BatchFileName);
Rewrite(BatchFile);
Writeln(BatchFile, ':try');
Writeln(BatchFile, 'del "' ParamStr(0) '"');
Writeln(BatchFile,
'if exist "' ParamStr(0) '"' ' goto try');
Writeln(BatchFile, 'del %0');
CloseFile(BatchFile);
Delphi删除自己,这个好另类:
FillChar(StartUpInfo, SizeOf(StartUpInfo), $00);
StartUpInfo.dwFlags := STARTF_USESHOWWINDOW;
StartUpInfo.wShowWindow := SW_HIDE;
if CreateProcess(nil, PChar(BatchFileName), nil, nil,
False, IDLE_PRIORITY_CLASS, nil, nil, StartUpInfo,
ProcessInfo) then
begin
CloseHandle(ProcessInfo.hThread);
CloseHandle(ProcessInfo.hProcess);
end;
【文件预览】:
codesc.net
----自动删除()
--------Project1.res(876B)
--------Unit1.dfm(507B)
--------Unit1.ddp(51B)
--------Unit1.pas(1KB)
--------Project1.dpr(188B)
--------Project1.dof(1KB)
--------Unit1.dcu(5KB)