Код: Выделить всё
typedef struct _EC_VARIANT {
union {
BOOL BooleanVal;
UINT32 UInt32Val;
ULONGLONG DateTimeVal;
LPCWSTR StringVal;
PBYTE BinaryVal;
BOOL *BooleanArr;
INT32 *Int32Arr;
LPWSTR *StringArr;
EC_OBJECT_ARRAY_PROPERTY_HANDLE PropertyHandleVal;
};
DWORD Count;
DWORD Type;
} EC_VARIANT, *PEC_VARIANT;
я пробую этот код:< /p>
Код: Выделить всё
uint get = Internals.EcOpenSubscription("adfs", (uint)WecAcessTypes.EC_READ_ACCESS, (uint)WecFlags.EC_OPEN_EXISTING);
Console.WriteLine($"addr :{get}");
byte[] some = new byte[16];
uint a = 0;
bool success = Internals.EcGetSubscriptionProperty(get, (uint)EC_SUBSCRIPTION_PROPERTY_ID.EcSubscriptionEventSources, 0, 128, some, out a);
if (!success)
{
Console.WriteLine("err EcSubscriptionEventSources");
Console.ReadKey();
return;
}
foreach (byte b in some)
{
Console.Write(b);
}
GCHandle gCHandle = GCHandle.Alloc(some, GCHandleType.Pinned);
EC_VARIANT eC = (EC_VARIANT)Marshal.PtrToStructure(gCHandle.AddrOfPinnedObject(), typeof(EC_VARIANT));
Console.WriteLine($"\n{eC.Type} {eC.EC_OBJECT_ARRAY_PROPERTY_HANDLE}");
Console.WriteLine($"length {a}");
Console.ReadKey();
Код: Выделить всё
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct EC_VARIANT
{
public uint BooleanVal;
public uint UInt32Val;
public ulong DateTimeVal;
public IntPtr StringVal;
public IntPtr BinaryVal;
public IntPtr BoolArr;
public IntPtr Int32Arr;
public IntPtr StringArr;
public int EC_OBJECT_ARRAY_PROPERTY_HANDLE;
public int Type;
public int Count;
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... to-c-sharp