유돌이

calendar

1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

Notice

2008. 12. 24. 18:03 델파이

//자기 자신을 삭제하는 로직//

 

procedure DeleteMe;
var
BatchFile:TextFile;
BatchFileName:String;
ProcessInfo:TProcessInformation;
StartUpInfo:TStartupInfo;
begin
//
BatchFileName:=ExtractFilePath(application.exename)+'$$336699.bat';

AssignFile(BatchFile, BatchFileName);
Rewrite(BatchFile);

Writeln(BatchFile, ':try');
Writeln(BatchFile, 'del "' + application.exename + '"');
Writeln(BatchFile, 'if exist "' + application.exename + '"' + ' goto try');
Writeln(BatchFile, 'del "' + BatchFileName + '"');
CloseFile(BatchFile);

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;
//Close;
end;


'델파이' 카테고리의 다른 글

쿠키 읽고/쓰기(GetCookie, SetCookie)  (0) 2008.12.29
파일 찾기  (0) 2008.12.24
키보드 이벤트[keybd_event  (0) 2008.12.24
레지스트리 값 읽고 쓰기  (0) 2008.12.24
웹에 있는 파일 다운로드 받기(UrlDownloadToFile)  (0) 2008.12.24
posted by 유돌이