打印本文 打印本文 关闭窗口 关闭窗口
网络小工具 ShareView
作者:武汉SEO闵涛  文章来源:敏韬网  点击数11009  更新时间:2009/4/23 18:28:24  文章录入:mintao  责任编辑:mintao

版权声明:

本文由Lyris完成,首发于CSDN,作者保留中文版权。
未经许可,不得使用于任何商业用途。
欢迎转载,但请保持文章及版权声明完整。
如需联络请发邮件:chenwentao@gmail.com


unit NetMonConsts;

interface

uses Windows;

type
  TShareInfo2 = packed record
    shi2_netname: PWChar;
    shi2_type: DWORD;
    shi2_remark: PWChar;
    shi2_permissions: DWORD;
    shi2_max_uses: DWORD;
    shi2_current_uses: DWORD;
    shi2_path: PWChar;
    shi2_passwd: PWChar;
  end;
  PShareInfo2 = ^TShareInfo2;
  TShareInfo2Array = array[0..512] of TShareInfo2;
  PShareInfo2Array = ^TShareInfo2Array;

type
  TShareInfo50 = packed record
    shi50_netname: array[0..12] of Char;
    shi50_type: Byte;
    shi50_flags: Word;
    shi50_remark: PChar;
    shi50_path: PChar;
    shi50_rw_password: array[0..8] of Char;
    shi50_ro_password: array[0..8] of Char;
  end;

type
  TSessionInfo502 = packed record
    Sesi502_cname: PWideChar;
    Sesi502_username: PWideChar;
    Sesi502_num_opens: DWORD;
    Sesi502_time: DWORD;
    Sesi502_idle_time: DWORD;
    Sesi502_user_flags: DWORD;
    Sesi502_cltype_name: PWideChar;
    Sesi502_transport: PWideChar;
  end;
  PSessionInfo502 = ^TSessionInfo502;
  TSessionInfo502Array = array[0..512] of TSessionInfo502;
  PSessionInfo502Array = ^TSessionInfo502Array;

type
  TSessionInfo50 = packed record
    Sesi50_cname: PChar;
    Sesi50_username: PChar;
    sesi50_key: Cardinal;
    sesi50_num_conns: Word;
    sesi50_num_opens: Word;
    sesi50_time: Cardinal;
    sesi50_idle_time: Cardinal;
    sesi50_protocol: Byte;
    pad1: Byte;
  end;

type
  TFileInfo3 = packed record
    fi3_id: DWORD;
    fi3_permissions: DWORD;
    fi3_num_locks: DWORD;
    fi3_pathname: PWChar;
    fi3_username: PWChar;
  end;
  PFileInfo3 = ^TFileInfo3;
  TFileInfo3Array = array[0..512] of TFileInfo3;
  PFileInfo3Array = ^TFileInfo3Array;

type
  TFileInfo50 = packed record
    fi50_id: Cardinal;
    fi50_permissions: WORD;
    fi50_num_locks: WORD;
    fi50_pathname: PChar;
    fi50_username: PChar;
    fi50_sharename: PChar;
  end;

type
  TMibIfRow = packed record
    wszName: array[0..255] of WideChar;
    dwIndex: DWORD;
    dwType: DWORD;
    dwMtu: DWORD;
    dwSpeed: DWORD;
    dwPhysAddrLen: DWORD;
    bPhysAddr: array[0..7] of Byte;
    dwAdminStatus: DWORD;
    dwOperStatus: DWORD;
    dwLastChange: DWORD;
    dwInOctets: DWORD;
    dwInUcastPkts: DWORD;
    dwInNUCastPkts: DWORD;
    dwInDiscards: DWORD;
    dwInErrors: DWORD;
    dwInUnknownProtos: DWORD;
    dwOutOctets: DWORD;
    dwOutUCastPkts: DWORD;
    dwOutNUCastPkts: DWORD;
    dwOutDiscards: DWORD;
    dwOutErrors: DWORD;
    dwOutQLen: DWORD;
    dwDescrLen: DWORD;
    bDescr: array[0..255] of Char;
  end;
  TMibIfArray = array[0..512] of TMibIfRow;
  PMibIfRow = ^TMibIfRow;
  PMibIfArray = ^TMibIfArray;

type
  TMibIfTable = packed record
    dwNumEntries: DWORD;
    Table: TMibIfArray;
  end;
  PMibIfTable = ^TMibIfTable;
var
  NetShareEnumNT: function(servername: PWChar;
    level: DWORD;
    bufptr: Pointer;
    prefmaxlen: DWORD;
    entriesread,
    totalentries,
    resume_handle: LPDWORD): DWORD; stdcall;

