#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <string>
#include <vector>
#include <time.h>
#include "shlwapi.h"
#pragma comment(lib,"shlwapi.lib")
using namespace std;
char szPath[200] = ".\\bankcard\\";
int Step2_Create_dstCnn( char *ROIImagePath)
{
struct tm *newtime;
char filename[200];
time_t long_time;
time(&long_time);
newtime = localtime(&long_time);
sprintf_s(filename,"%d-%d-%d-%d-%d-%d.jpg",newtime->tm_year+1900,newtime->tm_mon+1,newtime->tm_mday,newtime->tm_hour,newtime->tm_min,newtime->tm_sec);//
strcat(szPath,filename);
strcpy(ROIImagePath,szPath);
return 1;
}
int main()
{
char szPath[MAX_PATH] = ".\\bankcard\\";
if (!PathFileExists(szPath))
{
CreateDirectory( szPath, NULL );
}
char ROIImagePath[100];
memset(ROIImagePath,'\0',100);
Step2_Create_dstCnn(ROIImagePath);//把更新后的字符串返回,即一个绝对路径
cout<<ROIImagePath<<endl;
system("pause");
return 0;
}
获取当前目录路径:
char AbPath[512];
GetCurrentDirectory(512,AbPath);
strcat(AbPath,szPath);
strcpy(ROIImagePath,AbPath);
cvSaveImage(ROIImagePath, dst);
结果: .\bankcard\2016-5-3-15-34-9.jpg
请按任意键继续. . .