Dim rt As Long
'Get the path name
AppPath=App. Path
If Right $(AppPath, 1) & lt;> "" Then
AppPath=AppPath & amp; ""
End the If
"' the Allocate space for short path name
ShortPathName=Space $(255)
'Get the short path name since MCI only accepts those
GetShortPathName AppPath ShortPathName, Len (ShortPathName)
"Remove the empty Spaces and the trailing NULL character
ShortPathName=Left $(ShortPathName, Len (Trim $(ShortPathName)) - 1)
'Build the command string
CommandString="OPEN" & amp; ShortPathName & amp; FileName & amp; "TYPE WAVEAUDIO ALIAS" & amp; Alias
'Open the sound
Rt=McISendString (CommandString, 0 & amp; , 0, 0)
If rt & lt;> 0 Then 'Non 0=error
Errorstring=Space $(255)
McIGetErrorstring rt, Errorstring, Len (Errorstring
MsgBox "Error:" & amp; Errorstring
End the If
End Sub
Public Sub StopSounds ()
McISendString "STOP" & amp; MouseOverMCI, 0 & amp; , 0, 0
McISendString "STOP" & amp; MouseUpMCI, 0 & amp; , 0, 0
McISendString "STOP" & amp; MousePressMCI, 0 & amp; , 0, 0
End Sub
'* * * * * * * * * *===================
CodePudding user response:
May be the last call MCI interface has not been completed and is busy, unable to respond to play instruction.Try play audio using PlaySound function, efficiency than to the high number of calls to MCI interface, but the disadvantage is that only play WAV files (seemingly).
But because can play audio memory, so in terms of integrated comparative advantage, can will play sound effects into WAV put them in a resource file, application starts read a byte array, can play, don't need the existence of the entities file
CodePudding user response:
After changing the current Path, remember to return the current Path in front of the exit process to App. The Path, if you have a DLL function is declared with relative address:ChDir App. The Path