Use UIPermission to Checking for security access : UIPermission « Development Class « C# / C Sharp






Use UIPermission to Checking for security access


using System;
using System.Security.Permissions;

class MainClass {
    public static void Main() {
        RegistryPermission f = new RegistryPermission(RegistryPermissionAccess.Read,"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");

        if (f.IsUnrestricted())
            Console.WriteLine("Unrestricted Access allowed");
        else
            Console.WriteLine("Unrestricted Access DENIED");

        FileIOPermission fileIO = new FileIOPermission(PermissionState.None);
        Console.WriteLine("All Local files read access: {0}",FileIOPermissionAccess.Read);
        Console.WriteLine("All Local files write access: {0}",FileIOPermissionAccess.Write);

        UIPermission ui = new UIPermission(UIPermissionWindow.AllWindows,UIPermissionClipboard.AllClipboard);
        if (ui.IsUnrestricted())
            Console.WriteLine("UI Unrestricted Access allowed");
        else
            Console.WriteLine("UI Unrestricted Access DENIED");

    }
}

           
       








Related examples in the same category