I have a problem after upgrading Delphi.
I have this code:
function EnumerateWindows(hWnd: HWND; lparam:LPARAM):Bool;
var
ClassName, TheText : Array [0..255] of char;
sName : string;
begin
Application.ProcessMessages;
GetClassNAme(hWnd,Classname, 255);
if GetWindowText(hWnd, TheText, 255) > 0 then
begin
sName := StrPas(TheText);
if pos('NOTEPAD',UpperCase(sName)) > 0 then
postMessage(FindWindow(ClassName, TheText), WM_CLOSE, 0, 0);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
EnumWindows(@EnumerateWindows,0);
end;
In Delphi 7 the code above is working perfectly anytime there is NOTEPAD title and the program will kill its process but when I tried to use Selphi 10.3 the code above is not working. When i open Notepad it does not kill the process (there is no error in compiler). Is there any way to make the code work in Delphi 10.3?