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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get list of processes running in WinXP

Status
Not open for further replies.

JRB-Bldr

Programmer
May 17, 2001
3,281
US
I have a couple of 'pesky' Excel error messages popping up sporatically during the execution of a routine which appear despite oExcel.DisplayAlerts = .F. And they seem to be for no functional reason. I want to shut down these error messages. But my application cannot locate them to close them.

Consequently I am looking to get a method that can be used to produce a list (Cursor, Array, etc.) of the processes running in Windows XP.

I have already used the methods described in
How to determine what application are iconified on the taskbar.
faq184-5470
This is a very useful set of methods and they work OK for me for other operations.
But they are not showing the same process list that I would see if I go into Task Manager and go to the Processes tab page - resulting in my application not 'seeing' the processes which are generating the error messages.

The full list that is shown in the Task Manager process tab list (and their ProcessID's) is what I am after.

I am sure that it is merely a matter of stringing together the correct group of Win API's and using their resultant values in some manner, but I am hoping that someone has already done something like this before me (I'd rather not have to re-invent the wheel).

Any suggestions would be most welcome.

Thanks,
JRB-Bldr
 
Mike - Thats a good suggestion.

I found a routine which incorporates it and, with some modification, it looks promising.
But it is written for VFP9

It utilizes a CTOBIN() call which includes cflags
m.lnProcessID = CToBin(Substr(m.lcProcessArray, m.lnIndex, 4), "4rs")

I need to run this in VFP7 for which the CTOBIN() function does not support cflags

Do you have any suggestions on how to modify the VFP9 version to something that will run in VFP7?

Thanks,
JRB-Bldr
 
If you're able to use WMI, you may be able to use this. It could quite possibly give you more info than you need, but you can adapt it to go to a cursor instead of the screen:
Code:
*................. processes ...................

oManager = GETOBJECT("winmgmts:")
oStuff = ;
   oManager.InstancesOf("Win32_process")
FOR EACH PROCESS IN oStuff
   ?PROCESS.NAME

   x = PROCESS.Properties_
   FOR EACH Property IN x
      ?Property.NAME
      ??'----------------'
      ??Property.VALUE
   NEXT
   x = PROCESS.Methods_
   FOR EACH Method IN x
      ?Method.NAME
   NEXT
   x = PROCESS.Qualifiers_
   FOR EACH Qualifier IN x
      ?Qualifier.NAME
   NEXT

   IF 'ERRLOOK' $ UPPER(PROCESS.NAME)
      PROCESS.TERMINATE
   ENDIF
NEXT

RETURN


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Dave - I tried your suggestion and the results look promising.

In my test I intentionally added a
Code:
FOR Cntr = 1 TO 3
   * --- Put Here to Test !!!!! ---
   tmpsheet = CREATEOBJECT('excel.application')
   oExcel = tmpsheet.APPLICATION
   * -----------------------------------
ENDFOR
so that I could test if your code identified Excel and then subsequent code closed all of these instances.

That worked.

Unfortunately those 'annoying' error messages appear in the Task Manager as Excel.exe despite their being only messages.

Now I have to wait for the Excel error message to appear (I can't seem to generate them at-will for testing purposes).

Hopefully the addition of your code will KILL the messages.

Thanks,
JRB-Bldr




 
Mark Russinovich wrote numerous free utilities under the SysInternals moniker before he was hired by Microsoft. They are still available and periodically updated, but now on the MSFT technet website.


Two utilities that would be most helpful for you are Process Explorer (a good candidate to replace the Windows Task Manager) and Process Monitor. One of those should be helpful in your research.

Later, when you have time, review the other utilities to determine if others would be helpful in your work.
 
if you would kill the excell.exe you will kill the excel application not just the dialog. I am assuming here that your application is doing excel automation. and if this is the case i would try to detirmine what is causing the popup and correct the root cause and not kill the symptom.

other then just the
oExcel.DisplayAlerts = .F. i also
oExcel.AlertBeforeOverwriting = .f.

what i try to do is add a on key label ?? suspend so when one of the dialogs pops up i can suspend my app and with the trace see where i am in the code.

Steve Bowman
Independent Technology, Inc.
CA, USA
 
dbMark - I already us Sysinternal's Process Explorer as a Task Manager alternative. I don't see where this can be used as an API and called within VFP to close the Excel error message. But thanks anyway.

SteveB7 - Those Excel commands are already being used to no avail. This is still a mystery, but the issue has improved a little with better memory management.

Thanks,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top