.


:




:

































 

 

 

 


C




:

if(wndMain.Create(NULL) == NULL)

{

ATLTRACE(_T("Main window creation failed!\n"));

return 0;

}

 

wndMain.ShowWindow(nCmdShow);//

: ' , , . GetDevice(): - , , , :

void CDisc::GetDevice() //

{

m_DeviseList.empty(); //

DWORD dw = GetLogicalDriveStrings(0,NULL); //

TCHAR *str; //

str = new TCHAR[dw]; //

GetLogicalDriveStrings(dw,str); //

bool bSave = true; //

for(DWORD i=0;i<dw;i++) //

{

if((str[i] == '\0')&&(str[i+1] == '\0')) //

break; //

if(bSave) // \0

{

CString strD(&str[i]);//

if(GetDriveType(strD)==DRIVE_FIXED) //

m_DeviseList.push_back(strD); //

bSave = false; //

}

if(str[i] == '\0') //

bSave = true;

 

}

delete[] str; //

}

 

CheckDisc() :

int CDisc::CheckDisc(CString strDisc,LONG lBegin,LONG lEnd,CTestInterface* pInterface) //

{

 

if(strDisc[strDisc.GetLength()-1]=='\\') //

strDisc.Delete(strDisc.GetLength()-1);//

CString str; //

.

str.Format(_T("\\\\.\\%s"),strDisc); //

CreateFile():

m_hFile=CreateFile(str,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,

NULL,OPEN_EXISTING,0,NULL); //

CAutoVectorPtr<BYTE> pArray; //

pArray.Allocate(512); //

DWORD dwRead; //

:

if(!ReadFile(m_hFile,pArray,512,&dwRead,NULL)) //

{

return 1; //

}

, ReadFile 0, :

SetFilePointer(m_hFile,80*512,NULL,FILE_BEGIN); //

SYSTEMTIME() :

SYSTEMTIME tBegin; //

:

GetSystemTime(&tBegin); //

if(!ReadFile(m_hFile,pArray,512,&dwRead,NULL))//

{

return 1;//

}

SYSTEMTIME tEnd;//

ϳ :

GetSystemTime(&tEnd);//

:

m_dwTime = (tEnd.wHour - tBegin.wHour)*60*60*1000+(tEnd.wMinute - tBegin.wMinute)*60*1000+(tEnd.wSecond - tBegin.wSecond)*1000+(tEnd.wMilliseconds - tBegin.wMilliseconds);

//

m_pInterface = pInterface;

m_lBegin = lBegin;

m_lEnd = lEnd;

_beginthread(RunThread,0,this); //

 

return 0;

}

Test():

void CDisc::Test() //

{

srand(GetTickCount()); //

int rand_sec=0;//

:

SetFilePointer(m_hFile,m_lBegin*512,NULL,FILE_BEGIN);//

LONG lPoint = m_lBegin; // ,

:

for(;lPoint!=m_lEnd;lPoint++) //

{

BYTE pArray[512]; //

DWORD dwRead;//

random(), :

rand_sec = rand()%(m_lEnd-m_lBegin)+m_lBegin;//

BYTE pRead[512]; //

:

SetFilePointer(m_hFile,rand_sec*512,NULL,FILE_BEGIN);//

 

, , = 0 , 1 , .

int nStatus = 0; //

 

if (ReadFile(m_hFile,pRead,512,&dwRead,NULL)==0)//

{

 

nStatus = 1;// -

}

:

m_pInterface->CallBack(m_lBegin,m_lEnd,rand_sec,nStatus); //

}

m_pInterface->CallBack(m_lBegin,m_lEnd,lPoint,0);// ,

}

 

, :

if(m_dwEnd>m_dwStart)

::SendMessage(GetParent(),WM_STARTSCAN,NULL,NULL);

Else

:

::MessageBox(m_hWnd,_T(" "),0,0);

return 1;

 

 

P TestDisk:

 

.1. .

 

 
 
.2. . .

 


 

 
 
.3. . .

 

 


, 䳿 Windows:

- : , , ᒺ;

- ;

- random;

- : - ;

- .





:


: 2015-10-19; !; : 493 |


:

:

- , - .
==> ...

1441 - | 1369 -


© 2015-2024 lektsii.org - -

: 0.015 .