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. How do i get full path to "My Documents" dir?

How do i get full path to "My Documents" dir?

Scheduled Pinned Locked Moved C / C++ / MFC
questiondebugginghelpworkspace
9 Posts 7 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.
  • L Offline
    L Offline
    lobanovski
    wrote on last edited by
    #1

    Hello folks, just moved from unix environment into win32, not quite comfortable with the feeling that i'm a dumb yet again :( please, help! i need to get a full path to user's dir's like "My Documents". How can i do that? Just hardcoding the path "c:\\Documents and Settings\\USER_NAME_WHO_THE_HELL_KNOWS\\My Documents" is not good idea at all. And what about compatibility with different windowses (nt, xp, win2k or even win98)? any help is greatly appreciated :) alex, debug - is my life style

    R I G M 4 Replies Last reply
    0
    • L lobanovski

      Hello folks, just moved from unix environment into win32, not quite comfortable with the feeling that i'm a dumb yet again :( please, help! i need to get a full path to user's dir's like "My Documents". How can i do that? Just hardcoding the path "c:\\Documents and Settings\\USER_NAME_WHO_THE_HELL_KNOWS\\My Documents" is not good idea at all. And what about compatibility with different windowses (nt, xp, win2k or even win98)? any help is greatly appreciated :) alex, debug - is my life style

      R Offline
      R Offline
      Rob Manderson
      wrote on last edited by
      #2

      Check out SHGetSpecialFolder and related functions. You can also nick the code out of my CFileSpec[^] class :) Rob Manderson http://www.mindprobes.net **Paul Watson wrote:**What sense would you most dislike loosing? Ian Darling replied. Telepathy Then I'd no longer be able to find out everyones dirty little secrets The Lounge, December 4 2003

      1 Reply Last reply
      0
      • L lobanovski

        Hello folks, just moved from unix environment into win32, not quite comfortable with the feeling that i'm a dumb yet again :( please, help! i need to get a full path to user's dir's like "My Documents". How can i do that? Just hardcoding the path "c:\\Documents and Settings\\USER_NAME_WHO_THE_HELL_KNOWS\\My Documents" is not good idea at all. And what about compatibility with different windowses (nt, xp, win2k or even win98)? any help is greatly appreciated :) alex, debug - is my life style

        I Offline
        I Offline
        Ian Darling
        wrote on last edited by
        #3

        In the specific case you mention, start here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_programming/manage.asp[^] MSDN has compatability information on each API - you should install it from the CD/DVDs if you have them, or use the MSDN web site. -- Ian Darling "The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky

        1 Reply Last reply
        0
        • L lobanovski

          Hello folks, just moved from unix environment into win32, not quite comfortable with the feeling that i'm a dumb yet again :( please, help! i need to get a full path to user's dir's like "My Documents". How can i do that? Just hardcoding the path "c:\\Documents and Settings\\USER_NAME_WHO_THE_HELL_KNOWS\\My Documents" is not good idea at all. And what about compatibility with different windowses (nt, xp, win2k or even win98)? any help is greatly appreciated :) alex, debug - is my life style

          G Offline
          G Offline
          GeraldoLuiz
          wrote on last edited by
          #4

          You can also read the following registry key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal I use this in my programs. Geraldo.

          T R 2 Replies Last reply
          0
          • G GeraldoLuiz

            You can also read the following registry key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal I use this in my programs. Geraldo.

            T Offline
            T Offline
            Tim Smith
            wrote on last edited by
            #5

            Ack, don't do this. Microsoft might not always place that information there. Always use the proper API calls. It is hacks like this that cause programs to break. Tim Smith I'm going to patent thought. I have yet to see any prior art.

            N G 2 Replies Last reply
            0
            • T Tim Smith

              Ack, don't do this. Microsoft might not always place that information there. Always use the proper API calls. It is hacks like this that cause programs to break. Tim Smith I'm going to patent thought. I have yet to see any prior art.

              N Offline
              N Offline
              Navin
              wrote on last edited by
              #6

              True, although sometimes the proper API doesn't exist... or only exists if you have version 5.5 or higher of IE, or the API works great on 2000 but crashes on 9x... some other such bull. No single raindrop believes that it is responsible for the flood.

              1 Reply Last reply
              0
              • T Tim Smith

                Ack, don't do this. Microsoft might not always place that information there. Always use the proper API calls. It is hacks like this that cause programs to break. Tim Smith I'm going to patent thought. I have yet to see any prior art.

                G Offline
                G Offline
                GeraldoLuiz
                wrote on last edited by
                #7

                Oh, thanks Tim for the advice. From now on, I will use the API call.

                1 Reply Last reply
                0
                • G GeraldoLuiz

                  You can also read the following registry key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal I use this in my programs. Geraldo.

                  R Offline
                  R Offline
                  Rob Manderson
                  wrote on last edited by
                  #8

                  See this[^] for a good explanation of why using that registry key is undesirable. Rob Manderson http://www.mindprobes.net **Paul Watson wrote:**What sense would you most dislike loosing? Ian Darling replied. Telepathy Then I'd no longer be able to find out everyones dirty little secrets The Lounge, December 4 2003

                  1 Reply Last reply
                  0
                  • L lobanovski

                    Hello folks, just moved from unix environment into win32, not quite comfortable with the feeling that i'm a dumb yet again :( please, help! i need to get a full path to user's dir's like "My Documents". How can i do that? Just hardcoding the path "c:\\Documents and Settings\\USER_NAME_WHO_THE_HELL_KNOWS\\My Documents" is not good idea at all. And what about compatibility with different windowses (nt, xp, win2k or even win98)? any help is greatly appreciated :) alex, debug - is my life style

                    M Offline
                    M Offline
                    murali_utr
                    wrote on last edited by
                    #9

                    hi, use this function call SHGetFolderPath. refer msdn for parameters. Have A Nice Day! Murali.M

                    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