Code:
PlaySound((LPCWSTR) "C:\\music30.wav", NULL, SND_FILENAME | SND_ASYNC);
PlaySound(L"music30.wav.wav", NULL, SND_ASYNC | SND_FILENAME);
the first one is even more broken than the second one.
you can't just cast it and hope that it goes ok. it doesn't work like that. you need to use the macros like _T and TEXT.
PlaySound is a macro that expands to PlaySoundA or PlaySoundW, depending on what you have defined for your unicode project settings. if it's defined, it will change it to PlaySoundW and it expects a LPCWSTR (aka L"string"), if not, then it will use PlaySoundA and want the plain string (aka "string" aka LPCSTR).
like this:
Code:
PlaySound(TEXT("C:\\music30.wav"), NULL, SND_FILENAME | SND_ASYNC);
PlaySound(_T("C:\\music30.wav"), NULL, SND_FILENAME | SND_ASYNC);
PlaySoundA("C:\\music30.wav", NULL, SND_FILENAME | SND_ASYNC);
PlaySoundW(L"C:\\music30.wav", NULL, SND_FILENAME | SND_ASYNC);
wrong:
Code:
PlaySound(L"music30.wav", NULL, SND_ASYNC | SND_FILENAME);
PlaySound((LPCWSTR) "C:\\music30.wav", NULL, SND_FILENAME | SND_ASYNC);
PlaySound("C:\\music30.wav", NULL, SND_FILENAME | SND_ASYNC);
PlaySoundA(L"C:\\music30.wav", NULL, SND_FILENAME | SND_ASYNC);