Name

Marshal

Synopsis

This class offers a collection of shared methods for working with unmanaged memory and converting managed types to unmanaged types. Unless you are developing specialized code for marshaling types between managed and unmanaged code, you probably do not need to use any of these methods.

GetHRForException() converts a .NET exception to a COM HResult. If you are curious about the platform you are running on, you can find out the size of a character with the SystemDefaultCharSize field, which is 1 on an ANSI platform (Windows 9x/ME) and 2 on a Unicode platform (Windows NT, 2000, and XP).

Use the IsComObject() method to determine whether an object is actually an unmanaged COM object. The AddRef() method increments a COM object’s reference count.

Public NotInheritable Class Marshal
                  ' Public Shared Fields
   Public Shared ReadOnly SystemDefaultCharSize As Integer       // =2
   Public Shared ReadOnly SystemMaxDBCSCharSize As Integer       // =1
                  ' Public Shared Methods
   Public Shared Function AddRef(
        ByVal pUnk As IntPtr) As Integer  
   Public Shared Function AllocCoTaskMem(
        ByVal cb As Integer) As IntPtr  
   Public Shared Function AllocHGlobal(
        ByVal cb As Integer) As IntPtr  
   Public Shared Function AllocHGlobal(
        ByVal cb As IntPtr) As IntPtr  
   Public Shared Function BindToMoniker(
        ByVal monikerName As String) As Object  
   Public Shared Sub ChangeWrapperHandleStrength(
        ByVal otp As Object, ByVal fIsWeak As Boolean) 
   Public Shared Sub Copy(ByVal source As Byte(), ByVal startIndex As Integer, ByVal destination ...

Get VB.NET Core Classes in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.