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
public abstract class CriticalHandleZeroOrMinusOneIsInvalid : System.Runtime.InteropServices.CriticalHandle
type CriticalHandleZeroOrMinusOneIsInvalid = class
    inherit CriticalHandle
Public MustInherit Class CriticalHandleZeroOrMinusOneIsInvalid
Inherits CriticalHandle
繼承
CriticalHandleZeroOrMinusOneIsInvalid
繼承
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.

當您需要包裝不具有現有受控包裝函式的未受管理資源時,請使用 CriticalHandleZeroOrMinusOneIsInvalid 類別。Use 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. 若要直接處置型別,請呼叫其 Disposetry/ 區塊中的 catch 方法。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.

注意

如需重要的處理安全性和執行緒安全性的重要資訊,請參閱 CriticalHandle 類別。See 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 類別所使用的 Unmanaged 資源,指定是否要執行一般處置作業。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 的淺層複本 (Shallow Copy)。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)

適用於

另請參閱