在pptp连接上之后,怎么在VC里用代码来添加路由,根据选择不同的服务器连接pptp的时候,命令route add 119.147.20.0 mask 255.255.255.0  10.15.100.1里面的10.15.100.1是变化的,我们通过什么函数来得到的,并写在route add 119.147.20.0 mask 255.255.255.0  10.15.100.1,若要添加多条路由怎么实现

解决方案 »

  1.   

    使用CreateIpForwardEntry添加新的路由表,  
      使用DeleteIpForwardEntry删除路由表,  
      使用SetIpForwardEntry修改路由表。
    MSDN:
    Platform SDK: Internet Protocol Helper 
    CreateIpForwardEntry
    The CreateIpForwardEntry function creates a route in the local computer's IP routing table.DWORD CreateIpForwardEntry( 
      PMIB_IPFORWARDROW pRoute  // pointer to route information
    );
    Parameters
    pRoute 
    [in] Pointer to a MIB_IPFORWARDROW structure that specifies the information for the new route. The caller must specify values for all members of this structure. The caller must specify PROTO_IP_NETMGMT for the dwForwardProto member of MIB_IPFORWARDROW. 
    Return Values
    If the function succeeds, the return value is NO_ERROR.If the function fails, the return value is one of the following error codes.Value Meaning 
    ERROR_INVALID_PARAMETER The pRoute parameter is NULL, SetIpFowardEntry is unable to read from the memory pointed to by pRoute, or one of the members of the MIB_IPFORWARDROW structure is invalid. 
    ERROR_NOT_SUPPORTED The IP transport is not configured on the local computer. 
    Other Use FormatMessage to obtain the message string for the returned error. 
    Res
    To modify an existing route in the IP routing table, use the SetIpForwardEntry function.The caller should not specify a routing protocol, for example, PROTO_IP_OSPF, for the dwForwardProto member of the MIB_IPFORWARDROW structure. Routing protocol identifiers are used only to identify route information received through the specified routing protocol. For example, PROTO_IP_OSPF is used only to identify route information received through the OSPF routing protocol.The dwForwardPolicy member of the MIB_IPFORWARDROW structure is currently unused. The caller should specify zero for this member.The dwForwardAge member of the MIB_IPFORWARDROW structure is used only if the Routing and Remote Access Service (RRAS) is running, and then only for routes of type PROTO_IP_NETMGMT.Requirements 
      Windows NT/2000/XP: Included in Windows NT 4.0 SP4; Windows 2000; Windows XP Pro; and Windows .NET Server.
      Windows 95/98/Me: Included in Windows 98 and later.
      Header: Declared in Iphlpapi.h.
      Library: Use Iphlpapi.lib.
      

  2.   

    我是用ras.h里面的 函数创建的PPTP连接,那么ras.h里面有没有相关的函数能够获得这个vpn客户端IP地址的啊
    大家帮帮忙
      

  3.   

    获取机器ip不一定要用ras的方法,ipconfig等就可以打印当前所有的客户端ip地址
      

  4.   

    我也碰到类似问题,尝试下来只能在之前的默认接口下改变路由表,没找出在vpn拨入后给vpn连接增加路由表