Solved

Application management

Posted on 2004-10-13
5
170 Views
Last Modified: 2013-12-03

This is a follow on from

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21153287.html

Amir gave a final solution using enumwindows. That works fine but there are a couple of issues

1. If I have two instances of Excel running, I get THREE items listed .. the first of which has a caption prefixed by "Microsoft Excel-" . Why is this, and how can I get rid of this extra instance?. (Note : Task manager shows this extra instance, but the taskbar does not)

2. If I use the enumwindows approach, how do I then go on to do task (app) management -- eg switch to an app, kill an app. enumwindows will give me a handle, but where do I go from there? (previous task killing references have been based on the exe name? : dk if that will be any use given that Excel can give me multiple entries in the list)

3. What is the best way of refreshing the contents of the app list? I can use a timer, but would it be better to install a shell hook and monitor eg HSHELL_WINDOWCREATED?

4. If I want to go one step further and find out something about the current apps and what they are doing, is the handle that I get from enumwindows sufficient? Can I go back from the handle to work out the app name and arguments. For example, if I want to connect to a running instance of Excel and read some stuff from it, I need to do things like at http://www.djpate.freeserve.co.uk/AutoExcl.htm#OpenWorkbook .. I am going to need the filename of the xls at the very minimum.





0
Comment
Question by:Mutley2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
DragonSlayer earned 500 total points
ID: 12305180
1. Check and see if there is anything after the '-'? e.g. if you open abc.xls, the caption you get would be "Microsoft Excel - abc.xls", well, if it is just "Microsoft Excel - " then it means that is not the instance you want?

2. Send a WM_Close or a WM_Quit message to the handle instead, and let them close gracefully.

3. Well, it depends on how "real time" your monitoring is to be. In most cases, a timer would do, I guess?

4. Again, since you have the handle, you can retrieve its caption using GetWindowText
0
 

Author Comment

by:Mutley2003
ID: 12336666
"
4. Again, since you have the handle, you can retrieve its caption using GetWindowText
"
yeah, but is there anything ELSE I can get from the handle apart from stuff about the window.  Like the exe name and hopefully the arguments when it was called.

About 1. Originally I asked
" 1. If I have two instances of Excel running, I get THREE items listed .. the first of which has a caption prefixed by "Microsoft Excel-" . Why is this, and how can I get rid of this extra instance?. (Note : Task manager shows this extra instance, but the taskbar does not)"

I don't think the answer DragonSlayer gave to this quite gets to the point. Why are there THREE in task manager and what is the extra one and what can I do about it?

Thanks




0
 

Author Comment

by:Mutley2003
ID: 12409771
ok, I will close this .. no action for a while now
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 12431684
Sorry, didn't notice your previous posting... if you want to get more info for a process based on the process handle, take a look at madshi's madProcess package... check out www.madshi.net
0
 

Author Comment

by:Mutley2003
ID: 12450993
DragonSlayer

I could not see madProcess on that site .. maybe he has reorganized it. It does not seem to be part of madShell or madKernel which is where I would have guessed it would be

Any clues?

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
TEMBEDDEDWB how can i change its user agent ? 8 85
CheckListBox usage 3 83
Firemonkey BASS_Init into a thread 17 58
How to install a font on WIN2003SBS/IIS 6 & test 17 54
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question