

Important! You need to convert saves with tchernobog0.2.2atob-itemtransferonly.exe (inside release pack), before being able to play this version! I hope this is useful example to beginners.New version of the Tchernobog mod v0.2.2b has been released and added to the download section. After the file loads, the sound will play. player = new () Ħ.Now let's run the application just by Pressing the F5 to run the code.ħ.Click the button and select an audio file.

If(dialog.ShowDialog() = DialogResult.OK)ĥ.Add the following method code under the button1_Click event hander. OpenFileDialog dialog = new OpenFileDialog() ĭialog.Filter = "Audio Files (.wav)|*.wav" This code displays the File Open dialog box and passes the results to a method named "playSound" that you will create in the next step. To play an Audio file in the Windows form using C# let's check simple example as follows :ġ.Go Visual Studio(VS-2008/2010/2012) -> File Menu -> click New Project.Ģ.In the New Project -> click Windows Forms Application -> Give Name and then click OK.Ī new "Windows Forms" project will opens.ģ.Drag-and-Drop a Button control from the Toolbox to the Windows Form.Ĥ.Double-click the button to create automatically the default Click event handler, and add the following code. (How to play sounds you can see in other answers.) In your application, read sound file path or DLL resource from your registry keys and play it.Create sound profile of your application in the Windows Registry (Hint: no need of programming, just add the keys into installer of your application.).Each user profile can override these sounds in own way.This way users can easily change or remove sounds from your application and you do not need to write any user interface for this – it is already there.Implement any other sounds as customizable by your users in Sound control panel Methods of class will play them for you. Question - play with questions (system message box window plays this one)Įxclamation - play with excalamation icon (system message box window plays this one)Ĭritical stop ("Hand") - play with error (system message box window plays this one) Use five standard system sounds in typical scenarios, i.e.Īsterisk - play when you want to highlight current event Besides that, always note these two points: Technical details of playing particular sound were provided in other answers. This is a bit high-level answer for applications which want to seamlessly fit into the Windows environment.
