【问题标题】:Can't find PInvoke DLL error找不到 PInvoke DLL 错误
【发布时间】:2014-10-29 17:08:03
【问题描述】:

我尝试通过使用进度条来参考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

【问题讨论】:

    标签: c# windows-ce rfid


    【解决方案1】:

    Beep isn't supported on Windows CE你可能不得不尝试PlaySound

    [DllImport("coredll.dll")]
    public static extern int PlaySound(
                string szSound,
                IntPtr hModule,
                int 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
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-30
      • 2012-07-25
      • 2018-07-22
      • 2012-03-13
      • 2014-04-26
      • 1970-01-01
      • 1970-01-01
      • 2017-09-21
      相关资源
      最近更新 更多