Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to kill the Explorer task 1

Status
Not open for further replies.

john230873

Programmer
Oct 3, 2003
89
NZ
Been looking for a way to erminate the explorer task like if you went into the tsk manager and end task on Explorer.

The closest I have found is to destory the Progman task .

Any deas
 
I found a example n Torrys delphipages (

Code:
uses 
  Tlhelp32; 

function KillTask(ExeFileName: string): Integer; 
const 
  PROCESS_TERMINATE = $0001; 
var 
  ContinueLoop: BOOL; 
  FSnapshotHandle: THandle; 
  FProcessEntry32: TProcessEntry32; 
begin 
  Result := 0; 
  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 
  FProcessEntry32.dwSize := SizeOf(FProcessEntry32); 
  ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32); 

  while Integer(ContinueLoop) <> 0 do 
  begin 
    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = 
      UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) = 
      UpperCase(ExeFileName))) then 
      Result := Integer(TerminateProcess( 
                        OpenProcess(PROCESS_TERMINATE, 
                                    BOOL(0), 
                                    FProcessEntry32.th32ProcessID), 
                                    0)); 
     ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32); 
  end; 
  CloseHandle(FSnapshotHandle); 
end; 

procedure TForm1.Button1Click(Sender: TObject); 
begin 
  KillTask('explorer.exe'); 
end;

//Nordlund
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top