Export (0) Print
Expand All
Expand Minimize

UIPermissionClipboard Enumeration

Specifies the type of clipboard access that is allowed to the calling code.

[Visual Basic]
<Serializable>
Public Enum UIPermissionClipboard
[C#]
[Serializable]
public enum UIPermissionClipboard
[C++]
[Serializable]
__value public enum UIPermissionClipboard
[JScript]
public
   Serializable
enum UIPermissionClipboard

Remarks

This enumeration is used by UIPermission.

Members

Member name Description
AllClipboard Clipboard can be used without restriction.
NoClipboard Clipboard cannot be used.
OwnClipboard The ability to put data on the clipboard (Copy, Cut) is unrestricted. Intrinsic controls that accept Paste, such as text box, can accept the clipboard data, but user controls that must programmatically read the clipboard cannot.

Example

[Visual Basic] 
' This class generates UIPermission objects using UIPermissionWindow and 
' UIPermissionClipboard enumeration values.

Imports System
Imports System.Security
Imports System.Security.Permissions
Imports Microsoft.VisualBasic


Friend Class UIGenerator
    Private myUI As UIPermissionWindow() = _
    {UIPermissionWindow.AllWindows, _
     UIPermissionWindow.SafeSubWindows, _
     UIPermissionWindow.SafeTopLevelWindows, _
     UIPermissionWindow.NoWindows}

    Private myCB As UIPermissionClipboard() = _
    {UIPermissionClipboard.AllClipboard, _
     UIPermissionClipboard.OwnClipboard, _
     UIPermissionClipboard.NoClipboard}

    Private uiIndex As Integer = 0
    Private cbIndex As Integer = 0


    Public Sub New()
        ResetIndex()
    End Sub 'New


    Public Sub ResetIndex()
        uiIndex = 0
        cbIndex = 0
    End Sub 'ResetIndex

    Public Sub ResetUIIndex()
        uiIndex = 0
    End Sub 'ResetUIIndex

    ' Create a UIPermission object using both a UIPermission Window enumeration and a 
    ' UIPermissionClipboard enumeration to specify permissions.
    Public Overloads Function CreateUI(ByRef UIPerm As UIPermission, ByRef ui As UIPermissionWindow, ByRef cb As UIPermissionClipboard) As Boolean

        If uiIndex >= myUI.Length AndAlso cbIndex >= myCB.Length - 1 Then
            ui = UIPermissionWindow.NoWindows
            cb = UIPermissionClipboard.NoClipboard
            UIPerm = New UIPermission(ui, cb)
            Return False
        End If

        If uiIndex >= myUI.Length AndAlso cbIndex < myCB.Length - 1 Then
            ResetUIIndex()
            ui = myUI(uiIndex)
            uiIndex = uiIndex + 1
            cbIndex = cbIndex + 1
            cb = myCB(cbIndex)
            'ToDo: Unsupported operator
            'ToDo: && operator not supported within expressions
            UIPerm = New UIPermission(ui, cb)
            Return True
        End If

        ui = myUI(uiIndex)
        uiIndex = uiIndex + 1
        cb = myCB(cbIndex)
        Try
            UIPerm = New UIPermission(ui, cb)
            Return True
        Catch e As Exception
            Console.WriteLine(("Cannot create UIPermission: " & ui & " " & e.ToString()))
            UIPerm = New UIPermission(PermissionState.None)
            ui = UIPermissionWindow.NoWindows
            Return True
        End Try
    End Function 'CreateUI

    ' Create a UIPermission using the specified UIPermissionWindow enumeration 
    ' to set Window permissions.
    Public Overloads Function CreateUI(ByRef uiPerm As UIPermission, _
    ByRef ui As UIPermissionWindow) As Boolean

        If uiIndex >= myUI.Length Then
            uiPerm = New UIPermission(PermissionState.None)
            ui = UIPermissionWindow.NoWindows
            Return False
        End If
        ui = myUI(uiIndex)
        uiIndex = uiIndex + 1
        Try
            uiPerm = New UIPermission(ui)
            Return True
        Catch e As Exception
            Console.WriteLine(("Cannot create UIPermission: " & ui & " " & e.ToString()))
            uiPerm = New UIPermission(PermissionState.None)
            ui = UIPermissionWindow.NoWindows
            Return True
        End Try
    End Function 'CreateUI

    ' Create a UIPermission using  Create a UIPermission using the specified UIPermissionClipboard enumeration to set Clipboard permissions.
    Public Overloads Function CreateUI(ByRef uiPerm As UIPermission, ByRef cb As UIPermissionClipboard) As Boolean


        If cbIndex >= myCB.Length Then
            uiPerm = New UIPermission(PermissionState.None)
            cb = UIPermissionClipboard.NoClipboard

            Return False
        End If


        cb = myCB(cbIndex)
        cbIndex = cbIndex + 1
        Try
            uiPerm = New UIPermission(cb)
            Return True
        Catch e As Exception
            Console.WriteLine(("Cannot create UIPermission: " & cb & " " & e.ToString()))
            uiPerm = New UIPermission(PermissionState.None)
            cb = UIPermissionClipboard.NoClipboard
            Return True
        End Try
    End Function 'CreateUI
End Class 'UIGenerator 
'End of UIGenerator.

[C#] 

// This class generates UIPermission objects using UIPermissionWindow and 
// UIPermissionClipboard enumeration values.

using System;
using System.Security; 
using System.Security.Permissions; 

public  class UIGenerator
           {
               private UIPermissionWindow[] myUI = 
                {
                    UIPermissionWindow.AllWindows,
                    UIPermissionWindow.SafeSubWindows,
                    UIPermissionWindow.SafeTopLevelWindows, 
                    UIPermissionWindow.NoWindows};

               private UIPermissionClipboard[] myCB = 
                {
                    UIPermissionClipboard.AllClipboard,  
                    UIPermissionClipboard.OwnClipboard, 
                    UIPermissionClipboard.NoClipboard};

               private int uiIndex = 0;
               private int cbIndex = 0;

               public UIGenerator()
               {
                   ResetIndex();
               }

               public void ResetIndex()
               {
                   uiIndex = 0;
                   cbIndex = 0;
               }
               public void ResetUIIndex()
               {
                   uiIndex = 0;
               }
               // Create a UIPermission object using both a UIPermission Window enumeration and a 
               // UIPermissionClipboard enumeration to specify permissions.
               public bool CreateUI(out UIPermission UIPerm, out UIPermissionWindow ui, out UIPermissionClipboard cb)
               {

                   if(uiIndex >= myUI.Length && cbIndex >= (myCB.Length - 1)) 
                   {
                       ui = UIPermissionWindow.NoWindows;
                       cb = UIPermissionClipboard.NoClipboard;
                       UIPerm = new UIPermission(ui, cb);
                       return false;
                   }

                   if(uiIndex >= myUI.Length && cbIndex < (myCB.Length - 1)) 
                   {
                       ResetUIIndex();
                       ui = myUI[uiIndex++];
                       cb = myCB[++cbIndex];
                       UIPerm = new UIPermission(ui, cb);
                       return true;
                   }

                   ui = myUI[uiIndex++];
                   cb= myCB[cbIndex];
                   try
                   {
                       UIPerm = new UIPermission(ui, cb);
                       return true;
                   } 
                   catch(Exception e)
                   {
                       Console.WriteLine("Cannot create UIPermission: " + ui +" "+e);
                       UIPerm = new UIPermission(PermissionState.None);
                       ui = UIPermissionWindow.NoWindows;
                       return true;
                   }
               }
               // Create a UIPermission using  Create a UIPermission using the specified UIPermissionWindow 
               // enumeration to set Window permissions.
               public bool CreateUI(out UIPermission uiPerm, out UIPermissionWindow ui)
               {

                   if(uiIndex >= myUI.Length) 
                   {
                       uiPerm = new UIPermission(PermissionState.None);
                       ui=UIPermissionWindow.NoWindows;
                       return false;
                   }
                   ui = myUI[uiIndex++];
                   try
                   {
                       uiPerm = new UIPermission(ui);
                       return true;
                   } 
                   catch(Exception e)
                   {
                       Console.WriteLine("Cannot create UIPermission: " + ui +" "+e);
                       uiPerm = new UIPermission(PermissionState.None);
                       ui = UIPermissionWindow.NoWindows;
                       return true;
                   }
               }
               // Create a UIPermission using the specified UIPermissionClipboard enumeration to 
               // set Clipboard permissions.
               public bool CreateUI(out UIPermission uiPerm,  out UIPermissionClipboard cb)
               {


                   if(cbIndex >= myCB.Length) 
                   {
                       uiPerm = new UIPermission(PermissionState.None);
                       cb = UIPermissionClipboard.NoClipboard;

                       return false;
                   }


                   cb= myCB[cbIndex++];
                   try
                   {
                       uiPerm = new UIPermission(cb);
                       return true;
                   } 
                   catch(Exception e)
                   {
                       Console.WriteLine("Cannot create UIPermission: " + cb +" "+e);
                       uiPerm = new UIPermission(PermissionState.None);
                       cb = UIPermissionClipboard.NoClipboard;
                       return true;
                   }
               }

           } //End of UIGenerator.

[C++] 

// This class generates UIPermission objects using UIPermissionWindow and 
// UIPermissionClipboard enumeration values.

#using <mscorlib.dll>
using namespace System::Runtime::InteropServices;
using namespace System;
using namespace System::Security; 
using namespace System::Security::Permissions; 

public  __gc class UIGenerator
{
private:
    UIPermissionWindow myUI[];
    UIPermissionClipboard myCB[];
    int uiIndex;
    int cbIndex;

public:
    UIGenerator()
    {
        UIPermissionWindow tempUI[] = 
        {
            UIPermissionWindow::AllWindows,
                UIPermissionWindow::SafeSubWindows,
                UIPermissionWindow::SafeTopLevelWindows, 
                UIPermissionWindow::NoWindows
        };

        UIPermissionClipboard tempCB[] = 
        {
            UIPermissionClipboard::AllClipboard,  
                UIPermissionClipboard::OwnClipboard, 
                UIPermissionClipboard::NoClipboard
        };
        myUI = tempUI;
        myCB = tempCB;
        ResetIndex();
    }

    void ResetIndex()
    {
        uiIndex = 0;
        cbIndex = 0;
    }
    void ResetUIIndex()
    {
        uiIndex = 0;
    }
    // Create a UIPermission object using both a UIPermission Window enumeration and a 
    // UIPermissionClipboard enumeration to specify permissions.
    bool CreateUI([Out]UIPermission** UIPerm, [Out]UIPermissionWindow* ui, [Out]UIPermissionClipboard* cb)
    {

        if(uiIndex >= myUI->Length && cbIndex >= (myCB->Length - 1)) 
        {
            *ui = UIPermissionWindow::NoWindows;
            *cb = UIPermissionClipboard::NoClipboard;
            *UIPerm = new UIPermission(*ui, *cb);
            return false;
        }

        if(uiIndex >= myUI->Length && cbIndex < (myCB->Length - 1)) 
        {
            ResetUIIndex();
            *ui = myUI[uiIndex++];
            *cb = myCB[++cbIndex];
            *UIPerm = new UIPermission(*ui, *cb);
            return true;
        }

        *ui = myUI[uiIndex++];
        *cb= myCB[cbIndex];
        try
        {
            *UIPerm = new UIPermission(*ui, *cb);
            return true;
        } 
        catch(Exception* e)
        {
            Console::WriteLine(S"Cannot create UIPermission: {0} {1}", __box(*ui), e);
            *UIPerm = new UIPermission(PermissionState::None);
            *ui = UIPermissionWindow::NoWindows;
            return true;
        }
    }
    // Create a UIPermission using  Create a UIPermission using the specified UIPermissionWindow 
    // enumeration to set Window permissions.
    bool CreateUI([Out]UIPermission** uiPerm, [Out]UIPermissionWindow* ui)
    {

        if(uiIndex >= myUI->Length) 
        {
            *uiPerm = new UIPermission(PermissionState::None);
            *ui=UIPermissionWindow::NoWindows;
            return false;
        }
        *ui = myUI[uiIndex++];
        try
        {
            *uiPerm = new UIPermission(*ui);
            return true;
        } 
        catch(Exception* e)
        {
            Console::WriteLine(S"Cannot create UIPermission: {0} {1}", __box(*ui), e);
            *uiPerm = new UIPermission(PermissionState::None);
            *ui = UIPermissionWindow::NoWindows;
            return true;
        }
    }
    // Create a UIPermission using the specified UIPermissionClipboard enumeration to 
    // set Clipboard permissions.
    bool CreateUI([Out]UIPermission** uiPerm,  [Out]UIPermissionClipboard* cb)
    {

        if(cbIndex >= myCB->Length) 
        {
            *uiPerm = new UIPermission(PermissionState::None);
            *cb = UIPermissionClipboard::NoClipboard;

            return false;
        }

        *cb= myCB[cbIndex++];
        try
        {
            *uiPerm = new UIPermission(*cb);
            return true;
        } 
        catch(Exception* e)
        {
            Console::WriteLine(S"Cannot create UIPermission: {0} {1}", __box(*cb), e);
            *uiPerm = new UIPermission(PermissionState::None);
            *cb = UIPermissionClipboard::NoClipboard;
            return true;
        }
    }

}; //End of UIGenerator.

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Security.Permissions

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: Mscorlib (in Mscorlib.dll)

See Also

System.Security.Permissions Namespace | UIPermission | UIPermissionAttribute | UIPermissionWindow

Show:
© 2014 Microsoft