if( ret == 0 ){
tmppath = gCurrent_Path+"\\*.bin";
}else{
index = tmppath_content.ReverseFind( '\\' );
if( index != -1 ){
tmppath = tmppath_content.Left(index)+"\\*.bin";
}else{
tmppath = gCurrent_Path+"\\*.bin";
}
}
CFileDialog dlg(TRUE, NULL, tmppath, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT, "´ý¼ÓÃܵÄÎļþ (*.bin)|*.bin||");
if( IDOK == dlg.DoModal() ){
gFile_encrypt_Path = dlg.GetPathName();
}
write_path_record_file( gFile_record_file_Path, gFile_encrypt_Path );
UpdateData(FALSE);
int init_path_record_file( const CString &strFileLocalFullPath, CString &strFileLocalFullPath_content )
{
CString fileString;
CStdioFile f;
CFileException e;
int file_content_null;
file_content_null = 0x01;
if( !f.Open( strFileLocalFullPath, CFile::modeReadWrite, &e) ){
return 0;
}
if( f.ReadString(fileString) != FALSE ){
file_content_null = 0;
strFileLocalFullPath_content = fileString;
//MessageBox(NULL,fileString,"Buffer Size",MB_OK);
}
f.Flush();
f.Close();
if( file_content_null == 0 ){
return 1;
}else{
return 0;
}
}
BOOL write_path_record_file( const CString &strFileLocalFullPath, CString &strFileLocalFullPath_content )
{
ASSERT(strFileLocalFullPath != "");
char* pszBuffer = NULL;
DWORD dwWrite;
int nWrite;
const int BUFFER_LENGTH = 1024 * 2;
pszBuffer = new char[BUFFER_LENGTH];
HANDLE hFile = CreateFile( strFileLocalFullPath ,GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
//´´½¨±¾µØÎļþ
if( hFile == INVALID_HANDLE_VALUE ){
return false;
}
SetFilePointer( hFile, 0, 0, FILE_BEGIN );
memset( pszBuffer, 0, BUFFER_LENGTH );
LPTSTR p = strFileLocalFullPath_content.GetBuffer( strFileLocalFullPath_content.GetLength() );
strcpy( pszBuffer, p );
strFileLocalFullPath_content.ReleaseBuffer();
nWrite = strlen( pszBuffer );
WriteFile(hFile, pszBuffer, nWrite, &dwWrite, NULL);
//ÒÆ¶¯ÎļþÖ¸Õ뵽еÄλÖÃ
SetFilePointer( hFile, dwWrite, NULL, FILE_BEGIN );
//ÉèÖÃÎļþеĽáÊøÎ»Öá£
SetEndOfFile(hFile);
delete[]pszBuffer;
pszBuffer = NULL;
CloseHandle(hFile);
return true;
}