# How to connect glfw and DirectSound8

**URL:** <https://discourse.glfw.org/t/how-to-connect-glfw-and-directsound8/2985>\
**Category:** support\
**Created:** [January 7, 2026, 7:27am UTC](https://discourse.glfw.org/t/how-to-connect-glfw-and-directsound8/2985 "2026-01-07T07:27:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![YashwanthCB](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/yashwanthcb/32/1062_2.png) [@YashwanthCB](https://discourse.glfw.org/u/YashwanthCB)\
**Post date:** [January 7, 2026, 7:27am UTC](https://discourse.glfw.org/t/how-to-connect-glfw-and-directsound8/2985/1 "2026-01-07T07:27:23Z")

</div>

Hi. i am working with glfw and opengl for rendering and directsound8 for audio.

However i am not able to create ds8 object with glfw window.

here is my code:

```auto

int main(int argc, char* argv[])
{
    if (!glfwInit())
    {
        return -10;
    }
    
    GLFWwindow* window;
    window = glfwCreateWindow(640, 480, "Hello Engine Sound", NULL, NULL);
    
    if (window == NULL)
    {
        glfwTerminate();
        return -50;
    }
    
    glfwMakeContextCurrent(window);
    HWND hwnd = glfwGetWin32Window(window);
    GUID guid;
    IDirectSound8 *dsdevice;
    HRESULT result = DirectSoundCreate8(&guid, &dsdevice, NULL);
    result = dsdevice->SetCooperativeLevel(hwnd, DSSCL_PRIORITY);
return 0;
}

```

I am getting access violation at SetCooperativeLevel call.

---

<div class="post-metadata">

**Author:** ![YashwanthCB](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/yashwanthcb/32/1062_2.png) [@YashwanthCB](https://discourse.glfw.org/u/YashwanthCB)\
**Post date:** [January 7, 2026, 7:55am UTC](https://discourse.glfw.org/t/how-to-connect-glfw-and-directsound8/2985/2 "2026-01-07T07:55:56Z")

</div>

I found the issue. i should pass the GUID returned by enumerate device function.
