-
playsound error
Code:
#include <iostream>
#include <windows.h>
#include <conio.h>
using namespace std;
int main()
{
int i;
//char *prt = "C:\\WINDOWS\\Media\\chord.wav";
cout << "test";
do
{
i = getch();
if ( i == 13)
{
PlaySound("chord.wav", NULL, SND_ALIAS);
}
}while(1);
return 0;
}
what am i diong wrong here?
here are the linker errors im geting
Linking...
Text1.obj : error LNK2001: unresolved external symbol __imp__PlaySoundA@12
Debug/Text1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
-
btw, chord.wav is in my current directory
-
I could be wrong... but I think I had a problem with including windows.h and using namespace std. I think I had to use the old style headers and leave out namespace std.
-
Code:
#include <iostream.h>
#include <windows.h>
#include <conio.h>
//using namespace std;
int main()
{
int i;
//char *prt = "C:\\WINDOWS\\Media\\chord.wav";
//cout << "test";
do
{
i = getch();
if ( i == 13)
{
PlaySound("chord.wav", NULL, SND_ALIAS);
}
}while(1);
return 0;
}
same errors
does this only work in windows programs, im using this in a win32 console application
-
Your getting a linking error because it can't find the actual implementation of PlaySound. You need to link to the appropriate library winmm.lib either in the project settings or explicitly for Visual Studio by using this line near the top of the file.
Code:
#pragma comment(lib,"winmm.lib");
-
I guess I was wrong. :(
PlaySound() should work in console!
-
THANK YOU VERY MUCH
omg my project is going to be bomb! :D:D