PROCESSENTRY32 lpe_processentry
SetNull (lul_th32ProcessID)
lul_hSnapshot = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, lul_th32ProcessID)
long i
lb_1.Reset()
lb_processes.reset()
DW_1.RESET()
if lul_hSnapshot > 0 then
lpe_processentry.dwSize = 296
if Process32First (lul_hSnapshot, lpe_processentry) then
do
lb_processes.AddItem (lpe_processentry.szExeFile)
//lu_ProcessID=GetCurrentProcessId()
lb_1.AddItem(string(lpe_processentry.th32ProcessID))
//il_processid[i]=lpe_processentry.th32ProcessID
//i++
I=DW_1.INSERTROW(0)
DW_1.OBJECT.process_exename[I]=lpe_processentry.szExeFile
DW_1.OBJECT.process_exEID[I]=lpe_processentry.th32ProcessID
DW_1.OBJECT.dwsize[I]=lpe_processentry.dwsize
loop while Process32Next (lul_hSnapshot, lpe_processentry)
end if
event open;DW_1.SETTRANSOBJECT(SQLCA)
DW_1.RESET()
CB_1.TRIGGEREVENT(CLICKED!)
end event
type cb_4 from commandbutton within w_processes
integer x = 1074
integer y = 1360
integer width = 594
integer height = 104
integer taborder = 40
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "查看当前进程是否运行"
end type
event clicked;if invo_process.uf_isrunning(il_current_processid,is_exename) then
messagebox("","所选进程正在运行")
else
messagebox("","所选进程没运行")
end if
end event
type sle_1 from singlelineedit within w_processes
integer x = 32
integer y = 1236
integer width = 2277
integer height = 104
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
end type
type cb_3 from commandbutton within w_processes
integer x = 27
integer y = 1360
integer width = 343
integer height = 104
integer taborder = 20
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "创建进程"
end type
event clicked;if sle_1.text = "" then return
if invo_process.uf_createprocess(sle_1.text) then
DW_1.RESET()
CB_1.TRIGGEREVENT(CLICKED!)
MESSAGEBOX("","进程创建成功")
else
MESSAGEBOX("","进程创建失败")
end if
end event
type dw_1 from datawindow within w_processes
integer x = 9
integer y = 8
integer width = 2304
integer height = 1192
integer taborder = 50
string title = "none"
string dataobject = "d_process"
boolean hscrollbar = true
boolean vscrollbar = true
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type
event clicked;if row >0 then
il_current_processid=this.object.process_exeid[row]
IS_EXENAME =this.object.process_exename[row]
//messagebox("",il_current_processid)
end if
end event
forward
global type w_processes from window
end type
type cb_4 from commandbutton within w_processes
end type
type sle_1 from singlelineedit within w_processes
end type
type cb_3 from commandbutton within w_processes
end type
type dw_1 from datawindow within w_processes
end type
type lb_1 from listbox within w_processes
end type
type cb_2 from commandbutton within w_processes
end type
type cb_1 from commandbutton within w_processes
end type
type lb_processes from listbox within w_processes
end type
type cb_ok from commandbutton within w_processes
end type
type processentry32 from structure within w_processes
end type
end forward
type PROCESSENTRY32 from structure
ulong dwSize
ulong cntUsage
ulong th32ProcessID
ulong th32DefaultHeapID
ulong th32ModuleID
ulong cntThreads
ulong th32ParentProcessID
long pcPriClassBase
ulong dwFlags
character szExeFile[260]
end type
global type w_processes from window
integer x = 1056
integer y = 484
integer width = 2546
integer height = 1800
boolean titlebar = true
string title = "进程管理"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 78682240
cb_4 cb_4
sle_1 sle_1
cb_3 cb_3
dw_1 dw_1
lb_1 lb_1
cb_2 cb_2
cb_1 cb_1
lb_processes lb_processes
cb_ok cb_ok
end type
global w_processes w_processes
type prototypes
Function ulong CreateToolhelp32Snapshot (ulong dwFlags, ulong th32ProcessID) Library "KERNEL32.DLL"
Function boolean Process32First (ulong hSnapshot, ref PROCESSENTRY32 lppe) Library "KERNEL32.DLL"
Function boolean Process32Next (ulong hSnapshot, ref PROCESSENTRY32 lppe) Library "KERNEL32.DLL"
Function boolean CloseHandle (ref ulong hObject) Library "KERNEL32.DLL"
FUNCTION boolean TerminateProcess (ulong hProcess, uint uExitCode) LIBRARY "KERNEL32.DLL"
FUNCTION ulong GetCurrentProcessId() LIBRARY "kernel32.dll"
Subroutine ExitProcess(ulong uExitCode) LIBRARY "kernel32.dll"
FUNCTION boolean GetExitCodeProcess (ulong hProcess, Ref uint lpExitCode) LIBRARY "KERNEL32.DLL"
FUNCTION ulong GetCurrentProcess() LIBRARY "kernel32.dll"
FUNCTION ulong OpenProcess(ulong dwDesiredAccess,ulong bInheritHandle,ulong dwProcessId) LIBRARY "kernel32.dll"
end variables
on w_processes.create
this.cb_4=create cb_4
this.sle_1=create sle_1
this.cb_3=create cb_3
this.dw_1=create dw_1
this.lb_1=create lb_1
this.cb_2=create cb_2
this.cb_1=create cb_1
this.lb_processes=create lb_processes
this.cb_ok=create cb_ok
this.Control[]={this.cb_4,&
this.sle_1,&
this.cb_3,&
this.dw_1,&
this.lb_1,&
this.cb_2,&
this.cb_1,&
this.lb_processes,&
this.cb_ok}
end on
on w_processes.destroy
destroy(this.cb_4)
destroy(this.sle_1)
destroy(this.cb_3)
destroy(this.dw_1)
destroy(this.lb_1)
destroy(this.cb_2)
destroy(this.cb_1)
destroy(this.lb_processes)
destroy(this.cb_ok)
end on
Function long FindWindow (ref string lpClassName, ref string lpWindowName)Library "user32"
Function long GetWindowThreadProcessId (ref long hwnd,ref long lpdwProcessId)Library "user32"