如何使用 MessageBox 函数显示 BSTR 值?
How to display a BSTR value with MessageBox function?
我是 C++ 的新手。我使用 Code::Blocks,我需要用 MessageBox 函数显示一个 BSTR 值。
我试图 google 这个问题,但没有找到合适的答案。
如何操作?
BSTR是wchar_t*
,对于MessageBox来说,直接传给MessageBoxW就可以了。 MessageBoxW(hwnd,bStrVal,...);
对于MessageBoxA
,您必须使用WideCharToMultiByte
进行转换。
建议:在您的应用中始终使用 unicode,永远不要离开它。
我是 C++ 的新手。我使用 Code::Blocks,我需要用 MessageBox 函数显示一个 BSTR 值。
我试图 google 这个问题,但没有找到合适的答案。
如何操作?
BSTR是wchar_t*
,对于MessageBox来说,直接传给MessageBoxW就可以了。 MessageBoxW(hwnd,bStrVal,...);
对于MessageBoxA
,您必须使用WideCharToMultiByte
进行转换。
建议:在您的应用中始终使用 unicode,永远不要离开它。