C# String conversion

  • Thread starter Thread starter Neomite
  • Start date Start date
N

Neomite

Hi, I'm having some difficulty converting a String to a std::basic_string
(c++).

I've tried using StringBuilder and Marshal.LPxxxx , no luck.

I consistently get AccessViolation errors.

I've been reading all day but I can't seem to find the same problem posted
anywhere.

bool NNSMCAPI::Client::initialize(class std::basic_string<unsigned
short,struct std::char_traits<unsigned short>,class std::allocator<unsigned
short> > const &)

Can anyone help me with this issue?

thanks!
 
It wont work becuase Marshal.LPxxxx does not convert to basic_string, but
only gets you a pointer to the raw string charcters in memory.

You can try using a wrapper around your function which takes LPTSTR, this
way you can use Marshal.LPxxxx

---------
- G Himangi, LogicNP Software http://www.ssware.com
Shell MegaPack: GUI Controls For Drop-In Windows Explorer like File/Folder
Browsing Functionality (.Net & ActiveX Editions).
EZNamespaceExtensions: Develop namespace extensions rapidly in .Net and
MFC/ATL/C++
EZShellExtensions: Develop all shell extensions,explorer bars and BHOs
rapidly in .Net & MFC/ATL/C++
 
I read a few similiar posts that talked about using StringBuilder? Are you
familiar with this approach?
 
Yes, but that works only if data flow is from called function to yourself.
In this case, if i understand correctly, its the other way round.

---------
- G Himangi, LogicNP Software http://www.ssware.com
Shell MegaPack: GUI Controls For Drop-In Windows Explorer like File/Folder
Browsing Functionality (.Net & ActiveX Editions).
EZNamespaceExtensions: Develop namespace extensions rapidly in .Net and
MFC/ATL/C++
EZShellExtensions: Develop all shell extensions,explorer bars and BHOs
rapidly in .Net & MFC/ATL/C++
---------
 

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

Back
Top