Re: passing struct from vb to c dll
- From: "Henning" <computer_hero@xxxxxxxxxxxx>
- Date: Tue, 11 Jul 2006 13:41:09 +0200
<abhi.10dulkar@xxxxxxxxx> skrev i meddelandet
news:1152610732.377015.78160@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,MBRINFO.szMember is a fixed length string 80 characters. It will be what you
I am having some problem for getting values in struct from the c dll.
I have following definition
Type MBRINFO
szMember As String * 80 ' member name array
usLevel As Integer
End Type
I am passing this struct to c dll for getting back the values filled
from the dll
Declare Function GetMemberInfo Lib "xyz" (pInfo As MBRINFO) As Long
On c side I have code as following
struct MBRINFO
{
char szMember[80];
int usLevel;
}
long GetMemberInfo(MBRINFO * info)
{
long sts = 0;
memset(info,0,sizeof(MBRINFO ));
szMember(info->szMember,"Something");
info->usLevel = 10;
return sts;
}
The definition is exported from the xyz.dll for acess.
But, when I get value back on vb side, I noticed the value for szMember
is filled with assigned value which is "Something" folloed by lot of
space characters. Can somebody help me figure out how to avoid this
issue.
Thanks,
Abhijeet
say, 'Something' + 70 spaces. To get what you really want, you have to add a
f.ex. 'null' delimiter after 'Something' in the dll. Then you can extract
'Something' by:
Dim strMember As String
With pInfo
strMember = Left$(.szMember, Instr(.szMember, chr$(0)) -1)
End With
/Henning
.
- Follow-Ups:
- Re: passing struct from vb to c dll
- From: abhi . 10dulkar
- Re: passing struct from vb to c dll
- References:
- passing struct from vb to c dll
- From: abhi . 10dulkar
- passing struct from vb to c dll
- Prev by Date: Re: passing struct from vb to c dll
- Next by Date: Re: Computer of the net
- Previous by thread: Re: passing struct from vb to c dll
- Next by thread: Re: passing struct from vb to c dll
- Index(es):
Relevant Pages
|