bstr Questions

1

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...
Latinity asked 11/3, 2016 at 12:19

6

Solved

What is the correct way of doing this: _bstr_t description; errorInfo->GetDescription( &description.GetBSTR() ); or: _bstr_t description; errorInfo->GetDescription( description.GetAdd...
Flew asked 3/12, 2010 at 15:6

5

Solved

I have a _bstr_t variable bstrErr and I am having a CString variable csError. How do I set the value which come in bstrErr to csError?
Followup asked 6/11, 2009 at 6:35

3

Solved

It's at least common practice to treat null BSTR (null WCHAR* pointer) as an empty string and design all the code manipulating BSTRs accordingly. Answers to this question say the same. Where is th...
Upcoming asked 6/5, 2009 at 6:32

3

I have a _bstr_t string which contains Japanese text. I want to convert this string to a UTF-8 string which is defined as a char *. Can I convert the _bstr_t string to char * (UTF-8) string withou...
Amenable asked 9/3, 2009 at 12:40

4

Solved

How would you convert a std::string to BSTR*? STDMETHODIMP CMyRESTApp::rest(BSTR data, BSTR* restr) { RESTClient restclient; RESTClient::response resp = restclient.get(data); Log("Response St...
Knighterrant asked 9/7, 2015 at 10:0

2

I have a non-unicode (MBCS) C++ project building with VS2013. Given a BSTR value, how should I pass this to printf safely?
Mainland asked 9/9, 2015 at 14:36

2

Is it possible using macro magic or TMP to insert the length into a string at compile time? For example: const wchar_t* myString = L"Hello"; I would want the buffer to actually contain "[length...
Payola asked 28/11, 2013 at 11:12

2

Solved

When calling a function that expects a BSTR it'd be nice to be able to write something like: iFoo->function( bs"HELLO" ); However the only workaround I'm aware of is to use a wrapper that cal...
Paralogism asked 13/1, 2015 at 9:31

2

Solved

A co-worker wrote the following code, which I am convinced is wrong. I want to explain the problems to him, but don't know the proper term, so I cannot find references to support my position: His...
Frore asked 3/7, 2014 at 19:14

5

How can I pass a char * from C dll to VB Here is sample code: void Cfunc(char *buffer,int len) { BSTR buf_bstr = SysAllocString((BSTR)buffer); VBptr.VBfunc(buf_bstr,len); } This function is ...
Sempiternal asked 3/3, 2009 at 11:47

4

I have an out value as BSTR* for an interface in a C++ COM dll. And I am returning this to a C# .Net client. In my C++ function I have to assign different values according to a diff condition. For...
Relly asked 27/5, 2011 at 5:10

2

Solved

From book ATL Internals, I knew BSTR is different from OLECHAR*, and there are CComBSTR and CString for BSTR. According MSDN Allocating and Releasing Memory for a BSTR, I knew memory management re...
Gillard asked 15/3, 2013 at 20:4

3

I need to convert a CString instance into a properly allocated BSTR and pass that BSTR into a COM method. To have code that compiles and works indentically for both ANSI and Unicode I use CString::...
Factional asked 18/1, 2010 at 14:5

2

A leak checker tells me that I have a memory leak on memory that is allocated in the following code: // Get the value from the object as a variant. VARIANT vVal; VariantInit ( &vVal ); hres = ...
Smail asked 9/1, 2013 at 19:56

1

Solved

first: LPCTSTR asdfsdf = (LPCTSTR)(_bstr_t)v; printf("%s\n", asdfsdf); second: printf("%s\n", (LPCTSTR)(_bstr_t)v); they are the same, but the first condition causes unreadable code why?
Petulancy asked 6/12, 2012 at 7:52

4

Solved

Since a BSTR is only a typedef for wchar_t* our code base has several (many?) places where string literals are passed to a method expecting a BSTR this can mess up with marshallers or anyone who tr...
Capapie asked 24/1, 2012 at 11:33

3

I am working on a COM Object library with function that returns a VARIANT with a SAFEARRAY of BSTRs. How can I display the values from this VARIANT instance and save it inside a TStringList? I trie...
Easeful asked 19/12, 2011 at 7:33

5

Solved

After reading What's the rationale for null terminated strings? and some similar questions I have found that in C#/.NET strings are, internally, both length-prefixed and null terminated like in...
Varmint asked 9/6, 2011 at 13:24

1

Solved

Anyone know how to convert BSTR to char* ? Update: I tried to do this, but don't know if it is right or wrong. char *p= _com_util::ConvertBSTRToString(URL->bstrVal); strcpy(testDest,p );
Charlotte asked 6/9, 2010 at 3:26

3

Solved

I'm trying to convert a wchar_t * to BSTR. #include <iostream> #include <atlstr.h> using namespace std; int main() { wchar_t* pwsz = L"foo"; BSTR bstr(pwsz); cout << Sys...
Yseulte asked 23/7, 2010 at 23:53

5

Solved

When allocating a new BSTR with SysAllocString via a wchar_t* on the heap, should I then free the original wchar_t* on the heap? So is this the right way? wchar_t *hs = new wchar_t[20]; // load s...
Madeleinemadelena asked 20/4, 2010 at 17:4

4

Solved

So far I've discovered I can convert incoming BSTRs to ANSI in two (of many?) ways, and I'm curious to know whether one is "better" than the other with respect to speed / efficiency etc. The way I...
Councilwoman asked 23/2, 2009 at 5:37

2

Solved

I have read that the following code causes memory leak. But did not understand why. CComBSTR str; pFoo->get_Bar(&str); pFoo->get_Baf(&str); How does it cause a leak when we are not...
Redtop asked 16/11, 2009 at 23:12

2

Solved

Suppose a method from a COM interface returns BSTR value. Am I right in my opinion that I must free it? The code example at http://msdn.microsoft.com/en-us/library/aa365382(VS.85).aspx does not do...
Gudgeon asked 16/5, 2009 at 16:51

© 2022 - 2024 — McMap. All rights reserved.