Tipp 0532 Soundkarten-Informationen auslesen
Autor/Einsender:
Datum:
  Detlev Schubert
30.05.2007
Entwicklungsumgebung:   VB 6
Im Bereich der Multimedia-Programmierung ist es heute unerlässlich möglichst viele Informationen über die installierte Hardware zu erfahren, um seinen Code auf den gewonnenen Informationen aufbauen zu können. Hierzu bietet WinMM-API auch die entsprechenden Möglichkeiten.
Diese Bibliothek ist allerdings so umfangreich, dass in diesem Beispiel auch nur eine Handvoll Konstanten verwendet wurde, um die in Deutschland gängigsten Soundkartenhersteller zu ermitteln zu können. Die durch die Abfrage erlangten Informationen müssen dann lediglich noch entsprechend aufbereitet werden.
 
Option Explicit

' dwFormats-Konstanten
Private Const WAVE_INVALIDFORMAT As Long = &H0&
Private Const WAVE_FORMAT_1M08 As Long = &H1&
Private Const WAVE_FORMAT_1S08 As Long = &H2&
Private Const WAVE_FORMAT_1M16 As Long = &H4&
Private Const WAVE_FORMAT_1S16 As Long = &H8&
Private Const WAVE_FORMAT_2M08 As Long = &H10&
Private Const WAVE_FORMAT_2S08 As Long = &H20&
Private Const WAVE_FORMAT_2M16 As Long = &H40&
Private Const WAVE_FORMAT_2S16 As Long = &H80&
Private Const WAVE_FORMAT_4M08 As Long = &H100&
Private Const WAVE_FORMAT_4S08 As Long = &H200&
Private Const WAVE_FORMAT_4M16 As Long = &H400&
Private Const WAVE_FORMAT_4S16 As Long = &H800&

' dwSupport-Konstanten
Private Const WAVECAPS_LRVOLUME = &H8
Private Const WAVECAPS_PITCH = &H1
Private Const WAVECAPS_PLAYBACKRATE = &H2
Private Const WAVECAPS_SYNC = &H10
Private Const WAVECAPS_SAMPLEACCURATE = &H20
Private Const WAVECAPS_VOLUME = &H4

 ' Quelle: http://msdn2.microsoft.com/en-us/library/ms713743.aspx
 ' einige HerstellerID-Konstanten
Private Const MM_MICROSOFT = 1      'Microsoft Corporation
Private Const MM_CREATIVE = 2       'Creative Labs, Inc
Private Const MM_MEDIAVISION = 3    'Media Vision, Inc.
Private Const MM_FUJITSU = 4        'Fujitsu Corp.
Private Const MM_ARTISOFT = 20      'Artisoft, Inc.
Private Const MM_IBM = 22           'IBM Corporation
Private Const MM_ROLAND = 24        'Roland
Private Const MM_NEC = 26           'NEC
Private Const MM_ATI = 27           'ATI
Private Const MM_WANGLABS = 28      'Wang Laboratories, Inc
Private Const MM_TANDY = 29         'Tandy Corporation

' weitere sind bei den angegebenen Quellen zu finden
' Quelle: http://msdn2.microsoft.com/en-us/library/ms709443.aspx
' Quelle: http://doc.ddart.net/msdn/header/include/mmreg.h.html

Private Declare Function waveOutGetNumDevs Lib _
     "winmm.dll" () As Long
Private Declare Function waveOutGetDevCaps Lib _
     "winmm.dll" Alias "waveOutGetDevCapsA" (ByVal uDeviceID _
     As Long, lpCaps As WAVEOUTCAPS, ByVal uSize As Long) As Long

Private Type WAVEOUTCAPS
   wMid As Integer
   wPid As Integer
   vDriverVersion As Long
   szPname As String * 32
   dwFormats As Long
   wChannels As Integer
   dwSupport As Long
End Type

Private Sub Combo1_Click()
  GetSoundCardInfo Combo1.ListIndex
End Sub

Private Sub Form_Load()
  Dim intX As Integer

  If waveOutGetNumDevs = 0 Then
     Combo1.Enabled = False
  Else
     Combo1.Clear
     For intX = 1 To waveOutGetNumDevs
        GetSoundCardInfo intX - 1, True
     Next
     Combo1.ListIndex = Combo1.TopIndex
  End If

  Label2.Caption = Trim$(Str$(waveOutGetNumDevs))
End Sub

Private Sub GetSoundCardInfo(Index As Integer, _
     Optional Liste As Boolean)
  Dim Produkt As WAVEOUTCAPS 'Produktinformation

  waveOutGetDevCaps Index, Produkt, Len(Produkt)

  If Liste = True Then
     Combo1.AddItem Produkt.szPname
     Exit Sub
  Else
      'Eine Beispiel-Abfrage, weitere siehe Beispielprojekt
     If CBool(Produkt.dwFormats And WAVE_FORMAT_4S16) Then
        Label10.Caption = "44.1 kHz (16 Bit), Stereo"
     End If
      'Hersteller ID
     Label4.Caption = Trim$(Str$(Produkt.wMid))
      'Produkt ID
     Label6.Caption = Trim$(Str$(Produkt.wPid))
      'Version des Wave-Treibers
     Label8.Caption = Trim$(Str$(HiByte(Produkt.vDriverVersion))) _
          & "." & Trim$(Str$(LoByte(Produkt.vDriverVersion)))
  End If
End Sub

Public Function LoByte(ByVal intInput As Integer) As Byte
  LoByte = intInput And &HFF
End Function

Public Function HiByte(ByVal intInput As Integer) As Byte
  HiByte = (intInput And &HFF00&) \ 256
End Function
 
Weitere Links zum Thema
Ist eine Soundkarte installiert ?
Rechnerdaten auslesen
Hinweis
Das Download-Beispiel ist sehr ausführlich kommentiert. Auch sollten die angegebenen Quellen  besondere Beachtung geschenkt werden.

Windows-Version
95
98
ME
NT
2000
XP
Vista
Win 7
VB-Version
VBA 5
VBA 6
VB 4/16
VB 4/32
VB 5
VB 6


Download  (4,1 kB) Downloads bisher: [ 317 ]

Vorheriger Tipp Zum Seitenanfang Nächster Tipp

Startseite | Projekte | Tutorials | API-Referenz | VB-/VBA-Tipps | Komponenten | Bücherecke | VB/VBA-Forum | VB.Net-Forum | DirectX-Forum | Foren-Archiv | DirectX | VB.Net-Tipps | Chat | Spielplatz | Links | Suchen | Stichwortverzeichnis | Feedback | Impressum

Seite empfehlen Bug-Report
Letzte Aktualisierung: Mittwoch, 25. Mai 2011