Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to provide a HWND to DirectSound SetCooperativeLevel in a console program?
    primarykey
    data
    text
    <p>I'm writing a console program that uses DirectSound API to render some audio data. I stumbled on a curious problem when following the <a href="http://msdn.microsoft.com/en-us/library/ee416964%28v=VS.85%29.aspx" rel="nofollow">DirectSound Programming Guide (from Microsoft)</a>. According to the <a href="http://msdn.microsoft.com/en-us/library/ee416970%28v=VS.85%29.aspx" rel="nofollow">documentation</a> :</p> <blockquote> <p>After creating a device object, you must set the cooperative level for the device by using the <a href="http://msdn.microsoft.com/en-us/library/microsoft.directx_sdk.idirectsound8.idirectsound8.setcooperativelevel%28v=VS.85%29.aspx" rel="nofollow">IDirectSound8::SetCooperativeLevel</a> method. Unless you do this, no sounds will be heard.</p> </blockquote> <p>The problem is that I'm writing a console program, and <code>SetCooperativeLevel</code> requires a HWND as a first argument. I don't have any HWND to deal with in the console program. I tried providing a null pointer but it failed with a <code>DSERR_INVALIDPARAM</code> error code.</p> <p>What HWND value should be provided to <code>IDirectSound8::SetCooperativeLevel</code> in a console program ? The audio part of the program is planned to be built as a shared library, so it has little to no knowledge of the "outside" program.</p> <p>Thanks for any advice !</p> <p><em>Note : I know that there is a somewhat better solution for simply rendering audio, like using SDL, OpenAL, SFML (based on OpenAL), but for my current project DirectSound is enforced.</em></p> <hr> <p><strong>Edit</strong> : I found a <a href="http://groups.google.com/group/microsoft.public.win32.programmer.directx.audio/msg/2145cdcf7753c9c3" rel="nofollow">message</a> from a Microsoft engineer that removes doubts about using the desktop window or the console window as a HWND for <code>SetCooperativeLevel</code> when creating GLOBAL_FOCUS buffers.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload