Ejemplo n.º 1
0
void MusicUtils::EmptyDir(CString Dir)
{
	CFileFind finder;
	CFile cfile;
	CString Add=L"\\*";
	CString DirSpec=Dir+Add;                        //????????????
	BOOL bWorking = finder.FindFile(DirSpec);


	while (bWorking)
	{
		bWorking = finder.FindNextFile();

		if(!finder.IsDots())              //????????
		{
			if(finder.IsDirectory())           //????????
			{
				CString strDirectory = finder.GetFilePath();
				if(_rmdir((const char*)(LPSTR)(LPCTSTR)strDirectory)==-1)
				{
					EmptyDir(strDirectory); 
				}
				bWorking = finder.FindFile(DirSpec);
			}
			else                               //???????
			{
				cfile.Remove(finder.GetFilePath());
			}
		}
	}
	finder.Close();

}
Ejemplo n.º 2
0
void CProfile::ClearProfile()
{
    CFile file;

    // delete the XML file
    file.Remove(m_strDataFullPath);
}
Ejemplo n.º 3
0
void CDatabaseDlg2::OnBnClickedDeleteFace()
{
	// TODO: 在此添加控件通知处理程序代码
	int nIndex;
	CString id,fpath;
	CDatabase db;
	db.Open(NULL, FALSE, FALSE, _T("ODBC;DSN=face;UID=root;PWD=root"));
	nIndex = m_list.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
	//if(-1 == nIndex)
	//    nIndex = 0;
	if(-1 != nIndex)
	{
		id = m_list.GetItemText(nIndex,0);
		fpath = m_list.GetItemText(nIndex,4);
	}
	else     
	{   
		MessageBox("请选择要删除人脸!");
		db.Close();
		return;
	}

	//删除文件
	CFileFind finder;
	if(finder.FindFile(fpath))
	{
		CFile TempFile; 
		TempFile.Remove(fpath);
	}


	CString sql;
	sql.Format("delete from face where ID=%s", id);
	db.ExecuteSQL(sql);
	db.Close();
	
	CString cmdStr = "Select * from face order by ID";
	m_sname.SetWindowText("");
	m_spath.SetWindowText("");
	m_fname.SetWindowText("");
	m_fpath.SetWindowText("");
	ShowDatabase(cmdStr);
	MessageBox("删除成功");
}
Ejemplo n.º 4
0
void CExportData::SplitOneFileToManyFiles(CString Dir,CString DestFileName,bool bDayKline)
{
    CFile SrcFile;   

	CString sExd = ".day";
	if(bDayKline==false)
		sExd=".min";
	if(!SrcFile.Open(DestFileName,CFile::modeRead))
	{
		AfxMessageBox("打开文件出错!");
		return;
	}
	int LengthOfSrcFile=SrcFile.GetLength();
    
	int BytesPerDisk=1457000;
    int NumOfDisks= LengthOfSrcFile%BytesPerDisk==0 ? LengthOfSrcFile/BytesPerDisk:LengthOfSrcFile/BytesPerDisk+1;  
	for (int nDisk=1;nDisk<=NumOfDisks;nDisk++)
	{
       
		int nSize=min(BytesPerDisk,LengthOfSrcFile);
		if( nSize<= 0)
		{
		
			return;
		}

		CString DiskXFileName;
		DiskXFileName.Format("%d",nDisk);
		DiskXFileName=Dir+"\\TL_Disk"+DiskXFileName+sExd;
		CFile DiskXFile( DiskXFileName,CFile::modeCreate|CFile::modeWrite);
		DiskXFile.Write(&NumOfDisks,sizeof(4));  
		DiskXFile.Write(&nDisk,sizeof(4));      
		BYTE *Buffer=new BYTE[nSize];   
		SrcFile.Read(Buffer,nSize);   
		DiskXFile.Write(Buffer,nSize); 
		delete []Buffer;             
		DiskXFile.Close();
		
		LengthOfSrcFile-=nSize;     
	}
	SrcFile.Close();
	SrcFile.Remove(DestFileName);
}
Ejemplo n.º 5
0
BOOL CSVToolDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
	//  执行此操作
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标

	ShowWindow(SW_SHOW);
	m_Font.CreatePointFont(100, _T("微软雅黑"), NULL);
	m_static.SetFont(&m_Font, true);

	// TODO: 在此添加额外的初始化代码
	SetWindowText(_T("SVTool - V1.0"));
	
	CRect tabRect;

	m_tab.InsertItem(0,_T("ACPI"));
	m_tab.InsertItem(1,_T("CCTool"));

	CCTool.Create(IDD_DIALOG_CCTool, &m_tab);
	ACPI.Create(IDD_DIALOG_ACPI, &m_tab);

	m_tab.GetClientRect(&tabRect);
	tabRect.left += 5;                  
    tabRect.right -= 5;   
    tabRect.top += 25;   
    tabRect.bottom -= 5;

	//设置子对话框尺寸并移动到指定位置

	ACPI.MoveWindow(&tabRect);
	CCTool.MoveWindow(&tabRect);

	//分别设置隐藏和显示
	ACPI.ShowWindow(true);
	CCTool.ShowWindow(false);

	m_tab.SetCurSel(0);

	// 根据调整好的tabRect放置m_jzmDlg子对话框,并设置为显示   
    // CCTool.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW);   
    // 根据调整好的tabRect放置m_androidDlg子对话框,并设置为隐藏   
    //ACPI.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_SHOWWINDOW); 

	//ACPI
	TCHAR rbPath[MAX_PATH];
	GetModuleFileName(NULL,rbPath,MAX_PATH);
	ACPI.rootpath = rbPath;

	CString temp1;
	TCHAR TMP1[1024];
	DWORD dd;
	CRegKey KKey;
	CString HWinfo = ACPI.hardwareinfo();
	ACPI.SetDlgItemText(IDC_HWINFO,HWinfo);
	if(KKey.Open(HKEY_CURRENT_USER,_T("Software\\SVACPI\\ACPI Information")) == ERROR_SUCCESS)
	{
		AfxMessageBox(_T("1"));
		KKey.QueryStringValue(_T("OrigHWInfo"),TMP1,&dd);
		temp1 = TMP1;
		KKey.QueryStringValue(_T("ErrorPath"),TMP1,&dd);
		ACPI.errorpath = TMP1;
		if(ACPI.CheckDiffInfo(ACPI.ACPIs, temp1, HWinfo))
			ACPI.GetDlgItem(IDC_STATIC_Error)->EnableWindow(TRUE); 
	}
	KKey.Close();

	CRegKey hKey;
	if(hKey.Open(HKEY_CURRENT_USER,_T("Software\\SVACPI\\ACPI Information")) == ERROR_SUCCESS)
	{
		AfxMessageBox(_T("2"));
		TCHAR TMP[1024];
		CString temp;
		DWORD dwcount = 1024, dwType = REG_SZ;
		//从注册表中恢复设置
		hKey.QueryStringValue(_T("SetLoop"), TMP, &dwcount);
		temp = TMP;
		ACPI.SetDlgItemText(IDC_Loop, temp);

		hKey.QueryStringValue(_T("SetTime"), TMP, &dwcount);
		temp = TMP;
		ACPI.SetDlgItemText(IDC_Countdown, temp);
		ACPI.SetDlgItemText(IDC_time_to_run, temp);

		CRegKey lKey;
		if (lKey.Open(HKEY_CURRENT_USER, _T("Software\\SVACPI\\ACPI Information")) == ERROR_SUCCESS)
		{
			AfxMessageBox(_T("3"));
			lKey.QueryStringValue(_T("CurrState"), TMP, &dwcount);
			ACPI.ACPIs = TMP;
			temp = TMP;

			ULONGLONG a;
			lKey.QueryQWORDValue(_T("LastLoop"), a);
			CString Loop;
			Loop.Format(_T("%d"), a);
			ACPI.SetDlgItemText(IDC_Loop_time, Loop);
		}

		CString time;
		HKEY tKey;
		if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\SVACPI\\ACPI Information"), 0, KEY_READ | KEY_WRITE, &tKey) == ERROR_SUCCESS)
		{
			DWORD dwReturn = 1024;
			RegQueryValueEx(tKey, _T("RealTime"), NULL, &dwType, (LPBYTE)(&TMP), &dwReturn);
			time = TMP;
		}

		//S5开机初始化
		if(temp == _T("S5"))
		{
			ACPI.SetDlgItemText(IDC_S5BUTTON,_T("Stop S5"));
			ACPI.GetDlgItem(IDC_S4BUTTON)->EnableWindow(FALSE);
			ACPI.GetDlgItem(IDC_S3BUTTON)->EnableWindow(FALSE);
			ACPI.GetDlgItem(IDC_RbBUTTON)->EnableWindow(FALSE);
			ACPI.GetDlgItem(IDC_PBUTTON)->EnableWindow(TRUE);

			FILETIME ft; LARGE_INTEGER tmp; LONGLONG tmptime;
			SYSTEMTIME st;
			GetLocalTime(&st);

			SystemTimeToFileTime(&st, &ft);
			tmp.LowPart = ft.dwLowDateTime;
			tmp.HighPart = ft.dwHighDateTime;
			tmptime = tmp.QuadPart;

			tmptime += _ttoi64(time);
			tmp.QuadPart = tmptime;
			ft.dwLowDateTime = tmp.LowPart;
			ft.dwHighDateTime = tmp.HighPart;
			FileTimeToSystemTime(&ft, &st);
			SetLocalTime(&st);
		}
		//Reboot开机初始化
		else
		{
			ACPI.SetDlgItemText(IDC_RbBUTTON,_T("Stop Reboot"));
			ACPI.GetDlgItem(IDC_S4BUTTON)->EnableWindow(FALSE);
			ACPI.GetDlgItem(IDC_S3BUTTON)->EnableWindow(FALSE);
			ACPI.GetDlgItem(IDC_S5BUTTON)->EnableWindow(FALSE);
			ACPI.GetDlgItem(IDC_PBUTTON)->EnableWindow(TRUE);
		}
		hKey.Close();
		lKey.Close();
		ACPI.SetTimer(21,1000,NULL);
	}
	else
	{
		ACPI.SetDlgItemText(IDC_Loop,_T("9999"));
		ACPI.SetDlgItemText(IDC_Countdown,_T("15"));
		ACPI.SetDlgItemText(IDC_Loop_time,_T("0"));
		ACPI.SetDlgItemText(IDC_time_to_run,_T("-"));

		ACPI.SetDlgItemText(IDC_PBUTTON,_T("Pause"));
		ACPI.SetDlgItemText(IDC_S3BUTTON,_T("Run S1/S3"));
		ACPI.SetDlgItemText(IDC_S4BUTTON,_T("Run S4"));
		ACPI.SetDlgItemText(IDC_S5BUTTON,_T("Run S5"));
		ACPI.SetDlgItemText(IDC_RbBUTTON, _T("Reboot"));


		ACPI.GetDlgItem(IDC_PBUTTON)->EnableWindow(FALSE);
		ACPI.GetDlgItem(IDC_S3BUTTON)->EnableWindow(TRUE);
		ACPI.GetDlgItem(IDC_S4BUTTON)->EnableWindow(TRUE);
		ACPI.GetDlgItem(IDC_S5BUTTON)->EnableWindow(TRUE);
		ACPI.GetDlgItem(IDC_RbBUTTON)->EnableWindow(TRUE);
	}

	//copycompare
	CCTool.CheckDlgButton(IDC_200MS_RADIO, 1);
	CCTool.sourcepath = _T("D:\\CCData\\200MS");
	CCTool.SetDlgItemText(IDC_SOURCE_PATH_EDIT,CCTool.sourcepath);


	CString filename ;
	TCHAR SysTmpPath[MAX_PATH];
	GetTempPath(MAX_PATH,SysTmpPath);
	filename = SysTmpPath;
	filename+=_T("CCtool.bat");

	CFileFind finder;
	BOOL iffind = finder.FindFile(filename);
	if(iffind)
	{
		CFile CCbat;
		CCbat.Remove(filename);
	}
	
	CFile CCbat(filename, CFile::modeCreate|CFile::modeWrite);
	CCbat.Write("@echo off\r\necho CCLoop will start running in 10 seconds...\r\n", sizeof("@echo off\r\necho CCLoop will start running in 10 seconds...\r\n")-1);
	CCbat.Write("ping 127.0.0.1 -n 11>nul\r\n",sizeof("ping 127.0.0.1 -n 11>nul\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("set /a looptime=0\r\n",sizeof("set /a looptime=0\r\n")-1);
	CCbat.Write("set sdisk=%2\r\n",sizeof("set sdisk=%2\r\n")-1);
	CCbat.Write("set ddisk=%3\r\n",sizeof("set ddisk=%3\r\n")-1);
	CCbat.Write("set s=%sdisk:~0,1%\r\n",sizeof("set s=%sdisk:~0,1%\r\n")-1);
	CCbat.Write("set d=%ddisk:~0,1%\r\n",sizeof("set d=%ddisk:~0,1%\r\n")-1);
	CCbat.Write("if not exist %d%:\\ color fc&echo ERROR!!! %d%:\\ is not EXIST!!!&pause\r\n",sizeof("if not exist %d%:\\ color fc&echo ERROR!!! %d%:\\ is not EXIST!!!&pause\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("path=c:\\;c:\\windows\\command;c:\\windows\\system32;c:\\windows;C:\\WinNT\\system32;c:\\WinNT;c:\\windows\\sysWOW64;\r\n",sizeof("path=c:\\;c:\\windows\\command;c:\\windows\\system32;c:\\windows;C:\\WinNT\\system32;c:\\WinNT;c:\\windows\\sysWOW64;\r\n")-1);
	CCbat.Write("break=on\r\n",sizeof("break=on\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("if exist c:\\%s%-%d%-%1.txt del /q c:\\%s%-%d%-%1.txt\r\n",sizeof("if exist c:\\%s%-%d%-%1.txt del /q c:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write(":start\r\n",sizeof(":start\r\n")-1);
	CCbat.Write("echo ************** (%s%) copy to (%d%) is starting ******************* >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo ************** (%s%) copy to (%d%) is starting ******************* >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write(":l\r\n",sizeof(":l\r\n")-1);
	CCbat.Write("if exist %3 rd /s /q %3\r\n",sizeof("if exist %3 rd /s /q %3\r\n")-1);
	CCbat.Write("if exist D:\\%d%-%1-C rd /s /q D:\\%d%-%1-C\r\n",sizeof("if exist D:\\%d%-%1-C rd /s /q D:\\%d%-%1-C\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write(":loop\r\n",sizeof(":loop\r\n")-1);
	CCbat.Write("echo ************************************************************** >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo ************************************************************** >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("echo **************  Loop %looptime% is starting ****************** >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo **************  Loop %looptime% is starting ****************** >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("md %3\r\n",sizeof("md %3\r\n")-1);
	CCbat.Write("echo %time%\r\n",sizeof("echo %time%\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("set copybgntime=%time%\r\n",sizeof("set copybgntime=%time%\r\n")-1);
	CCbat.Write("set copybgndate=%date%\r\n",sizeof("set copybgndate=%date%\r\n")-1);
	CCbat.Write("copy /Y %2 %3\r\n",sizeof("copy /Y %2 %3\r\n")-1);
	CCbat.Write("set copyendtime=%time%\r\n",sizeof("set copyendtime=%time%\r\n")-1);
	CCbat.Write("set copyenddate=%date%\r\n",sizeof("set copyenddate=%date%\r\n")-1);
	CCbat.Write("if errorlevel 1 color fc&echo ERROR happened when copy from %2 to %3 !!(no files were found) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n",sizeof("if errorlevel 1 color fc&echo ERROR happened when copy from %2 to %3 !!(no files were found) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n")-1);
	CCbat.Write("if errorlevel 4 color cf&echo ERROR happened when copy from %2 to %3 !!(there is not enough memory) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n",sizeof("if errorlevel 4 color cf&echo ERROR happened when copy from %2 to %3 !!(there is not enough memory) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("echo n|comp %2 %3\r\n",sizeof("echo n|comp %2 %3\r\n")-1);
	CCbat.Write("set compendtime=%time%\r\n",sizeof("set compendtime=%time%\r\n")-1);
	CCbat.Write("set compenddate=%date%\r\n",sizeof("set compenddate=%date%\r\n")-1);
	CCbat.Write("if errorlevel 1 color cf&echo ERROR happened when compare %2 with %3 !!(files are different) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n",sizeof("if errorlevel 1 color cf&echo ERROR happened when compare %2 with %3 !!(files are different) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n")-1);
	CCbat.Write("if errorlevel 2 color fd&echo ERROR happened when compare %2 with %3 !!(cannot open one of the files or invalid arguments or invalid switch) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n",sizeof("if errorlevel 2 color fd&echo ERROR happened when compare %2 with %3 !!(cannot open one of the files or invalid arguments or invalid switch) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("echo Start copy from %2 to %3: %copybgntime% %copybgndate%. >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo Start copy from %2 to %3: %copybgntime% %copybgndate%. >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("echo Finish copy from %2 to %3: %copyendtime% %copyenddate%. >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo Finish copy from %2 to %3: %copyendtime% %copyenddate%. >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("echo Finish comp from %2 to %3: %compendtime% %compenddate%. >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo Finish comp from %2 to %3: %compendtime% %compenddate%. >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("set info=%s%-%d%-%1-copy\r\n",sizeof("set info=%s%-%d%-%1-copy\r\n")-1);
	CCbat.Write("call %~dp0count %copybgntime% %copyendtime% C:\\%info%\r\n",sizeof("call %~dp0count %copybgntime% %copyendtime% C:\\%info%\r\n")-1);
	CCbat.Write("set info=%s%-%d%-%1-comp\r\n",sizeof("set info=%s%-%d%-%1-comp\r\n")-1);
	CCbat.Write("call %~dp0count %copyendtime% %compendtime% C:\\%info%\r\n",sizeof("call %~dp0count %copyendtime% %compendtime% C:\\%info%\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("md D:\\%d%-%1-C\r\n",sizeof("md D:\\%d%-%1-C\r\n")-1);
	CCbat.Write("set copybgntime=%time%\r\n",sizeof("set copybgntime=%time%\r\n")-1);
	CCbat.Write("set copyenddate=%date%\r\n",sizeof("set copyenddate=%date%\r\n")-1);
	CCbat.Write("copy /Y %3 D:\\%d%-%1-C\r\n",sizeof("copy /Y %3 D:\\%d%-%1-C\r\n")-1);
	CCbat.Write("set copyendtime=%time%\r\n",sizeof("set copyendtime=%time%\r\n")-1);
	CCbat.Write("set copyenddate=%date%\r\n",sizeof("set copyenddate=%date%\r\n")-1);
	CCbat.Write("if errorlevel 1 color fc&echo ERROR happened when copy from %3 to D:\\%d%-%1-C !!(no files were found) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n",sizeof("if errorlevel 1 color fc&echo ERROR happened when copy from %3 to D:\\DataComp !!(no files were found) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n")-1);
	CCbat.Write("if errorlevel 4 color cf&echo ERROR happened when copy from %3 to D:\\%d%-%1-C !!(there is not enough memory) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n",sizeof("if errorlevel 4 color cf&echo ERROR happened when copy from %3 to D:\\DataComp !!(there is not enough memory) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n")-1);
	CCbat.Write("echo n|comp %2 D:\\%d%-%1-C\r\n",sizeof("echo n|comp %2 D:\\%d%-%1-C\r\n")-1);
	CCbat.Write("set compendtime=%time%\r\n",sizeof("set compendtime=%time%\r\n")-1);
	CCbat.Write("set compenddate=%date%\r\n",sizeof("set compenddate=%date%\r\n")-1);
	CCbat.Write("if errorlevel 1 color cf&echo ERROR happened when compare %2 with D:\\%d%-%1-C !!(files are different) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n",sizeof("if errorlevel 1 color cf&echo ERROR happened when compare %2 with D:\\DataComp !!(files are different) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n")-1);
	CCbat.Write("if errorlevel 2 color fd&echo ERROR happened when compare %2 with D:\\%d%-%1-C !!(cannot open one of the files or invalid arguments or invalid switch) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n",sizeof("if errorlevel 2 color fd&echo ERROR happened when compare %2 with D:\\DataComp !!(cannot open one of the files or invalid arguments or invalid switch) in loop %looptime% at %time% %date%>>C:\\error.txt &ping 127.0.0.1 -n 30>nul&goto l\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("echo Start copy from %2 to D:\\%d%-%1-C: %copybgntime% %copybgndate%. >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo Start copy from %2 to D:\\%d%-%1-C: %copybgntime% %copybgndate%. >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("echo Finish copy from %2 to D:\\%d%-%1-C: %copyendtime% %copyenddate%. >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo Finish copy from %2 to D:\\%d%-%1-C: %copyendtime% %copyenddate%. >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("echo Finish comp from %2 to D:\\%d%-%1-C: %compendtime% %compenddate%. >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo Finish comp from %2 to D:\\%d%-%1-C: %compendtime% %compenddate%. >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("set info=%s%-%d%-%1-copy\r\n",sizeof("set info=%s%-%d%-%1-copy\r\n")-1);
	CCbat.Write("call %~dp0count %copybgntime% %copyendtime% C:\\%info%\r\n",sizeof("call %~dp0count %copybgntime% %copyendtime% C:\\%info%\r\n")-1);
	CCbat.Write("set info=%s%-%d%-%1-comp\r\n",sizeof("set info=%s%-%d%-%1-comp\r\n")-1);
	CCbat.Write("call %~dp0count %copyendtime% %compendtime% C:\\%info%\r\n",sizeof("call %~dp0count %copyendtime% %compendtime% C:\\%info%\r\n")-1);
	CCbat.Write("\r\n",sizeof("\r\n")-1);
	CCbat.Write("rd /s /q %3\r\n",sizeof("rd /s /q %3\r\n")-1);
	CCbat.Write("rd /s /q D:\\%d%-%1-C\r\n",sizeof("rd /s /q D:\\%d%-%1-C\r\n")-1);
	CCbat.Write("echo **************  Loop %looptime% has finished ***************** >>C:\\%s%-%d%-%1.txt\r\n",sizeof("echo **************  Loop %looptime% has finished ***************** >>C:\\%s%-%d%-%1.txt\r\n")-1);
	CCbat.Write("set /a looptime=looptime+1\r\n",sizeof("set /a looptime=looptime+1\r\n")-1);
	CCbat.Write("ping 127.0.0.1 -n 05>nul\r\n",sizeof("ping 127.0.0.1 -n 05>nul\r\n")-1);
	CCbat.Write("goto loop\r\n",sizeof("goto loop\r\n")-1);
	CCbat.Flush();
	CCbat.Close();

	GetTempPath(MAX_PATH,SysTmpPath);
	filename = SysTmpPath;
	filename+=_T("count.bat");
	iffind = finder.FindFile(filename);
	if(iffind)
	{
		CFile CCcount;
		CCcount.Remove(filename);
	}

	CFile Countbat(filename, CFile::modeCreate|CFile::modeWrite);

	Countbat.Write("set tmptime=%1\r\n",sizeof("set tmptime=%1\r\n")-1);
	Countbat.Write("if %tmptime:~2,1%==: (\r\n",sizeof("if %tmptime:~2,1%==: (\r\n")-1);
	Countbat.Write("set /a hour=%tmptime:~0,2%\r\n",sizeof("set /a hour=%tmptime:~0,2%\r\n")-1);
	Countbat.Write("if %tmptime:~3,1%==0 set /a min=%tmptime:~4,1%\r\n",sizeof("if %tmptime:~3,1%==0 set /a min=%tmptime:~4,1%\r\n")-1);
	Countbat.Write("if %tmptime:~3,1% NEQ 0 set /a min=%tmptime:~3,2%\r\n",sizeof("if %tmptime:~3,1% NEQ 0 set /a min=%tmptime:~3,2%\r\n")-1);
	Countbat.Write("if %tmptime:~6,1%==0 set /a sec=%tmptime:~7,1%\r\n",sizeof("if %tmptime:~6,1%==0 set /a sec=%tmptime:~7,1%\r\n")-1);
	Countbat.Write("if %tmptime:~6,1% NEQ 0 set /a sec=%tmptime:~6,2%)\r\n",sizeof("if %tmptime:~6,1% NEQ 0 set /a sec=%tmptime:~6,2%)\r\n")-1);
	Countbat.Write("if %tmptime:~1,1%==: (\r\n",sizeof("if %tmptime:~1,1%==: (\r\n")-1);
	Countbat.Write("set /a hour=%tmptime:~0,1%\r\n",sizeof("set /a hour=%tmptime:~0,1%\r\n")-1);
	Countbat.Write("if %tmptime:~2,1%==0 set /a min=%tmptime:~3,1%\r\n",sizeof("if %tmptime:~2,1%==0 set /a min=%tmptime:~3,1%\r\n")-1);
	Countbat.Write("if %tmptime:~2,1% NEQ 0 set /a min=%tmptime:~2,2%\r\n",sizeof("if %tmptime:~2,1% NEQ 0 set /a min=%tmptime:~2,2%\r\n")-1);
	Countbat.Write("if %tmptime:~5,1%==0 set /a sec=%tmptime:~6,1%\r\n",sizeof("if %tmptime:~5,1%==0 set /a sec=%tmptime:~6,1%\r\n")-1);
	Countbat.Write("if %tmptime:~5,1% NEQ 0 set /a sec=%tmptime:~5,2%)\r\n",sizeof("if %tmptime:~5,1% NEQ 0 set /a sec=%tmptime:~5,2%)\r\n")-1);
	Countbat.Write("set /a begin=%hour%*3600+%min%*60+%sec%\r\n",sizeof("set /a begin=%hour%*3600+%min%*60+%sec%\r\n")-1);
	Countbat.Write("\r\n",sizeof("\r\n")-1);
	Countbat.Write("set tmptime=%2\r\n",sizeof("set tmptime=%2\r\n")-1);
	Countbat.Write("if %tmptime:~2,1%==: (\r\n",sizeof("if %tmptime:~2,1%==: (\r\n")-1);
	Countbat.Write("set /a hour=%tmptime:~0,2%\r\n",sizeof("set /a hour=%tmptime:~0,2%\r\n")-1);
	Countbat.Write("if %tmptime:~3,1%==0 set /a min=%tmptime:~4,1%\r\n",sizeof("if %tmptime:~3,1%==0 set /a min=%tmptime:~4,1%\r\n")-1);
	Countbat.Write("if %tmptime:~3,1% NEQ 0 set /a min=%tmptime:~3,2%\r\n",sizeof("if %tmptime:~3,1% NEQ 0 set /a min=%tmptime:~3,2%\r\n")-1);
	Countbat.Write("if %tmptime:~6,1%==0 set /a sec=%tmptime:~7,1%\r\n",sizeof("if %tmptime:~6,1%==0 set /a sec=%tmptime:~7,1%\r\n")-1);
	Countbat.Write("if %tmptime:~6,1% NEQ 0 set /a sec=%tmptime:~6,2%)\r\n",sizeof("if %tmptime:~6,1% NEQ 0 set /a sec=%tmptime:~6,2%)\r\n")-1);
	Countbat.Write("if %tmptime:~1,1%==: (\r\n",sizeof("if %tmptime:~1,1%==: (\r\n")-1);
	Countbat.Write("set /a hour=%tmptime:~0,1%\r\n",sizeof("set /a hour=%tmptime:~0,1%\r\n")-1);
	Countbat.Write("if %tmptime:~2,1%==0 set /a min=%tmptime:~3,1%\r\n",sizeof("if %tmptime:~2,1%==0 set /a min=%tmptime:~3,1%\r\n")-1);
	Countbat.Write("if %tmptime:~2,1% NEQ 0 set /a min=%tmptime:~2,2%\r\n",sizeof("if %tmptime:~2,1% NEQ 0 set /a min=%tmptime:~2,2%\r\n")-1);
	Countbat.Write("if %tmptime:~5,1%==0 set /a sec=%tmptime:~6,1%\r\n",sizeof("if %tmptime:~5,1%==0 set /a sec=%tmptime:~6,1%\r\n")-1);
	Countbat.Write("if %tmptime:~5,1% NEQ 0 set /a sec=%tmptime:~5,2%)\r\n",sizeof("if %tmptime:~5,1% NEQ 0 set /a sec=%tmptime:~5,2%)\r\n")-1);
	Countbat.Write("set /a final=%hour%*3600+%min%*60+%sec%\r\n",sizeof("set /a final=%hour%*3600+%min%*60+%sec%\r\n")-1);
	Countbat.Write("\r\n",sizeof("\r\n")-1);
	Countbat.Write("set /a total=%final%-%begin%\r\n",sizeof("set /a total=%final%-%begin%\r\n")-1);
	Countbat.Write("set info=%3\r\n",sizeof("set info=%3\r\n")-1);
	Countbat.Write("echo total %info% time: %total% seconds >>%info:~0,-5%.txt\r\n",sizeof("echo total %info% time: %total% seconds >>%info:~0,-5%.txt\r\n")-1);
	Countbat.Write("echo --                            >>%info:~0,-5%.txt\r\n",sizeof("echo --                            >>%info:~0,-5%.txt\r\n")-1);
	Countbat.Flush();
	Countbat.Close();

	return FALSE;  // 除非将焦点设置到控件,否则返回 TRUE
}
Ejemplo n.º 6
0
void CExportData::Produce2FloppyDisk(CString DestFileName,CString FloppyFileName)
{
	CFile SrcFile; 
   
	if(!SrcFile.Open(DestFileName,CFile::modeRead))
	{
		AfxMessageBox("打开文件出错!");
		return;
	}
	int LengthOfSrcFile=SrcFile.GetLength();

	int BytesPerDisk=1457000;
	int NumOfDisks=LengthOfSrcFile%BytesPerDisk==0?LengthOfSrcFile/BytesPerDisk:LengthOfSrcFile/BytesPerDisk+1;
	CString str;
	str.Format("%d",NumOfDisks);
	str="要导出到软盘上, 大约需要 " + str + " 张软盘(3.5寸)。";
	if( AfxMessageBox(str,MB_OKCANCEL)==IDCANCEL )
	{
		SrcFile.Close();
		SrcFile.Remove(DestFileName);
		return;
	}
	DWORD SectorsPerCluster,BytesPerSector,NumberOfFreeClusters,TotalNumberOfClusters;
	for(int nDisk=1;nDisk<=(NumOfDisks+1);nDisk++)
	{
	
		int nSize=min(BytesPerDisk,LengthOfSrcFile);
		if(nSize<=0)
		{
	
			SrcFile.Close();
			SrcFile.Remove(DestFileName);
			return;
		}
	    
		str.Format("%d",nDisk);
	    str="请插入第 "+str+" 张软盘。";
		if( AfxMessageBox(str,MB_OKCANCEL)==IDCANCEL )
		{
			SrcFile.Close();
			SrcFile.Remove(DestFileName);
			return;
		}

	
		::GetDiskFreeSpace(FloppyFileName.Mid(0,2),&SectorsPerCluster,&BytesPerSector,&NumberOfFreeClusters,&TotalNumberOfClusters);
		int FreeSpacePerDisk=NumberOfFreeClusters*SectorsPerCluster*BytesPerSector;
		
		while(FreeSpacePerDisk<(BytesPerDisk+8))
		{
			AfxMessageBox("请删除磁盘上的所有数据,或者格式化磁盘。按确定继续导出!",MB_ICONASTERISK);
			::GetDiskFreeSpace(FloppyFileName.Mid(0,2),&SectorsPerCluster,&BytesPerSector,&NumberOfFreeClusters,&TotalNumberOfClusters);
		    FreeSpacePerDisk=NumberOfFreeClusters*SectorsPerCluster*BytesPerSector;
			//return;
		}
		CFile FloppyFile(FloppyFileName,CFile::modeCreate|CFile::modeWrite);
		FloppyFile.Write(&NumOfDisks,sizeof(4));
		FloppyFile.Write(&nDisk,sizeof(4));
		BYTE *Buffer=new BYTE[nSize];
		SrcFile.Read(Buffer,nSize);
		FloppyFile.Write(Buffer,nSize);
		delete []Buffer;
        FloppyFile.Close();
		LengthOfSrcFile-=nSize;
	}
	SrcFile.Close();
	SrcFile.Remove(DestFileName);
}
Ejemplo n.º 7
0
BOOL CExportData::IsDirectoryExist()
{
	CFileFind finder;
	BOOL bWorking;
	CString Filepath,FileName,strNl;
	CFile DeleFile;
	CString GetUserPath;
	m_destination.GetWindowText(GetUserPath);
	GetUserPath.TrimRight("\\");
	
	GetUserPath+="\\";
   
	if(((CComboBox*)GetDlgItem(1011))->GetCurSel()==0)
	{
		FileName="导出1分钟二进制数据";
	    strNl=".1mn";
	}
	if(((CComboBox*)GetDlgItem(1011))->GetCurSel()==1)
	{
		FileName="导出1分钟文本数据";
		strNl=".txt";
	}
	if(((CComboBox*)GetDlgItem(1011))->GetCurSel()==2)
	{
		FileName="导出1分钟EXCEL数据";
		strNl=".xls";
	}

	if (!(bWorking=finder.FindFile(GetUserPath+FileName+"\\*.*") ) )
		if(!(::CreateDirectory(GetUserPath+  FileName,NULL)))
		{
			AfxMessageBox("路径中包括错误的路径,请重新设置!");
			m_destination.SetFocus();
			return 1;
		}
	
	if(bWorking)
	if( AfxMessageBox("存在同名文件,是否覆盖?",MB_ICONQUESTION|MB_YESNO )==IDNO )
			return 1;

	if (  !(bWorking=finder.FindFile(GetUserPath+FileName+"\\沪A\\"+strNl) ) )
		::CreateDirectory(GetUserPath+  FileName+"\\沪A",NULL);

	while(bWorking)
	{
		bWorking=finder.FindNextFile();
		Filepath=finder.GetFilePath();
		DeleFile.Remove(Filepath);
	}

	if (  !(bWorking=finder.FindFile(GetUserPath+FileName+"\\沪B\\"+strNl)  ))
		::CreateDirectory(  GetUserPath+FileName+"\\沪B",NULL);
		else while(bWorking)
		   {
			   bWorking=finder.FindNextFile();
			   Filepath=finder.GetFilePath();
			   DeleFile.Remove(Filepath);
		   }
	if (  !(bWorking= finder.FindFile(GetUserPath+FileName+"\\沪指\\"+strNl)  ))
		::CreateDirectory( GetUserPath+ FileName+"\\沪指",NULL);
			else while(bWorking)
		   {
			   bWorking=finder.FindNextFile();
			   Filepath=finder.GetFilePath();
			   DeleFile.Remove(Filepath);
		   }

	if (  !(bWorking= finder.FindFile(GetUserPath+FileName+"\\沪债\\"+strNl)  ))
		::CreateDirectory(  GetUserPath+FileName+"\\沪债",NULL);
			else while(bWorking)
		   {
			   bWorking=finder.FindNextFile();
			   Filepath=finder.GetFilePath();
			   DeleFile.Remove(Filepath);
		   }


	if (  !(bWorking= finder.FindFile(GetUserPath+FileName+"\\深A\\"+strNl)  ))
		::CreateDirectory(GetUserPath+ FileName+"\\深A",NULL);
			else while(bWorking)
		   {
			   bWorking=finder.FindNextFile();
			   Filepath=finder.GetFilePath();
			   DeleFile.Remove(Filepath);
		   }

	if (  !(bWorking= finder.FindFile(GetUserPath+FileName+"\\深B\\"+strNl)  ))
		::CreateDirectory( GetUserPath+ FileName+"\\深B",NULL);		
	   else while(bWorking)
		   {
			   bWorking=finder.FindNextFile();
			   Filepath=finder.GetFilePath();
			   DeleFile.Remove(Filepath);
		   }

	if (  !(bWorking= finder.FindFile(GetUserPath+FileName+"\\深指\\"+strNl)  ))
		::CreateDirectory(GetUserPath+ FileName+"\\深指",NULL);
			else while(bWorking)
		   {
			   bWorking=finder.FindNextFile();
			   Filepath=finder.GetFilePath();
			   DeleFile.Remove(Filepath);
		   }

	if (  !(bWorking=finder.FindFile(GetUserPath+FileName+"\\深债\\"+strNl)  ))
		::CreateDirectory(GetUserPath+  FileName+"\\深债",NULL);
			else while(bWorking)
		   {
			   bWorking=finder.FindNextFile();
			   Filepath=finder.GetFilePath();
			   DeleFile.Remove(Filepath);
		   }

     return 0;
}
Ejemplo n.º 8
0
static int deleteTempFile(void)
{
    CFile TempFile;
    TempFile.Remove(SVN_LOG_FILE);
    return 0;
}
Ejemplo n.º 9
0
//下载函数
int InternetGetFile(TCHAR szUrl[], TCHAR szFileName[],CString &filename)
{
	CString title;
	CString name;//源文件名
	CString destname;//目标文件名
	CString Fullpath;//目标全路径
	CString path;	//目标全路径不包括文件名
	//	TCHAR szMsg[1000];
	//	DWORD err;
	//获取源文件名
	name=szUrl;
	int cur=name.ReverseFind('/');
	name=name.Mid(cur+1,name.GetLength()-1-cur);
	TCHAR g_CurDir[MAX_PATH+1];
	
    // PengJiLin, 2010-6-7, GetCurrentDirectory()函数全部替代
    //::GetCurrentDirectory(MAX_PATH,g_CurDir);
    lstrcpy(g_CurDir, CBcfFile::GetAppPath());

	if(szFileName)
	{//如果指定了目录文件名,则用目录文件名
		destname=szFileName;
		if(destname.GetAt(0)=='\\')
			destname=destname.Mid(1,destname.GetLength()-1);
		//组成全路径名
		Fullpath.Format(TEXT("%s\\%s"),g_CurDir,destname);
	}
	else
	{//没有指定则用源文件名
		TCHAR tempath[MAX_PATH+1];
		DWORD len=GetTempPath(MAX_PATH,tempath);
		if(len == 0 || len > MAX_PATH)
		{
			return -1;
		}
		if(len<=MAX_PATH)
		{
			tempath[len*sizeof(TCHAR)+1]='\0';
		}
		TCHAR tempname[MAX_PATH+1];
		if(!::GetTempFileName(tempath,TEXT("bzw"),0,tempname))
		{
			return -1;
		}
		Fullpath=tempname;
	}
	//获取目标全路径不包括文件名
	path=Fullpath;
	cur=path.ReverseFind('\\');
	destname=path;
	path=destname.Mid(cur+1,destname.GetLength()-1-cur);
	destname=Fullpath;
	if(filename)
		filename=destname;

	DWORD dwFlags;
	InternetGetConnectedState(&dwFlags, 0);
	TCHAR strAgent[64];
	memset(strAgent,0,sizeof(strAgent));
	wsprintf(strAgent, TEXT("Agent%ld"), timeGetTime());
	HINTERNET hOpen;
	if(!(dwFlags & INTERNET_CONNECTION_PROXY))
		hOpen = InternetOpen(strAgent, INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY, NULL, NULL, 0);
	else
		hOpen = InternetOpen(strAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
	if(!hOpen)
	{//显示错误信息
		return -1;
	}

	DWORD dwSize;
	TCHAR   szHead[] = TEXT("Accept: */*\r\n\r\n");
	VOID* szTemp[16384];
	HINTERNET  hConnect;
	CFile file;

	if ( !(hConnect = InternetOpenUrl( hOpen, szUrl, szHead,
		lstrlen(szHead), INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_RELOAD, 0)))
	{//显示错误信息
		InternetCloseHandle(hOpen);
		return -1;
	}
	bool CreateDir=false;
retry:
	if(file.Open(destname.GetBuffer(),CFile::modeWrite|CFile::modeCreate)==FALSE)
	{//显示错误信息
		int err=GetLastError();
		if(!CreateDir)
		{//创建目录,然后重试
			::CreateDirectory(path.GetBuffer(),NULL);
			CreateDir = true;
			goto retry;
		}
		return -1;
	} 

	DWORD dwByteToRead = 0;
	DWORD dwSizeOfRq = 4;
	DWORD dwBytes = 0;

	if (!HttpQueryInfo(hConnect, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, 
		(LPVOID)&dwByteToRead, &dwSizeOfRq, NULL))
	{
		dwByteToRead = 0;
	}
	memset(szTemp,0,sizeof(szTemp));
	do
	{
		if(false)
		{
			file.Close();
			file.Remove(destname.GetBuffer());
			InternetCloseHandle(hConnect);
			InternetCloseHandle(hOpen);
			return -1;
		}
		if (!InternetReadFile (hConnect, szTemp, 16384,  &dwSize))
		{//显示错误信息
			file.Close();
			file.Remove(destname.GetBuffer());
			InternetCloseHandle(hConnect);
			InternetCloseHandle(hOpen);
			return -1;
		}
		if (dwSize==0)
			break;
		else
		{
			file.Write(szTemp,dwSize);
		}
	}while (TRUE);
	file.Close();
	InternetCloseHandle(hConnect);
	InternetCloseHandle(hOpen);
	return 0;
}
Ejemplo n.º 10
0
void CChuquanData::OutChuQuanData(CString FilePath)
{
	::SetCurrentDirectory(pDoc->m_CurrentWorkDirectory);

	UpdateData(TRUE);
	CFile OutFile;
	if(!OutFile.Open(FilePath,CFile::modeCreate|CFile::modeWrite,NULL))
	{
		MessageBox("导出除权信息失败!","警告",MB_OK|MB_ICONEXCLAMATION);
		return;
	}
	int nHeaderFlag=-1;
	int nTotalCount=0;
	POWER Power;
	struct POWER_1th      
	{
		BYTE  byFree[8];  
		int   nFlags;     
		int   nTime;
		float fGive;      
		float fAllocate;
		float fAllocatePrice;//行情数据结构数组类实现
		float fDividend;
	};
	POWER_1th Power_1th;
	int nSplitMask=-1;

	//int FileId=FILEID22;
	//OutFile.Write(&FileId,4);
	OutFile.Seek(8,CFile::begin);


	for(int nStockType=0;nStockType<8;nStockType++)
	{
		for(int i=0;i<pDoc->m_sharesInformation.GetStockTypeCount(nStockType);i++)
		{

			CReportData *pDat1=NULL;
			pDoc->m_sharesInformation.GetStockItem(nStockType,i,pDat1);
			if(pDat1)
			{
				if(pDat1->pBaseInfo)
				{
					if(pDat1->pBaseInfo->NumSplit>0)
					{
						nTotalCount++;
						OutFile.Write(&nSplitMask,sizeof(int));
						OutFile.Write(&(pDat1->id),8*sizeof(char));	

						int a =pDat1->kind;
						OutFile.Write(&a,4);

						for(int j=0;j<pDat1->pBaseInfo->NumSplit;j++)
						{
							memcpy(&Power,&(pDat1->
								pBaseInfo->m_Split[j]),sizeof(POWER));
							Power_1th.fAllocate=Power.fAllocate;
							Power_1th.fAllocatePrice=Power.fAllocatePrice;
							Power_1th.fDividend=Power.fDividend;
							Power_1th.fGive=Power.fGive;
							Power_1th.nTime=Power.nTime;
							OutFile.Write(&Power_1th,sizeof(POWER_1th));
						}
					}
				}
			}
		}
	}

	OutFile.Close();
	//	}
	if(nTotalCount==0)
	{//数据文件读写实现
		AfxMessageBox("没有除权数据!",MB_ICONASTERISK);
		OutFile.Remove(FilePath);
	}
	else
		AfxMessageBox("导出完毕!",MB_ICONASTERISK);
}