|
-
October 21st, 2002, 11:18 PM
#1
marshal char[]
I am trying to interface with a dll that uses this typedef.
typedef struct{
char szGroupKey[64]; // grouping key
char szCoordSysKey[64]; // system key
char szDatumKey[64]; // datum key
char szUnitKey[64]; // unit key
} COORDSYSTEM;
I've tried
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=64 )]
[ MarshalAs( UnmanagedType.ByValArray, SizeConst=64 )]
and god knows what else.
I am going slighty insane;
Any help would be GREATLY appreciated;
Thanks
-
October 22nd, 2002, 03:36 AM
#2
Try CharSet = CharSet.Ansi in DllImport directive.
Read also this article:
http://msdn.microsoft.com/library/de...rp09192002.asp
-
October 22nd, 2002, 10:41 AM
#3
CharSet.Ansi gives me errors
This isn't throwing errors, but it still isn't working right:
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto )]
public struct COORDSYSTEM
{
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=64 )]
public string szGroupKey; // grouping key
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=64 )]
public string szCoordSysKey; // system key
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=64 )]
public string szDatumKey; // datum key
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=64 )]
public string szUnitKey; // unit key
}
I've gotten it to work great in VB with this:
Type COORDSYSTEM
szGroupKey As String * 64
szCoordSysKey As String * 64
szDatumKey As String * 64
szUnitKey As String * 64
End Type
-
February 23rd, 2007, 09:44 PM
#4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|