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

ICertRequest2::Submit CSR data Compatability ASCII to BSTR

I have my certrequest as a PEM base64 data. See data below. 1) My understanding is that this is an ASCII data type and not in UNICODE format. Please clarify. -----BEGIN NEW CERTIFICATE…
Raj
  • 1,113
  • 1
  • 17
  • 34
0
votes
1 answer

Convert from Wstring to CComBstr

Please suggest me methods for converting from wstring to CComBstr. I tried to convert like following but it is failing CComBSTR BstrAddress(strID); // strID is wstring type I am getting error as "cannot convert parameter 1 from 'std::wstring' to…
Prabhu
  • 723
  • 2
  • 10
  • 29
0
votes
2 answers

Error in using the BSTR data type

My firebreath plugin project has a wrapper class of an active X control. One of the method takes a BSTR data type variable as input, but when I try to call the method and pass a BSTR, i get an error. I have even included the "WTypes.h" header file.…
Kai
  • 953
  • 6
  • 16
  • 37
0
votes
1 answer

ATL how to Convert BSTR* str to registry key.SetValue(LPCTSTR str type

It's been years since I have done C++ let alone ATL code I have this method that needs surgical help :( This is for a mobile app so I don't want to use CString and MFC I need to convert the BSTR* str to the correct type LPCTSTR for use in the…
WiredLessInTX
  • 113
  • 1
  • 6
0
votes
0 answers

Is this macro a good way to avoid an AllocSysString() memory leak?

People in my team (or formerly in my team) did not pay enough attention to memory management of strings in COM. There are far too many example of this: CString myString = _T("My String"); UseMyStringAsBSTR(myString.AllocSysString()); There is no…
ROBERT RICHARDSON
  • 2,077
  • 4
  • 24
  • 57
0
votes
1 answer

How to concatenate 2 BSTRs with a space in between them?

I have some methods that return a BSTR, and I need to concatenate those BSTRs, but it should have a space between each BSTR: BSTR a + " " + BSTR b + " " + BSTR c + and so on... I found a function that concatenates two BSTRs, however I cannot insert…
0
votes
1 answer

Memory leaks while using CComBstr and system::string

class ATL_NO_VTABLE CMasterStore : public CComObjectRootEx, public CComCoClass, public IDispatchImpl
0
votes
1 answer

Reassigning CComBSTR, memory leak?

As it's written in the MSDN documentation CComBSTR::operator= creates a copy of src. So when I write someCComBSTR = std::to_wstring(someVal).c_str(); I will have a copy of the temporary and everything is ok. But I haven't found what happens with…
Name
  • 37
  • 4
0
votes
1 answer

How do I use _malloca instead of _alloca in Win32 C++ project?

I'm updating an old C++ DLL project. For one of the exported functions there's BSTR __stdcall j2cs( const long lJulian, int bDMY, BSTR sDelim ) { USES_CONVERSION; int iDay, iMonth; long lYear; char chDate[20]; char chInt[10]; …
bugmagnet
  • 7,631
  • 8
  • 69
  • 131
0
votes
1 answer

C++, COM and passing strings

I am debugging some other programmer's source code of a Windows Media Player plugin. This plugin causes WMP to crash sometimes, and sometimes it takes really long time to open plugin settings window. The problem occurs only when opening settings…
JustAMartin
  • 13,165
  • 18
  • 99
  • 183
0
votes
1 answer

How to Modify the Buffer of BSTR in VARIANT directly?

I am using Visual C++ 2008. In my code, I get a variable of BSTR. Now I want to change the first half of the characters in it. How to do so? For example, if the string contains 5000 characters, then I want to modify the first 2500 characters in its…
alancc
  • 487
  • 2
  • 24
  • 68
0
votes
1 answer

Create BSTR from ASCIIZ PTR in PowerBasic sqlite3 Wrapper

I'm building a small wrapper for some sqlite3 functions. sqlite3.dll has a function sqlite3_column_text16() that returns a UTF-16 string. This seems like the right function to call since PowerBasic and Windows (and OLE) use UTF-16 natively (called a…
Russ
  • 31
  • 5
0
votes
0 answers

C++ std::swap - Does it swap data or data pointers?

I'm using std::swap with OLE BSTRs. I would like to confirm that this function swaps the data pointers and not the strings themselves. Is this the case?
user7340472
0
votes
0 answers

VarI4FromStr broken at lowest long value on ARM64?

The following code is fine on regular x64 Windows. const LCID LOCALE_EN_US = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT); long val; BSTR str = SysAllocString(L"-2147483648")); if (VarI4FromStr(str, LOCALE_EN_US,0,&val) ==…
0
votes
2 answers

MemoryLeak or false positive of DeLeaker when returning BSTR

I have COM-function that returns a BSTR. and its used like that: The interface: interface ITexts : IDispatch { [id(5)] HRESULT GetText([in] long Number, [in] long LangID, [out,retval] BSTR* pText); }; The implementation STDMETHODIMP…
suriel
  • 191
  • 1
  • 10