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. Administrator Privileges

Administrator Privileges

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 2 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.
  • M Offline
    M Offline
    MsmVc
    wrote on last edited by
    #1

    Hi All I need to block or show message when application run as Administrator.Is it possible? Please help me

    E 1 Reply Last reply
    0
    • M MsmVc

      Hi All I need to block or show message when application run as Administrator.Is it possible? Please help me

      E Offline
      E Offline
      Eugen Podsypalnikov
      wrote on last edited by
      #2

      Already tried[^] ? :)

      virtual void BeHappy() = 0;

      M 1 Reply Last reply
      0
      • E Eugen Podsypalnikov

        Already tried[^] ? :)

        virtual void BeHappy() = 0;

        M Offline
        M Offline
        MsmVc
        wrote on last edited by
        #3

        Thanks for reply No i just going through this let you know.

        M 1 Reply Last reply
        0
        • M MsmVc

          Thanks for reply No i just going through this let you know.

          M Offline
          M Offline
          MsmVc
          wrote on last edited by
          #4

          Hey i use code which is given in MSDN.I use like this

          bool CCheckApp::IsUserAdmin(void)
          {
          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))
          {
          AfxMessageBox("Test");
          b = FALSE;
          }
          FreeSid(AdministratorsGroup);
          }

          return(b);

          }
          And call in
          BOOL CCheckApp::InitInstance()
          {
          ...

          ..
          ..
          IsUserAdmin();

          }

          i am wrong or right.Please help me

          E 1 Reply Last reply
          0
          • M MsmVc

            Hey i use code which is given in MSDN.I use like this

            bool CCheckApp::IsUserAdmin(void)
            {
            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))
            {
            AfxMessageBox("Test");
            b = FALSE;
            }
            FreeSid(AdministratorsGroup);
            }

            return(b);

            }
            And call in
            BOOL CCheckApp::InitInstance()
            {
            ...

            ..
            ..
            IsUserAdmin();

            }

            i am wrong or right.Please help me

            E Offline
            E Offline
            Eugen Podsypalnikov
            wrote on last edited by
            #5

            Why not ? :) You could modify the last line:

            return (FALSE != b); // to prevent a possible warning

            virtual void BeHappy() = 0;

            M 1 Reply Last reply
            0
            • E Eugen Podsypalnikov

              Why not ? :) You could modify the last line:

              return (FALSE != b); // to prevent a possible warning

              virtual void BeHappy() = 0;

              M Offline
              M Offline
              MsmVc
              wrote on last edited by
              #6

              Thanks it's working...

              E 1 Reply Last reply
              0
              • M MsmVc

                Thanks it's working...

                E Offline
                E Offline
                Eugen Podsypalnikov
                wrote on last edited by
                #7

                Try it also in the admin mode at the switched-on UAC :)

                virtual void BeHappy() = 0;

                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