コード例 #1
0
        public void RemoveDesktopPermission(string userOrGroupName)
        {
            SafeHandle shWindowStation = new NonReleasingSafeHandle(GetProcessWindowStation(), false);
            var ws = new WindowStationSecurity(shWindowStation);
            ws.RemoveAccessRule(new AccessRule<NativeMethods.WindowStationRights>(userOrGroupName, NativeMethods.WindowStationRights.AllAccess, AccessControlType.Allow));
            ws.AcceptChanges();

            SafeHandle shDesktopThread = new NonReleasingSafeHandle(GetThreadDesktop(GetCurrentThreadId()), false);
            var ds = new DesktopSecurity(shDesktopThread);
            ds.RemoveAccessRule(new AccessRule<NativeMethods.DesktopRights>(userOrGroupName, NativeMethods.DesktopRights.AllAccess, AccessControlType.Allow));
            ds.AcceptChanges();
        }
コード例 #2
0
        public void RemoveDesktopPermission(string userOrGroupName)
        {
            SafeHandle shWindowStation = new NonReleasingSafeHandle(GetProcessWindowStation(), false);
            var        ws = new WindowStationSecurity(shWindowStation);

            ws.RemoveAccessRule(new AccessRule <NativeMethods.WindowStationRights>(userOrGroupName, NativeMethods.WindowStationRights.AllAccess, AccessControlType.Allow));
            ws.AcceptChanges();

            SafeHandle shDesktopThread = new NonReleasingSafeHandle(GetThreadDesktop(GetCurrentThreadId()), false);
            var        ds = new DesktopSecurity(shDesktopThread);

            ds.RemoveAccessRule(new AccessRule <NativeMethods.DesktopRights>(userOrGroupName, NativeMethods.DesktopRights.AllAccess, AccessControlType.Allow));
            ds.AcceptChanges();
        }