www.pudn.com > QRAPPuie.rar > AppMenuFunc.cpp


#include "stdafx.h" 
#include "AppMenuFunc.h" 
 
CAppMenuFunc::CAppMenuFunc(void) 
{ 
} 
 
CAppMenuFunc::~CAppMenuFunc(void) 
{ 
} 
 
void CAppMenuFunc::SaveAsInfofile(CString s) 
{ 
   BOOL writeflag; 
   DWORD errcode; 
 
   TCHAR lpFileName[MAX_PATH] = {0}; 
   TCHAR lphyphen[]=_T("-"); 
   TCHAR lpblank[]=_T(" "); 
 
   SYSTEMTIME systime; 
   GetLocalTime(&systime); 
    
   TCHAR year[5]   = {0}; 
   TCHAR month[5]  = {0}; 
   TCHAR day[5]    = {0}; 
   TCHAR hour[5]   = {0}; 
   TCHAR min[5]    = {0}; 
   TCHAR sec[5]    = {0}; 
   _itow(systime.wYear, year,10); 
   _itow(systime.wMonth, month,10); 
   _itow(systime.wDay, day,10); 
   _itow(systime.wHour, hour,10); 
   _itow(systime.wMinute, min,10); 
   _itow(systime.wSecond, sec,10); 
 
   lstrcpy(lpFileName,_T("\\My Documents\\我的QR码信息\\")); // 
   lstrcat(lpFileName,year); 
   lstrcat(lpFileName,lphyphen); 
 
   if(lstrlen(month)==1) 
	   lstrcat(lpFileName,_T("0")); 
   lstrcat(lpFileName,month); 
   lstrcat(lpFileName,lphyphen); 
   if(lstrlen(day)==1) 
	   lstrcat(lpFileName,_T("0")); 
   lstrcat(lpFileName,day); 
   lstrcat(lpFileName,lpblank); 
   if(lstrlen(hour)==1) 
	   lstrcat(lpFileName,_T("0")); 
   lstrcat(lpFileName,hour); 
   lstrcat(lpFileName,lphyphen); 
   if(lstrlen(min)==1) 
	   lstrcat(lpFileName,_T("0")); 
   lstrcat(lpFileName,min); 
   lstrcat(lpFileName,lphyphen); 
   if(lstrlen(sec)==1) 
	   lstrcat(lpFileName,_T("0")); 
   lstrcat(lpFileName,sec); 
   lstrcat(lpFileName,_T(".txt")); ///mqr 
 
   const char unicodeByte[] = {0xff,0xfe};//unicode txt flag 
 
   CFile   hTxtFile;    
 
   CreateDirectory(TEXT("\\My Documents\\我的QR码信息"),NULL); 
   writeflag = hTxtFile.Open(lpFileName,CFile::modeWrite|CFile::modeCreate); 
   hTxtFile.Write(unicodeByte,2*sizeof(char)); 
   hTxtFile.Write(s,sizeof(TCHAR)*s.GetLength()); 
   hTxtFile.Close(); 
    
   if(FALSE==writeflag)	 
   {  
   		errcode = GetLastError();    
   		AfxMessageBox(_T("保存文件失败!"),0,0); 
   } 
   else 
   { 
	///	SetFileAttributes(lpFileName,FILE_ATTRIBUTE_HIDDEN); 
   		AfxMessageBox(_T("成功保存!"),0,0); 
   }  
} 
 
void CAppMenuFunc::AddBeforeQuotation(CString s,TCHAR **pDst) 
{ 
	LPWSTR pTxt = s.GetBuffer(); 
	s.ReleaseBuffer(); 
	DWORD nTxtLen = s.GetLength(); 
	int n = 0; 
	for(int i=0; i