Now, as far as I can figure out, the _GUID is ISymWrapper and the _GUID in Microsoft.FlightSimulator.SimConnect are separate attempts to use the SDK struct GUID in managed code, and both define it as internal.
Nevertheless, the MSDN does give Managed C++ source code to covnert to/from a System.Guid.
So, with a little help from www.pinvoke.net and some puttering around, we get:
| |
[StructLayout(LayoutKind.Sequential, Size=0x10)]
struct _GUID { public Int32 Data1; public Int16 Data2; public Int16 Data3; [MarshalAs(UnmanagedType.ByValArray, SizeConst=8)] public byte[] Data4; }
Guid FromGUID(_GUID guid) { return new Guid(guid.Data1, guid.Data2, guid.Data3, guid.Data4[0],guid.Data4[1],guid.Data4[2], guid.Data4[3],guid.Data4[4],guid.Data4[5], guid.Data4[6],guid.Data4[7]); }
_GUID ToGUID(Guid guid) { _GUID newGuid = new _GUID(); byte[] guidData = guid.ToByteArray(); newGuid.Data1 = BitConverter.ToInt32(guidData, 0); newGuid.Data2 = BitConverter.ToInt16(guidData, 4); newGuid.Data3 = BitConverter.ToInt16(guidData, 6); newGuid.Data4 = new byte[8]; Array.Copy(guidData, 8, newGuid.Data4, 0, 8); return newGuid; } |
|