首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

Delphi远程交互程序源码放送!解决方法

2012-02-03 
Delphi远程交互程序源码放送!数据库读写?文件传输?远程控制?远程维护?......----------------------------

Delphi远程交互程序源码放送!
数据库读写?
文件传输?
远程控制?
远程维护?
......
------------------------------
众多的远程交互功能需求困扰你了吧? 来看个程序的界面:




该程序基于Delphi中间件QuickBurro轻松实现(网址:www.quickburro.com),下面是部分代码:、


//
// 当顺利连接到本地节点时,输入登陆参数...
procedure TMainForm.QBConnection1Connected(Sender: TObject);
begin
  failtimes:=0;
  CurrentNodeId:=qbconnection1.NodeId;
  CurrentDrive:='';
  CurrentPath:='';
  statusbar.Panels[0].Text:=' 当前节点:'+CurrentNodeId;
  form2.showmodal;
  ShowNodeTree;
end;

//
// 关闭确认...
procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  if application.MessageBox('是否确认从级联网远程管理器(NetAdmin)中退出?','退出确认',mb_okcancel+mb_iconquestion)<>IDOK then
  begin
  canclose:=false;
  exit;
  end;
  syncburro1.UserLogout;
  canclose:=true;
end;

//
// 得到一个节点代码中的顶层节点名...
// 对于Z#Y#X字符串,得到X
function TMainForm.TopNodeId(NodeId: string): string;
var
  tmpstr: string;
  j: integer;
begin
  tmpstr:=nodeid;
  j:=pos('#',tmpstr);
  while j>0 do
  begin
  delete(tmpstr,1,j);
  j:=pos('#',tmpstr);
  end;
  result:=tmpstr;
end;

//
// 以当前节点为末端节点,显示节点树...
procedure TMainForm.ShowNodeTree;
var
  tmpstr,nid: string;
  newnode,Node: TTreeNode;
begin
  treeview1.items.clear;
  tmpstr:=CurrentNodeId;
  node:=nil;
  while true do
  begin
  nid:=topnodeid(tmpstr);
  //
  // 若是根节点...
  if treeview1.Items.Count=0 then
  Node:=Treeview1.Items.AddFirst(nil,nid)
  //
  // 不是根节点...
  else
  begin
  newnode:=treeview1.Items.AddChild(node,nid);
  node:=newnode;
  end;
  node.ImageIndex:=1;
  node.SelectedIndex:=1;
  //
  // 假如不存在其它节点了,跳出循环...
  if pos('#',tmpstr)<=0 then
  break;
  //
  // 删除后部已经显示的上层名称...
  delete(tmpstr,length(tmpstr)-length(nid),length(nid)+1);
  end;
  node.Selected:=true;
end;

//
// 得到一个TreeView记录对应的节点全局代码的过程...
// 对于一个下层的Z,得到Z#Y#X代码的过程
function TMainForm.GetNodeId(ANode: TTreeNode): string;
var
  Node: TTreeNode;
begin
  if anode=nil then
  begin
  result:='';
  exit;
  end;
  node:=anode;
  result:=node.Text;
  while node.Parent<>nil do
  begin
  node:=node.Parent;
  result:=result+'#'+node.Text;
  end;
end;

//
// 选中节点改变时...
procedure TMainForm.TreeView1Change(Sender: TObject; Node: TTreeNode);
begin
//
// 先清除列表...
  listview2.Items.Clear;
  listview3.Items.Clear;
  listview4.items.Clear;
  CurrentNodeId:=GetNodeId(Node);
  CurrentDrive:='';
  CurrentPath:='';
  statusbar.Panels[0].Text:=' 系统提示:选中节点['+CurrentNodeId+'].';
  statusbar.Panels[1].Text:=' 当前节点:'+CurrentNodeId;
  statusbar.Panels[2].Text:=' 下属节点:0';
  statusbar.Panels[3].Text:=' 内网用户:0';
  statusbar.Panels[4].Text:=' 驱动器数:0';
  statusbar.Panels[5].Text:=' 当前路径:'+CurrentPath;
//
// 假如未选中,或选中节点不在线,返回...


  if (Node=nil) or (node.ImageIndex=0) then
  exit;
//
// 假如选中了,则需要接着按顺序获取该节点参数...
  ShowSonNodeList(Node);
//
// 显示用户列表...
  ShowUserList;
//
// 得到驱动器列表...
  ShowDriverList;
end;

//
// 显示节点列表...
procedure TMainForm.ShowSonNodeList(ParentNode: TTreeNode);
var
  Cds: TClientDataset;
  j: integer;
  tmpstr: string;
  Node: TTreeNode;
begin
  ParentNode.DeleteChildren;
  Cds:=TClientDataset.Create(nil);
  SyncBurro1.FetchSonNodeList(CurrentNodeId,Cds);
  CDS.First;
  while not CDS.Eof do
  begin
  tmpstr:=trim(Cds.fieldbyname('NodeId').asstring);
  j:=pos('#',tmpstr);
  if j>0 then
  tmpstr:=copy(tmpstr,1,j-1);
  node:=TreeView1.Items.AddChild(ParentNode,tmpstr);
  if trim(Cds.fieldbyname('Online').asstring)='1' then
  node.ImageIndex:=1
  else
  node.ImageIndex:=0;
  node.SelectedIndex:=node.ImageIndex;
  CDS.next;
  end;
  TreeView1.Selected.Expand(true);
  statusbar.Panels[2].text:=' 下属节点:'+inttostr(CDS.RecordCount);
  statusbar.Panels[0].Text:=' 系统提示:获取当前节点的子节点表成功.';
  Cds.free;
