Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to prevent the application running twice ?
Message
 
À
13/08/2007 23:47:52
Yim Ming Sun Derek
Spacious Design Consultant
Hong Kong, Hong Kong
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01232152
Message ID:
01247990
Vues:
105
Here is the code I use, posted by someone else here long ago.
DECLARE INTEGER CreateEvent IN WIN32API ;
   INTEGER lpEventAttributes, ;
   SHORT bManualReset, ;
   SHORT bInitialState, ;
   STRING @ lpName
DECLARE INTEGER GetLastError IN Win32API
DECLARE CloseHandle IN Win32API INTEGER hObject
nEh = CreateEvent(0,0,1, PROGRAM(0) + '.EVENT')
IF GetLastError() = 183 OR nEh = 0
   *  There's an instance running already (183) or the Event can't be defined
   *  So don't do it;  do release the handle, since it's harmless and should
   *  be done rather than relying on Windows to clean up after itself
   =CloseHandle(nEh)
   QUIT
ENDIF
Bob



>Dear Tore,
>Thank for your reply, but I want to ask what is
>the 'Mutex', I copy your code to my startup program,
>but I got an error for the class 'Mutex' not define.
>
>Please advise.
>
>Thanks.
'If the people lead, the leaders will follow'
'War does not determine who is RIGHT, just who is LEFT'
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform