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
2 answers

Confused in used BSTR in com dll in c++ builder

I make an OCX in C++ Builder Borland. My OCX has these function as I describe it: Login Write Read DebugOutput GetVal I am using this OCX in my c# application. In c# side I have a button and list box. The button calls login method from OCX…
MHM
  • 261
  • 1
  • 2
  • 15
0
votes
2 answers

Initializing a BSTR to another BSTR using assignment operator

I have a code like- void CSomeClass::Remove() { BSTR tempStr = NULL; while(!m_list.IsEmpty()) //m_list is a CSomeClass member of type CList { tempStr = m_list.RemoveHead(); //application crash here!! if(NULL==tempStr) …
BaluS
  • 55
  • 6
0
votes
1 answer

error C2061: syntax error : identifier '_bstr_t'

Code: virtual void DeleteItem(_bstr_t ItemName) = 0 Error: error C2061: syntax error : identifier '_bstr_t' i tried google online and use #include but it doesnt remove the error any other way to resolve this?
user1157977
  • 907
  • 1
  • 11
  • 17
0
votes
1 answer

How to convert C++ PBSTR to C# string

Have a C++ ActiveX OCX with the following ODL declaration: DISP_FUNCTION(CHellerCommCtrl, "GetRecipePath", GetRecipePath, VT_I4, VTS_PBSTR) Need to call GetRecipePath from C# program and convert resultant C++ BSTR to C# string. Am aware, from other…
user5505472
0
votes
0 answers

Converting BSTR to String[]

I can see a number of google results for converting string array to BSTR, but none that does it the other way around. How do I do that? Details I'm using VSTO + C# for writing a Word add-in. One of the functions of Word Object Model named…
dotNET
  • 33,414
  • 24
  • 162
  • 251
0
votes
1 answer

64 bit ACE OLEDB provider causes access violation in SysFreeString

My application uses MS Access mdb files because of legacy reasons. It connects to the database using ADO with the following connection string: Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=Dummy.mdb Recently I started…
andrebroz
  • 176
  • 10
0
votes
2 answers

Why we want to use BSTR

I'm new to COM. According to http://msdn.microsoft.com/en-us/library/windows/desktop/ms221069(v=vs.85).aspx BSTR is a string with prefix. I am wondering what it the purpose for BSTR. In which case we have to use BSTR instead of string type? If…
user454083
  • 1,337
  • 3
  • 16
  • 31
0
votes
0 answers

Use a BSTR as string in C# COM method

my project is about to control a device with the software I am working on. For doing this the vendor provides a COM library. I have a problem calling one method from this library: In the (unfortunately very shortly written) documentation of the COM…
sjss
  • 21
  • 2
0
votes
1 answer

Error in converting BSTR to CString

I using Visual C++ 2008 and ADO to access a database and obtain a field value like this: _variant_t vtValue; AfxVariantInit(&vtValue); vtValue = m_pRecordset->Fields->GetItem(_variant_t(strFieldName))->GetValue(); If (vtValue.vt == VT_BSTR) { …
alancc
  • 487
  • 2
  • 24
  • 68
0
votes
1 answer

What is the opposite of _bstr_t

I can easily convert a 'const char *' to 'BSTR' using BSTR bs = _bstr_t(myConstChar); This works fine. But I am not sure now to convert a BSTR to const char *. I don't know what the function (like "_bstr_t") for such a conversion would be.
tmighty
  • 10,734
  • 21
  • 104
  • 218
0
votes
1 answer

Read and display data from Variant VT_ARRAY | VT_BSTR?

I want to use an instrument that has a COM object interface. Unfortunately there is no C++ example in the SDK, only C#. After creating the wrapper class, I can successfully read the instrument's serial number into a VARIANT: VARIANT snumbers; …
0
votes
0 answers

print elements by multiple tag names - msxml - xml parsing in C++

I am trying to parse xml file using MSXML , But I want to parse particular tags(nodes) not all nodes. Below two lines additional to the whole for xml parsing , gives output of all nodes. If I replace L" " to L"tag_name" ... I will get the results…
May
  • 207
  • 2
  • 7
0
votes
1 answer

passing _bstr_t between c# and C++ /CLI

I am little confused whether we can use _bstr_t to pass string between c# to C++ and vice versa. I am using C++/CLI as intermediate layer between C# and C++. If possible also give example how to marshal it at C# end and C++/CLI end as there are not…
user2692032
  • 771
  • 7
  • 26
0
votes
1 answer

Access violation when passing BSTR string to _bstr_t or CComBSTR constructor

I have BSTR string which is passed from COM server. When I put this string into _bstr_t (or CComBSTR) constructor then access violation is occurred. I checked this exception and found that this exception raised only when BSTR is empty (or null). I…
Eldar Agalarov
  • 4,849
  • 4
  • 30
  • 38
0
votes
0 answers

_com_util::ConvertStringToBSTR - Access Violation

I'm invoke COM server's method and randomly get access violation error in the _com_util::ConvertStringToBSTR: g_quote->RegisterQuote(_bstr_t(pszTicker), _bstr_t(_T("*"))); RegisterQuote signature: HRESULT __stdcall RegisterQuote(BSTR bstrSymbol,…
Eldar Agalarov
  • 4,849
  • 4
  • 30
  • 38
1 2 3
11
12