PtrReader

Ecng.Interop

Provides methods to read data from an unmanaged memory pointer.

构造函数

PtrReader
public PtrReader(IntPtr ptr)
ptrReader = PtrReader(ptr)

Initializes a new instance of the PtrReader class with the specified pointer.

ptr
The unmanaged memory pointer to read from.

属性

Ptr
public IntPtr Ptr { get; set; }
value = ptrReader.Ptr
ptrReader.Ptr = value

Gets or sets the unmanaged memory pointer.

方法

GetByte
public byte GetByte()
result = ptrReader.GetByte()

Reads a byte from the current pointer and advances the pointer by the size of a byte.

返回值: The byte read from the pointer.

GetInt
public int GetInt()
result = ptrReader.GetInt()

Reads a 32-bit integer from the current pointer and advances the pointer by the size of an integer.

返回值: The 32-bit integer read from the pointer.

GetIntPtr
public IntPtr GetIntPtr()
result = ptrReader.GetIntPtr()

Reads an IntPtr from the current pointer and advances the pointer by the size of an IntPtr.

返回值: The IntPtr read from the pointer.

GetLong
public long GetLong()
result = ptrReader.GetLong()

Reads a 64-bit integer from the current pointer and advances the pointer by the size of a long.

返回值: The 64-bit integer read from the pointer.

GetShort
public short GetShort()
result = ptrReader.GetShort()

Reads a 16-bit integer from the current pointer and advances the pointer by the size of a short.

返回值: The 16-bit integer read from the pointer.

GetString
public string GetString()
result = ptrReader.GetString()

Reads a null-terminated ANSI string from the current pointer and advances the pointer by the size of an IntPtr.

返回值: The ANSI string read from the pointer. If the string is null, an empty string is returned.

GetString
public string GetString(int length)
result = ptrReader.GetString(length)

Reads an ANSI string of the specified length from the current pointer and advances the pointer by the specified length.

length
The length of the string to read.

返回值: The ANSI string read from the pointer. If the string is null, an empty string is returned.