end;

//
// 显示用户列表...
procedure TMainForm.ShowUserList;
var
  Cds: TClientDataset;
  j: integer;
  tmpstr: string;
begin
  Cds:=TClientDataset.Create(nil);
  ListView2.Items.BeginUpdate;
  ListView2.Items.Clear;
  SyncBurro1.FetchUserList(CurrentNodeId,Cds);
  CDS.First;
  while not CDS.Eof do
  begin
  with listview2.Items.Add do
  begin
  caption:=inttostr(listview2.items.count);
  subitems.Add(trim(cds.fieldbyname('UserId').asstring));
  subitems.Add(trim(cds.fieldbyname('UserName').asstring));
  subitems.Add(trim(cds.fieldbyname('UserTypeName').asstring));
  subitems.Add(trim(cds.fieldbyname('IPAddress').asstring));
  subitems.Add(trim(cds.fieldbyname('SyncPort').asstring));
  if cds.fieldbyname('Online').asinteger=0 then
  begin
  subitems.add('□');
  imageindex:=0;
  end
  else
  begin
  subitems.add('√');
  imageindex:=1;
  end;
  end;
  cds.next;
  end;
  ListView2.Items.EndUpdate;
  statusbar.Panels[3].text:=' 内网用户:'+inttostr(listview2.items.count);
  statusbar.Panels[0].Text:=' 系统提示:获取当前节点的用户列表成功.';
  Cds.free;
end;

//
// 显示驱动器列表...
procedure TMainForm.ShowDriverList;
var
  j: integer;
  tmpstr: string;
begin
  RpcRemoteFiles1.GetDiskList(CurrentNodeId,tmpstr);
  ListView3.Items.BeginUpdate;
  ListView3.Items.Clear;
  j:=pos(#13#10,tmpstr);
  while j>0 do
  begin
  with listview3.Items.add do
  begin
  caption:=trim(copy(tmpstr,1,j-1));
  imageindex:=0;
  end;
  delete(tmpstr,1,j);
  j:=pos(#13#10,tmpstr);
  end;
  statusbar.Panels[4].text:=' 驱动器数:'+inttostr(listview3.items.count);
  statusbar.Panels[0].Text:=' 系统提示:获取当前节点的驱动器列表成功.';


  if listview3.Items.Count>0 then
  listview3.Items[0].Selected:=true;
  ListView3.Items.EndUpdate;
end;

//
// 当选中一个驱动器时,索取其文件列表...
procedure TMainForm.ListView3SelectItem(Sender: TObject; Item: TListItem;
  Selected: Boolean);
begin
  if not selected then
  exit;
  if copy(listview3.selected.caption,1,2)=currentdrive then
  exit;
  currentdrive:=copy(listview3.selected.caption,1,2);
  currentpath:=currentdrive+'\';
  statusbar.Panels[5].text:=' 当前路径:'+CurrentPath;
  ShowFileList;
end;

//
// 显示文件列表的过程...
procedure TMainForm.ShowFileList;
var
  Cds: TClientDataset;
  j,attr: integer;
  tmpstr: string;
begin
  listview4.Items.BeginUpdate;
  listview4.Items.Clear;
  listview4.Items.EndUpdate;
//
// A:盘不允许访问...
  if uppercase(currentdrive)='A:' then
  exit;
//
// 得到文件列表...
  Cds:=TClientDataset.Create(nil);
  RpcRemoteFiles1.ListFiles(CurrentNodeId,CurrentPath,faAnyFile,'*.*',Cds);
//
// 显示列表...
  cds.First;
  j:=1;
  while not cds.Eof do
  begin
  with listview4.Items.Add do
  begin
  caption:=inttostr(j);
  subitems.add(trim(cds.fieldbyname('FileName').asstring));
  tmpstr:=trim(cds.fieldbyname('FileDateTime').asstring);
  tmpstr:=copy(tmpstr,1,4)+'-'+copy(tmpstr,5,2)+'-'+copy(tmpstr,7,2)+' '+copy(tmpstr,9,2)+':'+copy(tmpstr,11,2)+':'+copy(tmpstr,13,2);
  subitems.add(tmpstr);
  subitems.add(trim(cds.fieldbyname('FileSize').asstring));
  attr:=cds.fieldbyname('FileAttr').asinteger;
  if (attr and $20)=0 then
  subitems.add('.')
  else
  subitems.add('√');
  if (attr and $1)=0 then
  subitems.add('.')
  else
  subitems.add('√');
  if (attr and $2)=0 then
  subitems.add('.')
  else
  subitems.add('√');
  if (attr and $4)=0 then
  subitems.add('.')
  else
  subitems.add('√');
  if (attr and $8)=0 then
  subitems.add('.')
  else
  subitems.add('√');
  if (attr and $10)=0 then
  subitems.add('.')
  else
  subitems.add('√');
  if (attr and $10)<>0 then
  imageindex:=1
  else
  begin
  if (attr and $8)<>0 then
  imageindex:=2
  else
  imageindex:=0;
  end;
  end;
  inc(j);
  cds.next;
  end;
  cds.Free;
  statusbar.Panels[0].Text:=' 系统提示:获取当前路径的文件列表成功.';
end;
。。。。。。

[解决办法]
界面看着不错~~
[解决办法]
不是基于http协议的?
价格范围?
[解决办法]
很强
------解决方案--------------------


要钱吗?
我只想要传送文件部分
[解决办法]
UP
[解决办法]
有意思。
[解决办法]
我要接分,拿分给我吧,对于分我很饥渴
[解决办法]
MARK
[解决办法]
标记一下,以后看
[解决办法]
强。。

热点排行