Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Preventing another instance in systray

Posted on 2000-04-05
3
Medium Priority
?
203 Views
Last Modified: 2010-04-04
I have an app that resides in systray.  The common code I find for preventing another instance of my app works well when my app is on the taskbar but when in the systray, it forces a taskbar icon at the same time.  Maximizing the taskbar icon produces an invisible window and the systray icon is still present.  
I've been using Mutex Handles.  Is there a better way to do this?
0
Comment
Question by:d32coder
3 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 2688790
On this page you can see how to do that:

http://www.gnomehome.demon.nl/uddf/pages/api.htm#api0

Eps.
0
 
LVL 20

Accepted Solution

by:
Madshi earned 300 total points
ID: 2688807
I'm using this:

  if (CreateMutex(nil, false, 'd32codersTrayApp') = 0) or (GetLastError = ERROR_ALREADY_EXISTS) then
  ExitProcess(0);

You should add this as the first line of your project (dpr) like this:

begin
  if (CreateMutex...
  Application.Initialize;
  Application...
  ...
end.

Regards, Madshi.
0
 

Author Comment

by:d32coder
ID: 2701805
Love it.  Works great and with only one line of code.  Thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Screencast - Getting to Know the Pipeline
Suggested Courses

824 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