在非MFC环境中使用CString、使用_bstr_t

来源:互联网 发布:桌面美化软件哪个好 编辑:程序博客网 时间:2024/06/06 03:13

项目属性-》常规-》在共享 DLL 中使用 MFC

#include "stdafx.h"#include <string>#include <comdef.h>#include <atlstr.h>void wlog(LPWSTR str){FILE * fp = NULL;setlocale(LC_ALL,"chs");fp = fopen("C:\\log.txt", "a+" );fwprintf( fp, str );fwprintf( fp, L"\n" );fclose(fp);}int _tmain(int argc, _TCHAR* argv[]){    _bstr_t str = _bstr_t("1234");    CString cs = (LPCSTR)str;    LPWSTR lp = (LPWSTR)(LPCTSTR)cs;    wlog(lp);    system("pause");    return 0;}

原创粉丝点击