Link to home
Start Free TrialLog in
Avatar of gvector1
gvector1

asked on

MCI

I am attempting to use MCISendString in order to aquire information about a media file.  More specifically I want to get the file length(in time) of a wma file.  I found elsewhere some information that is supposed to accomplish this, but I cannot get it to work.  Below is my code.

Using the code below, the return values of the calls to mciSendString were 0, meaning no errors, but no matter what my command string is, I mssg is ALWAYS blank.  Does anyone see anything that would be keeping mssg from returning a value????????

Thanks,
Kendal
private void FindLength(string file)
		{
			string cmd = "open " + file + " alias voice1";
			StringBuilder mssg = new StringBuilder(255);
			int h = mciSendString(cmd,null,0,0);
			int i = mciSendString("set voice1 time format ms", null, 0, 0);
			int j = mciSendString("status voice1 length", mssg, mssg.Length, 0);
			MessageBox.Show(mssg.ToString());
 
		}
 
		[DllImport("winmm.dll")]
		public static extern int mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, int hwndCallback);
 
		[DllImport ("winmm.dll")] 
		private static extern int mciGetErrorString(int l1, StringBuilder s1, int l2);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of PlatoConsultant
PlatoConsultant
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gvector1
gvector1

ASKER

Excellent.....Thanks a million.  I would have sworn that I even tried using 255, but I guess something was not right.  Also instead of 255, mssg.Capacity could be used.

Thanks again,
Kendal