This has nothing to do with mciSendString.
The problem is that macro substitution does not occur inside quoted text (although that is not a problem really... it's a good thing).
example:
1 2
|
#define replaced yuk
cout << "I would be upset if the macro replaced any of this text";
|
despite 'replaced' occuring within my string, the compiler will fortunately not do macro substitution on it. If it did, it would be very difficult to have the literal text 'replaced' anywhere in my program!
But you really shouldn't be using macros for constants anyway. There are a million reasons why macros should be avoided.
Instead... you can use a constant:
|
const LPCTSTR song1 = TEXT("song1.mp3");
|
But then the problem becomes... how do you combine that constant with the "play" text? The answer is you'd do it just like any other string concatenation.
Note I'm going to get a little tricky here in order to try and keep this simple... bear with me:
1 2 3 4 5 6 7
|
#include <string>
//...
const std::string song1 = "E:\\song1.mp3";
//...
std::string command = "play " + song1; // append the strings together
mciSendStringA(command.c_str(), NULL, 0, NULL); // then send the joined strings to mciSendString
|
Note a few changes:
1) I'm using std::string to handle strings because it's way easier
2) I'm not using any macro garbage
3) I'm calling
mciSendStringA
instead of
mciSendString
. The difference between the two is that mciSendStringA takes normal char strings (meaning you don't need the TEXT() macro). mciSendString takes something called 'TCHAR' strings, which are retarded.