Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Application running more than once
Message
 
To
19/08/2005 15:15:18
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01042387
Message ID:
01042393
Views:
20
>I dont want having more than one of the same application running in a computer. What code can I use in order for me to acomplish that???
>
>
>The thing is that when I make a program in Visual Fox pro, I build the executable and install a short cut in my desktop. When I open the shortcut, It opens the program, and runs it. But if i open it again, without closing the first one, it opens another window with the same program. If anyone has any code in order that when I already have the program running, when i try to open it again withouth closing the first one I opened, it doesnt let have Two programs of the same kind????????
>
>
>plz help

Juan,
I use this way

In Main.prg:
Public hsem 
hsem = 0
IF IsRunning("your_string")
   MessageBox("The program is active"+CHR(13)+;
              "good-bye",16,"...")
   QUIT
ENDIF
When you close APP:
DECLARE CloseHandle IN WIN32API LONG hHandle
CloseHandle(hsem)
FUNCTION IsRunning(tcSemaphoreName)
    LOCAL 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)
_______________________________________________________________
Testing displays the presence, not the absence of bugs.
If a software application has to be designed, it has to be designed correctly!
_______________________________________________________________
Vladimir Zografski
Systems Analyst
Previous
Reply
Map
View

Click here to load this message in the networking platform