请高手指点,这样错在那里,要怎么修改
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,tlhelp32, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
function qqExist:boolean;
implementation
{$R *.dfm}
function SQLExist:boolean;
var ProcessList:Thandle;
pe:TPROCESSENTRY32;
begin
ProcessList:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
pe.dwSize:=sizeof(TPROCESSENTRY32);
try
if process32first(ProcessList,pe) then
if strcomp(pe.szExeFile, 'QQ.exe ')=0 then
begin
sqlexist:=False;
exit;
end
else
while process32next(processlist,pe) do
if strcomp(pe.szExeFile, 'QQ.exe ') <> 0 then
sqlexist:=true
else
begin
sqlexist:=false;
exit;
end;
finally
closehandle(processlist);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if sqlexist then
label1.Caption:= 'qq正在运行. '
else
label1.Caption:= 'qq不在运行! ';
end;
end.
[解决办法]
'QQ.exe ' :多了一个空格;
if strcomp(pe.szExeFile, 'QQ.exe ') <> 0 then //多了一个空格
sqlexist:=true //应该是False
else
begin
sqlexist:=false; //应该是true
[解决办法]
用F7执行,学会调试
看看到那里错误,或者到那里结果不正确