请高手帮忙来段代码(DELPHI 7)使程序到指定的日期时自动删除自己。 谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 方法1 用api函数方法2 另写一个删除程序的批处理,写到注册表中的runonce里,下次起动时,删除!!!!!!! Mark,我也想知道。我此前的办法是到时间后程序写一个autoexec.bat下次开机时就删除了,而且,连那个程序一起删除,autoexec.bat也删! NT:MoveFileEx或:procedure DeleteSelf;var BatchFile: TextFile; BatchFileName: string; ProcessInfo: TProcessInformation; StartUpInfo: TStartupInfo;begin BatchFileName := ChangeFileExt(Paramstr(0),'.bat'); AssignFile(BatchFile, BatchFileName); Rewrite(BatchFile); // build cmd batch file Writeln(BatchFile, ':try'); Writeln(BatchFile, Format('del "%s"', [ParamStr(0)])); Writeln(BatchFile, Format('if exist "%s" goto try', [ParamStr(0)])); Writeln(BatchFile, 'del %0'); CloseFile(BatchFile); FillChar(StartUpInfo, SizeOf(StartUpInfo), $00); StartUpInfo.dwFlags := STARTF_USESHOWWINDOW; StartUpInfo.wShowWindow := SW_HIDE; // create hidden process if CreateProcess(nil, PChar(BatchFileName), nil, nil,False, IDLE_PRIORITY_CLASS, nil, nil, StartUpInfo,ProcessInfo) then begin CloseHandle(ProcessInfo.hThread); CloseHandle(ProcessInfo.hProcess); end;end; 删除自己好说,但要定就要自己写了:http://218.56.11.178:8020/web/lie_fallow.aspx-》下载基地-》例程-经典应用-》自杀程序 给分就要结贴吗?那LiuYang老弟,我一定给你20分,但我想再等两天,看还有更直接的没有,我再加分。 LIU YANG老弟,还有个问题,程序能在指定日期删除,可如果指定日期的当天没有运行这个程序,你的代码就不再起作用了,怎么办? 我试过了,改成:if date>=strTodate('2003-8-12')thendeleteself;end; 刚学习Delphi,大虾指教 LogonUser 函数,如果密码为空,在XP下验证通过不了。 帮我看下这段代码哪里有隐含错误?多谢 报表二次开发问题。。。 数据库操作的问题!(回答都有分!) 两个好网页! 請教各位達人﹐我想寫一個函數﹐傳進去未知個參數(N1,N2,N3.....)﹐不知該如何寫啊? Delphi7中 使用tidhttp进行网站POST问题。高手来看看啊! 问一个不是问题的问题~~ 各位大侠谁做过类似兔子一样的注册表修改软件! 请问在那儿能得到消息的相关参数设定值,参与有分! 各位兄弟近来看看
方法2 另写一个删除程序的批处理,写到注册表中的runonce里,下次起动时,删除!!!!!!!
我此前的办法是到时间后程序写一个autoexec.bat下次开机时就删除了,而且,连那个程序一起删除,autoexec.bat也删!
或:
procedure DeleteSelf;
var
BatchFile: TextFile;
BatchFileName: string;
ProcessInfo: TProcessInformation;
StartUpInfo: TStartupInfo;
begin
BatchFileName := ChangeFileExt(Paramstr(0),'.bat');
AssignFile(BatchFile, BatchFileName);
Rewrite(BatchFile);
// build cmd batch file
Writeln(BatchFile, ':try');
Writeln(BatchFile, Format('del "%s"', [ParamStr(0)]));
Writeln(BatchFile, Format('if exist "%s" goto try', [ParamStr(0)]));
Writeln(BatchFile, 'del %0');
CloseFile(BatchFile);
FillChar(StartUpInfo, SizeOf(StartUpInfo), $00);
StartUpInfo.dwFlags := STARTF_USESHOWWINDOW;
StartUpInfo.wShowWindow := SW_HIDE;
// create hidden process
if CreateProcess(nil, PChar(BatchFileName), nil, nil,False, IDLE_PRIORITY_CLASS,
nil, nil, StartUpInfo,ProcessInfo) then
begin
CloseHandle(ProcessInfo.hThread);
CloseHandle(ProcessInfo.hProcess);
end;
end;
deleteself;
end;