Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

C# and activating sound files

zebradayzebraday Posts: 1Member
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

  • iwilld0itiwilld0it Posts: 1,134Member
    : 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.