MCI error

My app has been using this mciSendString fine until recently:

CmdStr = ("open  " & AVIFileName & " Type AVIVideo alias Animation parent " _
           + LTrim$(Str$(frmAVI.hwnd)) + " style " + LTrim$(Str$(WS_CHILD)))
   ret = mciSendString(CmdStr, 0&, 0, 0)

I am receiving this error...Why, and how can I fix this?
MMSYSTEM259 The command parameter used is not defined in the MCI command set.

Who is Participating?
SendohConnect With a Mentor Commented:
Hi !
I'd tried out your code the posted above.
Same error obtain. I suspect you copy the above code from somewhere and paste it on VB and run it right ??
It is because when I tried to retype the whole command (even a space), I'd make it work on my machine. Then I'd retried the code pasted a bove by using "copy" and "paste" it does not worked.

So :
1) make sure the file name and path are accurate.
2) make sure the command entered were correct(by adding
msgbox cmdstr 'before calling mcisendstring.
3) Don't just copied from experts-exchange homepage and paste on VB. It'll not worked.
4) Check the mci type valid in Win.ini

Hope it'll help you.
Hi !
I forgot to post my code as well !!

    Dim cmdStr As String * 100
    Dim retStr As String * 100
    cmdStr = "open c:\temp\mci\battery.avi type AVIVideo alias myavi parent " _
            & Form1.hWnd & " style " & Str(WS_CHILD)
    'cmdStr = "close all"
    'MsgBox cmdStr
    ret = mciSendString(cmdStr, 0&, 0, 0&)
    mciGetErrorString ret, retStr, 100
    MsgBox "Value = " & ret & Chr(13) & _
            "Str = " & retStr
    cmdStr = "play myavi"
    ret = mciSendString(cmdStr, 0&, 0, 0)
    mciGetErrorString ret, retStr, 100
    MsgBox "Value = " & ret & Chr(13) & _
            "Str = " & retStr

BWATERSAuthor Commented:
Ah were correct assuming there was a space in the string.  What was confusing me was the CmdStr WORKED on another machine because the avi path (AVIFileName) did not have a space in path. For example: 'c:\path\avifile.avi'.  Wheni I installed it on another machine, there was a space in the path
'c:\my path\avifile.avi".
You answered my question, thanks.  I know this might be a different question, but how would you get around a space in the path?  I want to get a response from you before I close out the question.  Thanks again.
Hi !

Ok, for this situation, you can tried follow :

cmdStr = "open c:\temp\mci\mypath~1\abc.avi type AVIVideo alias myavi parent " _
            & Picture1.hWnd & " style " & Str(WS_CHILD)

where the path name can be found when you were in dos prompt because for dos format is only 8.3. So the window actually stored the filename as what you'll see on the dos prompt.

Hope it'll help you  ^_^.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.