Solved

How do I convert wstring variable to LCPWSTR?

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Hibernate methods 2 58
countEvens challenge 2 59
is twain_32.dll cmpatible with windows 10 ? 10 96
post4 challenge 28 83
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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 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…

747 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

13 Experts available now in Live!

Get 1:1 Help Now