我已经好几年没写过 C++ 了,更不用说 ATL 代码了
我有这个方法需要手术帮助:(
这是一个移动应用程序,所以我不想使用 CString 和 MFC
我需要将 BSTR* str 转换为正确的类型 LPCTSTR,以便在注册表 Set.Value 方法中使用
STDMETHODIMP CAXSampleCtl::SendMSG(BSTR* str)
{
CRegKey key;
key.Create(HKEY_LOCAL_MACHINE, _T("MyKeyName"));
key.SetValue( str <<<--- nope, _T("MyValueName"));
key.Flush();
key.Close();
return S_OK;
}
最佳答案
COLE2T
宏专为您而设,请参阅 String Conversion Classes and Macros
To convert to a BSTR, pass the existing string to the constructor of CComBSTR. To convert from a BSTR, use COLE2[C]DestinationType[EX], such as COLE2T.
关于c++ - ATL 如何将 BSTR* str 转换为注册表项。SetValue(LPCTSTR str 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7654998/