Solved

Convert 'const CString' to 'OLECHAR FAR*'

Posted on 2006-11-29
6
1,724 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
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.

 
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

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

Title # Comments Views Activity
repeatEnd java challenge 42 84
Named range not carried over 10 62
Detect CR LF to each line 12 152
Thin secure Windows 10 5 74
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 (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

914 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

18 Experts available now in Live!

Get 1:1 Help Now