File: w_main.srw
Size: 3222
Date: Fri, 30 May 2025 01:32:34 +0200
$PBExportHeader$w_main.srw
forward
global type w_main from window
end type
type lb_1 from listbox within w_main
end type
type cb_query from commandbutton within w_main
end type
type cb_cancel from commandbutton within w_main
end type
end forward

global type w_main from window
integer width = 3342
integer height = 2228
boolean titlebar = true
string title = "WMI"
boolean controlmenu = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
lb_1 lb_1
cb_query cb_query
cb_cancel cb_cancel
end type
global w_main w_main

on w_main.create
this.lb_1=create lb_1
this.cb_query=create cb_query
this.cb_cancel=create cb_cancel
this.Control[]={this.lb_1,&
this.cb_query,&
this.cb_cancel}
end on

on w_main.destroy
destroy(this.lb_1)
destroy(this.cb_query)
destroy(this.cb_cancel)
end on

type lb_1 from listbox within w_main
integer x = 73
integer y = 256
integer width = 3186
integer height = 1828
integer taborder = 30
integer textsize = -11
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = fixed!
fontfamily fontfamily = modern!
string facename = "Consolas"
long textcolor = 33554432
boolean vscrollbar = true
boolean sorted = false
borderstyle borderstyle = stylelowered!
end type

type cb_query from commandbutton within w_main
integer x = 73
integer y = 64
integer width = 443
integer height = 132
integer taborder = 10
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Query"
end type

event clicked;n_wmi_base lnv_wmi
s_wmi_property lstr_Results[]
Long ll_idx, ll_max, ll_prop, ll_propmax
Long ll_ProcessID
String ls_Query, ls_PropValue

SetPointer(HourGlass!)

ls_Query = "Select * From Win32_Process Where Name Like 'PB%'"

ll_max = lnv_wmi.of_QueryWMI(ls_Query, lstr_Results)

lb_1.Reset()
lb_1.SetRedraw(False)

For ll_idx = 1 To ll_max
   ls_PropValue = lnv_wmi.of_GetPropString("ExecutablePath", lstr_Results[ll_idx])
   If ls_PropValue <> "" Then
      lb_1.AddItem("--- Process #" + String(ll_idx) + " ---------")

      ll_ProcessID = lnv_wmi.of_GetPropNumber("ProcessId", lstr_Results[ll_idx])
      lb_1.AddItem("ProcessId: " + String(ll_ProcessID))

      lb_1.AddItem("ExecutablePath: " + ls_PropValue)

      ls_PropValue = lnv_wmi.of_GetPropString("CommandLine", lstr_Results[ll_idx])
      lb_1.AddItem("CommandLine: " + ls_PropValue)

//    ll_propmax = UpperBound(lstr_Results[ll_idx].PropName)
//    For ll_prop = 1 To ll_propmax
//       lb_1.AddItem(lstr_Results[ll_idx].PropName[ll_prop] + " = " + lstr_Results[ll_idx].PropValue[ll_prop])
//    Next

      lb_1.AddItem("")
   End If
Next

lb_1.SetRedraw(True)

end event

type cb_cancel from commandbutton within w_main
integer x = 2816
integer y = 64
integer width = 443
integer height = 132
integer taborder = 20
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Cancel"
boolean cancel = true
end type

event clicked;Close(Parent)

end event