⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.pas

📁 该程序用D5编译
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  if extn='.wpj' then result:= 91 else
  if extn='.pr' then result:= 92 else
  if extn='.wsp' then result:= 93 else
  if extn='.java' then result:= 94 else
  if extn='.mdl' then result:= 95 else
  if extn='.rc' then result:= 96 else
  if extn='.dot' then result:= 97 else
  if extn='.vhd' then result:= 102 else
  if (extn='.v')or(extn='.tf') then result:= 103 else
  if extn='.xls' then result:= 104 else
  if extn='.psd' then result:= 108 else
end;

procedure TMainForm.ShowToolsForm(index: integer);
begin
  with ToolsForm do
  begin
    Show;
    if WindowState = wsMinimized then ShowWindow(Handle, SW_RESTORE);
    PageCtrl.ActivePageIndex := index;
  end;
end;

function TMainForm.GroupFunc(s:string):string;
begin
  if ((s<>'')and(s[1]='\')){or(s='查找')or(s='收藏')} then result:='未知'
  else result:=s;
end;

procedure TMainForm.AddCap(group:string;dir:string);
begin
  if (group='')and(dir='') then
  begin
    pnlHeader.Caption := '';
    exit;
  end;
  if group[length(group)]=#0 then delete(group,length(group),1);
  pnlHeader.Caption := ' 工作组:'+GroupFunc(group)+'      主机和文件夹:'+dir;
  StatusBar.Panels[2].Text := pnlHeader.Caption;

  CurDirName := dir + '\';
end;

procedure TExecuteThread.Execute;
begin
  ExecuteFile(exefile,'',exedir,SW_SHOW);
end;

procedure TMainForm.PageControlWndProc1(var Message: TMessage);  //Client
begin
  FOriginalPageControlWndProc1(Message);
  with Message do
    if (Msg = TCM_ADJUSTRECT) and (Message.WParam = 0) then
    begin
      PRect(LParam)^.Top := PRect(LParam)^.Top-5;
      PRect(LParam)^.Bottom := PRect(LParam)^.Bottom-2;
      PRect(LParam)^.left := PRect(LParam)^.left;
      PRect(LParam)^.Right := PRect(LParam)^.Right+1;
      InflateRect(PRect(LParam)^, 5, 3);
    end;
end;

procedure TMainForm.PageControlWndProc3(var Message: TMessage); //left
begin
  FOriginalPageControlWndProc3(Message);
  with Message do
    if (Msg = TCM_ADJUSTRECT) and (Message.WParam = 0) then
    begin
      PRect(LParam)^.Top := PRect(LParam)^.Top;
      PRect(LParam)^.Bottom := PRect(LParam)^.Bottom +3;
      PRect(LParam)^.left := PRect(LParam)^.left-1;
      PRect(LParam)^.Right := PRect(LParam)^.Right;
      InflateRect(PRect(LParam)^, 5, 3);
    end;
end;

procedure TMainForm.PageControlWndProc4(var Message: TMessage); //bottom
begin
  FOriginalPageControlWndProc4(Message);
  with Message do
    if (Msg = TCM_ADJUSTRECT) and (Message.WParam = 0) then
    begin
      PRect(LParam)^.Top := PRect(LParam)^.Top-7;
      PRect(LParam)^.left := PRect(LParam)^.left;
      InflateRect(PRect(LParam)^, 5, 1);
    end;
end;

procedure TMainForm.PageControlWndProc5(var Message: TMessage); //search
begin
  FOriginalPageControlWndProc5(Message);
  with Message do
    if (Msg = TCM_ADJUSTRECT) and (Message.WParam = 0) then
    begin
      PRect(LParam)^.Top := PRect(LParam)^.Top-3;
      PRect(LParam)^.Bottom := PRect(LParam)^.Bottom +2;
      PRect(LParam)^.left := PRect(LParam)^.left;
      InflateRect(PRect(LParam)^, 4, 1);
    end;
end;

procedure TMainForm.CheckFile(FileName,MyDir,MyGroup:string;ImageIndex:integer);
var
  listitem: TListitem;
begin
  with ConfigForm do
    begin

     if CheckDest(FileName) then
     begin
       listitem:=FindListview.Items.Add;
       if ImageIndex<>0 then listitem.ImageIndex:= GetImgIndex(FileName) else
       listitem.ImageIndex := ImageIndex;
       listitem.Caption := extractfilename(FileName);
       listitem.SubItems.add(MyDir);
       listitem.SubItems.add(MyGroup);
       StrListSearch.Add(' 工作组:'+GroupFunc(MyGroup)+' 地址:'+MyDir+'\'+FileName);
     end;

     if CheckMP3(FileName) then
     begin
       listitem:=MP3Listview.Items.Add;
       if ImageIndex<>0 then listitem.ImageIndex:= GetImgIndex(FileName) else
       listitem.ImageIndex := ImageIndex;
       listitem.Caption := extractfilename(FileName);
       listitem.SubItems.add(MyDir);
       listitem.SubItems.add(MyGroup);
       StrListMp3.Add(' 工作组:'+GroupFunc(MyGroup)+' 地址:'+MyDir+'\'+FileName);
     end;

     if CheckMovie(FileName) then
     begin
       listitem:=MovieListview.Items.Add;
       if ImageIndex<>0 then listitem.ImageIndex:= GetImgIndex(FileName) else
       listitem.ImageIndex := ImageIndex;
       listitem.Caption := extractfilename(FileName);
       listitem.SubItems.add(MyDir);
       listitem.SubItems.add(MyGroup);
       StrListMovie.Add(' 工作组:'+GroupFunc(MyGroup)+' 地址:'+MyDir+'\'+FileName);
     end;

  end;
end;

procedure TMainForm.OpenIni;
begin

  ini:=Tinifile.create(AppDir+'LanExplorer.ini');
  if not fileexists('LanExplorer.ini')
  then
  begin
    ini.writeInteger('window position','top',top);
    ini.writeInteger('window position','left',left);
    ini.writeInteger('window position','width',width);
    ini.writeInteger('window position','height',height);

    ini.writeInteger('panel position','left_panel',LeftPanel.Width);
    //ini.writeInteger('panel position','right_panel',RightPanel.Width);
    ini.writeInteger('panel position','bottom_panel',BottomPanel.Height);

    ini.writeString('Dock','RightDockPanel','alRight');

    // nbtstat IP address
    ini.writeString('NBT_IP','IP1','192.168.0.1');
    ini.writeString('NBT_IP','IP2','192.168.0.255');

    // TCP port scan address
    ini.writeString('TCP_PORT_SCAN','IP1','192.168.0.1');
    ini.writeString('TCP_PORT_SCAN','IP2','192.168.0.255');

    // ping IP address
    ini.writeString('PING','IP1','192.168.0.1');
    ini.writeString('PING','IP2','192.168.0.255');

    // Scan IP address
    ini.writeString('SCAN','IP1','192.168.0.1');
    ini.writeString('SCAN','IP2','192.168.0.255');

    // Save history or not
    ini.writeString('history','save','yes');
    ini.writeString('history','save_when_share','yes');
    ini.writeString('history','save_nbt','yes');
  end
  else
  begin
    top:=ini.ReadInteger('window position','top',50);
    left:=ini.ReadInteger('window position','left',50);
    width:=ini.ReadInteger('window position','width',500);
    height:=ini.ReadInteger('window position','height',50);

    if (width=screen.Width)and(height=screen.Height)then WindowState:=wsMaximized; 

    LeftPanel.Width:=ini.ReadInteger('panel position','left_panel',LeftPanel.Width);
    //RightPanel.Width:=ini.ReadInteger('panel position','right_panel',RightPanel.Width);
    BottomPanel.Height:=ini.ReadInteger('panel position','bottom_panel',BottomPanel.Height);

    //nbtstat IP address
    Nbt_IP1 := ini.ReadString('NBT_IP', 'IP1', '192.168.0.1');
    Nbt_IP2 := ini.ReadString('NBT_IP', 'IP2', '192.168.0.255');

    //TCP port scan address
    ScanPort_IP1 := ini.ReadString('TCP_PORT_SCAN','IP1','192.168.0.1');
    ScanPort_IP2 := ini.ReadString('TCP_PORT_SCAN','IP2','192.168.0.255');

    //ping IP address
    Ping_IP1 := ini.ReadString('PING','IP1','192.168.0.1');
    Ping_IP2 := ini.ReadString('PING','IP2','192.168.0.255');

    //CheckIpForm.edtStart.Text
    edtIP1.Text := ini.ReadString('SCAN', 'IP1', '192.168.0.1');
    edtIP2.Text := ini.ReadString('SCAN', 'IP2', '192.168.0.255');

    // Save History or not
    cbSaveHistory.Checked := (ini.ReadString('history','save','yes') = 'yes');
    cbSaveOpt.Checked := (ini.ReadString('history','save_when_share','yes') = 'yes');
    bNotAutoSaveNbt := (ini.ReadString('history','save_nbt','yes') = 'yes');
  end;
  ini.Free;
  
  
end;

procedure TMainForm.SaveIni;
begin

  if AppDir[1]='\' then exit; //open on the LAN
  //showmessage(mydir);
  ini:=Tinifile.create(AppDir+'LanExplorer.ini');

  ini.writeInteger('window position','top',top);
  ini.writeInteger('window position','left',left);
  ini.writeInteger('window position','width',width);
  ini.writeInteger('window position','height',height);

  ini.writeInteger('panel position','left_panel',LeftPanel.Width);
  //ini.writeInteger('panel position','right_panel',RightPanel.Width);
  ini.writeInteger('panel position','bottom_panel',BottomPanel.Height);

  //nbtstat IP address
  ini.WriteString('NBT_IP', 'IP1', ToolsForm.edtNbtIP1.Text);
  ini.WriteString('NBT_IP', 'IP2', ToolsForm.edtNbtIP2.Text);

  //TCP port scan address
  ini.writeString('TCP_PORT_SCAN','IP1',ToolsForm.edtScanIP1.Text);
  ini.writeString('TCP_PORT_SCAN','IP2',ToolsForm.edtScanIP2.Text);

  //ping IP address
  ini.writeString('PING','IP1',ToolsForm.edtPing1.Text);
  ini.writeString('PING','IP2',ToolsForm.edtPing2.Text);

  //Scan IP address
  ini.writeString('SCAN','IP1',edtIP1.Text);
  ini.writeString('SCAN','IP2',edtIP2.Text);

  // Save History or not
  if cbSaveHistory.Checked then ini.writeString('history','save','yes')
  else ini.writeString('history','save','no');

  if cbSaveOpt.Checked then ini.writeString('history','save_when_share','yes')
  else ini.writeString('history','save_when_share','no');

  if ToolsForm.cbNbtDataLoad.Checked then ini.writeString('history','save_nbt','yes')
  else ini.writeString('history','save_nbt','no');

  ini.Free;
  
end;

procedure TMainForm.OpenHistory;
var
  RootNode, TemNode, GroupNode: TTreeNode;
  s: string;
  f: TextFile;
  MyItemPtr     : PMyTreeItem;
begin

  RootNode:=HistoryTree.Items[0];
  GroupNode := RootNode;  ///
  if FileExists('History.txt') then
  begin
    AssignFile(f,'History.txt');
    reset(f);

    HistoryTree.Items.BeginUpdate; ///
    while not eof(f) do
    begin
      Application.ProcessMessages;

      readln(f,s);
      s := trim(s);
      if s = '' then continue;
      if s[1] <> '\' then  //group
      begin
       GroupNode := HistoryTree.Items.AddChild(RootNode,s);
       GroupNode.ImageIndex := 9;
       GroupNode.SelectedIndex := 9;
      end
      else
      begin
       New(MyItemPtr);
       MyItemPtr^.group := GroupNode.Text;
       MyItemPtr^.dirName := s;
       TemNode:=HistoryTree.Items.AddChild(GroupNode, s);
       TemNode.Data := MyItemPtr;
       TemNode.ImageIndex := 7;
       TemNode.SelectedIndex := 7;//12;
       GroupNode.Expand(false);
      end;
    end;
    HistoryTree.Items.EndUpdate; ////
    
    CloseFile(f);

    RootNode.Expand(false);
  end;

end;

procedure TMainForm.SaveHistory;
var
  i, j          : integer;
  TempGroupNode : TTreeNode;
  f             : TextFile;
begin

  if (not cbSaveHistory.Checked) then exit;
   
  if AppDir[1]<>'\' then     //open on the LAN
  begin
    assignfile(f, AppDir+'\History.txt');
    rewrite(f);
    if HistoryTree.Items[0].HasChildren  then
    begin
      HistoryTree.Items.BeginUpdate; ///
      //TempGroupNode:=nil; // just remove warning;
      for i:=1 to HistoryTree.Items[0].count do
      begin
        TempGroupNode:= HistoryTree.Items[0].Item[i-1]; //groups
        writeln(f,TempGroupNode.text);
        for j := 1 to TempGroupNode.Count do writeln(f,TempGroupNode.Item[j-1].Text); //host
      end;
      //caption:=TempGroupNode.text; // just remove warning;
      HistoryTree.Items.EndUpdate; ////
    end;
    closefile(f);
  end;

end;

function CheckFavo(s:string):integer;
var
  i, j: integer;
begin
  j:=0;
  for i:=1 to length(s) do if s[i]='\' then inc(j);
  result := j;
end;

procedure TMainForm.OpenFavorite;
var
  RootNode,TemNode      : TTreeNode;
  fg,fs                 : string;
  f                     : TextFile;
  MyItemPtr     : PMyTreeItem;
begin

   RootNode:=FavoTree.Items[0];
   if fileexists('Favorite.txt') then
   begin
     assignfile(f,'Favorite.txt');
     reset(f);

     FavoTree.Items.BeginUpdate;

     while not eof(f) do
     begin
        Application.ProcessMessages;
        
        readln(f,fg);
        New(MyItemPtr);
        MyItemPtr^.group := trim(fg);

        readln(f,fs);
        MyItemPtr^.dirName := trim(fs);

        if (trim(fg)='')or(trim(fs)='') then
        begin
          Dispose(MyItemPtr);
          continue;
        end;

        TemNode:=FavoTree.Items.AddChild(RootNode,fs);
        TemNode.Data := MyItemPtr;
        case CheckFavo(fs) of
          0:begin
              TemNode.ImageIndex := 5;
              TemNode.SelectedIndex := 5;//16;
            end;
          2:begin
              TemNode.ImageIndex := 7;
              TemNode.SelectedIndex := 7;//12;
            end;
          else TemNode.ImageIndex := 0;
        end;  //end of case;

     end;

     FavoTree.Items.EndUpdate;

     CloseFile(f);
     
     try
       FavoTree.Items[0].Expand(false);
       except on ETreeViewError do FavoTree.Items.AddChildFirst(nil,'收藏');
     end; //end of try
   end;

end;

procedure TMainForm.SaveFavorite;
var
  i             : integer;
  TempNode      : TTreeNode;
  f             : TextFile;
begin

  if AppDir[1]<>'\' then     //open on the LAN
  try
  begin
    AssignFile(f,AppDir+'\Favorite.txt');
    ReWrite(f);

    FavoTree.Items.BeginUpdate;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -