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. environmental variables?

environmental variables?

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
3 Posts 3 Posters 1 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.
  • R Offline
    R Offline
    rolfhorror
    wrote on last edited by
    #1

    whats the best way to get environmental variables like %windir% %userprofile% and so on? i've tried the above but vc++ 6.0 dont recognize them when for instance doing something like this: CString MyVar; MyVar = "%windir"; MessageBox(MyVar,"titletext"); ..returns "%windir%" in the messagebox not "C:" there may be a simple solution but i cant find it. anyone? thanx!

    S W 2 Replies Last reply
    0
    • R rolfhorror

      whats the best way to get environmental variables like %windir% %userprofile% and so on? i've tried the above but vc++ 6.0 dont recognize them when for instance doing something like this: CString MyVar; MyVar = "%windir"; MessageBox(MyVar,"titletext"); ..returns "%windir%" in the messagebox not "C:" there may be a simple solution but i cant find it. anyone? thanx!

      S Offline
      S Offline
      Sceptic Mole
      wrote on last edited by
      #2

      hobbyprogrammer wrote:

      whats the best way to get environmental variables like %windir% %userprofile% and so on?

      Try GetEnvironmentVariable (VC++) or getenv (C++)

      1 Reply Last reply
      0
      • R rolfhorror

        whats the best way to get environmental variables like %windir% %userprofile% and so on? i've tried the above but vc++ 6.0 dont recognize them when for instance doing something like this: CString MyVar; MyVar = "%windir"; MessageBox(MyVar,"titletext"); ..returns "%windir%" in the messagebox not "C:" there may be a simple solution but i cant find it. anyone? thanx!

        W Offline
        W Offline
        Waldermort
        wrote on last edited by
        #3

        You need to convert the %***% to a real path before you can use it as a path. Try ExpandEnvironmentStrings()

        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