Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

task manager process info

102 views
Skip to first unread message

srik

unread,
Jun 9, 2004, 5:26:22 AM6/9/04
to
hi,
is there any api which tells us the process information,
which is displayed by the task manager. i have to find out
whether pb IDE (development environment) is running or not.
FindWindowA api will be usefull if we know the application
name but user can open any application.
please help
SriK

Bruce Armstrong [TeamSybase]

unread,
Jun 9, 2004, 9:06:28 AM6/9/04
to
Use FindWindow to search on the window class name rather than the
title. All PowerBuilder based applications have the same class name
(with variations due to the major version). In addition, regardless
of what application is open in the IDE, the title bar for the window
should end in "PowerBuilder". So unless you're also adding
"PowerBuilder" to the end of the titles for your PowerBuilder based
applications, you should be able to find the IDE fairly easily.

Bruce Armstrong [TeamSybase]
http://www.teamsybase.com

Easy XML with PowerBuilder DOM: June 8 & 10, 2004
http://crm.sybase.com/sybase/www/ESD/ISUGJUNE2004Regbn.jsp

Two new books on developing with PowerBuilder
http://www.pb9books.com?source=newsgroups

Need code sample? Check out CodeXchange:
http://www.codexchange.sybase.com

ISUG Enhancement Requests
http://www.isug.com/cgi-bin/ISUG2/submit_enhancement

Preach the gospel at all times. If necessary, use words. - Francis of Assisi
http://www.needhim.org

---------------------------------------------------------------------
DISCLAIMER:

This newsgroup message is only intended for the recipient. Given that it
is a posting to a public newsgroup, that means if you can read this
message then you are the recipient. This message may contain information
that is confidential and protected from disclosure. And then again,
it may not.

Given that TeamSybase members are not employees of Sybase, the contents
of this message do not necessarily represent the views or policies of
Sybase. Given that TeamSybase is a diverse group of users of Sybase
products, the contents of this message do not necessarily represent the
views of a significant number of the members of TeamSybase. Given that the
author has mutliple personalities and hears voices in his head, the contents
of this message do not necessarily represent his own views.

philipsalgannik

unread,
Jun 9, 2004, 11:29:59 AM6/9/04
to
Actually enumerating running processes would work as
effectively if not better.
Import this:

$PBExportHeader$w_proc_memory.srw
forward
global type w_proc_memory from window
end type
type mle_1 from multilineedit within w_proc_memory
end type
type cb_ok from commandbutton within w_proc_memory
end type
type processentry from structure within w_proc_memory
end type
type moduleentry from structure within w_proc_memory
end type
type process_memory_counters from structure within
w_proc_memory
end type
end forward

type processentry from structure
unsignedlong lpidprocess[500]
end type

type moduleentry from structure
unsignedlong lpidmodule[100]
end type

type process_memory_counters from structure
unsignedlong cb
unsignedlong pagefaultcount
unsignedlong peakworkingsetsize
unsignedlong workingsetsize
unsignedlong quotapeakpagedpoolusage
unsignedlong quotapagedpoolusage
unsignedlong QuotaPeakNonPagedPoolUsage
unsignedlong QuotaNonPagedPoolUsage
unsignedlong PagefileUsage
unsignedlong PeakPagefileUsage
end type

global type w_proc_memory from window
integer x = 567
integer y = 336
integer width = 3109
integer height = 1680
boolean titlebar = true
string title = "List of Current Processes:"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 79741120
mle_1 mle_1
cb_ok cb_ok
end type
global w_proc_memory w_proc_memory

type prototypes
Function boolean CloseHandle (ref ulong hObject) Library
"KERNEL32.DLL"
Function Boolean EnumProcesses(REF processEntry Process,
long cb, REF long cbNeeded ) Library "PSAPI.DLL"
Function long OpenProcess( long dwDesiredAccess, boolean
bInheritHandle,ulong dwProcessId) LIBRARY "KERNEL32.DLL"
Function boolean EnumProcessModules( ulong hProcess, REF
ModuleEntry Module, long cb, REF long lpcbNeeded ) LIBRARY
"PSAPI.DLL"
Function long GetModuleBaseNameA(ulong hProcess, ulong
hModule, REF string lpBaseName,long nSize) LIBRARY
"PSAPI.DLL"
Function long GetModuleFileNameExA(ulong hProcess, ulong
hModule, REF string lpBaseName,long nSize) LIBRARY
"PSAPI.DLL"
Function boolean GetProcessMemoryInfo(ulong hProcess, REF
PROCESS_MEMORY_COUNTERS ppsmemCounters,long nSize) LIBRARY
"PSAPI.DLL"

