. , , ,

,,,

һ

.

220400.4405.22

__________________ ..

______________________2005.

.04 -2

________________ ..

______________________2005.

2005

һ

.

: : Microsoftâ Windows

NT 4.0 .

.

,

.

, .

C++ ,

.

: 1)

.

2)

:

,

, ,

(, ).

14 2005.

..

04 -2 ..

30 2005.




38 , 3 ,
30 , 2 .

Microsoftâ Windows NT 4.0 , : , , , , .

.

220400.4405.22

.

.

.

.

.

3

38

04 -2

..

..


TOC h z t " ;1; ;2;;1" . PAGEREF _Toc103029680 h 5

1 .. PAGEREF _Toc103029681 h 6

1.1 .. PAGEREF _Toc103029682 h 6

1.2 . PAGEREF _Toc103029683 h 8

1.3 . PAGEREF _Toc103029684 h 8

2 .. PAGEREF _Toc103029685 h 9

2.1 .. PAGEREF _Toc103029686 h 9

2.2. .. PAGEREF _Toc103029687 h 9

2.3 . PAGEREF _Toc103029688 h 10

. PAGEREF _Toc103029689 h 12

- .. PAGEREF _Toc103029690 h 13

.. PAGEREF _Toc103029692 h 15


( Vontrop Commander) Borlandâ C++Builderä 6.0, (VCL)
Windows API.

Borlandâ C++Builderä , . .

Vontrop Commander , , , (Unit1.c, Unit2.c, Unit3.c Unit4.c).

() (Unit1), , , , (Form1).

(Unit2) , , - . , , .

(Unit3) - (FormDialogCreateDir), .

(Unit4) - (FormDialogDelete), .


1

1.1

1.1.1 Form1 TForm ( 1). , FileListLeft FileListRigh, C:, , , DirAttribSet, .

Form1 : Create (, -: FormCreate). , Form1.

1.1.2 FileListLeft FileListRight TStringGrid ( ). , (), - . . , . (), ( , ). .

FileListLeft FileListRigh : DblClick ( , -: FileListLeftDblClick FileListRightDblClick), Enter (, , , -: FileListLeftEnter FileListRightEnter), KeyDown ( , -: FileListLeftKeyDown FileListRightKeyDown).

1.1.3 ListDevicesLeft ListDevicesRight TComboBox ( ). . - , , . , , , .

ListDevicesLeft ListDevicesRight : Select ( , -: ListDevicesLeftSelect ListDevicesRightSelect), Enter (, , , -: FileListLeftEnter FileListRightEnter).

1.1.4 bRemove, bCopy, bCreateDir, bDelete, bCurrentRootDirLeft
bCurrentRootDirRight TButton (). . Click (, : bCreateDirClick, bDeleteClick, bCopyClick, bRemoveClick, bCurrentRootDirLeftClick bCurrentRootDirRightClick).

bRemove (, ) , , , . bCopy bRemove. , .
bCreateDir FormDialogCreateDir. bDelete FormDialogDelete. bCurrentRootDirLeft bCurrentRootDirRight .


1.1.5 LabelCurrentPathLeft LabelCurrentPathRight TLabel (). .

1 Form1.


1.2

1.2.1 Form1 bCreateDir FormDialogCreateDir TForm ( 2).

FormDialogCreateDir.

1.2.2 edNewDirName TEdit ( ). , . edNewDirName KeyDown ( , - edNewDirNameKeyDown).

1.2.3 Label1 TLabel (). :.

1.2.4 bOk bCancel TButton (). bOk bCancel : Click (, -: bOkClick bCancelClick). bOk, (.. ) (, ), , , , . bCancel - .


2 FormDialogCreateDir.

1.3 .

1.3.1 Form1 bDelete FormDialogDelete TForm ( 3).

FormDialogDelete.

1.3.2 Label1 TLabel (). :.

1.3.3. bDelete, bCancel, bRecycler TButton (). bDelete, bCancel, bRecycler : Click (, -: bDeleteClick, bCancelClick bRecyclerClick). bDelete (), , . bRecycler, (), , . bCancel - .


3 FormDialogDelete.

2

2.1

- ( ). .

, . - -.

, .

- , .

Vontrop Commander , .

, (.. , ).

- .

.

2.2.

2.2.1. .

define. LEFT=1 RIGHT=0 , .

FO_DELETER=5 Delete .

2.2.2 .

DirSel ( int) , LitsDevicesLeft (ListDevicesRight) bCurrentRootDirLeft (bCurrentRootDirRight). HendlerOfOpen.

RootDirLeft RootDirRight ( AnsiString) . HendlerOfOpen.

CurrentPathLeft,CurrentPathRight ( AnsiString) . HendlerOfOpen. Delete, CreateFolder,CopyOrRemove.

Panel ( int) : LEFT RIGHT. .

2.3

2.3.1 CreateListOfDevices[1].

ListDevicesLeft ListDevicesRight.

. .

Windows API GetDriveType.

2.3.2 ScanDir.

, (char Path[]), , (int Panel), DequeFindLeft ( Panel=LEFT) DequeFindRight ( Panel=RIGHT).

Windows API:FindFirstFile, FindNextFile, FindClose.

ViewDirectory.

DequeFindLeft (DequeFindRight) , deque, WIN32_FIND_DATA. WIN32_FIND_DATA winbase.h. FindFirstFile FindNextFile.

2.3.3 StrucFindToFileProp.

WIN32_FIND_DATA _FileProperty.

WIN32_FIND_DATA _FileProperty. .

ViewDirectory.

_FileProperty ScanDir FileListLeft (FileListRight), .. WIN32_FIND_DATA .

2.3.4 ViewDirectory.

, Path[] .

, (char Path[]), , ScanDir, (int Panel), ScanDir, , FileListLeft ( Panel=LEFT) FileListRight ( Panel=RIGHT). .

