How to Play a Sound File with Dexterity

Dave Duesk - Click for blog homepageThis is a reposting of an article Dave Duesk originally wrote on my Developing for Dynamics GP blog.

This 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

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:backupdexwelcome.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,

This article was originally posted on the Developing for Dynamics GP Blog and has been reposted on

6 thoughts on “How to Play a Sound File with Dexterity

  1. Hi Nilotpal
    When using the extern statement to call a win32 dll, there is no need to register/unregister it.
    Thanks to Pat for this info.


  2. Thanks,
    but i wrote the DLL in Visual basic 2005, and not able to call it. Please refer to my post “calling dll from dexterity”.


  3. You cannot create a Win32 assembly using vb 2005 so that is why it doesn’t work.  That is only possible from C/C++.  
    From .net, you would have to create your assembly so that it is COM interop enabled.  Then you’d use normal COM method calls from Dexterity to call those methods.
    That should get you going.  If you have any further questions please open a support incident or post to the newsgroups.
    dev support


Please post feedback or comments

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.