Marshal.AllocHGlobal : Marshal « System.Runtime.InteropServices « C# / C Sharp by API






Marshal.AllocHGlobal

 

using System;
using System.Runtime.InteropServices;

public class MainClass
{
  [STAThread]
  static void Main(string[] args)
  {
    IntPtr ptr = IntPtr.Zero;

    ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)));
    Marshal.FreeHGlobal(ptr);
  }
}

   
  








Related examples in the same category

1.Marshal.AllocCoTaskMem
2.Marshal.FreeHGlobal
3.Marshal.StringToCoTaskMemAnsi