For some reasons, I want to play a system sound which is named "EmptyRecycleBin" in my program when a file has been deleted.
So I wrote these code:
Code1
[DllImport("winmm.dll", EntryPoint = "sndPlaySound")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern Boolean SndPlaySound(String pszSound, Int32 fuSound);
private const Int32 SND_SYSTEM = 0x00200000;
SndPlaySound("EmptyRecycleBin", SND_SYSTEM ); //The sound that was played is wrong, but I don't know why……
sndPlaySound function executes successfully, but unfortunately, the sound that was played is "Beep".
According to @AlexK. 's explain, sndPlaySound function can't identify the alias "EmptyRecycleBin".
In this case, I have to do this in another way:
Code2
var sound = new SoundPlayer(Registry.CurrentUser.OpenSubKey(@"AppEvents\Schemes\Apps\Explorer\EmptyRecycleBin\.Current", false).GetValue(null) as String);
sound.PlaySync();
It's all ok, but I still want to know that if it's possible to make Code1 work by using any other alias?
My system is windows 10, any help would be appreciated.