Questions tagged [bstr]

`BSTR` stands for "Basic String". It is a size-prefixed, fixed-length, null-terminated, UTF-16 encoded character array used heavily in Microsoft's COM and OLE technologies for marshalling strings, especially between languages.

In many (but not all) cases BSTRs can be used in place of standard wide character arrays, but in almost all cases the reverse is not true.

For a complete guide to BSTR semantics, see Eric's Complete Guide to BSTR Semantics.

179 questions
0
votes
1 answer

Problems with converting BSTR to float

I'm trying to convert BSTR to float with: wcstod(data, NULL) The problem is that this function works ok if data = 239.78, but i receive them in this format data = 239,78. CComBSTR data =…
nooby
  • 3
  • 1
0
votes
2 answers

Comparing CComBSTR to NULL

Lately, I was working on a code and found following code: CComBSTR userName; SUCCEED(getUserName(userName)); if(userName == NULL) ... The last line alerts me, since I'm comparing an object against NULL which is not intuitive. But after a glance on…
Archer
  • 507
  • 1
  • 8
  • 21
0
votes
2 answers

pass array of strings into COM object

I gave in with finding data type that would fit following method: I have COM object method which requires "vector of BSTR strings" (as COM documentation says). It works perfectly from: a) python (everything works from python…
0
votes
1 answer

OPOS BSTR* not converting properly

So after a bunch of research I found that using WideCharToMultiByte worked great for sending data from the Control Object through OPOS to my custom SO. well we encountered a bug. In the DirectIO portion the C# Control Object's map is DirectIO(int…
Robert Snyder
  • 2,399
  • 4
  • 33
  • 65
0
votes
1 answer

Do I need to free BSTRs populated by _Type::get_FullName

I have some code that looks like this: _TypePtr spType = NULL; . . . // host the CLR and populate that type { BSTR fullName; spType->get_FullName(&fullName); wprintf(L"Got type %s\n", fullName); } Do I need to free that bstr? How do I…
Justin Dearing
  • 14,270
  • 22
  • 88
  • 161
0
votes
1 answer

WIA 2.0 - IWiaDevMgr2::GetImgDlg() - How to declare/init the ppbstrFilePaths parameter

I'm trying to implement some WIA 2.0 code in my VS2012 C++ library and have run into a problem with the IWiaDevMgr2::GetImageDlg call, specifically the ppbstrFilePaths paraneter. I'm not quite sure how to declare/initialize it. From the…
DCreeron
  • 86
  • 2
0
votes
3 answers

How to delete the variables with types BSTR in C++

The code below is mine structure and class containing the structure reference. typedef struct MESSAGE { int MessageType; BSTR Name; _bstr_t TimeStampIs; } MESSAGE, *PMESSAGE; typedef struct MESSAGENODE { PMESSAGE Message; …
Dany
  • 2,034
  • 8
  • 34
  • 54
0
votes
2 answers

Visual C++ Write BSTR to File

I am a newbie to C++. I am trying to write a BSTR to a CSV file, but the data when I print with wcout is not matching with data what's present in file. BSTR tempString; ofstream outputFile; outputFile.open("C:\\data.csv",ios::out); tempString =…
TechyHarry
  • 301
  • 2
  • 8
  • 25
0
votes
2 answers

Looking for the shortest string type conversion C++

I'm making an unmanaged C++ DLL which uses the C# managed DLL. I'm writting the C++ library as I need to use functions and headers defined in a software for which the C++ library can be added as an addon. But the things I want to make are so complex…
Mirek
  • 4,013
  • 2
  • 32
  • 47
-1
votes
1 answer

::SysFreeString() crashing in WINDOWS2008 only

I have a COM code where i use BSTR. In that the application crashes when using ::SysFreeString() However the same works in WINDOWS2003, WIN7, WINXP etc. Any idea on what is causing the problem or what could be wrong. Sample code is as below class…
ckv
  • 10,539
  • 20
  • 100
  • 144
-2
votes
1 answer

passing BSTR string as a perimeter between managed and unmanaged code (COM interop)

While working on com interop ,i followed the tutorial on this link.The code runs fine as i have done some modification depending on my requirement but the problem comes while dealing with the string.I am using BSTR string here as a perimeter…
-2
votes
1 answer

converting BSTR to a BYTE array C++

I need to create a "SAFEARRAY of bytes" from a "BSTR" to pass it to a function. i have tried following ways to create a BYTE* from BSTR. Is there any other ways to convert a BSTR to BYTE* which won't lead to lose any data? BSTR bstr =…
Deadlock
  • 4,211
  • 1
  • 20
  • 25
-2
votes
1 answer

Method Argument is BSTR* in C#

I was stuck on a program I was writing and figured it couldn't hurt to ask here. The program is in C#. I'm using a command that is confusing me slightly. In C#, the command is: scanner.DirectIO(int x, int y, object z); But when I looked up the…
-3
votes
1 answer

How to convert UnicodeString to BSTR?

I'm having a problem when calling OpenDatabase function (DAO). It's prototipe is: virtual HRESULT STDMETHODCALLTYPE OpenDatabase(BSTR Name/*[in]*/, VARIANT Options/*[in,opt]*/, VARIANT…
Tracer
  • 2,544
  • 2
  • 23
  • 58
1 2 3
11
12