CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Command line issues.

  1. #1
    Join Date
    Oct 2001
    Posts
    80

    Command line issues.

    Hi,


    We use a third party software that passes a parameter to our MFC application. Unfortunatly, the third party software is crap and passes as first parameter something like this:

    "files\companyName\progName"


    resulting in an errormassage:

    "c:\TheDirectoryOfMyProgram\files\companyName\progName is an invalid path"

    and this happends even before the first line of code I have written in the View.


    Anyone know how to fix this? Why can't MFC handle a bad directory as first parameter?

    Any help would be greatly appreciated!

  2. #2
    Join Date
    May 2000
    Location
    Washington DC, USA
    Posts
    715

    Re: Command line issues.

    Why can't MFC handle a bad directory as first parameter?
    The first parameter passed into a program is the path and file name of the program being run. That's argc[0]. So the problem might not be a bad parameter being passed into your program, the problem might be that the OS is being told to run your program from a directory which doesn't exist.

    Anyone know how to fix this?
    have you tried creating the subdirectory structure which it is asking for? If that doesn't work try actually running your program from that subdirectory directory.

    Questions for you,
    (1)How are you calling this program to be run?
    (2)How do you know "this happends even before the first line of code"?

  3. #3
    Join Date
    May 2005
    Posts
    4,954

    Re: Command line issues.

    one more thing, sometimes it required to call path like this one will double quotes means:
    ""c:\TheDirectoryOfMyProgram\files\companyName\progName""
    and not
    "c:\TheDirectoryOfMyProgram\files\ companyName\progName"
    cause it can cut the path at the first blank.

    so to be on the safe side always concat \" in the begining and the end of the path you passing.
    so it could be the bug, but if i understood correctly you cant change it cause you are already getting the crappy string right?

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  4. #4
    Join Date
    Jan 2002
    Location
    Houston, TX
    Posts
    1,421

    Re: Command line issues.

    An example command line you could be seeing is
    Code:
    c:\program files\companyname\progname
    However, since it's not enclosed in quotes, is may well be parsed at the space - into two sections:
    Code:
    c:\program
    and
    Code:
    files\companyname\progname
    Not sure of a clean way to handle it, but that's probably what's happening. It sounds like the third party app isn't able to handle a space in the path for the app name.

    Hope that at least might give you a clue.

    Good luck.
    Be sure to rate those who help!
    -------------------------------------------------------------
    Karl - WK5M
    PP-ASEL-IA (N43CS)
    PGP Key: 0xDB02E193
    PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)