-
Now this seems really strange to me, but maybe one of you out there will know what the reason for this is.
I've copied some code to get a midi file playing when my splash screen loads. I wanted to use a midi file I had put in the subfolder of c:\Program Files where the rest of my project resides. The thing just would not play so just as I was about to give up on having music with my splash screen, I tried copying the file to the desktop, switched the file path to the desktop file and voila! I had sound!!! I really don't understand how a midi file could work off the desktop but not in the same folder that the rest of my project resides.
I don't want people to install this program and have a midi file added to their desktop, so I tried stashing it in the \Windows\Media and it works from there, too. I know, if it ain't broke, don't fix it, but I'm totally perplexed as to why it seems I can only get my midi to play when the file is in a subfolder of \Windows.
Does any of this sound familiar to anyone?
If it helps, here's the code that relates to midi:
In the main module:
Code:
Option Explicit
Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
(ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
In the splash screen general:
Code:
Public Sub sndPlayM(Filename As String)
Call mciSendString("Open " & Filename & " Alias MM", 0, 0, 0)
Call mciSendString("Play MM", 0, 0, 0)
End Sub
The splash screen form load:
Code:
Private Sub Form_Load()
sndPlayM "C:\Windows\Media\Hall.mid"
It works like this, but why the heck wouldn't it work when I had sndPlayM pointing to "C:\Program Files\Pest\Hall.mid"?????
-
Try calling the function with
Code:
sndPlayM chr(34) & "C:\Program Files\Pest\Hall.mid" & chr(34)
The path contains a space, so that may be the problem.
//Anders
-
Like magic!
Wow, I have no idea why that worked, but it did! Not that I doubted you, but I really didn't think adding those chr$(34) was going to work. Well, I guess that means I did doubt you, but I was very happily surprised when my little tune came thumping through the speakers!
The "Program Files" part of the path contains a space, but why does that make it necessary to add the chr$(34)'s to the beginning and the end of the file's path name?
Thanks a bunch!
[Edited by mikeycorn on 07-18-2000 at 12:43 AM]
-
I'm not sure why it's neccesary, but it's the same thing when you make a link in explorer. If there is a space in the path or filename, it adds the " thingies. I would imagine that if you tried to execute a program via the run option for example, anything after the space could be considered a parameter to whaterever is before it... if you get what I mean.
//Anders