Re: PlaySound

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: John Carson (donaldquixote_at_datafast.net.au)
Date: 01/01/05


Date: Sat, 1 Jan 2005 20:10:09 +1100


"George Hester" <hesterloli@hotmail.com> wrote in message
news:%23pMJ3W77EHA.1400@TK2MSFTNGP11.phx.gbl
> Here is a snippit of the "window proc":
>
> case WM_CREATE:
> PlaySound("Start Windows", NULL, SND_ALIAS | SND_ASYNC);
> return 0;
>
> Why isn't this working? Windows 2000 SP2 VC++6. If I do this:
>
> case WM_CREATE:
> PlaySound("hc_defau.wav", NULL, SND_FILENAME | SND_ASYNC);
> return 0;
>
> then there is no issue.
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_playsound.asp
>
> Thanks.
> --
> George Hester
> _________________________________

If I run your code, GetLastError returns "The system cannot find the file
specified".

You appear to be assuming that the list of sounds in the Control Panel
Sounds applet corresponds to the list of names that will work with
SND_ALIAS. Not so.

Under XP (and I assume it is the same under Win2000), there is a list of
aliases under

HKEY_CURRENT_USER\AppEvents\EventLabels

One of the keys is called SystemStart. Under that key is listed the name
"Start Windows". You need to use the name of the key itself rather than the
string stored under the key. Thus

PlaySound("SystemStart", NULL, SND_ALIAS | SND_ASYNC);

should work.

-- 
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead) 


Relevant Pages