C# and activating sound files

How do I activate a Win OS sound programatically? Example, the sound that occurs when a warning popup window is displayed like a bell, or a beep, or something. I know how to activate windows media player, but that's only good for the machine the program is written on. I also work on an XP machine.

Comments

  • : How do I activate a Win OS sound programatically? Example, the sound that occurs when a warning popup window is displayed like a bell, or a beep, or something. I know how to activate windows media player, but that's only good for the machine the program is written on. I also work on an XP machine.
    :

    Add this external function declaration to your code module ...

    [code]
    [DllImport("winmm.dll")]
    public static extern long PlaySound(
    String lpszName,
    long hModule,
    long dwFlags);
    [/code]

    Here is an example of how to use it ...

    [code]
    PlaySound("mySound.wav" , 0 , 0);
    [/code]

    To see a description of this API function go to ...

    http://www.mentalis.org/apilist/PlaySound.shtml

    Note that this is a VB based site, but the description of function arguments and return values, will still pertain to C# or almost any language for that matter.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion