如何在Windows CE 6.0 R3上P / Invoke WaveOut API

时间:2013-01-12 15:45:29

标签: audio pinvoke windows-ce waveout waveoutwrite

如何在Windows CE 6.0 R3上调用/调用WaveOut API?

当我把这个

[DllImport("winmm.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern MMRESULT waveOutOpen(ref IntPtr hWaveOut, int uDeviceID, ref WAVEFORMATEX lpFormat, DelegateWaveOutProc dwCallBack, int dwInstance, int dwFlags);

[DllImport("winmm.dll")]
public static extern MMRESULT waveInOpen(ref IntPtr hWaveIn, int deviceId, ref WAVEFORMATEX wfx, DelegateWaveInProc dwCallBack, int dwInstance, int dwFlags);

[DllImport("winmm.dll", SetLastError = true)]
public static extern MMRESULT waveInStart(IntPtr hWaveIn);

[DllImport("winmm.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern uint waveInGetDevCaps(int index, ref WAVEINCAPS pwic, int cbwic);

[DllImport("winmm.dll", SetLastError = true)]
public static extern uint waveInGetNumDevs();

[DllImport("winmm.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern uint waveOutGetDevCaps(int index, ref WAVEOUTCAPS pwoc, int cbwoc);

[DllImport("winmm.dll", SetLastError = true)]
public static extern uint waveOutGetNumDevs();

[DllImport("winmm.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern MMRESULT waveOutWrite(IntPtr hWaveOut, ref WAVEHDR pwh, int cbwh);

[DllImport("winmm.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern MMRESULT waveOutPrepareHeader(IntPtr hWaveOut, ref WAVEHDR lpWaveOutHdr, int uSize);

它适用于Window XP,7但会抛出一条消息"不能P / Invoke winmm.dll"在Wnidows CE 6.0上。

我做错了什么? WaveOut API是移动到其他dll还是其他内容?

无论如何,SoundPlayer(来自.NET Compact Framework 3.5)可以正常工作。

1 个答案:

答案 0 :(得分:0)

将winmm.dll更改为coredll.dll,您就完成了!