Download MetaTrader 5

Play external Sound File

To add comments, please log in or register
sunshineh
1249
sunshineh  

Hi,

the function PlaySound(...) plays the soundfile that must be located in terminal_directory\Sounds or its sub-directory.

How can I play a sound file from the C:\Windows\Media path?

whroeder1
15709
whroeder1  
  1. You can't from mql4. You'd have to shell the file
  2. Disk space is cheap, just copy the file. Or make a hard link to it: fsutil hardlink create soundsDirectory existingFile
Fernando Carreiro
2319
Fernando Carreiro  

I can think of two possibilities:

  • Either, use a DLL call to the WinAPI for that
  • or add a Junction Point to the "terminal_directory\Sounds" to point to other media folders.
JC
1499
JC  
sunshineh:

Hi,

the function PlaySound(...) plays the soundfile that must be located in terminal_directory\Sounds or its sub-directory.

How can I play a sound file from the C:\Windows\Media path?

An adaptation of https://www.mql5.com/en/forum/148934:

#import "winmm.dll"
   int PlaySoundW(string, int, int);
#import

void OnStart()
{
   PlaySoundW("c:\\windows\\media\\chimes.wav", 0, 1 /* SND_ASYNC */);
}
sunshineh
1249
sunshineh  

Great!!!

Thank you very much!

To add comments, please log in or register