Public Class SoundDevice
    Public sSpeaker As String
    Public sMic As String
    Private Sub SoundDevice_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim renderDevice As String
        Dim captureDevice As String

        renderDevice = sSpeaker
        captureDevice = sMic

        Try
            For i As Integer = 0 To GTAPIASM.GTAPIEnv.GetRenderDeviceCount() - 1
                cbSpeakers.Items.Add(GTAPIASM.GTAPIEnv.GetRenderDeviceName(i))

                If renderDevice.Length > 0 AndAlso GTAPIASM.GTAPIEnv.GetRenderDeviceName(i).IndexOf(renderDevice) >= 0 Then
                    cbSpeakers.SelectedIndex = i
                Else
                    If renderDevice.Length = 0 Then
                        If GTAPIASM.GTAPIEnv.IsRenderDevicePrimary(i) Then
                            cbSpeakers.SelectedIndex = i
                        End If
                    End If
                End If
            Next


            For i As Integer = 0 To GTAPIASM.GTAPIEnv.GetCaptureDeviceCount() - 1
                cbMics.Items.Add(GTAPIASM.GTAPIEnv.GetCaptureDeviceName(i))

                If captureDevice.Length > 0 AndAlso GTAPIASM.GTAPIEnv.GetCaptureDeviceName(i).IndexOf(captureDevice) >= 0 Then
                    cbMics.SelectedIndex = i
                Else
                    If captureDevice.Length = 0 Then
                        If GTAPIASM.GTAPIEnv.IsCaptureDevicePrimary(i) Then
                            cbMics.SelectedIndex = i
                        End If
                    End If
                End If

            Next
        Catch ex As Exception
        End Try
    End Sub


    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        sSpeaker = cbSpeakers.Text
        sMic = cbMics.Text
        DialogResult = DialogResult.OK
        Close()
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        DialogResult = DialogResult.Cancel
        Close()
    End Sub
End Class