Fórum if não funciona veja #287208
06/07/2005
0
[color=red:f993181723]procedure TForm1.BitBtn3Click(Sender: TObject);
var
SnapShot:THandle;
pe:TProcessEntry32;
ii:integer;
i:integer;
ss:string;
processo:dword;
progr:String;
begin
// lista os processos no grid
ii:=1;
SnapShot:=CreateToolhelp32Snapshot((TH32CS_SNAPPROCESS or TH32CS_SNAPTHREAD),0);
pe.dwSize:=sizeof(TProcessEntry32);
Process32First(SnapShot,pe);
repeat
if (StringGrid1.RowCount < ii+1) then
StringGrid1.RowCount := ii + 1;
StringGrid1.Cells[0,ii]:=format(´¬x´,[pe.th32ProcessID]);
StringGrid1.Cells[1,ii]:=inttostr(pe.cntThreads);
StringGrid1.Cells[2,ii]:=String(pe.szExeFile);
progr := String(pe.szExeFile);
inc(ii);
if progr = ´MsnMsgr.exe´ then
begin
processo:=0;
with StringGrid1 do begin
if(Row<1) then // sai se naum houver processo selecionado
exit;
ss:=Cells[0,Row];
// Converte a string em dword
for i:=1 to length(ss) do begin
processo := processo shl 4;
if ord(ss[i]) >= ord(´A´) then
processo:=processo + (ord(ss[i])-ord(´A´)+10)
else
processo:=processo + (ord(ss[i])-ord(´0´));
end;
//Mata o Processo
try
TerminateProcess(OpenProcess($0001,false,processo),0); // $0001 = Process_Terminate.
except
showmessage(´Falha ao tentar matar o processo ´+Cells[0,Row]);
end;
BitBtn3Click(nil);
end;
end;
until Process32Next(SnapShot,pe) = false;
StringGrid1.RowCount := ii;
end;[/color:f993181723]
Tenho este código mas o if que testa se a variavel progr é igual a constante não esta funcionando, alguem poderia testa e me dar uma ajuda
var
SnapShot:THandle;
pe:TProcessEntry32;
ii:integer;
i:integer;
ss:string;
processo:dword;
progr:String;
begin
// lista os processos no grid
ii:=1;
SnapShot:=CreateToolhelp32Snapshot((TH32CS_SNAPPROCESS or TH32CS_SNAPTHREAD),0);
pe.dwSize:=sizeof(TProcessEntry32);
Process32First(SnapShot,pe);
repeat
if (StringGrid1.RowCount < ii+1) then
StringGrid1.RowCount := ii + 1;
StringGrid1.Cells[0,ii]:=format(´¬x´,[pe.th32ProcessID]);
StringGrid1.Cells[1,ii]:=inttostr(pe.cntThreads);
StringGrid1.Cells[2,ii]:=String(pe.szExeFile);
progr := String(pe.szExeFile);
inc(ii);
if progr = ´MsnMsgr.exe´ then
begin
processo:=0;
with StringGrid1 do begin
if(Row<1) then // sai se naum houver processo selecionado
exit;
ss:=Cells[0,Row];
// Converte a string em dword
for i:=1 to length(ss) do begin
processo := processo shl 4;
if ord(ss[i]) >= ord(´A´) then
processo:=processo + (ord(ss[i])-ord(´A´)+10)
else
processo:=processo + (ord(ss[i])-ord(´0´));
end;
//Mata o Processo
try
TerminateProcess(OpenProcess($0001,false,processo),0); // $0001 = Process_Terminate.
except
showmessage(´Falha ao tentar matar o processo ´+Cells[0,Row]);
end;
BitBtn3Click(nil);
end;
end;
until Process32Next(SnapShot,pe) = false;
StringGrid1.RowCount := ii;
end;[/color:f993181723]
Tenho este código mas o if que testa se a variavel progr é igual a constante não esta funcionando, alguem poderia testa e me dar uma ajuda
Dpinho
Curtir tópico
+ 0
Responder
Posts
06/07/2005
Nildo
Tenta verificar com o LowerCase, dos dois lados do IF
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)