HandlerOfOpen, CreateFolder, CopyOrRemove Deleting.

2.3.5 HandlerOfOpen.

, . ListDevicesLeft (ListDevicesRight), , , , . bCurrentRootDirLeft (bCurrentRootDirRight), . ( Enter) FileListLeft (FileListRight), , , , . , , , , . , . .

, (AnsiString RootDir), (int Panel) (int DirSel). .

Windows API ShellExecute.

2.3.6 CreateFolder.

.

, (int Panel). bool, . , . .

Windows API: CreateDirectory MessageBox.

2.3.7 Deleting.

( , ), .

(int Panel) (int Operation), , .. . .

Windows API SHFileOperation.

2.3.8 CopyOrRemove.

( , ), .

(int Panel) (int Operation), , .. . .

Windows API SHFileOperation.


1       http://vsokovikov.narod.ru/

2       http://www.firststeps.ru/

3       http://msdn.rambler.ru/

4       http://program.rin.ru/

5       http://www.hardline.ru/

6       http://www.citforum.ru/

7       http://olddos.narod.ru/

8       http://delphiworld.narod.ru/

9       http://www.msdn.com/

10  http://www.kavkazchat.com/

11  http://physics.grsu.by/

12  http://www.microsoft.com/

13  http://www.buildercpp.net.ru/

14  http://delphi.olympus.ru/

15  http://www.codenet.ru/

16  http://ru-coding.com/

17  http://www.softera.ru/

18  http://borland.xportal.ru/

19  http://www.legprog.com/

20  http://articles.org.ru/

21  http://delphimag.narod.ru/

22  http://linux.irtel.ru/

23  http://viphome.net/

24  http://inprise.hotbox.ru/

25  http://hardware.org.ru/

26  http://bugtraq.ru/

27  http://forum.vingrad.ru/

28  http://home.ural.ru/

29  http://www.progz.ru/

30 


()

-

CreateListOfDevices();

CreateDirAttribSet();

RootDirLeft="C:\";

RootDirRight="C:\";

DirSel=1;

CurrentPathLeft=HandlerOfOpen(RootDirLeft, LEFT, DirSel);

CurrentPathRight=HandlerOfOpen(RootDirRight, RIGHT, DirSel);

DirSel=0;

CurrentPathLeft=HandlerOfOpen(RootDirLeft, LEFT, DirSel);

DirSel=0;

CurrentPathRight=HandlerOfOpen(RootDirRight,RIGHT, DirSel);

RootDirLeft=Form1->ListDevicesLeft->Text.Delete

(3,(Form1->ListDevicesLeft->Text.Length()-2));

DirSel=1;

CurrentPathLeft=HandlerOfOpen(RootDirLeft, LEFT, DirSel);

Form1->FileListLeft->SetFocus();


RootDirRight=Form1->ListDevicesRight->Text.Delete

(3,(Form1->ListDevicesRight->Text.Length()-2));

DirSel=1;

CurrentPathRight=HandlerOfOpen(RootDirRight, RIGHT, DirSel);

Form1->FileListRight->SetFocus();

FormDialogCreateDir->Show();

CopyOrRemove(Panel,FO_MOVE);

CopyOrRemove(Panel,FO_COPY);

FormDialogCreateDir->edNewDirName->Text="";

FormDialogCreateDir->edNewDirName->SetFocus();

FormDialogCreateDir->Hide();

bool Result=CreateFolder(Panel);

FormDialogCreateDir->edNewDirName->SetFocus();

if (Result==true)

{

FormDialogCreateDir->edNewDirName->Text="";

FormDialogCreateDir->Hide();

}

()


()

FormDialogDelete->Show();

FormDialogDelete->bRecycler->SetFocus();

Deleting(Panel,FO_DELETE);

FormDialogDelete->bRecycler->SetFocus();

FormDialogDelete->Hide();

Deleting(Panel,FO_DELETER);

FormDialogDelete->bRecycler->SetFocus();

FormDialogDelete->Hide();

FormDialogDelete->bRecycler->SetFocus();

FormDialogDelete->Hide();

DirSel=2;

CurrentPathLeft=HandlerOfOpen(RootDirLeft, LEFT, DirSel);

Form1->FileListLeft->SetFocus();

DirSel=2;

CurrentPathRight=HandlerOfOpen(RootDirRight, RIGHT, DirSel);

Form1->FileListRight->SetFocus();

FormDialogDelete->Show();

FormDialogDelete->bRecycler->SetFocus();

Deleting(Panel,FO_DELETE);

FormDialogDelete->bRecycler->SetFocus();

FormDialogDelete->Hide();

Deleting(Panel,FO_DELETER);

FormDialogDelete->bRecycler->SetFocus();

FormDialogDelete->Hide();

FormDialogDelete->bRecycler->SetFocus();

FormDialogDelete->Hide();

DirSel=2;

CurrentPathLeft=HandlerOfOpen(RootDirLeft, LEFT, DirSel);

Form1->FileListLeft->SetFocus();

DirSel=2;

CurrentPathRight=HandlerOfOpen(RootDirRight, RIGHT, DirSel);

Form1->FileListRight->SetFocus();


()

.

Unit1.c

//---------------------------------------------------------------------------

#include

#pragma hdrstop

#include "Unit1.h"

#include "Unit2.h"

#include "Unit3.h"

#include "Unit4.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)

