[DllImport("Kernel32", CharSet = CharSet.Auto)]
static extern Int32 GetShortPathName(String path, StringBuilder shortPath, Int32 shortPathLength);
[DllImport("winmm.dll")]
public static extern int mciSendString(string m_strCmd, StringBuilder m_strReceive, int m_v1, int m_v2);
/// <summary>
/// 得到播放时间,这个地方有点难,我研究了半天,呵呵!
/// </summary>
/// <param name="filePath">文件路径</param>
/// <returns></returns>
private string getasfTime(string filePath)
{
StringBuilder shortpath = new StringBuilder(80);
GetShortPathName(filePath, shortpath, shortpath.Capacity);
string name = shortpath.ToString();
StringBuilder buf = new StringBuilder(80);
mciSendString("close all", buf, buf.Capacity, 0);
mciSendString("open " + name + " alias media", buf, buf.Capacity, 0);
mciSendString("status media length", buf, buf.Capacity, 0);
TimeSpan ts = new TimeSpan(0, 0, 0, 0, (int)Convert.ToDouble(buf.ToString().Trim()));
return ts.ToString();
}