Message board for the users of flat assembler.
> Windows > Getting a Window Handle from a Process
Say I execute a file, using ShellExecute or WinExec or some function, how would I get the window handle of that executed file?
|02 Oct 2004, 05:00||
Assuming the app will put a window in the foreground, you can use
GetForegroundWindow. It has no params and returns the handle of the foreground window.
|02 Oct 2004, 07:01||
That could work, except on applications where it takes a certain amount of time for it to load.
|13 Oct 2004, 00:55||
Use CreateProcess to create a process, then enumerate windows (EnumWindows) and call GetWindowThreadProcessId for each window handle passed. Compare recieved values with ones from calling CreateProcess (last parameter, PROCESS_INFORMATION structure) to determine if this window is what you need.
I little bit weird but who knows, maybe it'll work for you
|13 Oct 2004, 08:21||
Try this function from the user32.dll
Set the first parameter to NULL, and the second to the name in the mainwindows "titlebar" ( and lets hope there isn't 2 windows with equal name ).
Well, there are several other ways to do this, and a good startingpoint to investigate it is the following link:
[in] Pointer to a null-terminated string that specifies the class name or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom must be in the low-order word of lpClassName; the high-order word must be zero.
If lpClassName points to a string, it specifies the window class name. The class name can be any name registered with RegisterClass or RegisterClassEx, or any of the predefined control-class names.
If lpClassName is NULL, it finds any window whose title matches the lpWindowName parameter.
[in] Pointer to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match.
If the function succeeds, the return value is a handle to the window that has the specified class name and window name.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
If the lpWindowName parameter is not NULL, FindWindow calls the GetWindowText function to retrieve the window name for comparison. For a description of a potential problem that can arise, see the Remarks for GetWindowText.
To check if the MicrosoftÂ® IntelliType version 1.x software is running, call FindWindow as follows:
|22 Nov 2004, 23:59||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.