Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Two Delphi 2 questions

Posted on 1997-05-16
2
Medium Priority
?
201 Views
Last Modified: 2010-04-04
How can I:
1) delete the program file of currently running application
2) check the previous running instance of the application and how to select the running application when attempting to run it twice

... both in Delphi 2

... thanx, Bocian
0
Comment
Question by:Bocian
[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 2

Accepted Solution

by:
icampbe1 earned 100 total points
ID: 1336366
1) I really dont think you can (nor should you be able to).  The program file is treated as a mapped file for the running program.  If you dont have the EXE then you dont have the mapped file, then you dont have the program.  You can't detach the running code (just because it may all be in memory) from the EXE file.

2) Use a Mutex.  If a Mutex is created with CreateMutex(), the lpName parameter holds a unique string identifier.  All of the programs that you want a single instance of should try and call OpenMutex().  OpenMutex will only work if someone actually created the Mutex first with CreateMutex.

Of course, there are kludgier ways like using FindWindow, but that relies on a unique window class or caption name.

Hope this helps...  Cheers,

Ian C.

0
 
LVL 2

Expert Comment

by:gysbert1
ID: 1336367
If you really have to delete the .exe you will have to use a killer .exe shipped with the app, maybe cat'ed to the first one and then dinamically written to a file by your app if you know how to do this. Your app will then execute the killer and exit itself. The killer will wait till the app is shut down and then delete the exe.

I used to do stuff like this in high school. Great fun trying to write incrackable copy protection, etc ...
0

Featured Post

Technology Partners: 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

610 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