Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Parsing Paths

Parsing Paths

Scheduled Pinned Locked Moved C / C++ / MFC
adobec++comjsonhelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Monty2
    wrote on last edited by
    #1

    Suppose i have a string like

    CString csPath = "c:\\windows\\test.exe -parm1"
    or
    CString csPath = "c:\\windows\\test.exe /parm1"

    now to test whether test.exe exists or not i can't just use csPath and call GetFileAttributes that will fail because of the commandline arguments i will have to extract the application path from the full command line which will be tedious(the examples above are easy but there are more complex ones like: C:\WINDOWS\ISUNINST.EXE -f"C:\Program Files\Adobe\Photoshop 5.5\Uninst.isu" -c"C:\Program Files\Adobe\Photoshop 5.5\Uninst.dll") any help suggestions are welcome


    C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
    http://www.mastishk.com

    R R 2 Replies Last reply
    0
    • M Monty2

      Suppose i have a string like

      CString csPath = "c:\\windows\\test.exe -parm1"
      or
      CString csPath = "c:\\windows\\test.exe /parm1"

      now to test whether test.exe exists or not i can't just use csPath and call GetFileAttributes that will fail because of the commandline arguments i will have to extract the application path from the full command line which will be tedious(the examples above are easy but there are more complex ones like: C:\WINDOWS\ISUNINST.EXE -f"C:\Program Files\Adobe\Photoshop 5.5\Uninst.isu" -c"C:\Program Files\Adobe\Photoshop 5.5\Uninst.dll") any help suggestions are welcome


      C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
      http://www.mastishk.com

      R Offline
      R Offline
      Ryan Binns
      wrote on last edited by
      #2

      PathRemoveArgs() should help :)

      Ryan

      "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

      1 Reply Last reply
      0
      • M Monty2

        Suppose i have a string like

        CString csPath = "c:\\windows\\test.exe -parm1"
        or
        CString csPath = "c:\\windows\\test.exe /parm1"

        now to test whether test.exe exists or not i can't just use csPath and call GetFileAttributes that will fail because of the commandline arguments i will have to extract the application path from the full command line which will be tedious(the examples above are easy but there are more complex ones like: C:\WINDOWS\ISUNINST.EXE -f"C:\Program Files\Adobe\Photoshop 5.5\Uninst.isu" -c"C:\Program Files\Adobe\Photoshop 5.5\Uninst.dll") any help suggestions are welcome


        C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
        http://www.mastishk.com

        R Offline
        R Offline
        Rory Solley
        wrote on last edited by
        #3

        Why not use: TCHAR szDrive[_MAX_DRIVE]; TCHAR szDir[_MAX_DIR]; TCHAR szFname[_MAX_FNAME]; TCHAR szExt[_MAX_EXT]; ::_tsplitpath(csPath, szDrive, szDir, szFname, szExt); Then, just check to see if you have the filename and extension in szFname and szExt.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups