Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get ApplicationObject from Handle

Status
Not open for further replies.

borgunit

Programmer
Mar 25, 2002
373
US
Hi, I have spent enough time on this. It seems like it should be simple but I cannot get it. I have a program that starts an application from the Shell (I need to do it this way so that some switches are enabled at start of the app). Anyway, I can get the instance handle and the window handle, but how do I get the Application Object of the running app. Some notes... another instance of the application may be running at the same time, and I need to allow this. I have tried starting the app with CreateObject, but I cannot control the switches this way. I am brainstorming like maybe I should force the window caption and try to grab the app this way... Any help? Thanks ahead of time.
 
FYI, I have found out that there is no direct way of accomplishing this. Some things you can do is to use GetObject (gets the first one created) and keep closing them until you get to the one you want. I chose a different route by controlling the way the application opens by altering the registry, then use CreateObject to start the app, and then reset the registry. A little bit of a hack version, but it works well.
 
Another option is to talk directy to some of the COM tables. Have a look at GetRunningObjectTable which supplies a pointer to the IRunningObjectTable interface. This latter interface will aloow you to enumerate all the running objects and then to return an 'object pointer' to any one of them that you select
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top