Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 327
  • Last Modified:

NetMessageBufferSend

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:
NET_API_STATUS nas;
LPBYTE msg = msgTxbx->Text;
DWORD buflen = 512;
LPCWSTR from = fromTxbx->Text;
LPCWSTR to = toTxbx->Text;
                  
nas = NetMessageBufferSend(sName,      //make server name global
                                                            to,
                                                            from,
                                                            msg,
                                                            buflen);

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.
0
fsharer
Asked:
fsharer
  • 4
  • 2
1 Solution
 
nonubikCommented:
'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 (http://msdn.microsoft.com/library/en-us/vclib/html/_crt_mbstowcs.asp)

LPCWSTR from, to, sName;

mbstowcs(from, fromTxBx->Text, strlen(fromTxbx->Text);
..etc
0
 
fsharerAuthor Commented:
Sorry, msgTxbx, and fromTxbx, are just message boxes on the GUI. Thanks for the help!
0
 
fsharerAuthor Commented:
I tried the mbstowcs but it gave me these compile errors

LPCWSTR from;
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

0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
nonubikCommented:
I see you're using managed code. So it should be:

nas = NetMessageBufferSend(sName,     //make server name global
                                                  toTxbx->Text->ToCharArray(),
                                                  fromTxBx->Text->ToCharArray(),
                                                  msgTxbx->Text->ToCharArray(),
                                                  buflen);
0
 
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!
0
 
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;
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now