Passing strings to C++ DLL



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



.



Relevant Pages

  • Re: blank response from curl when posting form data
    ... under 800 characters, everything works. ... I tried passing the post data in strings, ...
    (comp.lang.php)
  • Re: Passing strings to C++ DLL
    ... problems with passing strings as parameters. ... function call when the C header file is definined as taking a char * as an ...     I am using Uint for the *num parameter, ... C++ functions - the structures contain strings as well. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Specifying parameter passing convention and place (register)
    ... but they say nothing of the passing 'place' (specific ... > where data passed between languages will never include bounded strings, ... we might have the following declarations ... in this package: ...
    (comp.lang.ada)
  • something strange with new process Arguments
    ... I'm starting a new process and passing it some arguments to look at a ... The folder gets created correctly. ... I figure it has to be an encoding problem somewhere among the various ... possible encodings and passings of strings going on. ...
    (microsoft.public.dotnet.general)
  • Re: C# Object parameters in Outlook and Office methods
    ... passing a strings to GetItemFromID works for me. ... object par = mystring; ...
    (microsoft.public.outlook.program_addins)