UIPermissionClipboard 列挙体

呼び出し元のコードに対して許可されているクリップボードへのアクセスの種類を指定します。

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

解説

この列挙体は、 UIPermission で使用されます。

メンバ

メンバ名 説明
AllClipboard クリップボードは、無制限に使用できます。
NoClipboard クリップボードは使用できません。
OwnClipboard クリップボードにデータを貼り付ける権限 (CopyCut) は制限されません。テキスト ボックスなど、 Paste を受け入れる組み込みコントロールは、クリップボードのデータを受け入れることができますが、クリップボードをプログラムによって読み込む必要があるユーザー コントロールはクリップボードのデータを受け入れることができません。

使用例

 
' 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] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.Security.Permissions

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

アセンブリ: Mscorlib (Mscorlib.dll 内)

参照

System.Security.Permissions 名前空間 | UIPermission | UIPermissionAttribute | UIPermissionWindow