Windows Develop Bookmark and Share   
 index > Windows Forms General > C# how to detect whether a computer got sound device or not by code
 

C# how to detect whether a computer got sound device or not by code

Dear all,

Anybody know how to detect the sound device is existed or not?

In my application, i need to play music, if sound device got problem or do not installed, i need to prompt a message box and change the play button to grayout.

any clue?

Carrie17  Wednesday, April 09, 2008 11:34 PM

Hi,

I'm afraid this is for VB.NET hope u could convert it to C# without a problem.

But it should work.

Private Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Long
Private Sub cmdCanPlay_Click()
Dim i As Long
i = waveOutGetNumDevs()
If i > 0 Then
MsgBox "Your system can play sound files.", _
vbInformation, "Sound Card Test"
Else
MsgBox "Your system can not play sound Files.", _
vbInformation, "Sound Card Test"
End If
End Sub

Regards,

Geethanga.

Geethanga  Thursday, April 10, 2008 3:45 AM

Hi,

I'm afraid this is for VB.NET hope u could convert it to C# without a problem.

But it should work.

Private Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Long
Private Sub cmdCanPlay_Click()
Dim i As Long
i = waveOutGetNumDevs()
If i > 0 Then
MsgBox "Your system can play sound files.", _
vbInformation, "Sound Card Test"
Else
MsgBox "Your system can not play sound Files.", _
vbInformation, "Sound Card Test"
End If
End Sub

Regards,

Geethanga.

Geethanga  Thursday, April 10, 2008 3:45 AM

Thank you so much

it work wells

Carrie17  Friday, April 18, 2008 1:56 AM

You can use google to search for other answers

Custom Search

More Threads

• want to shift user-control below another user-control to reveal invisible part.
• Where are the events for a FolderBrowserDialog?
• BeginPrint not getting called!
• FolderBrowseDialog and Mapped Directories
• menu event question
• Need shapes or transparent images, can't use either
• disable window drawing
• Registry Application
• When Panel resize needs to resize the inside Button
• Circular buffered TextBox