Convert 'const CString' to 'OLECHAR FAR*'

Hi guys,

How would I convert:

'const CString' to 'OLECHAR FAR*'


Cheers!
LVL 4
Cyber-DrugsAsked:
Who is Participating?
 
mahesh1402Connect With a Mentor Commented:
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
 
AndyAinscowFreelance programmer / ConsultantCommented:
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
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.