Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Know if a program is already running
Message
From
20/06/2003 07:04:23
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
20/06/2003 06:57:39
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00802126
Message ID:
00802130
Views:
24
>Hi.
>I don't want my application started more
>than one time.
>How can I know if my application is
>already running when I started it?
>Thanks in advance,
>TONY

You could use a semaphore. ie:
FUNCTION AppAlreadyRunning
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
lpszSemName = "MyUniqueApplicationName" && Whatever you want per your app
hSem = CreateSemaphore(0,0,1,lpszSemName)
RETURN (hsem # 0 AND GetLastError() == ERROR_ALREADY_EXISTS)
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
Previous
Reply
Map
View

Click here to load this message in the networking platform