Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a way to determine an app is running ?
Message
From
22/01/2001 19:57:13
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00466291
Message ID:
00467069
Views:
20
>>Ed,
>>According to docs too CreateProcess() should be able to identify termination of an app. But I mean not just an app, a particular instance of an app. Say you fire 4 instances of word in different VFP sessions and want to wait for termination of particular instances in each. I can't do this now. The first instance waits for termination of all word instances while others immediately return as if word finished. All word instances have the same process id.
>>Api_apprun too immediately returns if before a word session is active (user opened word by himself).
>>IOW I'm after something that uniqely identifies an app session. Here Hwnd seems to be the only unique thing. Do you know a way of getting Hwnd through CreateProcess() or ShellExecute() launched app instance ? Currently I think to collect all top level windows before and after launch (with the risk another app might be launched in between). Is there a better way ? TIA
>
>CreateProcess() returns a ThreadID, which can be used to enumerate the set of Windows owned by the thread, but it requires a callback, so pure VFP implementation is ruled out.
>
>CreateProcess() should create a new instance of Word, not just DDE-up another thread like ShellExecutge() or ShellExecuteEx(). THe new process is distinct from the running instance of Word, and API_APPRUN's LaunchAppAndWait() should remain running as long as this process and any of it's threads are alive. You can't use ShellExecute() the way you'd like to.
>

To my surprise nothing returned in PROC_INFO structure could be used to identfy an instance. I wasn't talking about pure VFP and was using callbacks, still no luck with IDs. All you can catch is first instance. CreateProcess sounds to create a new process but it doesn't. New process is kinda popup of first. All instances share the same process id. ShellExecute behave the same way but IMHO has advantages over Createprocess like obeying policies (docs say it fits Gold Logo guides but not CreateProcess - and I don't know what that guide is about). Not a smart way but I resorted to this (wish could find another working solution):

EnumWindows(A callback here collecting existing toplevel into array)
CreateProcess() or ShellExecute()
EnumWindows(Callback here identifying newly added toplevel window)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform