I am working on a special project with an unusual design.
In my application/process, I will create a sub process to do some work. In my process, I need to get the feedback from sub process. I want to pass the Windows handle of my application/process to this sub process, so I am post message from this sub process.
How can I pass Window Handle to sub process? My sub process is an command line application without Window UI and with the main function like this:
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow)
Should I pass Window Handle to the main function? How?
Thanks
However, you can obtain the window handle by calling FindWindow() . This function retrieves a window handle based on a class name or window name. Call GetConsoleTitle() to determine the current console title. Then supply the current console title to FindWindow() .
getWindowHandle( ): When a website opens, we need to handle the main window i.e the parent window using driver. getWindowHandle( ); method. With this method, we get a unique ID of the current window which will identify it within this driver instance.
Once the Selenium WebDriver instance is instantiated, a unique alphanumeric id is assigned to the window. This is called window handle and is used to identify browser windows. Since the id is unique, it is used by the Selenium WebDriver to switch between different windows (or tabs).
Hi Fardeen, a Window Handle is a unique identifier that holds the address of all the windows. This is basically a pointer to a window, which returns the string value. This window handle function helps in getting the handles of all the windows. It is guaranteed that each browser will have a unique window handle.
Window handles (HWNDs) are global to the system so you can just print the handle as a decimal number into a string buffer, pass it as a string on the command line when you spawn your sub-process with CreateProcess, and call _wtoi() or similar to convert the string back to a handle again.
The whole mutex manipulation is only to make sure second process will not read from shared memory before anything is written there.
(thanks to @JonathanPotter for comments)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With