64,282
社区成员
发帖
与我相关
我的任务
分享
int main()
{
cout << "Begin Test." << endl;
cout << "********************" << endl;
CComBSTR ccombstrTest(_T("this is test."));
string strPath = "D:\\Projects_VC_2005\\bstrfile.txt";
ifstream outfile(strPath.c_str());
if (!outfile)
{
cout << "file error." << endl;
return -1;
}
IStream* pStream = (IStream*)(&outfile);
ccombstrTest.WriteToStream(pStream); //执行到这里中断了
outfile.close();
cout << "********************" << endl;
cout << "End Test." << endl;
return 0;
}
#include <atlbase.h>
#include <iostream>
using namespace std;
int main()
{
cout << "Begin Test." << endl;
cout << "********************" << endl;
CComBSTR ccombstrTest(_T"this is test."));
CoInitialize(NULL);
CComPtr<IStream> pStream = NULL;
SHCreateStreamOnFileA("D:\\bstrfile.txt", STGM_CREATE | STGM_WRITE | STGM_DIRECT | STGM_SHARE_EXCLUSIVE, &pStream);
ccombstrTest.WriteToStream(pStream);
cout << "********************" << endl;
cout << "End Test." << endl;
return 0;
}