Solved

Convert 'const CString' to 'OLECHAR FAR*'

Posted on 2006-11-29
6
1,738 Views
Last Modified: 2013-11-20
Hi guys,

How would I convert:

'const CString' to 'OLECHAR FAR*'


Cheers!
0
Comment
Question by:Cyber-Drugs
  • 3
  • 2
6 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 18040160
I think this should work.

bstr_t bst = MyString;

SomeFunc(bst);  // SomeFunc(OLECHAR FAR* bst)
0
 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 18040212
What is MyString?
What is SomeFunc?

Sorry, that didn't make much sense to me...
0
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 300 total points
ID: 18043013
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 200 total points
ID: 18043435
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
 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 18045611
Cheers Andy!
0
 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 18045617
... and Mahesh, sorry I didn't see your reply. :)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
unable to delete all specified values regedit 38 434
substring method in java 1 124
string initialization in java 11 114
Sed question 2 88
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

825 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