end prototypes

type variables
ulong HandleP[] // Handle of the process
constant ulong PROCESS_ALL_ACCESS = 2035711
end variables

on w_proc_memory.create
this.mle_1=create mle_1
this.cb_ok=create cb_ok
this.Control[]={this.mle_1,&
this.cb_ok}
end on

on w_proc_memory.destroy
destroy(this.mle_1)
destroy(this.cb_ok)
end on

event open;ProcessEntry Process // Window structure (array
of 500 ulong)...arbitrary value !
ModuleEntry Module // Window structure (array of 100
long)... idem
PROCESS_MEMORY_COUNTERS pmc
long tailleP=2000 // Size of Process
long TailleM=400 // Size of Module
long NeededP // returned size of Process
long NeededM // returned size of Module
long resName // size of returned name of the module
long ifx, ii // for looping through processes
boolean resultP, resultM // return codes for EnumProcesses
and EnumProcessModules
string name // Name of the module
string ls_message, ls_un
ls_un =
"~r~n-------------------------------------------------------------------------------------------~r~n"
resultP=EnumProcesses(Process,TailleP,NeededP)
if resultP=true then
for ifx=1 to integer(NeededP / 4)
HandleP[ifx] =
OpenProcess(PROCESS_ALL_ACCESS,false,Process.lpIdProcess[iFX])
resultM = EnumProcessModules(HandleP[ifx], Module,
TailleM, NeededM)
if NeededM >= 4 then
if GetProcessMemoryInfo( HandleP[ifx], pmc, 40 ) then
ls_message = ''
ls_message = "PageFaultCount: " +
string(pmc.PageFaultCount) + '~r~n' + &
+ "PeakWorkingSetSize: " +
string(pmc.PeakWorkingSetSize ) + '~r~n' &
+ "WorkingSetSize: " + string(pmc.WorkingSetSize )
+ '~r~n' &
+ "QuotaPeakPagedPoolUsage: " +
string(pmc.QuotaPeakPagedPoolUsage ) + '~r~n' &
+ "QuotaPagedPoolUsage: " +
string(pmc.QuotaPagedPoolUsage ) + '~r~n' &
+ "QuotaPeakNonPagedPoolUsage: " +
string(pmc.QuotaPeakNonPagedPoolUsage ) + '~r~n' &
+ "QuotaNonPagedPoolUsage: " +
string(pmc.QuotaNonPagedPoolUsage) + '~r~n' &
+ "PagefileUsage: " + string(pmc.PagefileUsage ) +
'~r~n' &
+ "PeakPagefileUsage: " +
string(pmc.PeakPagefileUsage )
Name=space(254)
resName=GetModuleBaseNameA(handleP[ifx],
Module.lpidmodule[1], name ,254)
//MessageBox( "Memory Info for : " + Name,ls_message)
ii ++
mle_1.text += "~r~nMemory Info for : " + Name + ls_un +
ls_message + ls_un
end if
end if
CloseHandle(HandleP[ifx])
next
IF ii > 0 THEN
mle_1.text = "Retrieved ProcessMemoryInfo for " +
string(ii) + " processes~r~n" + mle_1.text

END IF
else
MessageBox ("Memory Info","Fail calling EnumProcesses")
end if

end event

type mle_1 from multilineedit within w_proc_memory
integer x = 78
integer y = 52
integer width = 2917
integer height = 1332
integer taborder = 10
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
long textcolor = 33554432
boolean hscrollbar = true
boolean vscrollbar = true
boolean autovscroll = true
boolean displayonly = true
borderstyle borderstyle = stylelowered!
end type

type cb_ok from commandbutton within w_proc_memory
integer x = 2592
integer y = 1436
integer width = 361
integer height = 96
integer taborder = 10
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "MS Sans Serif"
string text = "Ok"
boolean default = true
end type

event clicked;close(parent)
end event

> ----------- DISCLAIMER:

0 new messages