Einzelnen Beitrag anzeigen

alzaimar
(Moderator)

Registriert seit: 6. Mai 2005
Ort: Berlin
4.956 Beiträge
 
Delphi 2007 Enterprise
 
#2

Re: WatchDog, Feststellen, das (fremdes Programm) hängt

  Alt 21. Okt 2008, 08:40
Hab ich mal irgendwo ausgeschnipselt, aber nie benutzt:
Delphi-Quellcode:
// For Win NT/2000/XP
function IsAppRespondigNT(wnd: HWND): Boolean;
type
  TIsHungAppWindow = function(wnd:hWnd): BOOL; stdcall;
var
  hKernel: THandle;
  IsHungAppWindow: TIsHungAppWindow;
begin
  Result := True;
  hKernel := GetModuleHandle('user32.dll');
  if (hKernel > 0) then
  begin
    @IsHungAppWindow := GetProcAddress(hKernel, 'IsHungAppWindow');
    if Assigned(IsHungAppWindow) then
    begin
      Result := not IsHungAppWindow(wnd);
    end;
  end;
end;

function IsAppRespondig(Wnd: HWND): Boolean;
begin
 if not IsWindow(Wnd) then
 begin
   ShowMessage('Incorrect window handle');
 Exit;
 end;
 if Win32Platform = VER_PLATFORM_WIN32_NT then
   Result := IsAppRespondigNT(wnd)
 else
   Result := IsAppRespondigNT(GetWindowThreadProcessId(wnd,nil));
end;
"Wenn ist das Nunstruck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput!"
(Monty Python "Joke Warefare")
  Mit Zitat antworten Zitat