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

Posted on 1998-05-23
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 200 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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
Create string splitting user defined function in C++ 23 338
Least Squares Curve Fitting 4 117
Gaming Software 1 30
learn programming 8 73
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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.
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.

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