powered by simpleCommunicator - 2.0.59     © 2025 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / PowerBuilder [игнор отключен] [закрыт для гостей] / Как получитть список запущенных процессов ?
6 сообщений из 6, страница 1 из 1
Как получитть список запущенных процессов ?
    #32725359
hurr
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Очень хочется знать запущен EXEL или нет.
Был где то примерчик - потерял :(
...
Рейтинг: 0 / 0
Как получитть список запущенных процессов ?
    #32726699
Фотография Филипп
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
$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
...
Рейтинг: 0 / 0
Как получитть список запущенных процессов ?
    #32726930
hurr
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Спасибо Филлип ! :) ОГРОММНОЕ
...
Рейтинг: 0 / 0
Как получитть список запущенных процессов ?
    #32728998
Фотография Филипп
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Проще можно вот так
...
Рейтинг: 0 / 0
Как получитть список запущенных процессов ?
    #32768568
hurr
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Интересно н овот этии ф-ции (упомянутые выше ) не работают под Win9x :(


Function Boolean EnumProcesses(REF processEntry Process, long cb, REF long cbNeeded ) Library "PSAPI.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"


Ругается - ошибка вызова "PSAPI.DLL"
В XP - ест оно в 9x - нет .... Интересно а как же в 9x ?
...
Рейтинг: 0 / 0
Как получитть список запущенных процессов ?
    #32768649
Dim2000
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
hurrИнтересно н овот этии ф-ции (упомянутые выше ) не работают под Win9x :(
Общеизвестный факт. У Win9x вместо этого Toolhelp (CreateToolhelp32Snapshot и иже с ним).
...
Рейтинг: 0 / 0
6 сообщений из 6, страница 1 из 1
Форумы / PowerBuilder [игнор отключен] [закрыт для гостей] / Как получитть список запущенных процессов ?
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]