Hello all, I have been working with the playsound() function in Visual Studio 2005, and find myself coming up short in getting it to work. I have recieved many compile errors, and never successfully have gotten it to function.
I am using VC++ console application, WITHOUT a precompiled header. My main form is too long to list, but here is the code that is runable.
#include <iostream> /* Basic STD*/
#include <string>/* For words */
#include <fstream> /* Save/load data*/
#include <cctype> /*Learned from another project, typing*/
#include <ctime> /* random generator */
#include <cstdlib> /* random generator */
#include <windows.h>
//#include <winmm.lib>
#include <mmsystem.h>
#include <conio.h>
using namespace std ;
int main()
{
PlaySound(TEXT("test.wav"), NULL, SND_ALIAS | SND_APPLICATION);
return 0 ;
}
I recieve this error:
1>main2.obj : error LNK2019: unresolved external symbol __imp__PlaySoundW@12 referenced in function _main
1>F:\RP MX\#Source Code#\Debug\RPG.exe : fatal error LNK1120: 1 unresolved externals
If I use this code
#include <iostream> /* Basic STD*/
#include <string>/* For words */
#include <fstream> /* Save/load data*/
#include <cctype> /*Learned from another project, typing*/
#include <ctime> /* random generator */
#include <cstdlib> /* random generator */
#include <windows.h>
//#include <winmm.lib>
#include <mmsystem.h>
#include <conio.h>
using namespace std ;
int main()
{
PlaySound("test.wav", NULL, SND_ALIAS | SND_APPLICATION);
return 0 ;
}
I receive this error:
1>f:\rp mx\#source code#\rpg\main2.cpp(82) : error C2664: 'PlaySoundW' : cannot convert parameter 1 from 'const char [9]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Finally:
#include <iostream> /* Basic STD*/
#include <string>/* For words */
#include <fstream> /* Save/load data*/
#include <cctype> /*Learned from another project, typing*/
#include <ctime> /* random generator */
#include <cstdlib> /* random generator */
#include <windows.h>
//#include <winmm.lib>
#include <mmsystem.h>
#include <conio.h>
using namespace std ;
int main()
{
PlaySound("test.wav");
return 0 ;
}
This error:
1>f:\rp mx\#source code#\rpg\main2.cpp(82) : error C2660: 'PlaySoundW' : function does not take 1 arguments
Please, anyone who helps me, please use a basic code to help. I cannot understand non-namespace, or any other advanced coding schemes. Thank you. -Keith