?
Solved

MCI

Posted on 2008-01-31
2
Medium Priority
?
497 Views
Last Modified: 2013-12-17
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

0
Comment
Question by:gvector1
2 Comments
 
LVL 11

Accepted Solution

by:
PlatoConsultant earned 2000 total points
ID: 20798169
i have tried ur code,  if u replace the mssg.length with 255 code start to work ...

i have changed ur code a liitle and its working now....

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, 255, 0);
 
            int seconds;
            seconds = int.Parse(mssg.ToString());
            seconds = seconds / 1000;
            MessageBox.Show( "Seconds = " + seconds.ToString());
 
        }

Open in new window

0
 

Author Comment

by:gvector1
ID: 20801148
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
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…
Suggested Courses
Course of the Month7 days, 2 hours left to enroll

592 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question