Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Close a 2nd VFP exe
Message
 
 
To
20/07/2007 08:41:35
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01242070
Message ID:
01242303
Views:
15
>>A possible way this task can be accomplished: on exit application #1 sends a specified window message to application #2. Upon receiving this message, application #2 exits (VFP9 required).
>>
>>On start application #2 must issue BINDEVENT with some of its window handles (_screen.HWnd, application.HWnd or form's HWND) to make that window message trigger a certain exiting procedure.
>>
>>Somehow, application #1 must obtain the window handle of application #2. After having started, application #2 can pass this handle to application #1 using interprocess communication, for example a mailslot with predefined name or global atom.
>>
>>* * *
>>Also consider DDE approach, when application #2 becomes DDE server and application #1 is DDE client.
>
>Another apporach "between" those two approaches would be OLE-Automating Application 2.
>There were WINAPI-ways to kill another process - no idea how far VISTA-compatible they are if you start that process, get process ID with enough rights to kill it. No idea how stable your #2 is, but if there is a chance of hanging, have such an appraoch as a security backdrop (and say goodby to the latest data entries)
>
>HTH
>
>thomas

Thanks for the suggestions. I went the semaphore file route and it's working well. One of the issues that I didn't anticipate and makes the semaphore route easier and simpler is that I actually have two different apps that can call the 2nd app, and if either one of them are running, I need to leave the 2nd app open. Using a semaphore file, when either of the two apps that calls the 2nd app startup, I create a semaphore file in the user's folder getenv("userprofile"). The semaphore file is different for each of the two startup apps. Then when they quit either one of these, it erases it's semaphore file.

The 2nd app, which can be called from either of the first two apps, has a timer that checks for either of the semaphore files and if neither is found, it closes.

Tested and working well.
John Fatte'

Life is beautiful!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform