Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to detect if your program is already running before
Message
 
To
22/06/2001 08:26:39
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00522073
Message ID:
00522378
Views:
7
>>>Hello Group,
>>>
>>>We have a user who keeps starting the filetrac program and watching to see its old icon in the tray. This isn't going to happen until I learn how to make the new filetrac program put the old filetrac icon in the tray.
>>>
>>Jim,
>>
>>Do you mean preventing a second instance of the application running? Are you talking about the taskbar or the System Tray?
>>
>>If you mean preventing a normal executable from running twice, there are a number of ways. Use the FindWindow() API call or something like my Is_Run32 program from the download section to determine if the window already exists. You could set up the application as a DDE server and test to see if it's active. Ed Rauh suggests using the CreateEvent() API call. I think if you'll check the FAQs you'll find that. I wrote an article for FoxPro Advisor (Nov., 1998) that uses CreateMutex().
>>
>>Some of this (inlcuding the DDE implementation) you can find in the FAQs or download sections.
>Hi George,
>
>Yep I meant the systray, had to take a minute to figure which one was which.
>
>I would like to prevent a normal executable from running twice.
>
>Thank you for your help
>
>Best regards

Jim,

In order to use my solution using a Mutex, see the November, 1998 issue of FoxPro Advisor. Unfortunately, this article used to be available on-line, but no longer is.

Ed Rauh provides one alternative in his Implementation of the Win32 Event object. You can download this file for details.

You can download Is_Run32. It allows you to pass the known portion of the title bar text. If a match is found it return the window handle, if no match is found it returns 0. It is not case sensitive and only the know portion of the title text is required. You can download it through "Is a Windows Application Running?".

See FindWindow() from the API section. The biggest problem with this solution is that it requires an exact match of the title text and is case sensitive.

Finally, Vlad Tatavu's Run only one instance of an application utilizes the DDE method.
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform