0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

c++ builder > sound > 音が鳴らない環境 / 鳴る環境 > Win32\Debug以下にある時に鳴らない

Last updated at Posted at 2016-01-11
環境
- 実装 : C++ Builder XE4
- 動作 : Windows 7pro

http://qiita.com/7of9/items/8da2ff7bc4bafd0c66f7
にて実装していたPlaySound()が鳴らない問題。

鳴る環境と、鳴らない環境が分かった。

  • 鳴らない環境 > Win32\Debug以下にあるexeファイル使用時
  • 鳴る環境 > 同じexeファイルを他の場所に移した時

これまで遭遇したことのない症状だ。

IDEのバグか?

PlaySound()もMediaPlayer使用時も両方とも音が鳴る環境が見つかった

Unit1.cpp
void __fastcall TForm1::Button3Click(TObject *Sender)
{
	wchar_t mywin[255];
	GetWindowsDirectory(mywin, MAX_PATH);
	ShellExecute(this->Handle, L"open", L"control", L"mmsys.cpl,,0", mywin, SW_SHOWNORMAL);
	Sleep(1000);

	PlaySound(L"C:\\WINDOWS\\Media\\chord.wav", NULL, SND_ASYNC);

	Sleep(1000);

	MediaPlayer1->FileName = L"C:\\WINDOWS\\Media\\chord.wav";
	MediaPlayer1->Open();
	MediaPlayer1->Play();
}
//---------------------------------------------------------------------------

上記の問題により「デバッグ時には音は鳴らない」

解決策2

Win32\Debug以下に.exeファイルがある場合、「名前を変更すれば」鳴るようになった。

例としてProject1.exeをProject1b.exeにする。

ただし、こちらもデバッグ時には音が鳴らない。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?