• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1845
  • Last Modified:

Convert 'const CString' to 'OLECHAR FAR*'

Hi guys,

How would I convert:

'const CString' to 'OLECHAR FAR*'


Cheers!
0
Cyber-Drugs
Asked:
Cyber-Drugs
  • 3
  • 2
2 Solutions
 
AndyAinscowCommented:
I think this should work.

bstr_t bst = MyString;

SomeFunc(bst);  // SomeFunc(OLECHAR FAR* bst)
0
 
Cyber-DrugsAuthor Commented:
What is MyString?
What is SomeFunc?

Sorry, that didn't make much sense to me...
0
 
mahesh1402Commented:
Use CString::AllocSysString() like :

OLECHAR FAR *pOleString = strMyString.AllocSysString();

If you call CString::AllocSysString() like above then after use you should call SysFreeString(pOleString) to avoid memory leak.

OLECHAR FAR *pOleString = strMyString.AllocSysString();

//Use pOleString

::SysFreeString(pOleString)


-MAHESH
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
AndyAinscowCommented:
How would I convert:

'const CString' to 'OLECHAR FAR*'


MyString is a CString variable
SomeFunc is a function that takes a parameter of type OLECHAR FAR*
0
 
Cyber-DrugsAuthor Commented:
Cheers Andy!
0
 
Cyber-DrugsAuthor Commented:
... and Mahesh, sorry I didn't see your reply. :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now