3 Replies Latest reply on Nov 11, 2014 9:29 PM by Wei He

    Can't find PInvoke DLL error in Windows Mobile

    Wei He

      Hi, I try reference Locate Tag in MC3190Z by using progress bar and want to show the vary of progress bar value with the sound together. Now only using Motorola sample code to play the sound. But the sound only one beep.

       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); }

      Want to make it like if Tag is closer, so progress bar value is high and the sound should be like fast beeping. And so with the tag is far, then progress bar is low and sound just beep slowly.

      Is it I need to put two type of sound in order to show the vary of sound?

       

      Currently my code is

       

      [DllImport("coredll.dll")]

      internal static extern bool Beep(uint dwFreq, uint dwDuration);

       

      if (m_isBeepingEnabled)

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

       

      but it shows error Can't find PInvoke DLL

        • Re: Can't find PInvoke DLL error in Windows Mobile

          Hi Wei:

          We are looking at this and will get back shortly.

          Prashant

          • Re: Can't find PInvoke DLL error in Windows Mobile

            Hello Wei:

             

            Are you running this code in the UI thread and still facing the problem ?

            Here is a code snippet. Let me know if this helps. If not, we can provide you with a sample project.

             

            [DllImport("coredll.dll")]
                    public static extern bool MessageBeep(BeepTypes beepType);
                    ///////////////////////////////////////////////////////////////////
                    public enum BeepTypes : uint
                    {
                        SimpleBeep = 0xffffffff,
                        IconAsterisk = 0x00000040,
                        IconExclamation = 0x00000030,
                        IconHand = 0x00000010,
                        IconQuestion = 0x00000020,
                        Ok = 0x00000000
                    };

                        this.RunInUIThread(() =>
                        {
                            for (int i = 0; i < 3; i++)
                            {
                                MessageBeep(BeepTypes.IconExclamation);
                                Thread.Sleep(500);
                            }
                            this.btAuto.Enabled = true;
                            this.bt_abort.Enabled = false;
                        });

            //////////////////////////////////////////////
            namespace MotorolaRFID.ExtensionMethods
            {
                using System;
                using System.Windows.Forms;

                public static class ControlExtensionMethods
                {
                    // example: this.RunInUIThread(() => this.progressBar1.Value = 0);
                    public static void RunInUIThread(this Control control, Action action)
                    {
                        if (control.InvokeRequired)
                        {
                            System.Threading.ThreadStart method = () => RunInUIThread(control, action);
                            control.BeginInvoke(method);
                        }
                        else
                        {
                            action();
                        }
                    }
                }
            }

             

            -Prashant