Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

920 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

16 Experts available now in Live!

Get 1:1 Help Now