when compiling the application I get
"Unhandled exception at 0x57cb47af (msvcr100d.dll) in Os_pro.exe: 0xC0000005: Access violation reading location 0x00000000."
What does this mean and how to treat it?
Code (part of the code gets format files and initial paths of hard disks as parameters)
enter code here bool FindByMask(int param) { int i = param+1; printf("Thread number %i start.\n", i); for(int i = 0; i < maskCount; ) { _TCHAR *drive = drives[param]; _TCHAR *mask = new _TCHAR[_tcslen(maska[i])]; _tcscpy(mask, _T("*.")); _tcscat(mask, maska[i]); find(drive, mask); ++i; } return true; } bool find(_TCHAR *drive, _TCHAR *mask) { _TCHAR tmp1[MAX_PATH]; _TCHAR *tmp2; WIN32_FIND_DATA findData; HANDLE hFileFind; memset(&findData, 0, sizeof(WIN32_FIND_DATA)); fstream fstr; _tcscpy(tmp1, drive); _tcscat(tmp1, _T("*.*")); hFileFind = FindFirstFile(tmp1, &findData); do { if(hFileFind != INVALID_HANDLE_VALUE) { if ((_tcscmp(findData.cFileName, _T(".")) != 0) && (_tcscmp(findData.cFileName, _T("..")) != 0)) { if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { _TCHAR newpath[MAX_PATH]; tmp2 = _tcssubstr(tmp1, 0, _tcslen(tmp1)-4); _tcscpy(newpath, tmp2); _tcscat(newpath, findData.cFileName); _tcscat(newpath, _T("\\")); find(newpath, mask); } } } } while(FindNextFile(hFileFind, &findData)); FindClose(hFileFind); _TCHAR *findPath = new _TCHAR[_tcslen(drive)+_tcslen(mask)]; _tcscpy(findPath, drive); _tcscat(findPath, mask); hFileFind = FindFirstFile(findPath, &findData); if(hFileFind != INVALID_HANDLE_VALUE) { do { if(!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { tmp2 = _tcssubstr(tmp1, 0, _tcslen(tmp1)-4); _TCHAR *fp = new _TCHAR[_tcslen(tmp2) + _tcslen(findData.cFileName)]; _tcscpy(fp, tmp2); _tcscat(fp, findData.cFileName); _TCHAR *tmp3 = new _TCHAR[_tcslen(fp)+2]; _tcscpy(tmp3, _T("\"")); _tcscat(tmp3, fp); _tcscat(tmp3, _T("\"")); DWORD dwAttr = GetFileAttributes(fp); if(dwAttr & FILE_ATTRIBUTE_ARCHIVE) { FILE* f = fopen(".\\list_file.lst", "a+"); fwprintf_s(f, _T("%s"), tmp3); fwprintf_s(f, _T("%s"), _T("\n")); SetFileAttributes(fp, dwAttr & FILE_ATTRIBUTE_ARCHIVE); fclose(f); _TCHAR *cml; cml = new _TCHAR[_tcslen(tmp_1)+_tcslen(tmp3)+_tcslen(tmp_3)]; _tcscpy(cml, tmp_1); _tcscat(cml, tmp_3); _tcscat(cml, _T(" ")); _tcscat(cml, tmp3); STARTUPINFO siStartupInfo; PROCESS_INFORMATION piProcessInfo; memset(&siStartupInfo, 0, sizeof(siStartupInfo)); memset(&piProcessInfo, 0, sizeof(piProcessInfo)); siStartupInfo.cb = sizeof(siStartupInfo); CreateProcess(_T(".\\rar.exe"), cml, 0, 0, FALSE, NORMAL_PRIORITY_CLASS, 0, _T(".\\"), &siStartupInfo, &piProcessInfo); WaitForSingleObject( piProcessInfo.hProcess, INFINITE); } } } while(FindNextFile(hFileFind, &findData)); } FindClose(hFileFind); return true; }`enter code here
drives
come from, for example. Maybe on this line crash_TCHAR *drive = drives[param];
- yapycoder