Thema: Delphi (Re)start explorer.exe

Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#3

Re: (Re)start explorer.exe

  Alt 23. Sep 2011, 14:30
This is my source. How can improve it?

Delphi-Quellcode:
var
  hWnd, hProc: Cardinal;
  pId: DWORD;
begin
  Result := False;
  hWnd := FindWindow('Progman', 'Program Manager');

  GetWindowThreadProcessId(hWnd, @pId);
  hProc := OpenProcess(PROCESS_TERMINATE, False, pId);
  if hProc <> 0 then
  begin
    Result := TerminateProcess(hProc, 0);

    if Result then
    begin
      CloseHandle(hProc);

      if FindWindow('Progman', nil) = 0 then
        ShellExecute(HInstance, 'open', 'explorer', nil, nil, SW_NORMAL)
      ;
    end;
  end;
end;
  Mit Zitat antworten Zitat