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. GetCommandLine

GetCommandLine

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
3 Posts 2 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.
  • T Offline
    T Offline
    Toni78
    wrote on last edited by
    #1

    GetCommandLine() returns a string enclosed in quotation marks. So the first question is why? Let's call this string strCmdLine. Since I had no idea that strCmdLine was enclosed in quotations marks, I would just extract the path of the executable by adding a null character at the location of the very last '\' occurence. So if my path was "c:\\apps\\myapp\\myapp.exe" I would convert the string to "c:\\apps\\myapp\0. As you can see there is a quotation mark at the begining of the string. Calling SetCurrentDirectory() would work just fine in Windows XP but it doesn't work in Windows 98. I fixed the problem by removing the leading quotation mark but I am puzzled as why would this work in XP and not in 98? This should not work at all. I don't know if it works in other windows versions. // Afterall, I realized that even my comment lines have bugs

    D 1 Reply Last reply
    0
    • T Toni78

      GetCommandLine() returns a string enclosed in quotation marks. So the first question is why? Let's call this string strCmdLine. Since I had no idea that strCmdLine was enclosed in quotations marks, I would just extract the path of the executable by adding a null character at the location of the very last '\' occurence. So if my path was "c:\\apps\\myapp\\myapp.exe" I would convert the string to "c:\\apps\\myapp\0. As you can see there is a quotation mark at the begining of the string. Calling SetCurrentDirectory() would work just fine in Windows XP but it doesn't work in Windows 98. I fixed the problem by removing the leading quotation mark but I am puzzled as why would this work in XP and not in 98? This should not work at all. I don't know if it works in other windows versions. // Afterall, I realized that even my comment lines have bugs

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Toni78 wrote: Calling SetCurrentDirectory() would work just fine in Windows XP but it doesn't work in Windows 98. What error is returned by GetLastError()? Can you provide a code snippet?

      T 1 Reply Last reply
      0
      • D David Crow

        Toni78 wrote: Calling SetCurrentDirectory() would work just fine in Windows XP but it doesn't work in Windows 98. What error is returned by GetLastError()? Can you provide a code snippet?

        T Offline
        T Offline
        Toni78
        wrote on last edited by
        #3

        Sorry, I forgot about that, it returns error 3, path not found. // Afterall, I realized that even my comment lines have bugs

        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