title: How to get song Length with MCI
body: <p>Try ro find song duration like HH:MM:SS for showing in my program.</p>
  
  <p>Try to use </p>
  
  <pre><code>[DllImport("winmm.dll")]
      private static extern long mciSendString(string strCommand,
          StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);
  </code></pre>
  
  <p>with     </p>
  
  <pre><code>public int CurrentTime()
      {
          MPlayerCommand = "status MediaFile length track number";
          error = mciSendString(MPlayerCommand, returnData, 128, IntPtr.Zero);
          return Convert.ToInt32(returnData.ToString());
      }
  </code></pre>
  
  <p>But as result get error - "incorrect input string"</p>
  
  <p>Use for understanding <a href="http://msdn.microsoft.com/en-us/library/ms713277%28v=vs.85%29.aspx" rel="nofollow">this</a>. As I understand for getting song length need to use command <code>status MediaFile length track number</code>, where <code>status</code> - main command, <code>MediaFile</code> - tell to use current opened MediaFile, <code>length track number</code> - requested parameter. Use this method only after opening file.</p>