I Have a dll project. I have to get host application handle. I Can't pass handle from host application to dll project because the host application is not mine.
The host application runs on second monitor but when the host application calls my form (dll) the form shown in first monitor. I have to detect host application screen coordinates or i have to detech the host application runs on first monitor or second monitor.
You are looking for top-level windows in your process. Find them like so:
GetCurrentProcessId
to obtain your process ID.EnumWindows
to enumerate all top level windows.GetWindowThreadProcessId
to obtain the process ID that owns the window. Any that match the process ID found in step 1 are from your process.The problem that you face is that step 3 might identify multiple such windows. You can call GetWindow
passing GW_OWNER
to obtain the owner of the window and use that to trim down the field of candidates. What you perceive as being the main window is likely to have no owner, but the other top level windows may well be owned. Even this cannot be guaranteed to trim the field down to a single candidate and you very likely will need to come up with some additional logic.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments