Solved

Problem with BSTR in VC++/DCOM.

Posted on 1998-09-24
4
328 Views
Last Modified: 2012-08-14
For oleautomation I am passing a BSTR from client program.The server is accepting it gracefully, but I want to convert the BSTR variable in server side to a char * or char array.My server can't use MFC as set previously.I tried with OLE2T/T2OLE etc. please help me in this matter.


Thanking u in anticipation,
Baidehish Dwibedy.
India.
0
Comment
Question by:bdwibedy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:bdwibedy
ID: 1173590
no
0
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 1173591
Use 'VectorFromBstr()' to receive an array of SAFEARRAYs of type 'VT_UI1'. You'll get the chars evaluating *(asa[ i].pvData)
0
 
LVL 2

Expert Comment

by:rayb
ID: 1173592
Cheap and dangerous way:
(Only dangerous if localization is an issue)
char buffer[max_buffer_size];
sprintf( buffer, "%S", bstr );  // Note that it's %'capital S'

Or you could use the MultiByteToWideChar function.
0
 
LVL 2

Expert Comment

by:rayb
ID: 1173593
Sorry, I meant to say the WideCharToMultiByte function.
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

726 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