I've been playing around with mciSendString("status") and for the life of me I can't get it to work.
I am on XP Pro in C# 2.0
open, close, play, resume, and pause work perfect, but status always returns ascii byte 32 (a lot of them)
mciSendString("open " + Filetoplay + " alias MyMedia", NULL, 0, 0);
this of course works, however:
Stat = Strings.Space(255);
mciSendString("status MyMedia mode", Stat, 255, 0);
just returns spaces in Stat. I've tried different sizes of
strings, defining media types, getting other status' such as length,
but it always returns spaces
is there some precursor to this that I am missing

mciSendString status question
Buddhist
[
DllImport("winmm.dll",EntryPoint="mciSendStringA", ExactSpelling=true, CharSet=CharSet.Ansi, SetLastError=true)] public static extern int mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, IntPtr hwndCallback);[
DllImport("kernel32",EntryPoint="GetShortPathNameA", ExactSpelling=true, CharSet=CharSet.Ansi, SetLastError=true)] public static extern int GetShortPathName(string lpszLongPath, StringBuilder lpszShortPath, int cchBuffer);==================find length=============
StringBuilder lstrbldrReturn = new StringBuilder(250); const uint cchReturnLen = 250; StringBuilder sRet = new StringBuilder((int)cchReturnLen); string lstrMCIRetValue = string.Empty;mintRet = mciSendString(mstrCommand, sRet, 250,
IntPtr.Zero);lstrMCIRetValue = sRet.ToString();
================================
string lstrShortName = string.Empty; StringBuilder lstrbldrShortPath = new StringBuilder(255);lstrShortName = Microsoft.VisualBasic.
Strings.Space(250); int lintsize = GetShortPathName(mstrFileName, lstrbldrShortPath, lstrbldrShortPath.Capacity);lstrShortName = lstrbldrShortPath.ToString().Trim();
if (lintsize > BOConstants.constZeroValue)lstrShortName = lstrShortName.Substring(
BOConstants.constZeroValue, lintsize);mintRet = mciSendString(ConstOpenCommand + lstrShortName + ConstAliasCommand + mstrAlias + ConstTypeCommand + lstrType,
null, BOConstants.constZeroValue, IntPtr.Zero);Wser
Try passing Stat as a StringBuilder object. This worked for me:
[DllImport("winmm.dll")]
static extern uint mciSendString(string sCommand, StringBuilder sReturn, uint cchReturn, IntPtr hwnd);
static void Main(string[] args)
{
const uint cchReturnLen = 256;
StringBuilder sRet = new StringBuilder((int)cchReturnLen);
uint err = mciSendString("open cdaudio alias mycd", sRet, cchReturnLen, IntPtr.Zero);
err = mciSendString("status mycd mode", sRet, cchReturnLen, IntPtr.Zero);
err = mciSendString("set mycd time format tmsf", sRet, cchReturnLen, IntPtr.Zero);
err = mciSendString("play mycd from 1 to 2", sRet, cchReturnLen, IntPtr.Zero);
err = mciSendString("status mycd mode", sRet, cchReturnLen, IntPtr.Zero);
err = mciSendString("stop mycd", sRet, cchReturnLen, IntPtr.Zero);
err = mciSendString("status mycd mode", sRet, cchReturnLen, IntPtr.Zero);
}
----------------------------------------------------------------------------
Mike Wasson, DirectShow SDK Documentation
This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use.
(c) 2006 Microsoft Corporation. All rights reserved.