Home > Back-end >  With Delphi development process browser, old appear from the phenomenon
With Delphi development process browser, old appear from the phenomenon

Time:10-21

The main program call subroutine (web controls in a subroutine), how to ensure that the web form shown in the main program within a given window? Now have to adopt the way of kidnapping, and result in frequent from the phenomenon, and kidnapping way cannot false death,

Develop a multi-process browser Delphi can't? Pair with what method to realize the program call, please? Ensure that the web form shown in the main program within a given window, not away from, also can false death,

CodePudding user response:

Delphi multithreaded used twice, the feeling is not directly use time controls control simpler, and see if I can use other ways instead of the thread,

CodePudding user response:

Is a multiple processes, not multithreading

CodePudding user response:

There are two ways:
1, after the CreateProcess, use a sleep wait;
2, use WaitForInputIdle

CodePudding user response:

What is the way "kidnapping"?

CodePudding user response:

Have made much more process browser,
Handle to keep after creating process, through the message to control the

CodePudding user response:

But some login web site in another open when they appear in the process of the unknown state

CodePudding user response:

Actually there is a better way, if we can get to the child in the main form of the handle, so that the child's main window is created,
 
The do while GetProcessWindow (ProcessInfo dwProcessID)=0
The begin
Application. ProcessMessages;
Sleep (10);
end;

 
//by the ProcessID search window Handle
The function GetProcessWindow (ProcessID: Cardinal) : HWND;
Var
ProcWndInfo: TProcessWindow;
The begin
ProcWndInfo. ProcessID:=ProcessID;
ProcWndInfo. FoundWindow:=0;
EnumWindows (@ EnumWindowsProc, Integer (@ ProcWndInfo));//find the form
Result:=ProcWndInfo. FoundWindow;
end;

CodePudding user response:

Above solution is suitable for: child form from reason is the child form is created,

CodePudding user response:

The function CreateProcess (lpApplicationName: PChar; The lpCommandLine: PChar;
LpProcessAttributes lpThreadAttributes: PSecurityAttributes;
BInheritHandles: BOOL; DwCreationFlags: DWORD; LpEnvironment: Pointer;
LpCurrentDirectory: PChar; Const lpStartupInfo: TStartupInfo;
Var lpProcessInformation: TProcessInformation) : BOOL; Stdcall;
Use the CreateProcess create the child process, get the process id
Using the @ whhitxjl provide GetProcessWindow returns the main window handle
Use Windows. SetParent gives it a parent-child relationship;
The function SetParent (hWndChild, hWndNewParent: HWND) : HWND; Stdcall;
So that we can do a process of forms in another process form shows;

Browser of false death I also want to know, looking forward to the downstairs prawns can have the reply!
  • Related