473,805 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

quick BSTR question

How can I write a function like this:

BSTR Greeting(BSTR name)
{
//return "Good Morning : " + name ;
}

In short I'm looking for a quick tutorial on using BSTR - Google is not
bringing up anything consise enough (I'm not particularly interested in
the history of BSTR and the differences between string types etc ...
just need to get down to the "nuts and bolts" of using BSTRs)

Aug 30 '06 #1
2 1543
How can I write a function like this:
>
BSTR Greeting(BSTR name)
{
//return "Good Morning : " + name ;
}

In short I'm looking for a quick tutorial on using BSTR - Google is not
bringing up anything consise enough (I'm not particularly interested in
the history of BSTR and the differences between string types etc ...
just need to get down to the "nuts and bolts" of using BSTRs)
You can use SysAllocString to allocate BSTRs
You have to use SysFreeString to deallocate them afterwards.

If you google around for tutorials that mention SysAllocString, you should
find a number of articles that tell you how to use BSTRs

--
Kind regards,
Bruno.
br************* *********@hotma il.com
Remove only "_nos_pam"

Aug 30 '06 #2
Ray
Lucy Ludmiller wrote:
How can I write a function like this:

BSTR Greeting(BSTR name)
{
//return "Good Morning : " + name ;
}

In short I'm looking for a quick tutorial on using BSTR - Google is not
bringing up anything consise enough (I'm not particularly interested in
the history of BSTR and the differences between string types etc ...
just need to get down to the "nuts and bolts" of using BSTRs)
Well the thing is that it's easier for you to understand BSTR if you
understand the "difference s between string types etc."

But search for _bstr_t, it makes using BSTR *that* much easier. Of
course this being C++ you can't expect it to be as simple as VB, but
close enough :)

Aug 30 '06 #3

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

Similar topics

1
5750
by: Chris | last post by:
I am not sure if this is the right newsgroup. But does anyone know what is the difference between a BSTR and a LPOLESTR? The only thing I could find out is that the advantage of taking BSTR instead of LPOLESTR is that determining the length of a BSTR is much faster.
7
7128
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 my managed code, I am calling that function with ‘out’ parameter of ‘string’ type. For normal size strings it works fine, but when the string is very big (> 50,000 bytes), I get a null exception from the COM interop. What is the reason?...
8
5198
by: Michael Tissington | last post by:
I have a C++ function in a DLL of the form BSTR WINAPI DoSomeWork(LPCSTR szConnection, LPCSTR szGUID) I use SysAllocStringByteLen to return a BSTR. For the most part this works accept when the calling applicaiton tries to free the BSTR and I get a RtlFreeHeep error. I'm guessing because the bstr has been allocated in one dll and it being released in another.
5
2666
by: bluter | last post by:
We have server components which were created by a third party and compiled in VC++5 (sp3). They run fine on NT4 and 2000, however during testing of our migration to Server 2003, these components have been failing when performing Data Access functions. In particular we have been having problems with BSTR and _bstr_t. _bstr_t(BSTR*, 1) is the original code that the problem started with. Other findings are - 1) Converting a BSTR* to a...
37
5481
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 32 bytes, because of the fact that a pointer, is 8 bytes instead of 4 bytes. The length prefix -still- is a UINT however and not a UINT_PTR.
0
343
by: Aleksandar Cikota | last post by:
Hi all, I'm beginner in Python and need help. I'm writing software for a robotic telescope. For CCD camera control we use MaxIm DL (Diffraction Limited). I have a problem with CCDCamera.SaveImage. Error message: > File "S:MaxImmaxim.py", line 19, in ? > CCDCamera.SaveImage('C:/1.fit') > File "C:ProgrammePython24Libsite-
4
5370
by: joseph_mueller | last post by:
I have a BSTR something like this firstHalf.secondHalf I want to parse this string using the "." as the delimeter, so I will end up with two different BSTRs, one for the stuff before the "." and one for the stuff after it. How can I do this?
12
3377
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 the beginning of the array. But I couldn't find this information by looking at the memory. (Via VS2005 - C++) My second questions is, if there is a mechanism to know how much memory is allocated for the array, why don't we use it for things like...
2
5861
by: mzdude | last post by:
I need to interface with a windows DLL that has the following signature extern "C" void Foo( BSTR in, BSTR *out ) Code so far Traceback (most recent call last): File "<pyshell#14>", line 1, in <module>
0
9718
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10364
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10370
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9186
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4328
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.