Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 6th, 2006, 05:16 AM
Authorized User
 
Join Date: Jul 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Converting BSTR to const char*

Hi guys, i am very new to C++, any one have any idea how i can convert BSTR to const char*?

Thanks in advance.

Reply With Quote
  #2 (permalink)  
Old September 6th, 2006, 05:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Use one of the ATL conversion macros.
For this puppose OLE2T might work.

Regards
Ankur
Reply With Quote
  #3 (permalink)  
Old September 6th, 2006, 10:28 AM
Authorized User
 
Join Date: Jul 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, i will try that and let you know how it goes!

Reply With Quote
  #4 (permalink)  
Old September 7th, 2006, 04:20 AM
Authorized User
 
Join Date: Jul 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Ankur_Verma,

I am afraid the macros did not work..i guess that is because i am not using them properly.

I will appreciate any ideas on how exactly to proceed.

Thanks.

Reply With Quote
  #5 (permalink)  
Old September 7th, 2006, 11:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

They showed an error 'didnt work' or were they not what
you needed 'didnt work'? Its an ATL/MFC project that we are
discussin here right?
I'll add that before you could use any of these MACROS anywhere you
need to state USES_CONVERSION; in that scope.

And yes, all my friends call me Ankur_Verma (pronounce Ankur underscore Verma) only, so what you did was nothing new. I'm also known to have responded to just "Ankur" though. You might wanna try that.

Regards
Ankur
Reply With Quote
  #6 (permalink)  
Old September 8th, 2006, 05:08 AM
Authorized User
 
Join Date: Jul 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Ankur, sorry i did not get your name quite right the first time i tried.

Anyway, yes it is an ATL project indeed. But the problem was far more complex than i'd initially thought. thanks for all your effort. I am at the present trying to rewrite the project and will almost definitely be coming to you guys again for some help.

Thanks again.

Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Big challenge here! How to convert char* to char^? samiswt Visual C++ 2005 1 November 30th, 2007 09:09 PM
Invalid conversion from 'char*' to 'char' deuxmio C++ Programming 3 December 8th, 2006 07:56 AM
BSTR * is not returning value sudharshansalvaji Visual C++ 1 October 16th, 2006 04:27 AM
converting char to datetime format santoshpayal SQL Language 0 September 11th, 2006 06:13 PM
Converting BSTR to const char* wambozi C# 1 September 6th, 2006 05:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.