LoginSignup
0
1

More than 5 years have passed since last update.

c++ builder XE4, 10.2 Tokyo > sound >コントロールパネルのサウンドタブを表示する

Last updated at Posted at 2016-01-11
動作確認
C++ Builder XE4
  - Windows 7 pro
Rad Studio 10.2 Tokyo Update 2 (追記: 2017/12/27)
  - Windows 10 pro バージョン 1709

やりたいこと

音量を可視化したい。

Windows7にて右下のvolumeを表示すれば音量は見えるが、自作アプリ実行時にはvolumeは閉じてしまう。

実装

参考1 http://www.greatis.com/delphicb/tips/lib/system-volumecontrol.html
参考2 http://stackoverflow.com/questions/4314217/how-to-open-microphone-properties-window/4314761#4314761

参考1のsndvol32.exeはWin7では見当たらないようだ。
参考2を足して(表示タブの番号を1から0に変更し)

Unit1.cpp
    wchar_t mywin[255];
    GetWindowsDirectory(mywin, MAX_PATH);
    ShellExecute(this->Handle, L"open", L"control", L"mmsys.cpl,,0", mywin, SW_SHOWNORMAL);
    Sleep(1000);

    Beep(2000, 300);

これでBeep()処理する前に以下のウィンドウが表示され、その右側のバーで音量の大きさが可視化される。

qiita.png

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1