Would someone help me figure out the signature for this struct [1]?
Thanks.
[1]
typedef struct _DATA
{
WCHAR wzName[24];
WCHAR wzKey[30];
VERSION version;
BYTE hash[76];
} DATA, *_DATA;
enum VERSION
{
A = 1,
B = 2
};
Jared Parsons [MSFT] - 26 Jan 2005 19:31 GMT
Try
[StructLayout(LayoutKind.Sequential, Pack=4)]
public struct _Data
{
IntPtr wzName;
IntPtr wzKey;
Version version;
IntPtr hash
}
public enum Version
{
A = 1,
B = 2
}

Signature
Jared Parsons [MSFT]
jaredpar@online.microsoft.com
"This posting is provided "AS IS" with no warranties, and confers no rights"
> Would someone help me figure out the signature for this struct [1]?
>
[quoted text clipped - 15 lines]
> B = 2
> };
Tom Glen - 26 Jan 2005 20:22 GMT
Thanks Jared. I hadn't anticipated a solution using IntPtr's. Doesn't this
mean I will have to mess with allocating memory and use GCHandle to make
sure it's pinned...etc?
> Try
>
[quoted text clipped - 32 lines]
>> B = 2
>> };
Jared Parsons [MSFT] - 26 Jan 2005 21:16 GMT
I haven't done a ton of interopt but the way that I normally take care of it
is to just marshal the pointers over to strings and explicitly free the
memory in the struct. I haven't ever had to pin any memory (or I have and
I've just gotten lucky : ) )
Jared

Signature
Jared Parsons [MSFT]
jaredpar@online.microsoft.com
"This posting is provided "AS IS" with no warranties, and confers no rights"
> Thanks Jared. I hadn't anticipated a solution using IntPtr's. Doesn't this
> mean I will have to mess with allocating memory and use GCHandle to make
[quoted text clipped - 36 lines]
> >> B = 2
> >> };
Mattias Sj?gren - 26 Jan 2005 21:19 GMT
>Would someone help me figure out the signature for this struct [1]?
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
struct DATA
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=24)]
public string wzName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=30)]
public string wzKey;
public Version version;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=76)]
public byte[] hash;
}
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Tom Glen - 26 Jan 2005 21:39 GMT
Thanks Mattias!
>>Would someone help me figure out the signature for this struct [1]?
>
[quoted text clipped - 11 lines]
>
> Mattias