How to get HWND from inside a DLL?

I have a DLL in which I want to play sounds using Direct Sound. To play sounds, I need an HWND executable. I do not have an HWND executable that loads the DLL. How do I get this in a DLL without passing it from an executable?

+5
source share
2 answers

You can use GetCurrentProcessId to get the current process id.

You can then call EnumWindows and check each window with GetWindowThreadProcessId to find the window associated with your process.

. 1x1, , Direct Sound.

, ( ).

+5

GetGUIThreadInfo . HWND. HWND , ( ) GetAncestor(GA_ROOT).

0

Source: https://habr.com/ru/post/1742609/


All Articles