change volume win32 c++

后端 未结 6 1992
你的背包
你的背包 2020-12-09 05:41

How would I go about changing the sound volume in c++ win32? Also how would I mute/unmute it? Thanks for the help!

6条回答
  •  清歌不尽
    2020-12-09 06:12

    If all you want to do is change the volume then you can use the virtual key codes to change volume like this:

    void changeVolume()
    {
      INPUT ip={0};
      ip.type = INPUT_KEYBOARD;
      ip.ki.wVk = VK_VOLUME_UP;   //or VOLUME_DOWN or MUTE
      SendInput(1, &ip, sizeof(INPUT));
      ip.ki.dwFlags = KEYEVENTF_KEYUP;
      SendInput(1, &ip, sizeof(INPUT));
    }
    

提交回复
热议问题