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

pass fixed string by ref

P: n/a
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


Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies

P: n/a
"Cc" <ko*****@singnet.com.sg> schrieb:
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?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #2

P: n/a
Have you looked at the MarshalAs attribute?

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Cc" <ko*****@singnet.com.sg> wrote in message
news:eO**************@tk2msftngp13.phx.gbl...
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

Nov 21 '05 #3

P: n/a
Cc
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

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ut****************@TK2MSFTNGP15.phx.gbl...
"Cc" <ko*****@singnet.com.sg> schrieb:
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?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

P: n/a
"Cc" <ko*****@singnet.com.sg> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5

P: n/a
Cc
it's works, thks

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
"Cc" <ko*****@singnet.com.sg> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.