Your post earlier generates errors. Thanks
Printable View
Your post earlier generates errors. Thanks
Here is the code that I used (the code stated by you in an earlier post)
Here is the compile log:Code:#include <windows.h>
#include <cstdio>
int main(int argc, char **argv)
{
BOOL f;
f = PlaySound("c:\\Fanfare.wav", 0, SND_FILENAME);
if (!f)
printf("Error\n");
else
printf("Done!\n");
return 0;
}
------ Build started: Project: soundtest3, Configuration: Debug Win32 ------
Compiling...
soundtest3.cpp
c:\documents and settings\mom\my documents\visual studio 2008\projects\soundtest3\soundtest3\soundtest3.cpp (7) : error C2664: 'PlaySoundW' : cannot convert parameter 1 from 'const char [15]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Build log was saved at "file://c:\Documents and Settings\Mom\My Documents\Visual Studio 2008\Projects\soundtest3\soundtest3\Debug\BuildLog .htm"
soundtest3 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I have the Fanfare.wav file on my C drive in not specific folder. I attempted to use PlaysoundA and still received errors.
Thanks Very Much
Well, I've already posted a working version. However, if you compile with Unicode enabled [as it seems you do], then you need to use the appropriate "make unicode out of text-string" such as TEXT("some text") or _T("some text") [those are both doing the same thing, and I can't remember which you use for which type of application - try one, and if it doesn't work, use the other.
The latter code I posted works on my machine without errors and warnings (using Visual Studio .Net), but it's entirely possible to set the compile flags or otherwise change settings. You also need to set the right library to be linked in, either using the pragma setting that you have in your example, or using the "additional libraries" in the linker tab on Visual Studios project properties page.
--
Mats