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. HKEY_CURRENT_USER\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\ logon User Name cannot access from system process

HKEY_CURRENT_USER\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\ logon User Name cannot access from system process

Scheduled Pinned Locked Moved C / C++ / MFC
helpwindows-admin
9 Posts 5 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.
  • V Offline
    V Offline
    vicky00000
    wrote on last edited by
    #1

    hai all HKEY_CURRENT_USER\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\ logon User Name cannot access from system process I use the following code LPCSTR szKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"); LPCSTR szValueName = _T("Logon User Name"); //open the registry key lRet = RegOpenKeyEx( HKEY_CURRENT_USER, szKey, 0, KEY_QUERY_VALUE, &hSubKey ); if( lRet == ERROR_SUCCESS) { dwBufLen = 256; lRet = RegQueryValueEx( hSubKey, szValueName, NULL, NULL, (LPBYTE) szValue, &dwBufLen); } pls help me Advance thanks

    CPalliniC D H M 4 Replies Last reply
    0
    • V vicky00000

      hai all HKEY_CURRENT_USER\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\ logon User Name cannot access from system process I use the following code LPCSTR szKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"); LPCSTR szValueName = _T("Logon User Name"); //open the registry key lRet = RegOpenKeyEx( HKEY_CURRENT_USER, szKey, 0, KEY_QUERY_VALUE, &hSubKey ); if( lRet == ERROR_SUCCESS) { dwBufLen = 256; lRet = RegQueryValueEx( hSubKey, szValueName, NULL, NULL, (LPBYTE) szValue, &dwBufLen); } pls help me Advance thanks

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      vicky00000 wrote:

      LPCSTR szKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"); LPCSTR szValueName = _T("Logon User Name");

      The above should be

      LPCTSTR szKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer");
      LPCTSTR szValueName = _T("Logon User Name");

      And the code shown lacks some definitions like the one of the buffer (probably they are already present in your program, I don't know), anyway, the following code (practically identical to yours) is working fine on my system (XP):

      TCHAR szValue[256];
      LPCTSTR szKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer");
      LPCTSTR szValueName = _T("Logon User Name");
      HKEY hSubKey;
      //open the registry key
      LRESULT lRet = RegOpenKeyEx( HKEY_CURRENT_USER, szKey, 0, KEY_QUERY_VALUE, &hSubKey );
      if( lRet == ERROR_SUCCESS)
      {
      DWORD dwBufLen = 256;
      Ret = RegQueryValueEx( hSubKey, szValueName, NULL, NULL,(LPBYTE) szValue, &dwBufLen);
      }

      BTW whenever RegQueryValueEx fails is worthy to give a look at reported error. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      [my articles]

      In testa che avete, signor di Ceprano?

      V 1 Reply Last reply
      0
      • CPalliniC CPallini

        vicky00000 wrote:

        LPCSTR szKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"); LPCSTR szValueName = _T("Logon User Name");

        The above should be

        LPCTSTR szKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer");
        LPCTSTR szValueName = _T("Logon User Name");

        And the code shown lacks some definitions like the one of the buffer (probably they are already present in your program, I don't know), anyway, the following code (practically identical to yours) is working fine on my system (XP):

        TCHAR szValue[256];
        LPCTSTR szKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer");
        LPCTSTR szValueName = _T("Logon User Name");
        HKEY hSubKey;
        //open the registry key
        LRESULT lRet = RegOpenKeyEx( HKEY_CURRENT_USER, szKey, 0, KEY_QUERY_VALUE, &hSubKey );
        if( lRet == ERROR_SUCCESS)
        {
        DWORD dwBufLen = 256;
        Ret = RegQueryValueEx( hSubKey, szValueName, NULL, NULL,(LPBYTE) szValue, &dwBufLen);
        }

        BTW whenever RegQueryValueEx fails is worthy to give a look at reported error. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        [my articles]

        V Offline
        V Offline
        vicky00000
        wrote on last edited by
        #3

        Thanks ur reply, My code is exactly like u mentioned. This code will work correctly while it run by a normal process . It shows error while it run as system process. The error it shows is ERROR_FILE_NOT_FOUND

        CPalliniC 1 Reply Last reply
        0
        • V vicky00000

          Thanks ur reply, My code is exactly like u mentioned. This code will work correctly while it run by a normal process . It shows error while it run as system process. The error it shows is ERROR_FILE_NOT_FOUND

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          vicky00000 wrote:

          t shows error while it run as system process

          Do you mean a service?

          vicky00000 wrote:

          The error it shows is ERROR_FILE_NOT_FOUND

          MSDN http://msdn2.microsoft.com/en-us/library/ms724911(VS.85).aspx[^] states: If lpValueName specifies a key that is not in the registry, the function returns ERROR_FILE_NOT_FOUND. Hence the service is not able to se this entry (or the entry there isn't when the service runs). But those are only poor hypothesis: I'm not an expert about, maybe you can also ask the OS/SysAdimn forum. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          [my articles]

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          • V vicky00000

            hai all HKEY_CURRENT_USER\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\ logon User Name cannot access from system process I use the following code LPCSTR szKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"); LPCSTR szValueName = _T("Logon User Name"); //open the registry key lRet = RegOpenKeyEx( HKEY_CURRENT_USER, szKey, 0, KEY_QUERY_VALUE, &hSubKey ); if( lRet == ERROR_SUCCESS) { dwBufLen = 256; lRet = RegQueryValueEx( hSubKey, szValueName, NULL, NULL, (LPBYTE) szValue, &dwBufLen); } pls help me Advance thanks

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

            So what's failing?

            "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            1 Reply Last reply
            0
            • V vicky00000

              hai all HKEY_CURRENT_USER\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\ logon User Name cannot access from system process I use the following code LPCSTR szKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"); LPCSTR szValueName = _T("Logon User Name"); //open the registry key lRet = RegOpenKeyEx( HKEY_CURRENT_USER, szKey, 0, KEY_QUERY_VALUE, &hSubKey ); if( lRet == ERROR_SUCCESS) { dwBufLen = 256; lRet = RegQueryValueEx( hSubKey, szValueName, NULL, NULL, (LPBYTE) szValue, &dwBufLen); } pls help me Advance thanks

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              Did you get any error or null result?

              1 Reply Last reply
              0
              • V vicky00000

                hai all HKEY_CURRENT_USER\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\ logon User Name cannot access from system process I use the following code LPCSTR szKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"); LPCSTR szValueName = _T("Logon User Name"); //open the registry key lRet = RegOpenKeyEx( HKEY_CURRENT_USER, szKey, 0, KEY_QUERY_VALUE, &hSubKey ); if( lRet == ERROR_SUCCESS) { dwBufLen = 256; lRet = RegQueryValueEx( hSubKey, szValueName, NULL, NULL, (LPBYTE) szValue, &dwBufLen); } pls help me Advance thanks

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                In the registry, the current user would be the account you're running from - the system account. See LocalSystem Account[^] Are you trying to get the name of the current logged-on user from a service running in a system account? Mark

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                V 1 Reply Last reply
                0
                • M Mark Salsbery

                  In the registry, the current user would be the account you're running from - the system account. See LocalSystem Account[^] Are you trying to get the name of the current logged-on user from a service running in a system account? Mark

                  Mark Salsbery Microsoft MVP - Visual C++ :java:

                  V Offline
                  V Offline
                  vicky00000
                  wrote on last edited by
                  #8

                  yes .................

                  M 1 Reply Last reply
                  0
                  • V vicky00000

                    yes .................

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #9

                    Did you look into this[^]? Mark

                    Mark Salsbery Microsoft MVP - Visual C++ :java:

                    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