Jump to content


Photo

[TRUCO DELPHI] Borrar mi propio programa al terminar.


  • Please log in to reply
No replies to this topic

#1 sir.dev.a.lot

sir.dev.a.lot

    Advanced Member

  • Miembros
  • PipPipPip
  • 545 posts
  • Location127.0.0.1

Posted 25 August 2016 - 11:17 AM

[TRUCO DELPHI] Borrar mi propio programa al terminar.


delphi
  1. procedure DelEXE;
  2. function GetTmpDir: string;
  3. var
  4. pc: PChar;
  5. begin
  6. pc := StrAlloc(MAX_PATH + 1);
  7. GetTempPath(MAX_PATH, pc);
  8. Result := string(pc);
  9. StrDispose(pc);
  10. end;
  11.  
  12. function GetTmpFileName(ext: string): string;
  13. var
  14. pc: PChar;
  15. begin
  16. pc := StrAlloc(MAX_PATH + 1);
  17. GetTempFileName(PChar(GetTmpDir), 'uis', 0, pc);
  18. Result := string(pc);
  19. Result := ChangeFileExt(Result, ext);
  20. StrDispose(pc);
  21. end;
  22.  
  23. var
  24. pfad: string;
  25. batchfile: TStringList;
  26. batchname: string;
  27. begin
  28. batchname := GetTmpFileName('.bat');
  29. FileSetAttr(ParamStr(0), 0);
  30. batchfile := TStringList.Create;
  31. batchfile.add(':Label1');
  32. batchfile.add('del "' + ParamStr(0) + '"');
  33. batchfile.add('if Exist "' + ParamStr(0) + '" goto Label1');
  34. batchfile.add('rmdir "' + ExtractFilePath(ParamStr(0)) + '"');
  35. batchfile.add('del ' + batchname);
  36. batchfile.SaveToFile(batchname);
  37. ChDir(GetTmpDir);
  38. WinExec(PChar(batchname), SW_HIDE);
  39. Halt;
  40. end;

Saludos!


  • 2




IP.Board spam blocked by CleanTalk.