Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
One Instance
Message
De
26/11/2004 17:23:06
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Versions des environnements
Visual FoxPro:
VFP 7
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
00957965
Message ID:
00965058
Vues:
10
>>>Function IsAppRunning
>>> Lparameters tcSemaphoreName
>>> Local hsem, lpszSemName
>>> #Define ERROR_ALREADY_EXISTS 183
>>> Declare Integer GetLastError In win32API
>>> Declare Integer CreateSemaphore In WIN32API ;
>>> string @ lpSemaphoreAttributes, ;
>>> LONG lInitialCount, ;
>>> LONG lMaximumCount, ;
>>> string @ lpName
>>> hsem = CreateSemaphore(0,0,1,tcSemaphoreName)
>>> Return (hsem # 0 And GetLastError() == ERROR_ALREADY_EXISTS)
>>>Cetin
>
>I do not the answer Fabio, but what about including the HWND into the semaphore's name?, something like:
>
>lcSemaphoreName = tcSemaphoreName + "~" + transform(thisform.HWND)
>
>Then you can parse the name of the semaphore to get the Window Handle and activate it.
>
>Just a thought

It wouldn't work as it'd be then something that you should know windowhandle. However you're up to something and reminded me one of the places I use it.


-I check if app is running
Yes: Ask user it's up already and if they want a new instance

-If app is going to create a new instance
Generate a GUID and insert into syslog table (and create another semaphore with that GUID to check if that particular instance is still alive). That's later used to record things that're related to that particular instance. Here Fabio could also record a HWND. I don't as I have nothing to track hwnd based.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform