views:

199

answers:

1

I've P/Invoked the mciSendString method from WinMM.dll:

[DllImport("winmm.dll")]
private static extern long mciSendString(string strCommand, StringBuilder strReturn,
                                         int iReturnLength, IntPtr hwndCallback);

I can play, pause, and stop songs (I can also open/close the CD drive, but that's not important). Now I want my user to be able to skip to a certain part in a song (e.g. 1:21). I've looked at the seek functions documentation and it seems pretty staightforward except that I can't figure out how long a song is. Does a command/method exist to do this in WinMM?

+1  A: 

It would probably be something like this:

StringBuilder sb = new StringBuilder(128);
mciSendString("status mediafile length", sb, 128, IntPtr.Zero);
long songlength = Convert.ToUInt64(sb.ToString());
Magnus Johansson
That did the trick. Thanks. BTW great Stackoverflow/Serverfault sidebar gadget.
Lucas McCoy