Hi Everybody.
I've got to use the following function of a C++ DLL:
CT_data (
unsigned short Ctn,
unsigned char *Dad,
unsigned char *Sad,
unsigned short Lc,
unsigned char *Cmd,
unsigned short *Lr,
unsigned char *Rsp
);
I've declared the following
[DllImport("ctscrw2k.dll", SetLastError=true, CharSet=CharSet.Ansi)]
private static extern int CT_data(ushort Ctn, ref ushort Dad, ref ushort
Sad, ushort Lc, char[] Cmd, ref ushort Lr, ref char[] Rsp);
The parameters Cmd and Rsp each are char[] arrays. The last parameter Rsp
is used as an response buffer, an i need to get a reference to the
RSP value to the imported function.
I always get this Exception:
MarshalDirectiveException: Can not marshal parameter #7. Ansi char arrays
can not be Marshaled as byref or as an unmanaged-to-managed parameter.
How can i solve this problem?
Regards
Mario Schymura 1 2842
Hi,
inline
"MarioSchymura" <Ma************@stock.informatik.com> wrote in message
news:Oz**************@TK2MSFTNGP12.phx.gbl... Hi Everybody.
I've got to use the following function of a C++ DLL: CT_data ( unsigned short Ctn, unsigned char *Dad, unsigned char *Sad, unsigned short Lc, unsigned char *Cmd, unsigned short *Lr, unsigned char *Rsp );
I've declared the following
[DllImport("ctscrw2k.dll", SetLastError=true, CharSet=CharSet.Ansi)] private static extern int CT_data(ushort Ctn, ref ushort Dad, ref ushort Sad, ushort Lc, char[] Cmd, ref ushort Lr, ref char[] Rsp);
[DllImport("ctscrw2k.dll", SetLastError=true, CharSet=CharSet.Ansi)]
private static extern int CT_data(ushort Ctn, ref byte Dad, ref byte Sad,
ushort Lc, char[] Cmd, ref ushort Lr, [In,Out] char[] Rsp);
unsigned char* Rsp;
The pointer can't change if you only pass a pointer. So if Rsp is really
only a char*, then you must allocate memory for rsp (using new char[...])
before calling the function.
HTH,
greetings
The parameters Cmd and Rsp each are char[] arrays. The last parameter Rsp is used as an response buffer, an i need to get a reference to the RSP value to the imported function.
I always get this Exception: MarshalDirectiveException: Can not marshal parameter #7. Ansi char arrays can not be Marshaled as byref or as an unmanaged-to-managed parameter.
How can i solve this problem?
Regards Mario Schymura
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: jab3 |
last post by:
(again :))
Hello everyone.
I'll ask this even at risk of being accused of not researching adequately.
My question (before longer reasoning) is: How does declaring (or defining,
whatever) a...
|
by: Stephen Gennard |
last post by:
Hello,
I having a problem dynamically invoking a static method that takes a
reference to a SByte*. If I do it directly it works just fine.
Anyone any ideas why?
I have include a example...
|
by: Rudy Velthuis |
last post by:
Hello,
Does anyone know how to create a struct that will marshal to the
following C++ struct A, containing an array of the user defined String10
type:
struct String10
{
char SLen;
char S;
|
by: Jeff |
last post by:
I am struggling with the following
How do I marshal/access a pointer to an array of strings within a structure
Than
Jef
----------------------------------------------------------------
|
by: Jeff |
last post by:
Hi guys
Mattias, thanx for answering my last question
Well, I'm struggling with marshaling a struct that has **ptr to an array of arrays of struct. Why? I'm stuck with it
1. I need to know...
|
by: Sin |
last post by:
Hello everybody,
I'm currently trying to understand how marshaling can use used for accessing
Win32 API functions as well as custom C/C++ code we design which exposes
functions the same way as...
|
by: Tom |
last post by:
I'm trying to pass this structure to a dll:
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _
Public Structure udtINTER01
<VBFixedString(8),...
|
by: Laurent |
last post by:
Hi again,
I created a thread some days ago, while I was trying to access a C++ DLL
using my C# program. First of all, I want to thanks all the guys who helped
me. But I still have a...
|
by: Aston Martin |
last post by:
Hi All,
********************** My Situation **********************
I am working on project that involves passing a structure to unmanaged
code from .Net world (well using C#). Perhaps an example...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
| |