Solved

Two Delphi 2 questions

Posted on 1997-05-16
2
175 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 50 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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
How to load 2 images in same column in Delphi 2 67
Twebbrowser add css to the header 3 38
scroll down TListBox component in Delphi 1 31
Broadcast a message using ICS 2 20
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

735 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