How do I marshal a C# string to call a C++ function that needs a L

P

Pucca

Hi, I need to call a funciton in a C++ Dll that requires 2 LPCWSTR
parameters. How do I marshall this in my DLLIMPORT statement in C# (string
trpe)? Thank you.?
 
J

Jeroen Mostert

Pucca said:
Hi, I need to call a funciton in a C++ Dll that requires 2 LPCWSTR
parameters. How do I marshall this in my DLLIMPORT statement in C# (string
trpe)? Thank you.?
C# has no DLLIMPORT statements; I assume you mean external declarations
decorated with the DllImport attribute.

Decorate the arguments to pass with [MarshalAs(UnmanagedType.LPWStr)]. See
also http://msdn2.microsoft.com/en-us/library/s9ts558h.aspx.
 
P

Pucca

That worked. Thank you.
--
Thanks.


Jeroen Mostert said:
Pucca said:
Hi, I need to call a funciton in a C++ Dll that requires 2 LPCWSTR
parameters. How do I marshall this in my DLLIMPORT statement in C# (string
trpe)? Thank you.?
C# has no DLLIMPORT statements; I assume you mean external declarations
decorated with the DllImport attribute.

Decorate the arguments to pass with [MarshalAs(UnmanagedType.LPWStr)]. See
also http://msdn2.microsoft.com/en-us/library/s9ts558h.aspx.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top