掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
構造体->Byte配列->構造体とコピーする方法は? (ID:120571)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
> Dim B() As Byte = {37, 82, 154, 68, 22, 66, 33, 44} > Structure TEST1_T > Dim test1_1 As Short > Dim test1_2 As Short > Dim test1_3 As Short > Dim test1_4 As Short > End Structure こんな感じ。 Dim B() As Byte = {37, 82, 154, 68, 22, 66, 33, 44} Dim test As TEST1_T Dim P As System.IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(TEST1_T))) Marshal.Copy(B, 0, P, B.Length) test = DirectCast(Marshal.PtrToStructure(P, GetType(TEST1_T)), TEST1_T) System.Runtime.InteropServices.Marshal.FreeHGlobal(P) Trace.WriteLine(String.Format("{0}(0x{0:x}),{1}(0x{1:x}),{2}(0x{2:x}),{3}(0x{3:x})", _ test.test1_1, test.test1_2, test.test1_3, test.test1_4))
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.