directsound

How do I get a HWND from inside a DLL?

感情迁移 提交于 2019-12-01 04:40:16
问题 I have a DLL that I want to play sounds using Direct Sound. In order to play sounds, I need the HWND of the executable. I don't have a HWND of the executable that loads the DLL. How do I get that in the DLL without passing it in from the executable? 回答1: You could use GetCurrentProcessId to get the current process Id. You could then call EnumWindows, and check each window with GetWindowThreadProcessId to find a window associated with your process. However, an easier option might be to just

Detect headphones in Windows [duplicate]

拈花ヽ惹草 提交于 2019-11-27 03:06:00
问题 This question already has answers here : Detecting when head phones are plugged in (5 answers) Closed 5 years ago . I'm trying to detect if the headphones are plugged in on Windows. I've already tried DirectSound and the NAudio library and have not had any success. Does anyone have any suggestions? NOTE: this question is a duplicate of this question, but the answer to that question didn't contain any code samples or tutorials. 回答1: So...I think I might found something REALY obscure.. Can any