Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Myproject2.exe will only run when myproject1.exe is runn
Message
From
22/09/2000 05:48:59
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00417228
Message ID:
00419615
Views:
22
thanx ed,
when i install my application to clients what are needed files (or DLLs).
or do i have to include a file on my project before compiling it?

>>hi,
>>is there a way to check whether an application is running.
>>i.e. myproject2.exe will only run when myproject1.exe is running.
>>when myproject2.exe is executed is will first check myproject1.exe, if >>myproject1.exe is currently running, myproject2.exe will continue to load, else it will prompt a message "myproject1.exe must be running before using this add-on" (lol! some stuff like that)...

>You can use CreateEvent() in the opposite fashion I use it to implement single-instance apps; have myproject1.exe create an event with a known name at startup; when myproject2.exe is started, have it check to see if the event object exists; if not, then the first app is not running, since the event object is destroyed when no process references the event; IOW, the first process makes it exist, and maintains the event handle until it exits, releasing the event reference. myproject2.exe, when it starts, checks to see if the event created by myproject1.exe exists - if it does, then myproject1.exe is running and it can procede; if not, it shuts down and reports that myproject1.exe is not running at the moment. The code would look something like this:

>* in myproject1 in it's startup:


>DECLARE INTEGER CreateEvent IN WIN32API ;
> INTEGER lpEventAttributes, ;
> SHORT bManualReset, ;
> SHORT bInitialState, ;
> STRING @ lpName
>DECLARE INTEGER GetLastError IN Win32API
>DECLARE CloseHandle IN Win32API INTEGER hObject
>PUBLIC nEh
>nEh = CreateEvent(0,0,1, 'MyProject1.EVENT')

>* in your shutdown code:
>=CloseHandle(nEh)

>* In myproject2:

>DECLARE INTEGER OpenEvent IN KERNEL32.DLL ;
> INTEGER dwDesiredAccess, ;
> INTEGER bInheritHandle, ;
> STRING @ lpName
>DECLARE INTEGER GetLastError IN Win32API
>DECLARE CloseHandle IN Win32API INTEGER hObject
>#DEFINE STANDARD_RIGHTS_REQUIRED 0xF0000
>#DEFINE SYNCHRONIZE 0x100000
>#DEFINE EVENT_ALL_ACCESS STANDARD_RIGHTS_REQUIRED + SYNCHRONIZE + 0x3
>nEh = OpenEvent(EVENT_ALL_ACCESS,0,'MyProject1.EVENT)
>IF nEh # 0
> * the event exists, we can proceed
> =CloseHandle(nEh) && we don't want to keep the event open if myproject1 >shuts down
>ELSE
> * No event
> WAIT WINDOW 'MyProject1 is not running'
> QUIT
>ENDIF
Previous
Reply
Map
View

Click here to load this message in the networking platform