I have two applications in which the first should find the form handle from the second (also mine), but of another application (not an instance, but another application). I have seen some methods, but I would like to know how safe it is, what I would like to do, or what is an effective way to do this.
I thought to use a function FindWindowwhere you can pass the name of the class, so if I change a member WinClassNamein the CreateParamsform for a unique value (for example, GUID), then I would be quite easy to find a window with a great chance, this is the one of my application.
Application whose form is to be found:
procedure TForm1.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.WinClassName := '{1EE65C52-2F4B-4600-AAE2-079C29AD2220}';
end;
Another application that should find the form from the previous one:
procedure TForm1.Button1Click(Sender: TObject);
var
FormHandle: HWND;
begin
FormHandle := FindWindow('{1EE65C52-2F4B-4600-AAE2-079C29AD2220}', nil);
ShowMessage(IntToStr(FormHandle));
end;
:
TCreateParams , , ? ( , )?
!