By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,530 Members | 880 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,530 IT Pros & Developers. It's quick & easy.

Dll Import Question

P: n/a
Hi, am calling a C DLL from a CSharp app. The function I'm calling
takes a pointer to a structure with two fixed length embedded Unicode
strings. The problem is that the only way that seems to work so far
is to pretend my arrays of Unicode characters are Int16's.

Is there a better way do this? If not, what is the easiest way to
get my arrays of Int16's into a String?

Thanks very much,
Jenny C.

typedef struct
{
int propertyID;
TCHAR name[64]; // Unicode String
TCHAR displayText[64]; // Unicode String
int attribs;
int listID;
int elementType;
int elementCount;
int byteCount;
Int64 limitLo;
Int64 limitHi;
int units;
} JSR_Info ;

C++ call:

int JSR_GetInfo( int handle, int id, JSR_Info *pInfo);


[ StructLayout( LayoutKind.Sequential )]
public class JSR_Info
{
public int propertyID;
[ MarshalAs( UnmanagedType.ByValArray, SizeConst=64 )]
public Int16 [] name;
[ MarshalAs( UnmanagedType.ByValArray, SizeConst=64 )]
public Int16 [] displayText;
public int attribs;
public int listID;
public int elementType;
public int elementCount;
public int byteCount;
public Int64 limitLo;
public Int64 limitHi;
public int units;
};
[DllImport("JSR_Common.dll", CharSet=CharSet.Unicode)]
public static extern int JSR_GetInfo(int Handle,
int ID, [Out] JSR_Info ji);

Apr 20 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.