I am an amateur and have been studying Visual C++ for a few months. I have Visual Studio 2010 Express. I have written a programme (Form) which needs sound. First version used Windows Media Player and .wma files, but I wrote it for a friend's little girl who lives in China and was told that most Chinese people (incl my friend) have pirate versions of Windows and cannot use mediaplayer - so I assume that means this version will not work there?? Then tried another version without mediaplayer but have to use .wav files (which I cannot generate on Windows 7 and do not trust the conversion tools on the internet, so have to have them recorded elsewhere). THIRD version I went back to .wma files and tried to find a way to play them without mediaplayer, and hit on mciSendString. I am getting nowhere and feel stupid. The documentation says:
Header - Mmsystem.h (include Windows.h) (i don't understand the syntax here)
library - Winmm.lib
dll - Winmm.dll
unicode and ansi names - mciSendStringW (Unicode) and mciSendStringA (ANSI)
Is this where my problem lies?
My (probably incorrect) code is:
mciSendString("open C:\\Yingwen2\\sounds\\" + c + ".wma alias MyFile", NULL, 0, 0);
mciSendString("play MyFile wait", NULL, 0, 0);
mciSendString("close MyFile", NULL, 0, 0);
and the output window shows:
1>c:\users\ant\documents\visual studio
2010\projects\yingwenmci\yingwenmci\Form1.h(433): error C2065: 'NULL' :
undeclared identifier
1>c:\users\ant\documents\visual studio
2010\projects\yingwenmci\yingwenmci\Form1.h(433): error C3861:
'mciSendString': identifier not found
1>c:\users\ant\documents\visual studio
2010\projects\yingwenmci\yingwenmci\Form1.h(434): error C2065: 'NULL' :
undeclared identifier
1>c:\users\ant\documents\visual studio
2010\projects\yingwenmci\yingwenmci\Form1.h(434): error C3861:
'mciSendString': identifier not found
1>c:\users\ant\documents\visual studio
2010\projects\yingwenmci\yingwenmci\Form1.h(435): error C2065: 'NULL' :
undeclared identifier
1>c:\users\ant\documents\visual studio
2010\projects\yingwenmci\yingwenmci\Form1.h(435): error C3861:
'mciSendString': identifier not found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I have found several posts on the internet regarding importing WinMM.dll and have tried mimicking them but it has not worked. Can somebody explain exactly how I use WinMM.dll and/or WinMM.lib.? Do I need an import statement as well as using the linker in Project Properties?? I found both files (I think both - I am not on my own computer at the moment) in System32 folder.
I hope someone has the indulgence and patience to help.........
(Also, as an aside, I am reading Ivor Horton's Beginning Visual Studio 2010 and he frightened the life out of me talking about pointers and the damage they can cause - I notice the definition of mciSendString states the first parameter is a pointer to a null-terminated string - I assume this is defined elsewhere and all I have to do is supply the command eg play or open and not worry about the pointer?
Hope someone can help!