How to Play a Sound File with Dexterity

Dave DusekThis is really an extension of the blog article that David Musgrave wrote VBA - Welcome to Dynamics Example, but instead of using VBA to play the sound file, we are using Dexterity. The same method is called in the winmm.dll, but this is just the Dexterity way to do it. I didn't include trigger information on this because you could really put this anywhere.

I am playing the Welcome.wav, but you could play any wav file with this.  This came up in a recent support incident, so that's why I'm posting this info.    

First, you need to create a Dexterity prototype procedure.  Here is what that would look like.  The name is important and must be PlaySound@winmm.dll.

PlaySound@winmm.dll Global Procedure

 {PlaySound@winmm.dll}
out long return_value; 
in string lsoundfile;
in long hModule;
in long dwFlags;

Now, you just need to call the method via the extern command.  Here is what your calling script would look like:

Example Calling Script

 local string lpath;
local long hModule;
local long dwFlags;
local long result;

lpath = "c:\backup\dex\welcome.wav";
hModule = 1;
dwFlags = 1;

extern 'PlaySound@winmm.dll',result, lpath, hModule,dwFlags;

Dave Dusek
Dynamics GP Developer Support

// Copyright © Microsoft Corporation. All Rights Reserved.
// This code released under the terms of the
// Microsoft Public License (MS-PL, https://opensource.org/licenses/ms-pl.html.)