I had been having problems with an old app of mine it wouldnt load or show anything and ive just recently picked it up to see why all of a sudden it stopped working.

After alot of messing around it came down to EnumWindows() freezing the app which i also used on startup tht's why it froze without showing anything.

This is my function......


Function WindowList(wHnd: THandle; List: TStringList): Bool; StdCall;
Var Buffer: Array[0..255] Of Char;
Begin
SendMessage(wHnd, WM_GETTEXT, 255, LongInt(@Buffer[0]));
If (Buffer <> '') And IsWindow(wHnd) AND IsWindowVisible(wHnd) Then
Begin
List.AddObject(Buffer, TObject(wHnd));
End;
Result := True; //Continue enumerations till false is returned.
End;

And this is what freezes my app...


Enumwindows(@WindowList, LParam(LstWindows.Items));

Does anybody know what the problem is it used to work but then just started freezing up im suspecting windows is being gay but maybe my code is just tempermental.