CriticalHandleZeroOrMinusOneIsInvalid 类

定义

为 Win32 关键句柄实现提供基类,在这些实现中值为 0 或 -1 时都表示无效句柄。Provides a base class for Win32 critical handle implementations in which the value of either 0 or -1 indicates an invalid handle.

public ref class CriticalHandleZeroOrMinusOneIsInvalid abstract : System::Runtime::InteropServices::CriticalHandle
[System.Security.SecurityCritical]
public abstract class CriticalHandleZeroOrMinusOneIsInvalid : System.Runtime.InteropServices.CriticalHandle
type CriticalHandleZeroOrMinusOneIsInvalid = class
    inherit CriticalHandle
Public MustInherit Class CriticalHandleZeroOrMinusOneIsInvalid
Inherits CriticalHandle
继承
CriticalHandleZeroOrMinusOneIsInvalid
属性

注解

此类从 System.Runtime.InteropServices.CriticalHandle 类派生。This class derives from the System.Runtime.InteropServices.CriticalHandle class. 它描述了无效句柄的格式。It describes the format of an invalid handle. 例如, 某些句柄使用-1 作为无效的句柄值, 而其他句柄则使用0。For example, some handles use -1 as an invalid handle value, while others use 0. 此类的进一步派生 (如文件或注册表句柄) 可以进一步专用化。Further derivations of this class (for example, file or registry handles) can specialize this further.

如果需要包装没有现有托管包装的非托管资源, 请使用类。CriticalHandleZeroOrMinusOneIsInvalidUse the CriticalHandleZeroOrMinusOneIsInvalid class when you need to wrap an unmanaged resource that does not have an existing managed wrapper.

此类型实现 IDisposable 接口。This type implements the IDisposable interface. 在使用完类型后,您应直接或间接释放类型。When you have finished using the type, you should dispose of it either directly or indirectly. 若要直接释放类型,请在 try/catch 块中调用其 Dispose 方法。To dispose of the type directly, call its Dispose method in a try/catch block. 若要间接释放类型,请使用 using(在 C# 中)或 Using(在 Visual Basic 中)等语言构造。To dispose of it indirectly, use a language construct such as using (in C#) or Using (in Visual Basic). 有关详细信息,请参阅 IDisposable 接口主题中的“使用实现 IDisposable 的对象”一节。For more information, see the "Using an Object that Implements IDisposable" section in the IDisposable interface topic.

备注

有关关键处理安全和线程安全的重要信息, 请参阅类。CriticalHandleSee the CriticalHandle class for important information on critical handle security and thread safety.

构造函数

CriticalHandleZeroOrMinusOneIsInvalid()

初始化 CriticalHandleZeroOrMinusOneIsInvalid 类的新实例。Initializes a new instance of the CriticalHandleZeroOrMinusOneIsInvalid class.

字段

handle

指定要包装的句柄。Specifies the handle to be wrapped.

(继承自 CriticalHandle)

属性

IsClosed

获取一个值,该值指示句柄是否已关闭。Gets a value indicating whether the handle is closed.

(继承自 CriticalHandle)
IsInvalid

获取一个值,该值指示句柄是否无效。Gets a value that indicates whether the handle is invalid.

方法

Close()

标记句柄,以便释放资源。Marks the handle for releasing and freeing resources.

(继承自 CriticalHandle)
Dispose()

释放由 CriticalHandle 使用的所有资源。Releases all resources used by the CriticalHandle.

(继承自 CriticalHandle)
Dispose(Boolean)

释放 CriticalHandle 类所使用的非托管资源,并指定是否执行常规释放 (Dispose) 操作。Releases the unmanaged resources used by the CriticalHandle class specifying whether to perform a normal dispose operation.

(继承自 CriticalHandle)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ReleaseHandle()

如果在派生类中重写,执行释放句柄所需的代码。When overridden in a derived class, executes the code required to free the handle.

(继承自 CriticalHandle)
SetHandle(IntPtr)

将句柄设置为预先存在的指定句柄。Sets the handle to the specified pre-existing handle.

(继承自 CriticalHandle)
SetHandleAsInvalid()

将句柄标记为无效。Marks a handle as invalid.

(继承自 CriticalHandle)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

安全性

InheritanceDemand
完全信任继承者。for full trust for inheritors. 部分受信任的代码不能继承此成员。This member cannot be inherited by partially trusted code.

SecurityCriticalAttribute
需要对直接调用方的完全信任。requires full trust for the immediate caller. 部分受信任的或透明的代码不能使用此成员。This member cannot be used by partially trusted or transparent code.

适用于

另请参阅