public void Free()
 {
     if (this.rgodf != null)
         {
         for (int i = 0; i < this.dwNumObjs; i++)
             {
             this.rgodf[i].Free();
             }
         Marshal.FreeCoTaskMem((IntPtr)this.rgodf);
         this.rgodf = null;
         this.dwNumObjs = 0;
         }
 }
 public void Init(int dwNumObjs)
 {
     this.dwSize     = Marshal.SizeOf(this);
     this.dwObjSize  = Marshal.SizeOf(typeof(DIOBJECTDATAFORMAT));
     this.dwFlags    = 0;
     this.dwDataSize = 0;
     this.rgodf      = null;
     this.dwNumObjs  = 0;
     Alloc(dwNumObjs);
 }
 public void Alloc(int dwNumObjs)
 {
     Free();
     //
     int cb         = this.dwObjSize * dwNumObjs;
     this.rgodf     = (DIOBJECTDATAFORMAT*)Marshal.AllocCoTaskMem(cb);
     this.dwNumObjs = dwNumObjs;
     for (int i = 0; i < this.dwNumObjs; i++)
         {
         this.rgodf[i].Init();
         }
 }