Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert BSTR to int

Tags:

c++

winapi

Does any one know how can I convert a BSTR to an int in VC++ 2008

Thanks in advance.

like image 981
Alonso Avatar asked Nov 27 '22 19:11

Alonso


2 Answers

You can pass a BSTR safely to any function expecting a wchar_t *. So you can use _wtoi().

like image 109
moonshadow Avatar answered Dec 05 '22 10:12

moonshadow


Google suggests VarI4FromStr:

HRESULT VarI4FromStr(
  _In_   LPCOLESTR strIn,
  _In_   LCID lcid,
  _In_   ULONG dwFlags,
  _Out_  LONG *plOut
);
like image 34
Scott Hanselman Avatar answered Dec 05 '22 11:12

Scott Hanselman