?
Solved

Problem with BSTR in VC++/DCOM.

Posted on 1998-09-24
4
Medium Priority
?
331 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 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses

762 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