Solved

Deleting

Posted on 2000-05-13
2
125 Views
Last Modified: 2010-04-04
How to make with Delphi that you could not delete a program(made in delphi)-when someone tries to delete program message"Can not delete!" must shows.
0
Comment
Question by:darko_poljak
2 Comments
 
LVL 15

Expert Comment

by:simonet
ID: 2807262
>"Can not delete!"

That message is given when trying to delete a file that has been locked by Windows. Files are locked when they are open (being used).

Unless your file is something like a service, that stays open all the time, you can write a seconf program that constantly watches your file for changes. The backbone of this monitor file would be an API call called FindFirstChangeNotification.

Another option, simplier, is to mark your file as read-only.

Alex
0
 

Accepted Solution

by:
LuK earned 50 total points
ID: 2808122
Write your programm in the Autostart-registrykey with a paramter.
Then make sure, that the first entry of the uses-list of your projectfile is a unit, that you can edit. write this into the interfacepart of your unit:
Function RegisterServiceProcess(id,state:integer):bool;stdcall;external 'shell32.dll';

write this directly before the 'end.' in your unit:

initialization
if paramstr(1)='your paramter' then begin
registerserviceprocess(getcurrentprocessid,1);
sleep(infinite);
end.

That will make your programm memory-resistent, so the user can't delete it.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now