下面一段代码:
GetSystemTime(&st1); strDate.Format("%4d-%2d-%2d",st1.wYear,st1.wMonth,st1.wDay); strTime.Format("%2d:%2d:%2d:%3d",st1.wHour,st1.wMinute,st1.wSecond,st1.wMilliseconds); strName=strDate+strTime+".jpg";
// if(iter == params.end()) params["-out"] = "AV_Image1.jpg";
if(iter == params.end()) params["-out"] = strName; …… std::ofstream fout(params["-out"].c_str(), std::ios_base::binary);
if(!fout)
MessageBox("could not be opened");
else
{
for(i = 0; i < iBufferSize; i++)
fout << pcImageBuffer[i];
if(!fout != true)
{
MessageBox("\image saved to file: ");
fout.close();
}
}
这段程序,
如果用现在被注释的那条代码,就可以顺利的输出结果,但是如果用没有注释的那一条,就会弹出MessageBox("could not be opened");请问是为什么呢?
GetSystemTime(&st1); strDate.Format("%4d-%2d-%2d",st1.wYear,st1.wMonth,st1.wDay); strTime.Format("%2d:%2d:%2d:%3d",st1.wHour,st1.wMinute,st1.wSecond,st1.wMilliseconds); strName=strDate+strTime+".jpg";
// if(iter == params.end()) params["-out"] = "AV_Image1.jpg";
if(iter == params.end()) params["-out"] = strName; …… std::ofstream fout(params["-out"].c_str(), std::ios_base::binary);
if(!fout)
MessageBox("could not be opened");
else
{
for(i = 0; i < iBufferSize; i++)
fout << pcImageBuffer[i];
if(!fout != true)
{
MessageBox("\image saved to file: ");
fout.close();
}
}
这段程序,
如果用现在被注释的那条代码,就可以顺利的输出结果,但是如果用没有注释的那一条,就会弹出MessageBox("could not be opened");请问是为什么呢?
解决方案 »
- 哪位大虾帮帮忙,vc里snmp编程如何获得1.3.6.1的字符串形式,有直接的函数可以调用吗
- 连续放分11,开始一个全新的软件项目,女朋友
- ADO 与数据库连接问题??????????????????????????????
- 刚刚借了一本 VISUAL C++6.0 技术内幕,第五版 有人说很垃圾。不如第四版?
- ?为何用StretchDIBits缩小图片后出现很多噪点?
- 聚合的内部组件不能直接在客户端创建吗,必须通过外部组件?
- 急急急
- 如何打开和关闭以及隐藏一个对话框?(像VB中的dialog.hide、dialog.open这种功能)
- 请问:Install-Shield安装过程中能否自动将当前VC工程文件所用到的dll等信息?
- MFC中主对话框关联的类对象this指针不能被正确传递的问题
- winpcap 发包到外网的问题
- 请教:在程序(C++)里打开(Documents->Open())一个Word文档后,如何获得每页的字符数?
你的格式化可能有问题,应该是
strDate.Format("%04d-%02d-%02d",st1.wYear,st1.wMonth,st1.wDay);strTime.Format("%02d:%02d:%02d:%03d",st1.wHour,st1.wMinute,st1.wSecond,st1.wMilliseconds);
strName=strDate+strTime+".jpg";断点查找字符串拼接是否正确
PS:楼主用AV_IMAGE啊,显示黄色图片可是不对的呀!
为什么我如果弹出一个MessageBox,先试一下strName,检查一下是没有问题的,
但是就是无法生成合法的文件名呢?顺便AV是arecont vision的缩写,是一家摄像头公司……
像是这样str="D:\\"这样的也不行么?