What about winexec? Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiAPI/html/delphi_20061114224727232.html
Below is Program Call program B. The logon page of program B is displayed. Enter the user name and password to log on to program B automatically.
Procedure tform1.image1click (Sender: tobject );
VaR
Fhwnd: thandle;
T1hwnd: thandle;
T2hwnd: thandle;
Bhwnd: thandle;
Begin
Winexec (pchar ('C: \ B .exe '), 0 );
// Why does the login interface pop up when run Runs to wait for the user to respond?
Why not directly run the following automatic username and password login operation ??
// But the strange thing is that you can execute it step by step and log on automatically !!
Fhwnd: = findwindow (nil, 'System logins ');
If fhwnd> 0 then
Begin
T1hwnd: = find1_wex (fhwnd, 0, 'tcombobox', nil );
T2hwnd: = find1_wex (fhwnd, 0, 'tedit ', nil );
Bhwnd: = find1_wex (fhwnd, 0, 'tbitbtn ', nil );
If t1hwnd> 0 then
Sendmessage (t1hwnd, wm_settext, 0, INTEGER (pchar (User )));
If t2hwnd> 0 then
Sendmessage (t2hwnd, wm_settext, 0, INTEGER (pchar (PWD )));
If bhwnd> 0 then
Sendmessage (bhwnd, bm_click, 0, 0 );
End;
End;
Please kindly advise!
because it takes some time (even dozens of microseconds) to start a process, the Code execution speed is very fast, at this time, the code for searching the window may have been executed. Therefore, after winexec (pchar ('C: \ B .exe '), 0), it will be better to delay some time, such as about 1 second. Latency:
var
dwtickcount: DWORD;
begin
winexec ('C: \ B .exe ', 0 );
// 1 second delay
dwtickcount: = gettickcount;
while gettickcount () application. processmessages;
// continue to the next step
fhwnd: = findwindow (nil, 'System logins ');
...
end;
I hit your lungs
That sound great!
Very good
I call a common two-tier program. The problem does not exist.
The preceding problem occurs when a three-tier program is called.
Solution after 1 second delay
Thank you! Thank you very much for your advice!
Good
Top