>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