//--------------------------------------------------------------------------- void __fastcall TOptDialog::BtnLocalDirClick(TObject *Sender) { #ifdef TCPP AnsiString dir=LocalDir->Text; if (!SelectDirectory("FTP/HTTP Local Directory","",dir)) return; LocalDir->Text=dir; #else UnicodeString dir=LocalDir->Text; TSelectDirExtOpts opt=TSelectDirExtOpts()<<sdNewUI<<sdNewFolder; if (!SelectDirectory(L"FTP/HTTP Local Directory",L"",dir,opt)) return; LocalDir->Text=dir; #endif }
// callback on button-output-directory -------------------------------------- void __fastcall TMainWindow::BtnOutDirClick(TObject *Sender) { #ifdef TCPP AnsiString dir=OutDir->Text; if (!SelectDirectory("Output Directory","",dir)) return; OutDir->Text=dir; #else UnicodeString dir=OutDir->Text; TSelectDirExtOpts opt=TSelectDirExtOpts()<<sdNewUI<<sdNewFolder; if (!SelectDirectory(L"Output Directory",L"",dir,opt)) return; OutDir->Text=dir; #endif }
//--------------------------------------------------------------------------- // ファイルを復号する処理 //--------------------------------------------------------------------------- void __fastcall TForm1::FileDecrypt(void) { int i; String MsgText; char password[32]; for (i = 0; i < 32; i++) { password[i] = NULL; } AnsiString Password; AnsiString PasswordFileHash, PasswordFileHeader; String AtcFilePath; String OutDirPath; String RootDirPath = ExtractFileDir(Application->ExeName); TSelectDirExtOpts opt; //フォームを実行中状態にする ChangeFormStatus(1); //親フォルダを生成しない //if ( fNoParentFldr == true ) if ( chkSaveToOtherDirectory->Checked == true ) { opt = TSelectDirExtOpts() << sdShowShares << sdNewUI << sdNewFolder << sdShowEdit << sdValidateDir; // '復号する先のフォルダーを指定してください。' if (SelectDirectory(LoadResourceString(&Msgexeout::_DIALOG_MSG_SELECT_SAVE_TO_FOLDER), RootDirPath, OutDirPath, opt, this) == false){ return; } } else{ OutDirPath = ExtractFileDir(Application->ExeName); } if ( DirectoryExists(OutDirPath) == false ) { //'保存する先のフォルダーが見つかりません。保存設定を再確認してください。'+#13+ //'復号処理化を中止します。'; MsgText = LoadResourceString(&Msgexeout::_MSG_ERROR_SAVE_DEC_TO_FOLDER_NOT_EXISTS)+"\n"+ OutDirPath; MessageDlg(MsgText, mtError, TMsgDlgButtons() << mbOK, 0); //エラー終了表示 ProgressBar1->Position = 0; lblProgressPercentNum->Caption = " - %"; //'キャンセル' lblStatus->Caption = LoadResourceString(&Msgexeout::_LABEL_STATUS_TITLE_USER_CANCEL); //'復号が中止されました。' lblMsg->Caption = LoadResourceString(&Msgexeout::_LABEL_STATUS_DETAIL_STOPPED); return; } //----------------------------------- // 復号処理の開始 //----------------------------------- //復号処理インスタンスの作成 decrypt = new TAttacheCaseFileDecrypt2(true); decrypt->OnTerminate = DecryptThreadTerminated; decrypt->FreeOnTerminate = true; decrypt->AppExeFilePath = Application->ExeName; //アタッシェケース本体の場所(実行形式出力のときに参照する) decrypt->AtcFilePath = Application->ExeName; //入力する暗号化ファイルパス(自分自身) decrypt->OutDirPath = OutDirPath; //出力するディレクトリ decrypt->fConfirmOverwirte = true; //上書きの確認 //----------------------------------- //パスワードのセット //----------------------------------- //パスワードファイルを使用する if (PasswordFilePath != "") { //SHA-1ハッシュを求める if ( GetSHA1HashFromFile(PasswordFilePath, PasswordFileHash, PasswordFileHeader) == true ){ StrLCopy(password, PasswordFileHash.c_str(), 32); decrypt->SetPasswordBinary(password); FileDecrypt(); } else{ //'パスワードファイルを開けません。他のアプリケーションで使用中の可能性があります。'; MsgText = LoadResourceString(&Msgexeout::_MSG_ERROR_OPEN_PASSWORD_FILE)+"\n"+PasswordFilePath; MessageDlg(MsgText, mtError, TMsgDlgButtons() << mbOK, 0); } } else{ //文字列をセット Password = (AnsiString)txtInputPassword->Text; StrLCopy(password, Password.c_str(), 32); decrypt->SetPasswordBinary(password); } //復号の実行 decrypt->Start(); //タスクバー進捗表示(Win7) if(CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_ALL, IID_ITaskbarList3, (void**)&ptl) != S_OK) { //失敗 } if (ptl) ptl->SetProgressState(Application->Handle, TBPF_NORMAL); //進捗をTimerで監視 TimerDecrypt->Enabled = true; }