private midiInAddBuffer ( HMIDIIN hMidiIn, |
||
hMidiIn | HMIDIIN | |
lpMidiInHdr | ||
cbMidiInHdr | ||
리턴 | MMRESULT |
private IntPtr RecycleLongMsgBuffer(UIntPtr ptr) { IntPtr newPtr = unchecked ((IntPtr)(long)(ulong)ptr); UInt32 size = (UInt32)Marshal.SizeOf <Win32API.MIDIHDR>(); CheckReturnCode(Win32API.midiInUnprepareHeader(handle, newPtr, size)); CheckReturnCode(Win32API.midiInPrepareHeader(handle, newPtr, size)); CheckReturnCode(Win32API.midiInAddBuffer(handle, newPtr, size)); //return unchecked((UIntPtr)(ulong)(long)newPtr); return(newPtr); }
private IntPtr RecycleLongMsgBuffer(UIntPtr ptr) { IntPtr newPtr = unchecked ((IntPtr)(long)(ulong)ptr); UInt32 size = (UInt32)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Win32API.MIDIHDR)); CheckReturnCode(Win32API.midiInUnprepareHeader(handle, newPtr, size)); CheckReturnCode(Win32API.midiInPrepareHeader(handle, newPtr, size)); CheckReturnCode(Win32API.midiInAddBuffer(handle, newPtr, size)); //return unchecked((UIntPtr)(ulong)(long)newPtr); return(newPtr); }
private IntPtr CreateLongMsgBuffer() { //add a buffer so we can receive SysEx messages IntPtr ptr; UInt32 size = (UInt32)Marshal.SizeOf <Win32API.MIDIHDR>(); Win32API.MIDIHDR header = new Win32API.MIDIHDR { lpData = Marshal.AllocHGlobal(4096), dwBufferLength = 4096, dwFlags = 0 }; try { ptr = Marshal.AllocHGlobal(Marshal.SizeOf <Win32API.MIDIHDR>()); } catch (Exception) { System.Runtime.InteropServices.Marshal.FreeHGlobal(header.lpData); throw; } try { System.Runtime.InteropServices.Marshal.StructureToPtr(header, ptr, false); } catch (Exception) { System.Runtime.InteropServices.Marshal.FreeHGlobal(header.lpData); System.Runtime.InteropServices.Marshal.FreeHGlobal(ptr); throw; } CheckReturnCode(Win32API.midiInPrepareHeader(handle, ptr, size)); CheckReturnCode(Win32API.midiInAddBuffer(handle, ptr, size)); //CheckReturnCode(Win32API.midiInUnprepareHeader(handle, ptr, size)); return(ptr); }