怎样用api来枚举当前运行的所有程序?
解决方案 »
- 求一个获取COM口和LPT口的代码
- D7调用TLB文件中的以下过程改如何处理
- extern "C" __declspec(dllimport) char * con(CString str)如何在delphi中调用?
- 有没有给树节点的背景添加颜色的?
- @#@关于MSComm发送数据, 请教高手将 VC++.net 的内容译为 Delphi 7 的代码, 在线等,帮顶有分@#@
- 如何清除Canvas画的图
- delphiseabird(沙鸥) 还是不行啊
- 我想把MSSQLSERVER里面的表导出到各个数据库文件中,如MSACCESS,Paradox等,请问该怎么办?
- 如何用Query生成一个空表(带索引)?
- 请问在SQL 7.0中如何将一个表拆成两个表(结构一样,数据不一样)。可以使用存储过程
- ≈≈≈≈≈≈响应号召,请大家多多推荐Win32 SDK/API版2002年内的精华帖,感谢! ≈≈≈≈≈≈
- 新年马上到了,不知道大家去年过的好吗?大家都进来聊聊。
Function ListRuningExeName(ExeName:TStrings):Integer;
Var
iHandle:LongInt;
lppe:tagProcessentry32;
i:integer;
begin
i:=0;
iHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
try
try
if iHandle=-1 then Raise Exception.Create('调用失败!');
Process32First(iHandle,lppe);
While GetLastError<>ERROR_NO_MORE_FILES do
begin
inc(i);
ExeName.Add(lppe.szExeFile);
Process32Next(iHandle,lppe);
end;
except
On E:Exception do begin
Application.HandleException(E);
i:=-1;
end; end;
finally
CloseHandle(iHandle);
Result:=i;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
lppe: TProcessEntry32;
found : boolean;
Hand : THandle;
begin
Hand := CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
found := Process32First(Hand,lppe);
while found do begin
ListBox1.Items.Add(StrPas(lppe.szExeFile));
found := Process32Next(Hand,lppe);
end;
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;type
TForm1 = class(TForm)
ListBox1: TListBox;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.BitBtn1Click(Sender: TObject);
var hcurrentwindow:hwnd;
sztext:array[0..254]of char;
begin
hcurrentwindow:=getwindow(handle,gw_hwndfirst);
while hcurrentwindow <> 0 do
begin
if getwindowtext(hcurrentwindow,@sztext,255) > 0 then
listbox1.Items.Add(strpas(@sztext));
hcurrentwindow:=getwindow(hcurrentwindow,gw_hwndnext);
end;
end;end.
回掉函数可以一一列举所有窗口!