Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
One instance of an application
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00276542
Message ID:
00276560
Vues:
24
Sorry... that is the name of the window that your application has. You can set the window title in the config.fpw

TITLE=Patient Database

>What is "Patient Database"?
>
>I haven't looked at the function in enough detail yet...but maybe you can give me a quick answer as to what the parameter is...thanks.
>
>Joe
>
>>Hi Joseph.
>>
>>In your main.prg put
>>
>>* check if the program is open already
>>if ckrun("Patient Database")
>> quit
>>endif
>>
>>
>>The function is then:
>>
>>**********************************************************
>>* detects if program is already running
>>* if it is then it shuts down
>>
>>FUNCTION ckrun
>>PARAMETERS WindowName
>>#define GW_OWNER 4
>>#DEFINE GW_HWNDFIRST 0
>>#DEFINE GW_HWNDNEXT 2
>>declare integer SetForegroundWindow in win32api long lnhWnd
>>declare integer GetWindowText in win32api integer, string, integer
>>declare integer GetWindow in win32api integer,INTEGER
>>declare integer IsWindowVisible in win32api integer
>>declare integer GetActiveWindow in win32api
>>IsWindEx = .F.
>>if len(WindowName) < 1
>> return .t.
>>endif
>>foxhwnd = GetActiveWindow() && get the window handle of this window
>>hwndNext = GetWindow(foxhwnd,GW_HWNDFIRST) && get the handel of the first window
>>
>>**** loop thru each window to search the title
>>DO WHILE hwndNext <> 0
>> *** if window is not the foxpro handle and not a child window
>> IF (hwndnext <> foxhwnd .AND. GetWindow(hwndnext,GW_OWNER) = 0)
>>
>>  Stuffer = SPACE(64)
>>  x = GetWindowText(hwndnext,@Stuffer,64)  && get the window text
>>*** check to see if this is the specified window.
>>  IF WindowName $ Stuffer
>>   IsWindEx = .T.
>>   =SetForegroundWindow(hwndnext)  && BRING WINDOW TO FRONT
>>   EXIT
>>  ENDIF
>> ENDIF
>> hwndNext = GetWindow(hwndnext,GW_HWNDNEXT)
>>ENDDO
>>RETURN IsWindEx
>>
>>*********************************
>>
>>
>>>First, let me appologize for this post...I think I've seen others like it before but I never made a mental note (or any type of note) of the solution.
>>>
>>>I want to only allow an application to run once from a machine. I am talking about a local EXE. Sometimes the users double-double-click on the shortcut's icon and the application is run twice....not really a problem, but I would like to stop it when it is run the second time.
>>>
>>>Thanks,
>>>Joe
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform