如何将Bstr转换为LPCSTR/LPSTR [英] How to convert Bstr to LPCSTR/LPSTR
本文介绍了如何将Bstr转换为LPCSTR/LPSTR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有COM Server(ATL),其中的接口很少.我有一个参数为BSTR的接口.我需要将此参数(bSTR)转换为LPSTR/LPCSTR,以便在接口内使用以调用Win32 API'的.
< b> Ex:CreateProcess</b>
I have COM Server(ATL) where i have few interfaces.I have a interface in which a parameter is BSTR .I need to convert this parameter(bSTR) to LPSTR/LPCSTR to use inside the interface for calling Win32 API''s.
<b>Ex:CreateProcess</b>
推荐答案
看看帮助器类_bstr_t
http://msdn.microsoft.com/es-es/library/zthfhkd6.aspx [ ^ ]
样本:
Take a look at the helper class_bstr_t
http://msdn.microsoft.com/es-es/library/zthfhkd6.aspx[^]
Sample:
_bstr_t bb(BSTR_var); // Helper class
char *s= bb; // Convert to LSTR
您可以使用_bstr_t
类,请参见完整C ++字符串指南,第二部分-字符串包装器类 [ ^ ].
You may use the _bstr_t
class, see The Complete Guide to C++ Strings, Part II - String Wrapper Classes[^].
这篇关于如何将Bstr转换为LPCSTR/LPSTR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文