找不到PInvoke DLL错误

时间:2014-08-29 02:39:34

标签: c# windows-ce rfid

我尝试使用进度条参考MC3190Z中的Locate Tag,并希望一起显示进度条值的变化。现在只使用摩托罗拉示例代码播放声音。但声音只有一声嘟嘟声。

m_LocateForm.Locate_PB.Value = tagDataArray[nIndex].LocationInfo.RelativeDistance; 

m_LocateForm.lastLocatedTagTimeStamp = System.Environment.TickCount; 

if (m_LocateForm.Locate_PB.Value >0) 
{ if (m_isBeepingEnabled) MessageBeep(MB_OK); }

想要使Tag更接近,所以进度条值很高,声音应该像快速的哔哔声。因此,如果标签很远,则进度条很低,声音只是缓慢发出声音。

为了显示声音的变化,我需要放两种声音吗?

目前我的代码是

[DllImport("coredll.dll")]
internal static extern bool Beep(uint dwFreq, uint dwDuration);

if (m_isBeepingEnabled)
Beep(Convert.ToUInt32(m_LocateForm.Locate_PB.Value), 150);

但它显示错误找不到PInvoke DLL

1 个答案:

答案 0 :(得分:0)

Beep isn't supported on Windows CE您可能需要尝试PlaySound

[DllImport("coredll.dll")]
public static extern int PlaySound(
            string szSound,
            IntPtr hModule,
            int flags);

以下为flags

的定义
public enum PlaySoundFlags : uint {
    SND_SYNC = 0x0,            // play synchronously (default)
    SND_ASYNC = 0x1,            // play asynchronously
    SND_NODEFAULT = 0x2,        // silence (!default) if sound not found
    SND_MEMORY = 0x4,            // pszSound points to a memory file
    SND_LOOP = 0x8,            // loop the sound until next sndPlaySound
    SND_NOSTOP = 0x10,            // don't stop any currently playing sound
    SND_NOWAIT = 0x2000,        // don't wait if the driver is busy
    SND_ALIAS = 0x10000,        // name is a registry alias
    SND_ALIAS_ID = 0x110000,        // alias is a predefined ID
    SND_FILENAME = 0x20000,        // name is file name
    SND_RESOURCE = 0x40004,        // name is resource name or atom
};