473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

pass fixed string by ref

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
5 3414
"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
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
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: Adrian Parker | last post by:
I'm using the code below in my project. When I print all of these fixed length string variables, one per line, they strings in questions do not properly pad with 0s. strQuantity prints as " ...
18
by: happyvalley | last post by:
Hi, basically, the test function get a char pointer, and assigned a string to it. then the string is passed back by the call-by-reference mechanism. in test(), I reallocate some memory for the...
1
by: O.B. | last post by:
In the example below, I'm trying to convert a fixed byte array to a string. I get an error about needing to use "fixed" but I have no clue where to apply it. Help? using System; using...
1
by: Rick Knospler | last post by:
I am trying to convert a vb6 project to vb.net. The conversion worked for the most part except for the fixed length strings and fixed length string arrays. Bascially the vb6 programmer stored all...
5
by: Larry Bud | last post by:
I'm writing a class to create a specifically formatted fixed width file. It's 800 characters wide, consisting of approx 30 fields. So I need to pass 30 variables, maybe 10 are required. Should...
11
by: venkatagmail | last post by:
I have problem understanding pass by value and pass by reference and want to how how they are or appear in the memory: I had to get my basics right again. I create an array and try all possible...
1
by: marjipie | last post by:
Hi, My problem goes like this, i created a wrapper for a third party DLL, and one of the functions is: 6.1.5.4 GetUsbDevicesNameEnum PROTOTYPE I C_MORPHO_Device::GetUsbDevicesNameEnum ( UL...
5
by: marshmallowww | last post by:
I have an Access 2000 mde application which uses ADO and pass through queries to communicate with SQL Server 7, 2000 or 2005. Some of my customers, especially those with SQL Server 2005, have had...
4
by: S. | last post by:
Hi all, I have the requirement that I must pass-by-reference to my function addStudent() and getAge() functions where my getAge() function is within the addStudent() function. I am able to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.