Solved

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

Posted on 1998-05-23
2
1,278 Views
Last Modified: 2012-06-21
How do I convert a LPOLESTR value to a LPSTR or CString in MFC???
0
Comment
Question by:Nightjar
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
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.
0
 
LVL 3

Expert Comment

by:tma050898
ID: 1164649
Nightjar,

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 } };

LPOLESTR lpOleStr = NULL;
HRESULT hr = ::StringFromCLSID(CLSID_RecyleBin, &lpOleStr);
if (SUCCEEDED(hr))
{
 CString str(lpOleStr);
 AfxMessageBox(str);
}

Take care,
Tom

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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 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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

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

9 Experts available now in Live!

Get 1:1 Help Now