// Called just after invoking the COM method. The IntPtr is the same one that just got returned // from MarshalManagedToNative. The return value is unused. override public object MarshalNativeToManaged(IntPtr pNativeData) { DvdKaraokeAttributes dka = m_obj as DvdKaraokeAttributes; // Copy in the value, and advance the pointer dka.bVersion = (byte)Marshal.ReadByte(pNativeData); pNativeData = (IntPtr)(pNativeData.ToInt64() + Marshal.SizeOf(typeof(byte))); // DWORD Align pNativeData = (IntPtr)(pNativeData.ToInt64() + 3); // Copy in the value, and advance the pointer dka.fMasterOfCeremoniesInGuideVocal1 = Marshal.ReadInt32(pNativeData) != 0; pNativeData = (IntPtr)(pNativeData.ToInt64() + Marshal.SizeOf(typeof(bool))); // Copy in the value, and advance the pointer dka.fDuet = Marshal.ReadInt32(pNativeData) != 0; pNativeData = (IntPtr)(pNativeData.ToInt64() + Marshal.SizeOf(typeof(bool))); // Copy in the value, and advance the pointer dka.ChannelAssignment = (DvdKaraokeAssignment)Marshal.ReadInt32(pNativeData); pNativeData = (IntPtr)(pNativeData.ToInt64() + Marshal.SizeOf(DvdKaraokeAssignment.GetUnderlyingType(typeof(DvdKaraokeAssignment)))); // Allocate a large enough array to hold all the returned structs. dka.wChannelContents = new DvdKaraokeContents[8]; for (int x = 0; x < 8; x++) { // Copy in the value, and advance the pointer dka.wChannelContents[x] = (DvdKaraokeContents)Marshal.ReadInt16(pNativeData); pNativeData = (IntPtr)(pNativeData.ToInt64() + Marshal.SizeOf(DvdKaraokeContents.GetUnderlyingType(typeof(DvdKaraokeContents)))); } return(null); }
void TestMisc() { int hr; DvdVideoAttributes pVATR; SPRMArray pRegisterArray; hr = m_idi2.GetAllSPRMs(out pRegisterArray); DsError.ThrowExceptionForHR(hr); Debug.Assert(pRegisterArray.registers[0] == 25966, "GetAllSPRMs"); hr = m_idi2.GetCurrentVideoAttributes(out pVATR); DsError.ThrowExceptionForHR(hr); Debug.Assert(pVATR.sourceResolutionX == 720, "GetCurrentVideoAttributes"); // This won't work for non-karaoke disks DvdKaraokeAttributes pKATR = new DvdKaraokeAttributes(); hr = m_idi2.GetKaraokeAttributes(0, pKATR); //DsError.ThrowExceptionForHR(hr); }