cwinapimci

mcisendstring returning null string


I'm stuck trying to retrieve the song length of a music I was able to open and play with WINMM's function mciSendString();

char szCmd[128];
char szResponse[128] = {0};
sprintf_s( szCmd, 128, "status my_alias length");

dwRet =  mciSendString( (LPCSTR)szCmd, szResponse, 0, NULL );

Even though no error code is returned, the szResponse string always return NULL.

I tried setting the time format to milliseconds, with

"set my_alias time format to milliseconds"

but got no luck as well.


Solution

  • As pointed out in the comments, I was passing 0 in the third parameter of mciSendString, which is the size of the return buffer specified by the second parameter.