I am having trouble with this. I have searched the other forums, and they have provided me with no help. I was wondering can someone help me, and explain to me how to get this working say using a GUI?

Here's what I have so far:
LPBYTE msg = msgTxbx->Text;
DWORD buflen = 512;
LPCWSTR from = fromTxbx->Text;
LPCWSTR to = toTxbx->Text;
nas = NetMessageBufferSend(sName,      //make server name global

right off the bat I know my LPCWSTR is wrong, I am a very confused on the whole convert thing. I think that is what I need to have explain to me the most.
Who is Participating?
I see you're using managed code. So it should be:

nas = NetMessageBufferSend(sName,     //make server name global
'sName', 'to' and 'from' must be wide character strings (Unicode).

First of all you did not post what are 'msgTxbx' and 'fromTxbx'.
But I presume that the 'Text' member is just a char string so you need to do a conversion from the multibyte to wide character string using mbstowcs (

LPCWSTR from, to, sName;

mbstowcs(from, fromTxBx->Text, strlen(fromTxbx->Text);
fsharerAuthor Commented:
Sorry, msgTxbx, and fromTxbx, are just message boxes on the GUI. Thanks for the help!
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

fsharerAuthor Commented:
I tried the mbstowcs but it gave me these compile errors

mbstowcs(from, fromTxBx->Text, strlen(fromTxbx->Text);

 error C2664: 'mbstowcs' : cannot convert parameter 1 from 'AnonymousSend::LPCWSTR' to 'wchar_t *'
 Conversion loses qualifiers
 error C2664: 'strlen' : cannot convert parameter 1 from 'System::String __gc *' to 'const char *'

I really dont understand this whole converting issue. can someone send me to a site, or point me to a book, or explain how to do this conversion? Man I have a lot to learn! Thanks

fsharerAuthor Commented:
I am using both, and it is difficult! For me atleast. The new compile error is

error C2664: 'AnonymousSend::NetMessageNameAdd' : cannot convert parameter 2 from '__wchar_t  __gc[]' to 'AnonymousSend::LPCWSTR'

Is there a site or book about conversions, that I can refer too? So I can understand this!
fsharerAuthor Commented:
After some research, I found some sites, and lead me to this. It seems like it works,  I get no compile errors, or runtime erros.

__wchar_t  from __gc [] = fromTxbx->Text->ToCharArray();
LPCWSTR pFrom = (LPCWSTR) &from;
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.