各位大家好,按照网上的所能查到的资料,小的已经注册SystemIinfo.dll(c#编写),然后得到得到一个SystemInfo.tlb的文件,并在delphi里create unit成为SystemInfo_Tlb.pas文件。
在C#程序里面(SystemInfo工程中)有:
namespace CurrentSystemInfo
{
    /// <summary>
    /// 系统信息类 - 获取CPU、内存、磁盘、进程信息
    /// </summary>
    public class SystemInfo
    {
       ............................
       ............................      public static List<NetInfo> GetNetInfoByType(NetType nettype)
        {
            //定义范型
            List<NetInfo> ninfos = new List<NetInfo>();            //定义,获取 MIB_IFTABLE 对象
            MIB_IFTABLE tbl = GetAllIfTable();            //如果成功
            if (tbl != null)
            {
                tbl.Deserialize();
                for (int i = 0; i < tbl.Table.Length; i++)
                {
                    NetInfo ninfo = GetNetInfo(tbl.Table[i]);
                    if (ninfo.Type == nettype)
                    {
                        ninfos.Add(ninfo);
                    }
                }
            }            return ninfos;
        } 
        #endregion        #region 获取指定物理地址的网络信息
        /// <summary>
        /// 获取指定物理地址的网络信息
        /// </summary>
        /// <param name="MACAddress">物理地址</param>
        /// <returns>NetInfo 网络信息范型</returns>
        public static NetInfo GetNetInfoByMac(string MACAddress)
        {
            //定义,获取 MIB_IFTABLE 对象
            MIB_IFTABLE tbl = GetAllIfTable();            //如果成功
            if (tbl != null)
            {
                tbl.Deserialize();
                for (int i = 0; i < tbl.Table.Length; i++)
                {
                    NetInfo ninfo = GetNetInfo(tbl.Table[i]);
                    if (string.Compare(MACAddress, ninfo.PhysAddr, true) == 0)
                    {
                        return ninfo;
                    }
                }
            }            return null;
        } 
        #endregion        #region 获取指定 ip 地址的网络信息
        /// <summary>
        /// 获取指定 ip 地址的网络信息
        /// </summary>
        /// <param name="IPAddress">ip 地址</param>
        /// <returns>NetInfo 网络信息范型</returns>
        public static NetInfo GetNetInfoByIp(string IPAddress)
        {
            string MACAddress = GetMacByIp(IPAddress);
            if (string.IsNullOrEmpty(MACAddress))
            {
                return null;
            }
            else
            {
                return GetNetInfoByMac(MACAddress);
        private static NetInfo GetNetInfo(MIB_IFROW row) //网卡信息,流量
        {
            NetInfo ninfo = new NetInfo();
            ninfo.Index = row.dwIndex;
            //ninfo.Name = Encoding.ASCII.GetString(row.bDescr, 0, (int)row.dwDescrLen);
            ninfo.Name = Encoding.GetEncoding("gb2312").GetString(row.bDescr, 0, (int)row.dwDescrLen);
            ninfo.PhysAddr = GetPhysAddr(row.bPhysAddr, (int)row.dwPhysAddrLen);
            ninfo.Type = (NetType)row.dwType;
            ninfo.Status = (NetState)row.dwOperStatus;
            ninfo.Speed = row.dwSpeed;
            ninfo.InErrors = row.dwInErrors;
            ninfo.InOctets = row.dwInOctets;
            ninfo.InUnknownProtos = row.dwInUnknownProtos;
            ninfo.OutErrors = row.dwOutErrors;
            ninfo.OutOctets = row.dwOutOctets;
            return ninfo;
        }
        ..............................
        ..............................
}我想在delphi里面获取网卡的流出和流入量,手头和网上也没查到什么资料,弄了快一周了,实在不知道怎么解决,看有没有会的牛人给指点一下怎么调用,本人分数不多,愿全部奉上,以表感谢。
SystemInfo_tlb.pas里面:const
  // TypeLibrary Major and minor versions
  SystemInfoMajorVersion = 1;
  SystemInfoMinorVersion = 0;  LIBID_SystemInfo: TGUID = '{89B8B129-92A6-4426-8583-D972696A2896}';    IID__IpInfo: TGUID = '{6E2ADA9F-F4C0-3CCB-8A41-92572A227ED0}';
    IID__SystemInfo: TGUID = '{848F3880-E5FE-301B-A824-7479E020304B}';
  IID__MarshallingMethods: TGUID = '{0881207F-DD1F-3568-804F-3CB05AC21688}';
  IID__CustomMarshalAsAttribute: TGUID = '{6AA2196F-0FDF-361D-A110-20B03BB4DB92}';
  IID__NetInfo: TGUID = '{843369FE-A608-37DF-AB6E-D5999018BAF2}';
  CLASS_MIB_IFTABLE: TGUID = '{3A387FE2-1B6D-3BA8-ACD1-96E2B785CFF1}';
  CLASS_IpInfo: TGUID = '{189F802B-524F-32C4-B932-4305A13ACEF6}';
  CLASS_DiskInfo: TGUID = '{DF46AE84-4729-345A-A3FA-68DA449D5EAD}';
  CLASS_SystemInfo_: TGUID = '{55DCAF9C-7A27-3D30-9197-32CC6F2A9D59}';
  CLASS_MarshallingMethods: TGUID = '{ED8686C8-41F7-3890-A5B3-8F82CE4CF1DE}';
  CLASS_CustomMarshalAsAttribute: TGUID = '{6D34F011-137E-3E96-AA16-8F6C537053D0}';
  CLASS_NetInfo: TGUID = '{3422C7A0-12B0-34A8-94B3-BAA89C5386FB}';
...........
...........
type// *********************************************************************//
// Forward declaration of types defined in TypeLibrary                    
// *********************************************************************//
  _CustomMarshaler = interface;
  _CustomMarshalerDisp = dispinterface;
  _MIB_IFTABLE = interface;
  _MIB_IFTABLEDisp = dispinterface;
  _ProcessInfo = interface;
  _ProcessInfoDisp = dispinterface;
  _IpInfo = interface;
  _IpInfoDisp = dispinterface;
  _DiskInfo = interface;
  _DiskInfoDisp = dispinterface;
  _SystemInfo = interface;
  _SystemInfoDisp = dispinterface;
  _MarshallingMethods = interface;
  _MarshallingMethodsDisp = dispinterface;
  _CustomMarshalAsAttribute = interface;
  _CustomMarshalAsAttributeDisp = dispinterface;
  _NetInfo = interface;
  _NetInfoDisp = dispinterface;
  _MIB_IFROW = interface;
  _MIB_IFROWDisp = dispinterface;// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
  CustomMarshaler = _CustomMarshaler;
  MIB_IFTABLE = _MIB_IFTABLE;
  ProcessInfo = _ProcessInfo;
  IpInfo = _IpInfo;
  DiskInfo = _DiskInfo;
  SystemInfo_ = _SystemInfo;
  MarshallingMethods = _MarshallingMethods;
  CustomMarshalAsAttribute = _CustomMarshalAsAttribute;
  NetInfo = _NetInfo;
  MIB_IFROW = _MIB_IFROW;
..........
..........
// *********************************************************************//
// Interface: _NetInfo
// Flags:     (4432) Hidden Dual OleAutomation Dispatchable
// GUID:      {843369FE-A608-37DF-AB6E-D5999018BAF2}
// *********************************************************************//
  _NetInfo = interface(IDispatch)
    ['{843369FE-A608-37DF-AB6E-D5999018BAF2}']
  end;// *********************************************************************//
// DispIntf:  _NetInfoDisp
// Flags:     (4432) Hidden Dual OleAutomation Dispatchable
// GUID:      {843369FE-A608-37DF-AB6E-D5999018BAF2}
// *********************************************************************//
  _NetInfoDisp = dispinterface
    ['{843369FE-A608-37DF-AB6E-D5999018BAF2}']
  end;
............
............
// *********************************************************************//
// The Class CoSystemInfo_ provides a Create and CreateRemote method to          
// create instances of the default interface _SystemInfo exposed by              
// the CoClass SystemInfo_. The functions are intended to be used by             
// clients wishing to automate the CoClass objects exposed by the         
// server of this typelibrary.                                            
// *********************************************************************//
  CoSystemInfo_ = class
    class function Create: _SystemInfo;
    class function CreateRemote(const MachineName: string): _SystemInfo;
  end;// *********************************************************************//
// The Class CoNetInfo provides a Create and CreateRemote method to          
// create instances of the default interface _NetInfo exposed by              
// the CoClass NetInfo. The functions are intended to be used by             
// clients wishing to automate the CoClass objects exposed by the         
// server of this typelibrary.                                            
// *********************************************************************//
  CoNetInfo = class
    class function Create: _NetInfo;
    class function CreateRemote(const MachineName: string): _NetInfo;
  end;
............
............
class function CoSystemInfo_.Create: _SystemInfo;
begin
  Result := CreateComObject(CLASS_SystemInfo_) as _SystemInfo;
end;class function CoSystemInfo_.CreateRemote(const MachineName: string): _SystemInfo;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_SystemInfo_) as _SystemInfo;
end;class function CoNetInfo.Create: _NetInfo;
begin
  Result := CreateComObject(CLASS_NetInfo) as _NetInfo;
end;class function CoNetInfo.CreateRemote(const MachineName: string): _NetInfo;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_NetInfo) as _NetInfo;
end;.....
end.