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

GetEnvironmentvariables

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionworkspace
5 Posts 4 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.
  • S Offline
    S Offline
    siva455
    wrote on last edited by
    #1

    Hi, How can i get the value of Environment variables(user variables)..thru a sample .... Please help me out....

    S 1 Reply Last reply
    0
    • S siva455

      Hi, How can i get the value of Environment variables(user variables)..thru a sample .... Please help me out....

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      TCHAR varValue[32767];
      GetEnvironmentVariable(_T("PATH"), varValue, 32767);

      varValue will (after the call) contain the path for your account.

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      P 1 Reply Last reply
      0
      • S Stuart Dootson

        TCHAR varValue[32767];
        GetEnvironmentVariable(_T("PATH"), varValue, 32767);

        varValue will (after the call) contain the path for your account.

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        P Offline
        P Offline
        p_1960
        wrote on last edited by
        #3

        Thanks for ur reply...suppose using this... TCHAR varValue[32767]; GetEnvironmentVariable(_T("TEMP"), varValue, 32767); if get the path of TEMP in varValue...how can i create a folder named "Testing" under that TEMP folder...using CreateDirectoryW()

        J S 2 Replies Last reply
        0
        • P p_1960

          Thanks for ur reply...suppose using this... TCHAR varValue[32767]; GetEnvironmentVariable(_T("TEMP"), varValue, 32767); if get the path of TEMP in varValue...how can i create a folder named "Testing" under that TEMP folder...using CreateDirectoryW()

          J Offline
          J Offline
          JBAK_CP
          wrote on last edited by
          #4

          Here is another way to do it...

          //Get the env variable
          CString directory = "";
          directory = getenv ( "ProgramFiles");

          //Create a new folder underneath the program files directory
          CString newDirectory(directory + "\\EnvFolder" );
          BOOL createDirEnv = CreateDirectory(newDirectory, NULL);

          1 Reply Last reply
          0
          • P p_1960

            Thanks for ur reply...suppose using this... TCHAR varValue[32767]; GetEnvironmentVariable(_T("TEMP"), varValue, 32767); if get the path of TEMP in varValue...how can i create a folder named "Testing" under that TEMP folder...using CreateDirectoryW()

            S Offline
            S Offline
            Stuart Dootson
            wrote on last edited by
            #5

            wchar_t varValue[32767];
            GetEnvironmentVariableW(L"TEMP", varValue, 32767);
            wchar_t testingDir[32767];
            PathCombineW(testingDir, varValue, "Testing");
            CreateDirectoryW(testingDir, 0);

            Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

            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