PB SENDMESSAGE ShellExecuteEx
Bonjour ,
si je je lance une application via
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
function RunAsAdmin(hWnd: hWnd; filename: string; Parameters: string): Boolean;
var
ExitCode, D1: DWORD;
Message1: TMsg;
begin
bProcess := true ;
ZeroMemory(@sei, SizeOf(sei));
sei.cbSize := SizeOf(TShellExecuteInfo);
sei.Wnd := hWnd;
sei.fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT ;
sei.lpVerb := PChar('runas');
sei.lpFile := PChar(filename); // PAnsiChar;
if Parameters <> '' then
sei.lpParameters := PChar(Parameters); // PAnsiChar;
sei.nShow := SW_SHOWNORMAL; // Integer;
result := false;
if ShellExecuteEx(@sei) then
begin
PH := sei.hProcess;
while WaitForSingleObject(sei.hProcess, 200) <> WAIT_OBJECT_0 do
begin
if not bProcess then TerminateProcess(sei.hProcess, 0);
Application.ProcessMessages;
end;
CloseHandle(PH);
result := true
end;
bProcess := false ;
end; |
La procédure suivante ne fonctionne plus
Code:
1 2 3 4
|
receiverHandle := FindWindow(PChar('TfrmMain'),PChar('Test')) ;
if receiverHandle <> 0 then
SendMessage(receiverHandle, WM_USER+1, 0 , 0) ; |
Elle fonctionne si je lance l'appli cible indépendament