Resolution to CreateIpForwardEntry failing on Vista

Previously, I had posted about a compatibility problem with Windows Vista if you used CreateIpForwardEntry to manage the IP routing table. In particular, if you call this routine on Vista with the intent to create a new route in the IP routing table, you may get an inexpicibly ERROR_BAD_ARGUMENTS error code returned.

There is an officially supported workaround, though it is not very well documented, and was in fact only recently made available in the Platform SDK documentation to my knowledge.

The official line is that you must call the GetIpInterfaceEntry function on Vista, if you wish to continue to be able to add routes.

(Yes, this does suck. It is a total breaking change for anyone who did route manipulation on OS’s prior to Vista, until you patch your programs out in the field. If this is unacceptable to you, I would encourage you to provide feedback to Microsoft about how this issue impacts customer experiences and your ability to deploy and use your product on Vista.)

I would encourage you to use this documented API instead of the undocumented solution that I posted about earlier, simply because it will (ostensibly) continue to work on future OS versions. (Although, given that the reason you have to call this is because of a breaking future-compatibility change in Vista, I am not sure that it is really justified to use that line here…)

3 Responses to “Resolution to CreateIpForwardEntry failing on Vista”

  1. MattyBoy says:

    I have succesfully added a route to Vista’s routing table with CreateIpForwardEntry. But it doesn’t work. The route is ignored. I use the metric returned by GetIpInterfaceEntry for the interface. “Route print” does show the correct route, but it doesn’t do anything. Has anyone else had this problem?

  2. Skywing says:

    Can you post your call to CreateIpForwardEntry and GetIpInterfaceEntry?

  3. […] a bit of googling, I found an explantion on http://www.nynaeve.net/?p=74 that pointed to a broken Vista API: Previously, I had posted about a compatibility problem with […]