1. Yuri Denshchik
  2. PowerBuilder
  3. Thursday, 20 July 2017 23:15 PM UTC

I need to get some information about current Window Processes

We used to call VBScript to get that. After we migrate app to 64-bit it is impossible to call VBScript using MSScriptControl.ScriptControl ActiveX. 

We are searching for alternatives. Luckly WbemScripting.SWbemLocator ActiveX is available on 64-bit and we partially can get it to work:

OleObject locator,service,props
String ls_query 
int li_cnt, ret, i

ls_query ="Select ProcessID from Win32_process where name = '" + as_app + "'"
locator = CREATE OleObject
ret = locator.ConnectToNewObject("WbemScripting.SWbemLocator");
service = locator.ConnectServer();
props = service.ExecQuery(ls_query);
li_cnt = props.count();

So far so good. Now we need to iterate through props for details. In VBScript it'd look like
For Each prop In props ... Next
Could someone advise how to iterate through that collection with PowerBuilder?

Thank you,

Yuri

 

 

Accepted Answer
René Ullrich Accepted Answer Pending Moderation
  1. Friday, 21 July 2017 05:48 AM UTC
  2. PowerBuilder
  3. # Permalink

There is a method "ItemIndex" you can call.

FOR ll_i = 1 TO ll_count

    prop = props.ItemIndex(ll_i - 1)

NEXT

Comment
There are no comments made yet.
David Peace Accepted Answer Pending Moderation
  1. Friday, 7 June 2024 07:18 AM UTC
  2. PowerBuilder
  3. # 1

Hi Yuri

I'm looking at doing something similar in order to debug and fix an extraneous process that we are getting in our PB App. The problem is the App is running in a terminal services environment. If we are looking for name = "appname" then will this pick up all the processes for the app, how would I filter on just this App process?

It would be useful if you could share your final working code to see how you processed the information?

I'm trying ot get the list of sub processes shown in Task Manager when you expand the Main process. For PB this is a list of windows, but we have an extranious process that we cannot identify with a Title "G". Apparently it came in after we introduced Themes. On our app in Task manager there is another "Window" with "G" next to it.

Thank for yours or anyone else’s help.

David

 

 

 

Comment
  1. Chris Pollach @Appeon
  2. Friday, 7 June 2024 11:05 AM UTC
Hi David;

Check out my code here in this App for that. It proves that you can run from PB but, you can't hide - LoL!

https://chrispollach.blogspot.com/2024/02/explorer.html

HTH

Regards ... Chris
  1. Helpful 1
  1. David Peace
  2. Friday, 7 June 2024 12:00 PM UTC
Thanks Chris I'll give that a go :-)
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.