Easy Question...Answer Needed Urgently (LPOLESTR -> LPSTR)

Posted on 1998-05-23
Medium Priority
Last Modified: 2012-06-21
How do I convert a LPOLESTR value to a LPSTR or CString in MFC???
Question by:Nightjar
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

tma050898 earned 800 total points
ID: 1164648
Have you tried...

CString str(oleString);  // where oleString is an LPOLESTR

I have code all over that does this w/o any problems. Exactly what problems are you having.

Expert Comment

ID: 1164649

Here's an example of this using the StringFromCLSID function. BTW, in case you are interested, the CString(LPCWSTR) c'tor is the one being used to convert the LPOLESTR to a CString.

static const GUID CLSID_RecyleBin =
{ 0x645ff040, 0x5081, 0x101b, { 0x9f, 0x08, 0x00, 0xaa, 0x00, 0x2f, 0x95, 0x4e } };

HRESULT hr = ::StringFromCLSID(CLSID_RecyleBin, &lpOleStr);
if (SUCCEEDED(hr))
 CString str(lpOleStr);

Take care,


Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses
Course of the Month12 days, 4 hours left to enroll

752 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