Created
September 30, 2014 07:09
-
-
Save betaEncoder/a5c06dfa310ca7e9c539 to your computer and use it in GitHub Desktop.
C#でwin32API等を呼び出す時に構造体をmarshal時にアンマネージド変数のようにパッキングしてもらう覚書き
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Runtime.InteropServices; | |
// 構造体の中身をきっちりパッキングする | |
[StructLayout(LayoutKind.Sequential)] | |
struct message | |
{ | |
public byte foo; | |
public byte bar; | |
public uint16 boo; | |
// 構造体に配列を含めたいとき | |
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 240)] | |
public byte[] dataArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment