2013-10-27
展开全部
[DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)]
public static extern int mciSendString(
string lpstrCommand,
string lpstrReturnString,
int uReturnLength,
int hwndCallback
);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName(
//[MarshalAs(UnmanagedType.LPTStr)]
string path,
//[MarshalAs(UnmanagedType.LPTStr)]
StringBuilder shortPath,
int shortPathLength);
private void button1_Click(object sender, EventArgs e)
{
StringBuilder shortPath = new StringBuilder(80);
openFileDialog1.ShowDialog();
if (openFileDialog1.FileName != string.Empty)
{
GetShortPathName(openFileDialog1.FileName, shortPath, shortPath.Capacity); //取得短路径(DOC路径格式)
//MessageBox.Show(shortPath.ToString());
mciSendString("close all", null, 0, 0); //关闭设备
mciSendString("open " + shortPath.ToString() + " alias MyMp3", null, 0, 0); //打开音乐文件
mciSendString("play MyMp3", null, 0, 0); //播放音乐
}
}
public static extern int mciSendString(
string lpstrCommand,
string lpstrReturnString,
int uReturnLength,
int hwndCallback
);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName(
//[MarshalAs(UnmanagedType.LPTStr)]
string path,
//[MarshalAs(UnmanagedType.LPTStr)]
StringBuilder shortPath,
int shortPathLength);
private void button1_Click(object sender, EventArgs e)
{
StringBuilder shortPath = new StringBuilder(80);
openFileDialog1.ShowDialog();
if (openFileDialog1.FileName != string.Empty)
{
GetShortPathName(openFileDialog1.FileName, shortPath, shortPath.Capacity); //取得短路径(DOC路径格式)
//MessageBox.Show(shortPath.ToString());
mciSendString("close all", null, 0, 0); //关闭设备
mciSendString("open " + shortPath.ToString() + " alias MyMp3", null, 0, 0); //打开音乐文件
mciSendString("play MyMp3", null, 0, 0); //播放音乐
}
}
2013-10-27
展开全部
win32的api
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询