我是vs.net 2005
用这个播放声音,可是总显示:
"无法加载 DLL“winmm.dll”: 找不到指定的程序。 (异常来自 HRESULT:0x8007007F)。"using System;
using System.Text;
using System.Runtime.InteropServices;namespace FontGame
{
/**/
/// <summary>
///
/// </summary>
public class sound
{
[DllImport("winmm.dll")]
private 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
); public sound()
{ } public void Play(string FileName)
{
StringBuilder shortPathTemp = new StringBuilder(255);
int result = GetShortPathName(FileName, shortPathTemp, shortPathTemp.Capacity);
string ShortPath = shortPathTemp.ToString(); mciSendString("open " + ShortPath + " alias song", "", 0, 0);
mciSendString("play song", "", 0, 0);
} public void Stop()
{
mciSendString("stop song", "", 0, 0);
} public void Pause()
{
mciSendString("pause song", "", 0, 0);
} public void Close()
{
mciSendString("close song", "", 0, 0);
}
}
}哪位大虾是知道怎么回事,感激不尽。
用这个播放声音,可是总显示:
"无法加载 DLL“winmm.dll”: 找不到指定的程序。 (异常来自 HRESULT:0x8007007F)。"using System;
using System.Text;
using System.Runtime.InteropServices;namespace FontGame
{
/**/
/// <summary>
///
/// </summary>
public class sound
{
[DllImport("winmm.dll")]
private 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
); public sound()
{ } public void Play(string FileName)
{
StringBuilder shortPathTemp = new StringBuilder(255);
int result = GetShortPathName(FileName, shortPathTemp, shortPathTemp.Capacity);
string ShortPath = shortPathTemp.ToString(); mciSendString("open " + ShortPath + " alias song", "", 0, 0);
mciSendString("play song", "", 0, 0);
} public void Stop()
{
mciSendString("stop song", "", 0, 0);
} public void Pause()
{
mciSendString("pause song", "", 0, 0);
} public void Close()
{
mciSendString("close song", "", 0, 0);
}
}
}哪位大虾是知道怎么回事,感激不尽。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货