diff --git a/configure b/configure
index 9048b943f7274e3670779c3572667c3050048cce..b95800e0190f328a832fd72876e93469d4c9605b 100755
--- a/configure
+++ b/configure
@@ -18962,7 +18962,7 @@ MAKE_LIB_RULES=libs/Makelib.rules
 MAKE_PROG_RULES=programs/Makeprog.rules
 
 
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/capi2032/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/ctl3d/Makefile dlls/wined3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3dim/Makefile dlls/d3dx8/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/icmp/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/msi/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrtd/Makefile dlls/msvideo/Makefile dlls/msvideo/msrle32/Makefile dlls/mswsock/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/sti/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/uxtheme/Makefile dlls/version/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winenas/Makefile dlls/winmm/winejack/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/uuid/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile"
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/capi2032/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/ctl3d/Makefile dlls/wined3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3dim/Makefile dlls/d3dx8/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/icmp/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/msi/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrtd/Makefile dlls/msvideo/Makefile dlls/msvideo/msrle32/Makefile dlls/mswsock/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/sti/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/uxtheme/Makefile dlls/version/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winenas/Makefile dlls/winmm/winejack/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/uuid/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile"
 
 
 cat >confcache <<\_ACEOF
@@ -19547,6 +19547,7 @@ do
   "dlls/imagehlp/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/imagehlp/Makefile" ;;
   "dlls/imm32/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/imm32/Makefile" ;;
   "dlls/iphlpapi/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/iphlpapi/Makefile" ;;
+  "dlls/iphlpapi/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/iphlpapi/tests/Makefile" ;;
   "dlls/kernel/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/kernel/Makefile" ;;
   "dlls/kernel/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/kernel/tests/Makefile" ;;
   "dlls/lzexpand/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/lzexpand/Makefile" ;;
diff --git a/configure.ac b/configure.ac
index 066cf7ca56f719eaa85408e4bcdc96de90611e06..161211eb8c38f0d6dc9baccda054006fd9ed4189 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1515,6 +1515,7 @@ dlls/icmp/Makefile
 dlls/imagehlp/Makefile
 dlls/imm32/Makefile
 dlls/iphlpapi/Makefile
+dlls/iphlpapi/tests/Makefile
 dlls/kernel/Makefile
 dlls/kernel/tests/Makefile
 dlls/lzexpand/Makefile
diff --git a/dlls/iphlpapi/Makefile.in b/dlls/iphlpapi/Makefile.in
index ca9fd76506c923dd008add54a66e006695ffb7f5..18bc68a5a35f267c8a4aaba9f2ce0c6d97aba43d 100644
--- a/dlls/iphlpapi/Makefile.in
+++ b/dlls/iphlpapi/Makefile.in
@@ -10,6 +10,8 @@ C_SRCS = \
 	iphlpapi_main.c \
 	ipstats.c
 
+SUBDIRS = tests
+
 @MAKE_DLL_RULES@
 
 ### Dependencies:
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index b136d4a380757b7900fbef3afa6d0a3f1e34aaa8..fee533c9fa4ce7c663afa7cae6eaf27d206c06fd 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -602,7 +602,7 @@ DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
 
             memset(pAdapterInfo, 0, size);
             if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
