A Couple of Winmm API Calls

By | 2002-06-01

There are 2 API Calls to the Winnmm API. One Detects if a Sound Card is installed. The other Plays an .AVI. You need to have Windows Media Player installed.

Original Author: Charles Davis

Assumptions

This code is very simple and pretty self explanatory.

Side Effects

As far as I know there are none.

API Declarations

‘For SoundCard Function
Private Declare Function waveOutGetNumDevs Lib “winmm.dll” () As Long
‘To Play Avi
Private Declare Function mciSendString Lib “winmm.dll” Alias _
“mciSendStringA” (ByVal lpstrCommand As String, _
ByVal lpstrReturnString As Any, ByVal uReturnLength As Long, _
ByVal hwndCallback As Long) As Long

Code

Public Function SoundCard() As Boolean
Dim lng As Long
lng = waveOutGetNumDevs()

If lng > 0 Then
  SoundCard = True
  Exit Function
Else
   SoundCard = False
   Exit Function
End If
End Function
Public Sub PlayAvi()
Dim strAviPath As String
Dim strCmdStr As String
Dim lngReturnVal As Long
strAviPath = "C:winntclock.avi"
strCmdStr = "play " & strAviPath & " fullscreen "
lngReturnVal = mciSendString(strCmdStr, 0&, 0, 0&)
End Sub

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.