Home > Software engineering >  MFC save the photo to the specified file
MFC save the photo to the specified file

Time:09-26

In my code project files under the root directory has built a Pic folder, Pic folder to follow my capture save picture information to generate the corresponding year month day such format folder, what should I write code,

CodePudding user response:

 void CCapturePictureDlg: : OnOnePicture (LONG ILoginID, BYTE * pbufs, UINT RevLen, UINT EncodeType, UINT CmdSerial) 
{
//Get the file path
Char path [1000].
Int filelen=GetModuleFileName (NULL, path, 1000);
Int I=filelen;
While (the path [I]! )
='\ \'{
I -;
}
The path [I + 1]='\ 0';

Cstrings filepath (path);
Cstrings filename="mpeg4. JPG";
Cstrings strfile=filepath + filename;
Char * pFileName=strfile. GetBuffer (200);

Now the path is as follows

CodePudding user response:

Every time call CreateDirectory function to create "date" directory, CreateDirectory date of the first parameter of Pic directory + string, formatting the can,

CodePudding user response:

CreateDirectory

CodePudding user response:

Fyi:
 # include & lt; Afxdisp. H> 
# include & lt; Stdio. H>
# include & lt; Stdlib. H>
Int main (int arg c, TCHAR * argv []) {
COleDateTime t;
COleDateTimeSpan ts;
Cstrings s, FMT;
Int nYear.
Int nMonth;
Int nDay;
Int nHour;
Int nMin;
Int nSec.
Int lDays;
Int nHours.
Int nMins;
Int nSecs;
Int I, N;
//initialize the MFC and the print and the error on failure
if (! AfxWinInit (: : GetModuleHandle (NULL), NULL, : : GetCommandLine (), 0)) {
Printf (" Fatal Error: MFC initialization failed \ n ");
return 1;
}
If (argc<13) {
Usage: printf (" % s sYYYY sMM sDD SHH sMM SSS pDD PHH PMM PSS n {SQL | YYYY | YY} \ n ", argv [0]).
return 2;
}
If (stricmp (argv [12], "SQL")==0) FMT="% % Y - m - H: % d % % m: % S".
Else if (stricmp (argv [12], "YYYY")==0) FMT="% % m % d % Y H % m % S".
Else if (stricmp (argv [12], "YY")==0) FMT="% % m % d % y H % m % S".
The else {
Usage: printf (" % s sYYYY sMM sDD SHH sMM SSS pDD PHH PMM PSS n {SQL | YYYY | YY} \ n ", argv [0]).
return 3;
}
NYear=atoi (argv [1]);
NMonth=atoi (argv [2]);
NDay=atoi (argv [3]);
NHour=atoi (argv [4]);
NMin=atoi (argv [5]);
NSec=atoi (argv [6]);
LDays=atoi (argv [7]);
NHours=atoi (argv [8]);
NMins=atoi (argv [9]);
NSecs=atoi (argv [10]);
N=atoi (argv [11]);
If (N<=0) {
Usage: printf (" % s sYYYY sMM sDD SHH sMM SSS pDD PHH PMM PSS n {SQL | YYYY | YY} \ n ", argv [0]).
return 4;
}
T=COleDateTime (nYear, nMonth nDay, nHour, nMin, nSec);
Ts=COleDateTimeSpan (lDays nHours, nMins, nSecs);
For (I=1; i<=N; I++) {
S=t.F ormat (FMT);
08 printf (" % d % s \ n ", I, s);
T=t + ts;
}
return 0;
}

CodePudding user response:

GetSystemTime (SYSTEMTIME)
CreateDirectory ()
  • Related