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

  • Thread starter Thread starter Pucca
  • Start date Start date
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.?
 
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.
 
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.
 
Back
Top