Windows Client development-Add a message tone to your client
I have previously shared how to operate the tray icon on the windows client. That is, how to control the flashing of the image disk icon.
However, I suddenly thought it was almost boring, because there was a new message, in addition to the flickering tray icon, but also with a cool tone.
Now, let's share it with you.
Some of my friends may find themselves in this way. It's not just a playsound function of NIMA. Do you want to write a blog.
Well, what I want to say is that he is right. It is a playsound function, but there are still many pitfalls in it.
Playsound
Purpose:
The PlaySound function plays a sound specified by the given file name, resource, or system event. (A system event may be associated with a sound in the registry or in the WIN. INI file .)
Syntax:
BOOL PlaySound( LPCTSTR pszSound, HMODULE hmod, DWORD fdwSound);
The parameters are also very simple.
The first is the file path, which must be. Wav files.
The second parameter is set to NULL.
Third parameter: SND_FILENAME | SND_ASYNC
Asynchronous or loop
At this time, you have been Snoop, debugging, and sound playing.
After enjoying your voice several times, you suddenly felt something was wrong.This sound is not a cool voice set by me. How is it like a system warning sound?
You will think, small case, it may be my mistake, put the wrong. Wav file. So you changed a prompt file and run it, and Nima was the sound of a system warning. Then you changed one sound and found it was a system warning sound.
You began to suspect that the video was not played successfully?
After reading this api function again, set a return value. The returned result is true, but it is not the cool tone you have prepared.
In your anger, you deleted all the prompts in the storage path you specified. Debugging, found that Nima still has sound play.
At this time, you suddenly realized that the previousThe first parameter is not correct, and the file cannot be found in the path.
From now on, do you still say that this function is not worth writing a blog? Once again, I dream about it again and look at the official api parameters. The first parameter is written as follows:
PszSound
A string that specifies the sound to play. The maximum length, including the null terminator, Which is 256 characters.If this parameter is NULL, any currently playing waveform sound is stopped. To stop a non-waveform sound, specify SND_PURGE in the fdwSound parameter.
I will not explain it.
Once again, I paid the price for my reckless behavior ~~~~