VC TCHAR转char ~ BSTR转换成char*
来源:互联网 发布:变声器男变女软件 编辑:程序博客网 时间:2024/06/05 09:14
TCHAR
TCHAR是通过define定义的字符串宏
C++支持两种字符串,即常规的ANSI编码(使用""包裹)和Unicode编码(使用L""包裹)
#include <stdio.h>
int main(void)
{
_TCHAR* tchar_str="weihuanzhen";
char char_str[256];
sprintf(char_str, "%S", tchar_str);
return 0;
}
BSTR
它被描述成一个与自动化相兼容的类型,由于操作系统提供相应的API函数(如SysAllocString)来管理它以及一些默认的调度代码。因此BSTR实际上就是一个COM字符串,但它却在自动化技术以外的多种场合下得到广泛使用
方法1,使用COleVariant或_variant_t。例如://COleVariant strVar("This is a test");
_variant_t strVar("This is a test");
BSTR bstrText = strVar.bstrVal;
方法2,使用_bstr_t,这是一种最简单的方法。例如:
BSTR bstrText = _bstr_t("This is a test");
方法3,使用CComBSTR。例如:
BSTR bstrText = CComBSTR("This is a test");
或
CComBSTR bstr("This is a test");
BSTR bstrText = bstr.m_str;
- VC TCHAR转char ~ BSTR转换成char*
- BSTR转换成char*
- BSTR转换成char*
- vc char* CString * BSTR之间的转换
- VC字符串转换(CHAR、BSTR、CString)
- [转] CString、TCHAR*、char*转换
- VC char和TCHAR之间转换
- VC char和TCHAR之间转换
- VC char和TCHAR之间转换
- VC char和TCHAR之间转换
- VC char和TCHAR之间转换
- char * bstr CComBSTR 转换
- BSTR与char*转换
- BSTR 和 char * 转换
- CString、TCHAR*、char*转换
- CString、TCHAR*、char*转换
- CString、TCHAR*、char*转换
- TCHAR和char转换
- 设计模式14 - 命令模式 Command Pattern
- 报表之使用rdlc创建图表
- Android系统如何实现UI的自适应
- 增加home city选项里没有的manila城市
- BB10 Cascades: 为页面添加菜单项
- VC TCHAR转char ~ BSTR转换成char*
- 模拟ATM自动取款机系统
- 百度地图从零学起(四)地图覆盖物
- C#调用C/C++动态库的参数传递---数组指针的传递
- 浅谈MAC、MII、PHY
- dialyzer:erlang代码分析器
- 关于COSMOS动态内存使用的疑问
- 简单分析RTEMS基于S3C2440 的中断处理原理
- Javascript的this用法