Solved

Deleting

Posted on 2000-05-13
2
131 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month5 days, 3 hours left to enroll

635 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