{

CreateListOfDevices();

CreateDirAttribSet();

RootDirLeft="C:\";

RootDirRight="C:\";

DirSel=1;

CurrentPathLeft=HandlerOfOpen(RootDirLeft, LEFT, DirSel);

CurrentPathRight=HandlerOfOpen(RootDirRight, RIGHT, DirSel);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::FileListLeftDblClick(TObject *Sender)

{

DirSel=0;

CurrentPathLeft=HandlerOfOpen(RootDirLeft, LEFT, DirSel);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::FileListRightDblClick(TObject *Sender)

{

DirSel=0;

CurrentPathRight=HandlerOfOpen(RootDirRight,RIGHT, DirSel);

}

//---------------------------------------------------------------------------


void __fastcall TForm1::ListDevicesLeftSelect(TObject *Sender)

{

RootDirLeft=Form1->ListDevicesLeft->Text.Delete

(3,(Form1->ListDevicesLeft->Text.Length()-2));

DirSel=1;

CurrentPathLeft=HandlerOfOpen(RootDirLeft, LEFT, DirSel);

Form1->FileListLeft->SetFocus();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::ListDevicesRightSelect(TObject *Sender)

{

RootDirRight=Form1->ListDevicesRight->Text.Delete

(3,(Form1->ListDevicesRight->Text.Length()-2));

DirSel=1;

CurrentPathRight=HandlerOfOpen(RootDirRight, RIGHT, DirSel);

Form1->FileListRight->SetFocus();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::FileListLeftEnter(TObject *Sender)

{

Panel=LEFT;

Form1->LabelCurrentPathLeft->Color=0x00E9E9E9;

Form1->ListDevicesLeft->Color=0x00E9E9E9;

Form1->FileListLeft->Color=clGradientInactiveCaption;

Form1->LabelCurrentPathRight->Color=0x00C4C4C4;

Form1->ListDevicesRight->Color=0x00C4C4C4;

Form1->FileListRight->Color=0x00C4C4C4;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::FileListRightEnter(TObject *Sender)

{

Panel=RIGHT;

Form1->LabelCurrentPathRight->Color=0x00E9E9E9;

Form1->ListDevicesRight->Color=0x00E9E9E9;

Form1->FileListRight->Color=clGradientInactiveCaption;

Form1->LabelCurrentPathLeft->Color=0x00C4C4C4;

Form1->ListDevicesLeft->Color=0x00C4C4C4;

Form1->FileListLeft->Color=0x00C4C4C4;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::ListDevicesLeftEnter(TObject *Sender)

{

Form1->LabelCurrentPathLeft->Color=0x00E9E9E9;

Form1->ListDevicesLeft->Color=0x00E9E9E9;

Form1->FileListLeft->Color=clGradientInactiveCaption;

Form1->LabelCurrentPathRight->Color=0x00C4C4C4;

Form1->ListDevicesRight->Color=0x00C4C4C4;

Form1->FileListRight->Color=0x00C4C4C4;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::ListDevicesRightEnter(TObject *Sender)

{

Form1->LabelCurrentPathRight->Color=0x00E9E9E9;

Form1->ListDevicesRight->Color=0x00E9E9E9;

Form1->FileListRight->Color=clGradientInactiveCaption;

Form1->LabelCurrentPathLeft->Color=0x00C4C4C4;

Form1->ListDevicesLeft->Color=0x00C4C4C4;

Form1->FileListLeft->Color=0x00C4C4C4;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::bCreateDirClick(TObject *Sender)

{

FormDialogCreateDir->Show();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::bDeleteClick(TObject *Sender)

{

FormDialogDelete->Show();

FormDialogDelete->bRecycler->SetFocus();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::bCopyClick(TObject *Sender)

{

CopyOrRemove(Panel,FO_COPY);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::bRemoveClick(TObject *Sender)

{

CopyOrRemove(Panel,FO_MOVE);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::FileListLeftKeyDown(TObject *Sender, WORD &Key,

TShiftState Shift)

{

switch (Key)

{

case 13: DirSel=0;

CurrentPathLeft=HandlerOfOpen(RootDirLeft, LEFT, DirSel);

break;

case 116: CopyOrRemove(Panel,FO_COPY);

break;

case 117: CopyOrRemove(Panel,FO_MOVE);

break;

case 118: FormDialogCreateDir->Show();

break;

case 119: FormDialogDelete->Show();

FormDialogDelete->bRecycler->SetFocus();

break;

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::FileListRightKeyDown(TObject *Sender, WORD &Key,

TShiftState Shift)

{

switch (Key)

{

case 13: DirSel=0;

CurrentPathRight=HandlerOfOpen(RootDirRight, RIGHT, DirSel);

break;

case 116: CopyOrRemove(Panel,FO_COPY);

break;

case 117: CopyOrRemove(Panel,FO_MOVE);

break;

case 118: FormDialogCreateDir->Show();

break;

case 119: FormDialogDelete->Show();

FormDialogDelete->bRecycler->SetFocus();

break;

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::bCurrentRootDirLeftClick(TObject *Sender)

{

DirSel=2;

CurrentPathLeft=HandlerOfOpen(RootDirLeft, LEFT, DirSel);

Form1->FileListLeft->SetFocus();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::bCurrentRootDirRightClick(TObject *Sender)

{

DirSel=2;

CurrentPathRight=HandlerOfOpen(RootDirRight, RIGHT, DirSel);

Form1->FileListRight->SetFocus();

}

//---------------------------------------------------------------------------


Unit2.h

//---------------------------------------------------------------------------

#ifndef Unit2H

#define Unit2H

//---------------------------------------------------------------------------

#endif

#define LEFT 1

#define RIGHT 0

#define FO_DELETER 5

extern int DirSel;

extern AnsiString RootDirLeft,RootDirRight;

extern AnsiString CurrentPathLeft,CurrentPathRight;

extern int Panel;

void CreateDirAttribSet();

AnsiString HandlerOfOpen(AnsiString RootDir, int Panel, int DirSel);

void CreateListOfDevices();

bool CreateFolder(int Panel);

void Deleting(int Panel, int Operation);

void CopyOrRemove(int Panel, int Operation);

Unit2.c

//---------------------------------------------------------------------------

#pragma hdrstop

#include "Unit1.h"

#include "Unit3.h"

#include

#include <_str.h>

#include

#include

#include

#include

#include

#include

//---------------------------------------------------------------------------

#pragma package(smart_init)

//---------------------------------------------------------------------------

int DirSel=0;// ListDevices

AnsiString RootDirLeft,RootDirRight;//

AnsiString CurrentPathLeft,CurrentPathRight;//

int Panel=LEFT;

struct _FileProperty //

{

char FileAttrib[12]; //

char CreateTime[25]; //

char AccessTime[25]; //

char WriteTime[25]; //

char FileSizeBy[21]; //

char FileSizeKb[18]; //

TCHAR FileName[MAX_PATH]; //

TCHAR AlterFileName[14]; //

}FileProperty;

deque DequeFindLeft; //

deque DequeFindRight;

WIN32_FIND_DATA StructFind; //

int ColName=0, //

ColSize=1,

ColAttrib=2,

ColCreTime=5,

ColAccTime=4,

ColWriTime=3;

//

set > DirAttribSet;

void CreateDirAttribSet()//

{

DirAttribSet.insert(16);

DirAttribSet.insert(17);

DirAttribSet.insert(18);

DirAttribSet.insert(19);

DirAttribSet.insert(20);

DirAttribSet.insert(21);

DirAttribSet.insert(22);

DirAttribSet.insert(48);

DirAttribSet.insert(49);

DirAttribSet.insert(50);

DirAttribSet.insert(8208);

}

//---------------------------------------------------------------------------

//

void CreateListOfDevices()

{

UINT DriveType;

char RootPath[4];

for(char i='A'; i<='Z'; i++)

{

strcpy(RootPath,"");

RootPath[0]=i;

RootPath[1]=':';

RootPath[2]='\';

RootPath[3]='';

DriveType=GetDriveType(RootPath);

switch (DriveType)

{

case DRIVE_REMOVABLE: strcat(RootPath, " 3 1\2 "");

Form1->ListDevicesLeft->Items->Add(RootPath);

Form1->ListDevicesRight->Items->Add(RootPath);

break;

case DRIVE_FIXED: strcat(RootPath," ");

Form1->ListDevicesLeft->Items->Add(RootPath);

Form1->ListDevicesRight->Items->Add(RootPath);

break;

case DRIVE_REMOTE: strcat(RootPath," ");

Form1->ListDevicesLeft->Items->Add(RootPath);

Form1->ListDevicesRight->Items->Add(RootPath);

case DRIVE_CDROM: strcat(RootPath," CD-ROM");

Form1->ListDevicesLeft->Items->Add(RootPath);

Form1->ListDevicesRight->Items->Add(RootPath);

break;

case DRIVE_RAMDISK: strcat(RootPath," RAM-Disk");

Form1->ListDevicesLeft->Items->Add(RootPath);

Form1->ListDevicesRight->Items->Add(RootPath);

break;

}

}

}

//------------------------------------------------------------------------------

//

void StrucFindToFileProp(WIN32_FIND_DATA StructFind, _FileProperty &FileProperty)

{

//

strcpy(FileProperty.FileName,StructFind.cFileName);

strcpy(FileProperty.AlterFileName, StructFind.cAlternateFileName);

char Temp[10];


//

switch (StructFind.dwFileAttributes)

{

case 1:

case 33:strcpy(FileProperty.FileAttrib,"ROnly");

break;

case 2:strcpy(FileProperty.FileAttrib,"Hide");

break;

case 4:

case 6:

case 34:

case 35:

case 38:

case 39:strcpy(FileProperty.FileAttrib,"Sys");

break;

case 8: strcpy(FileProperty.FileAttrib,"VolID");

break;

case 16:

case 17:

case 20:

case 21:

case 48:

case 49:

case 8208:strcpy(FileProperty.FileAttrib,"Dir");

break;

case 18:strcpy(FileProperty.FileAttrib,"HideDir");

break;

case 19:

case 50:

case 22:strcpy(FileProperty.FileAttrib,"HideSysDir");

break;

case 32:strcpy(FileProperty.FileAttrib,"Arch");

break;

case 63:strcpy(FileProperty.FileAttrib,"AnyF");

break;

case 64:strcpy(FileProperty.FileAttrib,"Device");

break;

case 256:strcpy(FileProperty.FileAttrib,"Temp");

break;

case 512:strcpy(FileProperty.FileAttrib,"Sprase");

break;

case 1024:strcpy(FileProperty.FileAttrib,"RepraseP");

break;

case 2048:strcpy(FileProperty.FileAttrib,"Compress");

break;

case 8192:strcpy(FileProperty.FileAttrib,"NContentInd");

break;

case 4096:strcpy(FileProperty.FileAttrib,"Offline");

break;

case 16384:strcpy(FileProperty.FileAttrib,"Encryp");

break;

default: strcpy(FileProperty.FileAttrib,ultoa(StructFind.dwFileAttributes,Temp,10));

strcat(FileProperty.FileAttrib,"");

break;

}

//

if (StructFind.nFileSizeHigh!=0)//

{

char TempStr[20];

strcpy(FileProperty.FileSizeBy, ultoa(StructFind.nFileSizeHigh,TempStr,10));

strcat(FileProperty.FileSizeBy, ultoa(StructFind.nFileSizeLow, TempStr,10));

strcat(FileProperty.FileSizeBy, "");

strcpy(FileProperty.FileSizeKb,">4");}

else {char TempStr[20];//

strcpy(FileProperty.FileSizeBy, ultoa(StructFind.nFileSizeLow,TempStr,10));

strcat(FileProperty.FileSizeBy, "");

strcpy(FileProperty.FileSizeKb, ultoa((StructFind.nFileSizeLow>>10),TempStr,10));

strcat(FileProperty.FileSizeKb, "");

}

if (DirAttribSet.count(StructFind.dwFileAttributes))// ,

{ //

strcpy(FileProperty.FileSizeBy, "DIR");

strcpy(FileProperty.FileSizeKb, "DIR");

}

else

if ((StructFind.nFileSizeLow>>10)==0) // ,

{ //

strcpy(FileProperty.FileSizeKb,FileProperty.FileSizeBy);

strcat(FileProperty.FileSizeKb," ");

}

// ...

void FileTimeToStrTime(_FILETIME &FileTime,char CharTime[]);

FileTimeToStrTime(StructFind.ftCreationTime, FileProperty.CreateTime);

FileTimeToStrTime(StructFind.ftLastAccessTime, FileProperty.AccessTime);

FileTimeToStrTime(StructFind.ftLastWriteTime, FileProperty.WriteTime);

}

void FileTimeToStrTime(_FILETIME &FileTime, char CharTime[])

{

_SYSTEMTIME DigitTime;

char TempStr[3];

FileTimeToSystemTime(&FileTime, &DigitTime);

strcpy(CharTime, "");

strcat(CharTime, ultoa(DigitTime.wDay,TempStr,10));

strcat(CharTime, ".");

strcat(CharTime, ultoa(DigitTime.wMonth,TempStr,10));

strcat(CharTime, ".");

strcat(CharTime, ultoa(DigitTime.wYear,TempStr,10));

strcat(CharTime, " ");

strcat(CharTime, ultoa(DigitTime.wHour,TempStr,10));

strcat(CharTime, ":");

strcat(CharTime, ultoa(DigitTime.wMinute,TempStr,10));

strcat(CharTime, ":");

strcat(CharTime, ultoa(DigitTime.wSecond,TempStr,10));

strcat(CharTime, "");

}

//------------------------------------------------------------------------------

//

void ScanDir(char Path[], int Panel)

{

HANDLE HWNDFind;

bool Flag=true;

if (Panel==LEFT)//

{

if (!DequeFindLeft.empty()) DequeFindLeft.clear();//

HWNDFind=FindFirstFile(Path, &StructFind);

while (Flag)

{

Flag=FindNextFile(HWNDFind,&StructFind);

if (Flag) DequeFindLeft.push_back(StructFind);

}

FindClose(HWNDFind);

}

else //

{

if (!DequeFindRight.empty()) DequeFindRight.clear();

HWNDFind=FindFirstFile(Path, &StructFind);

while (Flag)

{

Flag=FindNextFile(HWNDFind,&StructFind);

if (Flag) DequeFindRight.push_back(StructFind);

}

FindClose(HWNDFind);

}

}

//------------------------------------------------------------------------------

//

void ViewDirectory(char Path[], int Panel)

{

ScanDir(Path, Panel);

deque::iterator iter;

WIN32_FIND_DATA StructFindTemp;

int i=0; //

Form1->FileListLeft->Cells[ColName][i]="";

Form1->FileListLeft->Cells[ColSize][i]=" ";

Form1->FileListLeft->Cells[ColAttrib][i]="";

Form1->FileListLeft->Cells[ColCreTime][i]="";

Form1->FileListLeft->Cells[ColAccTime][i]="";

Form1->FileListLeft->Cells[ColWriTime][i]="";

Form1->FileListRight->Cells[ColName][i]="";

Form1->FileListRight->Cells[ColSize][i]=" ";

Form1->FileListRight->Cells[ColAttrib][i]="";

Form1->FileListRight->Cells[ColCreTime][i]="";

Form1->FileListRight->Cells[ColAccTime][i]="";

Form1->FileListRight->Cells[ColWriTime][i]="";

i++;

if (Panel==LEFT)//

{

iter=DequeFindLeft.begin();

Form1->FileListLeft->RowCount=2;// ,

//

while (iter!=DequeFindLeft.end())

{

StructFindTemp=*iter;

if (DirAttribSet.count(StructFindTemp.dwFileAttributes))//

{ // ( )

StrucFindToFileProp (StructFindTemp, FileProperty);

Form1->FileListLeft->Cells[ColName][i]=FileProperty.FileName;

Form1->FileListLeft->Cells[ColSize][i]=FileProperty.FileSizeKb;

Form1->FileListLeft->Cells[ColAttrib][i]=FileProperty.FileAttrib;

Form1->FileListLeft->Cells[ColCreTime][i]=FileProperty.CreateTime;

Form1->FileListLeft->Cells[ColAccTime][i]=FileProperty.AccessTime;

Form1->FileListLeft->Cells[ColWriTime][i]=FileProperty.WriteTime;

Form1->FileListLeft->RowCount=Form1->FileListLeft->RowCount+1;

i++;

}

iter++;

}

iter=DequeFindLeft.begin();

while (iter!=DequeFindLeft.end())// ( )

{

StructFindTemp=*iter;

if (DirAttribSet.count(StructFindTemp.dwFileAttributes)==0)

{

StrucFindToFileProp (*iter, FileProperty);

Form1->FileListLeft->Cells[ColName][i]=FileProperty.FileName;

Form1->FileListLeft->Cells[ColSize][i]=FileProperty.FileSizeKb;

Form1->FileListLeft->Cells[ColAttrib][i]=FileProperty.FileAttrib;

Form1->FileListLeft->Cells[ColCreTime][i]=FileProperty.CreateTime;

Form1->FileListLeft->Cells[ColAccTime][i]=FileProperty.AccessTime;

Form1->FileListLeft->Cells[ColWriTime][i]=FileProperty.WriteTime;

Form1->FileListLeft->RowCount=Form1->FileListLeft->RowCount+1;

i++;

}

iter++;

}

if (i==1)//

{

Form1->FileListLeft->Cells[ColName][i]="";

Form1->FileListLeft->Cells[ColSize][i]="";

Form1->FileListLeft->Cells[ColAttrib][i]="";

Form1->FileListLeft->Cells[ColCreTime][i]="";

Form1->FileListLeft->Cells[ColAccTime][i]="";

Form1->FileListLeft->Cells[ColWriTime][i]="";

}

if (i>1) Form1->FileListLeft->RowCount=Form1->FileListLeft->RowCount-1;

}

else //

{ // ( )

iter=DequeFindRight.begin();

Form1->FileListRight->RowCount=2;

while (iter!=DequeFindRight.end())

{

StructFindTemp=*iter;

if (DirAttribSet.count(StructFindTemp.dwFileAttributes))

{

StrucFindToFileProp (StructFindTemp, FileProperty);

Form1->FileListRight->Cells[ColName][i]=FileProperty.FileName;

Form1->FileListRight->Cells[ColSize][i]=FileProperty.FileSizeKb;

Form1->FileListRight->Cells[ColAttrib][i]=FileProperty.FileAttrib;

Form1->FileListRight->Cells[ColCreTime][i]=FileProperty.CreateTime;

Form1->FileListRight->Cells[ColAccTime][i]=FileProperty.AccessTime;

Form1->FileListRight->Cells[ColWriTime][i]=FileProperty.WriteTime;

Form1->FileListRight->RowCount=Form1->FileListRight->RowCount+1;

i++;

}

iter++;

}

iter=DequeFindRight.begin();

while (iter!=DequeFindRight.end())

{

StructFindTemp=*iter;

if (DirAttribSet.count(StructFindTemp.dwFileAttributes)==0)

{

StrucFindToFileProp (*iter, FileProperty);

Form1->FileListRight->Cells[ColName][i]=FileProperty.FileName;

Form1->FileListRight->Cells[ColSize][i]=FileProperty.FileSizeKb;

Form1->FileListRight->Cells[ColAttrib][i]=FileProperty.FileAttrib;

Form1->FileListRight->Cells[ColCreTime][i]=FileProperty.CreateTime;

Form1->FileListRight->Cells[ColAccTime][i]=FileProperty.AccessTime;

Form1->FileListRight->Cells[ColWriTime][i]=FileProperty.WriteTime;

Form1->FileListRight->RowCount=Form1->FileListRight->RowCount+1;

i++;

}

iter++;

}

if (i==1)

{

Form1->FileListRight->Cells[ColName][i]="";

Form1->FileListRight->Cells[ColSize][i]="";

Form1->FileListRight->Cells[ColAttrib][i]="";

Form1->FileListRight->Cells[ColCreTime][i]="";

Form1->FileListRight->Cells[ColAccTime][i]="";

Form1->FileListRight->Cells[ColWriTime][i]="";

}

if (i>1) Form1->FileListRight->RowCount=Form1->FileListRight->RowCount-1;

}

}

//------------------------------------------------------------------------------


//

AnsiString HandlerOfOpen(AnsiString RootDir, int Panel, int DirSel)

{

const AnsiString Mask="\*.*";

char PathChar[256];

AnsiString Path;

static AnsiString CurrentPathLeft=RootDir;

static AnsiString CurrentPathRight=RootDir;

long int Row=Form1->FileListLeft->Row;

AnsiString Name=Form1->FileListLeft->Cells[ColName][Row];

if (Panel==LEFT)

{

if (DirSel!=0)//

{

switch (DirSel)

{

case 1: // ListDevices

if (RootDir.AnsiCompare(RootDirRight)==0)//

{ // ,

CurrentPathLeft=CurrentPathRight; // ,

Path=CurrentPathLeft+Mask; //

strcpy(PathChar, Path.c_str());

ViewDirectory(PathChar,LEFT);

Form1->LabelCurrentPathLeft->Caption=CurrentPathLeft;

}

else // ,

{

CurrentPathLeft=RootDir+"\";

Path=RootDir+Mask;

strcpy(PathChar, Path.c_str()); // AnsiString char

ViewDirectory(PathChar, Panel);

Form1->LabelCurrentPathLeft->Caption=CurrentPathLeft;

}

break;

case 2:// bCurrentRootDir

CurrentPathLeft=RootDir+"\";

Path=RootDir+Mask;

strcpy(PathChar, Path.c_str()); // AnsiString char

ViewDirectory(PathChar, Panel);

Form1->LabelCurrentPathLeft->Caption=CurrentPathLeft;

break;

}

}

else

{

if ((Form1->FileListLeft->Cells[ColAttrib][Row]=="Dir")||//

(Form1->FileListLeft->Cells[ColAttrib][Row]=="HideDir")||//

(Form1->FileListLeft->Cells[ColAttrib][Row]=="HideSysDir"))

if (Name=="..")//

{

int Pos,Len=CurrentPathLeft.Length();

for (int i=Len-2; i>=3;i--)

{

if (CurrentPathLeft[i]=='\')

{

Pos=i;

break;

}

}

CurrentPathLeft.Delete(Pos,(Len-Pos));

Path=CurrentPathLeft+Mask;

strcpy(PathChar, Path.c_str()); // AnsiString char

ViewDirectory(PathChar, LEFT);

Form1->LabelCurrentPathLeft->Caption=CurrentPathLeft;

}

else //

{

CurrentPathLeft+=Name;

Path=CurrentPathLeft+Mask;

CurrentPathLeft+="\";

strcpy(PathChar, Path.c_str()); // AnsiString char

Form1->LabelCurrentPathLeft->Caption=CurrentPathLeft;

ViewDirectory(PathChar,LEFT);

}

else // ( )

{

if (Name!="")

{

AnsiString FilePath;

FilePath=CurrentPathLeft+Name;

strcpy(PathChar, FilePath.c_str());

ShellExecute(0,"open",PathChar ,"","",1);

}

}

}

return CurrentPathLeft;

}


else //

{

long int Row=Form1->FileListRight->Row;

AnsiString Name=Form1->FileListRight->Cells[ColName][Row];

if (DirSel!=0)//

{

switch (DirSel)

{

case 1:

if (RootDir.AnsiCompare(RootDirLeft)==0)//

{ // ,

CurrentPathRight=CurrentPathLeft; // ,

Path=CurrentPathRight+Mask; //

strcpy(PathChar, Path.c_str());

ViewDirectory(PathChar,RIGHT);

Form1->LabelCurrentPathRight->Caption=CurrentPathRight;

}

else

{

CurrentPathRight=RootDir+'\';

Path=RootDir+Mask;

strcpy(PathChar, Path.c_str()); // AnsiString char

ViewDirectory(PathChar, Panel);

Form1->LabelCurrentPathRight->Caption=CurrentPathRight;

}

break;

case 2:

CurrentPathRight=RootDir+'\';

Path=RootDir+Mask;

strcpy(PathChar, Path.c_str()); // AnsiString char

ViewDirectory(PathChar, Panel);

Form1->LabelCurrentPathRight->Caption=CurrentPathRight;

break;

}

}

else

{

if ((Form1->FileListRight->Cells[ColAttrib][Row]=="Dir")|| // ꠠ (Form1->FileListRight->Cells[ColAttrib][Row]=="HideDir")|| //

(Form1->FileListRight->Cells[ColAttrib][Row]=="HideSysDir"))

if (Name=="..") //

{

int Pos,Len=CurrentPathRight.Length();

for (int i=Len-2; i>=3;i--)


{

if (CurrentPathRight[i]=='\')

{

Pos=i;

break;

}

}

CurrentPathRight.Delete(Pos,(Len-Pos));

Path=CurrentPathRight+Mask;

strcpy(PathChar, Path.c_str()); // AnsiString char

ViewDirectory(PathChar, RIGHT);

Form1->LabelCurrentPathRight->Caption=CurrentPathRight;

}

else //

{

CurrentPathRight+=Name;

Path=CurrentPathRight+Mask;

CurrentPathRight+="\";

strcpy(PathChar, Path.c_str()); // AnsiString char

ViewDirectory(PathChar, RIGHT);

Form1->LabelCurrentPathRight->Caption=CurrentPathRight;

}

else

{

if (Name!="") // ( )

{

AnsiString FilePath;

FilePath=CurrentPathRight+Name;

strcpy(PathChar, FilePath.c_str());

ShellExecute(0,"open",PathChar ,"","",1);

}

}

}

return CurrentPathRight;

}

}

//------------------------------------------------------------------------------

//

bool CreateFolder(int Panel)

{

const AnsiString Mask="\*.*";

AnsiString Path;

bool Result;

char PathChar[256]="";


if(Panel==LEFT) //

{

Path=CurrentPathLeft+FormDialogCreateDir->edNewDirName->Text;

strcpy(PathChar, Path.c_str()); // AnsiString char

Result=CreateDirectory(PathChar,0);

if (Result==false)

{

MessageBox(0, " !n -n .",

"Vontrop Commander - !", 0);

}

else

{

Path=CurrentPathLeft+Mask;

strcpy(PathChar, Path.c_str()); // AnsiString char

ViewDirectory(PathChar, Panel);

if (CurrentPathLeft.AnsiCompare(CurrentPathRight)==0) ViewDirectory(PathChar, RIGHT);

}

}

else//

{

Path=CurrentPathRight+FormDialogCreateDir->edNewDirName->Text;

strcpy(PathChar, Path.c_str()); // AnsiString char

Result=CreateDirectory(PathChar,0);

if (Result==false)

{

MessageBox(0, " !n -n .",

"Vontrop Commander - !", 0);

}

else

{

Path=CurrentPathRight+Mask;

strcpy(PathChar, Path.c_str()); // AnsiString char

ViewDirectory(PathChar, Panel);

if (CurrentPathRight.AnsiCompare(CurrentPathLeft)==0) ViewDirectory(PathChar, LEFT);

}

}

return Result;

}

//------------------------------------------------------------------------------


//

void Deleting(int Panel, int Operation)

{

const AnsiString Mask="\*.*";

SHFILEOPSTRUCT StructOperation;

AnsiString Name;

char PathChar[256]="";

long int Row;Form1->FileListLeft->Row;

AnsiString Path;

StructOperation.hNameMappings=0;

StructOperation.lpszProgressTitle=0;

StructOperation.hwnd=0;

StructOperation.fAnyOperationsAborted=false;

StructOperation.pTo="";

switch (Operation)

{

case FO_DELETE: StructOperation.wFunc=FO_DELETE;

StructOperation.fFlags=0;

break;

case FO_DELETER:StructOperation.wFunc=FO_DELETE;

StructOperation.fFlags=FOF_ALLOWUNDO;

break;

}

if (Panel==LEFT)

{

Row=Form1->FileListLeft->Row;

Name=Form1->FileListLeft->Cells[ColName][Row];

Path=CurrentPathLeft+Name;

strcpy(PathChar, Path.c_str()); // AnsiString char

strcat(PathChar, "");

StructOperation.pFrom=PathChar;

SHFileOperation(&StructOperation);

Path=CurrentPathLeft+Mask;

strcpy(PathChar, Path.c_str()); // AnsiString char

ViewDirectory(PathChar, Panel);

if (CurrentPathRight.AnsiCompare(CurrentPathLeft)==0) ViewDirectory(PathChar, RIGHT);

}

else

{

Row=Form1->FileListRight->Row;

Name=Form1->FileListRight->Cells[ColName][Row];

Path=CurrentPathRight+Name;

strcpy(PathChar, Path.c_str()); // AnsiString char

strcat(PathChar, "");

StructOperation.pFrom=PathChar;

SHFileOperation(&StructOperation);

Path=CurrentPathRight+Mask;

strcpy(PathChar, Path.c_str()); // AnsiString char

ViewDirectory(PathChar, Panel);

if (CurrentPathRight.AnsiCompare(CurrentPathLeft)==0) ViewDirectory(PathChar, LEFT);

}

}

//------------------------------------------------------------------------------

//

void CopyOrRemove(int Panel, int Operation)

{

const AnsiString Mask="\*.*";

SHFILEOPSTRUCT StructOperation;

AnsiString Name;

char PathCharFrom[256]="";

char PathCharTo[256]="";

long int Row;Form1->FileListLeft->Row;

AnsiString Path;

if (CurrentPathRight.AnsiCompare(CurrentPathLeft)==0)

MessageBox(0, " !!!", "Vontrop Commander - !", 0);

else

{

StructOperation.hNameMappings=0;

StructOperation.lpszProgressTitle=0;

StructOperation.hwnd=0;

StructOperation.fAnyOperationsAborted=false;

StructOperation.fFlags=0;

switch (Operation)

{

case FO_COPY: StructOperation.wFunc=FO_COPY;

break;

case FO_MOVE:StructOperation.wFunc=FO_MOVE;

break;

}

if (Panel==LEFT)

{

Row=Form1->FileListLeft->Row;

Name=Form1->FileListLeft->Cells[ColName][Row];

Path=CurrentPathLeft+Name;

strcpy(PathCharFrom, Path.c_str()); // AnsiString char

StructOperation.pFrom=PathCharFrom;

strcpy(PathCharTo, CurrentPathRight.c_str()); // AnsiString char

StructOperation.pTo=PathCharTo;

SHFileOperation(&StructOperation);

Path=CurrentPathLeft+Mask;

strcpy(PathCharTo, Path.c_str()); // AnsiString char

ViewDirectory(PathCharTo, Panel);

Path=CurrentPathRight+Mask;

strcpy(PathCharTo, Path.c_str()); // AnsiString char

ViewDirectory(PathCharTo, RIGHT);

}

else

{

Row=Form1->FileListRight->Row;

Name=Form1->FileListRight->Cells[ColName][Row];

Path=CurrentPathRight+Name;

strcpy(PathCharFrom, Path.c_str()); // AnsiString char

StructOperation.pFrom=PathCharFrom;

strcpy(PathCharTo, CurrentPathLeft.c_str()); // AnsiString char

StructOperation.pTo=PathCharTo;

SHFileOperation(&StructOperation);

Path=CurrentPathRight+Mask;

strcpy(PathCharTo, Path.c_str()); // AnsiString char

ViewDirectory(PathCharTo, Panel);

Path=CurrentPathLeft+Mask;

strcpy(PathCharTo, Path.c_str()); // AnsiString char

ViewDirectory(PathCharTo, LEFT);

}

}

}

//------------------------------------------------------------------------------


Unit3.c

//---------------------------------------------------------------------------

#include

#pragma hdrstop

#include "Unit2.h"

#include "Unit3.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TFormDialogCreateDir *FormDialogCreateDir;

//---------------------------------------------------------------------------

__fastcall TFormDialogCreateDir::TFormDialogCreateDir(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TFormDialogCreateDir::bCancelClick(TObject *Sender)

{

FormDialogCreateDir->edNewDirName->Text="";

FormDialogCreateDir->edNewDirName->SetFocus();

FormDialogCreateDir->Hide();

}

//---------------------------------------------------------------------------

void __fastcall TFormDialogCreateDir::bOkClick(TObject *Sender)

{

bool Result=CreateFolder(Panel);

FormDialogCreateDir->edNewDirName->SetFocus();

if (Result==true)

{

FormDialogCreateDir->edNewDirName->Text="";

FormDialogCreateDir->Hide();

}

}

//---------------------------------------------------------------------------

void __fastcall TFormDialogCreateDir::edNewDirNameKeyDown(TObject *Sender,

WORD &Key, TShiftState Shift)

{

bool Result;

switch (Key)

{

case 13: Result=CreateFolder(Panel);

FormDialogCreateDir->edNewDirName->SetFocus();

if (Result==true)

{

FormDialogCreateDir->edNewDirName->Text="";

FormDialogCreateDir->Hide();

}

break;

case 27: FormDialogCreateDir->edNewDirName->Text="";

FormDialogCreateDir->edNewDirName->SetFocus();

FormDialogCreateDir->Hide();

break;

}

}

//---------------------------------------------------------------------------

Unit4.c

//---------------------------------------------------------------------------

#include

#pragma hdrstop

#include "Unit4.h"

#pragma package(smart_init)

#pragma resource "*.dfm"

TFormDialogDelete *FormDialogDelete;

#include "Unit2.h"

//---------------------------------------------------------------------------

__fastcall TFormDialogDelete::TFormDialogDelete(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TFormDialogDelete::bCancelClick(TObject *Sender)

{

FormDialogDelete->bRecycler->SetFocus();

FormDialogDelete->Hide();

}

//---------------------------------------------------------------------------

void __fastcall TFormDialogDelete::bDeleteClick(TObject *Sender)

{

Deleting(Panel,FO_DELETE);

FormDialogDelete->bRecycler->SetFocus();

FormDialogDelete->Hide();

}

//---------------------------------------------------------------------------

void __fastcall TFormDialogDelete::bRecyclerClick(TObject *Sender)

{

Deleting(Panel,FO_DELETER);

FormDialogDelete->bRecycler->SetFocus();

FormDialogDelete->Hide();

}

//---------------------------------------------------------------------------



[1] , , , .. - . (. A).

һ

 

 

 

! , , , .
. , :