VCCodeAttribute.IsReadOnly 属性

定义

获取表示包含父对象的文件是否是只读文件的值。

public:
 property bool IsReadOnly { bool get(); };
public:
 property bool IsReadOnly { bool get(); };
[System.Runtime.InteropServices.DispId(514)]
public bool IsReadOnly { [System.Runtime.InteropServices.DispId(514)] [System.Runtime.InteropServices.TypeLibFunc(System.Runtime.InteropServices.TypeLibFuncFlags.FNonBrowsable)] get; }
[<System.Runtime.InteropServices.DispId(514)>]
[<get: System.Runtime.InteropServices.DispId(514)>]
[<get: System.Runtime.InteropServices.TypeLibFunc(System.Runtime.InteropServices.TypeLibFuncFlags.FNonBrowsable)>]
member this.IsReadOnly : bool
Public ReadOnly Property IsReadOnly As Boolean

属性值

Boolean

true 如果包含父对象的文件是只读的,则为; 否则为。否则为 false

属性

示例

此示例在向代码元素添加注释之前验证该文件是否为只读。

' Macro code.  
Sub AddComment()  
    Dim vcElement As VCCodeElement  
    Dim vcElements As VCCodeElements  
    Dim textPoint As TextPoint  
    vcElements = DTE.Solution.Item(1).CodeModel.Classes  
    vcElement = vcElements.Item(1)  
    If (Not vcElement.IsReadOnly) Then  
        vcElement.Comment = "This is a comment."  
    End If  
End Sub  

注解

有关如何编译和运行此示例的信息,请参阅 如何:编译 Visual C++ 代码模型扩展性的示例代码

适用于