转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> Delphi程序 >> 正文
网络小工具 ShareView         ★★★★

网络小工具 ShareView

作者:闵涛 文章来源:闵涛的学习笔记 点击数:8287 更新时间:2009/4/23 18:28:24
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]  ...  下一页 >> 


没有相关教程
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台