CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2007
    Posts
    7

    problem with the spacing in the path

    The code bellow executes well:

    C:\mplayer\mencoder.exe -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames " & C:\mplayer\Max.mpg & " -o " & C:\mplayer\Max.flv & " -of lavf -ovc lavc -oac lavc -lavcopts vcodec=flv:vbitrate=500:autoaspect:mbd=2:mv0:trell:v4mv:cbp:last_pred=3redia=2ia=2recmp=2:cmp=2:subcmp=2reme=2:turbo:acodec=mp3:abitrate=56 -srate 22050 -af lavcresample=22050


    However the code bellow does not get executed:

    C:\Documents and Settings\Eugene\Desktop\mplayer\mencoder.exe -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames " & C:\Documents and Settings\Eugene\Desktop\mplayer\Max.mpg & " -o " & C:\Documents and Settings\Eugene\Desktop\mplayer\Max.flv & " -of lavf -ovc lavc -oac lavc -lavcopts vcodec=flv:vbitrate=500:autoaspect:mbd=2:mv0:trell:v4mv:cbp:last_pred=3redia=2ia=2recmp=2:cmp=2:subcmp=2reme=2:turbo:acodec=mp3:abitrate=56 -srate 22050 -af lavcresample=22050


    I believe its because of the spacing or gap in the path such as

    "Documents and Settings"


    How is it solved?.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: problem with the spacing in the path

    You can use an API to get the old short filename, and then use it.
    Code:
    Option Explicit
    Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
    Public Function GetShortPath(strFileName As String) As String
    	'KPD-Team 1999
    	'URL: http://www.allapi.net/
    	'E-Mail: [email protected]
    	Dim lngRes As Long, strPath As String
    	'Create a buffer
    	strPath = String$(165, 0)
    	'retrieve the short pathname
    	lngRes = GetShortPathName(strFileName, strPath, 164)
    	'remove all unnecessary chr$(0)'s
    	GetShortPath = Left$(strPath, lngRes)
    End Function
    
    Private Sub Command1_Click()
    	Dim shortfilename As String
    	shortfilename = GetShortPath(Dir1.Path & "\" & File1.FileName)
    	MsgBox (shortfilename)
    End Sub
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Aug 2006
    Posts
    145

    Re: problem with the spacing in the path

    wrap command line arguments with spaces in them in quotes, e.g.:
    Code:
    Shell "program.exe ""C:\Test Folder\File.ext"""

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured