delphi 能调API调设网卡MAC、IP、网关吗

解决方案 »

  1.   

    不能,MAC是固定的。网关也差不多,IP如果是动态分配会好一点,如果不是……
      

  2.   

    可以通过修改注册表来达到修改 MAC 地址.其他的可以通过 API 修改
      

  3.   

    利用iphlpapi.dll即可~~参考代码如下:const   
          iphlpapilib   =   iphlpapi.dll;   
        
      {$ifndef   iphlpapi_dynlink}   
        
      function   getnumberofinterfaces;   external   iphlpapilib   name   getnumberofinterfaces;   
      function   getifentry;   external   iphlpapilib   name   getifentry;   
      function   getiftable;   external   iphlpapilib   name   getiftable;   
      function   getipaddrtable;   external   iphlpapilib   name   getipaddrtable;   
      function   getipnettable;   external   iphlpapilib   name   getipnettable;   
      function   getipforwardtable;   external   iphlpapilib   name   getipforwardtable;   
      function   gettcptable;   external   iphlpapilib   name   gettcptable;   
      function   getudptable;   external   iphlpapilib   name   getudptable;   
      function   getipstatistics;   external   iphlpapilib   name   getipstatistics;   
      function   geticmpstatistics;   external   iphlpapilib   name   geticmpstatistics;   
      function   gettcpstatistics;   external   iphlpapilib   name   gettcpstatistics;   
      function   getudpstatistics;   external   iphlpapilib   name   getudpstatistics;   
      function   setifentry;   external   iphlpapilib   name   setifentry;   
      function   createipforwardentry;   external   iphlpapilib   name   createipforwardentry;   
      function   setipforwardentry;   external   iphlpapilib   name   setipforwardentry;   
      function   deleteipforwardentry;   external   iphlpapilib   name   deleteipforwardentry;   
      function   setipstatistics;   external   iphlpapilib   name   setipstatistics;   
      function   setipttl;   external   iphlpapilib   name   setipttl;   
      function   createipnetentry;   external   iphlpapilib   name   createipnetentry;   
      function   setipnetentry;   external   iphlpapilib   name   setipnetentry;   
      function   deleteipnetentry;   external   iphlpapilib   name   deleteipnetentry;   
      function   flushipnettable;   external   iphlpapilib   name   flushipnettable;   
      function   createproxyarpentry;   external   iphlpapilib   name   createproxyarpentry;   
      function   deleteproxyarpentry;   external   iphlpapilib   name   deleteproxyarpentry;   
      function   settcpentry;   external   iphlpapilib   name   settcpentry;   
      function   getinterfaceinfo;   external   iphlpapilib   name   getinterfaceinfo;   
      function   getunidirectionaladapterinfo;   external   iphlpapilib   name   getunidirectionaladapterinfo;   
      function   getbestinterface;   external   iphlpapilib   name   getbestinterface;   
      function   getbestroute;   external   iphlpapilib   name   getbestroute;   
      function   notifyaddrchange;   external   iphlpapilib   name   notifyaddrchange;   
      function   notifyroutechange;   external   iphlpapilib   name   notifyroutechange;   
      function   getadapterindex;   external   iphlpapilib   name   getadapterindex;   
      function   addipaddress;   external   iphlpapilib   name   addipaddress;   
      function   deleteipaddress;   external   iphlpapilib   name   deleteipaddress;   
      function   getnetworkparams;   external   iphlpapilib   name   getnetworkparams;   
      function   getadaptersinfo;   external   iphlpapilib   name   getadaptersinfo;   
      function   getperadapterinfo;   external   iphlpapilib   name   getperadapterinfo;   
      function   ipreleaseaddress;   external   iphlpapilib   name   ipreleaseaddress;   
      function   iprenewaddress;   external   iphlpapilib   name   iprenewaddress;   
      function   sendarp;   external   iphlpapilib   name   sendarp;   
      function   getrttandhopcount;   external   iphlpapilib   name   getrttandhopcount;   
      function   getfriendlyifindex;   external   iphlpapilib   name   getfriendlyifindex;   
      function   enablerouter;   external   iphlpapilib   name   enablerouter;   
      function   unenablerouter;   external   iphlpapilib   name   unenablerouter;   
        
      {$else}   
        
      var   
        hiphlpapi:   thandle   =   0;   
        
      function   iphlpapiinitapi:   boolean;   
      begin   
          result   :=   false;   
          if   hiphlpapi   =   0   then   hiphlpapi   :=   loadlibrary(iphlpapilib);   
          if   hiphlpapi   >   hinstance_error   then   
          begin   
              @getnetworkparams   :=   getprocaddress(hiphlpapi,   getnetworkparams);   
              @getadaptersinfo   :=   getprocaddress(hiphlpapi,   getadaptersinfo);   
              @getperadapterinfo   :=   getprocaddress(hiphlpapi,   getperadapterinfo);   
              @getadapterindex   :=   getprocaddress(hiphlpapi,   getadapterindex);   
              @getunidirectionaladapterinfo   :=   getprocaddress(hiphlpapi,   getunidirectionaladapterinfo);   
              @getnumberofinterfaces   :=   getprocaddress(hiphlpapi,   getnumberofinterfaces);   
              @getinterfaceinfo   :=   getprocaddress(hiphlpapi,   getinterfaceinfo);   
              @getfriendlyifindex   :=   getprocaddress(hiphlpapi,   getfriendlyifindex);   
              @getiftable   :=   getprocaddress(hiphlpapi,   getiftable);   
              @getifentry   :=   getprocaddress(hiphlpapi,   getifentry);   
              @setifentry   :=   getprocaddress(hiphlpapi,   setifentry);   
              @getipaddrtable   :=   getprocaddress(hiphlpapi,   getipaddrtable);   
              @addipaddress   :=   getprocaddress(hiphlpapi,   addipaddress);   
              @deleteipaddress   :=   getprocaddress(hiphlpapi,   deleteipaddress);   
              @ipreleaseaddress   :=   getprocaddress(hiphlpapi,   ipreleaseaddress);   
              @iprenewaddress   :=   getprocaddress(hiphlpapi,   iprenewaddress);   
              @getipnettable   :=   getprocaddress(hiphlpapi,   getipnettable);   
              @createipnetentry   :=   getprocaddress(hiphlpapi,   createipnetentry);   
              @deleteipnetentry   :=   getprocaddress(hiphlpapi,   deleteipnetentry);   
              @createproxyarpentry   :=   getprocaddress(hiphlpapi,   createproxyarpentry);   
              @deleteproxyarpentry   :=   getprocaddress(hiphlpapi,   deleteproxyarpentry);   
              @sendarp   :=   getprocaddress(hiphlpapi,   sendarp);   
              @getipstatistics   :=   getprocaddress(hiphlpapi,   getipstatistics);   
              @geticmpstatistics   :=   getprocaddress(hiphlpapi,   geticmpstatistics);   
              @setipstatistics   :=   getprocaddress(hiphlpapi,   setipstatistics);   
              @setipttl   :=   getprocaddress(hiphlpapi,   setipttl);   
              @getipforwardtable   :=   getprocaddress(hiphlpapi,getipforwardtable);   
              @createipforwardentry   :=   getprocaddress(hiphlpapi,   createipforwardentry);   
              @gettcptable   :=   getprocaddress(hiphlpapi,   gettcptable);   
              @getudptable   :=   getprocaddress(hiphlpapi,   getudptable);   
              @gettcpstatistics   :=   getprocaddress(hiphlpapi,   gettcpstatistics);   
              @getudpstatistics   :=   getprocaddress(hiphlpapi,   getudpstatistics);   
              @setipforwardentry   :=   getprocaddress(hiphlpapi,   setipforwardentry);   
              @deleteipforwardentry   :=   getprocaddress(hiphlpapi,   deleteipforwardentry);   
              @setipnetentry   :=   getprocaddress(hiphlpapi,   setipnetentry);   
              @settcpentry   :=   getprocaddress(hiphlpapi,   settcpentry);   
              @getbestroute   :=   getprocaddress(hiphlpapi,   getbestroute);   
              @notifyaddrchange   :=   getprocaddress(hiphlpapi,   notifyaddrchange);   
              @notifyroutechange   :=   getprocaddress(hiphlpapi,   notifyroutechange);   
              @getbestinterface   :=   getprocaddress(hiphlpapi,   getbestinterface);   
              @getrttandhopcount   :=   getprocaddress(hiphlpapi,   getrttandhopcount);   
              @enablerouter   :=   getprocaddress(hiphlpapi,   enablerouter);   
              @unenablerouter   :=   getprocaddress(hiphlpapi,   unenablerouter);   
              result   :=   true;   
          end;   
      end;   
        
      procedure   iphlpapifreeapi;   
      begin   
          if   hiphlpapi   <>   0   then   freelibrary(hiphlpapi);   
          hiphlpapi   :=   0;   
      end;   
      

  4.   

    楼上有点看不懂,上面有可改的mac吗
      

  5.   

    谁能具体说一下iphelper中一些函数的调用??