KeyboardStruct kfromBytes(byte[] arr) { KeyboardStruct mystruct = new KeyboardStruct(); int size = Marshal.SizeOf(mystruct); IntPtr ptr = Marshal.AllocHGlobal(size); Marshal.Copy(arr, 0, ptr, size); mystruct = (KeyboardStruct)Marshal.PtrToStructure(ptr, mystruct.GetType()); Marshal.FreeHGlobal(ptr); return(mystruct); }
KeyboardStruct kfromBytes(byte[] arr) { KeyboardStruct mystruct = new KeyboardStruct(); int size = Marshal.SizeOf(mystruct); IntPtr ptr = Marshal.AllocHGlobal(size); Marshal.Copy(arr, 0, ptr, size); mystruct = (KeyboardStruct)Marshal.PtrToStructure(ptr, mystruct.GetType()); Marshal.FreeHGlobal(ptr); return mystruct; }