Passing strings to C++ DLL
- From: "Andy Baker" <abaker@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 2 Jul 2008 12:17:45 +0100
I am attempting to write a .NET wrapper for a C++ DLL file, but am having
problems with passing strings as parameters. How should I be writing my C#
function call when the C header file is definined as taking a char * as an
argument? For example the C++ header says
SDCERR GetCurrentConfig(DWORD *num, char *name);
I am using Uint for the *num parameter, which returns the correct value
but for *name, I always get back a string of 6 squares. I have tried using
string, StringBuilder and char arrays, and passing by ref and not, but
always get the same result.
Connected to this I am also having problems with passing structures for
C++ functions - the structures contain strings as well. Whenever I call a
function that requires a structure as a parameter, I always get a
NotSupportedException, does this just mean that I have defined my structure
incorrectly? Do I have to initailise the structure beforehand (have tried
this but still didn't work)?
I am using Visual Studio 2005, and if it makes a difference it is for a
Compact Framework device. Thanks in advance for any help.
Andy Baker
.
- Follow-Ups:
- RE: Passing strings to C++ DLL
- From: KH
- Re: Passing strings to C++ DLL
- From: Pavel Minaev
- Re: Passing strings to C++ DLL
- From: puggid
- RE: Passing strings to C++ DLL
- Prev by Date: Re: Non Standard fontstyles
- Next by Date: Re: C# "expert" in two weeks
- Previous by thread: RE: WPF: Use MultiBinding to bind end of line to a thumb
- Next by thread: Re: Passing strings to C++ DLL
- Index(es):
Relevant Pages
|