I need it just to play a quick sound. I dont need it to play a sound file.
and when I am trying to do that
"PlaySound("C:\\SOUNDS\\BELLS.WAV", NULL, SND_ASYNC);" function I have an error : undefined reference to `PlaySoundA@12'
Try this small program, to see how to get a wav file to play. This worked for me using C++ Visual Express 2012.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// PlaySound.cpp : main project file.
#include <iostream>
#include <windows.h>
#include <string>
#pragma comment(lib, "winmm.lib")
int main()
{
std::wstring soundfile(L"C:\\Temp\\Flash Drive\\HelloCommander.wav");
// Change 'C:\\Temp\\Flash Drive\\HelloCommander.wav' above, to the name and location of your wav file
PlaySound(soundfile.c_str(), NULL, SND_ASYNC);
Sleep(2500);
std::cout << "Press any key to close program.." << std::endl;
getchar();
return 0;
}
whitenite1: I can't run it...
error: cannot convert 'const wchar_t*' to 'const CHAR*' for argument '1' to 'BOOL PlaySoundA(const CHAR*, HINSTANCE__*, DWORD)'