473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

BSTR to char* and vice versa

Hi

What's sthe best approach to convert char[] or char* strings to a BSTR and
vice versa? I would like to omit OLE2A macros and allocate the memory
myself, or is the the only way? Any hints?

Thanks, Urs
Nov 17 '05 #1
2 4508
Hi Urs Vogel,
Hi

What's sthe best approach to convert char[] or char* strings to a BSTR
and vice versa? I would like to omit OLE2A macros and allocate the
memory myself, or is the the only way? Any hints?


If you want to do it by hand, then you can use:

See: WideCharToMultiByte
http://msdn.microsoft.com/library/en...icode_2bj9.asp

(which is also internally use by any other method)

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #2
Hi Jochen Kalmbach,
Hi Urs Vogel,
Hi

What's sthe best approach to convert char[] or char* strings to a BSTR
and vice versa? I would like to omit OLE2A macros and allocate the
memory myself, or is the the only way? Any hints?


If you want to do it by hand, then you can use:

See: WideCharToMultiByte
http://msdn.microsoft.com/library/en...icode_2bj9.asp

(which is also internally use by any other method)


Oh sorry... this was the wrong direction...

Please use: MultiByteToWideChar
http://msdn.microsoft.com/library/en...icode_17si.asp

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Espen Ruud Schultz | last post by:
Lets say I have a char pointer and an std::string. Is it possible to get a pointer to the std::string's "content" so that the char pointer can point to the same text? And vice versa; can I give...
1
by: Dharmendra Singh | last post by:
Hi I'm using .Net(C#) and working on the form(Screen) which have text boxes for both arabic and english data to store. So i want to change the language at run time from arabic to english and...
1
by: André | last post by:
Hallo, erstmal vorweg: Ich bin noch ziemlicher Newbee also bitte nicht schlachten! Es geht darum den Inhalt eines bestimmten Verzeichnisses einer SIM-Karte zu interpretieren. Dazu hab ich den...
9
by: Juggernaut | last post by:
I am trying to create a p_thread pthread_create(&threads, &attr, Teste, (void *)var); where var is a char variable. But this doesnt't work, I get this message: test.c:58: warning: cast to pointer...
2
by: Steve - DND | last post by:
Just wondering if anyone out there has any code to convert a plural word to it's singular form and vice versa. Most of our database tables are named in a plural fashion. When we go to create...
7
by: Gilad Walden | last post by:
I use C# in .NET framework. I have an ActiveX implemented in C++ that has a COM interface method that gets as it’s out parameter a BSTR* . The interop translates this BSTR* into C# string. From...
37
by: Egbert Nierop \(MVP for IIS\) | last post by:
In win32 mode, a BSTR was UINT length prefixed and terminated exactly by a zero char. So if you allocated "Hello World" that would allocate 28 bytes. In x64 and (IA64 as well) it would become...
12
by: yufufi | last post by:
Hello, How does delete know how much memory to deallocate from the given pointer? AFAIK this informations is put there by new. new puts the size of the allocated memory before the just before...
1
by: Maric Michaud | last post by:
Le Tuesday 24 June 2008 07:08:46 swapna mudavath, vous avez écrit : This is not valid xml, there is no commas in attribute list in xml. You could try with minidom if your xml stream isn't too...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.