Grazie per questo, alla fine, ho usato una versione modifyed di Neftali's codice, ho incluso qui sotto nel caso in cui nessun altro ha gli stessi problemi in futuro.
FindWindow(PChar('notepad'), nil);
era sempre tornando 0, quindi durante la ricerca di un motivo per cui ho trovato this function che avrebbe trovato il hwnd, e che ha funzionato a meraviglia.
function FindWindowByTitle(WindowTitle: string): Hwnd;
var
NextHandle: Hwnd;
NextTitle: array[0..260] of char;
begin
// Get the first window
NextHandle := GetWindow(Application.Handle, GW_HWNDFIRST);
while NextHandle > 0 do
begin
// retrieve its text
GetWindowText(NextHandle, NextTitle, 255);
if Pos(WindowTitle, StrPas(NextTitle)) <> 0 then
begin
Result := NextHandle;
Exit;
end
else
// Get the next window
NextHandle := GetWindow(NextHandle, GW_HWNDNEXT);
end;
Result := 0;
end;
procedure hideExWindow()
var Indicador:Hwnd;
begin
// Find the window by Classname
Indicador := FindWindowByTitle('MyApp');
// if finded
if (Indicador <> 0) then
begin
// Minimize
ShowWindow(Indicador,SW_HIDE); //SW_MINIMIZE
end;
end;
Ho votato come mi hai messo sulla strada giusta, ma alla fine ho usato il codice di Neftali – Re0sless