void CZogvmDlg::OnButtonBuild() { // TODO: Add your control notification handler code here GetDlgItem(IDC_BUTTON_BUILD)->EnableWindow(FALSE); aaaa=GetTickCount(); SQLDB.Begin(); SQLDB.Hdd_SetNonsert(); CDLGHdd::Add27HDDid(); SQLDB.Commit(); hddList.clear(); //几个硬盘开几个线程 SQLDB.Hdd_Read(hddList); bool flag=false; list<struct HDD_ST>::iterator beglist; for(beglist=hddList.begin();beglist!=hddList.end();beglist++) { beglist->dealstep=DEALSTEP_ALL_END; if(beglist->insertflag && beglist->enable) { flag=true; beglist->dealstep=DEALSTEP_START; CreateThread(NULL,0,BuildThreadPROC,(void*)&(*beglist),0,NULL); } } if(false == flag) GetDlgItem(IDC_BUTTON_BUILD)->EnableWindow(TRUE); }
BOOL CZogvmApp::InitInstance() { AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif GetCurrentDirectory(MAX_PATH, CurrentDir); SQLDB.OpenDB("zogvm.db"); SQLDB.ZiDian_CreateTable(); SQLDB.Type_CreateTable(); SQLDB.Type_AddAll(); SQLDB.Hdd_CreateTable(); SQLDB.File_CreateTable(); SQLDB.File_CreateView(); SQLDB.Double_CreateTable(); SQLDB.Begin(); SQLDB.File_SetNoFlagAll(); SQLDB.Hdd_SetNonsert(); CDLGHdd::Add27HDDid(); SQLDB.Commit(); CZogvmDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } SQLDB.CloseDB(); // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
void CZogvmDlg::OnButtonBuild() { // TODO: Add your control notification handler code here GetDlgItem(IDC_BUTTON_BUILD)->EnableWindow(FALSE); aaaa=GetTickCount(); SQLDB.Begin(); SQLDB.Hdd_SetNonsert(); CDLGHdd::Add27HDDid(); SQLDB.Commit(); CreateThread(NULL,0,BuildThreadPROC,(void*)this,0,NULL); }
DWORD WINAPI ExeclThreadPROC(LPVOID lpParameter) { char path[260]; strcpy(path,(char *)lpParameter); unsigned short fontsize=256; workbook w; worksheet **sheet; long sheetTotal=0; long long *filenum; xf_t *xf = NULL; int i=0; long j,k,m; SYSTEMTIME systime; FILETIME temptime; ULARGE_INTEGER uli; int ret; char str[2048]; wchar_t wbuff[2048]; list<struct HDD_ST> MyhddList; SQLDB.Hdd_SetNonsert(); CDLGHdd::Add27HDDid(); MyhddList.clear(); SQLDB.Hdd_Read(MyhddList); if(MyhddList.size()<=0) { MessageBox(NULL,"没有硬盘","导出EXECL",MB_OK); return 0; } //导出硬盘 sheetTotal=1; sheet=(worksheet **)calloc(sheetTotal,sizeof(worksheet *)); filenum=(long long *)calloc(MyhddList.size(),sizeof(long long)); xf= w.xformat(); //xf->SetLocked(true) ;无效代码 sheet[0]=w.sheet(L"硬盘目录"); sheet[0]->colwidth(0,10*fontsize); sheet[0]->label(0,0,L"磁盘序列号"); sheet[0]->colwidth(1,10*fontsize); sheet[0]->label(0,1,L"分区"); sheet[0]->colwidth(2,30*fontsize); sheet[0]->label(0,2,L"标签"); sheet[0]->colwidth(3,20*fontsize); sheet[0]->label(0,3,L"总空间"); sheet[0]->colwidth(4,20*fontsize); sheet[0]->label(0,4,L"剩余空间"); list<struct HDD_ST>::iterator beglist; for(i=1,beglist=MyhddList.begin();beglist!=MyhddList.end();i++,beglist++) { MultiByteToWideChar(CP_ACP, 0, beglist->serno, -1, wbuff, 2048); sheet[0]->label(i,0,wbuff); MultiByteToWideChar(CP_ACP, 0, beglist->area, -1, wbuff, 2048); sheet[0]->label(i,1,wbuff); MultiByteToWideChar(CP_ACP, 0, beglist->mark, -1, wbuff, 2048); sheet[0]->label(i,2,wbuff); sprintf(str,"%I64u",beglist->TotalBytes); MultiByteToWideChar(CP_ACP, 0, str, -1, wbuff, 2048); sheet[0]->label(i,3,wbuff); sprintf(str,"%I64u",beglist->FreeBytes); MultiByteToWideChar(CP_ACP, 0, str, -1, wbuff, 2048); sheet[0]->label(i,4,wbuff); filenum[i-1]=SQLDB.File_NumberForHDD(beglist->hdd_nid); sheetTotal += (long)(filenum[i-1]/10000) +1; } //导出文件 sheet=(worksheet **)realloc(sheet,sheetTotal*sizeof(worksheet *)); outputList.clear(); list<struct FILE_VIEW_ST>::iterator filebeglist; k=1; for(i=0,beglist=MyhddList.begin();beglist!=MyhddList.end();i++,beglist++) { if(filenum[i] <= 0) continue; for(j=0;j< (long)(filenum[i]/10000) +1;j++) { sprintf(str,"%s %s %d",beglist->serno,beglist->mark,j); MultiByteToWideChar(CP_ACP, 0, str, -1, wbuff, 2048); sheet[k]=w.sheet(wbuff); sheet[k]->colwidth(0,10*fontsize); sheet[k]->label(0,0,L"序号"); sheet[k]->colwidth(1,150*fontsize); sheet[k]->label(0,1,L"文件路径"); sheet[k]->colwidth(2,5*fontsize); sheet[k]->label(0,2,L"类型"); sheet[k]->colwidth(3,5*fontsize); sheet[k]->label(0,3,L"后缀"); sheet[k]->colwidth(4,20*fontsize); sheet[k]->label(0,4,L"创建时间"); sheet[k]->colwidth(5,20*fontsize); sheet[k]->label(0,5,L"修改时间"); sheet[k]->colwidth(6,15*fontsize); sheet[k]->label(0,6,L"文件大小"); sheet[k]->colwidth(7,10*fontsize); sheet[k]->label(0,7,L"分辨率"); sheet[k]->colwidth(8,5*fontsize); sheet[k]->label(0,8,L"3D"); outputList.clear(); SQLDB.File_ReadHddPage(outputList,beglist->hdd_nid,true,j*10000,10000); if(outputList.size() <= 0) continue; for(m=1,filebeglist=outputList.begin();filebeglist!=outputList.end();m++,filebeglist++) { sprintf(str,"%I64u",filebeglist->file_data.file_nid); MultiByteToWideChar(CP_ACP, 0, str, -1, wbuff, 2048); sheet[k]->label(m,0,wbuff); sprintf(str,"%s%s",filebeglist->file_data.path,filebeglist->file_data.name); MultiByteToWideChar(CP_ACP, 0, str, -1, wbuff, 2048); sheet[k]->label(m,1,wbuff); sprintf(str,"%s",MainType2Str(filebeglist->file_data.maintype)); MultiByteToWideChar(CP_ACP, 0, str, -1, wbuff, 2048); sheet[k]->label(m,2,wbuff); MultiByteToWideChar(CP_ACP, 0, filebeglist->file_data.type, -1, wbuff, 2048); sheet[k]->label(m,3,wbuff); if(filebeglist->file_data.CreationTime) { uli.QuadPart=filebeglist->file_data.CreationTime; temptime.dwLowDateTime=uli.LowPart; temptime.dwHighDateTime=uli.HighPart; FileTimeToSystemTime(&temptime,&systime); sprintf(str,"%04d-%02d-%02d %02d:%02d:%02d", systime.wYear,systime.wMonth,systime.wDay, systime.wHour,systime.wMinute,systime.wSecond); MultiByteToWideChar(CP_ACP, 0, str, -1, wbuff, 2048); sheet[k]->label(m,4,wbuff); } if(filebeglist->file_data.LastWriteTime) { uli.QuadPart=filebeglist->file_data.LastWriteTime; temptime.dwLowDateTime=uli.LowPart; temptime.dwHighDateTime=uli.HighPart; FileTimeToSystemTime(&temptime,&systime); sprintf(str,"%04d-%02d-%02d %02d:%02d:%02d", systime.wYear,systime.wMonth,systime.wDay, systime.wHour,systime.wMinute,systime.wSecond); MultiByteToWideChar(CP_ACP, 0, str, -1, wbuff, 2048); sheet[k]->label(m,5,wbuff); } sprintf(str,"%I64u",filebeglist->file_data.filesize); MultiByteToWideChar(CP_ACP, 0, str, -1, wbuff, 2048); sheet[k]->label(m,6,wbuff); MultiByteToWideChar(CP_ACP, 0, filebeglist->file_data.zidian_fenbianlv , -1, wbuff, 2048); sheet[k]->label(m,7,wbuff); MultiByteToWideChar(CP_ACP, 0, filebeglist->file_data.zidian_3d, -1, wbuff, 2048); sheet[k]->label(m,8,wbuff); } k++; } } MyhddList.clear(); outputList.clear(); MultiByteToWideChar(CP_ACP, 0, path, -1, wbuff, 2048); ret = w.Dump(wbuff); free(filenum); free(sheet); pZogvmDlg->GetDlgItem(IDC_BUTTON_OUTPUTEXECL)->EnableWindow(TRUE); if (ret != 0) { MessageBox(NULL,"导出失败","导出EXECL",MB_OK); return 0; } MessageBox(NULL,"导出完成","导出EXECL",MB_OK); return 0; }