Click here to Skip to main content
15,892,674 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Marshal native string to managed string for wrapper DLL Pin
alleyes20-Oct-09 15:37
professionalalleyes20-Oct-09 15:37 
GeneralRe: Marshal native string to managed string for wrapper DLL Pin
Luc Pattyn20-Oct-09 15:40
sitebuilderLuc Pattyn20-Oct-09 15:40 
GeneralRe: Marshal native string to managed string for wrapper DLL Pin
alleyes20-Oct-09 15:58
professionalalleyes20-Oct-09 15:58 
GeneralRe: Marshal native string to managed string for wrapper DLL Pin
Luc Pattyn20-Oct-09 16:04
sitebuilderLuc Pattyn20-Oct-09 16:04 
GeneralRe: Marshal native string to managed string for wrapper DLL Pin
Andreoli Carlo21-Oct-09 2:46
professionalAndreoli Carlo21-Oct-09 2:46 
GeneralRe: Marshal native string to managed string for wrapper DLL Pin
alleyes21-Oct-09 8:53
professionalalleyes21-Oct-09 8:53 
GeneralRe: Marshal native string to managed string for wrapper DLL Pin
Mark Salsbery21-Oct-09 7:12
Mark Salsbery21-Oct-09 7:12 
GeneralRe: Marshal native string to managed string for wrapper DLL Pin
alleyes21-Oct-09 8:01
professionalalleyes21-Oct-09 8:01 
Thanks Mark,

An illustration goes a long way than a theoretical discussion.   I thought about the return type from the native code, what's been discussed and realized that rather than marshalling or converting it in the managed function, why not have the managed string object returned in native function.   That's one of the bigger bonuses of C++/CLI right?   So I decided to do the following:

<pre>

String^ SXNative::ReturnString()
{
   wchar_t Test[] = L"This is a dummy";
   msclr::auto_gcroot<String^> ret;

   wcscpy_s(retString, sizeof(Test) / sizeof(wchar_t), Test);
   ret = marshal_as<String^>(retString);
   return ret->ToString();
}

</pre>

<pre>

String^ ManagedWrapper::Managed_ReturnString()
{
   return nat_ptr->ReturnString();
}

</pre>

I want to say thanks again for posting the example because that may help someone else like it did for me.   I also want to post my solution as well as I feel that it shows an alternative solution.

Thanks again Mark   Big Grin | :-D

Al

Jer 29:11

GeneralRe: Marshal native string to managed string for wrapper DLL Pin
Mark Salsbery21-Oct-09 8:09
Mark Salsbery21-Oct-09 8:09 
GeneralRe: Marshal native string to managed string for wrapper DLL Pin
alleyes21-Oct-09 8:18
professionalalleyes21-Oct-09 8:18 
GeneralRe: Marshal native string to managed string for wrapper DLL Pin
Mark Salsbery21-Oct-09 8:29
Mark Salsbery21-Oct-09 8:29 
GeneralRe: Marshal native string to managed string for wrapper DLL Pin
alleyes21-Oct-09 8:39
professionalalleyes21-Oct-09 8:39 
GeneralRe: Marshal native string to managed string for wrapper DLL Pin
Mark Salsbery21-Oct-09 8:46
Mark Salsbery21-Oct-09 8:46 
GeneralRe: Marshal native string to managed string for wrapper DLL Pin
alleyes21-Oct-09 8:50
professionalalleyes21-Oct-09 8:50 
GeneralRe: Marshal native string to managed string for wrapper DLL Pin
Mark Salsbery21-Oct-09 8:53
Mark Salsbery21-Oct-09 8:53 
QuestionMulti layering Pin
Andreoli Carlo19-Oct-09 22:14
professionalAndreoli Carlo19-Oct-09 22:14 
AnswerRe: Multi layering Pin
Luc Pattyn20-Oct-09 2:14
sitebuilderLuc Pattyn20-Oct-09 2:14 
QuestionInvoking MFC COM objects from a C++/CLI application. Pin
Ger Hayden19-Oct-09 8:15
Ger Hayden19-Oct-09 8:15 
QuestionEvents for Combobox in Visual C++ Pin
Invinci19-Oct-09 4:39
Invinci19-Oct-09 4:39 
AnswerRe: Events for Combobox in Visual C++ Pin
Maximilien19-Oct-09 5:45
Maximilien19-Oct-09 5:45 
AnswerRe: Events for Combobox in Visual C++ Pin
N a v a n e e t h19-Oct-09 5:56
N a v a n e e t h19-Oct-09 5:56 
GeneralRe: Events for Combobox in Visual C++ Pin
Invinci19-Oct-09 22:37
Invinci19-Oct-09 22:37 
GeneralRe: Events for Combobox in Visual C++ Pin
N a v a n e e t h19-Oct-09 23:58
N a v a n e e t h19-Oct-09 23:58 
GeneralRe: Events for Combobox in Visual C++ Pin
Invinci20-Oct-09 0:11
Invinci20-Oct-09 0:11 
Questioncharset encoding going from std::string to System::String and viceversa [modified] Pin
Andreoli Carlo14-Oct-09 20:51
professionalAndreoli Carlo14-Oct-09 20:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.