pass fixed string by ref

  • Thread starter Thread starter Cc
  • Start date Start date
C

Cc

hi,
how do I pass fixed string byref to a dll . I had try
<VBFixedString(10)>

but when I run I keep getting system.accessviolation



Any help would be great
 
Cc said:
how do I pass fixed string byref to a dll . I had try
<VBFixedString(10)>

but when I run I keep getting system.accessviolation

Can you post the C/C++ function prototype and your 'Declare' statement?
 
thks for reply,
here the declaration in c

struct tEZL_GETLASTTRAN {
long device_id;
long result;
char tranDate[10];
char tranTime[8];
long tranValue;
int svcProviderId;
int tranType;
};

extern "C" __declspec(dllexport) int ezif_getlasttran(struct
tEZL_GETLASTTRAN *pkt);

and on vb.net

Public Structure tEZL_getLastTran

Public device_id As Integer

Public result As Integer

<VBFixedString(10)> Public tranDate As String

<VBFixedString(8)> Public tranTime As String

Public tranValue As Integer

Public svcProviderId As Short

Public tranType As Short

End Structure



<DllImport("EZLINTFC.DLL", EntryPoint:="ezif_getlasttran", _

SetLastError:=True, CharSet:=CharSet.Unicode, _

ExactSpelling:=True, _

CallingConvention:=CallingConvention.Cdecl)> _

Private Shared Function ezif_getlasttran(ByRef arg_tEZL_getLastTran As
tEZL_getLastTran) As Short

' ' Leave function empty - DLLImport attribute

End Function
 
Cc said:
struct tEZL_GETLASTTRAN {
[...]
char tranDate[10];

The line above translates to this line:

\\\
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=10)> _
Public tranDate() As Char
///

Don't forget to specify the appropriate charset for the structure containing
this member.
 
it's works, thks

Herfried K. Wagner said:
Cc said:
struct tEZL_GETLASTTRAN {
[...]
char tranDate[10];

The line above translates to this line:

\\\
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=10)> _
Public tranDate() As Char
///

Don't forget to specify the appropriate charset for the structure
containing this member.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top