ng); procedure Setsesi502_idle_time(const Value: DWord); procedure SetSesi502_num_opens(const Value: DWord); procedure SetSesi502_Time(const Value: DWord); procedure SetSesi502_username(const Value: WideString); public constructor Create(SessionInfo502: TSessionInfo502); property Sesi502_cname: WideString read FSesi502_cname write SetSesi502_cname; property Sesi502_username: WideString read FSesi502_username write SetSesi502_username; property Sesi502_num_opens: DWord read FSesi502_num_opens write SetSesi502_num_opens; property Sesi502_Time: DWord read FSesi502_Time write SetSesi502_Time; property sesi502_idle_time: DWord read Fsesi502_idle_time write Setsesi502_idle_time; end;
TSessionInfo50Obj = class private Fsesi50_num_opens: Integer; Fsesi50_time: Integer; Fsesi50_idle_time: Integer; FSesi50_cname: WideString; FSesi50_username: WideString; procedure SetSesi50_cname(const Value: WideString); procedure Setsesi50_idle_time(const Value: Integer); procedure Setsesi50_num_opens(const Value: Integer); procedure Setsesi50_time(const Value: Integer); procedure SetSesi50_username(const Value: WideString); public constructor Create(SessionInfo50: TSessionInfo50); property Sesi50_cname: WideString read FSesi50_cname write SetSesi50_cname; property Sesi50_username: WideString read FSesi50_username write SetSesi50_username; property sesi50_num_opens: Integer read Fsesi50_num_opens write Setsesi50_num_opens; property sesi50_time: Integer read Fsesi50_time write Setsesi50_time; property sesi50_idle_time: Integer read Fsesi50_idle_time write Setsesi50_idle_time; end;
TFileInfo3Obj = class private Ffi3_permissions: DWord; Ffi3_num_locks: DWord; Ffi3_id: DWord; Ffi3_pathname: WideString; Ffi3_username: WideString; procedure Setfi3_id(const Value: DWord); procedure Setfi3_num_locks(const Value: DWord); procedure Setfi3_pathname(const Value: WideString); procedure Setfi3_permissions(const Value: DWord); procedure Setfi3_username(const Value: WideString); public constructor Create(FileInfo3: TFileInfo3); property fi3_id: DWord read Ffi3_id write Setfi3_id; property fi3_permissions: DWord read Ffi3_permissions write Setfi3_permissions; property fi3_num_locks: DWord read Ffi3_num_locks write Setfi3_num_locks; property fi3_pathname: WideString read Ffi3_pathname write Setfi3_pathname; property fi3_username: WideString read Ffi3_username write Setfi3_username; end;
type TFileInfo50Obj = class private Ffi50_id: Integer; Ffi50_pathname: string; Ffi50_username: string; Ffi50_sharename: string; Ffi50_permissions: WORD; Ffi50_num_locks: WORD; procedure Setfi50_id(const Value: Integer); procedure Setfi50_num_locks(const Value: WORD); procedure Setfi50_pathname(const Value: string); procedure Setfi50_permissions(const Value: WORD); procedure Setfi50_sharename(const Value: string); procedure Setfi50_username(const Value: string); public constructor Create(FileInfo50: TFileInfo50); property fi50_id: Integer read Ffi50_id write Setfi50_id; property fi50_permissions: WORD read Ffi50_permissions write Setfi50_permissions; property fi50_num_locks: WORD read Ffi50_num_locks write Setfi50_num_locks; property fi50_pathname: string read Ffi50_pathname write Setfi50_pathname; property fi50_username: string read Ffi50_username write Setfi50_username; property fi50_sharename: string read Ffi50_sharename write Setfi50_sharename; end; type TMAC = array[0..7] of Byte; TTraffic = class private FMAC: string; FdwOutOctets: Integer; FdwInOctets: Integer; FCaption: string; procedure SetCaption(const Value: string); procedure SetdwInOctets(const Value: Integer); procedure SetdwOutOctets(const Value: Integer); procedure SetMAC(const Value: string); function GetMAC(Value: TMAC; Length: DWORD): string; public constructor Create(MibIfRow: TMibIfRow); property Caption: string read FCaption write SetCaption; property MAC: string read FMAC write SetMAC; property dwInOctets: Integer read FdwInOctets write SetdwInOctets; property dwOutOctets: Integer read FdwOutOctets write SetdwOutOctets; end;
implementation
uses SysUtils;
function IsNT(var Value: Boolean): Boolean; var Ver: TOSVersionInfo; BRes: Boolean; begin Ver.dwOSVersionInfoSize := SizeOf(TOSVersionInfo); BRes := GetVersionEx(Ver); if not BRes then begin Result := False; Exit; end else Result := True;
case Ver.dwPlatformId of VER_PLATFORM_WIN32_NT: Value := True; VER_PLATFORM_WIN32_WINDOWS: Value := False; VER_PLATFORM_WIN32s: Result := False end; end;
procedure GetShares(SharesList: TStrings); var i: Integer; FLibHandle: THandle; ShareNT: PShareInfo2Array; entriesread, totalentries: DWORD; //<= Win NT Share: array[0..512] of TShareInfo50; pcEntriesRead, pcTotalAvail: Word; //<= Windows 9x-Me OS: Boolean; begin if not IsNT(OS) then Exit; if OS then begin FLibHandle := LoadLibrary(''''NETAPI32.DLL''''); if FLibHandle = 0 then Exit; @NetShareEnumNT := GetProcAddress(FLibHandle, ''''NetShareEnum''''); if not Assigned(NetShareEnumNT) then begin FreeLibrary(FLibHandle); Exit; end; ShareNT := nil; if NetShareEnumNT(nil, 2, @ShareNT, DWORD(-1), @entriesread, @totalentries, nil) <> 0 then begin FreeLibrary(FLibHandle); Exit; end; if entriesread > 0 then for i := 0 to entriesread - 1 do SharesList.AddObject(string(ShareNT^[i].shi2_netname), TShareInfo2Obj.Create(ShareNT^[i])); end else begin FLibHandle := LoadLibrary(''''SVRAPI.DLL''''); if FLibHandle = 0 then Exit; @NetShareEnum := GetProcAddress(FLibHandle, ''''NetShareEnum''''); if not Assigned(NetShareEnum) then FreeLibrary(FLibHandle); Exit; if NetShareEnum(nil, 50, @Share, SizeOf(Share), @pcEntriesRead, @pcTotalAvail) <> 0 then begin FreeLibrary(FLibHandle); Exit; end; if pcEntriesRead > 0 then for i := 0 to pcEntriesRead - 1 do SharesList.AddObject(string(Share[i].shi50_netname), TShareInfo50Obj.Create(Share[i])); end; FreeLibrary(FLibHandle); end;
procedure CloseShare(ShareName: string); var OS: Boolean; FLibHandle: THandle; Name9x: array[0..12] of Char; NameNT: PWChar; i: Integer; begin if not IsNT(OS) then Exit;
if OS then begin FLibHandle := LoadLibrary(''''NETAPI32.DLL''''); if FLibHandle = 0 then Exit; @NetShareDelNT := GetProcAddress(FLibHandle, ''''NetShareDel''''); if not Assigned(NetShareDelNT) then begin FreeLibrary(FLibHandle); Exit; end; i := SizeOf(WideChar) * 256; GetMem(NameNT, i); StringToWideChar(ShareName, NameNT, i); NetShareDelNT(nil, NameNT, 0); FreeMem(NameNT); end else begin FLibHandle 上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >> 没有相关教程
|