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. Windows API
  4. How to get path to a INI-file in Vista?

How to get path to a INI-file in Vista?

Scheduled Pinned Locked Moved Windows API
salestutorialquestion
6 Posts 4 Posters 2 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.
  • J Offline
    J Offline
    jpe
    wrote on last edited by
    #1

    I have an application that, under the previous operating systems, store application data in a INI file located in the Windows directory. To make customer support easier, I've got a link in the application about box that link to and open the INI file in a text editor. Now, under Windows Vista, the installation application writes some data into the INI file located in the Windows directory, but when the application is reading/writing to the INI file the one in the Windows directory is untouched and a copy of the file is being stored in a windows directory equivalent found in a subfolder in the user folder. Is there a way to get the path to the copy of the INI file located in the user folder? Right now I simply use GetWindowsDirectory + "\\" + "filename.ini" and ShellExecute that. :) /Jonas

    M C 2 Replies Last reply
    0
    • J jpe

      I have an application that, under the previous operating systems, store application data in a INI file located in the Windows directory. To make customer support easier, I've got a link in the application about box that link to and open the INI file in a text editor. Now, under Windows Vista, the installation application writes some data into the INI file located in the Windows directory, but when the application is reading/writing to the INI file the one in the Windows directory is untouched and a copy of the file is being stored in a windows directory equivalent found in a subfolder in the user folder. Is there a way to get the path to the copy of the INI file located in the user folder? Right now I simply use GetWindowsDirectory + "\\" + "filename.ini" and ShellExecute that. :) /Jonas

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

      I asked the shell team this, and their answer was no, there's no way to say "if this file were put somewhere else due to virtualization, where would it go?" The real answer is to fix your code so it doesn't write to the Windows directory, that way non-admins on all OSes can use it.

      --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?

      J 1 Reply Last reply
      0
      • M Michael Dunn

        I asked the shell team this, and their answer was no, there's no way to say "if this file were put somewhere else due to virtualization, where would it go?" The real answer is to fix your code so it doesn't write to the Windows directory, that way non-admins on all OSes can use it.

        --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?

        J Offline
        J Offline
        jpe
        wrote on last edited by
        #3

        Thanks for you reply. I decided to check if Vista i running, if it is, I try access with... getenv("LOCALAPPDATA") + "\VirtualStore\Windows\" + sIniName ..and if that exists I used it. Otherwise I use the file found in the Windows folder. :doh:

        P 1 Reply Last reply
        0
        • J jpe

          Thanks for you reply. I decided to check if Vista i running, if it is, I try access with... getenv("LOCALAPPDATA") + "\VirtualStore\Windows\" + sIniName ..and if that exists I used it. Otherwise I use the file found in the Windows folder. :doh:

          P Offline
          P Offline
          Paresh Chitte
          wrote on last edited by
          #4

          Try also using CSIDL_WINDOWS. Regards, Paresh.

          J 1 Reply Last reply
          0
          • P Paresh Chitte

            Try also using CSIDL_WINDOWS. Regards, Paresh.

            J Offline
            J Offline
            jpe
            wrote on last edited by
            #5

            Thanks for the tip, but I'm pretty certain that CSIDL_WINDOWS returns the %SYSTEMROOT% variable which is set to e.g. C:\WINDOWS also on a Vista system. I assume, this is also what the regular GetWindowsDirectory function outputs. Nasty, nasty virtualization. /Jonas

            1 Reply Last reply
            0
            • J jpe

              I have an application that, under the previous operating systems, store application data in a INI file located in the Windows directory. To make customer support easier, I've got a link in the application about box that link to and open the INI file in a text editor. Now, under Windows Vista, the installation application writes some data into the INI file located in the Windows directory, but when the application is reading/writing to the INI file the one in the Windows directory is untouched and a copy of the file is being stored in a windows directory equivalent found in a subfolder in the user folder. Is there a way to get the path to the copy of the INI file located in the user folder? Right now I simply use GetWindowsDirectory + "\\" + "filename.ini" and ShellExecute that. :) /Jonas

              C Offline
              C Offline
              Christopher Duncan
              wrote on last edited by
              #6

              Replace your call to GetWindowsDirectory() with a call to SHGetFolderPath(). Pick the appropriate flags such as CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, etc. to fine tune which of the user's paths you want. Hope this helps, Chris

              Author of The Career Programmer and Unite the Tribes www.PracticalStrategyConsulting.com

              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