Solved

How do I convert wstring variable to LCPWSTR?

Posted on 2007-11-30
2
3,010 Views
Last Modified: 2013-11-17
Hi, I need to use the MessageBox to output a msg box in my COM component. This requires the message text, the 2nd parm, to be of type LPCWSTR.  My string is in wstring.  How can I convert this to LPCWSTR?  Thank you.
0
Comment
Question by:lapucca
  • 2
2 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 20384725
Just use the 'ca_str()' member, i.e.

wstring wstr = L"test";

LPCWSTR lpcwstr = wstr.c_str();

That's it.
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 20384730
Err, that should hace read "Just use the 'c_str()' member" of course...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

730 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