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. SHGetFolderPath() for *another* user

SHGetFolderPath() for *another* user

Scheduled Pinned Locked Moved C / C++ / MFC
comwindows-adminlinuxquestion
7 Posts 3 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.
  • T Offline
    T Offline
    Taka Muraoka
    wrote on last edited by
    #1

    I need to be able to find the special folders (e.g. My Documents) for a user other than the one currently logged on. The best I've been able to come up with so far is to use NetUserEnum() to get a list of all the users on the machine and check the HKEY_USERS\***\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders registry key (where *** is the user's SID). Peeking into the registry like this is a bit kludgy so is there a better way?


    0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall. Awasu 2.2.4 [^]: A free RSS/Atom feed reader with support for Code Project.

    D D 2 Replies Last reply
    0
    • T Taka Muraoka

      I need to be able to find the special folders (e.g. My Documents) for a user other than the one currently logged on. The best I've been able to come up with so far is to use NetUserEnum() to get a list of all the users on the machine and check the HKEY_USERS\***\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders registry key (where *** is the user's SID). Peeking into the registry like this is a bit kludgy so is there a better way?


      0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall. Awasu 2.2.4 [^]: A free RSS/Atom feed reader with support for Code Project.

      D Offline
      D Offline
      Don Box
      wrote on last edited by
      #2

      Other way is, get the folders present in "C:\Documents and Settings\". 'Cuz each and every user account on the system has folders (of username) in this path.

      Come online at:- jubinc@skype

      T 1 Reply Last reply
      0
      • D Don Box

        Other way is, get the folders present in "C:\Documents and Settings\". 'Cuz each and every user account on the system has folders (of username) in this path.

        Come online at:- jubinc@skype

        T Offline
        T Offline
        Taka Muraoka
        wrote on last edited by
        #3

        Doesn't work on NT nor Vista. Doesn't work on non-English versions of Windows since that directory will be named differently. It also won't work if the special folders have been redirected to elsewhere.


        0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall. Awasu 2.2.4 [^]: A free RSS/Atom feed reader with support for Code Project.

        1 Reply Last reply
        0
        • T Taka Muraoka

          I need to be able to find the special folders (e.g. My Documents) for a user other than the one currently logged on. The best I've been able to come up with so far is to use NetUserEnum() to get a list of all the users on the machine and check the HKEY_USERS\***\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders registry key (where *** is the user's SID). Peeking into the registry like this is a bit kludgy so is there a better way?


          0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall. Awasu 2.2.4 [^]: A free RSS/Atom feed reader with support for Code Project.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Taka Muraoka wrote:

          I need to be able to find the special folders (e.g. My Documents) for a user other than the one currently logged on.

          That's what the third argument to SHGetFolderPath() is for.


          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

          "Judge not by the eye but by the heart." - Native American Proverb

          T 1 Reply Last reply
          0
          • D David Crow

            Taka Muraoka wrote:

            I need to be able to find the special folders (e.g. My Documents) for a user other than the one currently logged on.

            That's what the third argument to SHGetFolderPath() is for.


            "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

            "Judge not by the eye but by the heart." - Native American Proverb

            T Offline
            T Offline
            Taka Muraoka
            wrote on last edited by
            #5

            DavidCrow wrote:

            That's what the third argument to SHGetFolderPath() is for.

            Doesn't work for me, unfortunately. You need the user's password to get a token.


            0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall. Awasu 2.2.4 [^]: A free RSS/Atom feed reader with support for Code Project.

            D 1 Reply Last reply
            0
            • T Taka Muraoka

              DavidCrow wrote:

              That's what the third argument to SHGetFolderPath() is for.

              Doesn't work for me, unfortunately. You need the user's password to get a token.


              0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall. Awasu 2.2.4 [^]: A free RSS/Atom feed reader with support for Code Project.

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              Then just query the registry. For each user, query the following registry key: HKEY_USERS\<SID of user>\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders


              "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

              "Judge not by the eye but by the heart." - Native American Proverb

              T 1 Reply Last reply
              0
              • D David Crow

                Then just query the registry. For each user, query the following registry key: HKEY_USERS\<SID of user>\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders


                "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                "Judge not by the eye but by the heart." - Native American Proverb

                T Offline
                T Offline
                Taka Muraoka
                wrote on last edited by
                #7

                Well, that's what I wrote in my original post but it seems a bit of a clunky way of getting the info I need so I was just asking if there was a better way. Thanks anyway :-)


                0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall. Awasu 2.2.4 [^]: A free RSS/Atom feed reader with support for Code Project.

                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