本文整理汇总了C++中CFileFind类的典型用法代码示例。如果您正苦于以下问题:C++ CFileFind类的具体用法?C++ CFileFind怎么用?C++ CFileFind使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CFileFind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEXT
void CBATCHDlg::OnBnClickedButtonSeletepath()
{
TCHAR szFolderPath[MAX_PATH] = {0};
CString strFolderPath = TEXT("");
BROWSEINFO sInfo;
::ZeroMemory(&sInfo, sizeof(BROWSEINFO));
sInfo.pidlRoot = 0;
sInfo.lpszTitle = _T("ÇëÑ¡ÔñÒ»¸öÎļþ¼Ð£º");
sInfo.ulFlags = BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE | BIF_EDITBOX;
sInfo.lpfn = NULL;
// ÏÔʾÎļþ¼ÐÑ¡Ôñ¶Ô»°¿ò
LPITEMIDLIST lpidlBrowse = ::SHBrowseForFolder(&sInfo);
if (lpidlBrowse != NULL)
{
// È¡µÃÎļþ¼ÐÃû
if (::SHGetPathFromIDList(lpidlBrowse,szFolderPath))
{
strFolderPath = szFolderPath;
m_path = strFolderPath;
CString str_file = strFolderPath;
CString res_str;
m_images.clear();
CString suffixs[] = {"\\*.jpg","\\*.jpeg","\\*.bmp","\\*.png"};
for(int i = 0; i < 4; ++i)
{
CFileFind finder;
CString filepathname;
BOOL YesNo=finder.FindFile(str_file + suffixs[i]);
while (YesNo)
{
YesNo=finder.FindNextFile();
filepathname=finder.GetFilePath();
m_images.push_back(filepathname);
}
}
for(vector<CString>::size_type v_i = 0; v_i != m_images.size(); ++v_i)
{
res_str += m_images[v_i];
res_str += "\r\n";
}
m_res = res_str;
UpdateData(FALSE);
}
}
if(lpidlBrowse != NULL)
{
::CoTaskMemFree(lpidlBrowse);
}
}
示例2: fillFiles
void ListFileProvider::fillFiles( const CString& path )
{
CFileFind finder;
CString p = path + "\\*.*";
if ( !finder.FindFile( p ) )
return;
// hack to avoid reading
std::string legacyThumbnailPostfix = ".thumbnail.bmp";
int legacyThumbSize = (int)legacyThumbnailPostfix.length();
int thumbSize = (int)thumbnailPostfix_.length();
bool ignoreFiles = false;
if ( !includeFolders_.empty()
&& !StringUtils::matchSpec( (LPCTSTR)path, includeFolders_ ) )
ignoreFiles = true;
BOOL notEOF = TRUE;
while( notEOF && getThreadWorking() )
{
notEOF = finder.FindNextFile();
if ( !finder.IsDirectory() )
{
if ( !ignoreFiles )
{
std::string fname( (LPCTSTR)finder.GetFileName() );
if ( StringUtils::matchExtension( fname, extensions_ )
&& ( (int)fname.length() <= thumbSize
|| fname.substr( fname.length() - thumbSize ) != thumbnailPostfix_ )
&& ( (int)fname.length() <= legacyThumbSize
|| fname.substr( fname.length() - legacyThumbSize ) != legacyThumbnailPostfix )
)
{
ListItemPtr item = new ListItem();
item->fileName = (LPCTSTR)finder.GetFilePath();
item->dissolved = BWResource::dissolveFilename( item->fileName );
item->title = (LPCTSTR)finder.GetFileName();
threadMutex_.grab();
if ( (threadItems_.size() % VECTOR_BLOCK_SIZE) == 0 )
threadItems_.reserve( threadItems_.size() + VECTOR_BLOCK_SIZE );
threadItems_.push_back( item );
threadMutex_.give();
}
}
}
else if ( !finder.IsDots()
&& !( flags_ & LISTFILEPROV_DONTRECURSE )
&& ( excludeFolders_.empty()
|| !StringUtils::matchSpec( (LPCTSTR)finder.GetFilePath(), excludeFolders_ ) )
)
{
fillFiles( finder.GetFilePath() );
}
if ( threadYieldMsec_ > 0 )
{
if ( ( clock() - yieldClock_ ) * 1000 / CLOCKS_PER_SEC > threadYieldMsec_ )
{
Sleep( 50 ); // yield
yieldClock_ = clock();
}
}
if ( ( clock() - flushClock_ ) * 1000 / CLOCKS_PER_SEC >= threadFlushMsec_ )
{
flushThreadBuf();
flushClock_ = clock();
}
}
}
示例3: SetWindowPos
BOOL CDlgNote::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 在此添加额外的初始化
///SetWindowPos(NULL, 0+1, CAPTIONHEIGHT+TOOLHEIGHT+1, MINSIZEX-2, MINSIZEY-(CAPTIONHEIGHT+TOOLHEIGHT)-2, NULL);//left top width height
SetWindowPos(NULL, 0+1, CAPTIONHEIGHT+TOOLHEIGHT+1, MINSIZEX-2, MINSIZEY-(CAPTIONHEIGHT+TOOLHEIGHT)-2, NULL);
//SetBackgroundColor(RGB(45,62,92),TRUE);
SetBackgroundColor(RGB(105,161,191),TRUE);
m_List_ctlTitle.SetBkColor(LISTCONTROLBACKGROUNDCOLOR);
m_List_ctlTitle.SetRowHeigt(25); //设置行高度
m_List_ctlTitle.SetHeaderHeight(1); //设置头部高度
m_List_ctlTitle.SetHeaderFontHW(12,0); //设置头部字体高度,和宽度,0表示缺省,自适应
m_List_ctlTitle.SetHeaderTextColor(RGB(105,161,191)); //设置头部字体颜色
m_List_ctlTitle.SetHeaderBKColor(76,85,89,1); //设置头部背景色
m_List_ctlTitle.SetFontHW(12,0); //设置字体高度,和宽度,0表示缺省宽度
m_List_ctlTitle.SetColTextColor(0,RGB(255,255,255)); //设置列文本颜色
m_List_ctlTitle.InsertColumn(0,_T("备忘标题"),LVCFMT_LEFT,80);
m_List_ctlTitle.InsertColumn(1,_T("文件路径"),LVCFMT_LEFT,0);
m_List_ctlTitle.MoveWindow(1,0,168,550+27);
CRect rcClient;
m_List_ctlTitle.GetClientRect(&rcClient);
m_List_ctlTitle.SetColumnWidth(0,rcClient.Width());
m_Button_ctlNew.LoadStdImage(IDB_PNG_NEW, _T("PNG"));
m_Button_ctlNew.MoveWindow(169,1,63,24,TRUE);//62,23
m_Button_ctlSave.LoadStdImage(IDB_PNG_NOTESAVE, _T("PNG"));
m_Button_ctlSave.MoveWindow(MINSIZEX-63*2-5-20,1,63,24,TRUE);
m_Button_ctlCancel.LoadStdImage(IDB_PNG_NOTEDEL, _T("PNG"));
m_Button_ctlCancel.MoveWindow(MINSIZEX-63-20,1,63,24,TRUE);
// CRect rcClient;
m_List_ctlTitle.GetClientRect(&rcClient);
m_List_ctlTitle.SetColumnWidth(0,rcClient.Width());
m_Edit_ctlTitle.MoveWindow(168,25,MINSIZEX-2-168,25);
m_Edit_ctlContent.MoveWindow(168,51,MINSIZEX-2-168,MINSIZEY-(CAPTIONHEIGHT+TOOLHEIGHT)-2-23-2-25-4);
int i=0;
CFileFind finder;
CString strPath;
CString strFileName;
CString strSavePath;
strSavePath=CBoBoDingApp::g_strNotePath+_T("*.txt");
BOOL bWorking = finder.FindFile(strSavePath);
while (bWorking)
{
bWorking = finder.FindNextFile();
strPath=finder.GetFilePath();
strFileName=finder.GetFileTitle();
//strPath就是所要获取Test目录下的文件夹和文件(包括路径)
m_List_ctlTitle.InsertItem(i,strFileName,LVCFMT_LEFT);
m_List_ctlTitle.SetItemText(i,1,strPath);
i++;
}
m_Font.CreatePointFont(105, _T("宋体"));
m_Edit_ctlTitle.SetFont(&m_Font);
m_Edit_ctlContent.SetFont(&m_Font);
m_List_ctlTitle.EnableScrollBar(SB_HORZ, ESB_DISABLE_BOTH);
/******************************************************************************/
//.........这里部分代码省略.........
示例4: BufferAppend
//.........这里部分代码省略.........
CTime time;
static int Tx, Ty, T, Rx, Ry, Tb, Tc, Td, b0, b1;
static int CurrentCounter, CurrentByte;
// Hack, for now statically allocate
static unsigned char *CameraBuffer;
static unsigned int CurrentCameraID;
static unsigned int CameraBufferIndex;
static unsigned int SegmentIndex;
static bool PictureInProgress;
static unsigned int LastPicID;
#define MAX_PIC_SIZE 80000
#define INVALID_SENSOR 0
#define PH_SENSOR 1
#define PRESSURE_SENSOR 2
#define ACCELEROMETER_SENSOR 3
#define CAMERA_SENSOR 4
#define FIRST_SEGMENT 0x1111
#define MID_SEGMENT 0
#define END_OF_PIC 0xffff
for(int channel = 0; (channel < NUMCHANNELS) && bFirstTime; channel++) {
MoteIDs[channel] = 0;
HeaderIndex = 0;
CurrentCameraID = 0;
CameraBuffer = NULL;
CameraBufferIndex = 0;
PictureInProgress = false;
}
if (bFirstTime) {
// Figure out the start of the file names
CFileFind finder;
CString TempName;
unsigned int TempID;
LastPicID = 0;
BOOL bResult = finder.FindFile("c:\\icam\\*.jpg");
while (bResult) {
bResult = finder.FindNextFile();
TempName = finder.GetFileName();
if (sscanf((LPCSTR)TempName, "%d.jpg", &TempID) == 1) {
// valid pic id
if (LastPicID < TempID) {
LastPicID = TempID;
}
}
}
LastPicID++;
}
bFirstTime = false;
TRACE("Rx...Buffer = %#X\tNumBytesReceived = %d\n",rxstring,numBytesReceived);
byte_index = 0;
while(byte_index < numBytesReceived) {
// Look for DEADBEEF, get all header info
for(; (byte_index < numBytesReceived) && !bGotBeef; byte_index++) {
switch (HeaderIndex) {
case 0:
if (rxstring[byte_index] == 0xEF) {
HeaderIndex = 1;
}
break;
case 1:
示例5: _tmain
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
HMODULE hModule = ::GetModuleHandle(NULL);
if (hModule != NULL)
{
// 初始化 MFC 并在失败时显示错误
if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0))
{
// TODO: 更改错误代码以符合您的需要
_tprintf(_T("错误: MFC 初始化失败\n"));
nRetCode = 1;
}
else
{
// TODO: 在此处为应用程序的行为编写代码。
char m_ExePath[256];
GetModuleFileName(NULL, m_ExePath, 256);
CString localpath;
localpath = m_ExePath;
int nLength = localpath.ReverseFind('\\');
localpath = localpath.Left(nLength+1);
CString configPath = localpath + "config.ini";
// ready
char inputPath[1000];
CString srcPath ;
CString dstPath ;
memset(inputPath, '\0', 1000);
GetPrivateProfileString("PATH", "srcPath", "", inputPath, sizeof(inputPath), configPath);
srcPath = inputPath;
printf("srcPath %s\n", inputPath);
GetPrivateProfileString("PATH", "dstPath", "", inputPath, sizeof(inputPath), configPath);
dstPath = inputPath;
printf("dstPath %s\n", inputPath);
int nLen = srcPath.GetLength();
char ch = srcPath.GetAt(nLen-1);
if ( ch != '\\' )
srcPath += "\\";
nLen = dstPath.GetLength();
ch = dstPath.GetAt(nLen-1);
if ( ch != '\\' )
dstPath += "\\";
vector<CString> imgSet;
// Batch
CFileFind mFinder;
CString mFilePathName;
CString mFileName;
CString strImgPath;
CString lastChars;
while (1)
{
int mMorefiles = mFinder.FindFile(srcPath + "*");
if ( mMorefiles == 0 )
{
AfxMessageBox("没有找到文件");
return 0;
}
AeiParser classBW;
//classBW.getIniPath((string)srcPath, (string)dstPath);
while ( mMorefiles )
{
mMorefiles = mFinder.FindNextFile();
mFilePathName = mFinder.GetFilePath();
if ( mFilePathName == "" )
continue;
if ( mFinder.IsDots() )
continue;
mFileName = mFilePathName.Mid(mFilePathName.ReverseFind('\\') + 1);
bool blFile = classBW.isValid((string)mFileName);
if ( !blFile )
continue;
CString mDstName = dstPath + mFileName;
bool blRtnVal = classBW.ParseFrom((string)mFilePathName);
if (!blRtnVal)
{
printf("ParseFrom Failed!\n");
}
// blRtnVal = classBW.SaveTo((string)mDstName);
// if (!blRtnVal)
// {
// printf("SaveTo Failed!\n");
// }
//.........这里部分代码省略.........
示例6: switch
void InformApp::FindExtensions(void)
{
m_extensions.clear();
for (int i = 0; i < 2; i++)
{
CString path;
switch (i)
{
case 0:
path.Format("%s\\Internal\\Extensions\\*.*",(LPCSTR)GetAppDir());
break;
case 1:
path.Format("%s\\Inform\\Extensions\\*.*",(LPCSTR)GetHomeDir());
break;
default:
ASSERT(FALSE);
break;
}
CFileFind find;
BOOL finding = find.FindFile(path);
while (finding)
{
finding = find.FindNextFile();
if (!find.IsDots() && find.IsDirectory())
{
CString author = find.GetFileName();
if (author == "Reserved")
continue;
if ((author.GetLength() > 0) && (author.GetAt(0) == '.'))
continue;
path.Format("%s\\*.*",(LPCSTR)find.GetFilePath());
CFileFind find;
BOOL finding = find.FindFile(path);
while (finding)
{
finding = find.FindNextFile();
if (!find.IsDirectory())
{
CString ext = ::PathFindExtension(find.GetFilePath());
if (ext.CompareNoCase(".i7x") == 0)
m_extensions.push_back(ExtLocation(author,find.GetFileTitle(),(i == 0),find.GetFilePath()));
else if (ext.IsEmpty() && (i == 1))
{
// Rename an old-style extension (with no file extension) to end with ".i7x"
CString newPath = find.GetFilePath();
newPath.Append(".i7x");
if (::MoveFile(find.GetFilePath(),newPath))
m_extensions.push_back(ExtLocation(author,find.GetFileTitle(),(i == 0),newPath));
}
}
}
find.Close();
}
}
find.Close();
}
std::sort(m_extensions.begin(),m_extensions.end());
}
示例7: ReadDirectory
void CACEdit::ReadDirectory(CString m_Dir)
{
CFileFind FoundFiles;
TCHAR ch;
CWaitCursor hg;
// Wenn mittem im Pfad,
// vorheriges Verzeichnis einlesen.
if (m_Dir.Right(1) != _T('\\'))
{
_tsplitpath(m_Dir, m_szDrive, m_szDir, m_szFname, m_szExt);
m_Dir.Format(_T("%s%s"),m_szDrive, m_szDir);
}
//ist hübscher
ch = (TCHAR)towupper(m_Dir.GetAt(0));
m_Dir.SetAt(0,ch);
CString m_Name,m_File,m_Dir1 = m_Dir;
if (m_Dir.Right(1) != _T('\\'))
m_Dir += _T("\\");
if(m_LastDirectory.CompareNoCase(m_Dir) == 0 && m_Liste.m_SearchList.GetSize())
return;
m_LastDirectory = m_Dir;
m_Dir += _T("*.*");
BOOL bContinue = FoundFiles.FindFile(m_Dir);
if(bContinue)
RemoveSearchAll();
while (bContinue == TRUE)
{
bContinue = FoundFiles.FindNextFile();
m_File = FoundFiles.GetFileName();
if(FoundFiles.IsHidden() || FoundFiles.IsSystem())
continue;
if(FoundFiles.IsDirectory())
{
if(m_iMode & _MODE_ONLY_FILES)
continue;
if(FoundFiles.IsDots())
continue;
if (m_File.Right(1) != _T('\\'))
m_File += _T("\\");
}
if(!FoundFiles.IsDirectory())
if(m_iMode & _MODE_ONLY_DIRS)
continue;
if(m_iMode & _MODE_FS_START_DIR_)
{
m_Name = m_File;
}
else
{
m_Name = m_Dir1;
if (m_Name.Right(1) != _T('\\'))
m_Name += _T("\\");
m_Name += m_File;
}
AddSearchString(m_Name);
}
FoundFiles.Close();
return;
}
示例8: MoveWindow
BOOL CDeskTopDlg::OnInitDialog()
{
CDialog::OnInitDialog();
HWND hProgMan = ::FindWindow(L"ProgMan", NULL);
if(hProgMan)
{
HWND hShellDefView = ::FindWindowEx(hProgMan, NULL, L"SHELLDLL_DefView", NULL);
if(hShellDefView)
m_hWndDesktop = ::FindWindowEx(hShellDefView, NULL, L"SysListView32", NULL);
}
::SetParent(m_hWnd,m_hWndDesktop);
MoveWindow(0,0,GetSystemMetrics ( SM_CXSCREEN ) ,GetSystemMetrics ( SM_CYSCREEN ));
m_DeskIconManager.SetShowWnd(m_hWnd);
CFileFind finder;
CString strPath;
BOOL bWorking = finder.FindFile(L"C:\\Users\\GaoZan\\Desktop\\*.*");
while(bWorking)
{
bWorking = finder.FindNextFile();
strPath = finder.GetFilePath();
OutputDebugStringW(strPath+L"\n");
if(finder.IsDirectory() && !finder.IsDots())
{
int a=0;
}
else if(!finder.IsDirectory() && !finder.IsDots())
{
CString strIconText;
strIconText = finder.GetFileTitle();
CString strNotePadPath(strPath);
SHFILEINFO stFileInfo;
:: SHGetFileInfo( strNotePadPath,0,&stFileInfo,sizeof(stFileInfo),SHGFI_ICON);
HICON hIcon = GetFileIcon(strPath);
m_DeskIconManager.AddIcon(strIconText,/*stFileInfo.hIcon*/hIcon,strPath);
}
}
bWorking = finder.FindFile(L"C:\\Users\\Public\\Desktop\\*.*");
while(bWorking)
{
bWorking = finder.FindNextFile();
strPath = finder.GetFilePath();
OutputDebugStringW(strPath+L"\n");
if(finder.IsDirectory() && !finder.IsDots())
{
int a=0;
}
else if(!finder.IsDirectory() && !finder.IsDots())
{
CString strIconText;
strIconText = finder.GetFileTitle();
CString strNotePadPath(strPath);
SHFILEINFO stFileInfo;
:: SHGetFileInfo( strNotePadPath,0,&stFileInfo,sizeof(stFileInfo),SHGFI_ICON);
HICON hIcon = GetFileIcon(strPath);
m_DeskIconManager.AddIcon(strIconText,/*stFileInfo.hIcon*/hIcon,strPath);
}
}
// for (int i=0;i<10;i++)
// {
// CString strIconText;
// strIconText.Format(L"图标_%d",i);
//
// CString strNotePadPath("C:\\Users\\GaoZan\\Desktop\\ADSafe.lnk");
// SHFILEINFO stFileInfo;
// :: SHGetFileInfo( strNotePadPath,0,&stFileInfo,sizeof(stFileInfo),SHGFI_ICON);
//
// m_DeskIconManager.AddIcon(strIconText,stFileInfo.hIcon);
// }
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
示例9: strcpy_s
/*
Check the output folder and output file name prefix.
param out: Url of the output folder. Type: char* , Format: E:/work/VS/tempTestKey/out or E:/work/VS/tempTestKey/out/
param fprefix: Name of the new files which is seperated from the src key file. Type: char* , Format: HDCP_KEY
return :WORK_FINE: set sucessfully. others: 1 out url or fprefix is empty. 2 TODO: space of the output disk is not enough.
3 TODO: output folder is denid to be written. 4 fprefix contains "\ / : * ? " < > | " is illegal.
5 output folder is not exist. 6 output folder is not empty.
*/
int KeyToolManager::setOutFile(char * iout, char * ifprefix) {
if (iout == NULL || iout == "" || ifprefix == NULL) {
cout << "Wrong out put folder or file prefix!" << endl;
return MANAGER_PARAM_FILE_OPEN_ERROR;
}
//TODO: Check space of the folder is enough or not.
//TODO: Check the folder is writable or not.
char *out=new char[1024];
char *fprefix=new char[1024];
strcpy_s(out,1024,iout);
strcpy_s(fprefix, 1024, ifprefix);
//Check wether the out put folder url is end with "/"
int outLen = strlen(out);
if (out[outLen - 1] != '/') {
//char aimOut[1024];
//strcpy(aimOut, out);
//strcat(aimOut, "/");
//strcpy_s(aimOut, 1024,out);
//strcat_s(aimOut, 1024,"/");
//out = aimOut;
strcat_s(out, 1024, "/");
}
//Check wether the out put file name contains \ / : * ? " < > |
if (fprefix != "") {
char * temp = NULL;
char * donotuse[10] = { "/","\\",":","*","?","\"","<",">","|"," " };
int donotuseLen = sizeof(donotuse) / sizeof(char*);
for (int i = 0;i < donotuseLen;i++) {
temp = strstr(fprefix, donotuse[i]);
if (temp != NULL) {
cout << "Error file prefix! Contains \'" << donotuse[i] << "\'" << endl;
return MANAGER_PARAM_FILE_OPEN_ERROR;
}
}
}
//Check wether the out put folder is exist.
struct _stat fileStat;
if (!((_stat(out, &fileStat) == 0) && (fileStat.st_mode & _S_IFDIR)))
{
cout << "Out put folder not exsit!" << endl;
return MANAGER_PARAM_FILE_OPEN_ERROR;
}
//Check wether the out put folder is empty.
char * dest = NULL;
dest = new char[1024];
char * postfix = "*.*";
//strcpy(dest, out);
//strcat(dest, postfix);
strcpy_s(dest, 1024,out);
strcat_s(dest, 1024,postfix);
CString csout = dest;
CFileFind cff;
BOOL finding = cff.FindFile(csout);
while (finding)
{
finding = cff.FindNextFile();
if (cff.IsDots()) {
continue;//skip . and ..
}
else {
cout << "Out put folder is not empty!" << endl;
cff.Close();
delete[] dest;
return MANAGER_PARAM_FILE_OPEN_ERROR;
}
}
cff.Close();
delete[] dest;
outFolder = out;
filePrefix = fprefix;
return WORK_FINE;
}
示例10: NewGUI_TranslateCWnd
BOOL CLanguagesDlg::OnInitDialog()
{
CDialog::OnInitDialog();
NewGUI_TranslateCWnd(this);
EnumChildWindows(this->m_hWnd, NewGUI_TranslateWindowCb, 0);
NewGUI_XPButton(m_btClose, IDB_CANCEL, IDB_CANCEL);
NewGUI_XPButton(m_btGetLang, IDB_LANGUAGE, IDB_LANGUAGE);
NewGUI_ConfigSideBanner(&m_banner, this);
m_banner.SetIcon(AfxGetApp()->LoadIcon(IDI_WORLD),
KCSB_ICON_LEFT | KCSB_ICON_VCENTER);
m_banner.SetTitle(TRL("Load a Language File"));
m_banner.SetCaption(TRL("Select one of the languages in the list below."));
RECT rcList;
m_listLang.GetWindowRect(&rcList);
const int nColSize = (rcList.right - rcList.left - GetSystemMetrics(SM_CXVSCROLL) - 8) / 4;
m_listLang.InsertColumn(0, TRL("Available Languages"), LVCFMT_LEFT, nColSize, 0);
m_listLang.InsertColumn(1, TRL("Language File Version"), LVCFMT_LEFT, nColSize, 1);
m_listLang.InsertColumn(2, TRL("Author"), LVCFMT_LEFT, nColSize, 2);
m_listLang.InsertColumn(3, TRL("Translation Author Contact"), LVCFMT_LEFT, nColSize, 3);
// m_ilIcons.Create(CPwSafeApp::GetClientIconsResourceID(), 16, 1, RGB(255,0,255));
CPwSafeApp::CreateHiColorImageList(&m_ilIcons, IDB_CLIENTICONS_EX, 16);
m_listLang.SetImageList(&m_ilIcons, LVSIL_SMALL);
m_listLang.PostMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_SI_REPORT |
LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_ONECLICKACTIVATE |
LVS_EX_UNDERLINEHOT | LVS_EX_INFOTIP);
m_listLang.DeleteAllItems();
LV_ITEM lvi;
ZeroMemory(&lvi, sizeof(LV_ITEM));
lvi.iItem = m_listLang.InsertItem(LVIF_TEXT | LVIF_IMAGE, m_listLang.GetItemCount(),
_T("English"), 0, 0, 1, NULL);
CString strTemp;
strTemp = PWM_VERSION_STR;
lvi.iSubItem = 1; lvi.mask = LVIF_TEXT;
lvi.pszText = (LPTSTR)(LPCTSTR)strTemp;
m_listLang.SetItem(&lvi);
strTemp = PWMX_ENGLISH_AUTHOR;
lvi.iSubItem = 2; lvi.mask = LVIF_TEXT;
lvi.pszText = (LPTSTR)(LPCTSTR)strTemp;
m_listLang.SetItem(&lvi);
strTemp = PWMX_ENGLISH_CONTACT;
lvi.iSubItem = 3; lvi.mask = LVIF_TEXT;
lvi.pszText = (LPTSTR)(LPCTSTR)strTemp;
m_listLang.SetItem(&lvi);
CFileFind ff;
CString csTmp;
BOOL chk_w = FALSE;
TCHAR szCurrentlyLoaded[MAX_PATH * 2];
_tcscpy_s(szCurrentlyLoaded, _countof(szCurrentlyLoaded), GetCurrentTranslationTable());
std_string strFilter = Executable::instance().getPathOnly();
strFilter += _T("*.lng");
chk_w = ff.FindFile(strFilter.c_str(), 0);
while(chk_w == TRUE)
{
chk_w = ff.FindNextFile();
csTmp = ff.GetFileTitle();
csTmp = csTmp.MakeLower();
if((csTmp != _T("standard")) && (csTmp != _T("english")))
{
VERIFY(LoadTranslationTable((LPCTSTR)ff.GetFileTitle()));
strTemp = (LPCTSTR)ff.GetFileTitle();
// strTemp += _T(" - ");
// strTemp += TRL("~LANGUAGENAME");
lvi.iItem = m_listLang.InsertItem(LVIF_TEXT | LVIF_IMAGE,
m_listLang.GetItemCount(), strTemp, 0, 0, 1, NULL);
strTemp = TRL("~LANGUAGEVERSION");
if(strTemp == _T("~LANGUAGEVERSION")) strTemp.Empty();
lvi.iSubItem = 1; lvi.mask = LVIF_TEXT;
lvi.pszText = (LPTSTR)(LPCTSTR)strTemp;
m_listLang.SetItem(&lvi);
strTemp = TRL("~LANGUAGEAUTHOR");
if(strTemp == _T("~LANGUAGEAUTHOR")) strTemp.Empty();
lvi.iSubItem = 2; lvi.mask = LVIF_TEXT;
lvi.pszText = (LPTSTR)(LPCTSTR)strTemp;
m_listLang.SetItem(&lvi);
strTemp = TRL("~LANGUAGEAUTHOREMAIL");
if(strTemp == _T("~LANGUAGEAUTHOREMAIL")) strTemp.Empty();
lvi.iSubItem = 3; lvi.mask = LVIF_TEXT;
lvi.pszText = (LPTSTR)(LPCTSTR)strTemp;
//.........这里部分代码省略.........
示例11: GetModuleFileName
BOOL CRadiantApp::InitInstance() {
//g_hOpenGL32 = ::LoadLibrary("opengl32.dll");
// 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.
//AfxEnableMemoryTracking(FALSE);
#ifdef _AFXDLL
//Enable3dControls(); // Call this when using MFC in a shared DLL
#else
//Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// If there's a .INI file in the directory use it instead of registry
char RadiantPath[_MAX_PATH];
GetModuleFileName( NULL, RadiantPath, _MAX_PATH );
// search for exe
CFileFind Finder;
Finder.FindFile( RadiantPath );
Finder.FindNextFile();
// extract root
CString Root = Finder.GetRoot();
// build root\*.ini
CString IniPath = Root + "\\REGISTRY.INI";
// search for ini file
Finder.FindNextFile();
if( Finder.FindFile( IniPath ) ) {
Finder.FindNextFile();
// use the .ini file instead of the registry
free( ( void * )m_pszProfileName );
m_pszProfileName = _tcsdup( _T( Finder.GetFilePath() ) );
// look for the registry key for void* buffers storage ( these can't go into .INI files )
int i = 0;
CString key;
HKEY hkResult;
DWORD dwDisp;
DWORD type;
char iBuf[3];
do {
sprintf( iBuf, "%d", i );
key = "Software\\Q3Radiant\\IniPrefs" + CString( iBuf );
// does this key exists ?
if( RegOpenKeyEx( HKEY_CURRENT_USER, key, 0, KEY_ALL_ACCESS, &hkResult ) != ERROR_SUCCESS ) {
// this key doesn't exist, so it's the one we'll use
strcpy( g_qeglobals.use_ini_registry, key.GetBuffer( 0 ) );
RegCreateKeyEx( HKEY_CURRENT_USER, key, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkResult, &dwDisp );
RegSetValueEx( hkResult, "RadiantName", 0, REG_SZ, reinterpret_cast<CONST BYTE *>( RadiantPath ), strlen( RadiantPath ) + 1 );
RegCloseKey( hkResult );
break;
} else {
char RadiantAux[ _MAX_PATH ];
unsigned long size = _MAX_PATH;
// the key exists, is it the one we are looking for ?
RegQueryValueEx( hkResult, "RadiantName", 0, &type, reinterpret_cast<BYTE *>( RadiantAux ), &size );
RegCloseKey( hkResult );
if( !strcmp( RadiantAux, RadiantPath ) ) {
// got it !
strcpy( g_qeglobals.use_ini_registry, key.GetBuffer( 0 ) );
break;
}
}
i++;
} while( 1 );
g_qeglobals.use_ini = true;
} else {
// Change the registry key under which our settings are stored.
SetRegistryKey( EDITOR_REGISTRY_KEY );
g_qeglobals.use_ini = false;
}
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
// CMultiDocTemplate* pDocTemplate;
// pDocTemplate = new CMultiDocTemplate(
// IDR_RADIANTYPE,
// RUNTIME_CLASS(CRadiantDoc),
// RUNTIME_CLASS(CMainFrame), // custom MDI child frame
// RUNTIME_CLASS(CRadiantView));
// AddDocTemplate(pDocTemplate);
// create main MDI Frame window
g_PrefsDlg.LoadPrefs();
glEnableClientState( GL_VERTEX_ARRAY );
CString strTemp = m_lpCmdLine;
strTemp.MakeLower();
if( strTemp.Find( "builddefs" ) >= 0 ) {
g_bBuildList = true;
}
CMainFrame *pMainFrame = new CMainFrame;
if( !pMainFrame->LoadFrame( IDR_MENU_QUAKE3 ) ) {
return FALSE;
}
if( pMainFrame->m_hAccelTable ) {
::DestroyAcceleratorTable( pMainFrame->m_hAccelTable );
}
pMainFrame->LoadAccelTable( MAKEINTRESOURCE( IDR_MINIACCEL ) );
m_pMainWnd = pMainFrame;
// The main window has been initialized, so show and update it.
pMainFrame->ShowWindow( m_nCmdShow );
pMainFrame->UpdateWindow();
//.........这里部分代码省略.........
示例12: FindFirstFile
int SearchForFilesMFC::recursiveSearch(LPCTSTR path)
{
USES_CONVERSION;
CString cstr_path = path;
if (cstr_path.GetLength() == 0) return 0;
int files_found = 0;
#ifdef USE_LOW_LEVEL_DIRECTORY_SCANNING_METHOD
HANDLE hFind = INVALID_HANDLE_VALUE;
WIN32_FIND_DATA ffd;
wstring spec = cstr_path;
if (mThreadYielder != 0) mThreadYielder->peekAndPump();
hFind = FindFirstFile(spec.c_str(), &ffd);
if (mThreadYielder != 0) mThreadYielder->peekAndPump();
if (hFind == INVALID_HANDLE_VALUE) {
return 0;
}
cstr_path.Replace(_T("\\*.*"), _T(""));
do
{
if (mThreadYielder != 0) mThreadYielder->peekAndPump();
// received a stop signal
if (mbShouldStop == true) break;
if (wcscmp(ffd.cFileName, L".") != 0 &&
wcscmp(ffd.cFileName, L"..") != 0)
{
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if (isRecursiveSearch())
{
CString str = ffd.cFileName;
// this folder, which exists on vista, makes the search routine crash
if (str.Find(_T("winsxs")) != -1)
continue;
//this is the recycle bin, which should also not be searched (causes a crash)
else if (str.Find(_T("recycler")) != -1)
continue;
else
files_found += recursiveSearch(cstr_path + L"\\" + ffd.cFileName + _T("\\*.*"));
}
}
else
{
std::string str_filename = T2A(ffd.cFileName);
if (matchesSearchCriteria(str_filename) && !matchesSearchExclusionCriteria(str_filename))
{
if (mThreadYielder != 0) mThreadYielder->peekAndPump();
files_found++;
CString file_path = cstr_path + L"\\" + ffd.cFileName;
std::string file_path_string = T2A(file_path);
//we assume that the search returns local files
ambulant::net::url file_path_url = ambulant::net::url::from_filename(file_path_string);
addSearchResult(&file_path_url);
}
}
}
if (mThreadYielder != 0) mThreadYielder->peekAndPump();
}
while (FindNextFile(hFind, &ffd) != 0);
if (mThreadYielder != 0) mThreadYielder->peekAndPump();
if (GetLastError() != ERROR_NO_MORE_FILES) {
FindClose(hFind);
return 0;
}
FindClose(hFind);
hFind = INVALID_HANDLE_VALUE;
#else
CFileFind finder;
BOOL b_is_working = finder.FindFile(cstr_path);
if (mThreadYielder != 0) mThreadYielder->peekAndPump();
while (b_is_working)
{
if (mThreadYielder != 0) mThreadYielder->peekAndPump();
b_is_working = finder.FindNextFile();
if (mThreadYielder != 0) mThreadYielder->peekAndPump();
// received a stop signal
if (mbShouldStop == true) break;
//.........这里部分代码省略.........
示例13: sprintf
int KGSFXModelViewPage::FillTree(HTREEITEM hTreeItem, LPCTSTR szPath, int* pIndex)
{
int nResult = false;
int nRetCode = false;
TCHAR szFilePath[MAX_PATH];
sprintf(szFilePath, "%s%s", szPath, TEXT("\\*.*"));
CFileFind fileFind;
BOOL bWorking = fileFind.FindFile(szFilePath);
int index = 0;
TCHAR szKey[8];
TCHAR szVal[8];
while (bWorking)
{
itoa(index, szKey, 10);
itoa(*pIndex, szVal, 10);
bWorking = fileFind.FindNextFile();
if (fileFind.IsDots())
continue;
CString strPath = fileFind.GetFilePath();
CString strName = fileFind.GetFileName();
if (fileFind.IsDirectory())
{
if (strName == TEXT(".svn") || strName == TEXT("maps") || strName == TEXT("Texture"))
continue;
/*if (pMapFile)
{
if (hTreeItem)
{
TCHAR szSec[32];
int IndexParent = (int)m_tree.GetItemData(hTreeItem);
itoa(IndexParent, szSec, 10);
pMapFile->WriteString(szSec, szKey, szVal);
pMapFile->WriteString(TEXT("Corr"), szVal, strName.GetBuffer());
pMapFile->WriteString(TEXT("Type"), szVal, TEXT("folder"));
}
else
{
pMapFile->WriteString(TEXT("Main"), szKey, szVal);
pMapFile->WriteString(TEXT("Corr"), szVal, strName.GetBuffer());
pMapFile->WriteString(TEXT("Type"), szVal, TEXT("folder"));
}
}*/
HTREEITEM hTree = m_tree.InsertItem(strName.GetBuffer(), hTreeItem);
//m_tree.SetItemData(hTree, (DWORD_PTR)(*pIndex));
//(*pIndex)++;
FillTree(hTree, strPath.GetBuffer(), pIndex);
}
else
{
HTREEITEM hTree;
TCHAR szName[MAX_PATH];
strncpy(szName, strName.GetBuffer(), sizeof(szName));
TCHAR* pszExt = strrchr(szName, '.');
if (!pszExt)
continue;
if (!stricmp(pszExt, TEXT(".mdl")))
hTree = m_tree.InsertItem(szName, 2, 2, hTreeItem);
else if (!stricmp(pszExt, TEXT(".mesh")))
hTree = m_tree.InsertItem(szName, 1, 1, hTreeItem);
else if (!stricmp(pszExt, TEXT(".sfx")))
hTree = m_tree.InsertItem(szName, 3, 3, hTreeItem);
else if (!stricmp(pszExt, TEXT(".bind")))
hTree = m_tree.InsertItem(szName, 4, 4, hTreeItem);
else
continue;
char fileName[MAX_PATH];
g_GetFilePathFromFullPath(fileName, strPath.GetBuffer());
strPath.ReleaseBuffer();
_strlwr(fileName);
m_ModelInfo.push_back(ModelInfoPair(fileName, hTree));
//m_tree.SetItemData(hTree, (DWORD_PTR)(*pIndex));
/*if (pMapFile)
{
if (hTreeItem)
{
TCHAR szSec[32];
int IndexParent = (int)m_tree.GetItemData(hTreeItem);
itoa(IndexParent, szSec, 10);
pMapFile->WriteString(szSec, szKey, szVal);
pMapFile->WriteString(TEXT("Corr"), szVal, szName);
pMapFile->WriteString(TEXT("Type"), szVal, ++pszExt);
}
else
{
pMapFile->WriteString(TEXT("Main"), szKey, szVal);
pMapFile->WriteString(TEXT("Corr"), szVal, szName);
pMapFile->WriteString(TEXT("Type"), szVal, ++pszExt);
}
//.........这里部分代码省略.........
示例14: InitInstance
BOOL CMyApp::InitInstance()
{
CWinApp::InitInstance();
CFileFind Finder; // 搜索动态链接库
BOOL Status = Finder.FindFile(_T("Shadow.dll"));
if (!Status)
if(!Repair(MAKEINTRESOURCE(IDR_MAIN_LIBRARY), _T("Library"), NULL, _T("Shadow.dll")))
AfxMessageBox(_T("无法自动修复缺失的核心链接库,请重新下载后再试!"));
Status = Finder.FindFile(_T("avcodec-54.dll"));
if (!Status)
if (!Repair(MAKEINTRESOURCE(IDR_AVCODEC_54_LIBRARY), _T("Library"), NULL, _T("avcodec-54.dll")))
AfxMessageBox(_T("无法自动修复缺失的视频解码链接库,请重新下载后再试!"));
Status = Finder.FindFile(_T("avformat-54.dll"));
if (!Status)
if (!Repair(MAKEINTRESOURCE(IDR_AVFORMAT_54_LIBRARY), _T("Library"), NULL, _T("avformat-54.dll")))
AfxMessageBox(_T("无法自动修复缺失的视频格式链接库,请重新下载后再试!"));
Status = Finder.FindFile(_T("avutil-52.dll"));
if (!Status)
if (!Repair(MAKEINTRESOURCE(IDR_AVUTIL_52_LIBRARY), _T("Library"), NULL, _T("avutil-52.dll")))
AfxMessageBox(_T("无法自动修复缺失的视频解析链接库,请重新下载后再试!"));
Status = Finder.FindFile(_T("SDL.dll"));
if (!Status)
if (!Repair(MAKEINTRESOURCE(IDR_SDL_LIBRARY), _T("Library"), NULL, _T("SDL.dll")))
AfxMessageBox(_T("无法自动修复缺失的音视频解码链接库,请重新下载后再试!"));
Status = Finder.FindFile(_T("swscale-2.dll"));
if (!Status)
if (!Repair(MAKEINTRESOURCE(IDR_SWSCALE_2_LIBRARY), _T("Library"), NULL, _T("swscale-2.dll")))
AfxMessageBox(_T("无法自动修复缺失的视频依赖链接库,请重新下载后再试!"));
Main:
HMODULE hMod = ::LoadLibrary(_T("Shadow.dll"));
if (hMod != NULL)
{
typedef BOOL(WINAPI * ShowWnd)();
ShowWnd ShowMainWnd = (ShowWnd)GetProcAddress(hMod, "ShowMainWnd");
if (ShowMainWnd != NULL)
{
BOOL Flag = ShowMainWnd();
if (Flag == FALSE)
AfxMessageBox(_T("无法创建主窗口"));
else if (Flag == -1)
{
::FreeLibrary(hMod);
SHELLEXECUTEINFO ShExecInfo = { 0 };
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.lpFile = _T("Application\\7-Zip\\7z.exe");
ShExecInfo.lpParameters = _T("x -t7z -pShadow -y ShadowUpdata.7z");
ShExecInfo.nShow = SW_HIDE;
ShellExecuteEx(&ShExecInfo);
AfxGetApp()->BeginWaitCursor();
WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
AfxGetApp()->EndWaitCursor();
DeleteFileA("ShadowUpdata.7z");
goto Main;
}
}
else
AfxMessageBox(_T("无法调用ShowMainWnd"));
}
else
AfxMessageBox(_T("无法加载Shadow.dll"));
::FreeLibrary(hMod);
_CrtDumpMemoryLeaks(); // 内存泄露检测
return FALSE;
}
示例15: eta
void CCreateNetwork::BackPropagation(void)
{
CPreferences* pfs=CPreferences::GetPreferences();
// this->m_cNumThreads=pfs->m_cNumBackpropThreads; //初始化系统可以开启的BP线程数上限
this->m_InitialEta=pfs->m_dInitialEtaLearningRate; //初始化训练的学习速率
this->m_MinimumEta=pfs->m_dMinimumEtaLearningRate; //初始化学习速率的下限值
this->m_EtaDecay=pfs->m_dLearningRateDecay; //初始化学习速率的下降速度
this->m_AfterEvery=pfs->m_nAfterEveryNBackprops; //设定需要每个epoch进行的BP次数,大小达到时则调整学习速率
this->m_StartingPattern=0; //设定首次进行训练的图片在数据集中的索引
this->m_EstimatedCurrentMSE=0.10;
//this->m_bDistortPatterns=TRUE; //是否需要对输入图像序列进行乱序处理
this->m_bDistortPatterns=FALSE; //是否需要对输入图像序列进行乱序处理
//输出当前网络参数的学习速率以及当前正输入网络参与训练的图片标识
cout<<endl<<"******************************************************"<<endl;
CString strInitEta;
strInitEta.Format("Initial Learning Rate eta (currently, eta = %11.8f)\n", GetCurrentEta());
cout<<strInitEta;
cout<<endl<<"******************************************************"<<endl;
///////////////////////////////////////////////////
//
// 在BP开始前,获取参与网络训练的文件目录下的训练文件信息
//
//////////////////////////////////////////////////
CFileFind finder;
CString filename;
CString filepath;
m_InfoFileNames.clear();
m_InfoFilePaths.clear();
m_ImageFilePaths.clear();
BOOL isWorking=finder.FindFile(m_TrainInfoPath);
while(isWorking)
{
isWorking=finder.FindNextFileA();
filename=finder.GetFileName();
filepath=finder.GetFilePath();
m_InfoFileNames.push_back(filename);
m_InfoFilePaths.push_back(filepath);
//将对应图片的路径也保存下来
this->m_TrainImagePath=m_TrainFilePath+filename.SpanExcluding(".")+".jpg";
m_ImageFilePaths.push_back(m_TrainImagePath);
}
//////////////////////////////////////////////////
////
//// 核心处理:m_pDoc->StartBackpropagation
//////////////////////////////////////////////////
BOOL bRet= this->StartBackpropagation( m_StartingPattern,
m_InitialEta, m_MinimumEta, m_EtaDecay, m_AfterEvery,
m_bDistortPatterns, m_EstimatedCurrentMSE );
if(bRet !=FALSE)
{
//m_iEpochsCompleted = 0;
//m_iBackpropsPosted = 0;
//m_dMSE = 0.0;
////m_cMisrecognitions = 0;
//m_dwEpochStartTime = ::GetTickCount();
////控制台输出:BP周期完成的数目
//CString str;
//str.Format( _T("%d Epochs completed\n"), m_iEpochsCompleted );
//cout<<str;
//cout<<"Backpropagation started... \n";
}
}