1 2 //--------------------------------------------------------------------------- 3 4 #include <vcl.h> 5 #pragma hdrstop 6 7 #include "Unit1.h" 8 //--------------------------------------------------------------------------- 9 #pragma package(smart_init) 10 #pragma resource "*.dfm" 11 TForm1 *Form1; 12 //--------------------------------------------------------------------------- 13 __fastcall TForm1::TForm1(TComponent* Owner) 14 : TForm(Owner) 15 { 16 } 17 bool AppFrozen(HWND H){ 18 unsigned long dwResult; 19 unsigned int timeout = 3000; // ms 20 21 return SendMessageTimeout(H, WM_NULL, 0, 0, 22 SMTO_ABORTIFHUNG || SMTO_BLOCK, 23 timeout, 24 &dwResult) != 0; 25 } 26 //--------------------------------------------------------------------------- 27 28 void __fastcall TForm1::Button1Click(TObject *Sender) 29 { 30 31 HWND H; 32 33 H = FindWindow(NULL, "Name of Application"); 34 if (H != 0){ 35 if (AppFrozen(H)) { 36 ShowMessage("This Application is Frozen!"); 37 38 } 39 } 40 41 42 } 43 //---------------------------------------------------------------------------