Search code examples
cmcisendstring

Using mciSendString with spaces


i am trying to play a sound file with spaces in its name

example: "my File.wav"

So sending files like this:

mciSendString("play C:\\myFile.wav",0,0,0);

will work just fine. but:

mciSendString("play C:\\my File.wav",0,0,0);

will fail.

is there any solution to this problem?


Solution

  • On Windows, paths containing white characters must be wrapped with quotation marks. So instead of:

    mciSendString("play C:\\my File.wav", 0, 0, 0);
    

    write this:

    mciSendString("play \"C:\\my File.wav\"", 0, 0, 0);
    

    That should work.