var
  NetShareEnum: function(pszServer: PChar;
    sLevel: Cardinal;
    pbBuffer: Pchar;
    cbBuffer: Cardinal;
    pcEntriesRead,
    pcTotalAvail: Pointer): DWORD; stdcall;

var
  NetShareDelNT: function(servername: PWideChar;
    netname: PWideChar;
    reserved: DWORD): LongInt; stdcall;

var
  NetShareDel: function(pszServer,
    pszNetName: PChar;
    usReserved: Word): DWORD; stdcall;

var
  NetShareAddNT: function(servername: PWideChar;
    level: DWORD;
    buf: Pointer;
    parm_err: LPDWORD): DWORD; stdcall;

var
  NetShareAdd: function(pszServer: Pchar;
    sLevel: Cardinal;
    pbBuffer: PChar;
    cbBuffer: Word): DWORD; stdcall;

var
  NetSessionEnumNT: function(servername,
    UncClientName,
    username: PWChar;
    level: DWORD;
    bufptr: Pointer;
    prefmaxlen: DWORD;
    entriesread,
    totalentries,
    resume_handle: LPDWORD): DWORD; stdcall;

var
  NetSessionEnum: function(pszServer: PChar;
    sLevel: DWORD;
    pbBuffer: Pointer;
    cbBuffer: DWORD;
    pcEntriesRead,
    pcTotalAvial: Pointer): integer; stdcall;

var
  NetSessionDelNT: function(ServerName,
    UncClientName,
    username: PWChar): DWORD; stdcall;

var
  NetSessionDel: function(pszServer: PChar;
    pszClientName: PChar;
    sReserved: SmallInt): DWORD; stdcall;

var
  NetFileEnumNT: function(servername,
    basepath,
    username: PWChar;
    level: DWORD;
    bufptr: Pointer;
    prefmaxlen: DWORD;
    entriesread,
    totalentries,
    resume_handle: LPDWORD): DWORD; stdcall;

var
  NetFileEnum: function(pszServer,
    pszBasePath: PChar;
    sLevel: DWORD;
    pbBuffer: Pointer;
    cbBuffer: DWORD;
    pcEntriesRead,
    pcTotalAvail: pointer): integer; stdcall;

var
  NetFileClose: function(ServerName: PWideChar;
    FileId: DWORD): DWORD; stdcall;

var
  NetFileClose2: function(pszServer: PChar;
    ulFileId: LongWord): DWORD; stdcall;

var
  GetIfTable: function(pIfTable: PMibIfTable;
    pdwSize: PULONG;
    bOrder: Boolean): DWORD; stdcall;

implementation

end.

unit NetMonUtils;

interface

uses Windows, Classes, NetMonConsts;

function IsNT(var Value: Boolean): Boolean;

procedure GetShares(SharesList: TStrings);
procedure CloseShare(ShareName: string);
procedure AddShare(ShareName, ShareDir: string);

procedure GetSessions(List: TStrings);
procedure CloseSession(SessionName: string);

procedure GetFiles(FilesList: TStrings);
procedure CloseFile(FileIndex: string);

procedure GetTrafficSets(TrafficsList: TStrings);

function IntegerToTimeStr(Value: Integer): string;

type
  TShareInfo2Obj = class
  private
    Fshi2_netname: string;
    Fshi2_path: string;
    procedure Setshi2_netname(const Value: string);
    procedure Setshi2_path(const Value: string);
  public
    constructor Create(ShareInfo2: TShareInfo2);
    property shi2_netname: string read Fshi2_netname write Setshi2_netname;
    property shi2_path: string read Fshi2_path write Setshi2_path;
  end;
  TShareInfo50Obj = class
  private
    Fshi50_netname: string;
    Fshi50_path: string;
    procedure Setshi50_netname(const Value: string);
    procedure Setshi50_path(const Value: string);
  public
    constructor Create(ShareInfo50: TShareInfo50);
    property shi50_netname: string read Fshi50_netname write Setshi50_netname;
    property shi50_path: string read Fshi50_path write Setshi50_path;
  end;
  TSessionInfo502Obj = class
  private
    FSesi502_Time: DWord;
    Fsesi502_idle_time: DWord;
    FSesi502_num_opens: DWord;
    FSesi502_cname: WideString;
    FSesi502_username: WideString;
    procedure SetSesi502_cname(const Value: WideStri

[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ...  下一页 >> 

打印本文 打印本文 关闭窗口 关闭窗口