Solved

How do I convert wstring variable to LCPWSTR?

Posted on 2007-11-30
2
2,993 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
haveThree challenge 22 121
twoTwo  challenge 35 107
child constructor and parent constructor, overriding and overloading 6 88
Gaming Software 1 17
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

789 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