Solved

pass unicode from COM client to COM server

Posted on 2004-03-24
2
287 Views
Last Modified: 2010-04-01
hello, all,

  A COM server (VC6.0) which requires a string with unicode characters from client (VC6.0), therefore I defined a BSTR variable in COM server interface. it looks like:

//COM server
CCNStServer::GeneralBrowser(BSTR name)
{
.....
}

On client side, my code looks like:
//COM Client
_bstr_t name("xxxxxxx"/*unicode might be inside of this string*/);
theApp.GetServerHandle()->GeneralBrowser(name);
...
 I found that only Ascii characters can be passed to COM server, I have no idea where  those unicode characters are!, anybody can help me?

thanx in advance
 
 
0
Comment
Question by:kim_wei
2 Comments
 
LVL 12

Expert Comment

by:andrewjb
ID: 10669101
"xxxxx" isn't a unicode string literal.

You need, say

_T("xxxxxx")
0
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 10670400
Though "xxxxx" is an ANSI string, the constructor of _bstr_t is able to convert it to Unicode. To explicitly specify Unicode strings, use L"xxxxx". I don't think there is a problem. How do you know the Unicode strings are not working? Maybe you are debugging it without turning on Unicode?

Check the following option,

Menu Tools/Options..., Debug tab, Display unicode strings
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now