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
1
vote
0 answers

CComVariant for boolean?

I am writing an ATL library (I'm very new at this) and I have a function that I want to return BSTR and VARIANT_BOOL. My function looks like this: STDMETHODIMP myClass::GetResult(BSTR* myString, VARIANT_BOOL* contains) { std::pair
Everyone
  • 1,751
  • 13
  • 36
1
vote
1 answer

Using a COM-DLL with BSTR* parameters --> Float Div By Zero error

Currently, I'm developing a mid-sized in-house application, which should include some features that are already included in a previous application. This has been developed in Visual Basic 6 many years ago by an external supplier. Unfortunately I…
FlKo
  • 805
  • 1
  • 10
  • 27
1
vote
0 answers

Does my CList would cause memory leak?

void CClass::Add(enum MyEnum eMy,BSTR bstring) { CComBSTR temp(bstring); switch(eMy) { case e1: m_List1.AddTail(temp.Copy()); //m_List1, m_List2, m_List3 are of type CList break; case e2: …
BaluS
  • 55
  • 6
1
vote
1 answer

SAFEARRAY(BSTR) as [out] parameter in DCOM fails to return strings

I want to write a DCOM server and a client so that they could exchange some data. Both sides are compiled using MS Visual Studio 2008, client connects using pure WinAPI, proxy/stub is a separate dll (in case anything of this matters). The problem…
Abstraction
  • 1,108
  • 11
  • 25
1
vote
0 answers

PostAsJsonAsync causing my COM interface call to fail - Could not load file or assembly 'Newtonsoft.Json'

I have a COM interface setup between my C# class library and a native executable. The native exe makes a call into the managed module, which should return a string (which is marshalled to a BSTR c++ side). During this call, the following line is…
friartuck
  • 2,954
  • 4
  • 33
  • 67
1
vote
1 answer

BSTR's and VARIANT's under... mac os x

Under mac os x I have office 2011 and its excel and VBA, and I have gcc-5.3.0's g++. I played a lot to passing arrays (of numerical built-in types) from VBA to the dylib (extension of dll's on mac os x) and updating them and sending them back to…
Olórin
  • 3,367
  • 2
  • 22
  • 42
1
vote
0 answers

Including atlbase.h to use CComBSTR

I have a .NET library for which I'm writing a C++/CLI wrapper to expose the public members to native world. One of the requirement is to make use of CComBSTR for strings and avoid the std namespace altogether. For this purpose, I included the…
Rahul Vijay Dawda
  • 1,123
  • 3
  • 14
  • 36
1
vote
2 answers

How to Convert int to BSTR?

I have a question how can BSTR accepts a number the second line here gives an error unsigned int number =10; BSTR mybstr=SysAllocString(number); also this line gives an error VarBstrCat(mybstr, number, &mybstr); Thank you :) your help…
Rehab Reda
  • 193
  • 7
  • 16
1
vote
1 answer

Access violation on CompStr(BSTR, BSTR) after getting string?

I am getting an access violation that I can't figure out when trying to compare to BSTR strings in a c++ function. For whatever reason, the code runs normally most of the time. But on occasion, seemingly randomly, it will throw the exception. This…
climbak
  • 441
  • 1
  • 5
  • 14
1
vote
1 answer

Set BSTR to null

In a Visual C++ i have a function like shown below.it is a dll code. From vb6 application i am calling dll and run the function and get result.But every time when i call this from my vb6 application(without closing vb6 exe) i get result with…
Navaneet
  • 1,367
  • 1
  • 19
  • 44
1
vote
2 answers

Iterating through a VARIANT/SAFEARRAY of BSTR to Assign Values and Print to Console in C++

I'm attempting to fill a SAFEARRAY of 10 indexes of BSTR type with the value "test" and print out to console the value of each index of the SAFEARRAY after it has been assigned to verify correctness. I ran the debugger and got these values below for…
cosmo479
  • 89
  • 2
  • 9
1
vote
1 answer

C# program calls vc++ function which has BSTR as input parameter

From C# program, I am calling VC++ function which has BSTR as input parameter. I am not getting any return value. My c# application crashes. C# : SampleCS, var value = object.GetValue(10, "TEST"); VC++ : SampleCPP, GetValue(long index, BSTR key,…
magg
  • 119
  • 1
  • 3
  • 11
1
vote
1 answer

Converting large strings from BSTR tp std::string?

I have string in BSTR, and I would like to convert it using W2CA (WideCharToMultiByte): USES_CONVERSION; std::string myMBS = W2CA(myBSTR); // myBSTR is BSTR But when string is extremely large - it throws exception "StackOverFlowException" on this…
user2706838
  • 1,061
  • 2
  • 13
  • 21
1
vote
1 answer

How to get String from Pointer in VB6

I must call C DLL with VB6. C Code short int decode(BOOL Mode, char* tete, char* adresse, char* status, char* nombre, char* datadecode); My VB Code : Private Declare Function decode Lib "VBdecode.dll" ( _ ByVal Mode As Long, _ ByVal tete As…
mahader
  • 21
  • 3
1
vote
1 answer

BSTR bstrRtf = 0xcccccccccccccccc on debugging ( = CXX0030: Error: expression cannot be evaluated)

I am using an IXLMDOMDocument to load a xml file from a stream using IXMLDOMDocument *pDomDoc = pDomDoc->load(vtHtmlSource, &vfSuccess); After loading the stream (containing the xml contents) it creates a style sheet in order to get the content…
Sss
  • 1,519
  • 8
  • 37
  • 67