很多时候为了批量命名文件的方便我们都会选用系统时间作为文件名,下面是使用C++获取系统时间并且将其转换为字符串的代码,极其菜鸟仅供日后查阅方便:
int CALLBACK CMainFrame::SnapCallback(HV_SNAP_INFO *pInfo)
{
CMainFrame *pFrame = (CMainFrame *)(pInfo->pParam);
ASSERT(pFrame);
int now_time;
now_time=time(NULL);
char s[1000];
itoa(now_time,s,10);
char* s1 = s;
strcat(s1,".jpg");
HVSaveJPEG(s1,pFrame->m_pImageBuffer, (int)(pFrame->m_pBmpInfo->bmiHeader.biWidth), (int)(pFrame->m_pBmpInfo->bmiHeader.biHeight), (int)(pFrame->m_pBmpInfo->bmiHeader.biBitCount), TRUE, 100);
pFrame->SendMessage(WM_CHANGE_SNAP, 0, 0);
return 1;
}