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;