-             "\\Software\\Wine\\Wine\\Config\\Network", 0, KEY_READ,
+             "Software\\Wine\\Wine\\Config\\Network", 0, KEY_READ,
              &hKey) == ERROR_SUCCESS) {
               DWORD size = sizeof(primaryWINS.String);
               unsigned long addr;
@@ -1042,7 +1042,7 @@ DWORD WINAPI GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, BOOL
           ret = ERROR_INSUFFICIENT_BUFFER;
         }
         else {
-          DWORD ndx;
+          DWORD ndx, bcast;
 
           pIpAddrTable->dwNumEntries = 0;
           for (ndx = 0; ndx < table->numIndexes; ndx++) {
@@ -1051,8 +1051,13 @@ DWORD WINAPI GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, BOOL
              getInterfaceIPAddrByIndex(table->indexes[ndx]);
             pIpAddrTable->table[ndx].dwMask =
              getInterfaceMaskByIndex(table->indexes[ndx]);
+            /* the dwBCastAddr member isn't the broadcast address, it indicates
+             * whether the interface uses the 1's broadcast address (1) or the
+             * 0's broadcast address (0).
+             */
+            bcast = getInterfaceBCastAddrByIndex(table->indexes[ndx]);
             pIpAddrTable->table[ndx].dwBCastAddr =
-             getInterfaceBCastAddrByIndex(table->indexes[ndx]);
+             (bcast & pIpAddrTable->table[ndx].dwMask) ? 1 : 0;
             /* FIXME: hardcoded reasm size, not sure where to get it */
             pIpAddrTable->table[ndx].dwReasmSize = 65535;
             pIpAddrTable->table[ndx].unused1 = 0;
diff --git a/dlls/iphlpapi/tests/.cvsignore b/dlls/iphlpapi/tests/.cvsignore
new file mode 100644
index 0000000000000000000000000000000000000000..8c55ad91551316e52579c01803e7689649adf6b3
--- /dev/null
+++ b/dlls/iphlpapi/tests/.cvsignore
@@ -0,0 +1,4 @@
+Makefile
+iphlpapi.ok
+iphlpapi_test.exe.spec.c
+testlist.c
diff --git a/dlls/iphlpapi/tests/Makefile.in b/dlls/iphlpapi/tests/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..0f1b423006fb8bc4fd7cbd20d0c6ffa24be91f40
--- /dev/null
+++ b/dlls/iphlpapi/tests/Makefile.in
@@ -0,0 +1,13 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+TESTDLL   = iphlpapi.dll
+IMPORTS   = iphlpapi
+
+CTESTS = \
+	iphlpapi.c
+
+@MAKE_TEST_RULES@
+
+### Dependencies:
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c
new file mode 100644
index 0000000000000000000000000000000000000000..fddeece973957080d398e0688b0c656a6db33326
--- /dev/null
+++ b/dlls/iphlpapi/tests/iphlpapi.c
@@ -0,0 +1,607 @@
+/*
+ * iphlpapi dll test
+ *
+ * Copyright (C) 2003 Juan Lang
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/*
+ * Some observations that an automated test can't produce:
+ * An adapter index is a key for an adapter.  That is, if an index is returned
+ * from one API, that same index may be used successfully in another API, as
+ * long as the adapter remains present.
+ * If the adapter is removed and reinserted, however, the index may change (and
+ * indeed it does change on Win2K).
+ *
+ * The Name field of the IP_ADAPTER_INDEX_MAP entries returned by
+ * GetInterfaceInfo is declared as a wide string, but the bytes are actually
+ * an ASCII string on some versions of the IP helper API under Win9x.  This was
+ * apparently an MS bug, it's corrected in later versions.
+ *
+ * The DomainName field of FIXED_INFO isn't NULL-terminated on Win98.
+ */
+
+#include <stdarg.h>
+#include "windef.h"
+#include "winbase.h"
+#include "iphlpapi.h"
+#include "iprtrmib.h"
+#include "wine/test.h"
+#include <sys/types.h>
+#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static HMODULE hLibrary = NULL;
+
+typedef DWORD (WINAPI *GetNumberOfInterfacesFunc)(PDWORD);
+typedef DWORD (WINAPI *GetIpAddrTableFunc)(PMIB_IPADDRTABLE,PULONG,BOOL);
+typedef DWORD (WINAPI *GetIfEntryFunc)(PMIB_IFROW);
+typedef DWORD (WINAPI *GetFriendlyIfIndexFunc)(DWORD);
+typedef DWORD (WINAPI *GetIfTableFunc)(PMIB_IFTABLE,PULONG,BOOL);
+typedef DWORD (WINAPI *GetIpForwardTableFunc)(PMIB_IPFORWARDTABLE,PULONG,BOOL);
+typedef DWORD (WINAPI *GetIpNetTableFunc)(PMIB_IPNETTABLE,PULONG,BOOL);
+typedef DWORD (WINAPI *GetInterfaceInfoFunc)(PIP_INTERFACE_INFO,PULONG);
+typedef DWORD (WINAPI *GetAdaptersInfoFunc)(PIP_ADAPTER_INFO,PULONG);
+typedef DWORD (WINAPI *GetNetworkParamsFunc)(PFIXED_INFO,PULONG);
+typedef DWORD (WINAPI *GetIcmpStatisticsFunc)(PMIB_ICMP);
+typedef DWORD (WINAPI *GetIpStatisticsFunc)(PMIB_IPSTATS);
+typedef DWORD (WINAPI *GetTcpStatisticsFunc)(PMIB_TCPSTATS);
+typedef DWORD (WINAPI *GetUdpStatisticsFunc)(PMIB_UDPSTATS);
+typedef DWORD (WINAPI *GetTcpTableFunc)(PMIB_TCPTABLE,PDWORD,BOOL);
+typedef DWORD (WINAPI *GetUdpTableFunc)(PMIB_UDPTABLE,PDWORD,BOOL);
+
+static GetNumberOfInterfacesFunc gGetNumberOfInterfaces = NULL;
+static GetIpAddrTableFunc gGetIpAddrTable = NULL;
+static GetIfEntryFunc gGetIfEntry = NULL;
+static GetFriendlyIfIndexFunc gGetFriendlyIfIndex = NULL;
+static GetIfTableFunc gGetIfTable = NULL;
+static GetIpForwardTableFunc gGetIpForwardTable = NULL;
+static GetIpNetTableFunc gGetIpNetTable = NULL;
+static GetInterfaceInfoFunc gGetInterfaceInfo = NULL;
+static GetAdaptersInfoFunc gGetAdaptersInfo = NULL;
+static GetNetworkParamsFunc gGetNetworkParams = NULL;
+static GetIcmpStatisticsFunc gGetIcmpStatistics = NULL;
+static GetIpStatisticsFunc gGetIpStatistics = NULL;
+static GetTcpStatisticsFunc gGetTcpStatistics = NULL;
+static GetUdpStatisticsFunc gGetUdpStatistics = NULL;
+static GetTcpTableFunc gGetTcpTable = NULL;
+static GetUdpTableFunc gGetUdpTable = NULL;
+
+static void loadIPHlpApi(void)
+{
+  hLibrary = LoadLibraryA("iphlpapi.dll");
+  if (hLibrary) {
+    gGetNumberOfInterfaces = (GetNumberOfInterfacesFunc)GetProcAddress(
+     hLibrary, "GetNumberOfInterfaces");
+    gGetIpAddrTable = (GetIpAddrTableFunc)GetProcAddress(
+     hLibrary, "GetIpAddrTable");
+    gGetIfEntry = (GetIfEntryFunc)GetProcAddress(
+     hLibrary, "GetIfEntry");
+    gGetFriendlyIfIndex = (GetFriendlyIfIndexFunc)GetProcAddress(
+     hLibrary, "GetFriendlyIfIndex");
+    gGetIfTable = (GetIfTableFunc)GetProcAddress(
+     hLibrary, "GetIfTable");
+    gGetIpForwardTable = (GetIpForwardTableFunc)GetProcAddress(
+     hLibrary, "GetIpForwardTable");
+    gGetIpNetTable = (GetIpNetTableFunc)GetProcAddress(
+     hLibrary, "GetIpNetTable");
+    gGetInterfaceInfo = (GetInterfaceInfoFunc)GetProcAddress(
+     hLibrary, "GetInterfaceInfo");
+    gGetAdaptersInfo = (GetAdaptersInfoFunc)GetProcAddress(
+     hLibrary, "GetAdaptersInfo");
+    gGetNetworkParams = (GetNetworkParamsFunc)GetProcAddress(
+     hLibrary, "GetNetworkParams");
+    gGetIcmpStatistics = (GetIcmpStatisticsFunc)GetProcAddress(
+     hLibrary, "GetIcmpStatistics");
+    gGetIpStatistics = (GetIpStatisticsFunc)GetProcAddress(
+     hLibrary, "GetIpStatistics");
+    gGetTcpStatistics = (GetTcpStatisticsFunc)GetProcAddress(
+     hLibrary, "GetTcpStatistics");
+    gGetUdpStatistics = (GetUdpStatisticsFunc)GetProcAddress(
+     hLibrary, "GetUdpStatistics");
+    gGetTcpTable = (GetTcpTableFunc)GetProcAddress(
+     hLibrary, "GetTcpTable");
+    gGetUdpTable = (GetUdpTableFunc)GetProcAddress(
+     hLibrary, "GetUdpTable");
+  }
+}
+
+static void freeIPHlpApi(void)
+{
+  if (hLibrary) {
+    gGetNumberOfInterfaces = NULL;
+    gGetIpAddrTable = NULL;
+    gGetIfEntry = NULL;
+    gGetFriendlyIfIndex = NULL;
+    gGetIfTable = NULL;
+    gGetIpForwardTable = NULL;
+    gGetIpNetTable = NULL;
+    gGetInterfaceInfo = NULL;
+    gGetAdaptersInfo = NULL;
+    gGetNetworkParams = NULL;
+    gGetIcmpStatistics = NULL;
+    gGetIpStatistics = NULL;
+    gGetTcpStatistics = NULL;
+    gGetUdpStatistics = NULL;
+    gGetTcpTable = NULL;
+    gGetUdpTable = NULL;
+    FreeLibrary(hLibrary);
+    hLibrary = NULL;
+  }
+}
+
+/*
+still-to-be-tested 98-only functions:
+GetUniDirectionalAdapterInfo
+*/
+void testWin98OnlyFunctions(void)
+{
+}
+
+static void testGetNumberOfInterfaces(void)
+{
+  if (gGetNumberOfInterfaces) {
+    DWORD apiReturn = gGetNumberOfInterfaces(NULL), numInterfaces;
+
+    if (apiReturn == ERROR_NOT_SUPPORTED)
+      return;
+    ok(apiReturn == ERROR_INVALID_PARAMETER, 
+     "GetNumberOfInterfaces(NULL) returned %ld, expected ERROR_INVALID_PARAMETER\n",
+     apiReturn);
+    apiReturn = gGetNumberOfInterfaces(&numInterfaces);
+    ok(apiReturn == NO_ERROR,
+     "GetNumberOfInterfaces returned %ld, expected 0\n", apiReturn);
+  }
+}
+
+static void testGetIfEntry(DWORD index)
+{
+  if (gGetIfEntry) {
+    DWORD apiReturn;
+    MIB_IFROW row;
+
+    memset(&row, 0, sizeof(row));
+    apiReturn = gGetIfEntry(NULL);
+    if (apiReturn == ERROR_NOT_SUPPORTED)
+      return;
+    ok(apiReturn == ERROR_INVALID_PARAMETER,
+     "GetIfEntry(NULL) returned %ld, expected ERROR_INVALID_PARAMETER\n",
+     apiReturn);
+    row.dwIndex = -1; /* hope that's always bogus! */
+    apiReturn = gGetIfEntry(&row);
+    ok(apiReturn == ERROR_INVALID_DATA,
+     "GetIfEntry(bogus row) returned %ld, expected ERROR_INVALID_DATA\n",
+     apiReturn);
+    row.dwIndex = index;
+    apiReturn = gGetIfEntry(&row);
+    ok(apiReturn == NO_ERROR, 
+     "GetIfEntry returned %ld, expected NO_ERROR\n", apiReturn);
+  }
+}
+
+static void testGetIpAddrTable(void)
+{
+  if (gGetIpAddrTable) {
+    DWORD apiReturn;
+    ULONG dwSize = 0;
+
+    apiReturn = gGetIpAddrTable(NULL, NULL, FALSE);
+    if (apiReturn == ERROR_NOT_SUPPORTED)
+      return;
+    ok(apiReturn == ERROR_INVALID_PARAMETER,
+     "GetIpAddrTable(NULL, NULL, FALSE) returned %ld, expected ERROR_INVALID_PARAMETER\n",
+     apiReturn);
+    apiReturn = gGetIpAddrTable(NULL, &dwSize, FALSE);
+    ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
+     "GetIpAddrTable(NULL, &dwSize, FALSE) returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n",
+     apiReturn);
+    if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
+      PMIB_IPADDRTABLE buf = (PMIB_IPADDRTABLE)malloc(dwSize);
+
+      apiReturn = gGetIpAddrTable(buf, &dwSize, FALSE);
+      ok(apiReturn == NO_ERROR,
+       "GetIpAddrTable(buf, &dwSize, FALSE) returned %ld, expected NO_ERROR\n",
+       apiReturn);
+      if (apiReturn == NO_ERROR)
+        testGetIfEntry(buf->table[0].dwIndex);
+      free(buf);
+    }
+  }
+}
+
+static void testGetIfTable(void)
+{
+  if (gGetIfTable) {
+    DWORD apiReturn;
+    ULONG dwSize = 0;
+
+    apiReturn = gGetIfTable(NULL, NULL, FALSE);
+    if (apiReturn == ERROR_NOT_SUPPORTED)
+      return;
+    ok(apiReturn == ERROR_INVALID_PARAMETER,
+     "GetIfTable(NULL, NULL, FALSE) returned %ld, expected ERROR_INVALID_PARAMETER\n",
+     apiReturn);
+    apiReturn = gGetIfTable(NULL, &dwSize, FALSE);
+    ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
+     "GetIfTable(NULL, &dwSize, FALSE) returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n",
+     apiReturn);
+    if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
+      PMIB_IFTABLE buf = (PMIB_IFTABLE)malloc(dwSize);
+
+      apiReturn = gGetIfTable(buf, &dwSize, FALSE);
+      ok(apiReturn == NO_ERROR,
+       "GetIfTable(buf, &dwSize, FALSE) returned %ld, expected NO_ERROR\n\n",
+       apiReturn);
+      free(buf);
+    }
+  }
+}
+
+static void testGetIpForwardTable(void)
+{
+  if (gGetIpForwardTable) {
+    DWORD apiReturn;
+    ULONG dwSize = 0;
+
+    apiReturn = gGetIpForwardTable(NULL, NULL, FALSE);
+    if (apiReturn == ERROR_NOT_SUPPORTED)
+      return;
+    ok(apiReturn == ERROR_INVALID_PARAMETER,
+     "GetIpForwardTable(NULL, NULL, FALSE) returned %ld, expected ERROR_INVALID_PARAMETER\n",
+     apiReturn);
+    apiReturn = gGetIpForwardTable(NULL, &dwSize, FALSE);
+    ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
+     "GetIpForwardTable(NULL, &dwSize, FALSE) returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n",
+     apiReturn);
+    if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
+      PMIB_IPFORWARDTABLE buf = (PMIB_IPFORWARDTABLE)malloc(dwSize);
+
+      apiReturn = gGetIpForwardTable(buf, &dwSize, FALSE);
+      ok(apiReturn == NO_ERROR,
+       "GetIpForwardTable(buf, &dwSize, FALSE) returned %ld, expected NO_ERROR\n",
+       apiReturn);
+      if (apiReturn == NO_ERROR)
+        ok(buf->dwNumEntries > 0,
+          "Got 0 IP forward table entries, expect at least 1\n");
+      free(buf);
+    }
+  }
+}
+
+void testGetIpNetTable(void)
+{
+  if (gGetIpNetTable) {
+    DWORD apiReturn;
+    ULONG dwSize = 0;
+
+    apiReturn = gGetIpNetTable(NULL, NULL, FALSE);
+    if (apiReturn == ERROR_NOT_SUPPORTED)
+      return;
+    ok(apiReturn == ERROR_INVALID_PARAMETER,
+     "GetIpNetTable(NULL, NULL, FALSE) returned %ld, expected ERROR_INVALID_PARAMETER\n",
+     apiReturn);
+    apiReturn = gGetIpNetTable(NULL, &dwSize, FALSE);
+    ok(apiReturn == ERROR_NO_DATA || apiReturn == ERROR_INSUFFICIENT_BUFFER,
+     "GetIpNetTable(NULL, &dwSize, FALSE) returned %ld, expected ERROR_NO_DATA or ERROR_INSUFFICIENT_BUFFER\n",
+     apiReturn);
+    if (apiReturn == ERROR_NO_DATA)
+      ; /* empty ARP table's okay */
+    else if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
+      PMIB_IPNETTABLE buf = (PMIB_IPNETTABLE)malloc(dwSize);
+
+      apiReturn = gGetIpNetTable(buf, &dwSize, FALSE);
+      ok(apiReturn == NO_ERROR,
+       "GetIpNetTable(buf, &dwSize, FALSE) returned %ld, expected NO_ERROR\n",
+       apiReturn);
+      free(buf);
+    }
+  }
+}
+
+void testGetIcmpStatistics(void)
+{
+  if (gGetIcmpStatistics) {
+    DWORD apiReturn;
+    MIB_ICMP stats;
+
+    apiReturn = gGetIcmpStatistics(NULL);
+    if (apiReturn == ERROR_NOT_SUPPORTED)
+      return;
+    ok(apiReturn == ERROR_INVALID_PARAMETER,
+     "GetIcmpStatistics(NULL) returned %ld, expected ERROR_INVALID_PARAMETER\n",
+     apiReturn);
+    apiReturn = gGetIcmpStatistics(&stats);
+    ok(apiReturn == NO_ERROR,
+     "GetIcmpStatistics returned %ld, expected NO_ERROR\n", apiReturn);
+  }
+}
+
+void testGetIpStatistics(void)
+{
+  if (gGetIpStatistics) {
+    DWORD apiReturn;
+    MIB_IPSTATS stats;
+
+    apiReturn = gGetIpStatistics(NULL);
+    if (apiReturn == ERROR_NOT_SUPPORTED)
+      return;
+    ok(apiReturn == ERROR_INVALID_PARAMETER,
+     "GetIpStatistics(NULL) returned %ld, expected ERROR_INVALID_PARAMETER\n",
+     apiReturn);
+    apiReturn = gGetIpStatistics(&stats);
+    ok(apiReturn == NO_ERROR,
+      "GetIpStatistics returned %ld, expected NO_ERROR\n", apiReturn);
+  }
+}
+
+void testGetTcpStatistics(void)
+{
+  if (gGetTcpStatistics) {
+    DWORD apiReturn;
+    MIB_TCPSTATS stats;
+
+    apiReturn = gGetTcpStatistics(NULL);
+    if (apiReturn == ERROR_NOT_SUPPORTED)
+      return;
+    ok(apiReturn == ERROR_INVALID_PARAMETER,
+     "GetTcpStatistics(NULL) returned %ld, expected ERROR_INVALID_PARAMETER\n",
+     apiReturn);
+    apiReturn = gGetTcpStatistics(&stats);
+    ok(apiReturn == NO_ERROR,
+      "GetTcpStatistics returned %ld, expected NO_ERROR\n", apiReturn);
+  }
+}
+
+void testGetUdpStatistics(void)
+{
+  if (gGetUdpStatistics) {
+    DWORD apiReturn;
+    MIB_UDPSTATS stats;
+
+    apiReturn = gGetUdpStatistics(NULL);
+    if (apiReturn == ERROR_NOT_SUPPORTED)
+      return;
+    ok(apiReturn == ERROR_INVALID_PARAMETER,
+     "GetUdpStatistics(NULL) returned %ld, expected ERROR_INVALID_PARAMETER\n",
+     apiReturn);
+    apiReturn = gGetUdpStatistics(&stats);
+    ok(apiReturn == NO_ERROR,
+     "GetUdpStatistics returned %ld, expected NO_ERROR\n", apiReturn);
+  }
+}
+
+void testGetTcpTable(void)
+{
+  if (gGetTcpTable) {
+    DWORD apiReturn;
+    ULONG dwSize = 0;
+
+    apiReturn = gGetTcpTable(NULL, NULL, FALSE);
+    if (apiReturn == ERROR_NOT_SUPPORTED)
+      return;
+    ok(apiReturn == ERROR_INVALID_PARAMETER,
+     "GetTcpTable(NULL, NULL, FALSE) returned %ld, expected ERROR_INVALID_PARAMETER\n",
+     apiReturn);
+    apiReturn = gGetTcpTable(NULL, &dwSize, FALSE);
+    ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
+     "GetTcpTable(NULL, &dwSize, FALSE) returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n",
+     apiReturn);
+    if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
+      PMIB_TCPTABLE buf = (PMIB_TCPTABLE)malloc(dwSize);
+
+      apiReturn = gGetTcpTable(buf, &dwSize, FALSE);
+      ok(apiReturn == NO_ERROR,
+       "GetTcpTable(buf, &dwSize, FALSE) returned %ld, expected NO_ERROR\n",
+       apiReturn);
+      free(buf);
+    }
+  }
+}
+
+void testGetUdpTable(void)
+{
+  if (gGetUdpTable) {
+    DWORD apiReturn;
+    ULONG dwSize = 0;
+
+    apiReturn = gGetUdpTable(NULL, NULL, FALSE);
+    if (apiReturn == ERROR_NOT_SUPPORTED)
+      return;
+    ok(apiReturn == ERROR_INVALID_PARAMETER,
+     "GetUdpTable(NULL, NULL, FALSE) returned %ld, expected ERROR_INVALID_PARAMETER\n",
+     apiReturn);
+    apiReturn = gGetUdpTable(NULL, &dwSize, FALSE);
+    ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
+     "GetUdpTable(NULL, &dwSize, FALSE) returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n",
+     apiReturn);
+    if (apiReturn != ERROR_INSUFFICIENT_BUFFER) {
+      PMIB_UDPTABLE buf = (PMIB_UDPTABLE)malloc(dwSize);
+
+      apiReturn = gGetUdpTable(buf, &dwSize, FALSE);
+      ok(apiReturn == NO_ERROR,
+       "GetUdpTable(buf, &dwSize, FALSE) returned %ld, expected NO_ERROR\n",
+       apiReturn);
+      free(buf);
+    }
+  }
+}
+
+/*
+still-to-be-tested NT4-onward functions:
+CreateIpForwardEntry
+DeleteIpForwardEntry
+CreateIpNetEntry
+DeleteIpNetEntry
+GetFriendlyIfIndex
+GetRTTAndHopCount
+SetIfEntry
+SetIpForwardEntry
+SetIpNetEntry
+SetIpStatistics
+SetIpTTL
+SetTcpEntry
+*/
+static void testWinNT4Functions(void)
+{
+  testGetNumberOfInterfaces();
+  testGetIpAddrTable();
+  testGetIfTable();
+  testGetIpForwardTable();
+  testGetIpNetTable();
+  testGetIcmpStatistics();
+  testGetIpStatistics();
+  testGetTcpStatistics();
+  testGetUdpStatistics();
+  testGetTcpTable();
+  testGetUdpTable();
+}
+
+static void testGetInterfaceInfo(void)
+{
+  if (gGetInterfaceInfo) {
+    DWORD apiReturn;
+    ULONG len = 0;
+
+    apiReturn = gGetInterfaceInfo(NULL, NULL);
+    if (apiReturn == ERROR_NOT_SUPPORTED)
+      return;
+    ok(apiReturn == ERROR_INVALID_PARAMETER,
+     "GetInterfaceInfo returned %ld, expected ERROR_INVALID_PARAMETER\n",
+     apiReturn);
+    apiReturn = gGetInterfaceInfo(NULL, &len);
+    ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
+     "GetInterfaceInfo returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n",
+     apiReturn);
+    if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
+      PIP_INTERFACE_INFO buf = (PIP_INTERFACE_INFO)malloc(len);
+
+      apiReturn = gGetInterfaceInfo(buf, &len);
+      ok(apiReturn == NO_ERROR,
+       "GetInterfaceInfo(buf, &dwSize) returned %ld, expected NO_ERROR\n",
+       apiReturn);
+      free(buf);
+    }
+  }
+}
+
+static void testGetAdaptersInfo(void)
+{
+  if (gGetAdaptersInfo) {
+    DWORD apiReturn;
+    ULONG len = 0;
+
+    apiReturn = gGetAdaptersInfo(NULL, NULL);
+    if (apiReturn == ERROR_NOT_SUPPORTED)
+      return;
+    ok(apiReturn == ERROR_INVALID_PARAMETER,
+     "GetAdaptersInfo returned %ld, expected ERROR_INVALID_PARAMETER\n",
+     apiReturn);
+    apiReturn = gGetAdaptersInfo(NULL, &len);
+    ok(apiReturn == ERROR_NO_DATA || apiReturn == ERROR_BUFFER_OVERFLOW,
+     "GetAdaptersInfo returned %ld, expected ERROR_NO_DATA or ERROR_BUFFER_OVERFLOW\n",
+     apiReturn);
+    if (apiReturn == ERROR_NO_DATA)
+      ; /* no adapter's, that's okay */
+    else if (apiReturn == ERROR_BUFFER_OVERFLOW) {
+      PIP_ADAPTER_INFO buf = (PIP_ADAPTER_INFO)malloc(len);
+
+      apiReturn = gGetAdaptersInfo(buf, &len);
+      ok(apiReturn == NO_ERROR,
+       "GetAdaptersInfo(buf, &dwSize) returned %ld, expected NO_ERROR\n",
+       apiReturn);
+      free(buf);
+    }
+  }
+}
+
+static void testGetNetworkParams(void)
+{
+  if (gGetNetworkParams) {
+    DWORD apiReturn;
+    ULONG len = 0;
+
+    apiReturn = gGetNetworkParams(NULL, NULL);
+    if (apiReturn == ERROR_NOT_SUPPORTED)
+      return;
+    ok(apiReturn == ERROR_INVALID_PARAMETER,
+     "GetNetworkParams returned %ld, expected ERROR_INVALID_PARAMETER\n",
+     apiReturn);
+    apiReturn = gGetNetworkParams(NULL, &len);
+    ok(apiReturn == ERROR_BUFFER_OVERFLOW,
+     "GetNetworkParams returned %ld, expected ERROR_BUFFER_OVERFLOW\n",
+     apiReturn);
+    if (apiReturn == ERROR_BUFFER_OVERFLOW) {
+      PFIXED_INFO buf = (PFIXED_INFO)malloc(len);
+
+      apiReturn = gGetNetworkParams(buf, &len);
+      ok(apiReturn == NO_ERROR,
+       "GetNetworkParams(buf, &dwSize) returned %ld, expected NO_ERROR\n",
+       apiReturn);
+      free(buf);
+    }
+  }
+}
+
+/*
+still-to-be-tested 98-onward functions:
+GetBestInterface
+GetBestRoute
+IpReleaseAddress
+IpRenewAddress
+*/
+static void testWin98Functions(void)
+{
+  testGetInterfaceInfo();
+  testGetAdaptersInfo();
+  testGetNetworkParams();
+}
+
+/*
+still-to-be-tested 2K-onward functions:
+AddIPAddress
+CreateProxyArpEntry
+DeleteIPAddress
+DeleteProxyArpEntry
+EnableRouter
+FlushIpNetTable
+GetAdapterIndex
+GetPerAdapterInfo
+NotifyAddrChange
+NotifyRouteChange
+SendARP
+UnenableRouter
+*/
+static void testWin2KFunctions(void)
+{
+}
+
+START_TEST(iphlpapi)
+{
+
+  loadIPHlpApi();
+  if (hLibrary) {
+    testWin98OnlyFunctions();
+    testWinNT4Functions();
+    testWin98Functions();
+    testWin2KFunctions();
+    freeIPHlpApi();
+  }
+}