Why do I only get part of the string returned from this function?
I am trying to use a VB.net 2005 windows application to access function in an unmanaged c based dll that I do not have the source code. It is required to use this dll for reliable messaging with legacy systems. This dll contains a function to read a message off a queue and return the message string and status codes used to test for successfull completion. The function has the following prototype:
int32 pams_get_msg (
char * MsgArea,char * Priority,q_address * Source,short * msgClass,short * MsgType,short * MsgAreaLen,short * LenData,int32 * SelFilter,struct PSB * PSB,struct show_buffer * ShowBuff,int32 * ShowBuffLen,
int32 * LargeAreaLen,int32 * LargeSize,char * NullArg1);
Argument Data Type Mechanism Prototype Access
msg_area char reference char * returned
priority char reference char * passed
source q_address reference q_address * returned
class short reference short * returned
type short reference short * returned
msg_area_len short reference short * passed
len_data short reference short* returned
[sel_filter] int32 reference int32 * passed
[psb] struct psb reference struct psb * returned
[show_buffer] struct show_buffer reference struct show_buffer * returned
[show_buffer_len] int32 reference int32 * passed
[large_area_len] int32 reference int32 * passed/returned
[large_size] int32 reference int32 * returned
[nullarg_3] char reference char* passed
I have the function declare in VB as:
DeclareFunction pams_get_msgLib"dmq.dll" (ByVal MsgAreaAs StringBuilder,ByRef PriorityAsByte,ByRef SourceAs QAddress,ByRef msgClassAsShort,ByRef MsgTypeAsShort,ByRef MsgAreaLenAsShort,ByRef LenDataAsShort,ByRef SelFilterAsInteger,ByRef PSBAs PSB,ByRef ShowBuffAs ShowBuffer,ByRef ShowBuffLenAsInteger,ByRef LargeAreaLenAsInteger,ByRef LargeSizeAsInteger,ByVal NullArg1AsInteger)AsIntegerCalling code:
Dim msgAsNew StringBuilder(31500)Dim
statusAsIntegerStatic show_bufferAs ShowBufferDim show_bufflenAsIntegerDim large_area_lenAsIntegerDim large_sizeAsIntegerDim nullrefAsIntegershow_bufflen = SHOW_BUFFER_LEN
large_area_len = 0
nullref =
Nothingstatus = pams_get_msg(msg, msg.Priority, msg.SrcTarget, msg.dmqClass, msg.dmqType, 31500, msg.MsgLen, msg.SelFilter, msg.PSB, show_buffer, show_bufflen, large_area_len, large_size, nullref)
Result:
I get a good status and good return parameter values except for the message itself. I can only see the message number which is the first few characters in the string--NOT the entire message. Where is the rest of the string and how can I access it? If I make the msg size in VB (say msg(1024) )smaller than the actual message it knows it and fails, but as soon I make it big enough it succeeds but I can't see the whole message. Am I missing something in the unmanaged to managed transistion?
Thanks for any help!

