Solved

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

Posted on 1998-05-23
2
1,291 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

803 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