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. getting Program Files path

getting Program Files path

Scheduled Pinned Locked Moved C / C++ / MFC
questioncomtools
4 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.
  • A Offline
    A Offline
    Amit Dey
    wrote on last edited by
    #1

    how do I get the path to what on my system is C:\Program Files? I'm looking up the value of %PROGRAMFILES% currently but this might not be defined on every system. TCHAR szPath[MAX_PATH + 1]; ExpandEnvironmentStrings("%PROGRAMFILES%",szPath,MAX_PATH); any alternatives? Do I have to lookup some reg key? Thanks.

    Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
    Writing Word addins Office addin

    M C 2 Replies Last reply
    0
    • A Amit Dey

      how do I get the path to what on my system is C:\Program Files? I'm looking up the value of %PROGRAMFILES% currently but this might not be defined on every system. TCHAR szPath[MAX_PATH + 1]; ExpandEnvironmentStrings("%PROGRAMFILES%",szPath,MAX_PATH); any alternatives? Do I have to lookup some reg key? Thanks.

      Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
      Writing Word addins Office addin

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      Use SHGetFolderPath() to get the location of the folder CSIDL_PROGRAM_FILES (that function is in shfolder.dll which you can redistribute, and it comes with any recent OS and IE version) --Mike-- Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber "That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."   -- Buffy

      1 Reply Last reply
      0
      • A Amit Dey

        how do I get the path to what on my system is C:\Program Files? I'm looking up the value of %PROGRAMFILES% currently but this might not be defined on every system. TCHAR szPath[MAX_PATH + 1]; ExpandEnvironmentStrings("%PROGRAMFILES%",szPath,MAX_PATH); any alternatives? Do I have to lookup some reg key? Thanks.

        Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
        Writing Word addins Office addin

        C Offline
        C Offline
        Code4Food
        wrote on last edited by
        #3

        I use the c function _getcwd to retrieve the current working directory which is almost always the directory the program is running in unless you have your working directory set differently when doing debugs in VC++. Code4Food ---- "There is no try; only do or do not" -Yoda

        J 1 Reply Last reply
        0
        • C Code4Food

          I use the c function _getcwd to retrieve the current working directory which is almost always the directory the program is running in unless you have your working directory set differently when doing debugs in VC++. Code4Food ---- "There is no try; only do or do not" -Yoda

          J Offline
          J Offline
          John M Drescher
          wrote on last edited by
          #4

          Code4Food wrote: "There is no try; only do or do not" -Yoda I think that is my all time favorite movie quote... John

          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