简体   繁体   中英

Can't find PInvoke DLL error

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

Beep isn't supported on Windows CE you will probably have to try PlaySound

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

with the following definition for 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
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM