delphi中对于进程的操作
Uses Tlhelp32;
//用Listbox显示方法
procedure TForm1.Button1Click(Sender: TObject);
var
lppe:TProcessEntry32;
found:boolean;
Hand:THandle;
begin
Hand:=CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
lppe.dwSize := Sizeof(lppe); //初始化
found:=Process32First(Hand,lppe);
while found do
begin
ListBox1.Items.Add(StrPas(lppe.szExeFile));//列出所有进程。
found:=Process32Next(Hand,lppe);
end;
end;
=====================================================
procedure TForm1.Timer1Timer(Sender: TObject); //刷新进程列表
begin
listbox.Clear;
self.Button1.Click;
end;
end.
-------------------------------------------------------------------------------------------------------------
//用Listview显示方法
procedure TForm1.FormCreate(Sender: TObject);
var
found:boolean; //定义枚举进程所需变量
NewItem: TListItem;
FSnapshotHandle:tHANDLE;
lppe:TProcessEntry32;
Summ: Word;
begin
with listview1 do
begin
Columns.Add;
Columns.Add;
Columns.Add;
ViewStyle:=vsreport;
GridLines:=true;
columns.items[0].caption:='进程名';
columns.items[1].caption:='进程序号';
columns.items[2].caption:='进程ID';
Columns.Items[0].Width:=100;
Columns.Items[1].Width:=100;
Columns.Items[2].Width:=150; //初始化listview
end;
ListView1.Items.BeginUpdate;
ListView1.Items.Clear;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); //CreateToolhelp32Snapshot函数得到进程快照
lppe.dwSize := Sizeof(lppe); //初始化
found := Process32First(FSnapshotHandle, lppe); //Process32First 得到一个系统快照里第一个进程的信息
Summ := 0;
while found do
begin
Summ := Summ + 1;
NewItem := ListView1.Items.Add; //在ListView1显示
NewItem.ImageIndex := -1;
NewItem.Caption := ExtractFileName(lppe.szExeFile);//进程名称
NewItem.subItems.Add(FormatFloat('00', Summ));//序号
NewItem.subItems.Add(IntToStr(lppe.th32ProcessID));//进程ID
found := Process32Next(FSnapshotHand
相关文档:
内容简介
dbExpress是Borland公司下一代数据访问技术。本书不仅详细介绍了dbExpress的基本功能、使用技巧以及Delphi/Kylix的DataSnap技术,还详细讨论了dbExpress的实现原理以及dbExpress的未来发展趋势。本书结构清晰,讲解透彻,实例丰富。作者李维是Borland公司著名技术专家,曾著有多部Delphi名 ......
{ 函数 : RESULTSTRING = HexToBin(HEXSTRING)
{ 目的 : 把十六进制字符串转换为二进制字符串
{
{===============================================================}
{ 函数 : RESULTINTEGER = HexCharToInt(HEXCHAR)
{ 目的 : 转换一个十六进制字符为整数
{==================================================== ......
procedure TForm1.Button1Click(Sender: TObject);
Var
Num: Integer;
Begin
Try
Num:=StrToInt(Edit1.Text);
Edit2.Text:=IntToStr(Num*Num);
Except
On EConvertError Do ShowMessage(Edit1.Text+'无法转成整数!');
......
制作圆角矩形的窗体:
01.procedure TPortForm.FormCreate(Sender: Tobject);
02.var hr :thandle;
03.begin
04.hr:=createroundrectrgn(0,0,width,height,20,20);
05.setwindowrgn(handle,hr,true);
06.end;
如果不要窗体外框,则使用:
01.procedure TPortForm.FormCreate(Sender: Tobject);
02.var hr :thandl ......