Solved

Deleting

Posted on 2000-05-13
2
128 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
code issue 8 155
Making delphi communicate with a c# service 16 112
How to convert memory stream to PDF file 6 116
Microsoft Access 97 and Delphi XE2 9 54
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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

829 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