Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to delete our own application Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
18-Sep-03
Category
Files Operation
Language
Delphi 4.x
Views
190
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Christian Cristofori

How to delete our own application

Answer:

Solve 1:

This solution comes from my idea of doing a installer program. InstallShield(C) and 
others just uses that solution. 

Do not use a Batch file, instead use a small (about 25K) console application that 
just takes one parameter (the file 
that must be deleted) and waits until your application unloads and/or EXE file is 
unlocked. Just run it from your application before exiting. 

1   program DelFile;
2   {$APPTYPE CONSOLE}
3   uses SysUtils, Windows;
4   begin
5     if (ParamCount = 0) then
6       Exit;
7     repeat
8       Sleep(10);
9     until (DeleteFile(PChar(ParamStr(1))));
10  end.


To do a better work, the DelFile.Exe file should be put during the installation of 
the program into the Windows\Temp folder and runned from there, specifing the 
complete path of the file that must be deleted. 

PRO: 
  The batch file can be modified and can be done to not delete your file. 
VS: 
  You must hide a program in the Windows\Temp folder of a  user, that's not good. 


Solve 2:

You can use the registry key: 

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Runonce 

to add a command that will be runned only once, and your application will be 
deleted next type your Windows will be restarted. 

Key name: "DeleteMyOwnApplicationFile" 
Key value: "c:\windows\temp\delfile.exe c:\myapp\myapp.exe" 

PRO: 
  The next time Windows starts, you application will be surelly not 
  loaded, also if it's in the Statup folder. 
VS: 
  You must hide a program in the Windows\Temp folder of a 
  user, that's not good. 
  The system must be rebooted.   

Solve 3:

Always using, the key registry, don't use your delfile.exe, but: 

Key name: "DeleteMyOwnApplicationFile" 
Key value: "del c:\myapp\myapp.exe" 

...using the DOS "Del" command. 

PRO: 
  You don't need to hide programs. 
VS: 
  The system must be restarted. 

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC