Dennis:
I've used this a fair amount on both the Desktop and Pocket PC and haven't
noticed any performance degradation.
Mine implementation is slightly different, but I don't think that's the
cause---I had just read that you should use constants instead...
Define two constants...
public const int SND_FILENAME = 0x00020000;
public const int SND_ASYNC = 0x0001;
Define PlaySOund ass
public static extern bool PlaySound(string pszSound, int hmod, int
fdwSound);
then the call would be PlaySound("Windows XP Exclamation.wav",
SND_FILENAME|SND_ASYNC);
See if this doesn't make a difference.
BTW, I got the code originally from John Paul Mueller's .NET Framework
Solutions....I don't want to take credit for his stuff. He does mention
that you should use the COnstants, so maybe that's a possible issue.
Not sure...but maybe this helps.
Cheers,
BIll
"Dennis C. Drumm" <de*******@primacode.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Using the Win API to play a sound with the code below in my Windows Form
application. I get a huge delay (seems like application is hanging) just
prior to the sound being played each time. Is this something to do with
unmanaged code? Is there any way to fix the delay and speed the process
up?
Thanks,
Dennis
using System.Runtime.InteropServices;
[DllImport("winmm.dll")]
public static extern int sndPlaySound(string lpszSoundName, int uFlags);
sndPlaySound("Windows XP Exclamation.wav", 0x001);