dle); Exit; end; NetFileClose(nil, StrToInt(FileIndex)); end else begin FLibHandle := LoadLibrary(''''SVRAPI.DLL''''); if FLibHandle = 0 then Exit; @NetFileClose2 := GetProcAddress(FLibHandle, ''''NetFileClose2''''); if not Assigned(NetFileClose2) then begin FreeLibrary(FLibHandle); Exit; end; NetFileClose2(nil, StrToInt(FileIndex)); end; FreeLibrary(FLibHandle); end;
procedure GetTrafficSets(TrafficsList: TStrings); var FLibHandle : THandle; Table: TMibIfTable; i : integer; Size : integer; begin TrafficsList.Clear; FLibHandle := LoadLibrary(''''IPHLPAPI.DLL''''); if FLibHandle = 0 then Exit; @GetIfTable := GetProcAddress(FLibHandle, ''''GetIfTable''''); if not Assigned(GetIfTable) then begin FreeLibrary(FLibHandle); Exit; end; Size := SizeOf(Table); if GetIfTable(@Table, @Size, false ) = 0 then for i:= 0 to Table.dwNumEntries-1 do TrafficsList.AddObject(Table.Table[i].bDescr, TTraffic.Create(Table.Table[i])); FreeLibrary(FLibHandle); end;
function IntegerToTimeStr(Value: Integer): string; var d, h, m, s: Real; begin d := 0; h := 0; m := 0; s := Value; if s > 59 then begin m := int(s / 60); s := s - (m * 60); end; if m > 59 then begin h := int(m / 60); m := m - (h * 60); end; if h > 23 then begin d := int(h / 24); h := h - (d * 24); end; Result := ''''''''; if (d > 0) then Result := Result + floattostr(d) + '''' d. ''''; if (h < 9) then Result := Result + ''''0'''' + floattostr(h) + '''':'''' else Result := Result + floattostr(h) + '''':''''; if (m < 9) then Result := Result + ''''0'''' + floattostr(m) + '''':'''' else Result := Result + floattostr(m) + '''':''''; if (s < 9) then Result := Result + ''''0'''' + floattostr(s) else Result := Result + floattostr(s); end;
{ TSessionInfo50Obj }
constructor TSessionInfo50Obj.Create(SessionInfo50: TSessionInfo50); begin FSesi50_cname := SessionInfo50.Sesi50_cname; FSesi50_username := SessionInfo50.Sesi50_username;
end;
procedure TSessionInfo50Obj.SetSesi50_cname(const Value: WideString); begin FSesi50_cname := Value; end;
procedure TSessionInfo50Obj.Setsesi50_idle_time(const Value: Integer); begin Fsesi50_idle_time := Value; end;
procedure TSessionInfo50Obj.Setsesi50_num_opens(const Value: Integer); begin Fsesi50_num_opens := Value; end;
procedure TSessionInfo50Obj.Setsesi50_time(const Value: Integer); begin Fsesi50_time := Value; end;
procedure TSessionInfo50Obj.SetSesi50_username(const Value: WideString); begin FSesi50_username := Value; end;
{ TSessionInfo502Obj }
constructor TSessionInfo502Obj.Create(SessionInfo502: TSessionInfo502); begin FSesi502_cname := SessionInfo502.Sesi502_cname; FSesi502_username := SessionInfo502.Sesi502_username; FSesi502_num_opens := SessionInfo502.Sesi502_num_opens; FSesi502_Time := SessionInfo502.Sesi502_time; Fsesi502_idle_time := SessionInfo502.Sesi502_idle_time; end;
procedure TSessionInfo502Obj.SetSesi502_cname(const Value: WideString); begin FSesi502_cname := Value; end;
procedure TSessionInfo502Obj.Setsesi502_idle_time(const Value: DWord); begin Fsesi502_idle_time := Value; end;
procedure TSessionInfo502Obj.SetSesi502_num_opens(const Value: DWord); begin FSesi502_num_opens := Value; end;
procedure TSessionInfo502Obj.SetSesi502_Time(const Value: DWord); begin FSesi502_Time := Value; end;
procedure TSessionInfo502Obj.SetSesi502_username(const Value: WideString); begin FSesi502_username := Value; end;
{ TFileInfo3Obj }
constructor TFileInfo3Obj.Create(FileInfo3: TFileInfo3); begin Ffi3_id := FileInfo3.fi3_id; Ffi3_permissions := FileInfo3.fi3_permissions; Ffi3_num_locks := FileInfo3.fi3_num_locks; Ffi3_pathname := FileInfo3.fi3_pathname; Ffi3_username := FileInfo3.fi3_username; end;
procedure TFileInfo3Obj.Setfi3_id(const Value: DWord); begin Ffi3_id := Value; end;
procedure TFileInfo3Obj.Setfi3_num_locks(const Value: DWord); begin Ffi3_num_locks := Value; end;
procedure TFileInfo3Obj.Setfi3_pathname(const Value: WideString); begin Ffi3_pathname := Value; end;
procedure TFileInfo3Obj.Setfi3_permissions(const Value: DWord); begin Ffi3_permissions := Value; end;
procedure TFileInfo3Obj.Setfi3_username(const Value: WideString); begin Ffi3_username := Value; end;
{ TFileInfo50Obj }
constructor TFileInfo50Obj.Create(FileInfo50: TFileInfo50); begin Ffi50_id := FileInfo50.fi50_id; Ffi50_permissions := FileInfo50.fi50_permissions; Ffi50_num_locks := FileInfo50.fi50_num_locks; Ffi50_pathname := FileInfo50.fi50_pathname; Ffi50_username := FileInfo50.fi50_username; Ffi50_sharename := FileInfo50.fi50_sharename; end;
procedure TFileInfo50Obj.Setfi50_id(const Value: Integer); begin Ffi50_id := Value; end;
procedure TFileInfo50Obj.Setfi50_num_locks(const Value: WORD); begin Ffi50_num_locks := Value; end;
procedure TFileInfo50Obj.Setfi50_pathname(const Value: string); begin Ffi50_pathname := Value; end;
procedure TFileInfo50Obj.Setfi50_permissions(const Value: WORD); begin Ffi50_permissions := Value; end;
procedure TFileInfo50Obj.Setfi50_sharename(const Value: string); begin Ffi50_sharename := Value; end;
procedure TFileInfo50Obj.Setfi50_username(const Value: string); begin Ffi50_username := Value;
end;
{ TTraffic }
constructor TTraffic.Create(MibIfRow: TMibIfRow); begin FCaption := string(MibIfRow.bDescr); FMAC := GetMAC(TMAC(MibIfRow.bPhysAddr), MibIfRow.dwPhysAddrLen); FdwInOctets := MibIfRow.dwInOctets; FdwOutOctets := MibIfRow.dwOutOctets; end;
procedure TTraffic.SetCaption(const Value: string); begin FCaption := Value; end;
procedure TTraffic.SetdwInOctets(const Value: Integer); begin FdwInOctets := Value; end;
procedure TTraffic.SetdwOutOctets(const Value: Integer); begin FdwOutOctets := Value; end;
procedure TTraffic.SetMAC(const Value: string); begin FMAC := Value; end;
function TTraffic.GetMAC(Value: TMAC; Length: DWORD): string; var i: Integer; begin if Length = 0 then Result := ''''00-00-00-00-00-00'''' else begin Result := ''''''''; for i := 0 to Length - 2 do Result := Result + IntToHex(Value[i], 2) + ''''-''''; Result := Result + IntToHex(Value[Length - 1], 2); end; end;
{ TSessionInfo2Obj }
constructor TShareInfo2Obj.Create(ShareInfo2: TShareInfo2); begin Fshi2_netname := ShareInfo2.shi2_netname; Fshi2_path := ShareInfo2.shi2_path; end;
procedure TShareInfo2Obj.Setshi2_netname(const Value: string); begin Fshi2_netname := Value; end;
procedure TShareInfo2Obj.Setshi2_path(const Value: string); begin Fshi2_path := Value; end;
{ TShareInfo50Obj }
constructor TShareInfo50Obj.Create(ShareInfo50: TShareInfo50); begin Fshi50_netname := ShareInfo50.shi50_netname; Fshi50_path := ShareInfo50.shi50_path; end;
procedure TShareInfo50Obj.Setshi50_netname(const Value: string); begin Fshi50_netname := Value; end;
procedure TShareInfo50Obj.Setshi50_path(const Value: string); begin Fshi50_path := Value; end;
end.
unit NetSendUtils;
interface
uses Classes, Windows;
procedure GetNetGroupNameList(Names: TStrings); procedure GetComputerNameList(GroupName: string; Names: TStrings);
implementation
procedure GetNetGroupNameList(Names: TStrings); var lphEnum: THandle; Buf1, Buf2: Pointer; Count, BufSize, Res: DWORD; P: ^TNetResource; I, J: Integer; List: TList; NetResource: TNetResource; begin //获取整个网络中的文件资源的句柄,lphEnum为返回名柄 Res := WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_DISK, RESOURCEUSAGE_CONTAINER, nil, lphEnum); if Res <> NO_ERROR then Exit; //执行失败 //获取整个网络中的网络类型信息 Count := $FFFFFFFF; //不限资源数目 BufSize := 8192; //缓冲区大小设置为8K Get 上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >> 没有相关教程
|