打印本文 打印本文 关闭窗口 关闭窗口
网络小工具 ShareView
作者:武汉SEO闵涛  文章来源:敏韬网  点击数11018  更新时间:2009/4/23 18:28:24  文章录入:mintao  责任编辑:mintao
ject);
var
  Name, Dir: string;
begin
  if Sys_SelectDirectory(Self.Handle, Dir, ''''请选择共享目录:'''', True) then
  begin
    Name := InputBox(''''输入'''', ''''请输入共享名称'''', ExtractFileName(Dir));
    AddShare(Name, Dir);
    with LvShares.Items.Add do
    begin
      Caption := Name;
      SubItems.Add(Dir);
    end;
  end;
end;

procedure TMainForm.SessionRefreshActionExecute(Sender: TObject);
var
  List: TStrings;
  I: Integer;
  OS: Boolean;
  SessionInfo502Obj: TSessionInfo502Obj;
begin
  if not IsNT(OS) then Exit;
  List := TStringList.Create;
  try
    GetSessions(List);
    lvSessions.Items.Clear;
    for I := 0 to List.Count - 1 do
    begin
      SessionInfo502Obj := TSessionInfo502Obj(List.Objects[I]);
      if SessionInfo502Obj <> nil then
      begin
        with lvSessions.Items.Add do
        begin
          Caption := List[I];
          SubItems.Add(SessionInfo502Obj.Sesi502_username);
          SubItems.Add(IntToStr(SessionInfo502Obj.Sesi502_num_opens));
          SubItems.Add(IntegerToTimeStr(SessionInfo502Obj.Sesi502_Time));
          SubItems.Add(IntegerToTimeStr(SessionInfo502Obj.sesi502_idle_time));
        end;
      end;
    end;
  finally
    List.Free;
  end;
end;

procedure TMainForm.SessionCloseActionExecute(Sender: TObject);
begin
  if (lvSessions.Items.Count = 0) or (lvSessions.Selected = nil) then
    Exit;
  if Application.MessageBox(''''确实要关闭该会话吗?'''', ''''提示'''', MB_YESNO + MB_ICONQUESTION) <> ID_YES then
    Exit;
  CloseSession(lvSessions.Selected.Caption);
  lvSessions.Items.Delete(lvSessions.Selected.Index);
end;

procedure TMainForm.TrafficRefreshActionExecute(Sender: TObject);
var
  List: TStrings;
  I: Integer;
  OS: Boolean;
  Traffic: TTraffic;
begin
  if not IsNT(OS) then Exit;
  List := TStringList.Create;
  try
    GetTrafficSets(List);
    lvTraffic.Items.BeginUpdate;
    try
      lvTraffic.Items.Clear;
      for I := 0 to List.Count - 1 do
      begin
        Traffic := TTraffic(List.Objects[I]);
        if Traffic <> nil then
        begin
          with lvTraffic.Items.Add do
          begin
            Caption := List[I];
            SubItems.Add(Traffic.MAC);
            SubItems.Add(IntToStr(Traffic.dwInOctets));
            SubItems.Add(IntToStr(Traffic.dwInOctets));
          end;
        end;
      end;
    finally
      lvTraffic.Items.EndUpdate;
    end;
  finally
    List.Free;
  end;
end;


procedure TMainForm.Timer1Timer(Sender: TObject);
begin
  ShareRefreshActionExecute(nil);
  SessionRefreshActionExecute(nil);
  TrafficRefreshActionExecute(nil);
  FileRefreshActionExecute(nil);
  if LvFiles.Items.Count <> 0 then
    ShowMainForm(nil);
end;

procedure TMainForm.FormShow(Sender: TObject);
begin
  ShareRefreshActionExecute(nil);
  SessionRefreshActionExecute(nil);
  TrafficRefreshActionExecute(nil);
  FileRefreshActionExecute(nil);
  Timer1.Enabled := True;
end;

procedure TMainForm.FileRefreshActionExecute(Sender: TObject);
var
  List: TStrings;
  I: Integer;
  OS: Boolean;
  FileInfo3Obj: TFileInfo3Obj;
begin
  if not IsNT(OS) then Exit;
  List := TStringList.Create;
  try
    GetFiles(List);
    lvFiles.Items.BeginUpdate;
    try
      lvFiles.Items.Clear;
      for I := 0 to List.Count - 1 do
      begin
        FileInfo3Obj := TFileInfo3Obj(List.Objects[I]);
        if FileInfo3Obj <> nil then
        begin
          with lvFiles.Items.Add do
          begin
            Caption := List[I];
            SubItems.Add(FileInfo3Obj.fi3_pathname);
            SubItems.Add(FileInfo3Obj.fi3_username);
          end;
        end;
      end;
    finally
      lvFiles.Items.EndUpdate;
    end;
  finally
    List.Free;
  end;
end;

procedure TMainForm.lvSessionsMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  SessionCloseAction.Enabled := (lvSessions.Items.Count <> 0) and (lvSessions.Selected <> nil);
  N15.Enabled := SessionCloseAction.Enabled;
end;

procedure TMainForm.LvFilesMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  FileCloseAction.Enabled := (LvFiles.Items.Count <> 0) and (LvFiles.Selected <> nil);
end;

procedure TMainForm.FileCloseActionExecute(Sender: TObject);
begin
  if (lvFiles.Items.Count = 0) or (lvFiles.Selected = nil) then
    Exit;
  if Application.MessageBox(''''确实要关闭该会话吗?'''', ''''提示'''', MB_YESNO + MB_ICONQUESTION) <> ID_YES then
    Exit;
  CloseFile(lvFiles.Selected.Caption);
  lvFiles.Items.Delete(lvFiles.Selected.Index);
end;

procedure TMainForm.N13Click(Sender: TObject);
var
  Path: string;
begin
  if LvShares.Selected <> nil then
  begin
    Path := LvShares.Selected.SubItems[0];
    ShellExecute(0, ''''explore'''', PChar(Path),
      nil, nil, SW_NORMAL);
  end;
end;

procedure TMainForm.N15Click(Sender: TObject);
var
  Name: string;
begin
  if LvSessions.Selected <> nil then
  begin
    Name := LvSessions.Selected.SubItems[0];
    Clipboard.AsText := Name
  end;
end;

procedure TMainForm.N16Click(Sender: TObject);
begin
  if FSendToNames.IndexOf(FCurNode.Text + ''''*'''') = -1 then
    FSendToNames.Add(FCurNode.Text + ''''*'''');
  EdToName.Text := EdToName.Text + FCurNode.Text + ''''*'''';
end;

procedure TMainForm.N19Click(Sender: TObject);
begin
  Application.Terminate;
end;

procedure TMainForm.N17Click(Sender: TObject);
begin
  ShowMainForm(nil);
end;

procedure TMainForm.ShowMainForm(Sender: TObject);
begin
  TrayNotifyIcon1.HideTask := False;
end;


procedure TMainForm.WMSysCommand(var Msg: TMessage);
begin
  if (Msg.WParam = SC_CLOSE) then
    Msg.WParam := SC_MINIMIZE;
  inherited;
  if (Msg.WParam = SC_MINIMIZE) then
    TrayNotifyIcon1.HideTask := True;
end;

procedure TMainForm.WMHotkeyHandle(var Msg: Tmessage);
begin
  if (Msg.LParamHi = VK_RETURN) and (Msg.lparamLo = MOD_CONTROL) then
  begin
    if BtnOk.Enabled then
      BtnOkClick(nil);
    Msg.Result := 1;
  end;
end;

end.


界面dfm文件
object MainForm: TMainForm
  Left = 64
  Top = 98
  Width = 921
  Height = 577
  Color = clBtnFace
  Font.Charset = GB2312_CHARSET
  Font.Color = clWindowText
  Font.Height = -12
  Font.Name = ''''宋体''''
  Font.Style = []
  OldCreateOrder = False
  WindowState = wsMaximized
  OnActivate = FormActivate
  OnCreate = FormCreate
  OnDestroy = FormDestroy
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 12
  object Splitter2: TSplitter
    Left = 0
    Top = 233
    Width

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ...  下一页 >> 

打印本文 打印本文 关闭窗口 关闭窗口