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. Writing to Registry

Writing to Registry

Scheduled Pinned Locked Moved C / C++ / MFC
windows-admin
19 Posts 6 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.
  • R Rajesh R Subramanian

    venkat.kupunaram wrote:

    I am getting a compilation error

    My telescope is missing. Can you tell me what exactly the error is?

    Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]

    V Offline
    V Offline
    V K 2
    wrote on last edited by
    #6

    I am using VC++6.0 error C2065: 'IsUserAnAdmin' : undeclared identifier

    R D 2 Replies Last reply
    0
    • R Rajesh R Subramanian

      venkat.kupunaram wrote:

      I am getting a compilation error

      My telescope is missing. Can you tell me what exactly the error is?

      Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]

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

      Rajesh R Subramanian wrote:

      My telescope is missing. Can you tell me the what exactly the error is?

      Nope. Go back home and get the telescope. ;P BTW: Eventually MFC appeared in your profile :-D

      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.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      R 1 Reply Last reply
      0
      • V V K 2

        I am using VC++6.0 error C2065: 'IsUserAnAdmin' : undeclared identifier

        R Offline
        R Offline
        Rajesh R Subramanian
        wrote on last edited by
        #8

        The function information of IsUserAnAdmin() says - "Shell32.DLL version 5.0 or higher will be required" to make use of this call, which means earlier versions won't have this function exported at all. See here[^]. You'll need the latest SDK (or the SDK which is latest enough and has version 5.0 or higher of Shell32.DLL) to use this call.

        Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]

        V 1 Reply Last reply
        0
        • CPalliniC CPallini

          Rajesh R Subramanian wrote:

          My telescope is missing. Can you tell me the what exactly the error is?

          Nope. Go back home and get the telescope. ;P BTW: Eventually MFC appeared in your profile :-D

          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.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          R Offline
          R Offline
          Rajesh R Subramanian
          wrote on last edited by
          #9

          CPallini wrote:

          Nope. Go back home and get the telescope. [Poke tongue]

          Sorry, but I see the question was not "very urgent", so I could ask the OP to take some time to let me know more of the error.

          CPallini wrote:

          BTW: Eventually MFC appeared in your profile [Big Grin]

          :-O :-\

          Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]

          CPalliniC 1 Reply Last reply
          0
          • _ _AnsHUMAN_

            Use BOOL IsUserAnAdmin(VOID); Perform writing to the registry only if this function returns true.

            Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

            V Offline
            V Offline
            V K 2
            wrote on last edited by
            #10

            This api is giving a compilation error in VC++6.0

            _ 1 Reply Last reply
            0
            • R Rajesh R Subramanian

              CPallini wrote:

              Nope. Go back home and get the telescope. [Poke tongue]

              Sorry, but I see the question was not "very urgent", so I could ask the OP to take some time to let me know more of the error.

              CPallini wrote:

              BTW: Eventually MFC appeared in your profile [Big Grin]

              :-O :-\

              Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]

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

              Rajesh R Subramanian wrote:

              Sorry, but I see the question was not "very urgent", so I could ask the OP to take some time to let me know more of the error.

              You're wrong: "very urgent" it's the default. "Plz plz very urgent" is the courtesy form. :-D

              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.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              In testa che avete, signor di Ceprano?

              R 1 Reply Last reply
              0
              • CPalliniC CPallini

                Rajesh R Subramanian wrote:

                Sorry, but I see the question was not "very urgent", so I could ask the OP to take some time to let me know more of the error.

                You're wrong: "very urgent" it's the default. "Plz plz very urgent" is the courtesy form. :-D

                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.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                R Offline
                R Offline
                Rajesh R Subramanian
                wrote on last edited by
                #12

                "Attack of the Urgent Monkeys" :laugh: BTW, we're dangerously close to hijack this thread. :suss:

                Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]

                CPalliniC 1 Reply Last reply
                0
                • V V K 2

                  This api is giving a compilation error in VC++6.0

                  _ Offline
                  _ Offline
                  _AnsHUMAN_
                  wrote on last edited by
                  #13

                  Here is the code for IsUserAdmin

                  BOOL IsUserAdmin(VOID)
                  /*++ 
                  Routine Description: This routine returns TRUE if the caller's process is a member of the Administrators local group. Caller is NOT expected to be impersonating anyone and is expected to be able to open its own process and process token. 
                  Arguments: None. 
                  Return Value: 
                     TRUE - Caller has Administrators local group. 
                     FALSE - Caller does not have Administrators local group. --
                  */ 
                  {
                  BOOL b;
                  SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
                  PSID AdministratorsGroup; 
                  b = AllocateAndInitializeSid(
                      &NtAuthority,
                      2,
                      SECURITY_BUILTIN_DOMAIN_RID,
                      DOMAIN_ALIAS_RID_ADMINS,
                      0, 0, 0, 0, 0, 0,
                      &AdministratorsGroup); 
                  if(b) 
                  {
                      if (!CheckTokenMembership( NULL, AdministratorsGroup, &b)) 
                      {
                           b = FALSE;
                      } 
                      FreeSid(AdministratorsGroup); 
                  }
                  
                  V 1 Reply Last reply
                  0
                  • R Rajesh R Subramanian

                    "Attack of the Urgent Monkeys" :laugh: BTW, we're dangerously close to hijack this thread. :suss:

                    Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]

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

                    :laugh:

                    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.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                    [My articles]

                    In testa che avete, signor di Ceprano?

                    1 Reply Last reply
                    0
                    • _ _AnsHUMAN_

                      Here is the code for IsUserAdmin

                      BOOL IsUserAdmin(VOID)
                      /*++ 
                      Routine Description: This routine returns TRUE if the caller's process is a member of the Administrators local group. Caller is NOT expected to be impersonating anyone and is expected to be able to open its own process and process token. 
                      Arguments: None. 
                      Return Value: 
                         TRUE - Caller has Administrators local group. 
                         FALSE - Caller does not have Administrators local group. --
                      */ 
                      {
                      BOOL b;
                      SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
                      PSID AdministratorsGroup; 
                      b = AllocateAndInitializeSid(
                          &NtAuthority,
                          2,
                          SECURITY_BUILTIN_DOMAIN_RID,
                          DOMAIN_ALIAS_RID_ADMINS,
                          0, 0, 0, 0, 0, 0,
                          &AdministratorsGroup); 
                      if(b) 
                      {
                          if (!CheckTokenMembership( NULL, AdministratorsGroup, &b)) 
                          {
                               b = FALSE;
                          } 
                          FreeSid(AdministratorsGroup); 
                      }
                      
                      V Offline
                      V Offline
                      V K 2
                      wrote on last edited by
                      #15

                      Thanks.. But I written a user define function and written the above code.. I am getting a compilation error at CheckTokenMembership...

                      _ 1 Reply Last reply
                      0
                      • R Rajesh R Subramanian

                        The function information of IsUserAnAdmin() says - "Shell32.DLL version 5.0 or higher will be required" to make use of this call, which means earlier versions won't have this function exported at all. See here[^]. You'll need the latest SDK (or the SDK which is latest enough and has version 5.0 or higher of Shell32.DLL) to use this call.

                        Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Microsoft MVP - Visual C++[^]

                        V Offline
                        V Offline
                        V K 2
                        wrote on last edited by
                        #16

                        I am using File version 6.0.3790.4184.. But still I am getting a compilation error.

                        1 Reply Last reply
                        0
                        • V V K 2

                          Thanks.. But I written a user define function and written the above code.. I am getting a compilation error at CheckTokenMembership...

                          _ Offline
                          _ Offline
                          _AnsHUMAN_
                          wrote on last edited by
                          #17

                          You should do the following: Header: Declared in Winbase.h; include Windows.h. Library: Use Advapi32.lib And look for Advapi32.dll. Check out MSDN for more details

                          Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

                          1 Reply Last reply
                          0
                          • V V K 2

                            I am using VC++6.0 error C2065: 'IsUserAnAdmin' : undeclared identifier

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

                            Do you have the Feb 2003 version of the Platform SDK?

                            "Love people and use things, not love things and use people." - Unknown

                            "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 V K 2

                              Hi, My application writes into a particular location in Registry Eg. RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_ALL_ACCESS, &h_Key); //Open a particular registry key //Write to that registry key. I need to restrict this activity to only Administrator.. Can I have a code snippet which allows this only for Administrator. Thanks. Venkat

                              H Offline
                              H Offline
                              halibobo
                              wrote on last edited by
                              #19

                              If you can speak Chinese,you can go to"www.csdn.net" .He will help you ! :)

                              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