0
String ^ fileName = textBox5->Text + "DES.wav";

PlaySound(fileName, NULL, SND_FILENAME | SND_SYNC);

错误是说:

错误 4 错误 C2664:“PlaySoundW”:无法将参数 1 从“System::String ^”转换为“LPCWSTR”

4

1 回答 1

0

无需混合托管和非托管代码,使用SoundPlayer类:

String ^ fileName = textBox5->Text + "DES.wav";
SoundPlayer^ player = gcnew SoundPlayer(filename);
player->PlaySync();    // or Play for asynchronous execution

http://msdn.microsoft.com/en-us/library/system.media.soundplayer.aspx

于 2013-04-20T14:30:56.863 回答