private /*MMAL_COMPONENT_T*/ IntPtr CreateComponentHandle(MMALComponentName componentName) { Console.WriteLine("Creating component " + componentName.Value); //var status = NativeMethods.ComponentCreate(componentName.Value, out MMAL_COMPONENT_T handle); //if (status != MMAL_STATUS_T.MMAL_SUCCESS) // throw new MMALException(status); //handle.DumpFields(); //return handle; var status = MMALNativeMethods.ComponentCreate(componentName.Value, out IntPtr handle); if (status != MMAL_STATUS_T.MMAL_SUCCESS) { throw new MMALException(status); } return(handle); //Console.WriteLine($"Ptr={handle}"); //for (int i = 1; i <= 100; i++) //{ // byte b = Marshal.ReadByte(handle, i - 1); // Console.Write("{0:X2} ", b); // if (i % 16 == 0) // Console.WriteLine(); // else if (i % 8 == 0) // Console.Write(" "); //} //IntPtr namePtr = Marshal.ReadIntPtr(handle, Marshal.SizeOf<IntPtr>() * 2); //Console.WriteLine($"namePtr={namePtr}"); //string name = Marshal.PtrToStringAnsi(namePtr); //Console.WriteLine($"name={name}"); //MMAL_COMPONENT_T comp = Marshal.PtrToStructure<MMAL_COMPONENT_T>(handle); //comp.DumpFields(); ////throw new NotImplementedException(); //return comp; }