[PATCH] dlls/ddraw/tests: enable compilation with long types

Eric Pouech eric.pouech at gmail.com
Thu Jul 7 03:52:54 CDT 2022


Signed-off-by: Eric Pouech <eric.pouech at gmail.com>

---
 dlls/ddraw/tests/Makefile.in  |    1 
 dlls/ddraw/tests/d3d.c        |  620 ++---
 dlls/ddraw/tests/ddraw1.c     | 4082 +++++++++++++++---------------
 dlls/ddraw/tests/ddraw2.c     | 4702 +++++++++++++++++-----------------
 dlls/ddraw/tests/ddraw4.c     | 5646 +++++++++++++++++++++--------------------
 dlls/ddraw/tests/ddraw7.c     | 5360 +++++++++++++++++++--------------------
 dlls/ddraw/tests/ddrawmodes.c |  182 +
 dlls/ddraw/tests/dsurface.c   |  752 +++--
 dlls/ddraw/tests/refcount.c   |  126 -
 dlls/ddraw/tests/visual.c     |  448 ++-
 10 files changed, 10959 insertions(+), 10960 deletions(-)

diff --git a/dlls/ddraw/tests/Makefile.in b/dlls/ddraw/tests/Makefile.in
index 6316bf91892e..a3d0ce5cf121 100644
--- a/dlls/ddraw/tests/Makefile.in
+++ b/dlls/ddraw/tests/Makefile.in
@@ -1,4 +1,3 @@
-EXTRADEFS = -DWINE_NO_LONG_TYPES
 TESTDLL   = ddraw.dll
 IMPORTS   = ddraw user32 gdi32 ole32
 
diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c
index d8f3618200bd..e894e0fed234 100644
--- a/dlls/ddraw/tests/d3d.c
+++ b/dlls/ddraw/tests/d3d.c
@@ -99,14 +99,14 @@ static BOOL CreateDirect3D(void)
 
     rc = pDirectDrawCreateEx(NULL, (void**)&lpDD,
         &IID_IDirectDraw7, NULL);
-    ok(rc==DD_OK || rc==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", rc);
+    ok(rc==DD_OK || rc==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %lx\n", rc);
     if (!lpDD) {
-        trace("DirectDrawCreateEx() failed with an error %x\n", rc);
+        trace("DirectDrawCreateEx() failed with an error %lx\n", rc);
         return FALSE;
     }
 
     rc = IDirectDraw7_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL);
-    ok(rc==DD_OK, "SetCooperativeLevel returned: %x\n", rc);
+    ok(rc==DD_OK, "SetCooperativeLevel returned: %lx\n", rc);
 
     rc = IDirectDraw7_QueryInterface(lpDD, &IID_IDirect3D7, (void**) &lpD3D);
     if (rc == E_NOINTERFACE)
@@ -114,7 +114,7 @@ static BOOL CreateDirect3D(void)
         IDirectDraw7_Release(lpDD);
         return FALSE;
     }
-    ok(rc==DD_OK, "QueryInterface returned: %x\n", rc);
+    ok(rc==DD_OK, "QueryInterface returned: %lx\n", rc);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -145,12 +145,12 @@ static BOOL CreateDirect3D(void)
     ddsd.dwWidth = 256;
     ddsd.dwHeight = 256;
     rc = IDirectDraw7_CreateSurface(lpDD, &ddsd, &lpDDSdepth, NULL);
-    ok(rc==DD_OK, "CreateSurface returned: %x\n", rc);
+    ok(rc==DD_OK, "CreateSurface returned: %lx\n", rc);
     if (FAILED(rc)) {
         lpDDSdepth = NULL;
     } else {
         rc = IDirectDrawSurface_AddAttachedSurface(lpDDS, lpDDSdepth);
-        ok(rc == DD_OK, "IDirectDrawSurface_AddAttachedSurface returned %x\n", rc);
+        ok(rc == DD_OK, "IDirectDrawSurface_AddAttachedSurface returned %lx\n", rc);
         if (FAILED(rc))
         {
             IDirectDrawSurface7_Release(lpDDSdepth);
@@ -163,17 +163,17 @@ static BOOL CreateDirect3D(void)
 
     rc = IDirect3D7_CreateDevice(lpD3D, &IID_IDirect3DTnLHalDevice, lpDDS,
         &lpD3DDevice);
-    ok(rc==D3D_OK || rc==DDERR_NOPALETTEATTACHED || rc==E_OUTOFMEMORY, "CreateDevice returned: %x\n", rc);
+    ok(rc==D3D_OK || rc==DDERR_NOPALETTEATTACHED || rc==E_OUTOFMEMORY, "CreateDevice returned: %lx\n", rc);
     if (!lpD3DDevice) {
-        trace("IDirect3D7::CreateDevice() for a TnL Hal device failed with an error %x, trying HAL\n", rc);
+        trace("IDirect3D7::CreateDevice() for a TnL Hal device failed with an error %lx, trying HAL\n", rc);
         rc = IDirect3D7_CreateDevice(lpD3D, &IID_IDirect3DHALDevice, lpDDS,
             &lpD3DDevice);
         if (!lpD3DDevice) {
-            trace("IDirect3D7::CreateDevice() for a HAL device failed with an error %x, trying RGB\n", rc);
+            trace("IDirect3D7::CreateDevice() for a HAL device failed with an error %lx, trying RGB\n", rc);
             rc = IDirect3D7_CreateDevice(lpD3D, &IID_IDirect3DRGBDevice, lpDDS,
                 &lpD3DDevice);
             if (!lpD3DDevice) {
-                trace("IDirect3D7::CreateDevice() for a RGB device failed with an error %x, giving up\n", rc);
+                trace("IDirect3D7::CreateDevice() for a RGB device failed with an error %lx, giving up\n", rc);
                 if (lpDDSdepth)
                     IDirectDrawSurface7_Release(lpDDSdepth);
                 IDirectDrawSurface7_Release(lpDDS);
@@ -242,29 +242,29 @@ static void LightTest(void)
     U2(light.dvDirection).y = 1.f;
 
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 5, &light);
-    ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
+    ok(rc==D3D_OK, "SetLight returned: %lx\n", rc);
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 10, &light);
-    ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
+    ok(rc==D3D_OK, "SetLight returned: %lx\n", rc);
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 45, &light);
-    ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
+    ok(rc==D3D_OK, "SetLight returned: %lx\n", rc);
 
 
     /* Try to retrieve a light beyond the indices of the lights that have
        been set. */
     rc = IDirect3DDevice7_GetLight(lpD3DDevice, 50, &light);
-    ok(rc==DDERR_INVALIDPARAMS, "GetLight returned: %x\n", rc);
+    ok(rc==DDERR_INVALIDPARAMS, "GetLight returned: %lx\n", rc);
     rc = IDirect3DDevice7_GetLight(lpD3DDevice, 2, &light);
-    ok(rc==DDERR_INVALIDPARAMS, "GetLight returned: %x\n", rc);
+    ok(rc==DDERR_INVALIDPARAMS, "GetLight returned: %lx\n", rc);
 
 
     /* Try to retrieve one of the lights that have been set */
     rc = IDirect3DDevice7_GetLight(lpD3DDevice, 10, &light);
-    ok(rc==D3D_OK, "GetLight returned: %x\n", rc);
+    ok(rc==D3D_OK, "GetLight returned: %lx\n", rc);
 
 
     /* Enable a light that have been previously set. */
     rc = IDirect3DDevice7_LightEnable(lpD3DDevice, 10, TRUE);
-    ok(rc==D3D_OK, "LightEnable returned: %x\n", rc);
+    ok(rc==D3D_OK, "LightEnable returned: %lx\n", rc);
 
 
     /* Enable some lights that have not been previously set, and verify that
@@ -277,45 +277,45 @@ static void LightTest(void)
     U3(defaultlight.dvDirection).z = 1.f;
 
     rc = IDirect3DDevice7_LightEnable(lpD3DDevice, 20, TRUE);
-    ok(rc==D3D_OK, "LightEnable returned: %x\n", rc);
+    ok(rc==D3D_OK, "LightEnable returned: %lx\n", rc);
     memset(&light, 0, sizeof(D3DLIGHT7));
     rc = IDirect3DDevice7_GetLight(lpD3DDevice, 20, &light);
-    ok(rc==D3D_OK, "GetLight returned: %x\n", rc);
+    ok(rc==D3D_OK, "GetLight returned: %lx\n", rc);
     ok(!memcmp(&light, &defaultlight, sizeof(D3DLIGHT7)),
         "light data doesn't match expected default values\n" );
 
     rc = IDirect3DDevice7_LightEnable(lpD3DDevice, 50, TRUE);
-    ok(rc==D3D_OK, "LightEnable returned: %x\n", rc);
+    ok(rc==D3D_OK, "LightEnable returned: %lx\n", rc);
     memset(&light, 0, sizeof(D3DLIGHT7));
     rc = IDirect3DDevice7_GetLight(lpD3DDevice, 50, &light);
-    ok(rc==D3D_OK, "GetLight returned: %x\n", rc);
+    ok(rc==D3D_OK, "GetLight returned: %lx\n", rc);
     ok(!memcmp(&light, &defaultlight, sizeof(D3DLIGHT7)),
         "light data doesn't match expected default values\n" );
 
 
     /* Disable one of the light that have been previously enabled. */
     rc = IDirect3DDevice7_LightEnable(lpD3DDevice, 20, FALSE);
-    ok(rc==D3D_OK, "LightEnable returned: %x\n", rc);
+    ok(rc==D3D_OK, "LightEnable returned: %lx\n", rc);
 
     /* Try to retrieve the enable status of some lights */
     /* Light 20 is supposed to be disabled */
     rc = IDirect3DDevice7_GetLightEnable(lpD3DDevice, 20, &bEnabled );
-    ok(rc==D3D_OK, "GetLightEnable returned: %x\n", rc);
+    ok(rc==D3D_OK, "GetLightEnable returned: %lx\n", rc);
     ok(!bEnabled, "GetLightEnable says the light is enabled\n");
 
     /* Light 10 is supposed to be enabled */
     bEnabled = FALSE;
     rc = IDirect3DDevice7_GetLightEnable(lpD3DDevice, 10, &bEnabled );
-    ok(rc==D3D_OK, "GetLightEnable returned: %x\n", rc);
+    ok(rc==D3D_OK, "GetLightEnable returned: %lx\n", rc);
     ok(bEnabled, "GetLightEnable says the light is disabled\n");
 
     /* Light 80 has not been set */
     rc = IDirect3DDevice7_GetLightEnable(lpD3DDevice, 80, &bEnabled );
-    ok(rc==DDERR_INVALIDPARAMS, "GetLightEnable returned: %x\n", rc);
+    ok(rc==DDERR_INVALIDPARAMS, "GetLightEnable returned: %lx\n", rc);
 
     /* Light 23 has not been set */
     rc = IDirect3DDevice7_GetLightEnable(lpD3DDevice, 23, &bEnabled );
-    ok(rc==DDERR_INVALIDPARAMS, "GetLightEnable returned: %x\n", rc);
+    ok(rc==DDERR_INVALIDPARAMS, "GetLightEnable returned: %lx\n", rc);
 
     /* Set some lights with invalid parameters */
     memset(&light, 0, sizeof(D3DLIGHT7));
@@ -325,7 +325,7 @@ static void LightTest(void)
     U3(light.dcvDiffuse).b = 1.f;
     U3(light.dvDirection).z = 1.f;
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 100, &light);
-    ok(rc==DDERR_INVALIDPARAMS, "SetLight returned: %x\n", rc);
+    ok(rc==DDERR_INVALIDPARAMS, "SetLight returned: %lx\n", rc);
 
     memset(&light, 0, sizeof(D3DLIGHT7));
     light.dltType = 12345;
@@ -334,10 +334,10 @@ static void LightTest(void)
     U3(light.dcvDiffuse).b = 1.f;
     U3(light.dvDirection).z = 1.f;
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 101, &light);
-    ok(rc==DDERR_INVALIDPARAMS, "SetLight returned: %x\n", rc);
+    ok(rc==DDERR_INVALIDPARAMS, "SetLight returned: %lx\n", rc);
 
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 102, NULL);
-    ok(rc==DDERR_INVALIDPARAMS, "SetLight returned: %x\n", rc);
+    ok(rc==DDERR_INVALIDPARAMS, "SetLight returned: %lx\n", rc);
 
     memset(&light, 0, sizeof(D3DLIGHT7));
     light.dltType = D3DLIGHT_SPOT;
@@ -348,58 +348,58 @@ static void LightTest(void)
 
     light.dvAttenuation0 = -one / zero; /* -INFINITY */
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
-    ok(rc==DDERR_INVALIDPARAMS, "SetLight returned: %x\n", rc);
+    ok(rc==DDERR_INVALIDPARAMS, "SetLight returned: %lx\n", rc);
 
     light.dvAttenuation0 = -1.0;
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
-    ok(rc==DDERR_INVALIDPARAMS, "SetLight returned: %x\n", rc);
+    ok(rc==DDERR_INVALIDPARAMS, "SetLight returned: %lx\n", rc);
 
     light.dvAttenuation0 = 0.0;
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
-    ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
+    ok(rc==D3D_OK, "SetLight returned: %lx\n", rc);
 
     light.dvAttenuation0 = 1.0;
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
-    ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
+    ok(rc==D3D_OK, "SetLight returned: %lx\n", rc);
 
     light.dvAttenuation0 = one / zero; /* +INFINITY */
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
-    ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
+    ok(rc==D3D_OK, "SetLight returned: %lx\n", rc);
 
     light.dvAttenuation0 = zero / zero; /* NaN */
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
     ok(rc==D3D_OK ||
-       broken(rc==DDERR_INVALIDPARAMS), "SetLight returned: %x\n", rc);
+       broken(rc==DDERR_INVALIDPARAMS), "SetLight returned: %lx\n", rc);
 
     /* Directional light ignores attenuation */
     light.dltType = D3DLIGHT_DIRECTIONAL;
     light.dvAttenuation0 = -1.0;
     rc = IDirect3DDevice7_SetLight(lpD3DDevice, 103, &light);
-    ok(rc==D3D_OK, "SetLight returned: %x\n", rc);
+    ok(rc==D3D_OK, "SetLight returned: %lx\n", rc);
 
     memset(&mat, 0, sizeof(mat));
     rc = IDirect3DDevice7_SetMaterial(lpD3DDevice, &mat);
-    ok(rc == D3D_OK, "IDirect3DDevice7_SetMaterial returned: %x\n", rc);
+    ok(rc == D3D_OK, "IDirect3DDevice7_SetMaterial returned: %lx\n", rc);
 
     U4(mat).power = 129.0;
     rc = IDirect3DDevice7_SetMaterial(lpD3DDevice, &mat);
-    ok(rc == D3D_OK, "IDirect3DDevice7_SetMaterial(power = 129.0) returned: %x\n", rc);
+    ok(rc == D3D_OK, "IDirect3DDevice7_SetMaterial(power = 129.0) returned: %lx\n", rc);
     memset(&mat, 0, sizeof(mat));
     rc = IDirect3DDevice7_GetMaterial(lpD3DDevice, &mat);
-    ok(rc == D3D_OK, "IDirect3DDevice7_GetMaterial returned: %x\n", rc);
+    ok(rc == D3D_OK, "IDirect3DDevice7_GetMaterial returned: %lx\n", rc);
     ok(U4(mat).power == 129, "Returned power is %f\n", U4(mat).power);
 
     U4(mat).power = -1.0;
     rc = IDirect3DDevice7_SetMaterial(lpD3DDevice, &mat);
-    ok(rc == D3D_OK, "IDirect3DDevice7_SetMaterial(power = -1.0) returned: %x\n", rc);
+    ok(rc == D3D_OK, "IDirect3DDevice7_SetMaterial(power = -1.0) returned: %lx\n", rc);
     memset(&mat, 0, sizeof(mat));
     rc = IDirect3DDevice7_GetMaterial(lpD3DDevice, &mat);
-    ok(rc == D3D_OK, "IDirect3DDevice7_GetMaterial returned: %x\n", rc);
+    ok(rc == D3D_OK, "IDirect3DDevice7_GetMaterial returned: %lx\n", rc);
     ok(U4(mat).power == -1, "Returned power is %f\n", U4(mat).power);
 
     memset(&caps, 0, sizeof(caps));
     rc = IDirect3DDevice7_GetCaps(lpD3DDevice, &caps);
-    ok(rc == D3D_OK, "IDirect3DDevice7_GetCaps failed with %x\n", rc);
+    ok(rc == D3D_OK, "IDirect3DDevice7_GetCaps failed with %lx\n", rc);
 
     if ( caps.dwMaxActiveLights == (DWORD) -1) {
         /* Some cards without T&L Support return -1 (Examples: Voodoo Banshee, RivaTNT / NV4) */
@@ -409,24 +409,24 @@ static void LightTest(void)
 
     for(i = 1; i <= caps.dwMaxActiveLights; i++) {
         rc = IDirect3DDevice7_LightEnable(lpD3DDevice, i, TRUE);
-        ok(rc == D3D_OK, "Enabling light %u failed with %x\n", i, rc);
+        ok(rc == D3D_OK, "Enabling light %u failed with %lx\n", i, rc);
         rc = IDirect3DDevice7_GetLightEnable(lpD3DDevice, i, &enabled);
-        ok(rc == D3D_OK, "GetLightEnable on light %u failed with %x\n", i, rc);
+        ok(rc == D3D_OK, "GetLightEnable on light %u failed with %lx\n", i, rc);
         ok(enabled, "Light %d is %s\n", i, enabled ? "enabled" : "disabled");
     }
 
     /* TODO: Test the rendering results in this situation */
     rc = IDirect3DDevice7_LightEnable(lpD3DDevice, i + 1, TRUE);
-    ok(rc == D3D_OK, "Enabling one light more than supported returned %x\n", rc);
+    ok(rc == D3D_OK, "Enabling one light more than supported returned %lx\n", rc);
     rc = IDirect3DDevice7_GetLightEnable(lpD3DDevice, i + 1, &enabled);
-    ok(rc == D3D_OK, "GetLightEnable on light %u failed with %x\n", i + 1,  rc);
+    ok(rc == D3D_OK, "GetLightEnable on light %u failed with %lx\n", i + 1,  rc);
     ok(enabled, "Light %d is %s\n", i + 1, enabled ? "enabled" : "disabled");
     rc = IDirect3DDevice7_LightEnable(lpD3DDevice, i + 1, FALSE);
-    ok(rc == D3D_OK, "Disabling the additional returned %x\n", rc);
+    ok(rc == D3D_OK, "Disabling the additional returned %lx\n", rc);
 
     for(i = 1; i <= caps.dwMaxActiveLights; i++) {
         rc = IDirect3DDevice7_LightEnable(lpD3DDevice, i, FALSE);
-        ok(rc == D3D_OK, "Disabling light %u failed with %x\n", i, rc);
+        ok(rc == D3D_OK, "Disabling light %u failed with %lx\n", i, rc);
     }
 }
 
@@ -436,15 +436,15 @@ static void SceneTest(void)
 
     /* Test an EndScene without BeginScene. Should return an error */
     hr = IDirect3DDevice7_EndScene(lpD3DDevice);
-    ok(hr == D3DERR_SCENE_NOT_IN_SCENE, "IDirect3DDevice7_EndScene returned %08x\n", hr);
+    ok(hr == D3DERR_SCENE_NOT_IN_SCENE, "IDirect3DDevice7_EndScene returned %08lx\n", hr);
 
     /* Test a normal BeginScene / EndScene pair, this should work */
     hr = IDirect3DDevice7_BeginScene(lpD3DDevice);
-    ok(hr == D3D_OK, "IDirect3DDevice7_BeginScene failed with %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_BeginScene failed with %08lx\n", hr);
     if (SUCCEEDED(hr))
     {
         hr = IDirect3DDevice7_EndScene(lpD3DDevice);
-        ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed with %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed with %08lx\n", hr);
     }
 
     if (lpDDSdepth)
@@ -454,17 +454,17 @@ static void SceneTest(void)
         fx.dwSize = sizeof(fx);
 
         hr = IDirectDrawSurface7_Blt(lpDDSdepth, NULL, NULL, NULL, DDBLT_DEPTHFILL, &fx);
-        ok(hr == D3D_OK, "Depthfill failed outside a BeginScene / EndScene pair, hr 0x%08x\n", hr);
+        ok(hr == D3D_OK, "Depthfill failed outside a BeginScene / EndScene pair, hr 0x%08lx\n", hr);
 
         hr = IDirect3DDevice7_BeginScene(lpD3DDevice);
-        ok(hr == D3D_OK, "IDirect3DDevice7_BeginScene failed with %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_BeginScene failed with %08lx\n", hr);
         if (SUCCEEDED(hr))
         {
             hr = IDirectDrawSurface7_Blt(lpDDSdepth, NULL, NULL, NULL, DDBLT_DEPTHFILL, &fx);
             ok(hr == D3D_OK || broken(hr == E_FAIL),
-                    "Depthfill failed in a BeginScene / EndScene pair, hr 0x%08x\n", hr);
+                    "Depthfill failed in a BeginScene / EndScene pair, hr 0x%08lx\n", hr);
             hr = IDirect3DDevice7_EndScene(lpD3DDevice);
-            ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed with %08x\n", hr);
+            ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed with %08lx\n", hr);
         }
     }
     else
@@ -474,17 +474,17 @@ static void SceneTest(void)
 
     /* Test another EndScene without having begun a new scene. Should return an error */
     hr = IDirect3DDevice7_EndScene(lpD3DDevice);
-    ok(hr == D3DERR_SCENE_NOT_IN_SCENE, "IDirect3DDevice7_EndScene returned %08x\n", hr);
+    ok(hr == D3DERR_SCENE_NOT_IN_SCENE, "IDirect3DDevice7_EndScene returned %08lx\n", hr);
 
     /* Two nested BeginScene and EndScene calls */
     hr = IDirect3DDevice7_BeginScene(lpD3DDevice);
-    ok(hr == D3D_OK, "IDirect3DDevice7_BeginScene failed with %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_BeginScene failed with %08lx\n", hr);
     hr = IDirect3DDevice7_BeginScene(lpD3DDevice);
-    ok(hr == D3DERR_SCENE_IN_SCENE, "IDirect3DDevice7_BeginScene returned %08x\n", hr);
+    ok(hr == D3DERR_SCENE_IN_SCENE, "IDirect3DDevice7_BeginScene returned %08lx\n", hr);
     hr = IDirect3DDevice7_EndScene(lpD3DDevice);
-    ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed with %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed with %08lx\n", hr);
     hr = IDirect3DDevice7_EndScene(lpD3DDevice);
-    ok(hr == D3DERR_SCENE_NOT_IN_SCENE, "IDirect3DDevice7_EndScene returned %08x\n", hr);
+    ok(hr == D3DERR_SCENE_NOT_IN_SCENE, "IDirect3DDevice7_EndScene returned %08lx\n", hr);
 
     /* TODO: Verify that blitting works in the same way as in d3d9 */
 }
@@ -513,20 +513,20 @@ static HRESULT WINAPI enumDevicesCallback(GUID *Guid, char *DeviceDescription,
         ok(hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE,
            "RGB Device %d hel tri caps does not have D3DPTEXTURECAPS_PERSPECTIVE set\n", ver);
 
-        ok(hal->dcmColorModel == 0, "RGB Device %u hal caps has colormodel %u\n", ver, hal->dcmColorModel);
-        ok(hel->dcmColorModel == D3DCOLOR_RGB, "RGB Device %u hel caps has colormodel %u\n", ver, hel->dcmColorModel);
+        ok(hal->dcmColorModel == 0, "RGB Device %u hal caps has colormodel %lu\n", ver, hal->dcmColorModel);
+        ok(hel->dcmColorModel == D3DCOLOR_RGB, "RGB Device %u hel caps has colormodel %lu\n", ver, hel->dcmColorModel);
 
-        ok(hal->dwFlags == 0, "RGB Device %u hal caps has hardware flags %x\n", ver, hal->dwFlags);
-        ok(hel->dwFlags != 0, "RGB Device %u hel caps has hardware flags %x\n", ver, hel->dwFlags);
+        ok(hal->dwFlags == 0, "RGB Device %u hal caps has hardware flags %lx\n", ver, hal->dwFlags);
+        ok(hel->dwFlags != 0, "RGB Device %u hel caps has hardware flags %lx\n", ver, hel->dwFlags);
     }
     else if(IsEqualGUID(&IID_IDirect3DHALDevice, Guid))
     {
         trace("HAL Device %d\n", ver);
-        ok(hal->dcmColorModel == D3DCOLOR_RGB, "HAL Device %u hal caps has colormodel %u\n", ver, hel->dcmColorModel);
-        ok(hel->dcmColorModel == 0, "HAL Device %u hel caps has colormodel %u\n", ver, hel->dcmColorModel);
+        ok(hal->dcmColorModel == D3DCOLOR_RGB, "HAL Device %u hal caps has colormodel %lu\n", ver, hel->dcmColorModel);
+        ok(hel->dcmColorModel == 0, "HAL Device %u hel caps has colormodel %lu\n", ver, hel->dcmColorModel);
 
-        ok(hal->dwFlags != 0, "HAL Device %u hal caps has hardware flags %x\n", ver, hal->dwFlags);
-        ok(hel->dwFlags != 0, "HAL Device %u hel caps has hardware flags %x\n", ver, hel->dwFlags);
+        ok(hal->dwFlags != 0, "HAL Device %u hal caps has hardware flags %lx\n", ver, hal->dwFlags);
+        ok(hel->dwFlags != 0, "HAL Device %u hel caps has hardware flags %lx\n", ver, hel->dwFlags);
     }
     else if(IsEqualGUID(&IID_IDirect3DRefDevice, Guid))
     {
@@ -568,12 +568,12 @@ static HRESULT WINAPI enumDevicesCallback(GUID *Guid, char *DeviceDescription,
         ok(hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE,
            "Ramp Device %d hel tri caps does not have D3DPTEXTURECAPS_PERSPECTIVE set\n", ver);
 
-        ok(hal->dcmColorModel == 0, "Ramp Device %u hal caps has colormodel %u\n", ver, hal->dcmColorModel);
-        ok(hel->dcmColorModel == D3DCOLOR_MONO, "Ramp Device %u hel caps has colormodel %u\n",
+        ok(hal->dcmColorModel == 0, "Ramp Device %u hal caps has colormodel %lu\n", ver, hal->dcmColorModel);
+        ok(hel->dcmColorModel == D3DCOLOR_MONO, "Ramp Device %u hel caps has colormodel %lu\n",
                 ver, hel->dcmColorModel);
 
-        ok(hal->dwFlags == 0, "Ramp Device %u hal caps has hardware flags %x\n", ver, hal->dwFlags);
-        ok(hel->dwFlags != 0, "Ramp Device %u hel caps has hardware flags %x\n", ver, hel->dwFlags);
+        ok(hal->dwFlags == 0, "Ramp Device %u hal caps has hardware flags %lx\n", ver, hal->dwFlags);
+        ok(hel->dwFlags != 0, "Ramp Device %u hel caps has hardware flags %lx\n", ver, hel->dwFlags);
     }
     else if(IsEqualGUID(&IID_IDirect3DMMXDevice, Guid))
     {
@@ -595,11 +595,11 @@ static HRESULT WINAPI enumDevicesCallback(GUID *Guid, char *DeviceDescription,
         ok(hel->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_PERSPECTIVE,
            "MMX Device %d hel tri caps does not have D3DPTEXTURECAPS_PERSPECTIVE set\n", ver);
 
-        ok(hal->dcmColorModel == 0, "MMX Device %u hal caps has colormodel %u\n", ver, hal->dcmColorModel);
-        ok(hel->dcmColorModel == D3DCOLOR_RGB, "MMX Device %u hel caps has colormodel %u\n", ver, hel->dcmColorModel);
+        ok(hal->dcmColorModel == 0, "MMX Device %u hal caps has colormodel %lu\n", ver, hal->dcmColorModel);
+        ok(hel->dcmColorModel == D3DCOLOR_RGB, "MMX Device %u hel caps has colormodel %lu\n", ver, hel->dcmColorModel);
 
-        ok(hal->dwFlags == 0, "MMX Device %u hal caps has hardware flags %x\n", ver, hal->dwFlags);
-        ok(hel->dwFlags != 0, "MMX Device %u hel caps has hardware flags %x\n", ver, hel->dwFlags);
+        ok(hal->dwFlags == 0, "MMX Device %u hal caps has hardware flags %lx\n", ver, hal->dwFlags);
+        ok(hel->dwFlags != 0, "MMX Device %u hel caps has hardware flags %lx\n", ver, hel->dwFlags);
     }
     else
     {
@@ -673,11 +673,11 @@ static void D3D7EnumTest(void)
     D3D7ECancelTest d3d7_cancel_test;
 
     hr = IDirect3D7_EnumDevices(lpD3D, NULL, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirect3D7_EnumDevices returned 0x%08x\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "IDirect3D7_EnumDevices returned 0x%08lx\n", hr);
 
     memset(&d3d7et, 0, sizeof(d3d7et));
     hr = IDirect3D7_EnumDevices(lpD3D, enumDevicesCallbackTest7, &d3d7et);
-    ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08lx\n", hr);
 
     /* A couple of games (Delta Force LW and TFD) rely on this behaviour */
     ok(d3d7et.tnlhal < d3d7et.total, "TnLHal device enumerated as only device.\n");
@@ -691,7 +691,7 @@ static void D3D7EnumTest(void)
     d3d7_cancel_test.desired_ret = DDENUMRET_CANCEL;
     d3d7_cancel_test.total = 0;
     hr = IDirect3D7_EnumDevices(lpD3D, enumDevicesCancelTest7, &d3d7_cancel_test);
-    ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08lx\n", hr);
 
     ok(d3d7_cancel_test.total == 1, "Enumerated a total of %u devices\n",
        d3d7_cancel_test.total);
@@ -700,7 +700,7 @@ static void D3D7EnumTest(void)
     d3d7_cancel_test.desired_ret = E_INVALIDARG;
     d3d7_cancel_test.total = 0;
     hr = IDirect3D7_EnumDevices(lpD3D, enumDevicesCancelTest7, &d3d7_cancel_test);
-    ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08lx\n", hr);
 
     ok(d3d7_cancel_test.total == 1, "Enumerated a total of %u devices\n",
        d3d7_cancel_test.total);
@@ -714,7 +714,7 @@ static void D3D7EnumLifetimeTest(void)
 
     ctx.count = 0;
     hr = IDirect3D7_EnumDevices(lpD3D, enumDevicesLifetimeTest7, &ctx);
-    ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08lx\n", hr);
 
     /* The enumeration strings remain valid even after IDirect3D7_EnumDevices finishes. */
     for (i = 0; i < ctx.count; i++)
@@ -727,7 +727,7 @@ static void D3D7EnumLifetimeTest(void)
 
     ctx2.count = 0;
     hr = IDirect3D7_EnumDevices(lpD3D, enumDevicesLifetimeTest7, &ctx2);
-    ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08lx\n", hr);
 
     /* The enumeration strings and their order are identical across enumerations. */
     ok(ctx.count == ctx2.count, "Enumerated %u and %u devices\n", ctx.count, ctx2.count);
@@ -755,7 +755,7 @@ static void D3D7EnumLifetimeTest(void)
 
     ctx2.count = 0;
     hr = IDirect3D7_EnumDevices(lpD3D, enumDevicesLifetimeTest7, &ctx2);
-    ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3D7_EnumDevices returned 0x%08lx\n", hr);
 
     /* The original contents of the enumeration strings are not restored. */
     ok(ctx.count == ctx2.count, "Enumerated %u and %u devices\n", ctx.count, ctx2.count);
@@ -784,12 +784,12 @@ static void CapsTest(void)
     UINT ver;
 
     hr = DirectDrawCreate(NULL, &dd1, NULL);
-    ok(hr == DD_OK, "Cannot create a DirectDraw 1 interface, hr = %08x\n", hr);
+    ok(hr == DD_OK, "Cannot create a DirectDraw 1 interface, hr = %08lx\n", hr);
     hr = IDirectDraw_QueryInterface(dd1, &IID_IDirect3D3, (void **) &d3d3);
-    ok(hr == D3D_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirectDraw_QueryInterface returned %08lx\n", hr);
 
     hr = IDirect3D3_EnumDevices(d3d3, NULL, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirect3D3_EnumDevices returned 0x%08x\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "IDirect3D3_EnumDevices returned 0x%08lx\n", hr);
 
     ver = 3;
     IDirect3D3_EnumDevices(d3d3, enumDevicesCallback, &ver);
@@ -798,12 +798,12 @@ static void CapsTest(void)
     IDirectDraw_Release(dd1);
 
     hr = DirectDrawCreate(NULL, &dd1, NULL);
-    ok(hr == DD_OK, "Cannot create a DirectDraw 1 interface, hr = %08x\n", hr);
+    ok(hr == DD_OK, "Cannot create a DirectDraw 1 interface, hr = %08lx\n", hr);
     hr = IDirectDraw_QueryInterface(dd1, &IID_IDirect3D2, (void **) &d3d2);
-    ok(hr == D3D_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirectDraw_QueryInterface returned %08lx\n", hr);
 
     hr = IDirect3D2_EnumDevices(d3d2, NULL, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirect3D2_EnumDevices returned 0x%08x\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "IDirect3D2_EnumDevices returned 0x%08lx\n", hr);
 
     ver = 2;
     IDirect3D2_EnumDevices(d3d2, enumDevicesCallback, &ver);
@@ -828,17 +828,17 @@ static BOOL D3D1_createObjects(void)
 
     /* An IDirect3DDevice cannot be queryInterfaced from an IDirect3DDevice7 on windows */
     hr = DirectDrawCreate(NULL, &DirectDraw1, NULL);
-    ok(hr==DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreate returned: %x\n", hr);
+    ok(hr==DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreate returned: %lx\n", hr);
     if (!DirectDraw1) {
         return FALSE;
     }
 
     hr = IDirectDraw_SetCooperativeLevel(DirectDraw1, NULL, DDSCL_NORMAL);
-    ok(hr==DD_OK, "SetCooperativeLevel returned: %x\n", hr);
+    ok(hr==DD_OK, "SetCooperativeLevel returned: %lx\n", hr);
 
     hr = IDirectDraw_QueryInterface(DirectDraw1, &IID_IDirect3D, (void**) &Direct3D1);
     if (hr == E_NOINTERFACE) return FALSE;
-    ok(hr==DD_OK, "QueryInterface returned: %x\n", hr);
+    ok(hr==DD_OK, "QueryInterface returned: %lx\n", hr);
     if (!Direct3D1) {
         return FALSE;
     }
@@ -856,7 +856,7 @@ static BOOL D3D1_createObjects(void)
     }
 
     hr = IDirectDrawSurface_QueryInterface(Surface1, &IID_IDirect3DRGBDevice, (void **) &Direct3DDevice1);
-    ok(hr==D3D_OK || hr==DDERR_NOPALETTEATTACHED || hr==E_OUTOFMEMORY, "CreateDevice returned: %x\n", hr);
+    ok(hr==D3D_OK || hr==DDERR_NOPALETTEATTACHED || hr==E_OUTOFMEMORY, "CreateDevice returned: %lx\n", hr);
     if(!Direct3DDevice1) {
         return FALSE;
     }
@@ -868,22 +868,22 @@ static BOOL D3D1_createObjects(void)
     desc.dwBufferSize = 128;
     desc.lpData = NULL;
     hr = IDirect3DDevice_CreateExecuteBuffer(Direct3DDevice1, &desc, &ExecuteBuffer, NULL);
-    ok(hr == D3D_OK, "IDirect3DDevice_CreateExecuteBuffer failed: %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice_CreateExecuteBuffer failed: %08lx\n", hr);
     if(!ExecuteBuffer) {
         return FALSE;
     }
 
     hr = IDirect3D_CreateViewport(Direct3D1, &Viewport, NULL);
-    ok(hr == D3D_OK, "IDirect3D_CreateViewport failed: %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3D_CreateViewport failed: %08lx\n", hr);
     if(!Viewport) {
         return FALSE;
     }
 
     hr = IDirect3DViewport_Initialize(Viewport, Direct3D1);
-    ok(hr == DDERR_ALREADYINITIALIZED, "IDirect3DViewport_Initialize returned %08x\n", hr);
+    ok(hr == DDERR_ALREADYINITIALIZED, "IDirect3DViewport_Initialize returned %08lx\n", hr);
 
     hr = IDirect3DDevice_AddViewport(Direct3DDevice1, Viewport);
-    ok(hr == D3D_OK, "IDirect3DDevice_AddViewport returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice_AddViewport returned %08lx\n", hr);
     vp_data.dwSize = sizeof(vp_data);
     vp_data.dwX = 0;
     vp_data.dwY = 0;
@@ -896,10 +896,10 @@ static BOOL D3D1_createObjects(void)
     vp_data.dvMinZ = 0;
     vp_data.dvMaxZ = 1;
     hr = IDirect3DViewport_SetViewport(Viewport, &vp_data);
-    ok(hr == D3D_OK, "IDirect3DViewport_SetViewport returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DViewport_SetViewport returned %08lx\n", hr);
 
     hr = IDirect3D_CreateLight(Direct3D1, &Light, NULL);
-    ok(hr == D3D_OK, "IDirect3D_CreateLight failed: %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3D_CreateLight failed: %08lx\n", hr);
     if (!Light)
         return FALSE;
 
@@ -929,14 +929,14 @@ static void ViewportTest(void)
     *(DWORD*)&infinity = 0x7f800000;
 
     hr = IDirect3DDevice_AddViewport(Direct3DDevice1, Viewport);
-    ok(hr == D3D_OK, "IDirect3DDevice_AddViewport returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice_AddViewport returned %08lx\n", hr);
 
     hr = IDirect3DViewport_QueryInterface(Viewport, &IID_IDirect3DViewport2, (void**) &Viewport2);
-    ok(hr==D3D_OK, "QueryInterface returned: %x\n", hr);
+    ok(hr==D3D_OK, "QueryInterface returned: %lx\n", hr);
     ok(Viewport2 == (IDirect3DViewport2 *)Viewport, "IDirect3DViewport2 iface different from IDirect3DViewport\n");
 
     hr = IDirect3DViewport_QueryInterface(Viewport, &IID_IDirect3DViewport3, (void**) &Viewport3);
-    ok(hr==D3D_OK, "QueryInterface returned: %x\n", hr);
+    ok(hr==D3D_OK, "QueryInterface returned: %lx\n", hr);
     ok(Viewport3 == (IDirect3DViewport3 *)Viewport, "IDirect3DViewport3 iface different from IDirect3DViewport\n");
     IDirect3DViewport3_Release(Viewport3);
 
@@ -965,18 +965,18 @@ static void ViewportTest(void)
     vp2_data.dvMaxZ = 0.9;
 
     hr = IDirect3DViewport2_SetViewport(Viewport2, &vp1_data);
-    ok(hr == D3D_OK, "IDirect3DViewport2_SetViewport returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DViewport2_SetViewport returned %08lx\n", hr);
 
     memset(&ret_vp1_data, 0xff, sizeof(ret_vp1_data));
     ret_vp1_data.dwSize = sizeof(vp1_data);
 
     hr = IDirect3DViewport2_GetViewport(Viewport2, &ret_vp1_data);
-    ok(hr == D3D_OK, "IDirect3DViewport2_GetViewport returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DViewport2_GetViewport returned %08lx\n", hr);
 
-    ok(ret_vp1_data.dwX == vp1_data.dwX, "dwX is %u, expected %u\n", ret_vp1_data.dwX, vp1_data.dwX);
-    ok(ret_vp1_data.dwY == vp1_data.dwY, "dwY is %u, expected %u\n", ret_vp1_data.dwY, vp1_data.dwY);
-    ok(ret_vp1_data.dwWidth == vp1_data.dwWidth, "dwWidth is %u, expected %u\n", ret_vp1_data.dwWidth, vp1_data.dwWidth);
-    ok(ret_vp1_data.dwHeight == vp1_data.dwHeight, "dwHeight is %u, expected %u\n", ret_vp1_data.dwHeight, vp1_data.dwHeight);
+    ok(ret_vp1_data.dwX == vp1_data.dwX, "dwX is %lu, expected %lu\n", ret_vp1_data.dwX, vp1_data.dwX);
+    ok(ret_vp1_data.dwY == vp1_data.dwY, "dwY is %lu, expected %lu\n", ret_vp1_data.dwY, vp1_data.dwY);
+    ok(ret_vp1_data.dwWidth == vp1_data.dwWidth, "dwWidth is %lu, expected %lu\n", ret_vp1_data.dwWidth, vp1_data.dwWidth);
+    ok(ret_vp1_data.dwHeight == vp1_data.dwHeight, "dwHeight is %lu, expected %lu\n", ret_vp1_data.dwHeight, vp1_data.dwHeight);
     ok(ret_vp1_data.dvMaxX == vp1_data.dvMaxX, "dvMaxX is %f, expected %f\n", ret_vp1_data.dvMaxX, vp1_data.dvMaxX);
     ok(ret_vp1_data.dvMaxY == vp1_data.dvMaxY, "dvMaxY is %f, expected %f\n", ret_vp1_data.dvMaxY, vp1_data.dvMaxY);
     todo_wine ok(ret_vp1_data.dvScaleX == infinity, "dvScaleX is %f, expected %f\n", ret_vp1_data.dvScaleX, infinity);
@@ -985,18 +985,18 @@ static void ViewportTest(void)
     ok(ret_vp1_data.dvMaxZ == 1.0, "dvMaxZ is %f, expected 1.0\n", ret_vp1_data.dvMaxZ);
 
     hr = IDirect3DViewport2_SetViewport2(Viewport2, &vp2_data);
-    ok(hr == D3D_OK, "IDirect3DViewport2_SetViewport2 returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DViewport2_SetViewport2 returned %08lx\n", hr);
 
     memset(&ret_vp2_data, 0xff, sizeof(ret_vp2_data));
     ret_vp2_data.dwSize = sizeof(vp2_data);
 
     hr = IDirect3DViewport2_GetViewport2(Viewport2, &ret_vp2_data);
-    ok(hr == D3D_OK, "IDirect3DViewport2_GetViewport2 returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DViewport2_GetViewport2 returned %08lx\n", hr);
 
-    ok(ret_vp2_data.dwX == vp2_data.dwX, "dwX is %u, expected %u\n", ret_vp2_data.dwX, vp2_data.dwX);
-    ok(ret_vp2_data.dwY == vp2_data.dwY, "dwY is %u, expected %u\n", ret_vp2_data.dwY, vp2_data.dwY);
-    ok(ret_vp2_data.dwWidth == vp2_data.dwWidth, "dwWidth is %u, expected %u\n", ret_vp2_data.dwWidth, vp2_data.dwWidth);
-    ok(ret_vp2_data.dwHeight == vp2_data.dwHeight, "dwHeight is %u, expected %u\n", ret_vp2_data.dwHeight, vp2_data.dwHeight);
+    ok(ret_vp2_data.dwX == vp2_data.dwX, "dwX is %lu, expected %lu\n", ret_vp2_data.dwX, vp2_data.dwX);
+    ok(ret_vp2_data.dwY == vp2_data.dwY, "dwY is %lu, expected %lu\n", ret_vp2_data.dwY, vp2_data.dwY);
+    ok(ret_vp2_data.dwWidth == vp2_data.dwWidth, "dwWidth is %lu, expected %lu\n", ret_vp2_data.dwWidth, vp2_data.dwWidth);
+    ok(ret_vp2_data.dwHeight == vp2_data.dwHeight, "dwHeight is %lu, expected %lu\n", ret_vp2_data.dwHeight, vp2_data.dwHeight);
     ok(ret_vp2_data.dvClipX == vp2_data.dvClipX, "dvClipX is %f, expected %f\n", ret_vp2_data.dvClipX, vp2_data.dvClipX);
     ok(ret_vp2_data.dvClipY == vp2_data.dvClipY, "dvClipY is %f, expected %f\n", ret_vp2_data.dvClipY, vp2_data.dvClipY);
     ok(ret_vp2_data.dvClipWidth == vp2_data.dvClipWidth, "dvClipWidth is %f, expected %f\n",
@@ -1010,12 +1010,12 @@ static void ViewportTest(void)
     ret_vp1_data.dwSize = sizeof(vp1_data);
 
     hr = IDirect3DViewport2_GetViewport(Viewport2, &ret_vp1_data);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
-    ok(ret_vp1_data.dwX == vp2_data.dwX, "dwX is %u, expected %u.\n", ret_vp1_data.dwX, vp2_data.dwX);
-    ok(ret_vp1_data.dwY == vp2_data.dwY, "dwY is %u, expected %u.\n", ret_vp1_data.dwY, vp2_data.dwY);
-    ok(ret_vp1_data.dwWidth == vp2_data.dwWidth, "dwWidth is %u, expected %u.\n", ret_vp1_data.dwWidth, vp2_data.dwWidth);
-    ok(ret_vp1_data.dwHeight == vp2_data.dwHeight, "dwHeight is %u, expected %u.\n", ret_vp1_data.dwHeight, vp2_data.dwHeight);
+    ok(ret_vp1_data.dwX == vp2_data.dwX, "dwX is %lu, expected %lu.\n", ret_vp1_data.dwX, vp2_data.dwX);
+    ok(ret_vp1_data.dwY == vp2_data.dwY, "dwY is %lu, expected %lu.\n", ret_vp1_data.dwY, vp2_data.dwY);
+    ok(ret_vp1_data.dwWidth == vp2_data.dwWidth, "dwWidth is %lu, expected %lu.\n", ret_vp1_data.dwWidth, vp2_data.dwWidth);
+    ok(ret_vp1_data.dwHeight == vp2_data.dwHeight, "dwHeight is %lu, expected %lu.\n", ret_vp1_data.dwHeight, vp2_data.dwHeight);
     ok(ret_vp1_data.dvMaxX == vp1_data.dvMaxX, "dvMaxX is %f, expected %f.\n", ret_vp1_data.dvMaxX, vp1_data.dvMaxX);
     ok(ret_vp1_data.dvMaxY == vp1_data.dvMaxY, "dvMaxY is %f, expected %f.\n", ret_vp1_data.dvMaxY, vp1_data.dvMaxY);
     ok(ret_vp1_data.dvScaleX == infinity, "dvScaleX is %f, expected %f.\n", ret_vp1_data.dvScaleX, infinity);
@@ -1024,18 +1024,18 @@ static void ViewportTest(void)
     ok(ret_vp1_data.dvMaxZ == 1.0, "dvMaxZ is %f, expected 1.0.\n", ret_vp1_data.dvMaxZ);
 
     hr = IDirect3DViewport2_SetViewport2(Viewport2, &vp2_data);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&ret_vp2_data, 0xff, sizeof(ret_vp2_data));
     ret_vp2_data.dwSize = sizeof(vp2_data);
 
     hr = IDirect3DViewport2_GetViewport2(Viewport2, &ret_vp2_data);
-    ok(hr == D3D_OK, "IDirect3DViewport2_GetViewport2 returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DViewport2_GetViewport2 returned %08lx\n", hr);
 
-    ok(ret_vp2_data.dwX == vp2_data.dwX, "dwX is %u, expected %u\n", ret_vp2_data.dwX, vp2_data.dwX);
-    ok(ret_vp2_data.dwY == vp2_data.dwY, "dwY is %u, expected %u\n", ret_vp2_data.dwY, vp2_data.dwY);
-    ok(ret_vp2_data.dwWidth == vp2_data.dwWidth, "dwWidth is %u, expected %u\n", ret_vp2_data.dwWidth, vp2_data.dwWidth);
-    ok(ret_vp2_data.dwHeight == vp2_data.dwHeight, "dwHeight is %u, expected %u\n", ret_vp2_data.dwHeight, vp2_data.dwHeight);
+    ok(ret_vp2_data.dwX == vp2_data.dwX, "dwX is %lu, expected %lu\n", ret_vp2_data.dwX, vp2_data.dwX);
+    ok(ret_vp2_data.dwY == vp2_data.dwY, "dwY is %lu, expected %lu\n", ret_vp2_data.dwY, vp2_data.dwY);
+    ok(ret_vp2_data.dwWidth == vp2_data.dwWidth, "dwWidth is %lu, expected %lu\n", ret_vp2_data.dwWidth, vp2_data.dwWidth);
+    ok(ret_vp2_data.dwHeight == vp2_data.dwHeight, "dwHeight is %lu, expected %lu\n", ret_vp2_data.dwHeight, vp2_data.dwHeight);
     ok(ret_vp2_data.dvClipX == vp2_data.dvClipX, "dvClipX is %f, expected %f\n", ret_vp2_data.dvClipX, vp2_data.dvClipX);
     ok(ret_vp2_data.dvClipY == vp2_data.dvClipY, "dvClipY is %f, expected %f\n", ret_vp2_data.dvClipY, vp2_data.dvClipY);
     ok(ret_vp2_data.dvClipWidth == vp2_data.dvClipWidth, "dvClipWidth is %f, expected %f\n",
@@ -1046,18 +1046,18 @@ static void ViewportTest(void)
     ok(ret_vp2_data.dvMaxZ == vp2_data.dvMaxZ, "dvMaxZ is %f, expected %f\n", ret_vp2_data.dvMaxZ, vp2_data.dvMaxZ);
 
     hr = IDirect3DViewport2_SetViewport(Viewport2, &vp1_data);
-    ok(hr == D3D_OK, "IDirect3DViewport2_SetViewport returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DViewport2_SetViewport returned %08lx\n", hr);
 
     memset(&ret_vp1_data, 0xff, sizeof(ret_vp1_data));
     ret_vp1_data.dwSize = sizeof(vp1_data);
 
     hr = IDirect3DViewport2_GetViewport(Viewport2, &ret_vp1_data);
-    ok(hr == D3D_OK, "IDirect3DViewport2_GetViewport returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DViewport2_GetViewport returned %08lx\n", hr);
 
-    ok(ret_vp1_data.dwX == vp1_data.dwX, "dwX is %u, expected %u\n", ret_vp1_data.dwX, vp1_data.dwX);
-    ok(ret_vp1_data.dwY == vp1_data.dwY, "dwY is %u, expected %u\n", ret_vp1_data.dwY, vp1_data.dwY);
-    ok(ret_vp1_data.dwWidth == vp1_data.dwWidth, "dwWidth is %u, expected %u\n", ret_vp1_data.dwWidth, vp1_data.dwWidth);
-    ok(ret_vp1_data.dwHeight == vp1_data.dwHeight, "dwHeight is %u, expected %u\n", ret_vp1_data.dwHeight, vp1_data.dwHeight);
+    ok(ret_vp1_data.dwX == vp1_data.dwX, "dwX is %lu, expected %lu\n", ret_vp1_data.dwX, vp1_data.dwX);
+    ok(ret_vp1_data.dwY == vp1_data.dwY, "dwY is %lu, expected %lu\n", ret_vp1_data.dwY, vp1_data.dwY);
+    ok(ret_vp1_data.dwWidth == vp1_data.dwWidth, "dwWidth is %lu, expected %lu\n", ret_vp1_data.dwWidth, vp1_data.dwWidth);
+    ok(ret_vp1_data.dwHeight == vp1_data.dwHeight, "dwHeight is %lu, expected %lu\n", ret_vp1_data.dwHeight, vp1_data.dwHeight);
     ok(ret_vp1_data.dvMaxX == vp1_data.dvMaxX, "dvMaxX is %f, expected %f\n", ret_vp1_data.dvMaxX, vp1_data.dvMaxX);
     ok(ret_vp1_data.dvMaxY == vp1_data.dvMaxY, "dvMaxY is %f, expected %f\n", ret_vp1_data.dvMaxY, vp1_data.dvMaxY);
     todo_wine ok(ret_vp1_data.dvScaleX == infinity, "dvScaleX is %f, expected %f\n", ret_vp1_data.dvScaleX, infinity);
@@ -1069,13 +1069,13 @@ static void ViewportTest(void)
     ret_vp2_data.dwSize = sizeof(vp2_data);
 
     hr = IDirect3DViewport2_GetViewport2(Viewport2, &ret_vp2_data);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
-    ok(ret_vp2_data.dwX == vp1_data.dwX, "dwX is %u, expected %u.\n", ret_vp2_data.dwX, vp1_data.dwX);
-    ok(ret_vp2_data.dwY == vp1_data.dwY, "dwY is %u, expected %u.\n", ret_vp2_data.dwY, vp1_data.dwY);
-    ok(ret_vp2_data.dwWidth == vp1_data.dwWidth, "dwWidth is %u, expected %u.\n",
+    ok(ret_vp2_data.dwX == vp1_data.dwX, "dwX is %lu, expected %lu.\n", ret_vp2_data.dwX, vp1_data.dwX);
+    ok(ret_vp2_data.dwY == vp1_data.dwY, "dwY is %lu, expected %lu.\n", ret_vp2_data.dwY, vp1_data.dwY);
+    ok(ret_vp2_data.dwWidth == vp1_data.dwWidth, "dwWidth is %lu, expected %lu.\n",
             ret_vp2_data.dwWidth, vp1_data.dwWidth);
-    ok(ret_vp2_data.dwHeight == vp1_data.dwHeight, "dwHeight is %u, expected %u.\n",
+    ok(ret_vp2_data.dwHeight == vp1_data.dwHeight, "dwHeight is %lu, expected %lu.\n",
             ret_vp2_data.dwHeight, vp1_data.dwHeight);
     todo_wine ok(ret_vp2_data.dvClipX == vp2_data.dvClipX, "dvClipX is %f, expected %f.\n",
             ret_vp2_data.dvClipX, vp2_data.dvClipX);
@@ -1091,7 +1091,7 @@ static void ViewportTest(void)
     IDirect3DViewport2_Release(Viewport2);
 
     hr = IDirect3DDevice_DeleteViewport(Direct3DDevice1, Viewport);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 }
 
 static void Direct3D1Test(void)
@@ -1107,14 +1107,14 @@ static void Direct3D1Test(void)
 
     /* Interface consistency check. */
     hr = IDirect3DDevice_GetDirect3D(Direct3DDevice1, &Direct3D_alt);
-    ok(hr == D3D_OK, "IDirect3DDevice_GetDirect3D failed: %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice_GetDirect3D failed: %08lx\n", hr);
     ok(Direct3D_alt == Direct3D1, "Direct3D1 struct pointer mismatch: %p != %p\n", Direct3D_alt, Direct3D1);
     IDirect3D_Release(Direct3D_alt);
 
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
     hr = IDirect3DExecuteBuffer_Lock(ExecuteBuffer, &desc);
-    ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Lock failed: %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Lock failed: %08lx\n", hr);
 
     memset(desc.lpData, 0, 128);
     instr = desc.lpData;
@@ -1132,16 +1132,16 @@ static void Direct3D1Test(void)
     instr[idx].bSize = 0;
     instr[idx].wCount = 0;
     hr = IDirect3DExecuteBuffer_Unlock(ExecuteBuffer);
-    ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Unlock failed: %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Unlock failed: %08lx\n", hr);
 
     hr = IDirect3DDevice_Execute(Direct3DDevice1, ExecuteBuffer, Viewport, D3DEXECUTE_CLIPPED);
-    ok(hr == D3D_OK, "IDirect3DDevice_Execute returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice_Execute returned %08lx\n", hr);
 
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
 
     hr = IDirect3DExecuteBuffer_Lock(ExecuteBuffer, &desc);
-    ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Lock failed: %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Lock failed: %08lx\n", hr);
 
     memset(desc.lpData, 0, 128);
     instr = desc.lpData;
@@ -1160,17 +1160,17 @@ static void Direct3D1Test(void)
     instr[0].bSize = 0;
     instr[0].wCount = 0;
     hr = IDirect3DExecuteBuffer_Unlock(ExecuteBuffer);
-    ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Unlock failed: %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Unlock failed: %08lx\n", hr);
 
     hr = IDirect3DDevice_Execute(Direct3DDevice1, ExecuteBuffer, Viewport, D3DEXECUTE_CLIPPED);
-    ok(hr == D3D_OK, "IDirect3DDevice_Execute returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice_Execute returned %08lx\n", hr);
 
     /* Test rendering 0 triangles */
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
 
     hr = IDirect3DExecuteBuffer_Lock(ExecuteBuffer, &desc);
-    ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Lock failed: %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Lock failed: %08lx\n", hr);
 
     memset(desc.lpData, 0, 128);
     instr = desc.lpData;
@@ -1183,29 +1183,29 @@ static void Direct3D1Test(void)
     instr->bSize = 0;
     instr->wCount = 0;
     hr = IDirect3DExecuteBuffer_Unlock(ExecuteBuffer);
-    ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Unlock failed: %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DExecuteBuffer_Unlock failed: %08lx\n", hr);
 
     hr = IDirect3DDevice_Execute(Direct3DDevice1, ExecuteBuffer, Viewport, D3DEXECUTE_CLIPPED);
-    ok(hr == D3D_OK, "IDirect3DDevice_Execute returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice_Execute returned %08lx\n", hr);
 
     hr = IDirect3DDevice_DeleteViewport(Direct3DDevice1, Viewport);
-    ok(hr == D3D_OK, "IDirect3DDevice_DeleteViewport returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice_DeleteViewport returned %08lx\n", hr);
 
     hr = IDirect3DViewport_AddLight(Viewport, Light);
-    ok(hr == D3D_OK, "IDirect3DViewport_AddLight returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DViewport_AddLight returned %08lx\n", hr);
     refcount = getRefcount((IUnknown*) Light);
-    ok(refcount == 2, "Refcount should be 2, returned is %d\n", refcount);
+    ok(refcount == 2, "Refcount should be 2, returned is %ld\n", refcount);
 
     hr = IDirect3DViewport_NextLight(Viewport, NULL, &d3dlight, D3DNEXT_HEAD);
-    ok(hr == D3D_OK, "IDirect3DViewport_AddLight returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DViewport_AddLight returned %08lx\n", hr);
     ok(d3dlight == Light, "Got different light returned %p, expected %p\n", d3dlight, Light);
     refcount = getRefcount((IUnknown*) Light);
-    ok(refcount == 3, "Refcount should be 2, returned is %d\n", refcount);
+    ok(refcount == 3, "Refcount should be 2, returned is %ld\n", refcount);
 
     hr = IDirect3DViewport_DeleteLight(Viewport, Light);
-    ok(hr == D3D_OK, "IDirect3DViewport_DeleteLight returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DViewport_DeleteLight returned %08lx\n", hr);
     refcount = getRefcount((IUnknown*) Light);
-    ok(refcount == 2, "Refcount should be 2, returned is %d\n", refcount);
+    ok(refcount == 2, "Refcount should be 2, returned is %ld\n", refcount);
 
     IDirect3DLight_Release(Light);
 }
@@ -1248,7 +1248,7 @@ static void TextureLoadTest(void)
     U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 8;
 
     hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &TexSurface, NULL);
-    ok(hr==D3D_OK, "CreateSurface returned: %x\n", hr);
+    ok(hr==D3D_OK, "CreateSurface returned: %lx\n", hr);
     if (FAILED(hr)) {
         skip("IDirectDraw_CreateSurface failed; skipping further tests\n");
         goto cleanup;
@@ -1256,14 +1256,14 @@ static void TextureLoadTest(void)
 
     hr = IDirectDrawSurface_QueryInterface(TexSurface, &IID_IDirect3DTexture,
                 (void *)&Texture);
-    ok(hr==D3D_OK, "IDirectDrawSurface_QueryInterface returned: %x\n", hr);
+    ok(hr==D3D_OK, "IDirectDrawSurface_QueryInterface returned: %lx\n", hr);
     if (FAILED(hr)) {
         skip("Can't get IDirect3DTexture interface; skipping further tests\n");
         goto cleanup;
     }
 
     hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &TexSurface2, NULL);
-    ok(hr==D3D_OK, "CreateSurface returned: %x\n", hr);
+    ok(hr==D3D_OK, "CreateSurface returned: %lx\n", hr);
     if (FAILED(hr)) {
         skip("IDirectDraw_CreateSurface failed; skipping further tests\n");
         goto cleanup;
@@ -1271,7 +1271,7 @@ static void TextureLoadTest(void)
 
     hr = IDirectDrawSurface_QueryInterface(TexSurface2, &IID_IDirect3DTexture,
                 (void *)&Texture2);
-    ok(hr==D3D_OK, "IDirectDrawSurface_QueryInterface returned: %x\n", hr);
+    ok(hr==D3D_OK, "IDirectDrawSurface_QueryInterface returned: %lx\n", hr);
     if (FAILED(hr)) {
         skip("Can't get IDirect3DTexture interface; skipping further tests\n");
         goto cleanup;
@@ -1279,11 +1279,11 @@ static void TextureLoadTest(void)
 
     /* test load of Texture to Texture */
     hr = IDirect3DTexture_Load(Texture, Texture);
-    ok(hr == DD_OK, "IDirect3DTexture_Load returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirect3DTexture_Load returned %08lx\n", hr);
 
     /* test Load when both textures have no palette */
     hr = IDirect3DTexture_Load(Texture2, Texture);
-    ok(hr == DD_OK, "IDirect3DTexture_Load returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirect3DTexture_Load returned %08lx\n", hr);
 
     for (i = 0; i < 256; i++) {
         table1[i].peRed = i;
@@ -1293,7 +1293,7 @@ static void TextureLoadTest(void)
     }
 
     hr = IDirectDraw_CreatePalette(DirectDraw1, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, table1, &palette, NULL);
-    ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
+    ok(hr == DD_OK, "CreatePalette returned %08lx\n", hr);
     if (FAILED(hr)) {
         skip("IDirectDraw_CreatePalette failed; skipping further tests\n");
         goto cleanup;
@@ -1301,9 +1301,9 @@ static void TextureLoadTest(void)
 
     /* test Load when source texture has palette and destination has no palette */
     hr = IDirectDrawSurface_SetPalette(TexSurface, palette);
-    ok(hr == DD_OK, "IDirectDrawSurface_SetPalette returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface_SetPalette returned %08lx\n", hr);
     hr = IDirect3DTexture_Load(Texture2, Texture);
-    ok(hr == DDERR_NOPALETTEATTACHED, "IDirect3DTexture_Load returned %08x\n", hr);
+    ok(hr == DDERR_NOPALETTEATTACHED, "IDirect3DTexture_Load returned %08lx\n", hr);
 
     for (i = 0; i < 256; i++) {
         table2[i].peRed = 255 - i;
@@ -1313,7 +1313,7 @@ static void TextureLoadTest(void)
     }
 
     hr = IDirectDraw_CreatePalette(DirectDraw1, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, table2, &palette2, NULL);
-    ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
+    ok(hr == DD_OK, "CreatePalette returned %08lx\n", hr);
     if (FAILED(hr)) {
         skip("IDirectDraw_CreatePalette failed; skipping further tests\n");
         goto cleanup;
@@ -1321,38 +1321,38 @@ static void TextureLoadTest(void)
 
     /* test Load when source has no palette and destination has a palette */
     hr = IDirectDrawSurface_SetPalette(TexSurface, NULL);
-    ok(hr == DD_OK, "IDirectDrawSurface_SetPalette returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface_SetPalette returned %08lx\n", hr);
     hr = IDirectDrawSurface_SetPalette(TexSurface2, palette2);
-    ok(hr == DD_OK, "IDirectDrawSurface_SetPalette returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface_SetPalette returned %08lx\n", hr);
     hr = IDirect3DTexture_Load(Texture2, Texture);
-    ok(hr == DD_OK, "IDirect3DTexture_Load returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirect3DTexture_Load returned %08lx\n", hr);
     hr = IDirectDrawSurface_GetPalette(TexSurface2, &palette_tmp);
-    ok(hr == DD_OK, "IDirectDrawSurface_GetPalette returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface_GetPalette returned %08lx\n", hr);
     if (!palette_tmp) {
         skip("IDirectDrawSurface_GetPalette failed; skipping color table check\n");
         goto cleanup;
     } else {
         hr = IDirectDrawPalette_GetEntries(palette_tmp, 0, 0, 256, table_tmp);
-        ok(hr == DD_OK, "IDirectDrawPalette_GetEntries returned %08x\n", hr);
+        ok(hr == DD_OK, "IDirectDrawPalette_GetEntries returned %08lx\n", hr);
         ok(colortables_check_equality(table2, table_tmp), "Unexpected palettized texture color table\n");
         IDirectDrawPalette_Release(palette_tmp);
     }
 
     /* test Load when both textures have palettes */
     hr = IDirectDrawSurface_SetPalette(TexSurface, palette);
-    ok(hr == DD_OK, "IDirectDrawSurface_SetPalette returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface_SetPalette returned %08lx\n", hr);
     hr = IDirect3DTexture_Load(Texture2, Texture);
-    ok(hr == DD_OK, "IDirect3DTexture_Load returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirect3DTexture_Load returned %08lx\n", hr);
     hr = IDirect3DTexture_Load(Texture2, Texture);
-    ok(hr == DD_OK, "IDirect3DTexture_Load returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirect3DTexture_Load returned %08lx\n", hr);
     hr = IDirectDrawSurface_GetPalette(TexSurface2, &palette_tmp);
-    ok(hr == DD_OK, "IDirectDrawSurface_GetPalette returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface_GetPalette returned %08lx\n", hr);
     if (!palette_tmp) {
         skip("IDirectDrawSurface_GetPalette failed; skipping color table check\n");
         goto cleanup;
     } else {
         hr = IDirectDrawPalette_GetEntries(palette_tmp, 0, 0, 256, table_tmp);
-        ok(hr == DD_OK, "IDirectDrawPalette_GetEntries returned %08x\n", hr);
+        ok(hr == DD_OK, "IDirectDrawPalette_GetEntries returned %08lx\n", hr);
         ok(colortables_check_equality(table1, table_tmp), "Unexpected palettized texture color table\n");
         IDirectDrawPalette_Release(palette_tmp);
     }
@@ -1383,10 +1383,10 @@ static void VertexBufferDescTest(void)
     desc.dwFVF = D3DFVF_XYZ;
     desc.dwNumVertices = 1;
     rc = IDirect3D7_CreateVertexBuffer(lpD3D, &desc, &lpVBufSrc, 0);
-    ok(rc==D3D_OK || rc==E_OUTOFMEMORY, "CreateVertexBuffer returned: %x\n", rc);
+    ok(rc==D3D_OK || rc==E_OUTOFMEMORY, "CreateVertexBuffer returned: %lx\n", rc);
     if (!lpVBufSrc)
     {
-        trace("IDirect3D7::CreateVertexBuffer() failed with an error %x\n", rc);
+        trace("IDirect3D7::CreateVertexBuffer() failed with an error %lx\n", rc);
         goto out;
     }
 
@@ -1397,9 +1397,9 @@ static void VertexBufferDescTest(void)
         skip("GetVertexBuffer Failed!\n");
     ok( mem.desc2.dwSize == sizeof(D3DVERTEXBUFFERDESC)*2, "Size returned from GetVertexBufferDesc does not match the value put in\n" );
     ok( mem.buffer[sizeof(D3DVERTEXBUFFERDESC)] == 0x12, "GetVertexBufferDesc cleared outside of the struct! (dwSize was double the size of the struct)\n");
-    ok( mem.desc2.dwCaps == desc.dwCaps, "dwCaps returned differs. Got %x, expected %x\n", mem.desc2.dwCaps, desc.dwCaps);
-    ok( mem.desc2.dwFVF == desc.dwFVF, "dwFVF returned differs. Got %x, expected %x\n", mem.desc2.dwFVF, desc.dwFVF);
-    ok (mem.desc2.dwNumVertices == desc.dwNumVertices, "dwNumVertices returned differs. Got %x, expected %x\n", mem.desc2.dwNumVertices, desc.dwNumVertices);
+    ok( mem.desc2.dwCaps == desc.dwCaps, "dwCaps returned differs. Got %lx, expected %lx\n", mem.desc2.dwCaps, desc.dwCaps);
+    ok( mem.desc2.dwFVF == desc.dwFVF, "dwFVF returned differs. Got %lx, expected %lx\n", mem.desc2.dwFVF, desc.dwFVF);
+    ok (mem.desc2.dwNumVertices == desc.dwNumVertices, "dwNumVertices returned differs. Got %lx, expected %lx\n", mem.desc2.dwNumVertices, desc.dwNumVertices);
 
     memset(mem.buffer, 0x12, sizeof(mem.buffer));
     mem.desc2.dwSize = 0;
@@ -1408,9 +1408,9 @@ static void VertexBufferDescTest(void)
         skip("GetVertexBuffer Failed!\n");
     ok( mem.desc2.dwSize == 0, "Size returned from GetVertexBufferDesc does not match the value put in\n" );
     ok( mem.buffer[sizeof(D3DVERTEXBUFFERDESC)] == 0x12, "GetVertexBufferDesc cleared outside of the struct! (dwSize was 0)\n");
-    ok( mem.desc2.dwCaps == desc.dwCaps, "dwCaps returned differs. Got %x, expected %x\n", mem.desc2.dwCaps, desc.dwCaps);
-    ok( mem.desc2.dwFVF == desc.dwFVF, "dwFVF returned differs. Got %x, expected %x\n", mem.desc2.dwFVF, desc.dwFVF);
-    ok (mem.desc2.dwNumVertices == desc.dwNumVertices, "dwNumVertices returned differs. Got %x, expected %x\n", mem.desc2.dwNumVertices, desc.dwNumVertices);
+    ok( mem.desc2.dwCaps == desc.dwCaps, "dwCaps returned differs. Got %lx, expected %lx\n", mem.desc2.dwCaps, desc.dwCaps);
+    ok( mem.desc2.dwFVF == desc.dwFVF, "dwFVF returned differs. Got %lx, expected %lx\n", mem.desc2.dwFVF, desc.dwFVF);
+    ok (mem.desc2.dwNumVertices == desc.dwNumVertices, "dwNumVertices returned differs. Got %lx, expected %lx\n", mem.desc2.dwNumVertices, desc.dwNumVertices);
 
     memset(mem.buffer, 0x12, sizeof(mem.buffer));
     mem.desc2.dwSize = sizeof(D3DVERTEXBUFFERDESC);
@@ -1419,9 +1419,9 @@ static void VertexBufferDescTest(void)
         skip("GetVertexBuffer Failed!\n");
     ok( mem.desc2.dwSize == sizeof(D3DVERTEXBUFFERDESC), "Size returned from GetVertexBufferDesc does not match the value put in\n" );
     ok( mem.buffer[sizeof(D3DVERTEXBUFFERDESC)] == 0x12, "GetVertexBufferDesc cleared outside of the struct! (dwSize was the size of the struct)\n");
-    ok( mem.desc2.dwCaps == desc.dwCaps, "dwCaps returned differs. Got %x, expected %x\n", mem.desc2.dwCaps, desc.dwCaps);
-    ok( mem.desc2.dwFVF == desc.dwFVF, "dwFVF returned differs. Got %x, expected %x\n", mem.desc2.dwFVF, desc.dwFVF);
-    ok (mem.desc2.dwNumVertices == desc.dwNumVertices, "dwNumVertices returned differs. Got %x, expected %x\n", mem.desc2.dwNumVertices, desc.dwNumVertices);
+    ok( mem.desc2.dwCaps == desc.dwCaps, "dwCaps returned differs. Got %lx, expected %lx\n", mem.desc2.dwCaps, desc.dwCaps);
+    ok( mem.desc2.dwFVF == desc.dwFVF, "dwFVF returned differs. Got %lx, expected %lx\n", mem.desc2.dwFVF, desc.dwFVF);
+    ok (mem.desc2.dwNumVertices == desc.dwNumVertices, "dwNumVertices returned differs. Got %lx, expected %lx\n", mem.desc2.dwNumVertices, desc.dwNumVertices);
 
 out:
     IDirect3DVertexBuffer7_Release(lpVBufSrc);
@@ -1432,7 +1432,7 @@ static void SetMaterialTest(void)
     HRESULT rc;
 
     rc =IDirect3DDevice7_SetMaterial(lpD3DDevice, NULL);
-    ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %x\n", rc);
+    ok(rc == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %lx\n", rc);
 }
 
 static void SetRenderTargetTest(void)
@@ -1452,7 +1452,7 @@ static void SetRenderTargetTest(void)
     ddsd.dwHeight = 64;
 
     hr = IDirectDraw7_CreateSurface(lpDD, &ddsd, &newrt, NULL);
-    ok(hr == DD_OK, "IDirectDraw7_CreateSurface failed, hr=0x%08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw7_CreateSurface failed, hr=0x%08lx\n", hr);
     if(FAILED(hr))
     {
         skip("Skipping SetRenderTarget test\n");
@@ -1471,7 +1471,7 @@ static void SetRenderTargetTest(void)
     U3(U4(ddsd2).ddpfPixelFormat).dwZBitMask = 0x0000FFFF;
 
     hr = IDirectDraw7_CreateSurface(lpDD, &ddsd2, &failrt, NULL);
-    ok(hr == DD_OK, "IDirectDraw7_CreateSurface failed, hr=0x%08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw7_CreateSurface failed, hr=0x%08lx\n", hr);
 
     memset(&vp, 0, sizeof(vp));
     vp.dwX = 10;
@@ -1481,46 +1481,46 @@ static void SetRenderTargetTest(void)
     vp.dvMinZ = 0.25;
     vp.dvMaxZ = 0.75;
     hr = IDirect3DDevice7_SetViewport(lpD3DDevice, &vp);
-    ok(hr == D3D_OK, "IDirect3DDevice7_SetViewport failed, hr=0x%08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_SetViewport failed, hr=0x%08lx\n", hr);
 
     hr = IDirect3DDevice7_GetRenderTarget(lpD3DDevice, &oldrt);
-    ok(hr == DD_OK, "IDirect3DDevice7_GetRenderTarget failed, hr=0x%08x\n", hr);
+    ok(hr == DD_OK, "IDirect3DDevice7_GetRenderTarget failed, hr=0x%08lx\n", hr);
 
     refcount = getRefcount((IUnknown*) oldrt);
-    ok(refcount == 3, "Refcount should be 3, returned is %d\n", refcount);
+    ok(refcount == 3, "Refcount should be 3, returned is %ld\n", refcount);
 
     refcount = getRefcount((IUnknown*) failrt);
-    ok(refcount == 1, "Refcount should be 1, returned is %d\n", refcount);
+    ok(refcount == 1, "Refcount should be 1, returned is %ld\n", refcount);
 
     hr = IDirect3DDevice7_SetRenderTarget(lpD3DDevice, failrt, 0);
     ok(hr != D3D_OK, "IDirect3DDevice7_SetRenderTarget succeeded\n");
 
     refcount = getRefcount((IUnknown*) oldrt);
-    ok(refcount == 2, "Refcount should be 2, returned is %d\n", refcount);
+    ok(refcount == 2, "Refcount should be 2, returned is %ld\n", refcount);
 
     refcount = getRefcount((IUnknown*) failrt);
-    ok(refcount == 2, "Refcount should be 2, returned is %d\n", refcount);
+    ok(refcount == 2, "Refcount should be 2, returned is %ld\n", refcount);
 
     hr = IDirect3DDevice7_GetRenderTarget(lpD3DDevice, &temprt);
-    ok(hr == DD_OK, "IDirect3DDevice7_GetRenderTarget failed, hr=0x%08x\n", hr);
+    ok(hr == DD_OK, "IDirect3DDevice7_GetRenderTarget failed, hr=0x%08lx\n", hr);
     ok(failrt == temprt, "Wrong iface returned\n");
 
     refcount = getRefcount((IUnknown*) failrt);
-    ok(refcount == 3, "Refcount should be 3, returned is %d\n", refcount);
+    ok(refcount == 3, "Refcount should be 3, returned is %ld\n", refcount);
 
     hr = IDirect3DDevice7_SetRenderTarget(lpD3DDevice, newrt, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderTarget failed, hr=0x%08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderTarget failed, hr=0x%08lx\n", hr);
 
     refcount = getRefcount((IUnknown*) failrt);
-    ok(refcount == 2, "Refcount should be 2, returned is %d\n", refcount);
+    ok(refcount == 2, "Refcount should be 2, returned is %ld\n", refcount);
 
     memset(&vp, 0xff, sizeof(vp));
     hr = IDirect3DDevice7_GetViewport(lpD3DDevice, &vp);
-    ok(hr == D3D_OK, "IDirect3DDevice7_GetViewport failed, hr=0x%08x\n", hr);
-    ok(vp.dwX == 10, "vp.dwX is %u, expected 10\n", vp.dwX);
-    ok(vp.dwY == 10, "vp.dwY is %u, expected 10\n", vp.dwY);
-    ok(vp.dwWidth == 246, "vp.dwWidth is %u, expected 246\n", vp.dwWidth);
-    ok(vp.dwHeight == 246, "vp.dwHeight is %u, expected 246\n", vp.dwHeight);
+    ok(hr == D3D_OK, "IDirect3DDevice7_GetViewport failed, hr=0x%08lx\n", hr);
+    ok(vp.dwX == 10, "vp.dwX is %lu, expected 10\n", vp.dwX);
+    ok(vp.dwY == 10, "vp.dwY is %lu, expected 10\n", vp.dwY);
+    ok(vp.dwWidth == 246, "vp.dwWidth is %lu, expected 246\n", vp.dwWidth);
+    ok(vp.dwHeight == 246, "vp.dwHeight is %lu, expected 246\n", vp.dwHeight);
     ok(vp.dvMinZ == 0.25, "vp.dvMinZ is %f, expected 0.25\n", vp.dvMinZ);
     ok(vp.dvMaxZ == 0.75, "vp.dvMaxZ is %f, expected 0.75\n", vp.dvMaxZ);
 
@@ -1532,39 +1532,39 @@ static void SetRenderTargetTest(void)
     vp.dvMinZ = 0.0;
     vp.dvMaxZ = 1.0;
     hr = IDirect3DDevice7_SetViewport(lpD3DDevice, &vp);
-    ok(hr == D3D_OK, "IDirect3DDevice7_SetViewport failed, hr=0x%08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_SetViewport failed, hr=0x%08lx\n", hr);
 
     hr = IDirect3DDevice7_BeginStateBlock(lpD3DDevice);
-    ok(hr == D3D_OK, "IDirect3DDevice7_BeginStateblock failed, hr=0x%08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_BeginStateblock failed, hr=0x%08lx\n", hr);
     hr = IDirect3DDevice7_SetRenderTarget(lpD3DDevice, oldrt, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderTarget failed, hr=0x%08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderTarget failed, hr=0x%08lx\n", hr);
 
     /* Check this twice, before and after ending the stateblock */
     memset(&vp, 0xff, sizeof(vp));
     hr = IDirect3DDevice7_GetViewport(lpD3DDevice, &vp);
-    ok(hr == D3D_OK, "IDirect3DDevice7_GetViewport failed, hr=0x%08x\n", hr);
-    ok(vp.dwX == 0, "vp.dwX is %u, expected 0\n", vp.dwX);
-    ok(vp.dwY == 0, "vp.dwY is %u, expected 0\n", vp.dwY);
-    ok(vp.dwWidth == 64, "vp.dwWidth is %u, expected 64\n", vp.dwWidth);
-    ok(vp.dwHeight == 64, "vp.dwHeight is %u, expected 64\n", vp.dwHeight);
+    ok(hr == D3D_OK, "IDirect3DDevice7_GetViewport failed, hr=0x%08lx\n", hr);
+    ok(vp.dwX == 0, "vp.dwX is %lu, expected 0\n", vp.dwX);
+    ok(vp.dwY == 0, "vp.dwY is %lu, expected 0\n", vp.dwY);
+    ok(vp.dwWidth == 64, "vp.dwWidth is %lu, expected 64\n", vp.dwWidth);
+    ok(vp.dwHeight == 64, "vp.dwHeight is %lu, expected 64\n", vp.dwHeight);
     ok(vp.dvMinZ == 0.0, "vp.dvMinZ is %f, expected 0.0\n", vp.dvMinZ);
     ok(vp.dvMaxZ == 1.0, "vp.dvMaxZ is %f, expected 1.0\n", vp.dvMaxZ);
 
     hr = IDirect3DDevice7_EndStateBlock(lpD3DDevice, &stateblock);
-    ok(hr == D3D_OK, "IDirect3DDevice7_EndStateblock failed, hr=0x%08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_EndStateblock failed, hr=0x%08lx\n", hr);
 
     memset(&vp, 0xff, sizeof(vp));
     hr = IDirect3DDevice7_GetViewport(lpD3DDevice, &vp);
-    ok(hr == D3D_OK, "IDirect3DDevice7_GetViewport failed, hr=0x%08x\n", hr);
-    ok(vp.dwX == 0, "vp.dwX is %u, expected 0\n", vp.dwX);
-    ok(vp.dwY == 0, "vp.dwY is %u, expected 0\n", vp.dwY);
-    ok(vp.dwWidth == 64, "vp.dwWidth is %u, expected 64\n", vp.dwWidth);
-    ok(vp.dwHeight == 64, "vp.dwHeight is %u, expected 64\n", vp.dwHeight);
+    ok(hr == D3D_OK, "IDirect3DDevice7_GetViewport failed, hr=0x%08lx\n", hr);
+    ok(vp.dwX == 0, "vp.dwX is %lu, expected 0\n", vp.dwX);
+    ok(vp.dwY == 0, "vp.dwY is %lu, expected 0\n", vp.dwY);
+    ok(vp.dwWidth == 64, "vp.dwWidth is %lu, expected 64\n", vp.dwWidth);
+    ok(vp.dwHeight == 64, "vp.dwHeight is %lu, expected 64\n", vp.dwHeight);
     ok(vp.dvMinZ == 0.0, "vp.dvMinZ is %f, expected 0.0\n", vp.dvMinZ);
     ok(vp.dvMaxZ == 1.0, "vp.dvMaxZ is %f, expected 1.0\n", vp.dvMaxZ);
 
     hr = IDirect3DDevice7_DeleteStateBlock(lpD3DDevice, stateblock);
-    ok(hr == D3D_OK, "IDirect3DDevice7_DeleteStateblock failed, hr=0x%08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_DeleteStateblock failed, hr=0x%08lx\n", hr);
 
     memset(&vp, 0, sizeof(vp));
     vp.dwX = 0;
@@ -1574,7 +1574,7 @@ static void SetRenderTargetTest(void)
     vp.dvMinZ = 0.0;
     vp.dvMaxZ = 0.0;
     hr = IDirect3DDevice7_SetViewport(lpD3DDevice, &vp);
-    ok(hr == D3D_OK, "IDirect3DDevice7_SetViewport failed, hr=0x%08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_SetViewport failed, hr=0x%08lx\n", hr);
 
     IDirectDrawSurface7_Release(oldrt);
     IDirectDrawSurface7_Release(newrt);
@@ -1617,18 +1617,18 @@ static void VertexBufferLockRest(void)
     desc.dwFVF = D3DFVF_XYZ;
     desc.dwNumVertices = 64;
     hr = IDirect3D7_CreateVertexBuffer(lpD3D, &desc, &buffer, 0);
-    ok(hr == D3D_OK, "IDirect3D7_CreateVertexBuffer failed, 0x%08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3D7_CreateVertexBuffer failed, 0x%08lx\n", hr);
 
     for(i = 0; i < (sizeof(test_data) / sizeof(*test_data)); i++)
     {
         hr = IDirect3DVertexBuffer7_Lock(buffer, test_data[i].flags, &data, NULL);
-        ok(hr == test_data[i].result, "Lock flags %s returned 0x%08x, expected 0x%08x\n",
+        ok(hr == test_data[i].result, "Lock flags %s returned 0x%08lx, expected 0x%08lx\n",
             test_data[i].debug_string, hr, test_data[i].result);
         if(SUCCEEDED(hr))
         {
             ok(data != NULL, "The data pointer returned by Lock is NULL\n");
             hr = IDirect3DVertexBuffer7_Unlock(buffer);
-            ok(hr == D3D_OK, "IDirect3DVertexBuffer7_Unlock failed, 0x%08x\n", hr);
+            ok(hr == D3D_OK, "IDirect3DVertexBuffer7_Unlock failed, 0x%08lx\n", hr);
         }
     }
 
@@ -1656,7 +1656,7 @@ static void BackBuffer3DCreateSurfaceTest(void)
     memset(&ddcaps, 0, sizeof(ddcaps));
     ddcaps.dwSize = sizeof(DDCAPS);
     hr = IDirectDraw_GetCaps(DirectDraw1, &ddcaps, NULL);
-    ok(SUCCEEDED(hr), "DirectDraw_GetCaps failed: 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "DirectDraw_GetCaps failed: 0x%08lx\n", hr);
     if (!(ddcaps.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
     {
         skip("DDraw reported no VIDEOMEMORY cap. Broken video driver? Skipping surface caps tests.\n");
@@ -1679,20 +1679,20 @@ static void BackBuffer3DCreateSurfaceTest(void)
     created_ddsd.dwSize = sizeof(DDSURFACEDESC);
 
     hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &surf, NULL);
-    ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed: 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed: 0x%08lx\n", hr);
     if (surf != NULL)
     {
         hr = IDirectDrawSurface_GetSurfaceDesc(surf, &created_ddsd);
-        ok(SUCCEEDED(hr), "IDirectDraw_GetSurfaceDesc failed: 0x%08x\n", hr);
+        ok(SUCCEEDED(hr), "IDirectDraw_GetSurfaceDesc failed: 0x%08lx\n", hr);
         ok(created_ddsd.ddsCaps.dwCaps == expected_caps,
-           "GetSurfaceDesc returned caps %x, expected %x\n", created_ddsd.ddsCaps.dwCaps,
+           "GetSurfaceDesc returned caps %lx, expected %lx\n", created_ddsd.ddsCaps.dwCaps,
            expected_caps);
 
         hr = IDirectDrawSurface_QueryInterface(surf, &IID_IDirect3DHALDevice, (void **)&d3dhal);
         /* Currently Wine only supports the creation of one Direct3D device
            for a given DirectDraw instance. It has been created already
            in D3D1_createObjects() - IID_IDirect3DRGBDevice */
-        todo_wine ok(SUCCEEDED(hr), "Expected IDirectDrawSurface::QueryInterface to succeed, got 0x%08x\n", hr);
+        todo_wine ok(SUCCEEDED(hr), "Expected IDirectDrawSurface::QueryInterface to succeed, got 0x%08lx\n", hr);
 
         if (SUCCEEDED(hr))
             IDirect3DDevice_Release(d3dhal);
@@ -1701,28 +1701,28 @@ static void BackBuffer3DCreateSurfaceTest(void)
     }
 
     hr = IDirectDraw_QueryInterface(DirectDraw1, &IID_IDirectDraw2, (void **) &dd2);
-    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08lx\n", hr);
 
     hr = IDirectDraw2_CreateSurface(dd2, &ddsd, &surf, NULL);
-    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw2_CreateSurface didn't return %x08x, but %x08x\n",
+    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw2_CreateSurface didn't return %lx08x, but %lx08x\n",
        DDERR_INVALIDCAPS, hr);
 
     IDirectDraw2_Release(dd2);
 
     hr = IDirectDraw_QueryInterface(DirectDraw1, &IID_IDirectDraw4, (void **) &dd4);
-    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08lx\n", hr);
 
     hr = IDirectDraw4_CreateSurface(dd4, &ddsd2, &surf4, NULL);
-    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw4_CreateSurface didn't return %x08x, but %x08x\n",
+    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw4_CreateSurface didn't return %lx08x, but %lx08x\n",
        DDERR_INVALIDCAPS, hr);
 
     IDirectDraw4_Release(dd4);
 
     hr = IDirectDraw_QueryInterface(DirectDraw1, &IID_IDirectDraw7, (void **) &dd7);
-    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08lx\n", hr);
 
     hr = IDirectDraw7_CreateSurface(dd7, &ddsd2, &surf7, NULL);
-    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw7_CreateSurface didn't return %x08x, but %x08x\n",
+    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw7_CreateSurface didn't return %lx08x, but %lx08x\n",
        DDERR_INVALIDCAPS, hr);
 
     IDirectDraw7_Release(dd7);
@@ -1737,7 +1737,7 @@ static void BackBuffer3DAttachmentTest(void)
             100, 100, 160, 160, NULL, NULL, NULL, NULL);
 
     hr = IDirectDraw_SetCooperativeLevel(DirectDraw1, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel returned %08x\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel returned %08lx\n", hr);
 
     /* Perform attachment tests on a back-buffer */
     memset(&ddsd, 0, sizeof(ddsd));
@@ -1747,7 +1747,7 @@ static void BackBuffer3DAttachmentTest(void)
     ddsd.dwWidth = GetSystemMetrics(SM_CXSCREEN);
     ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN);
     hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &surface2, NULL);
-    ok(SUCCEEDED(hr), "CreateSurface returned: %x\n",hr);
+    ok(SUCCEEDED(hr), "CreateSurface returned: %lx\n",hr);
 
     if (surface2 != NULL)
     {
@@ -1757,7 +1757,7 @@ static void BackBuffer3DAttachmentTest(void)
         ddsd.dwFlags = DDSD_CAPS;
         ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
         hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &surface1, NULL);
-        ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
+        ok(hr==DD_OK,"CreateSurface returned: %lx\n",hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
@@ -1766,7 +1766,7 @@ static void BackBuffer3DAttachmentTest(void)
         ddsd.dwWidth = GetSystemMetrics(SM_CXSCREEN);
         ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN);
         hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &surface3, NULL);
-        ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
+        ok(hr==DD_OK,"CreateSurface returned: %lx\n",hr);
 
         /* This one has a different size */
         memset(&ddsd, 0, sizeof(ddsd));
@@ -1776,43 +1776,43 @@ static void BackBuffer3DAttachmentTest(void)
         ddsd.dwWidth = 128;
         ddsd.dwHeight = 128;
         hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &surface4, NULL);
-        ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
+        ok(hr==DD_OK,"CreateSurface returned: %lx\n",hr);
 
         hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
         todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
-           "Attaching a back buffer to a front buffer returned %08x\n", hr);
+           "Attaching a back buffer to a front buffer returned %08lx\n", hr);
         if(SUCCEEDED(hr))
         {
             /* Try the reverse without detaching first */
             hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface1);
-            ok(hr == DDERR_SURFACEALREADYATTACHED, "Attaching an attached surface to its attachee returned %08x\n", hr);
+            ok(hr == DDERR_SURFACEALREADYATTACHED, "Attaching an attached surface to its attachee returned %08lx\n", hr);
             hr = IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface2);
-            ok(hr == DD_OK, "DeleteAttachedSurface failed with %08x\n", hr);
+            ok(hr == DD_OK, "DeleteAttachedSurface failed with %08lx\n", hr);
         }
         hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface1);
         todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
-           "Attaching a front buffer to a back buffer returned %08x\n", hr);
+           "Attaching a front buffer to a back buffer returned %08lx\n", hr);
         if(SUCCEEDED(hr))
         {
             /* Try to detach reversed */
             hr = IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface2);
-            ok(hr == DDERR_CANNOTDETACHSURFACE, "DeleteAttachedSurface returned %08x\n", hr);
+            ok(hr == DDERR_CANNOTDETACHSURFACE, "DeleteAttachedSurface returned %08lx\n", hr);
             /* Now the proper detach */
             hr = IDirectDrawSurface_DeleteAttachedSurface(surface2, 0, surface1);
-            ok(hr == DD_OK, "DeleteAttachedSurface failed with %08x\n", hr);
+            ok(hr == DD_OK, "DeleteAttachedSurface failed with %08lx\n", hr);
         }
         hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface3);
         todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
-           "Attaching a back buffer to another back buffer returned %08x\n", hr);
+           "Attaching a back buffer to another back buffer returned %08lx\n", hr);
         if(SUCCEEDED(hr))
         {
             hr = IDirectDrawSurface_DeleteAttachedSurface(surface2, 0, surface3);
-            ok(hr == DD_OK, "DeleteAttachedSurface failed with %08x\n", hr);
+            ok(hr == DD_OK, "DeleteAttachedSurface failed with %08lx\n", hr);
         }
         hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a back buffer to a front buffer of different size returned %08x\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a back buffer to a front buffer of different size returned %08lx\n", hr);
         hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface1);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a front buffer to a back buffer of different size returned %08x\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a front buffer to a back buffer of different size returned %08lx\n", hr);
 
         IDirectDrawSurface_Release(surface4);
         IDirectDrawSurface_Release(surface3);
@@ -1821,16 +1821,16 @@ static void BackBuffer3DAttachmentTest(void)
     }
 
     hr =IDirectDraw_SetCooperativeLevel(DirectDraw1, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel returned %08x\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel returned %08lx\n", hr);
 
     DestroyWindow(window);
 }
 
 static void dump_format(const DDPIXELFORMAT *fmt)
 {
-    trace("dwFlags %08x, FourCC %08x, dwZBufferBitDepth %u, stencil %08x\n", fmt->dwFlags, fmt->dwFourCC,
+    trace("dwFlags %08lx, FourCC %08lx, dwZBufferBitDepth %lu, stencil %08lx\n", fmt->dwFlags, fmt->dwFourCC,
           U1(*fmt).dwZBufferBitDepth, U2(*fmt).dwStencilBitDepth);
-    trace("dwZBitMask %08x, dwStencilBitMask %08x, dwRGBZBitMask %08x\n", U3(*fmt).dwZBitMask,
+    trace("dwZBitMask %08lx, dwStencilBitMask %08lx, dwRGBZBitMask %08lx\n", U3(*fmt).dwZBitMask,
           U4(*fmt).dwStencilBitMask, U5(*fmt).dwRGBZBitMask);
 }
 
@@ -1881,11 +1881,11 @@ static HRESULT WINAPI enum_z_fmt_cb(DDPIXELFORMAT *fmt, void *ctx)
     ddsd.dwWidth = 1024;
     ddsd.dwHeight = 1024;
     hr = IDirectDraw7_CreateSurface(lpDD, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "IDirectDraw7_CreateSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw7_CreateSurface failed, hr %#lx.\n", hr);
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
     hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd);
-    ok(SUCCEEDED(hr), "IDirectDrawSurface7_GetSurfaceDesc failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDrawSurface7_GetSurfaceDesc failed, hr %#lx.\n", hr);
     IDirectDrawSurface7_Release(surface);
 
     ok(ddsd.dwFlags & DDSD_PIXELFORMAT, "DDSD_PIXELFORMAT is not set\n");
@@ -1903,7 +1903,7 @@ static HRESULT WINAPI enum_z_fmt_cb(DDPIXELFORMAT *fmt, void *ctx)
     if (U1(ddsd).lPitch != 0 && U1(ddsd).lPitch != expected_pitch
             && !broken(U1(ddsd).lPitch == expected_pitch + 128))
     {
-        ok(0, "Z buffer pitch is %u, expected %u\n", U1(ddsd).lPitch, expected_pitch);
+        ok(0, "Z buffer pitch is %lu, expected %u\n", U1(ddsd).lPitch, expected_pitch);
         dump_format(fmt);
     }
 
@@ -1930,7 +1930,7 @@ static void z_format_test(void)
         return;
     }
 
-    ok(SUCCEEDED(hr), "IDirect3D7_EnumZBufferFormats failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3D7_EnumZBufferFormats failed, hr %#lx.\n", hr);
     ok(count, "Expected at least one supported Z Buffer format\n");
 }
 
@@ -1949,17 +1949,17 @@ static void test_get_caps1(void)
 
     /* NULL pointers */
     hr = IDirect3DDevice_GetCaps(Direct3DDevice1, &hw_caps, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "GetCaps with NULL hel caps returned hr %#x, expected INVALIDPARAMS.\n", hr);
-    ok(hw_caps.dwFlags == 0xdeadbeef, "hw_caps.dwFlags was modified: %#x.\n", hw_caps.dwFlags);
+    ok(hr == DDERR_INVALIDPARAMS, "GetCaps with NULL hel caps returned hr %#lx, expected INVALIDPARAMS.\n", hr);
+    ok(hw_caps.dwFlags == 0xdeadbeef, "hw_caps.dwFlags was modified: %#lx.\n", hw_caps.dwFlags);
     hr = IDirect3DDevice_GetCaps(Direct3DDevice1, NULL, &hel_caps);
-    ok(hr == DDERR_INVALIDPARAMS, "GetCaps with NULL hw caps returned hr %#x, expected INVALIDPARAMS.\n", hr);
-    ok(hel_caps.dwFlags == 0xdeadc0de, "hel_caps.dwFlags was modified: %#x.\n", hel_caps.dwFlags);
+    ok(hr == DDERR_INVALIDPARAMS, "GetCaps with NULL hw caps returned hr %#lx, expected INVALIDPARAMS.\n", hr);
+    ok(hel_caps.dwFlags == 0xdeadc0de, "hel_caps.dwFlags was modified: %#lx.\n", hel_caps.dwFlags);
 
     /* Successful call: Both are modified */
     hr = IDirect3DDevice_GetCaps(Direct3DDevice1, &hw_caps, &hel_caps);
-    ok(hr == D3D_OK, "GetCaps with correct size returned hr %#x, expected D3D_OK.\n", hr);
-    ok(hw_caps.dwFlags != 0xdeadbeef, "hw_caps.dwFlags was not modified: %#x.\n", hw_caps.dwFlags);
-    ok(hel_caps.dwFlags != 0xdeadc0de, "hel_caps.dwFlags was not modified: %#x.\n", hel_caps.dwFlags);
+    ok(hr == D3D_OK, "GetCaps with correct size returned hr %#lx, expected D3D_OK.\n", hr);
+    ok(hw_caps.dwFlags != 0xdeadbeef, "hw_caps.dwFlags was not modified: %#lx.\n", hw_caps.dwFlags);
+    ok(hel_caps.dwFlags != 0xdeadc0de, "hel_caps.dwFlags was not modified: %#lx.\n", hel_caps.dwFlags);
 
     memset(&hw_caps, 0, sizeof(hw_caps));
     hw_caps.dwSize = sizeof(hw_caps);
@@ -1970,15 +1970,15 @@ static void test_get_caps1(void)
 
     /* If one is invalid the call fails */
     hr = IDirect3DDevice_GetCaps(Direct3DDevice1, &hw_caps, &hel_caps);
-    ok(hr == DDERR_INVALIDPARAMS, "GetCaps with invalid hel_caps size returned hr %#x, expected INVALIDPARAMS.\n", hr);
-    ok(hw_caps.dwFlags == 0xdeadbeef, "hw_caps.dwFlags was modified: %#x.\n", hw_caps.dwFlags);
-    ok(hel_caps.dwFlags == 0xdeadc0de, "hel_caps.dwFlags was modified: %#x.\n", hel_caps.dwFlags);
+    ok(hr == DDERR_INVALIDPARAMS, "GetCaps with invalid hel_caps size returned hr %#lx, expected INVALIDPARAMS.\n", hr);
+    ok(hw_caps.dwFlags == 0xdeadbeef, "hw_caps.dwFlags was modified: %#lx.\n", hw_caps.dwFlags);
+    ok(hel_caps.dwFlags == 0xdeadc0de, "hel_caps.dwFlags was modified: %#lx.\n", hel_caps.dwFlags);
     hel_caps.dwSize = sizeof(hel_caps);
     hw_caps.dwSize = sizeof(hw_caps) + 1;
     hr = IDirect3DDevice_GetCaps(Direct3DDevice1, &hw_caps, &hel_caps);
-    ok(hr == DDERR_INVALIDPARAMS, "GetCaps with invalid hw_caps size returned hr %#x, expected INVALIDPARAMS.\n", hr);
-    ok(hw_caps.dwFlags == 0xdeadbeef, "hw_caps.dwFlags was modified: %#x.\n", hw_caps.dwFlags);
-    ok(hel_caps.dwFlags == 0xdeadc0de, "hel_caps.dwFlags was modified: %#x.\n", hel_caps.dwFlags);
+    ok(hr == DDERR_INVALIDPARAMS, "GetCaps with invalid hw_caps size returned hr %#lx, expected INVALIDPARAMS.\n", hr);
+    ok(hw_caps.dwFlags == 0xdeadbeef, "hw_caps.dwFlags was modified: %#lx.\n", hw_caps.dwFlags);
+    ok(hel_caps.dwFlags == 0xdeadc0de, "hel_caps.dwFlags was modified: %#lx.\n", hel_caps.dwFlags);
 
     for (i = 0; i < 1024; i++)
     {
@@ -1990,24 +1990,24 @@ static void test_get_caps1(void)
         {
             /* D3DDEVICEDESCSIZE in old sdk versions */
             case FIELD_OFFSET(D3DDEVICEDESC, dwMinTextureWidth): /* 172, DirectX 3, IDirect3DDevice1 */
-                ok(hw_caps.dwMinTextureWidth == 0xfefefefe, "hw_caps.dwMinTextureWidth was modified: %#x.\n",
+                ok(hw_caps.dwMinTextureWidth == 0xfefefefe, "hw_caps.dwMinTextureWidth was modified: %#lx.\n",
                         hw_caps.dwMinTextureWidth);
-                ok(hel_caps.dwMinTextureWidth == 0xfefefefe, "hel_caps.dwMinTextureWidth was modified: %#x.\n",
+                ok(hel_caps.dwMinTextureWidth == 0xfefefefe, "hel_caps.dwMinTextureWidth was modified: %#lx.\n",
                         hel_caps.dwMinTextureWidth);
                 /* drop through */
             case FIELD_OFFSET(D3DDEVICEDESC, dwMaxTextureRepeat): /* 204, DirectX 5, IDirect3DDevice2 */
-                ok(hw_caps.dwMaxTextureRepeat == 0xfefefefe, "hw_caps.dwMaxTextureRepeat was modified: %#x.\n",
+                ok(hw_caps.dwMaxTextureRepeat == 0xfefefefe, "hw_caps.dwMaxTextureRepeat was modified: %#lx.\n",
                         hw_caps.dwMaxTextureRepeat);
-                ok(hel_caps.dwMaxTextureRepeat == 0xfefefefe, "hel_caps.dwMaxTextureRepeat was modified: %#x.\n",
+                ok(hel_caps.dwMaxTextureRepeat == 0xfefefefe, "hel_caps.dwMaxTextureRepeat was modified: %#lx.\n",
                         hel_caps.dwMaxTextureRepeat);
                 /* drop through */
             case sizeof(D3DDEVICEDESC): /* 252, DirectX 6, IDirect3DDevice3 */
-                ok(hr == D3D_OK, "GetCaps with size %u returned hr %#x, expected D3D_OK.\n", i, hr);
+                ok(hr == D3D_OK, "GetCaps with size %u returned hr %#lx, expected D3D_OK.\n", i, hr);
                 break;
 
             default:
                 ok(hr == DDERR_INVALIDPARAMS,
-                        "GetCaps with size %u returned hr %#x, expected DDERR_INVALIDPARAMS.\n", i, hr);
+                        "GetCaps with size %u returned hr %#lx, expected DDERR_INVALIDPARAMS.\n", i, hr);
                 break;
         }
     }
@@ -2016,7 +2016,7 @@ static void test_get_caps1(void)
     hw_caps.dwSize = 172;
     hel_caps.dwSize = sizeof(D3DDEVICEDESC);
     hr = IDirect3DDevice_GetCaps(Direct3DDevice1, &hw_caps, &hel_caps);
-    ok(hr == D3D_OK, "GetCaps with different sizes returned hr %#x, expected D3D_OK.\n", hr);
+    ok(hr == D3D_OK, "GetCaps with different sizes returned hr %#lx, expected D3D_OK.\n", hr);
 }
 
 static void test_get_caps7(void)
@@ -2025,11 +2025,11 @@ static void test_get_caps7(void)
     D3DDEVICEDESC7 desc;
 
     hr = IDirect3DDevice7_GetCaps(lpD3DDevice, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirect3DDevice7::GetCaps(NULL) returned hr %#x, expected INVALIDPARAMS.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "IDirect3DDevice7::GetCaps(NULL) returned hr %#lx, expected INVALIDPARAMS.\n", hr);
 
     memset(&desc, 0, sizeof(desc));
     hr = IDirect3DDevice7_GetCaps(lpD3DDevice, &desc);
-    ok(hr == D3D_OK, "IDirect3DDevice7::GetCaps(non-NULL) returned hr %#x, expected D3D_OK.\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7::GetCaps(non-NULL) returned hr %#lx, expected D3D_OK.\n", hr);
 
     /* There's no dwSize in D3DDEVICEDESC7 */
 }
@@ -2051,29 +2051,29 @@ static void d3d2_release_objects(struct d3d2_test_context *context)
     if (context->viewport)
     {
         hr = IDirect3DDevice2_DeleteViewport(context->device, context->viewport);
-        ok(hr == D3D_OK, "DeleteViewport returned %08x.\n", hr);
+        ok(hr == D3D_OK, "DeleteViewport returned %08lx.\n", hr);
         ref = IDirect3DViewport2_Release(context->viewport);
-        ok(ref == 0, "Viewport has reference count %d, expected 0.\n", ref);
+        ok(ref == 0, "Viewport has reference count %ld, expected 0.\n", ref);
     }
     if (context->device)
     {
         ref = IDirect3DDevice2_Release(context->device);
-        ok(ref == 0, "Device has reference count %d, expected 0.\n", ref);
+        ok(ref == 0, "Device has reference count %ld, expected 0.\n", ref);
     }
     if (context->surface)
     {
         ref = IDirectDrawSurface_Release(context->surface);
-        ok(ref == 0, "Surface has reference count %d, expected 0.\n", ref);
+        ok(ref == 0, "Surface has reference count %ld, expected 0.\n", ref);
     }
     if (context->d3d)
     {
         ref = IDirect3D2_Release(context->d3d);
-        ok(ref == 1, "IDirect3D2 has reference count %d, expected 1.\n", ref);
+        ok(ref == 1, "IDirect3D2 has reference count %ld, expected 1.\n", ref);
     }
     if (context->ddraw)
     {
         ref = IDirectDraw_Release(context->ddraw);
-        ok(ref == 0, "DDraw has reference count %d, expected 0.\n", ref);
+        ok(ref == 0, "DDraw has reference count %ld, expected 0.\n", ref);
     }
 }
 
@@ -2086,15 +2086,15 @@ static BOOL d3d2_create_objects(struct d3d2_test_context *context)
     memset(context, 0, sizeof(*context));
 
     hr = DirectDrawCreate(NULL, &context->ddraw, NULL);
-    ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreate failed: %08x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreate failed: %08lx.\n", hr);
     if (!context->ddraw) goto error;
 
     hr = IDirectDraw_SetCooperativeLevel(context->ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed: %08x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed: %08lx.\n", hr);
     if (FAILED(hr)) goto error;
 
     hr = IDirectDraw_QueryInterface(context->ddraw, &IID_IDirect3D2, (void**) &context->d3d);
-    ok(hr == DD_OK || hr == E_NOINTERFACE, "QueryInterface failed: %08x.\n", hr);
+    ok(hr == DD_OK || hr == E_NOINTERFACE, "QueryInterface failed: %08lx.\n", hr);
     if (!context->d3d) goto error;
 
     memset(&ddsd, 0, sizeof(ddsd));
@@ -2111,15 +2111,15 @@ static BOOL d3d2_create_objects(struct d3d2_test_context *context)
     }
 
     hr = IDirect3D2_CreateDevice(context->d3d, &IID_IDirect3DHALDevice, context->surface, &context->device);
-    ok(hr == D3D_OK  || hr == E_OUTOFMEMORY || hr == E_NOINTERFACE, "CreateDevice failed: %08x.\n", hr);
+    ok(hr == D3D_OK  || hr == E_OUTOFMEMORY || hr == E_NOINTERFACE, "CreateDevice failed: %08lx.\n", hr);
     if (!context->device) goto error;
 
     hr = IDirect3D2_CreateViewport(context->d3d, &context->viewport, NULL);
-    ok(hr == D3D_OK, "CreateViewport failed: %08x.\n", hr);
+    ok(hr == D3D_OK, "CreateViewport failed: %08lx.\n", hr);
     if (!context->viewport) goto error;
 
     hr = IDirect3DDevice2_AddViewport(context->device, context->viewport);
-    ok(hr == D3D_OK, "AddViewport returned %08x.\n", hr);
+    ok(hr == D3D_OK, "AddViewport returned %08lx.\n", hr);
     vp_data.dwSize = sizeof(vp_data);
     vp_data.dwX = 0;
     vp_data.dwY = 0;
@@ -2132,7 +2132,7 @@ static BOOL d3d2_create_objects(struct d3d2_test_context *context)
     vp_data.dvMinZ = 0;
     vp_data.dvMaxZ = 1;
     hr = IDirect3DViewport2_SetViewport(context->viewport, &vp_data);
-    ok(hr == D3D_OK, "SetViewport returned %08x.\n", hr);
+    ok(hr == D3D_OK, "SetViewport returned %08lx.\n", hr);
 
     return TRUE;
 
@@ -2156,17 +2156,17 @@ static void test_get_caps2(const struct d3d2_test_context *context)
 
     /* NULL pointers */
     hr = IDirect3DDevice2_GetCaps(context->device, &hw_caps, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "GetCaps with NULL hel caps returned hr %#x, expected INVALIDPARAMS.\n", hr);
-    ok(hw_caps.dwFlags == 0xdeadbeef, "hw_caps.dwFlags was modified: %#x.\n", hw_caps.dwFlags);
+    ok(hr == DDERR_INVALIDPARAMS, "GetCaps with NULL hel caps returned hr %#lx, expected INVALIDPARAMS.\n", hr);
+    ok(hw_caps.dwFlags == 0xdeadbeef, "hw_caps.dwFlags was modified: %#lx.\n", hw_caps.dwFlags);
     hr = IDirect3DDevice2_GetCaps(context->device, NULL, &hel_caps);
-    ok(hr == DDERR_INVALIDPARAMS, "GetCaps with NULL hw caps returned hr %#x, expected INVALIDPARAMS.\n", hr);
-    ok(hel_caps.dwFlags == 0xdeadc0de, "hel_caps.dwFlags was modified: %#x.\n", hel_caps.dwFlags);
+    ok(hr == DDERR_INVALIDPARAMS, "GetCaps with NULL hw caps returned hr %#lx, expected INVALIDPARAMS.\n", hr);
+    ok(hel_caps.dwFlags == 0xdeadc0de, "hel_caps.dwFlags was modified: %#lx.\n", hel_caps.dwFlags);
 
     /* Successful call: Both are modified */
     hr = IDirect3DDevice2_GetCaps(context->device, &hw_caps, &hel_caps);
-    ok(hr == D3D_OK, "GetCaps with correct size returned hr %#x, expected D3D_OK.\n", hr);
-    ok(hw_caps.dwFlags != 0xdeadbeef, "hw_caps.dwFlags was not modified: %#x.\n", hw_caps.dwFlags);
-    ok(hel_caps.dwFlags != 0xdeadc0de, "hel_caps.dwFlags was not modified: %#x.\n", hel_caps.dwFlags);
+    ok(hr == D3D_OK, "GetCaps with correct size returned hr %#lx, expected D3D_OK.\n", hr);
+    ok(hw_caps.dwFlags != 0xdeadbeef, "hw_caps.dwFlags was not modified: %#lx.\n", hw_caps.dwFlags);
+    ok(hel_caps.dwFlags != 0xdeadc0de, "hel_caps.dwFlags was not modified: %#lx.\n", hel_caps.dwFlags);
 
     memset(&hw_caps, 0, sizeof(hw_caps));
     hw_caps.dwSize = sizeof(hw_caps);
@@ -2177,15 +2177,15 @@ static void test_get_caps2(const struct d3d2_test_context *context)
 
     /* If one is invalid the call fails */
     hr = IDirect3DDevice2_GetCaps(context->device, &hw_caps, &hel_caps);
-    ok(hr == DDERR_INVALIDPARAMS, "GetCaps with invalid hel_caps size returned hr %#x, expected INVALIDPARAMS.\n", hr);
-    ok(hw_caps.dwFlags == 0xdeadbeef, "hw_caps.dwFlags was modified: %#x.\n", hw_caps.dwFlags);
-    ok(hel_caps.dwFlags == 0xdeadc0de, "hel_caps.dwFlags was modified: %#x.\n", hel_caps.dwFlags);
+    ok(hr == DDERR_INVALIDPARAMS, "GetCaps with invalid hel_caps size returned hr %#lx, expected INVALIDPARAMS.\n", hr);
+    ok(hw_caps.dwFlags == 0xdeadbeef, "hw_caps.dwFlags was modified: %#lx.\n", hw_caps.dwFlags);
+    ok(hel_caps.dwFlags == 0xdeadc0de, "hel_caps.dwFlags was modified: %#lx.\n", hel_caps.dwFlags);
     hel_caps.dwSize = sizeof(hel_caps);
     hw_caps.dwSize = sizeof(hw_caps) + 1;
     hr = IDirect3DDevice2_GetCaps(context->device, &hw_caps, &hel_caps);
-    ok(hr == DDERR_INVALIDPARAMS, "GetCaps with invalid hw_caps size returned hr %#x, expected INVALIDPARAMS.\n", hr);
-    ok(hw_caps.dwFlags == 0xdeadbeef, "hw_caps.dwFlags was modified: %#x.\n", hw_caps.dwFlags);
-    ok(hel_caps.dwFlags == 0xdeadc0de, "hel_caps.dwFlags was modified: %#x.\n", hel_caps.dwFlags);
+    ok(hr == DDERR_INVALIDPARAMS, "GetCaps with invalid hw_caps size returned hr %#lx, expected INVALIDPARAMS.\n", hr);
+    ok(hw_caps.dwFlags == 0xdeadbeef, "hw_caps.dwFlags was modified: %#lx.\n", hw_caps.dwFlags);
+    ok(hel_caps.dwFlags == 0xdeadc0de, "hel_caps.dwFlags was modified: %#lx.\n", hel_caps.dwFlags);
 
     for (i = 0; i < 1024; i++)
     {
@@ -2197,24 +2197,24 @@ static void test_get_caps2(const struct d3d2_test_context *context)
         {
             /* D3DDEVICEDESCSIZE in old sdk versions */
             case FIELD_OFFSET(D3DDEVICEDESC, dwMinTextureWidth): /* 172, DirectX 3, IDirect3DDevice1 */
-                ok(hw_caps.dwMinTextureWidth == 0xfefefefe, "dwMinTextureWidth was modified: %#x.\n",
+                ok(hw_caps.dwMinTextureWidth == 0xfefefefe, "dwMinTextureWidth was modified: %#lx.\n",
                         hw_caps.dwMinTextureWidth);
-                ok(hel_caps.dwMinTextureWidth == 0xfefefefe, "dwMinTextureWidth was modified: %#x.\n",
+                ok(hel_caps.dwMinTextureWidth == 0xfefefefe, "dwMinTextureWidth was modified: %#lx.\n",
                         hel_caps.dwMinTextureWidth);
                 /* drop through */
             case FIELD_OFFSET(D3DDEVICEDESC, dwMaxTextureRepeat): /* 204, DirectX 5, IDirect3DDevice2 */
-                ok(hw_caps.dwMaxTextureRepeat == 0xfefefefe, "dwMaxTextureRepeat was modified: %#x.\n",
+                ok(hw_caps.dwMaxTextureRepeat == 0xfefefefe, "dwMaxTextureRepeat was modified: %#lx.\n",
                         hw_caps.dwMaxTextureRepeat);
-                ok(hel_caps.dwMaxTextureRepeat == 0xfefefefe, "dwMaxTextureRepeat was modified: %#x.\n",
+                ok(hel_caps.dwMaxTextureRepeat == 0xfefefefe, "dwMaxTextureRepeat was modified: %#lx.\n",
                         hel_caps.dwMaxTextureRepeat);
                 /* drop through */
             case sizeof(D3DDEVICEDESC): /* 252, DirectX 6, IDirect3DDevice3 */
-                ok(hr == D3D_OK, "GetCaps with size %u returned hr %#x, expected D3D_OK.\n", i, hr);
+                ok(hr == D3D_OK, "GetCaps with size %u returned hr %#lx, expected D3D_OK.\n", i, hr);
                 break;
 
             default:
                 ok(hr == DDERR_INVALIDPARAMS,
-                        "GetCaps with size %u returned hr %#x, expected DDERR_INVALIDPARAMS.\n", i, hr);
+                        "GetCaps with size %u returned hr %#lx, expected DDERR_INVALIDPARAMS.\n", i, hr);
                 break;
         }
     }
@@ -2223,7 +2223,7 @@ static void test_get_caps2(const struct d3d2_test_context *context)
     hw_caps.dwSize = 172;
     hel_caps.dwSize = sizeof(D3DDEVICEDESC);
     hr = IDirect3DDevice2_GetCaps(context->device, &hw_caps, &hel_caps);
-    ok(hr == D3D_OK, "GetCaps with different sizes returned hr %#x, expected D3D_OK.\n", hr);
+    ok(hr == D3D_OK, "GetCaps with different sizes returned hr %#lx, expected D3D_OK.\n", hr);
 }
 
 START_TEST(d3d)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index b87b7903289c..ce4f4d21de6d 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -120,9 +120,9 @@ static BOOL ddraw_get_identifier(IDirectDraw *ddraw, DDDEVICEIDENTIFIER *identif
     HRESULT hr;
 
     hr = IDirectDraw_QueryInterface(ddraw, &IID_IDirectDraw4, (void **)&ddraw4);
-    ok(SUCCEEDED(hr), "Failed to get IDirectDraw4 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get IDirectDraw4 interface, hr %#lx.\n", hr);
     hr = IDirectDraw4_GetDeviceIdentifier(ddraw4, identifier, 0);
-    ok(SUCCEEDED(hr), "Failed to get device identifier, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device identifier, hr %#lx.\n", hr);
     IDirectDraw4_Release(ddraw4);
 
     return SUCCEEDED(hr);
@@ -210,7 +210,7 @@ static DWORD WINAPI create_window_thread_proc(void *param)
 
     p->window = create_window();
     ret = SetEvent(p->window_created);
-    ok(ret, "SetEvent failed, last error %#x.\n", GetLastError());
+    ok(ret, "SetEvent failed, last error %#lx.\n", GetLastError());
 
     for (;;)
     {
@@ -223,7 +223,7 @@ static DWORD WINAPI create_window_thread_proc(void *param)
             break;
         if (res != WAIT_TIMEOUT)
         {
-            ok(0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+            ok(0, "Wait failed (%#lx), last error %#lx.\n", res, GetLastError());
             break;
         }
     }
@@ -238,13 +238,13 @@ static void create_window_thread(struct create_window_thread_param *p)
     DWORD res, tid;
 
     p->window_created = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(!!p->window_created, "CreateEvent failed, last error %#x.\n", GetLastError());
+    ok(!!p->window_created, "CreateEvent failed, last error %#lx.\n", GetLastError());
     p->destroy_window = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(!!p->destroy_window, "CreateEvent failed, last error %#x.\n", GetLastError());
+    ok(!!p->destroy_window, "CreateEvent failed, last error %#lx.\n", GetLastError());
     p->thread = CreateThread(NULL, 0, create_window_thread_proc, p, 0, &tid);
-    ok(!!p->thread, "Failed to create thread, last error %#x.\n", GetLastError());
+    ok(!!p->thread, "Failed to create thread, last error %#lx.\n", GetLastError());
     res = WaitForSingleObject(p->window_created, INFINITE);
-    ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+    ok(res == WAIT_OBJECT_0, "Wait failed (%#lx), last error %#lx.\n", res, GetLastError());
 }
 
 static void destroy_window_thread(struct create_window_thread_param *p)
@@ -263,9 +263,9 @@ static IDirectDrawSurface *get_depth_stencil(IDirect3DDevice *device)
     HRESULT hr;
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetAttachedSurface(rt, &caps, &ret);
-    ok(SUCCEEDED(hr) || hr == DDERR_NOTFOUND, "Failed to get the z buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || hr == DDERR_NOTFOUND, "Failed to get the z buffer, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(rt);
     return ret;
 }
@@ -351,14 +351,14 @@ static D3DCOLOR get_surface_color(IDirectDrawSurface *surface, UINT x, UINT y)
     surface_desc.dwSize = sizeof(surface_desc);
 
     hr = IDirectDrawSurface_Lock(surface, &rect, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     if (FAILED(hr))
         return 0xdeadbeef;
 
     color = *((DWORD *)surface_desc.lpSurface) & 0x00ffffff;
 
     hr = IDirectDrawSurface_Unlock(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     return color;
 }
@@ -371,7 +371,7 @@ static void fill_surface(IDirectDrawSurface *surface, D3DCOLOR color)
     DWORD *ptr;
 
     hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
 
     for (y = 0; y < surface_desc.dwHeight; ++y)
     {
@@ -383,7 +383,7 @@ static void fill_surface(IDirectDrawSurface *surface, D3DCOLOR color)
     }
 
     hr = IDirectDrawSurface_Unlock(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 }
 
 static void check_rect(IDirectDrawSurface *surface, RECT r)
@@ -417,7 +417,7 @@ static void check_rect(IDirectDrawSurface *surface, RECT r)
                     if (x < 0 || x >= 640 || y < 0 || y >= 480)
                         continue;
                     color = get_surface_color(surface, x, y);
-                    ok(color == expected, "Pixel (%d, %d) has color %08x, expected %08x.\n", x, y, color, expected);
+                    ok(color == expected, "Pixel (%ld, %ld) has color %08lx, expected %08lx.\n", x, y, color, expected);
                 }
             }
         }
@@ -595,7 +595,7 @@ static void set_execute_data(IDirect3DExecuteBuffer *execute_buffer, UINT vertex
     exec_data.dwInstructionOffset = offset;
     exec_data.dwInstructionLength = len;
     hr = IDirect3DExecuteBuffer_SetExecuteData(execute_buffer, &exec_data);
-    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#lx.\n", hr);
 }
 
 static DWORD get_device_z_depth(IDirect3DDevice *device)
@@ -646,7 +646,7 @@ static IDirect3DDevice *create_device_ex(IDirectDraw *ddraw, HWND window, DWORD
     HRESULT hr;
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, coop_level);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -658,18 +658,18 @@ static IDirect3DDevice *create_device_ex(IDirectDraw *ddraw, HWND window, DWORD
     surface_desc.dwHeight = 480;
 
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     if (coop_level & DDSCL_NORMAL)
     {
         IDirectDrawClipper *clipper;
 
         hr = IDirectDraw_CreateClipper(ddraw, 0, &clipper, NULL);
-        ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
         hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
-        ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
         hr = IDirectDrawSurface_SetClipper(surface, clipper);
-        ok(SUCCEEDED(hr), "Failed to set surface clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set surface clipper, hr %#lx.\n", hr);
         IDirectDrawClipper_Release(clipper);
     }
 
@@ -691,7 +691,7 @@ static IDirect3DDevice *create_device_ex(IDirectDraw *ddraw, HWND window, DWORD
             continue;
 
         hr = IDirectDrawSurface_AddAttachedSurface(surface, ds);
-        ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
         IDirectDrawSurface_Release(ds);
         if (FAILED(hr))
             continue;
@@ -719,11 +719,11 @@ static IDirect3DViewport *create_viewport(IDirect3DDevice *device, UINT x, UINT
     HRESULT hr;
 
     hr = IDirect3DDevice_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D_CreateViewport(d3d, &viewport, NULL);
-    ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice_AddViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to add viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to add viewport, hr %#lx.\n", hr);
     memset(&vp, 0, sizeof(vp));
     vp.dwSize = sizeof(vp);
     vp.dwX = x;
@@ -737,7 +737,7 @@ static IDirect3DViewport *create_viewport(IDirect3DDevice *device, UINT x, UINT
     vp.dvMinZ = 0.0f;
     vp.dvMaxZ = 1.0f;
     hr = IDirect3DViewport_SetViewport(viewport, &vp);
-    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#lx.\n", hr);
     IDirect3D_Release(d3d);
 
     return viewport;
@@ -750,9 +750,9 @@ static void viewport_set_background(IDirect3DDevice *device, IDirect3DViewport *
     HRESULT hr;
 
     hr = IDirect3DMaterial2_GetHandle(material, device, &material_handle);
-    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#lx.\n", hr);
     hr = IDirect3DViewport2_SetBackground(viewport, material_handle);
-    ok(SUCCEEDED(hr), "Failed to set viewport background, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport background, hr %#lx.\n", hr);
 }
 
 static void destroy_viewport(IDirect3DDevice *device, IDirect3DViewport *viewport)
@@ -760,7 +760,7 @@ static void destroy_viewport(IDirect3DDevice *device, IDirect3DViewport *viewpor
     HRESULT hr;
 
     hr = IDirect3DDevice_DeleteViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to delete viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to delete viewport, hr %#lx.\n", hr);
     IDirect3DViewport_Release(viewport);
 }
 
@@ -771,11 +771,11 @@ static IDirect3DMaterial *create_material(IDirect3DDevice *device, D3DMATERIAL *
     HRESULT hr;
 
     hr = IDirect3DDevice_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D_CreateMaterial(d3d, &material, NULL);
-    ok(SUCCEEDED(hr), "Failed to create material, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create material, hr %#lx.\n", hr);
     hr = IDirect3DMaterial_SetMaterial(material, mat);
-    ok(SUCCEEDED(hr), "Failed to set material data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set material data, hr %#lx.\n", hr);
     IDirect3D_Release(d3d);
 
     return material;
@@ -865,7 +865,7 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
     {
         if (expect_messages->check_wparam)
             ok (wparam == expect_messages->expect_wparam,
-                    "Got unexpected wparam %lx for message %x, expected %lx.\n",
+                    "Got unexpected wparam %Ix for message %x, expected %Ix.\n",
                     wparam, message, expect_messages->expect_wparam);
 
         ++expect_messages;
@@ -887,9 +887,9 @@ static void fix_wndproc(HWND window, LONG_PTR proc)
 
     SetWindowLongPtrA(window, GWLP_WNDPROC, proc);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     IDirectDraw_Release(ddraw);
 }
@@ -897,7 +897,7 @@ static void fix_wndproc(HWND window, LONG_PTR proc)
 static HRESULT CALLBACK restore_callback(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context)
 {
     HRESULT hr = IDirectDrawSurface_Restore(surface);
-    ok(SUCCEEDED(hr) || hr == DDERR_IMPLICITLYCREATED, "Failed to restore surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || hr == DDERR_IMPLICITLYCREATED, "Failed to restore surface, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface);
 
     return DDENUMRET_OK;
@@ -920,23 +920,23 @@ static void test_coop_level_create_device_window(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
 
@@ -950,48 +950,48 @@ static void test_coop_level_create_device_window(void)
     }
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, focus_window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
             | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOHWND, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!!device_window, "Device window not found.\n");
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
             | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!!device_window, "Device window not found.\n");
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!!device_window, "Device window not found.\n");
 
@@ -1065,22 +1065,22 @@ static void test_clipper_blt(void)
     ok(ret, "Failed to map client rect.\n");
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     hr = IDirectDraw_CreateClipper(ddraw, 0, &clipper, NULL);
-    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
-    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#lx.\n", hr);
     rgn_data = HeapAlloc(GetProcessHeap(), 0, ret);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, rgn_data, &ret);
-    ok(SUCCEEDED(hr), "Failed to get clip list, hr %#x.\n", hr);
-    ok(rgn_data->rdh.dwSize == sizeof(rgn_data->rdh), "Got unexpected structure size %#x.\n", rgn_data->rdh.dwSize);
-    ok(rgn_data->rdh.iType == RDH_RECTANGLES, "Got unexpected type %#x.\n", rgn_data->rdh.iType);
-    ok(rgn_data->rdh.nCount >= 1, "Got unexpected count %u.\n", rgn_data->rdh.nCount);
+    ok(SUCCEEDED(hr), "Failed to get clip list, hr %#lx.\n", hr);
+    ok(rgn_data->rdh.dwSize == sizeof(rgn_data->rdh), "Got unexpected structure size %#lx.\n", rgn_data->rdh.dwSize);
+    ok(rgn_data->rdh.iType == RDH_RECTANGLES, "Got unexpected type %#lx.\n", rgn_data->rdh.iType);
+    ok(rgn_data->rdh.nCount >= 1, "Got unexpected count %lu.\n", rgn_data->rdh.nCount);
     ok(EqualRect(&rgn_data->rdh.rcBound, &client_rect),
             "Got unexpected bounding rect %s, expected %s.\n",
             wine_dbgstr_rect(&rgn_data->rdh.rcBound), wine_dbgstr_rect(&client_rect));
@@ -1100,11 +1100,11 @@ static void test_clipper_blt(void)
     DeleteObject(r1);
 
     hr = IDirectDrawClipper_SetClipList(clipper, rgn_data, 0);
-    ok(hr == DDERR_CLIPPERISUSINGHWND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CLIPPERISUSINGHWND, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetHWnd(clipper, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetClipList(clipper, rgn_data, 0);
-    ok(SUCCEEDED(hr), "Failed to set clip list, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clip list, hr %#lx.\n", hr);
 
     HeapFree(GetProcessHeap(), 0, rgn_data);
 
@@ -1122,33 +1122,33 @@ static void test_clipper_blt(void)
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff;
 
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#lx.\n", hr);
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &dst_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     hr = IDirectDrawSurface_Blt(src_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(src_surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#x.\n", hr);
-    ok(U1(surface_desc).lPitch == 2560, "Got unexpected surface pitch %u.\n", U1(surface_desc).lPitch);
+    ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#lx.\n", hr);
+    ok(U1(surface_desc).lPitch == 2560, "Got unexpected surface pitch %lu.\n", U1(surface_desc).lPitch);
     ptr = surface_desc.lpSurface;
     memcpy(&ptr[   0], &src_data[ 0], 6 * sizeof(DWORD));
     memcpy(&ptr[ 640], &src_data[ 6], 6 * sizeof(DWORD));
     memcpy(&ptr[1280], &src_data[12], 6 * sizeof(DWORD));
     hr = IDirectDrawSurface_Unlock(src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_SetClipper(dst_surface, clipper);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
 
     SetRect(&src_rect, 1, 1, 5, 2);
     hr = IDirectDrawSurface_Blt(dst_surface, NULL, src_surface, &src_rect, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
     for (i = 0; i < 4; ++i)
     {
         for (j = 0; j < 4; ++j)
@@ -1158,13 +1158,13 @@ static void test_clipper_blt(void)
             color = get_surface_color(dst_surface, x, y);
             ok(compare_color(color, expected1[i * 4 + j], 1)
                     || broken(compare_color(color, expected1_broken[i * 4 + j], 1)),
-                    "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected1[i * 4 + j], x, y, color);
+                    "Expected color 0x%08lx at %u,%u, got 0x%08lx.\n", expected1[i * 4 + j], x, y, color);
         }
     }
 
     U5(fx).dwFillColor = 0xff0000ff;
     hr = IDirectDrawSurface_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#lx.\n", hr);
     for (i = 0; i < 4; ++i)
     {
         for (j = 0; j < 4; ++j)
@@ -1173,35 +1173,35 @@ static void test_clipper_blt(void)
             y = 60 * ((2 * i) + 1);
             color = get_surface_color(dst_surface, x, y);
             ok(compare_color(color, expected2[i * 4 + j], 1),
-                    "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
+                    "Expected color 0x%08lx at %u,%u, got 0x%08lx.\n", expected2[i * 4 + j], x, y, color);
         }
     }
 
     hr = IDirectDrawSurface_BltFast(dst_surface, 0, 0, src_surface, NULL, DDBLTFAST_WAIT);
-    ok(hr == DDERR_BLTFASTCANTCLIP || broken(hr == E_NOTIMPL /* NT4 */), "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_BLTFASTCANTCLIP || broken(hr == E_NOTIMPL /* NT4 */), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
-    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#lx.\n", hr);
     DestroyWindow(window);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetHWnd(clipper, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetClipList(clipper, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to set clip list, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clip list, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(dst_surface);
     IDirectDrawSurface_Release(src_surface);
     refcount = IDirectDrawClipper_Release(clipper);
-    ok(!refcount, "Clipper has %u references left.\n", refcount);
+    ok(!refcount, "Clipper has %lu references left.\n", refcount);
     IDirectDraw_Release(ddraw);
 }
 
@@ -1235,31 +1235,31 @@ static void test_coop_level_d3d_state(void)
     viewport_set_background(device, viewport, background);
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(rt);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     memset(&lock, 0, sizeof(lock));
     lock.dwSize = sizeof(lock);
     lock.lpSurface = (void *)0xdeadbeef;
     hr = IDirectDrawSurface_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     ok(lock.lpSurface == (void *)0xdeadbeef, "Got unexpected lock.lpSurface %p.\n", lock.lpSurface);
 
     hr = restore_surfaces(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface2_Unlock(rt, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&material, 0, sizeof(material));
     material.dwSize = sizeof(material);
@@ -1268,16 +1268,16 @@ static void test_coop_level_d3d_state(void)
     U3(U(material).diffuse).b = 0.0f;
     U4(U(material).diffuse).a = 1.0f;
     hr = IDirect3DMaterial_SetMaterial(background, &material);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(surface == rt, "Got unexpected surface %p.\n", surface);
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
     ok(compare_color(color, 0x0000ff00, 1) || broken(compare_color(color, 0x00000000, 1)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
 
     destroy_viewport(device, viewport);
     destroy_material(background);
@@ -1327,7 +1327,7 @@ static void test_surface_interface_mismatch(void)
     surface_desc.dwHeight = 480;
 
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3);
     if (FAILED(hr))
@@ -1344,15 +1344,15 @@ static void test_surface_interface_mismatch(void)
     surface_desc.dwWidth = 640;
     surface_desc.dwHeight = 480;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &ds, NULL);
-    ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#lx.\n", hr);
     if (FAILED(hr))
         goto cleanup;
 
     /* Using a different surface interface version still works */
     hr = IDirectDrawSurface3_AddAttachedSurface(surface3, (IDirectDrawSurface3 *)ds);
-    ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
     refcount = IDirectDrawSurface_Release(ds);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     if (FAILED(hr))
         goto cleanup;
 
@@ -1367,9 +1367,9 @@ static void test_surface_interface_mismatch(void)
     viewport_set_background(device, viewport, background);
 
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
     color = get_surface_color(surface, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
 cleanup:
     if (viewport)
@@ -1394,7 +1394,7 @@ static void test_coop_level_threaded(void)
     create_window_thread(&p);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, p.window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     destroy_window_thread(&p);
     IDirectDraw_Release(ddraw);
@@ -1447,79 +1447,79 @@ static void test_viewport_object(void)
     }
 
     hr = IDirectDraw_QueryInterface(ddraw, &IID_IDirect3D, (void **)&d3d);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *) d3d);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
 
     hr = IDirect3D_CreateViewport(d3d, &viewport, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *)viewport);
-    ok(ref == 1, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 1, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount((IUnknown *)d3d);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
 
     memset(&desc, 0, sizeof(desc));
     hr = IDirect3DViewport_GetViewport(viewport, &desc.vp1);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     desc.vp1.dwSize = sizeof(desc.vp1) + 1;
     hr = IDirect3DViewport_GetViewport(viewport, &desc.vp1);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     desc.vp1.dwSize = sizeof(desc.vp1) - 1;
     hr = IDirect3DViewport_GetViewport(viewport, &desc.vp1);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     desc.vp1.dwSize = sizeof(desc.vp1);
     hr = IDirect3DViewport_GetViewport(viewport, &desc.vp1);
-    ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
-    ok(desc.vp1.dwSize == sizeof(desc.vp1), "Got unexpected dwSize %u.\n", desc.vp1.dwSize);
+    ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#lx.\n", hr);
+    ok(desc.vp1.dwSize == sizeof(desc.vp1), "Got unexpected dwSize %lu.\n", desc.vp1.dwSize);
 
     /* E_FAIL return values are returned by Winetestbot Windows NT machines. While not supporting
      * newer interfaces is legitimate for old ddraw versions, E_FAIL violates Microsoft's rules
      * for QueryInterface, hence the broken() */
     gamma = (IDirectDrawGammaControl *)0xdeadbeef;
     hr = IDirect3DViewport_QueryInterface(viewport, &IID_IDirectDrawGammaControl, (void **)&gamma);
-    ok(hr == E_NOINTERFACE || broken(hr == E_FAIL), "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOINTERFACE || broken(hr == E_FAIL), "Got unexpected hr %#lx.\n", hr);
     ok(gamma == NULL, "Interface not set to NULL by failed QI call: %p\n", gamma);
 
     hr = IDirect3DViewport_QueryInterface(viewport, &IID_IDirect3DViewport2, (void **)&viewport2);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     ref = get_refcount((IUnknown *)viewport);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount((IUnknown *)viewport2);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
 
     hr = IDirect3DViewport_QueryInterface(viewport, &IID_IDirect3DViewport3, (void **)&viewport3);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     ref = get_refcount((IUnknown *)viewport);
-    ok(ref == 3, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 3, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount((IUnknown *)viewport3);
-    ok(ref == 3, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 3, "Got unexpected refcount %lu.\n", ref);
     IDirect3DViewport3_Release(viewport3);
 
     hr = IDirect3DViewport_QueryInterface(viewport, &IID_IUnknown, (void **)&unknown);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *)viewport);
-    ok(ref == 3, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 3, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount(unknown);
-    ok(ref == 3, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 3, "Got unexpected refcount %lu.\n", ref);
     IUnknown_Release(unknown);
 
     hr = IDirect3DDevice_DeleteViewport(device, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3D_CreateViewport(d3d, &another_vp, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* AddViewport(NULL): Segfault */
     hr = IDirect3DDevice_AddViewport(device, viewport);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *) viewport);
-    ok(ref == 3, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 3, "Got unexpected refcount %lu.\n", ref);
     hr = IDirect3DDevice_AddViewport(device, another_vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *) another_vp);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
 
     memset(&vp, 0, sizeof(vp));
     vp.dwX = 0;
@@ -1533,11 +1533,11 @@ static void test_viewport_object(void)
     vp.dvMaxX = 1.0f;
     vp.dvMaxY = 1.0f;
     hr = IDirect3DViewport_SetViewport(viewport, &vp);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     vp.dwSize = sizeof(vp);
     hr = IDirect3DViewport_SetViewport(viewport, &vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     vp2.dwSize = sizeof(vp2);
     vp2.dwX = 160;
@@ -1551,12 +1551,12 @@ static void test_viewport_object(void)
     vp2.dvMinZ = 0.5f;
     vp2.dvMaxZ = 2.0f;
     hr = IDirect3DViewport2_SetViewport2(viewport2, &vp2);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vp, 0xff, sizeof(vp));
     vp.dwSize = sizeof(vp);
     hr = IDirect3DViewport2_GetViewport(viewport2, &vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(vp.dvMaxX == 4.5f && vp.dvMaxY == -1.75f && vp.dvScaleX == 192.0f
             && vp.dvScaleY == -240.0f && vp.dvMinZ == 0.0f && vp.dvMaxZ == 1.0f,
             "Got unexpected values %g, %g, %g, %g, %g, %g.\n",
@@ -1570,12 +1570,12 @@ static void test_viewport_object(void)
     vp2.dvMaxZ = 0.5f;
 
     hr = IDirect3DViewport2_SetViewport2(viewport2, &vp2);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vp, 0xff, sizeof(vp));
     vp.dwSize = sizeof(vp);
     hr = IDirect3DViewport2_GetViewport(viewport2, &vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(vp.dvMaxX == -3.0f && vp.dvMaxY == 1.75f && vp.dvScaleX == -320.0f
             && vp.dvScaleY == 180.0f && vp.dvMinZ == 0.0f && vp.dvMaxZ == 1.0f,
             "Got unexpected values %g, %g, %g, %g, %g, %g.\n",
@@ -1585,12 +1585,12 @@ static void test_viewport_object(void)
     vp.dvMinZ = 0.5f;
     vp.dvMaxZ = 2.0f;
     hr = IDirect3DViewport2_SetViewport(viewport2, &vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vp2, 0xff, sizeof(vp2));
     vp2.dwSize = sizeof(vp2);
     hr = IDirect3DViewport2_GetViewport2(viewport2, &vp2);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(vp2.dvClipX == 0.75f && vp2.dvClipY == 1.0f && vp2.dvClipWidth == -1.5f
             && vp2.dvClipHeight == 2.0f && vp2.dvMinZ == 0.0f && vp2.dvMaxZ == 1.0f,
             "Got unexpected values %g, %g, %g, %g, %g, %g.\n",
@@ -1604,12 +1604,12 @@ static void test_viewport_object(void)
     vp.dvMaxZ = 0.5f;
 
     hr = IDirect3DViewport3_SetViewport(viewport3, &vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vp2, 0xff, sizeof(vp2));
     vp2.dwSize = sizeof(vp2);
     hr = IDirect3DViewport2_GetViewport2(viewport2, &vp2);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(vp2.dvClipX == -1.25f && vp2.dvClipY == -0.75f && vp2.dvClipWidth == 2.5f
             && vp2.dvClipHeight == -1.5f && vp2.dvMinZ == 0.0f && vp2.dvMaxZ == 1.0f,
             "Got unexpected values %g, %g, %g, %g, %g, %g.\n",
@@ -1618,16 +1618,16 @@ static void test_viewport_object(void)
     IDirect3DViewport2_Release(viewport2);
 
     hr = IDirect3DDevice_DeleteViewport(device, another_vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *) another_vp);
-    ok(ref == 1, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 1, "Got unexpected refcount %lu.\n", ref);
 
     IDirect3DDevice_Release(device);
     ref = get_refcount((IUnknown *) viewport);
-    ok(ref == 1, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 1, "Got unexpected refcount %lu.\n", ref);
 
     hr = IDirect3DViewport_SetViewport(viewport, &vp);
-    ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DViewport_Release(another_vp);
     IDirect3D_Release(d3d);
@@ -1683,9 +1683,9 @@ static void test_zenable(const GUID *device_guid)
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
 
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#lx.\n", hr);
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#lx.\n", hr);
     memcpy(exec_desc.lpData, tquad, sizeof(tquad));
     ptr = ((BYTE *)exec_desc.lpData) + sizeof(tquad);
     emit_process_vertices(&ptr, D3DPROCESSVERTICES_COPY, 0, 4);
@@ -1695,20 +1695,20 @@ static void test_zenable(const GUID *device_guid)
     inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData;
     inst_length -= sizeof(tquad);
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     set_execute_data(execute_buffer, 4, sizeof(tquad), inst_length);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     for (i = 0; i < 4; ++i)
     {
         for (j = 0; j < 4; ++j)
@@ -1717,7 +1717,7 @@ static void test_zenable(const GUID *device_guid)
             y = 60 * ((2 * i) + 1);
             color = get_surface_color(rt, x, y);
             ok(compare_color(color, 0x0000ff00, 1),
-                    "Expected color 0x0000ff00 at %u, %u, got 0x%08x.\n", x, y, color);
+                    "Expected color 0x0000ff00 at %u, %u, got 0x%08lx.\n", x, y, color);
         }
     }
     IDirectDrawSurface_Release(rt);
@@ -1831,11 +1831,11 @@ static void test_ck_rgba(const GUID *device_guid)
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0xff00ff00;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0xff00ff00;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture, (void **)&texture);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture_GetHandle(texture, device, &texture_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3DTexture_Release(texture);
 
     memset(&exec_desc, 0, sizeof(exec_desc));
@@ -1844,10 +1844,10 @@ static void test_ck_rgba(const GUID *device_guid)
     exec_desc.dwBufferSize = 1024;
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -1855,7 +1855,7 @@ static void test_ck_rgba(const GUID *device_guid)
         void *ptr;
 
         hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         memcpy(exec_desc.lpData, tquad, sizeof(tquad));
         ptr = ((BYTE *)exec_desc.lpData) + sizeof(tquad);
         emit_process_vertices(&ptr, D3DPROCESSVERTICES_COPY, 0, 4);
@@ -1882,45 +1882,45 @@ static void test_ck_rgba(const GUID *device_guid)
         emit_end(&ptr);
         draw2_len = (BYTE *)ptr - (BYTE *)exec_desc.lpData - draw1_len;
         hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         memset(&fx, 0, sizeof(fx));
         fx.dwSize = sizeof(fx);
         U5(fx).dwFillColor = tests[i].fill_color;
         hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         /* RT clears are broken on Windows for software render target. */
         if (is_software_device_type(device_guid))
             fill_surface(rt, 0xffff0000);
 
         hr = IDirect3DDevice_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         set_execute_data(execute_buffer, 8, sizeof(tquad), draw1_len);
         hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, tests[i].result1, 2)
                 || broken(compare_color(color, tests[i].result1_r200, 1))
                 || broken(compare_color(color, tests[i].result1_warp, 1)),
-                "Got unexpected color 0x%08x for test %u.\n", color, i);
+                "Got unexpected color 0x%08lx for test %u.\n", color, i);
 
         U5(fx).dwFillColor = 0xff0000ff;
         hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         set_execute_data(execute_buffer, 8, sizeof(tquad) + draw1_len, draw2_len);
         hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         /* This tests that fragments that are masked out by the color key are
          * discarded, instead of just fully transparent. */
@@ -1928,7 +1928,7 @@ static void test_ck_rgba(const GUID *device_guid)
         ok(compare_color(color, tests[i].result2, 2)
                 || broken(compare_color(color, tests[i].result2_r200, 1))
                 || broken(compare_color(color, tests[i].result2_warp, 1)),
-                "Got unexpected color 0x%08x for test %u.\n", color, i);
+                "Got unexpected color 0x%08lx for test %u.\n", color, i);
     }
 
     IDirectDrawSurface_Release(rt);
@@ -1983,7 +1983,7 @@ static void test_ck_default(void)
     }
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     background = create_diffuse_material(device, 0.0, 1.0f, 0.0f, 1.0f);
     viewport = create_viewport(device, 0, 0, 640, 480);
@@ -2004,18 +2004,18 @@ static void test_ck_default(void)
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x000000ff;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x000000ff;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture, (void **)&texture);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirect3DTexture_GetHandle(texture, device, &texture_handle);
-    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#lx.\n", hr);
     IDirect3DTexture_Release(texture);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 0x000000ff;
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#lx.\n", hr);
 
     memset(&exec_desc, 0, sizeof(exec_desc));
     exec_desc.dwSize = sizeof(exec_desc);
@@ -2023,10 +2023,10 @@ static void test_ck_default(void)
     exec_desc.dwBufferSize = 1024;
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#lx.\n", hr);
     memcpy(exec_desc.lpData, tquad, sizeof(tquad));
     ptr = (BYTE *)exec_desc.lpData + sizeof(tquad);
     emit_process_vertices(&ptr, D3DPROCESSVERTICES_COPY, 0, 4);
@@ -2054,59 +2054,59 @@ static void test_ck_default(void)
     draw4_offset = draw3_offset + draw3_len;
     draw4_len = (BYTE *)ptr - (BYTE *)exec_desc.lpData - draw4_offset;
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     set_execute_data(execute_buffer, 4, draw1_offset, draw1_len);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
     /* Color keying is supposed to be on by default in ddraw1, but used only if a ckey is set.
      * WARP begs to differ. The default of D3DRENDERSTATE_COLORKEYENABLE is random, and it
      * doesn't mind the absence of a color key (the latter part affects other tests, not this one). */
     ok(compare_color(color, 0x0000ff00, 1) || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x000000ff, 1)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     set_execute_data(execute_buffer, 4, draw2_offset, draw2_len);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     set_execute_data(execute_buffer, 4, draw3_offset, draw3_len);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     set_execute_data(execute_buffer, 4, draw4_offset, draw4_len);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirect3DExecuteBuffer_Release(execute_buffer);
     IDirectDrawSurface_Release(surface);
@@ -2150,20 +2150,20 @@ static void test_ck_complex(void)
     surface_desc.dwWidth = 128;
     surface_desc.dwHeight = 128;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
     color_key.dwColorSpaceLowValue = 0x0000ff00;
     color_key.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     memset(&color_key, 0, sizeof(color_key));
     hr = IDirectDrawSurface_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceLowValue);
-    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceHighValue);
 
     mipmap = surface;
@@ -2171,20 +2171,20 @@ static void test_ck_complex(void)
     for (i = 0; i < 7; ++i)
     {
         hr = IDirectDrawSurface_GetAttachedSurface(mipmap, &caps, &tmp);
-        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#lx.\n", i, hr);
 
         hr = IDirectDrawSurface_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-        ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x, i %u.\n", hr, i);
+        ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx, i %u.\n", hr, i);
         color_key.dwColorSpaceLowValue = 0x000000ff;
         color_key.dwColorSpaceHighValue = 0x000000ff;
         hr = IDirectDrawSurface_SetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-        ok(SUCCEEDED(hr), "Failed to set color key, hr %#x, i %u.\n", hr, i);
+        ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx, i %u.\n", hr, i);
         memset(&color_key, 0, sizeof(color_key));
         hr = IDirectDrawSurface_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-        ok(SUCCEEDED(hr), "Failed to get color key, hr %#x, i %u.\n", hr, i);
-        ok(color_key.dwColorSpaceLowValue == 0x000000ff, "Got unexpected value 0x%08x, i %u.\n",
+        ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx, i %u.\n", hr, i);
+        ok(color_key.dwColorSpaceLowValue == 0x000000ff, "Got unexpected value 0x%08lx, i %u.\n",
                 color_key.dwColorSpaceLowValue, i);
-        ok(color_key.dwColorSpaceHighValue == 0x000000ff, "Got unexpected value 0x%08x, i %u.\n",
+        ok(color_key.dwColorSpaceHighValue == 0x000000ff, "Got unexpected value 0x%08lx, i %u.\n",
                 color_key.dwColorSpaceHighValue, i);
 
         IDirectDrawSurface_Release(mipmap);
@@ -2193,17 +2193,17 @@ static void test_ck_complex(void)
 
     memset(&color_key, 0, sizeof(color_key));
     hr = IDirectDrawSurface_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceLowValue);
-    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceHighValue);
 
     hr = IDirectDrawSurface_GetAttachedSurface(mipmap, &caps, &tmp);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface_Release(mipmap);
     refcount = IDirectDrawSurface_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -2211,45 +2211,45 @@ static void test_ck_complex(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     surface_desc.dwBackBufferCount = 1;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
     color_key.dwColorSpaceLowValue = 0x0000ff00;
     color_key.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     memset(&color_key, 0, sizeof(color_key));
     hr = IDirectDrawSurface_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceLowValue);
-    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceHighValue);
 
     hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &tmp);
-    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x, i %u.\n", hr, i);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx, i %u.\n", hr, i);
     color_key.dwColorSpaceLowValue = 0x0000ff00;
     color_key.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface_SetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     memset(&color_key, 0, sizeof(color_key));
     hr = IDirectDrawSurface_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceLowValue);
-    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceHighValue);
 
     IDirectDrawSurface_Release(tmp);
 
     refcount = IDirectDrawSurface_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -2271,13 +2271,13 @@ static void test_qi(const char *test_name, IUnknown *base_iface,
     for (i = 0; i < entry_count; ++i)
     {
         hr = IUnknown_QueryInterface(base_iface, tests[i].iid, (void **)&iface1);
-        ok(hr == tests[i].hr, "Got hr %#x for test \"%s\" %u.\n", hr, test_name, i);
+        ok(hr == tests[i].hr, "Got hr %#lx for test \"%s\" %u.\n", hr, test_name, i);
         if (SUCCEEDED(hr))
         {
             for (j = 0; j < entry_count; ++j)
             {
                 hr = IUnknown_QueryInterface(iface1, tests[j].iid, (void **)&iface2);
-                ok(hr == tests[j].hr, "Got hr %#x for test \"%s\" %u, %u.\n", hr, test_name, i, j);
+                ok(hr == tests[j].hr, "Got hr %#lx for test \"%s\" %u, %u.\n", hr, test_name, i, j);
                 if (SUCCEEDED(hr))
                 {
                     expected_refcount = 0;
@@ -2286,7 +2286,7 @@ static void test_qi(const char *test_name, IUnknown *base_iface,
                     if (IsEqualGUID(tests[i].refcount_iid, tests[j].refcount_iid))
                         ++expected_refcount;
                     refcount = IUnknown_Release(iface2);
-                    ok(refcount == expected_refcount, "Got refcount %u for test \"%s\" %u, %u, expected %u.\n",
+                    ok(refcount == expected_refcount, "Got refcount %lu for test \"%s\" %u, %u, expected %lu.\n",
                             refcount, test_name, i, j, expected_refcount);
                 }
             }
@@ -2295,7 +2295,7 @@ static void test_qi(const char *test_name, IUnknown *base_iface,
             if (IsEqualGUID(refcount_iid, tests[i].refcount_iid))
                 ++expected_refcount;
             refcount = IUnknown_Release(iface1);
-            ok(refcount == expected_refcount, "Got refcount %u for test \"%s\" %u, expected %u.\n",
+            ok(refcount == expected_refcount, "Got refcount %lu for test \"%s\" %u, expected %lu.\n",
                     refcount, test_name, i, expected_refcount);
         }
     }
@@ -2378,9 +2378,9 @@ static void test_surface_qi(void)
     surface_desc.dwWidth = 512;
     surface_desc.dwHeight = 512;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, (IDirectDrawSurface **)0xdeadbeef, NULL);
-    ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     test_qi("surface_qi", (IUnknown *)surface, &IID_IDirectDrawSurface, tests, ARRAY_SIZE(tests));
 
@@ -2492,36 +2492,36 @@ static void test_wndproc(void)
             WS_MAXIMIZE | WS_CAPTION , 0, 0, 640, 480, 0, 0, 0, 0);
 
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     expect_messages = messages;
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     ref = IDirectDraw_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     /* DDSCL_NORMAL doesn't. */
     ddraw = create_ddraw();
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     ref = IDirectDraw_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     /* The original window proc is only restored by ddraw if the current
@@ -2529,53 +2529,53 @@ static void test_wndproc(void)
      * from DDSCL_NORMAL to DDSCL_EXCLUSIVE. */
     ddraw = create_ddraw();
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     ddraw_proc = proc;
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)DefWindowProcA, proc);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = SetWindowLongPtrA(window, GWLP_WNDPROC, ddraw_proc);
-    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)DefWindowProcA, proc);
     ref = IDirectDraw_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     ddraw = create_ddraw();
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     ref = IDirectDraw_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)DefWindowProcA, proc);
 
     fix_wndproc(window, (LONG_PTR)test_proc);
@@ -2606,12 +2606,12 @@ static void test_window_style(void)
     SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    todo_wine ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n",
@@ -2623,9 +2623,9 @@ static void test_window_style(void)
     ok(ret, "Failed to set foreground window.\n");
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    todo_wine ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
@@ -2634,77 +2634,77 @@ static void test_window_style(void)
     ShowWindow(window, SW_HIDE);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_NOWINDOWCHANGES);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    todo_wine ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ShowWindow(window, SW_HIDE);
     tmp = GetWindowLongA(window, GWL_STYLE);
-    todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    todo_wine ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_NOWINDOWCHANGES);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ShowWindow(window, SW_HIDE);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     ShowWindow(window, SW_SHOW);
     ret = SetForegroundWindow(GetDesktopWindow());
@@ -2712,20 +2712,20 @@ static void test_window_style(void)
     SetActiveWindow(window);
     ok(GetActiveWindow() == window, "Unexpected active window.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n",
             wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r));
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     SetWindowPos(window, NULL, 0, 0, 100, 100, SWP_NOZORDER | SWP_NOACTIVATE);
     GetWindowRect(window, &r);
@@ -2735,13 +2735,13 @@ static void test_window_style(void)
     ret = SetForegroundWindow(window2);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n",
@@ -2750,46 +2750,46 @@ static void test_window_style(void)
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ShowWindow(window, SW_HIDE);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     ShowWindow(window, SW_SHOW);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE | WS_MINIMIZE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ref = IDirectDraw_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     DestroyWindow(window2);
     DestroyWindow(window);
@@ -2810,15 +2810,15 @@ static void test_redundant_mode_set(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw_GetDisplayMode(ddraw, &surface_desc);
-    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw_SetDisplayMode(ddraw, surface_desc.dwWidth, surface_desc.dwHeight,
             U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
-    ok(SUCCEEDED(hr), "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetDisplayMode failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &q);
     r = q;
@@ -2830,14 +2830,14 @@ static void test_redundant_mode_set(void)
 
     hr = IDirectDraw_SetDisplayMode(ddraw, surface_desc.dwWidth, surface_desc.dwHeight,
             U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
-    ok(SUCCEEDED(hr), "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetDisplayMode failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &s);
     ok(EqualRect(&r, &s) || broken(EqualRect(&q, &s) /* Windows 10 */),
             "Expected %s, got %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&s));
 
     ref = IDirectDraw_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     DestroyWindow(window);
 }
@@ -2976,10 +2976,10 @@ static void test_coop_level_mode_set(void)
     memset(&devmode, 0, sizeof(devmode));
     devmode.dmSize = sizeof(devmode);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
 
     ret = save_display_modes(&original_modes, &display_count);
@@ -2990,9 +2990,9 @@ static void test_coop_level_mode_set(void)
 
     memset(&param, 0, sizeof(param));
     hr = IDirectDraw_EnumDisplayModes(ddraw, 0, NULL, &param, test_coop_level_mode_set_enum_cb);
-    ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#lx.\n", hr);
     ref = IDirectDraw_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     if (!param.user32_height)
     {
@@ -3011,7 +3011,7 @@ static void test_coop_level_mode_set(void)
     devmode.dmPelsWidth = param.user32_width;
     devmode.dmPelsHeight = param.user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
@@ -3024,7 +3024,7 @@ static void test_coop_level_mode_set(void)
             0, 0, 100, 100, 0, 0, 0, 0);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &user32_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&user32_rect),
@@ -3036,12 +3036,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.user32_width, "Expected surface width %lu, got %lu.\n",
             param.user32_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.user32_height, "Expected surface height %lu, got %lu.\n",
             param.user32_height, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3054,16 +3054,16 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
-            "Expected screen size %ux%u, got %ux%u.\n",
+            "Expected screen size %lux%lu, got %lux%lu.\n",
             param.ddraw_width, param.ddraw_height, screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
@@ -3071,10 +3071,10 @@ static void test_coop_level_mode_set(void)
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.user32_width, "Expected surface width %lu, got %lu.\n",
             param.user32_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.user32_height, "Expected surface height %lu, got %lu.\n",
             param.user32_height, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
@@ -3084,12 +3084,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3102,16 +3102,16 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
-            "Expected screen size %ux%u, got %ux%u.\n",
+            "Expected screen size %lux%lu, got %lux%lu.\n",
             param.user32_width, param.user32_height, screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
@@ -3127,7 +3127,7 @@ static void test_coop_level_mode_set(void)
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
-            && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected screen size %ux%u.\n",
+            && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected screen size %lux%lu.\n",
             devmode.dmPelsWidth, devmode.dmPelsHeight);
 
     expect_messages = exclusive_focus_restore_messages;
@@ -3140,11 +3140,11 @@ static void test_coop_level_mode_set(void)
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == param.ddraw_width
-            && devmode.dmPelsHeight == param.ddraw_height, "Got unexpected screen size %ux%u.\n",
+            && devmode.dmPelsHeight == param.ddraw_height, "Got unexpected screen size %lux%lu.\n",
             devmode.dmPelsWidth, devmode.dmPelsHeight);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     /* Normally the primary should be restored here. Unfortunately this causes the
      * GetSurfaceDesc call after the next display mode change to crash on the Windows 8
      * testbot. Another Restore call would presumably avoid the crash, but it also moots
@@ -3166,7 +3166,7 @@ static void test_coop_level_mode_set(void)
     expect_messages = NULL;
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
     expect_messages = exclusive_messages;
@@ -3174,17 +3174,17 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     ok(screen_size.cx == registry_mode.dmPelsWidth
             && screen_size.cy == registry_mode.dmPelsHeight,
-            "Expected screen size %ux%u, got %ux%u.\n",
+            "Expected screen size %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
@@ -3192,16 +3192,16 @@ static void test_coop_level_mode_set(void)
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
     /* For Wine. */
     change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -3209,12 +3209,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3222,17 +3222,17 @@ static void test_coop_level_mode_set(void)
             wine_dbgstr_rect(&r));
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
@@ -3242,12 +3242,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3260,18 +3260,18 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
     devmode.dmPelsWidth = param.user32_width;
     devmode.dmPelsHeight = param.user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
     hr = IDirectDrawSurface_IsLost(primary);
-    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
@@ -3283,7 +3283,7 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
     if (hr == DDERR_NOEXCLUSIVEMODE /* NT4 testbot */)
     {
@@ -3292,25 +3292,25 @@ static void test_coop_level_mode_set(void)
         IDirectDraw_Release(ddraw);
         goto done;
     }
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
@@ -3320,12 +3320,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3338,25 +3338,25 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
@@ -3364,11 +3364,11 @@ static void test_coop_level_mode_set(void)
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
             && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n",
+            "Expected resolution %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
             devmode.dmPelsWidth, devmode.dmPelsHeight);
     change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -3376,12 +3376,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3392,17 +3392,17 @@ static void test_coop_level_mode_set(void)
      * Resizing the window on mode changes is a property of DDSCL_EXCLUSIVE,
      * not DDSCL_FULLSCREEN. */
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
@@ -3412,12 +3412,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3430,18 +3430,18 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
     devmode.dmPelsWidth = param.user32_width;
     devmode.dmPelsHeight = param.user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
     hr = IDirectDrawSurface_IsLost(primary);
-    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
@@ -3453,27 +3453,27 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
@@ -3483,12 +3483,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3501,25 +3501,25 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
@@ -3527,11 +3527,11 @@ static void test_coop_level_mode_set(void)
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
             && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n",
+            "Expected resolution %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
             devmode.dmPelsWidth, devmode.dmPelsHeight);
     change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -3539,12 +3539,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
@@ -3554,12 +3554,12 @@ static void test_coop_level_mode_set(void)
 
     /* Unlike ddraw2-7, changing from EXCLUSIVE to NORMAL does not restore the resolution */
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -3567,19 +3567,19 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
     hr = IDirectDraw_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     ref = IDirectDraw_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &ddraw_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&ddraw_rect),
@@ -3593,36 +3593,36 @@ static void test_coop_level_mode_set(void)
     devmode.dmPelsWidth = param.user32_width;
     devmode.dmPelsHeight = param.user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     ref = IDirectDraw_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     memset(&devmode2, 0, sizeof(devmode2));
     devmode2.dmSize = sizeof(devmode2);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &registry_mode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
 
     /* Test that no mode restorations if no mode changes happened with fullscreen ddraw objects */
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     ref = IDirectDraw_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &registry_mode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -3632,19 +3632,19 @@ static void test_coop_level_mode_set(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     ref = IDirectDraw_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -3653,23 +3653,23 @@ static void test_coop_level_mode_set(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     hr = IDirectDraw_RestoreDisplayMode(ddraw);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
 
     ref = IDirectDraw_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
 done:
     expect_messages = NULL;
@@ -3696,10 +3696,10 @@ static void test_coop_level_mode_set_multi(void)
     memset(&devmode, 0, sizeof(devmode));
     devmode.dmSize = sizeof(devmode);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
 
     ret = save_display_modes(&original_modes, &display_count);
@@ -3720,14 +3720,14 @@ static void test_coop_level_mode_set_multi(void)
         DestroyWindow(window);
         return;
     }
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 600, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3737,7 +3737,7 @@ static void test_coop_level_mode_set_multi(void)
      * the initial mode, before the first SetDisplayMode() call. */
     ddraw1 = create_ddraw();
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3745,21 +3745,21 @@ static void test_coop_level_mode_set_multi(void)
 
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3768,7 +3768,7 @@ static void test_coop_level_mode_set_multi(void)
     /* Regardless of release ordering. */
     ddraw1 = create_ddraw();
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3776,21 +3776,21 @@ static void test_coop_level_mode_set_multi(void)
 
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3800,21 +3800,21 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3824,7 +3824,7 @@ static void test_coop_level_mode_set_multi(void)
      * restoring the display mode. */
     ddraw1 = create_ddraw();
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3832,24 +3832,24 @@ static void test_coop_level_mode_set_multi(void)
 
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw2, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     ref = IDirectDraw_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3858,28 +3858,28 @@ static void test_coop_level_mode_set_multi(void)
     /* Exclusive mode blocks mode setting on other ddraw objects in general. */
     ddraw1 = create_ddraw();
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 600, "Got unexpected screen height %u.\n", h);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw1, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
 
     ref = IDirectDraw_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3907,7 +3907,7 @@ static void test_coop_level_mode_set_multi(void)
     memset(&old_devmode, 0, sizeof(old_devmode));
     old_devmode.dmSize = sizeof(old_devmode);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &old_devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
 
     devmode = old_devmode;
     while (EnumDisplaySettingsW(second_monitor_name, mode_idx++, &devmode))
@@ -3924,32 +3924,32 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ok(!!ddraw1, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw1, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     memset(&devmode2, 0, sizeof(devmode2));
     devmode2.dmSize = sizeof(devmode2);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     if (compare_mode_rect(&devmode2, &old_devmode))
     {
         skip("Failed to change display settings of the second monitor.\n");
         ref = IDirectDraw_Release(ddraw1);
-        ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+        ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
         goto done;
     }
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw1, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     ref = IDirectDraw_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     memset(&devmode3, 0, sizeof(devmode3));
     devmode3.dmSize = sizeof(devmode3);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode3);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode3, &devmode2), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -3959,19 +3959,19 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ok(!!ddraw1, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     ref = IDirectDraw_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -3980,23 +3980,23 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ok(!!ddraw1, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     hr = IDirectDraw_RestoreDisplayMode(ddraw1);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
 
     ref = IDirectDraw_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
 
@@ -4004,24 +4004,24 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ok(!!ddraw1, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL,
             CDS_UPDATEREGISTRY | CDS_NORESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     ref = IDirectDraw_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
+            "Expected resolution %lux%lu, got %lux%lu.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
             devmode2.dmPelsWidth, devmode2.dmPelsHeight);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
+            "Expected resolution %lux%lu, got %lux%lu.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
             devmode2.dmPelsWidth, devmode2.dmPelsHeight);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -4033,27 +4033,27 @@ static void test_coop_level_mode_set_multi(void)
     ddraw2 = create_ddraw();
     ok(!!ddraw2, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     hr = IDirectDraw_RestoreDisplayMode(ddraw2);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
 
     ref = IDirectDraw_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     ref = IDirectDraw_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
 
@@ -4064,25 +4064,25 @@ static void test_coop_level_mode_set_multi(void)
     ddraw2 = create_ddraw();
     ok(!!ddraw2, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     ref = IDirectDraw_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
 
     ref = IDirectDraw_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
 done:
     DestroyWindow(window);
@@ -4101,26 +4101,26 @@ static void test_initialize(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw_Initialize(ddraw, NULL);
-    ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x.\n", hr);
+    ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#lx.\n", hr);
     IDirectDraw_Release(ddraw);
 
     CoInitialize(NULL);
     hr = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectDraw, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to create IDirectDraw instance, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create IDirectDraw instance, hr %#lx.\n", hr);
     hr = IDirectDraw_QueryInterface(ddraw, &IID_IDirect3D, (void **)&d3d);
     if (SUCCEEDED(hr))
     {
         /* IDirect3D_Initialize() just returns DDERR_ALREADYINITIALIZED. */
         hr = IDirect3D_Initialize(d3d, NULL);
-        ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x, expected DDERR_ALREADYINITIALIZED.\n", hr);
+        ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#lx, expected DDERR_ALREADYINITIALIZED.\n", hr);
         IDirect3D_Release(d3d);
     }
     else
         skip("D3D interface is not available, skipping test.\n");
     hr = IDirectDraw_Initialize(ddraw, NULL);
-    ok(hr == DD_OK, "Initialize returned hr %#x, expected DD_OK.\n", hr);
+    ok(hr == DD_OK, "Initialize returned hr %#lx, expected DD_OK.\n", hr);
     hr = IDirectDraw_Initialize(ddraw, NULL);
-    ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x, expected DDERR_ALREADYINITIALIZED.\n", hr);
+    ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#lx, expected DDERR_ALREADYINITIALIZED.\n", hr);
     IDirectDraw_Release(ddraw);
     CoUninitialize();
 
@@ -4128,7 +4128,7 @@ static void test_initialize(void)
     {
         CoInitialize(NULL);
         hr = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_INPROC_SERVER, &IID_IDirect3D, (void **)&d3d);
-        ok(hr == E_NOINTERFACE, "CoCreateInstance returned hr %#x, expected E_NOINTERFACE.\n", hr);
+        ok(hr == E_NOINTERFACE, "CoCreateInstance returned hr %#lx, expected E_NOINTERFACE.\n", hr);
         CoUninitialize();
     }
 }
@@ -4149,20 +4149,20 @@ static void test_coop_level_surf_create(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     surface = (void *)0xdeadbeef;
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "Surface creation returned hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "Surface creation returned hr %#lx.\n", hr);
     ok(surface == (void *)0xdeadbeef, "Got unexpected surface %p.\n", surface);
 
     surface = (void *)0xdeadbeef;
     hr = IDirectDraw_CreateSurface(ddraw, NULL, &surface, NULL);
-    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "Surface creation returned hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "Surface creation returned hr %#lx.\n", hr);
     ok(surface == (void *)0xdeadbeef, "Got unexpected surface %p.\n", surface);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     surface = (void *)0xdeadbeef;
     hr = IDirectDraw_CreateSurface(ddraw, NULL, &surface, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Unexpected hr %#lx.\n", hr);
     ok(surface == (void *)0xdeadbeef, "Got unexpected surface %p.\n", surface);
 
     IDirectDraw_Release(ddraw);
@@ -4180,9 +4180,9 @@ static void test_coop_level_multi_window(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(IsWindow(window1), "Window 1 was destroyed.\n");
     ok(IsWindow(window2), "Window 2 was destroyed.\n");
 
@@ -4215,7 +4215,7 @@ static void test_clear_rect_count(void)
     }
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     white = create_diffuse_material(device, 1.0f, 1.0f, 1.0f, 1.0f);
     red   = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f);
@@ -4225,20 +4225,20 @@ static void test_clear_rect_count(void)
 
     viewport_set_background(device, viewport, white);
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     viewport_set_background(device, viewport, red);
     hr = IDirect3DViewport_Clear(viewport, 0, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     viewport_set_background(device, viewport, green);
     hr = IDirect3DViewport_Clear(viewport, 0, NULL, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     viewport_set_background(device, viewport, blue);
     hr = IDirect3DViewport_Clear(viewport, 1, NULL, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 320, 240);
     ok(compare_color(color, 0x00ffffff, 1) || broken(compare_color(color, 0x000000ff, 1)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface_Release(rt);
     destroy_viewport(device, viewport);
@@ -4269,7 +4269,7 @@ static LRESULT CALLBACK activateapp_test_proc(HWND hwnd, UINT message, WPARAM wp
             activateapp_testdata.received = FALSE;
             hr = IDirectDraw_SetCooperativeLevel(activateapp_testdata.ddraw,
                     activateapp_testdata.window, activateapp_testdata.coop_level);
-            ok(SUCCEEDED(hr), "Recursive SetCooperativeLevel call failed, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Recursive SetCooperativeLevel call failed, hr %#lx.\n", hr);
             ok(!activateapp_testdata.received, "Received WM_ACTIVATEAPP during recursive SetCooperativeLevel call.\n");
         }
         activateapp_testdata.received = TRUE;
@@ -4301,31 +4301,31 @@ static void test_coop_level_activateapp(void)
     SetForegroundWindow(window);
     activateapp_testdata.received = FALSE;
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(!activateapp_testdata.received, "Received WM_ACTIVATEAPP although window was already active.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Exclusive with window not active. */
     SetForegroundWindow(GetDesktopWindow());
     activateapp_testdata.received = FALSE;
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(activateapp_testdata.received, "Expected WM_ACTIVATEAPP, but did not receive it.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Normal with window not active, then exclusive with the same window. */
     SetForegroundWindow(GetDesktopWindow());
     activateapp_testdata.received = FALSE;
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(!activateapp_testdata.received, "Received WM_ACTIVATEAPP when setting DDSCL_NORMAL.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(activateapp_testdata.received, "Expected WM_ACTIVATEAPP, but did not receive it.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Recursive set of DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN. */
     SetForegroundWindow(GetDesktopWindow());
@@ -4334,10 +4334,10 @@ static void test_coop_level_activateapp(void)
     activateapp_testdata.window = window;
     activateapp_testdata.coop_level = DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN;
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(activateapp_testdata.received, "Expected WM_ACTIVATEAPP, but did not receive it.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* The recursive call seems to have some bad effect on native ddraw, despite (apparently)
      * succeeding. Another switch to exclusive and back to normal is needed to release the
@@ -4345,9 +4345,9 @@ static void test_coop_level_activateapp(void)
      * WM_ACTIVATEAPP messages. */
     activateapp_testdata.ddraw = NULL;
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Setting DDSCL_NORMAL with recursive invocation. */
     SetForegroundWindow(GetDesktopWindow());
@@ -4356,7 +4356,7 @@ static void test_coop_level_activateapp(void)
     activateapp_testdata.window = window;
     activateapp_testdata.coop_level = DDSCL_NORMAL;
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(activateapp_testdata.received, "Expected WM_ACTIVATEAPP, but did not receive it.\n");
 
     /* DDraw is in exclusive mode now. */
@@ -4366,15 +4366,15 @@ static void test_coop_level_activateapp(void)
     ddsd.dwBackBufferCount = 1;
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface);
 
     /* Recover again, just to be sure. */
     activateapp_testdata.ddraw = NULL;
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     DestroyWindow(window);
     UnregisterClassA("ddraw_test_wndproc_wc", GetModuleHandleA(NULL));
@@ -4450,7 +4450,7 @@ static void test_unsupported_formats(void)
     {
         struct format_support_check check = {&formats[i].fmt, FALSE};
         hr = IDirect3DDevice_EnumTextureFormats(device, test_unsupported_formats_cb, &check);
-        ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#lx.\n", hr);
 
         for (j = 0; j < ARRAY_SIZE(caps); j++)
         {
@@ -4469,7 +4469,7 @@ static void test_unsupported_formats(void)
 
             hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
             ok(SUCCEEDED(hr) == expect_success,
-                    "Got unexpected hr %#x for format %s, caps %#x, expected %s.\n",
+                    "Got unexpected hr %#lx for format %s, caps %#lx, expected %s.\n",
                     hr, formats[i].name, caps[j], expect_success ? "success" : "failure");
             if (FAILED(hr))
                 continue;
@@ -4477,7 +4477,7 @@ static void test_unsupported_formats(void)
             memset(&ddsd, 0, sizeof(ddsd));
             ddsd.dwSize = sizeof(ddsd);
             hr = IDirectDrawSurface_GetSurfaceDesc(surface, &ddsd);
-            ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
 
             if (caps[j] & DDSCAPS_VIDEOMEMORY)
                 expected_caps = DDSCAPS_VIDEOMEMORY;
@@ -4489,7 +4489,7 @@ static void test_unsupported_formats(void)
                 expected_caps = DDSCAPS_SYSTEMMEMORY;
 
             ok(ddsd.ddsCaps.dwCaps & expected_caps,
-                    "Expected capability %#x, format %s, input cap %#x.\n",
+                    "Expected capability %#lx, format %s, input cap %#lx.\n",
                     expected_caps, formats[i].name, caps[j]);
 
             IDirectDrawSurface_Release(surface);
@@ -4670,12 +4670,12 @@ static void test_rt_caps(const GUID *device_guid)
 
     memset(palette_entries, 0, sizeof(palette_entries));
     hr = IDirectDraw_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, palette_entries, &palette, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw_GetCaps(ddraw, &hal_caps, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
@@ -4710,14 +4710,14 @@ static void test_rt_caps(const GUID *device_guid)
         hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
         ok(hr == expected_hr || broken(test_data[i].create_may_fail
                 || (software_device && test_data[i].pf == &p8_fmt && hr == DDERR_INVALIDPIXELFORMAT)),
-                "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+                "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
         if (FAILED(hr))
             continue;
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-        ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+        ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
 
         if ((caps_in & DDSCAPS_SYSTEMMEMORY) || !(hal_caps.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
             expected_caps = caps_in | DDSCAPS_SYSTEMMEMORY;
@@ -4728,43 +4728,43 @@ static void test_rt_caps(const GUID *device_guid)
                 && surface_desc.ddsCaps.dwCaps == (caps_in | DDSCAPS_SYSTEMMEMORY))
                 || (software_device && caps_in & DDSCAPS_ZBUFFER
                 && surface_desc.ddsCaps.dwCaps == (caps_in | DDSCAPS_SYSTEMMEMORY)),
-                "Got unexpected caps %#x, expected %#x, test %u, software_device %u.\n",
+                "Got unexpected caps %#lx, expected %#lx, test %u, software_device %u.\n",
                 surface_desc.ddsCaps.dwCaps, expected_caps, i, software_device);
 
         hr = IDirectDrawSurface_QueryInterface(surface, device_guid, (void **)&device);
         ok((!software_device && hr == test_data[i].create_device_hr)
                 || (software_device && (hr == (test_data[i].create_device_hr == D3DERR_SURFACENOTINVIDMEM
                 ? DD_OK : test_data[i].create_device_hr))),
-                "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+                "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
         if (hr == DDERR_NOPALETTEATTACHED)
         {
             hr = IDirectDrawSurface_SetPalette(surface, palette);
-            ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+            ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
             hr = IDirectDrawSurface_QueryInterface(surface, device_guid, (void **)&device);
             if (software_device)
                 todo_wine
-                ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n",
+                ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n",
                         hr, i, software_device);
             else if (surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)
-                ok(hr == DDERR_INVALIDPIXELFORMAT, "Got unexpected hr %#x, test %u, software_device %u.\n",
+                ok(hr == DDERR_INVALIDPIXELFORMAT, "Got unexpected hr %#lx, test %u, software_device %u.\n",
                         hr, i, software_device);
             else
-                ok(hr == D3DERR_SURFACENOTINVIDMEM, "Got unexpected hr %#x, test %u, software_device %u.\n",
+                ok(hr == D3DERR_SURFACENOTINVIDMEM, "Got unexpected hr %#lx, test %u, software_device %u.\n",
                         hr, i, software_device);
         }
         if (SUCCEEDED(hr))
         {
             refcount = IDirect3DDevice_Release(device);
-            ok(refcount == 1, "Test %u: Got unexpected refcount %u.\n", i, refcount);
+            ok(refcount == 1, "Test %u: Got unexpected refcount %lu.\n", i, refcount);
         }
 
         refcount = IDirectDrawSurface_Release(surface);
-        ok(refcount == 0, "Test %u: The surface was not properly freed, refcount %u.\n", i, refcount);
+        ok(refcount == 0, "Test %u: The surface was not properly freed, refcount %lu.\n", i, refcount);
     }
 
     IDirectDrawPalette_Release(palette);
     refcount = IDirectDraw_Release(ddraw);
-    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -4889,7 +4889,7 @@ static void test_primary_caps(void)
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirectDraw_SetCooperativeLevel(ddraw, window, test_data[i].coop_level);
-        ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
@@ -4899,23 +4899,23 @@ static void test_primary_caps(void)
         surface_desc.ddsCaps.dwCaps = test_data[i].caps_in;
         surface_desc.dwBackBufferCount = test_data[i].back_buffer_count;
         hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
         if (FAILED(hr))
             continue;
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#lx.\n", i, hr);
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == test_data[i].caps_out,
-                "Test %u: Got unexpected caps %#x, expected %#x.\n",
+                "Test %u: Got unexpected caps %#lx, expected %#lx.\n",
                 i, surface_desc.ddsCaps.dwCaps, test_data[i].caps_out);
 
         IDirectDrawSurface_Release(surface);
     }
 
     refcount = IDirectDraw_Release(ddraw);
-    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -5000,27 +5000,27 @@ static void test_surface_lock(void)
         ddsd.ddsCaps.dwCaps = tests[i].caps;
 
         hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, type %s, hr %#x.\n", tests[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to create surface, type %s, hr %#lx.\n", tests[i].name, hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface_Lock(surface, NULL, &ddsd, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, type %s, hr %#x.\n", tests[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, type %s, hr %#lx.\n", tests[i].name, hr);
         if (SUCCEEDED(hr))
         {
             hr = IDirectDrawSurface_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, type %s, hr %#x.\n", tests[i].name, hr);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, type %s, hr %#lx.\n", tests[i].name, hr);
         }
 
         memset(&ddsd, 0, sizeof(ddsd));
         hr = IDirectDrawSurface_Lock(surface, NULL, &ddsd, DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x, type %s.\n", hr, tests[i].name);
+        ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx, type %s.\n", hr, tests[i].name);
 
         IDirectDrawSurface_Release(surface);
     }
 
     refcount = IDirectDraw_Release(ddraw);
-    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -5071,7 +5071,7 @@ static void test_surface_discard(void)
         }
 
         hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void**)&target);
-        ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
@@ -5089,29 +5089,29 @@ static void test_surface_discard(void)
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface_Lock(surface, NULL, &ddsd, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         addr = ddsd.lpSurface;
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface_Lock(surface, NULL, &ddsd, DDLOCK_DISCARDCONTENTS | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         discarded = ddsd.lpSurface != addr;
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         hr = IDirectDrawSurface_Blt(target, NULL, surface, NULL, DDBLT_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface_Lock(surface, NULL, &ddsd, DDLOCK_DISCARDCONTENTS | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         discarded |= ddsd.lpSurface != addr;
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         IDirectDrawSurface_Release(surface);
 
@@ -5159,7 +5159,7 @@ static void test_flip(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
@@ -5182,90 +5182,90 @@ static void test_flip(void)
         surface_desc.dwHeight = 512;
         surface_desc.dwBackBufferCount = 3;
         hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
 
         surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_FLIP;
         surface_desc.dwFlags |= DDSD_BACKBUFFERCOUNT;
         hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
 
         surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_COMPLEX;
         surface_desc.ddsCaps.dwCaps |= DDSCAPS_FLIP;
         hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
 
         surface_desc.ddsCaps.dwCaps |= DDSCAPS_COMPLEX;
         hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
         todo_wine_if(test_data[i].caps & DDSCAPS_TEXTURE)
-            ok(SUCCEEDED(hr), "%s: Failed to create surface, hr %#x.\n", test_data[i].name, hr);
+            ok(SUCCEEDED(hr), "%s: Failed to create surface, hr %#lx.\n", test_data[i].name, hr);
         if (FAILED(hr))
             continue;
 
         hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-        ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_IsLost(frontbuffer);
-        ok(hr == DD_OK, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DD_OK, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Flip(frontbuffer, NULL, DDFLIP_WAIT);
         if (test_data[i].caps & DDSCAPS_PRIMARYSURFACE)
-            ok(hr == DDERR_NOEXCLUSIVEMODE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+            ok(hr == DDERR_NOEXCLUSIVEMODE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         else
-            ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+            ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-        ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_IsLost(frontbuffer);
-        todo_wine ok(hr == DDERR_SURFACELOST, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        todo_wine ok(hr == DDERR_SURFACELOST, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = restore_surfaces(ddraw);
-        ok(SUCCEEDED(hr), "%s: Failed to restore surfaces, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to restore surfaces, hr %#lx.\n", test_data[i].name, hr);
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface_GetSurfaceDesc(frontbuffer, &surface_desc);
-        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#lx.\n", test_data[i].name, hr);
         expected_caps = DDSCAPS_FRONTBUFFER | DDSCAPS_COMPLEX | DDSCAPS_FLIP | test_data[i].caps;
         if (test_data[i].caps & DDSCAPS_PRIMARYSURFACE)
             expected_caps |= DDSCAPS_VISIBLE;
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == expected_caps,
-                "%s: Got unexpected caps %#x.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
+                "%s: Got unexpected caps %#lx.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
         sysmem_primary = surface_desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY;
 
         hr = IDirectDrawSurface_GetAttachedSurface(frontbuffer, &caps, &backbuffer1);
-        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#lx.\n", test_data[i].name, hr);
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface_GetSurfaceDesc(backbuffer1, &surface_desc);
-        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#x.\n", test_data[i].name, hr);
-        ok(!surface_desc.dwBackBufferCount, "%s: Got unexpected back buffer count %u.\n",
+        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#lx.\n", test_data[i].name, hr);
+        ok(!surface_desc.dwBackBufferCount, "%s: Got unexpected back buffer count %lu.\n",
                 test_data[i].name, surface_desc.dwBackBufferCount);
         expected_caps &= ~(DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER);
         expected_caps |= DDSCAPS_BACKBUFFER;
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == expected_caps,
-                "%s: Got unexpected caps %#x.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
+                "%s: Got unexpected caps %#lx.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
 
         hr = IDirectDrawSurface_GetAttachedSurface(backbuffer1, &caps, &backbuffer2);
-        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#lx.\n", test_data[i].name, hr);
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface_GetSurfaceDesc(backbuffer2, &surface_desc);
-        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#x.\n", test_data[i].name, hr);
-        ok(!surface_desc.dwBackBufferCount, "%s: Got unexpected back buffer count %u.\n",
+        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#lx.\n", test_data[i].name, hr);
+        ok(!surface_desc.dwBackBufferCount, "%s: Got unexpected back buffer count %lu.\n",
                 test_data[i].name, surface_desc.dwBackBufferCount);
         expected_caps &= ~DDSCAPS_BACKBUFFER;
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == expected_caps,
-                "%s: Got unexpected caps %#x.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
+                "%s: Got unexpected caps %#lx.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
 
         hr = IDirectDrawSurface_GetAttachedSurface(backbuffer2, &caps, &backbuffer3);
-        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#lx.\n", test_data[i].name, hr);
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface_GetSurfaceDesc(backbuffer3, &surface_desc);
-        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#x.\n", test_data[i].name, hr);
-        ok(!surface_desc.dwBackBufferCount, "%s: Got unexpected back buffer count %u.\n",
+        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#lx.\n", test_data[i].name, hr);
+        ok(!surface_desc.dwBackBufferCount, "%s: Got unexpected back buffer count %lu.\n",
                 test_data[i].name, surface_desc.dwBackBufferCount);
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == expected_caps,
-                "%s: Got unexpected caps %#x.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
+                "%s: Got unexpected caps %#lx.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
 
         hr = IDirectDrawSurface_GetAttachedSurface(backbuffer3, &caps, &surface);
-        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#lx.\n", test_data[i].name, hr);
         ok(surface == frontbuffer, "%s: Got unexpected surface %p, expected %p.\n",
                 test_data[i].name, surface, frontbuffer);
         IDirectDrawSurface_Release(surface);
@@ -5277,19 +5277,19 @@ static void test_flip(void)
         surface_desc.dwWidth = 640;
         surface_desc.dwHeight = 480;
         hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(SUCCEEDED(hr), "%s: Failed to create surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to create surface, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Flip(frontbuffer, surface, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         IDirectDrawSurface_Release(surface);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, frontbuffer, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Flip(backbuffer1, NULL, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Flip(backbuffer2, NULL, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Flip(backbuffer3, NULL, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
 
         /* The Nvidia Geforce 7 driver cannot do a color fill on a texture backbuffer after
          * the backbuffer has been locked or GetSurfaceDesc has been called. Do it ourselves
@@ -5299,59 +5299,59 @@ static void test_flip(void)
         fill_surface(backbuffer3, 0xff0000ff);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, NULL, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
         /* The testbot seems to just copy the contents of one surface to all the
          * others, instead of properly flipping. */
         ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
-        ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer3, 0xffff0000);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, NULL, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
         ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
-        ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer3, 0xff00ff00);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, NULL, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
         ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
-        ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer3, 0xff0000ff);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, backbuffer1, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer2, 320, 240);
         ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer3, 320, 240);
-        ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer1, 0xffff0000);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, backbuffer2, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
-        ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer3, 320, 240);
         ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer2, 0xff00ff00);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, backbuffer3, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
         ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
-        ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
 
         IDirectDrawSurface_Release(backbuffer3);
         IDirectDrawSurface_Release(backbuffer2);
@@ -5360,7 +5360,7 @@ static void test_flip(void)
     }
 
     refcount = IDirectDraw_Release(ddraw);
-    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -5378,7 +5378,7 @@ static void test_sysmem_overlay(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -5393,10 +5393,10 @@ static void test_sysmem_overlay(void)
     U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
     U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DDERR_NOOVERLAYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOOVERLAYHW, "Got unexpected hr %#lx.\n", hr);
 
     ref = IDirectDraw_Release(ddraw);
-    ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Ddraw object not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -5424,7 +5424,7 @@ static void test_primary_palette(void)
         return;
     }
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -5432,22 +5432,22 @@ static void test_primary_palette(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     surface_desc.dwBackBufferCount = 1;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetAttachedSurface(primary, &surface_caps, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#lx.\n", hr);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     hr = IDirectDraw_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256, palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)palette);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
-    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
-    ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#x.\n", palette_caps);
+    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#lx.\n", hr);
+    ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#lx.\n", palette_caps);
 
     hr = IDirectDrawSurface_SetPalette(primary, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     /* The Windows 8 testbot attaches the palette to the backbuffer as well,
      * and is generally somewhat broken with respect to 8 bpp / palette
@@ -5460,99 +5460,99 @@ static void test_primary_palette(void)
         /* The Windows 8 testbot keeps extra references to the primary and
          * backbuffer while in 8 bpp mode. */
         hr = IDirectDraw_RestoreDisplayMode(ddraw);
-        ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#lx.\n", hr);
         goto done;
     }
 
     refcount = get_refcount((IUnknown *)palette);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
-    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#lx.\n", hr);
     ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_PRIMARYSURFACE | DDPCAPS_ALLOW256),
-            "Got unexpected palette caps %#x.\n", palette_caps);
+            "Got unexpected palette caps %#lx.\n", palette_caps);
 
     hr = IDirectDrawSurface_SetPalette(primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)palette);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
-    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
-    ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#x.\n", palette_caps);
+    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#lx.\n", hr);
+    ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#lx.\n", palette_caps);
 
     hr = IDirectDrawSurface_SetPalette(primary, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)palette);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface_GetPalette(primary, &tmp);
-    ok(SUCCEEDED(hr), "Failed to get palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette, hr %#lx.\n", hr);
     ok(tmp == palette, "Got unexpected palette %p, expected %p.\n", tmp, palette);
     IDirectDrawPalette_Release(tmp);
     hr = IDirectDrawSurface_GetPalette(backbuffer, &tmp);
-    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirectDrawPalette_Release(palette);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     /* Note that this only seems to work when the palette is attached to the
      * primary surface. When attached to a regular surface, attempting to get
      * the palette here will cause an access violation. */
     hr = IDirectDrawSurface_GetPalette(primary, &tmp);
-    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
-    ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 8, "Got unexpected bit count %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %lu.\n", surface_desc.dwWidth);
+    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %lu.\n", surface_desc.dwHeight);
+    ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 8, "Got unexpected bit count %lu.\n",
             U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
 
     hr = set_display_mode(ddraw, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %lu.\n", surface_desc.dwWidth);
+    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %lu.\n", surface_desc.dwHeight);
     ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 32
             || U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 24,
-            "Got unexpected bit count %u.\n", U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
+            "Got unexpected bit count %lu.\n", U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %lu.\n", surface_desc.dwWidth);
+    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %lu.\n", surface_desc.dwHeight);
     ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 32
             || U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 24,
-            "Got unexpected bit count %u.\n", U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
+            "Got unexpected bit count %lu.\n", U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
 
 done:
     refcount = IDirectDrawSurface_Release(backbuffer);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawSurface_Release(primary);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -5581,7 +5581,7 @@ static void test_surface_attachment(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -5591,14 +5591,14 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 128;
     surface_desc.dwHeight = 128;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_GetAttachedSurface(surface1, &caps, &surface2);
-    ok(SUCCEEDED(hr), "Failed to get mip level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get mip level, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetAttachedSurface(surface2, &caps, &surface3);
-    ok(SUCCEEDED(hr), "Failed to get mip level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get mip level, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetAttachedSurface(surface3, &caps, &surface4);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
 
     surface_count = 0;
     IDirectDrawSurface_EnumAttachedSurfaces(surface1, &surface_count, surface_counter);
@@ -5617,20 +5617,20 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 16;
     surface_desc.dwHeight = 16;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface1);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface3, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface3);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface2);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(surface4);
 
@@ -5641,27 +5641,27 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 16;
     surface_desc.dwHeight = 16;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     if (SUCCEEDED(hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4)))
     {
         skip("Running on refrast, skipping some tests.\n");
         hr = IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface4);
-        ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
     }
     else
     {
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface1);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface_AddAttachedSurface(surface3, surface4);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface3);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface4);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface2);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     }
 
     IDirectDrawSurface_Release(surface4);
@@ -5670,7 +5670,7 @@ static void test_surface_attachment(void)
     IDirectDrawSurface_Release(surface1);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Try a single primary and two offscreen plain surfaces. */
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -5678,7 +5678,7 @@ static void test_surface_attachment(void)
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -5687,7 +5687,7 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = registry_mode.dmPelsWidth;
     surface_desc.dwHeight = registry_mode.dmPelsHeight;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -5696,7 +5696,7 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = registry_mode.dmPelsWidth;
     surface_desc.dwHeight = registry_mode.dmPelsHeight;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* This one has a different size. */
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -5706,33 +5706,33 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 128;
     surface_desc.dwHeight = 128;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     /* Try the reverse without detaching first. */
     hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface1);
-    ok(hr == DDERR_SURFACEALREADYATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACEALREADYATTACHED, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface2);
-    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface1);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     /* Try to detach reversed. */
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface2);
-    ok(hr == DDERR_CANNOTDETACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTDETACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface2, 0, surface1);
-    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface3);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface2, 0, surface3);
-    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface1);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(surface4);
     IDirectDrawSurface_Release(surface3);
@@ -5747,7 +5747,7 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 64;
     surface_desc.dwHeight = 64;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -5760,26 +5760,26 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 32;
     surface_desc.dwHeight = 32;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
     surface_desc.dwWidth = 64;
     surface_desc.dwHeight = 64;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
     surface_desc.dwWidth = 128;
     surface_desc.dwHeight = 128;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
-    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     if (SUCCEEDED(hr))
         IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface2);
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface3);
-    ok(hr == D3D_OK, "Failed to attach depth buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to attach depth buffer, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface3);
-    ok(hr == D3D_OK, "Failed to detach depth buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to detach depth buffer, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4);
-    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(surface4);
     IDirectDrawSurface_Release(surface3);
@@ -5800,47 +5800,47 @@ static void test_surface_attachment(void)
     U3(surface_desc.ddpfPixelFormat).dwGBitMask = 0x07e0;
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x001f;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
     surface_desc.ddpfPixelFormat.dwFlags = DDPF_ZBUFFER;
     U1(surface_desc.ddpfPixelFormat).dwZBufferBitDepth = 16;
     U3(surface_desc.ddpfPixelFormat).dwZBitMask = 0x0000ffff;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)surface2);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
-    ok(hr == DDERR_SURFACEALREADYATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACEALREADYATTACHED, "Got unexpected hr %#lx.\n", hr);
 
     /* Attaching while already attached to other surface. */
     hr = IDirectDrawSurface_AddAttachedSurface(surface3, surface2);
-    todo_wine ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    todo_wine ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface3, 0, surface2);
-    todo_wine ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    todo_wine ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface3);
 
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface2);
-    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)surface2);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     /* Automatic detachment on release. */
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)surface2);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawSurface_Release(surface1);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawSurface_Release(surface2);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -5923,7 +5923,7 @@ static void test_pixel_format(void)
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
     if (FAILED(hr))
     {
-        skip("Failed to set cooperative level, hr %#x.\n", hr);
+        skip("Failed to set cooperative level, hr %#lx.\n", hr);
         goto cleanup;
     }
 
@@ -5933,9 +5933,9 @@ static void test_pixel_format(void)
     if (hdc2)
     {
         hr = IDirectDraw_CreateClipper(ddraw, 0, &clipper, NULL);
-        ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
         hr = IDirectDrawClipper_SetHWnd(clipper, 0, window2);
-        ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
 
         test_format = GetPixelFormat(hdc);
         ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -5950,7 +5950,7 @@ static void test_pixel_format(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -5964,7 +5964,7 @@ static void test_pixel_format(void)
     if (clipper)
     {
         hr = IDirectDrawSurface_SetClipper(primary, clipper);
-        ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
 
         test_format = GetPixelFormat(hdc);
         ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -5979,18 +5979,18 @@ static void test_pixel_format(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     ddsd.dwWidth = ddsd.dwHeight = 64;
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &offscreen, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     hr = IDirectDrawSurface_Blt(offscreen, NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#lx.\n", hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
 
     hr = IDirectDrawSurface_Blt(primary, NULL, offscreen, NULL, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to blit to primary surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit to primary surface, hr %#lx.\n", hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -6096,7 +6096,7 @@ static void test_create_surface_pitch(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ((63 * 4) + 8) * 63);
 
@@ -6119,32 +6119,32 @@ static void test_create_surface_pitch(void)
         if (test_data[i].flags_in & DDSD_LPSURFACE)
         {
             HRESULT expected_hr = SUCCEEDED(test_data[i].hr) ? DDERR_INVALIDPARAMS : test_data[i].hr;
-            ok(hr == expected_hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, expected_hr);
+            ok(hr == expected_hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, expected_hr);
             surface_desc.lpSurface = mem;
             hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
         }
         if ((test_data[i].caps & DDSCAPS_VIDEOMEMORY) && hr == DDERR_NODIRECTDRAWHW)
             continue;
-        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
         if (FAILED(hr))
             continue;
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#lx.\n", i, hr);
         ok((surface_desc.dwFlags & flags_mask) == test_data[i].flags_out,
-                "Test %u: Got unexpected flags %#x, expected %#x.\n",
+                "Test %u: Got unexpected flags %#lx, expected %#lx.\n",
                 i, surface_desc.dwFlags & flags_mask, test_data[i].flags_out);
         if (!(test_data[i].caps & DDSCAPS_TEXTURE))
         {
             if (is_ddraw64 && test_data[i].pitch_out32 != test_data[i].pitch_out64)
                 todo_wine ok(U1(surface_desc).lPitch == test_data[i].pitch_out64,
-                        "Test %u: Got unexpected pitch %u, expected %u.\n",
+                        "Test %u: Got unexpected pitch %lu, expected %lu.\n",
                         i, U1(surface_desc).lPitch, test_data[i].pitch_out64);
             else
                 ok(U1(surface_desc).lPitch == test_data[i].pitch_out32,
-                        "Test %u: Got unexpected pitch %u, expected %u.\n",
+                        "Test %u: Got unexpected pitch %lu, expected %lu.\n",
                         i, U1(surface_desc).lPitch, test_data[i].pitch_out32);
         }
         ok(!surface_desc.lpSurface, "Test %u: Got unexpected lpSurface %p.\n", i, surface_desc.lpSurface);
@@ -6154,7 +6154,7 @@ static void test_create_surface_pitch(void)
 
     HeapFree(GetProcessHeap(), 0, mem);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -6194,12 +6194,12 @@ static void test_mipmap(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) != (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP))
     {
         skip("Mipmapped textures not supported, skipping tests.\n");
@@ -6219,18 +6219,18 @@ static void test_mipmap(void)
         if (tests[i].flags & DDSD_MIPMAPCOUNT)
             U2(surface_desc).dwMipMapCount = tests[i].mipmap_count_in;
         hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         if (FAILED(hr))
             continue;
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#lx.\n", i, hr);
         ok(surface_desc.dwFlags & DDSD_MIPMAPCOUNT,
-                "Test %u: Got unexpected flags %#x.\n", i, surface_desc.dwFlags);
+                "Test %u: Got unexpected flags %#lx.\n", i, surface_desc.dwFlags);
         ok(U2(surface_desc).dwMipMapCount == tests[i].mipmap_count_out,
-                "Test %u: Got unexpected mipmap count %u.\n", i, U2(surface_desc).dwMipMapCount);
+                "Test %u: Got unexpected mipmap count %lu.\n", i, U2(surface_desc).dwMipMapCount);
 
         surface_base = surface;
         IDirectDrawSurface2_AddRef(surface_base);
@@ -6238,31 +6238,31 @@ static void test_mipmap(void)
         while (mipmap_count > 1)
         {
             hr = IDirectDrawSurface_GetAttachedSurface(surface_base, &caps, &surface_mip);
-            ok(SUCCEEDED(hr), "Test %u, %u: Failed to get attached surface, hr %#x.\n", i, mipmap_count, hr);
+            ok(SUCCEEDED(hr), "Test %u, %u: Failed to get attached surface, hr %#lx.\n", i, mipmap_count, hr);
 
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface_GetSurfaceDesc(surface_base, &surface_desc);
-            ok(SUCCEEDED(hr), "Test %u, %u: Failed to get surface desc, hr %#x.\n", i, mipmap_count, hr);
+            ok(SUCCEEDED(hr), "Test %u, %u: Failed to get surface desc, hr %#lx.\n", i, mipmap_count, hr);
             ok(surface_desc.dwFlags & DDSD_MIPMAPCOUNT,
-                    "Test %u, %u: Got unexpected flags %#x.\n", i, mipmap_count, surface_desc.dwFlags);
+                    "Test %u, %u: Got unexpected flags %#lx.\n", i, mipmap_count, surface_desc.dwFlags);
             ok(U2(surface_desc).dwMipMapCount == mipmap_count,
-                    "Test %u, %u: Got unexpected mipmap count %u.\n",
+                    "Test %u, %u: Got unexpected mipmap count %lu.\n",
                     i, mipmap_count, U2(surface_desc).dwMipMapCount);
 
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface_Lock(surface_base, NULL, &surface_desc, 0, NULL);
-            ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#x.\n", i, mipmap_count, hr);
+            ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#lx.\n", i, mipmap_count, hr);
             ok(surface_desc.dwMipMapCount == mipmap_count,
-                    "Test %u, %u: unexpected change of mipmap count %u.\n",
+                    "Test %u, %u: unexpected change of mipmap count %lu.\n",
                     i, mipmap_count, surface_desc.dwMipMapCount);
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface_Lock(surface_mip, NULL, &surface_desc, 0, NULL);
-            ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#x.\n", i, mipmap_count, hr);
+            ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#lx.\n", i, mipmap_count, hr);
             ok(surface_desc.dwMipMapCount == mipmap_count - 1,
-                    "Test %u, %u: Child mipmap count unexpected %u\n", i, mipmap_count, surface_desc.dwMipMapCount);
+                    "Test %u, %u: Child mipmap count unexpected %lu\n", i, mipmap_count, surface_desc.dwMipMapCount);
             IDirectDrawSurface_Unlock(surface_mip, NULL);
             IDirectDrawSurface_Unlock(surface_base, NULL);
 
@@ -6276,7 +6276,7 @@ static void test_mipmap(void)
     }
 
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -6301,12 +6301,12 @@ static void test_palette_complex(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) != (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP))
     {
         skip("Mipmapped textures not supported, skipping mipmap palette test.\n");
@@ -6325,28 +6325,28 @@ static void test_palette_complex(void)
     surface_desc.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
     U1(surface_desc.ddpfPixelFormat).dwRGBBitCount = 8;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     hr = IDirectDraw_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     palette_entries[1].peRed = 0xff;
     palette_entries[1].peGreen = 0x80;
     hr = IDirectDraw_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette_mipmap, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     palette2 = (void *)0xdeadbeef;
     hr = IDirectDrawSurface_GetPalette(surface, &palette2);
-    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx.\n", hr);
     ok(!palette2, "Got unexpected palette %p.\n", palette2);
     hr = IDirectDrawSurface_SetPalette(surface, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetPalette(surface, &palette2);
-    ok(SUCCEEDED(hr), "Failed to get palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette, hr %#lx.\n", hr);
     ok(palette == palette2, "Got unexpected palette %p.\n", palette2);
     IDirectDrawPalette_Release(palette2);
 
@@ -6355,46 +6355,46 @@ static void test_palette_complex(void)
     for (i = 0; i < 7; ++i)
     {
         hr = IDirectDrawSurface_GetAttachedSurface(mipmap, &caps, &tmp);
-        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#lx.\n", i, hr);
         palette2 = (void *)0xdeadbeef;
         hr = IDirectDrawSurface_GetPalette(tmp, &palette2);
-        ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x, i %u.\n", hr, i);
+        ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx, i %u.\n", hr, i);
         ok(!palette2, "Got unexpected palette %p, i %u.\n", palette2, i);
 
         hr = IDirectDrawSurface_SetPalette(tmp, palette_mipmap);
-        ok(SUCCEEDED(hr), "Failed to set palette, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to set palette, i %u, hr %#lx.\n", i, hr);
 
         hr = IDirectDrawSurface_GetPalette(tmp, &palette2);
-        ok(SUCCEEDED(hr), "Failed to get palette, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get palette, i %u, hr %#lx.\n", i, hr);
         ok(palette_mipmap == palette2, "Got unexpected palette %p.\n", palette2);
         IDirectDrawPalette_Release(palette2);
 
         hr = IDirectDrawSurface_GetDC(tmp, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC, i %u, hr %#lx.\n", i, hr);
         count = GetDIBColorTable(dc, 1, 1, &rgbquad);
         ok(count == 1, "Expected count 1, got %u.\n", count);
         ok(rgbquad.rgbRed == 0xff, "Expected rgbRed = 0xff, got %#x.\n", rgbquad.rgbRed);
         ok(rgbquad.rgbGreen == 0x80, "Expected rgbGreen = 0x80, got %#x.\n", rgbquad.rgbGreen);
         ok(rgbquad.rgbBlue == 0x0, "Expected rgbBlue = 0x0, got %#x.\n", rgbquad.rgbBlue);
         hr = IDirectDrawSurface_ReleaseDC(tmp, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC, i %u, hr %#lx.\n", i, hr);
 
         IDirectDrawSurface_Release(mipmap);
         mipmap = tmp;
     }
 
     hr = IDirectDrawSurface_GetAttachedSurface(mipmap, &caps, &tmp);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface_Release(mipmap);
     refcount = IDirectDrawSurface_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette_mipmap);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -6425,7 +6425,7 @@ static void test_p8_blit(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     is_warp = ddraw_is_warp(ddraw);
 
     memset(palette_entries, 0, sizeof(palette_entries));
@@ -6435,14 +6435,14 @@ static void test_p8_blit(void)
     palette_entries[4].peRed = 0xff;
     hr = IDirectDraw_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
     palette_entries[1].peBlue = 0xff;
     palette_entries[2].peGreen = 0xff;
     palette_entries[3].peRed = 0xff;
     palette_entries[4].peFlags = 0x0;
     hr = IDirectDraw_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -6454,11 +6454,11 @@ static void test_p8_blit(void)
     surface_desc.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
     U1(surface_desc.ddpfPixelFormat).dwRGBBitCount = 8;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &src, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &dst_p8, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_SetPalette(dst_p8, palette2);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -6474,34 +6474,34 @@ static void test_p8_blit(void)
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(surface_desc.ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_Lock(src, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#lx.\n", hr);
     memcpy(surface_desc.lpSurface, src_data, sizeof(src_data));
     hr = IDirectDrawSurface_Unlock(src, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(dst_p8, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#lx.\n", hr);
     memcpy(surface_desc.lpSurface, src_data2, sizeof(src_data2));
     hr = IDirectDrawSurface_Unlock(dst_p8, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#lx.\n", hr);
 
     fx.dwSize = sizeof(fx);
     fx.dwFillColor = 0xdeadbeef;
     hr = IDirectDrawSurface_Blt(dst, NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
-    ok(SUCCEEDED(hr), "Failed to color fill %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to color fill %#lx.\n", hr);
 
     hr = IDirectDrawSurface_SetPalette(src, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_WAIT, NULL);
     /* The r500 Windows 7 driver returns E_NOTIMPL. r200 on Windows XP works.
      * The Geforce 7 driver on Windows Vista returns E_FAIL. Newer Nvidia GPUs work. */
     ok(SUCCEEDED(hr) || broken(hr == E_NOTIMPL) || broken(hr == E_FAIL),
-            "Failed to blit, hr %#x.\n", hr);
+            "Failed to blit, hr %#lx.\n", hr);
 
     if (SUCCEEDED(hr))
     {
@@ -6512,7 +6512,7 @@ static void test_p8_blit(void)
              * blits see below. */
             todo_wine ok(compare_color(color, expected[x], 0)
                     || broken(is_warp && compare_color(color, 0x00000000, 0)),
-                    "Pixel %u: Got color %#x, expected %#x.\n",
+                    "Pixel %u: Got color %#lx, expected %#lx.\n",
                     x, color, expected[x]);
         }
     }
@@ -6520,10 +6520,10 @@ static void test_p8_blit(void)
     fx.ddckSrcColorkey.dwColorSpaceHighValue = 0x2;
     fx.ddckSrcColorkey.dwColorSpaceLowValue = 0x2;
     hr = IDirectDrawSurface_Blt(dst_p8, NULL, src, NULL, DDBLT_WAIT | DDBLT_KEYSRCOVERRIDE, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(dst_p8, NULL, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#lx.\n", hr);
     /* A color keyed P8 blit doesn't do anything on WARP - it just leaves the data in the destination
      * surface untouched. Error checking (DDBLT_KEYSRC without a key
      * for example) also works as expected.
@@ -6534,7 +6534,7 @@ static void test_p8_blit(void)
             || broken(is_warp && !memcmp(surface_desc.lpSurface, src_data2, sizeof(src_data2))),
             "Got unexpected P8 color key blit result.\n");
     hr = IDirectDrawSurface_Unlock(dst_p8, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(src);
     IDirectDrawSurface_Release(dst);
@@ -6543,7 +6543,7 @@ static void test_p8_blit(void)
     IDirectDrawPalette_Release(palette2);
 
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -6596,7 +6596,7 @@ static void test_material(void)
     }
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     background = create_diffuse_material(device, 0.0f, 0.0f, 1.0f, 1.0f);
     viewport = create_viewport(device, 0, 0, 640, 480);
@@ -6604,7 +6604,7 @@ static void test_material(void)
 
     material = create_emissive_material(device, 0.0f, 1.0f, 0.0f, 0.0f);
     hr = IDirect3DMaterial_GetHandle(material, device, &mat_handle);
-    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#lx.\n", hr);
 
     memset(&exec_desc, 0, sizeof(exec_desc));
     exec_desc.dwSize = sizeof(exec_desc);
@@ -6613,12 +6613,12 @@ static void test_material(void)
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
 
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-        ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#lx.\n", hr);
 
         memcpy(exec_desc.lpData, quad, sizeof(quad));
         ptr = ((BYTE *)exec_desc.lpData) + sizeof(quad);
@@ -6630,67 +6630,67 @@ static void test_material(void)
         inst_length -= sizeof(quad);
 
         hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-        ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#lx.\n", hr);
 
         hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER);
-        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         set_execute_data(execute_buffer, 4, sizeof(quad), inst_length);
         hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-        ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx.\n", hr);
         hr = IDirect3DDevice_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
         color = get_surface_color(rt, 320, 240);
         if (test_data[i].material)
             ok(compare_color(color, test_data[i].expected_color, 1)
                     /* The Windows 8 testbot appears to return undefined results. */
                     || broken(TRUE),
-                    "Got unexpected color 0x%08x, test %u.\n", color, i);
+                    "Got unexpected color 0x%08lx, test %u.\n", color, i);
         else
             ok(compare_color(color, test_data[i].expected_color, 1),
-                    "Got unexpected color 0x%08x, test %u.\n", color, i);
+                    "Got unexpected color 0x%08lx, test %u.\n", color, i);
     }
 
     destroy_material(material);
     material = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f);
     hr = IDirect3DMaterial_GetHandle(material, device, &mat_handle);
-    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport_SetBackground(viewport, mat_handle);
-    ok(SUCCEEDED(hr), "Failed to set viewport background, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport background, hr %#lx.\n", hr);
     hr = IDirect3DViewport_GetBackground(viewport, &tmp, &valid);
-    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#x.\n", hr);
-    ok(tmp == mat_handle, "Got unexpected material handle %#x, expected %#x.\n", tmp, mat_handle);
+    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#lx.\n", hr);
+    ok(tmp == mat_handle, "Got unexpected material handle %#lx, expected %#lx.\n", tmp, mat_handle);
     ok(valid, "Got unexpected valid %#x.\n", valid);
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DViewport_SetBackground(viewport, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport_GetBackground(viewport, &tmp, &valid);
-    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#x.\n", hr);
-    ok(tmp == mat_handle, "Got unexpected material handle %#x, expected %#x.\n", tmp, mat_handle);
+    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#lx.\n", hr);
+    ok(tmp == mat_handle, "Got unexpected material handle %#lx, expected %#lx.\n", tmp, mat_handle);
     ok(valid, "Got unexpected valid %#x.\n", valid);
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     destroy_viewport(device, viewport);
     viewport = create_viewport(device, 0, 0, 640, 480);
 
     hr = IDirect3DViewport_GetBackground(viewport, &tmp, &valid);
-    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#x.\n", hr);
-    ok(!tmp, "Got unexpected material handle %#x.\n", tmp);
+    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#lx.\n", hr);
+    ok(!tmp, "Got unexpected material handle %#lx.\n", tmp);
     ok(!valid, "Got unexpected valid %#x.\n", valid);
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00000000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirect3DExecuteBuffer_Release(execute_buffer);
     destroy_viewport(device, viewport);
@@ -6698,9 +6698,9 @@ static void test_material(void)
     destroy_material(material);
     IDirectDrawSurface_Release(rt);
     refcount = IDirect3DDevice_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Ddraw object has %u references left.\n", refcount);
+    ok(!refcount, "Ddraw object has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -6831,30 +6831,30 @@ static void test_lighting(void)
     }
 
     hr = IDirect3DDevice_GetDirect3D(device, &d3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     material = create_diffuse_and_ambient_material(device, 1.0f, 1.0f, 1.0f, 1.0f);
     viewport_set_background(device, viewport, material);
 
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice_CreateMatrix(device, &world_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice_SetMatrix(device, world_handle, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice_CreateMatrix(device, &view_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice_SetMatrix(device, view_handle, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice_CreateMatrix(device, &proj_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice_SetMatrix(device, proj_handle, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&exec_desc, 0, sizeof(exec_desc));
     exec_desc.dwSize = sizeof(exec_desc);
@@ -6863,10 +6863,10 @@ static void test_lighting(void)
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
 
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memcpy(exec_desc.lpData, unlitquad, sizeof(unlitquad));
     ptr = ((BYTE *)exec_desc.lpData) + sizeof(unlitquad);
@@ -6883,17 +6883,17 @@ static void test_lighting(void)
     inst_length -= sizeof(unlitquad);
 
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     set_execute_data(execute_buffer, 4, sizeof(unlitquad), inst_length);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memcpy(exec_desc.lpData, litquad, sizeof(litquad));
     ptr = ((BYTE *)exec_desc.lpData) + sizeof(litquad);
@@ -6904,14 +6904,14 @@ static void test_lighting(void)
     inst_length -= sizeof(litquad);
 
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     set_execute_data(execute_buffer, 4, sizeof(litquad), inst_length);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memcpy(exec_desc.lpData, unlitnquad, sizeof(unlitnquad));
     ptr = ((BYTE *)exec_desc.lpData) + sizeof(unlitnquad);
@@ -6922,14 +6922,14 @@ static void test_lighting(void)
     inst_length -= sizeof(unlitnquad);
 
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     set_execute_data(execute_buffer, 4, sizeof(unlitnquad), inst_length);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memcpy(exec_desc.lpData, litnquad, sizeof(litnquad));
     ptr = ((BYTE *)exec_desc.lpData) + sizeof(litnquad);
@@ -6940,29 +6940,29 @@ static void test_lighting(void)
     inst_length -= sizeof(litnquad);
 
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     set_execute_data(execute_buffer, 4, sizeof(litnquad), inst_length);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 360);
-    ok(color == 0x00ff0000, "Unlit quad without normals has color 0x%08x.\n", color);
+    ok(color == 0x00ff0000, "Unlit quad without normals has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 160, 120);
-    ok(color == 0x0000ff00, "Lit quad without normals has color 0x%08x.\n", color);
+    ok(color == 0x0000ff00, "Lit quad without normals has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 360);
-    ok(color == 0x00ffffff, "Unlit quad with normals has color 0x%08x.\n", color);
+    ok(color == 0x00ffffff, "Unlit quad with normals has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 120);
-    ok(color == 0x00ffffff, "Lit quad with normals has color 0x%08x.\n", color);
+    ok(color == 0x00ffffff, "Lit quad with normals has color 0x%08lx.\n", color);
 
     hr = IDirect3DMaterial_GetHandle(material, device, &mat_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3D_CreateLight(d3d, &light, NULL);
-    ok(SUCCEEDED(hr), "Failed to create a light object, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create a light object, hr %#lx.\n", hr);
     memset(&light_desc, 0, sizeof(light_desc));
     light_desc.dwSize = sizeof(light_desc);
     light_desc.dltType = D3DLIGHT_DIRECTIONAL;
@@ -6972,35 +6972,35 @@ static void test_lighting(void)
     U4(light_desc.dcvColor).a = 1.0f;
     U3(light_desc.dvDirection).z = 1.0f;
     hr = IDirect3DLight_SetLight(light, &light_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport_AddLight(viewport, light);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport_AddLight(viewport, light);
-    ok(hr == D3DERR_LIGHTHASVIEWPORT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_LIGHTHASVIEWPORT, "Got unexpected hr %#lx.\n", hr);
 
     viewport2 = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DViewport_AddLight(viewport2, light);
-    ok(hr == D3DERR_LIGHTHASVIEWPORT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_LIGHTHASVIEWPORT, "Got unexpected hr %#lx.\n", hr);
     destroy_viewport(device, viewport2);
 
     hr = IDirect3DViewport_DeleteLight(viewport, light);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport_AddLight(viewport, light);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice_SetMatrix(device, world_handle, tests[i].world_matrix);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         memcpy(exec_desc.lpData, tests[i].quad, sizeof(nquad));
         ptr = ((BYTE *)exec_desc.lpData) + sizeof(nquad);
@@ -7013,17 +7013,17 @@ static void test_lighting(void)
         inst_length -= sizeof(nquad);
 
         hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         set_execute_data(execute_buffer, 4, sizeof(nquad), inst_length);
         hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         color = get_surface_color(rt, 320, 240);
-        ok(color == tests[i].expected, "%s has color 0x%08x.\n", tests[i].message, color);
+        ok(color == tests[i].expected, "%s has color 0x%08lx.\n", tests[i].message, color);
     }
 
     IDirect3DExecuteBuffer_Release(execute_buffer);
@@ -7031,16 +7031,16 @@ static void test_lighting(void)
     IDirect3DDevice_DeleteMatrix(device, view_handle);
     IDirect3DDevice_DeleteMatrix(device, proj_handle);
     hr = IDirect3DViewport_DeleteLight(viewport, light);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3DLight_Release(light);
     destroy_material(material);
     destroy_viewport(device, viewport);
     IDirectDrawSurface_Release(rt);
     refcount = IDirect3DDevice_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D_Release(d3d);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Ddraw object has %u references left.\n", refcount);
+    ok(!refcount, "Ddraw object has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -7285,36 +7285,36 @@ static void test_specular_lighting(void)
     }
 
     hr = IDirect3DDevice_GetDirect3D(device, &d3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     background_material = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f);
     viewport_set_background(device, viewport, background_material);
 
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice_CreateMatrix(device, &world_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice_SetMatrix(device, world_handle, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice_CreateMatrix(device, &view_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice_SetMatrix(device, view_handle, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice_CreateMatrix(device, &proj_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice_SetMatrix(device, proj_handle, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
 
     hr = IDirect3D_CreateLight(d3d, &light, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport_AddLight(viewport, light);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&exec_desc, 0, sizeof(exec_desc));
     exec_desc.dwSize = sizeof(exec_desc);
@@ -7323,26 +7323,26 @@ static void test_specular_lighting(void)
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
 
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         tests[i].light->dwFlags = D3DLIGHT_ACTIVE;
         material = create_specular_material(device, 1.0f, 1.0f, 1.0f, 1.0f, tests[i].specular_power);
         hr = IDirect3DMaterial_GetHandle(material, device, &mat_handle);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DLight_SetLight(light, (D3DLIGHT *)tests[i].light);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         memcpy(exec_desc.lpData, quad, sizeof(*quad) * vertex_count);
         ptr = ((BYTE *)exec_desc.lpData) + sizeof(*quad) * vertex_count;
@@ -7362,21 +7362,21 @@ static void test_specular_lighting(void)
         inst_length -= sizeof(*quad) * vertex_count;
 
         hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         set_execute_data(execute_buffer, vertex_count, sizeof(*quad) * vertex_count, inst_length);
         hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         for (j = 0; j < tests[i].expected_count; ++j)
         {
             colour = get_surface_color(rt, tests[i].expected[j].x, tests[i].expected[j].y);
             ok(compare_color(colour, tests[i].expected[j].colour, 1)
                     || broken(is_warp && compare_color(colour, 0x00ff0000, 1)),
-                    "Expected colour 0x%08x at location (%u, %u), got 0x%08x, case %u.\n",
+                    "Expected colour 0x%08lx at location (%u, %u), got 0x%08lx, case %u.\n",
                     tests[i].expected[j].colour, tests[i].expected[j].x,
                     tests[i].expected[j].y, colour, i);
         }
@@ -7389,16 +7389,16 @@ static void test_specular_lighting(void)
     IDirect3DDevice_DeleteMatrix(device, proj_handle);
 
     hr = IDirect3DViewport_DeleteLight(viewport, light);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3DLight_Release(light);
     destroy_material(background_material);
     destroy_viewport(device, viewport);
     IDirectDrawSurface_Release(rt);
     refcount = IDirect3DDevice_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D_Release(d3d);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Ddraw object has %u references left.\n", refcount);
+    ok(!refcount, "Ddraw object has %lu references left.\n", refcount);
     DestroyWindow(window);
     heap_free(indices);
     heap_free(quad);
@@ -7446,7 +7446,7 @@ static void test_palette_gdi(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -7458,7 +7458,7 @@ static void test_palette_gdi(void)
     surface_desc.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
     U1(surface_desc.ddpfPixelFormat).dwRGBBitCount = 8;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* Avoid colors from the Windows default palette. */
     memset(palette_entries, 0, sizeof(palette_entries));
@@ -7470,7 +7470,7 @@ static void test_palette_gdi(void)
     palette_entries[4].peBlue = 0x15;
     hr = IDirectDraw_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     /* If there is no palette assigned and the display mode is not 8 bpp, some
      * drivers refuse to create a DC while others allow it. If a DC is created,
@@ -7483,9 +7483,9 @@ static void test_palette_gdi(void)
      * contains uninitialized garbage. See comments below for the P8 case. */
 
     hr = IDirectDrawSurface_SetPalette(surface, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     ddraw_palette_handle = SelectPalette(dc, GetStockObject(DEFAULT_PALETTE), FALSE);
     ok(ddraw_palette_handle == GetStockObject(DEFAULT_PALETTE),
             "Got unexpected palette %p, expected %p.\n",
@@ -7512,7 +7512,7 @@ static void test_palette_gdi(void)
     palette_entries[4].peGreen = 0x24;
     palette_entries[4].peBlue = 0x25;
     hr = IDirectDrawPalette_SetEntries(palette, 0, 4, 1, &palette_entries[4]);
-    ok(SUCCEEDED(hr), "Failed to set palette entries, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette entries, hr %#lx.\n", hr);
 
     i = GetDIBColorTable(dc, 4, 1, &rgbquad[4]);
     ok(i == 1, "Expected count 1, got %u.\n", i);
@@ -7523,9 +7523,9 @@ static void test_palette_gdi(void)
 
     /* Neither does re-setting the palette. */
     hr = IDirectDrawSurface_SetPalette(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_SetPalette(surface, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     i = GetDIBColorTable(dc, 4, 1, &rgbquad[4]);
     ok(i == 1, "Expected count 1, got %u.\n", i);
@@ -7535,11 +7535,11 @@ static void test_palette_gdi(void)
             expected1[4].rgbRed, expected1[4].rgbGreen, expected1[4].rgbBlue);
 
     hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     /* Refresh the DC. This updates the palette. */
     hr = IDirectDrawSurface_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad);
     ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i);
     for (i = 0; i < ARRAY_SIZE(expected2); i++)
@@ -7556,13 +7556,13 @@ static void test_palette_gdi(void)
                 i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue);
     }
     hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     refcount = IDirectDrawSurface_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     if (FAILED(IDirectDraw_SetDisplayMode(ddraw, 640, 480, 8)))
     {
         win_skip("Failed to set 8 bpp display mode, skipping test.\n");
@@ -7571,35 +7571,35 @@ static void test_palette_gdi(void)
         DestroyWindow(window);
         return;
     }
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 3;
     SetRect(&r, 0, 0, 319, 479);
     hr = IDirectDrawSurface_Blt(primary, &r, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear surface, hr %#lx.\n", hr);
     SetRect(&r, 320, 0, 639, 479);
     U5(fx).dwFillColor = 4;
     hr = IDirectDrawSurface_Blt(primary, &r, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_SetPalette(primary, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetDC(primary, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
 
     color = GetPixel(dc, 160, 240);
-    ok(color == 0x00030000, "Clear index 3: Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00030000, "Clear index 3: Got unexpected color 0x%08lx.\n", color);
     color = GetPixel(dc, 480, 240);
-    ok(color == 0x00252423, "Clear index 4: Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00252423, "Clear index 4: Got unexpected color 0x%08lx.\n", color);
 
     ddraw_palette_handle = SelectPalette(dc, GetStockObject(DEFAULT_PALETTE), FALSE);
     ok(ddraw_palette_handle == GetStockObject(DEFAULT_PALETTE),
@@ -7629,7 +7629,7 @@ static void test_palette_gdi(void)
                 i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue);
     }
     hr = IDirectDrawSurface_ReleaseDC(primary, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -7638,12 +7638,12 @@ static void test_palette_gdi(void)
     surface_desc.dwHeight = 16;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* Here the offscreen surface appears to use the primary's palette,
      * but in all likelihood it is actually the system palette. */
     hr = IDirectDrawSurface_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad);
     ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i);
     for (i = 0; i < ARRAY_SIZE(expected2); i++)
@@ -7660,7 +7660,7 @@ static void test_palette_gdi(void)
                 i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue);
     }
     hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     /* On real hardware a change to the primary surface's palette applies immediately,
      * even on device contexts from offscreen surfaces that do not have their own
@@ -7676,14 +7676,14 @@ static void test_palette_gdi(void)
     palette_entries[4].peBlue = 0x56;
     hr = IDirectDraw_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_SetPalette(surface, palette2);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     /* A palette assigned to the offscreen surface overrides the primary / system
      * palette. */
     hr = IDirectDrawSurface_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad);
     ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i);
     for (i = 0; i < ARRAY_SIZE(expected3); i++)
@@ -7700,24 +7700,24 @@ static void test_palette_gdi(void)
                 i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue);
     }
     hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     refcount = IDirectDrawSurface_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     /* The Windows 8 testbot keeps extra references to the primary and
      * backbuffer while in 8 bpp mode. */
     hr = IDirectDraw_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#lx.\n", hr);
 
     refcount = IDirectDrawSurface_Release(primary);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette2);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -7756,18 +7756,18 @@ static void test_palette_alpha(void)
         return;
     }
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     palette_entries[1].peFlags = 0x42;
     palette_entries[2].peFlags = 0xff;
     palette_entries[3].peFlags = 0x80;
     hr = IDirectDraw_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     memset(palette_entries, 0x66, sizeof(palette_entries));
     hr = IDirectDrawPalette_GetEntries(palette, 0, 1, 4, palette_entries);
-    ok(SUCCEEDED(hr), "Failed to get palette entries, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette entries, hr %#lx.\n", hr);
     ok(palette_entries[0].peFlags == 0x42, "Got unexpected peFlags 0x%02x, expected 0xff.\n",
             palette_entries[0].peFlags);
     ok(palette_entries[1].peFlags == 0xff, "Got unexpected peFlags 0x%02x, expected 0xff.\n",
@@ -7786,11 +7786,11 @@ static void test_palette_alpha(void)
     palette_entries[3].peFlags = 0x80;
     hr = IDirectDraw_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT | DDPCAPS_ALPHA,
             palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     memset(palette_entries, 0x66, sizeof(palette_entries));
     hr = IDirectDrawPalette_GetEntries(palette, 0, 1, 4, palette_entries);
-    ok(SUCCEEDED(hr), "Failed to get palette entries, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette entries, hr %#lx.\n", hr);
     ok(palette_entries[0].peFlags == 0x42, "Got unexpected peFlags 0x%02x, expected 0xff.\n",
             palette_entries[0].peFlags);
     ok(palette_entries[1].peFlags == 0xff, "Got unexpected peFlags 0x%02x, expected 0xff.\n",
@@ -7809,13 +7809,13 @@ static void test_palette_alpha(void)
         surface_desc.dwHeight = 128;
         surface_desc.ddsCaps.dwCaps = test_data[i].caps;
         hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create %s surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to create %s surface, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_SetPalette(surface, palette);
         if (test_data[i].attach_allowed)
-            ok(SUCCEEDED(hr), "Failed to attach palette to %s surface, hr %#x.\n", test_data[i].name, hr);
+            ok(SUCCEEDED(hr), "Failed to attach palette to %s surface, hr %#lx.\n", test_data[i].name, hr);
         else
-            ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#x, %s surface.\n", hr, test_data[i].name);
+            ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#lx, %s surface.\n", hr, test_data[i].name);
 
         if (SUCCEEDED(hr))
         {
@@ -7825,7 +7825,7 @@ static void test_palette_alpha(void)
 
             hr = IDirectDrawSurface_GetDC(surface, &dc);
             ok(SUCCEEDED(hr) || broken(hr == DDERR_CANTCREATEDC) /* Win2k testbot */,
-                    "Failed to get DC, hr %#x, %s surface.\n", hr, test_data[i].name);
+                    "Failed to get DC, hr %#lx, %s surface.\n", hr, test_data[i].name);
             if (SUCCEEDED(hr))
             {
                 retval = GetDIBColorTable(dc, 1, 1, &rgbquad);
@@ -7839,7 +7839,7 @@ static void test_palette_alpha(void)
                 ok(rgbquad.rgbReserved == 0, "Expected rgbReserved = 0, got %u, %s surface.\n",
                         rgbquad.rgbReserved, test_data[i].name);
                 hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-                ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
             }
         }
         IDirectDrawSurface_Release(surface);
@@ -7859,20 +7859,20 @@ static void test_palette_alpha(void)
     U3(surface_desc.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_SetPalette(surface, palette);
-    ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface);
 
     /* The Windows 8 testbot keeps extra references to the primary
      * while in 8 bpp mode. */
     hr = IDirectDraw_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#lx.\n", hr);
 
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -7895,7 +7895,7 @@ static void test_lost_device(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -7903,7 +7903,7 @@ static void test_lost_device(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     surface_desc.dwBackBufferCount = 1;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -7912,7 +7912,7 @@ static void test_lost_device(void)
     surface_desc.dwWidth = 100;
     surface_desc.dwHeight = 100;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -7933,84 +7933,84 @@ static void test_lost_device(void)
     }
 
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Restore(surface);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Restore(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface_Restore(vidmem_surface);
-        ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     ret = SetForegroundWindow(window1);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = restore_surfaces(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
     ok(hr == DDERR_NOEXCLUSIVEMODE || broken(ddraw_is_warp(ddraw) && hr == DDERR_SURFACELOST),
-            "Got unexpected hr %#x.\n", hr);
+            "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK || broken(ddraw_is_warp(ddraw) && hr == DDERR_SURFACELOST), "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK || broken(ddraw_is_warp(ddraw) && hr == DDERR_SURFACELOST), "Got unexpected hr %#lx.\n", hr);
     }
 
     /* Trying to restore the primary will crash, probably because flippable
@@ -8021,59 +8021,59 @@ static void test_lost_device(void)
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = restore_surfaces(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     ret = SetForegroundWindow(window1);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = restore_surfaces(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     IDirectDrawSurface_Release(surface);
@@ -8083,103 +8083,103 @@ static void test_lost_device(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     surface_desc.dwBackBufferCount = 1;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window2, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     memset(&caps, 0, sizeof(caps));
     caps.dwCaps = DDSCAPS_FLIP;
 
     hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &back_buffer);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Restore(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &back_buffer);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(back_buffer);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface_Release(back_buffer);
 
     if (vidmem_surface)
@@ -8187,7 +8187,7 @@ static void test_lost_device(void)
     IDirectDrawSurface_Release(sysmem_surface);
     IDirectDrawSurface_Release(surface);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window2);
     DestroyWindow(window1);
 }
@@ -8205,7 +8205,7 @@ static void test_surface_desc_lock(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -8214,36 +8214,36 @@ static void test_surface_desc_lock(void)
     surface_desc.dwHeight = 16;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0xaa, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!surface_desc.lpSurface, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
 
     memset(&surface_desc, 0xaa, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ok(surface_desc.lpSurface != NULL, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
     memset(&surface_desc, 0xaa, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!surface_desc.lpSurface, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
     hr = IDirectDrawSurface_Unlock(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0xaa, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!surface_desc.lpSurface, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
 
     IDirectDrawSurface_Release(surface);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -8305,7 +8305,7 @@ static void test_texturemapblend(void)
     }
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     material = create_diffuse_material(device, 0.0f, 0.0f, 0.0f, 1.0f);
     viewport = create_viewport(device, 0, 0, 640, 480);
@@ -8317,7 +8317,7 @@ static void test_texturemapblend(void)
     exec_desc.dwBufferSize = 1024;
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#lx.\n", hr);
 
     /* Test alpha with DDPF_ALPHAPIXELS texture - should be taken from texture alpha channel.
      *
@@ -8337,27 +8337,27 @@ static void test_texturemapblend(void)
     U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(ddsd.ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture, (void **)&texture);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirect3DTexture_GetHandle(texture, device, &texture_handle);
-    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 0xff0000ff;
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
     U5(fx).dwFillColor = 0x800000ff;
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
 
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#lx.\n", hr);
 
     memcpy(exec_desc.lpData, test1_quads, sizeof(test1_quads));
 
@@ -8410,29 +8410,29 @@ static void test_texturemapblend(void)
     inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData;
     inst_length -= sizeof(test1_quads);
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#lx.\n", hr);
     set_execute_data(execute_buffer, 8, sizeof(test1_quads), inst_length);
 
     hr = IDirect3DDevice_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_UNCLIPPED);
-    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     /* The above SPECULARENABLE = FALSE on WARP matters here.*/
     color = get_surface_color(rt, 5, 5);
-    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 5);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 5, 245);
-    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 245);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
 
     IDirect3DTexture_Release(texture);
     ref = IDirectDrawSurface_Release(surface);
-    ok(ref == 0, "Surface not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Surface not properly released, refcount %lu.\n", ref);
 
     /* Test alpha with texture that has no alpha channel - alpha should be taken from diffuse vertex color. */
     memset(&ddsd, 0, sizeof(ddsd));
@@ -8449,25 +8449,25 @@ static void test_texturemapblend(void)
     U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
 
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture, (void **)&texture);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirect3DTexture_GetHandle(texture, device, &texture_handle);
-    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     U5(fx).dwFillColor = 0xff0000ff;
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
     U5(fx).dwFillColor = 0x800000ff;
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
 
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#lx.\n", hr);
 
     ptr = ((BYTE *)exec_desc.lpData) + sizeof(test1_quads);
     emit_process_vertices(&ptr, D3DPROCESSVERTICES_COPY, 0, 8);
@@ -8480,15 +8480,15 @@ static void test_texturemapblend(void)
     inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData;
     inst_length -= sizeof(test1_quads);
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#lx.\n", hr);
     set_execute_data(execute_buffer, 8, sizeof(test1_quads), inst_length);
 
     hr = IDirect3DDevice_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_UNCLIPPED);
-    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     /* Despite our best efforts at not making color keying randomly triggering, those
      * four broken() results occur every now and then on WARP. Presumably the non-
@@ -8496,23 +8496,23 @@ static void test_texturemapblend(void)
     color = get_surface_color(rt, 5, 5);
     ok(compare_color(color, 0x000000ff, 2)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x00000000, 2)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 5);
     ok(compare_color(color, 0x000000ff, 2)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x00000000, 2)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 5, 245);
     ok(compare_color(color, 0x00000080, 2)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x00000000, 2)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 245);
     ok(compare_color(color, 0x00000080, 2)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x00000000, 2)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
 
     IDirect3DTexture_Release(texture);
     ref = IDirectDrawSurface_Release(surface);
-    ok(ref == 0, "Surface not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Surface not properly released, refcount %lu.\n", ref);
 
     /* Test RGB - should multiply color components from diffuse vertex color and texture. */
     memset(&ddsd, 0, sizeof(ddsd));
@@ -8529,25 +8529,25 @@ static void test_texturemapblend(void)
     U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(ddsd.ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture, (void **)&texture);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirect3DTexture_GetHandle(texture, device, &texture_handle);
-    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     U5(fx).dwFillColor = 0x00ffffff;
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
     U5(fx).dwFillColor = 0x00ffff80;
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
 
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#lx.\n", hr);
 
     memcpy(exec_desc.lpData, test2_quads, sizeof(test2_quads));
 
@@ -8563,15 +8563,15 @@ static void test_texturemapblend(void)
     inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData;
     inst_length -= sizeof(test2_quads);
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#lx.\n", hr);
     set_execute_data(execute_buffer, 8, sizeof(test2_quads), inst_length);
 
     hr = IDirect3DDevice_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_UNCLIPPED);
-    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     /* WARP (Win8 testbot) emulates color keying with the alpha channel like Wine does,
      * but even applies it when there's no color key assigned. The surface alpha is zero
@@ -8581,20 +8581,20 @@ static void test_texturemapblend(void)
      * different defaults in ddraw1 and ddraw2. */
     color = get_surface_color(rt, 5, 5);
     ok(compare_color(color, 0x00ff0040, 2) || broken(compare_color(color, 0x00000000, 1)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 5);
     ok(compare_color(color, 0x00ff0080, 2) || broken(compare_color(color, 0x00000000, 1)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 5, 245);
     ok(compare_color(color, 0x00800080, 2) || broken(compare_color(color, 0x00000000, 1)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 245);
     ok(compare_color(color, 0x008000ff, 2) || broken(compare_color(color, 0x00000000, 1)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
 
     IDirect3DTexture_Release(texture);
     ref = IDirectDrawSurface_Release(surface);
-    ok(ref == 0, "Surface not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Surface not properly released, refcount %lu.\n", ref);
 
     /* Test alpha again, now with color keyed texture (colorkey emulation in wine can interfere). */
     memset(&ddsd, 0, sizeof(ddsd));
@@ -8611,30 +8611,30 @@ static void test_texturemapblend(void)
     U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x001f;
 
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture, (void **)&texture);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirect3DTexture_GetHandle(texture, device, &texture_handle);
-    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     U5(fx).dwFillColor = 0xf800;
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
     U5(fx).dwFillColor = 0x001f;
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = 0x001f;
     ckey.dwColorSpaceHighValue = 0x001f;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#lx.\n", hr);
 
     memcpy(exec_desc.lpData, test1_quads, sizeof(test1_quads));
 
@@ -8657,41 +8657,41 @@ static void test_texturemapblend(void)
     inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData;
     inst_length -= sizeof(test1_quads);
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#lx.\n", hr);
     set_execute_data(execute_buffer, 8, sizeof(test1_quads), inst_length);
 
     hr = IDirect3DDevice_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_UNCLIPPED);
-    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     /* Allow broken WARP results (colorkey disabled). */
     color = get_surface_color(rt, 5, 5);
     ok(compare_color(color, 0x00000000, 2) || broken(compare_color(color, 0x000000ff, 2)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 5);
-    ok(compare_color(color, 0x00ff0000, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 5, 245);
     ok(compare_color(color, 0x00000000, 2) || broken(compare_color(color, 0x00000080, 2)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 245);
-    ok(compare_color(color, 0x00800000, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00800000, 2), "Got unexpected color 0x%08lx.\n", color);
 
     IDirect3DTexture_Release(texture);
     ref = IDirectDrawSurface_Release(surface);
-    ok(ref == 0, "Surface not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Surface not properly released, refcount %lu.\n", ref);
 
     ref = IDirect3DExecuteBuffer_Release(execute_buffer);
-    ok(ref == 0, "Execute buffer not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Execute buffer not properly released, refcount %lu.\n", ref);
     destroy_viewport(device, viewport);
     ref = IDirect3DMaterial_Release(material);
-    ok(ref == 0, "Material not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Material not properly released, refcount %lu.\n", ref);
     IDirectDrawSurface_Release(rt);
     IDirect3DDevice_Release(device);
     ref = IDirectDraw_Release(ddraw);
-    ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Ddraw object not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -8721,32 +8721,32 @@ static void test_viewport_clear_rect(void)
     }
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     red = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f);
     viewport = create_viewport(device, 0, 0, 640, 480);
     viewport_set_background(device, viewport, red);
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
     green = create_diffuse_material(device, 0.0f, 1.0f, 0.0f, 1.0f);
     viewport2 = create_viewport(device, 100, 100, 20, 20);
     viewport_set_background(device, viewport2, green);
     hr = IDirect3DViewport_Clear(viewport2, 1, &clear_rect2, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 85, 85); /* Outside both. */
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 95, 95); /* Outside vp, inside rect. */
     /* AMD GPUs ignore the viewport dimensions and only care about the rectangle. */
     ok(compare_color(color, 0x00ff0000, 1) || broken(compare_color(color, 0x0000ff00, 1)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 105, 105); /* Inside both. */
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 115, 115); /* Inside vp, outside rect. */
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 125, 125); /* Outside both. */
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     destroy_viewport(device, viewport2);
     destroy_material(green);
@@ -8755,7 +8755,7 @@ static void test_viewport_clear_rect(void)
     IDirectDrawSurface_Release(rt);
     IDirect3DDevice_Release(device);
     ref = IDirectDraw_Release(ddraw);
-    ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Ddraw object not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -8937,13 +8937,13 @@ static void test_color_fill(void)
     }
 
     hr = IDirectDraw_GetFourCCCodes(ddraw, &num_fourcc_codes, NULL);
-    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#lx.\n", hr);
     fourcc_codes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
             num_fourcc_codes * sizeof(*fourcc_codes));
     if (!fourcc_codes)
         goto done;
     hr = IDirectDraw_GetFourCCCodes(ddraw, &num_fourcc_codes, fourcc_codes);
-    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#lx.\n", hr);
     for (i = 0; i < num_fourcc_codes; i++)
     {
         if (fourcc_codes[i] == MAKEFOURCC('Y', 'U', 'Y', '2'))
@@ -8956,7 +8956,7 @@ static void test_color_fill(void)
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
 
     if ((!support_yuy2 && !support_uyvy) || !(hal_caps.dwCaps & DDCAPS_OVERLAY))
         skip("Overlays or some YUV formats not supported, skipping YUV colorfill tests.\n");
@@ -8983,7 +8983,7 @@ static void test_color_fill(void)
         {
             struct format_support_check check = {&tests[i].format, FALSE};
             hr = IDirect3DDevice_EnumTextureFormats(device, test_unsupported_formats_cb, &check);
-            ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#lx.\n", hr);
             if (!check.supported)
                 continue;
         }
@@ -9018,16 +9018,16 @@ static void test_color_fill(void)
         }
 
         hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x, surface %s.\n", hr, tests[i].name);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx, surface %s.\n", hr, tests[i].name);
 
         hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
         todo_wine_if (tests[i].format.dwFourCC)
-            ok(hr == tests[i].colorfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
+            ok(hr == tests[i].colorfill_hr, "Blt returned %#lx, expected %#lx, surface %s.\n",
                     hr, tests[i].colorfill_hr, tests[i].name);
 
         hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
         todo_wine_if (tests[i].format.dwFourCC)
-            ok(hr == tests[i].colorfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
+            ok(hr == tests[i].colorfill_hr, "Blt returned %#lx, expected %#lx, surface %s.\n",
                     hr, tests[i].colorfill_hr, tests[i].name);
 
         if (SUCCEEDED(hr) && tests[i].check_result)
@@ -9035,19 +9035,19 @@ static void test_color_fill(void)
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
             color = surface_desc.lpSurface;
-            ok(*color == tests[i].result, "Got clear result 0x%08x, expected 0x%08x, surface %s.\n",
+            ok(*color == tests[i].result, "Got clear result 0x%08lx, expected 0x%08lx, surface %s.\n",
                     *color, tests[i].result, tests[i].name);
             hr = IDirectDrawSurface_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
         }
 
         hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-        ok(hr == tests[i].depthfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
+        ok(hr == tests[i].depthfill_hr, "Blt returned %#lx, expected %#lx, surface %s.\n",
                 hr, tests[i].depthfill_hr, tests[i].name);
         hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-        ok(hr == tests[i].depthfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
+        ok(hr == tests[i].depthfill_hr, "Blt returned %#lx, expected %#lx, surface %s.\n",
                 hr, tests[i].depthfill_hr, tests[i].name);
 
         if (SUCCEEDED(hr) && tests[i].check_result)
@@ -9055,23 +9055,23 @@ static void test_color_fill(void)
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
             color = surface_desc.lpSurface;
             todo_wine_if(tests[i].caps & DDSCAPS_VIDEOMEMORY && U2(surface_desc).dwZBufferBitDepth != 16)
                 ok((*color & mask) == (tests[i].result & mask) || broken((*color & mask) == (expected_broken & mask))
                         || broken(is_warp && (*color & mask) == (~0u & mask)) /* Windows 8+ testbot. */,
-                        "Got clear result 0x%08x, expected 0x%08x, surface %s.\n",
+                        "Got clear result 0x%08lx, expected 0x%08lx, surface %s.\n",
                         *color & mask, tests[i].result & mask, tests[i].name);
             hr = IDirectDrawSurface_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
         }
 
         U5(fx).dwFillColor = 0xdeadbeef;
         fx.dwROP = BLACKNESS;
         hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
-        ok(FAILED(hr) == !tests[i].rop_success, "Blt returned %#x, expected %s, surface %s.\n",
+        ok(FAILED(hr) == !tests[i].rop_success, "Blt returned %#lx, expected %s, surface %s.\n",
                 hr, tests[i].rop_success ? "success" : "failure", tests[i].name);
-        ok(U5(fx).dwFillColor == 0xdeadbeef, "dwFillColor was set to 0x%08x, surface %s\n",
+        ok(U5(fx).dwFillColor == 0xdeadbeef, "dwFillColor was set to 0x%08lx, surface %s\n",
                 U5(fx).dwFillColor, tests[i].name);
 
         if (SUCCEEDED(hr) && tests[i].check_result)
@@ -9079,19 +9079,19 @@ static void test_color_fill(void)
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
             color = surface_desc.lpSurface;
-            ok(*color == 0, "Got clear result 0x%08x, expected 0x00000000, surface %s.\n",
+            ok(*color == 0, "Got clear result 0x%08lx, expected 0x00000000, surface %s.\n",
                     *color, tests[i].name);
             hr = IDirectDrawSurface_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
         }
 
         fx.dwROP = WHITENESS;
         hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
-        ok(FAILED(hr) == !tests[i].rop_success, "Blt returned %#x, expected %s, surface %s.\n",
+        ok(FAILED(hr) == !tests[i].rop_success, "Blt returned %#lx, expected %s, surface %s.\n",
                 hr, tests[i].rop_success ? "success" : "failure", tests[i].name);
-        ok(U5(fx).dwFillColor == 0xdeadbeef, "dwFillColor was set to 0x%08x, surface %s\n",
+        ok(U5(fx).dwFillColor == 0xdeadbeef, "dwFillColor was set to 0x%08lx, surface %s\n",
                 U5(fx).dwFillColor, tests[i].name);
 
         if (SUCCEEDED(hr) && tests[i].check_result)
@@ -9099,13 +9099,13 @@ static void test_color_fill(void)
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
             color = surface_desc.lpSurface;
             /* WHITENESS sets the alpha channel to 0x00. Ignore this for now. */
-            ok((*color & 0x00ffffff) == 0x00ffffff, "Got clear result 0x%08x, expected 0xffffffff, surface %s.\n",
+            ok((*color & 0x00ffffff) == 0x00ffffff, "Got clear result 0x%08lx, expected 0xffffffff, surface %s.\n",
                     *color, tests[i].name);
             hr = IDirectDrawSurface_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
         }
 
         IDirectDrawSurface_Release(surface);
@@ -9129,78 +9129,78 @@ static void test_color_fill(void)
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* No DDBLTFX. */
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_COLORFILL | DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_ROP | DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Unused source rectangle. */
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     /* Unused source surface. */
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     /* Inverted destination or source rectangle. */
     SetRect(&rect, 5, 7, 7, 5);
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, &rect, surface2, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
 
     /* Negative rectangle. */
     SetRect(&rect, -1, -1, 5, 5);
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, &rect, surface2, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, &rect, surface2, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
 
     /* Out of bounds rectangle. */
     SetRect(&rect, 0, 0, 65, 65);
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
 
     /* Combine multiple flags. */
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(rops); i++)
     {
         fx.dwROP = rops[i].rop;
         hr = IDirectDrawSurface_Blt(surface, NULL, surface2, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
-        ok(hr == rops[i].hr, "Got unexpected hr %#x for rop %s.\n", hr, rops[i].name);
+        ok(hr == rops[i].hr, "Got unexpected hr %#lx for rop %s.\n", hr, rops[i].name);
     }
 
     IDirectDrawSurface_Release(surface2);
@@ -9214,54 +9214,54 @@ static void test_color_fill(void)
     U2(surface_desc).dwZBufferBitDepth = get_device_z_depth(device);
     surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* No DDBLTFX. */
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Unused source rectangle. */
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     /* Unused source surface. */
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Inverted destination or source rectangle. */
     SetRect(&rect, 5, 7, 7, 5);
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, &rect, surface2, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Negative rectangle. */
     SetRect(&rect, -1, -1, 5, 5);
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, &rect, surface2, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, &rect, surface2, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Out of bounds rectangle. */
     SetRect(&rect, 0, 0, 65, 65);
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
 
     /* Combine multiple flags. */
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(surface2);
     IDirectDrawSurface_Release(surface);
@@ -9269,7 +9269,7 @@ static void test_color_fill(void)
 done:
     IDirect3DDevice_Release(device);
     refcount = IDirectDraw_Release(ddraw);
-    ok(refcount == 0, "Ddraw object not properly released, refcount %u.\n", refcount);
+    ok(refcount == 0, "Ddraw object not properly released, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -9358,7 +9358,7 @@ static void test_colorkey_precision(void)
         return;
     }
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     is_nvidia = ddraw_is_nvidia(ddraw);
     /* The Windows 8 WARP driver has plenty of false negatives in X8R8G8B8
@@ -9379,7 +9379,7 @@ static void test_colorkey_precision(void)
     exec_desc.dwBufferSize = 1024;
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
@@ -9404,9 +9404,9 @@ static void test_colorkey_precision(void)
         /* Windows XP (at least with the r200 driver, other drivers untested) produces
          * garbage when doing color keyed texture->texture blits. */
         hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &src, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
         hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
         U5(fx).dwFillColor = tests[t].clear;
         /* On the w8 testbot (WARP driver) the blit result has different values in the
@@ -9424,16 +9424,16 @@ static void test_colorkey_precision(void)
             surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = c << tests[t].shift;
             surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = c << tests[t].shift;
             hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &texture, NULL);
-            ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
             hr = IDirectDrawSurface_QueryInterface(texture, &IID_IDirect3DTexture, (void **)&d3d_texture);
-            ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
             hr = IDirect3DTexture_GetHandle(d3d_texture, device, &handle);
-            ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#lx.\n", hr);
             IDirect3DTexture_Release(d3d_texture);
 
             hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-            ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#lx.\n", hr);
 
             memcpy(exec_desc.lpData, quad, sizeof(quad));
 
@@ -9458,14 +9458,14 @@ static void test_colorkey_precision(void)
             inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData;
             inst_length -= sizeof(quad);
             hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-            ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#lx.\n", hr);
             set_execute_data(execute_buffer, 8, sizeof(quad), inst_length);
 
             hr = IDirectDrawSurface_Blt(dst, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-            ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#lx.\n", hr);
 
             hr = IDirectDrawSurface_Lock(src, NULL, &lock_desc, DDLOCK_WAIT, NULL);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
             switch (tests[t].bpp)
             {
                 case 4:
@@ -9483,21 +9483,21 @@ static void test_colorkey_precision(void)
                     break;
             }
             hr = IDirectDrawSurface_Unlock(src, 0);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
             hr = IDirectDrawSurface_Blt(texture, NULL, src, NULL, DDBLT_WAIT, NULL);
-            ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
             ckey.dwColorSpaceLowValue = c << tests[t].shift;
             ckey.dwColorSpaceHighValue = c << tests[t].shift;
             hr = IDirectDrawSurface_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-            ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
             hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC | DDBLT_WAIT, NULL);
-            ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
             /* Don't make this read only, it somehow breaks the detection of the Nvidia bug below. */
             hr = IDirectDrawSurface_Lock(dst, NULL, &lock_desc, DDLOCK_WAIT, NULL);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
             switch (tests[t].bpp)
             {
                 case 4:
@@ -9515,11 +9515,11 @@ static void test_colorkey_precision(void)
                     break;
             }
             hr = IDirectDrawSurface_Unlock(dst, 0);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
             if (!c)
             {
-                ok(data[0] == tests[t].clear, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+                ok(data[0] == tests[t].clear, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                         tests[t].clear, data[0], tests[t].name, c);
 
                 if (data[3] == tests[t].clear)
@@ -9543,52 +9543,52 @@ static void test_colorkey_precision(void)
                 }
             }
             else
-                ok(data[0] == (c - 1) << tests[t].shift, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+                ok(data[0] == (c - 1) << tests[t].shift, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                         (c - 1) << tests[t].shift, data[0], tests[t].name, c);
 
-            ok(data[1] == tests[t].clear, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+            ok(data[1] == tests[t].clear, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                     tests[t].clear, data[1], tests[t].name, c);
 
             if (c == tests[t].max)
-                ok(data[2] == tests[t].clear, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+                ok(data[2] == tests[t].clear, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                         tests[t].clear, data[2], tests[t].name, c);
             else
-                ok(data[2] == (c + 1) << tests[t].shift, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+                ok(data[2] == (c + 1) << tests[t].shift, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                         (c + 1) << tests[t].shift, data[2], tests[t].name, c);
 
             hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-            ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice_BeginScene(device);
-            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
             hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_UNCLIPPED);
-            ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
             hr = IDirect3DDevice_EndScene(device);
-            ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
             color = get_surface_color(rt, 80, 240);
             if (!c)
                 ok(compare_color(color, 0x0000ff00, 1) || broken(is_warp && compare_color(color, 0x00000000, 1)),
-                        "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                        "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                         color, tests[t].name, c);
             else
                 ok(compare_color(color, 0x00000000, 1) || broken(is_warp && compare_color(color, 0x0000ff00, 1)),
-                        "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                        "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                         color, tests[t].name, c);
 
             color = get_surface_color(rt, 240, 240);
             ok(compare_color(color, 0x0000ff00, 1) || broken(is_warp && compare_color(color, 0x00000000, 1)),
-                    "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                    "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                     color, tests[t].name, c);
 
             color = get_surface_color(rt, 400, 240);
             if (c == tests[t].max)
                 ok(compare_color(color, 0x0000ff00, 1) || broken(is_warp && compare_color(color, 0x00000000, 1)),
-                        "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                        "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                         color, tests[t].name, c);
             else
                 ok(compare_color(color, 0x00000000, 1) || broken(is_warp && compare_color(color, 0x0000ff00, 1)),
-                        "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                        "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                         color, tests[t].name, c);
 
             IDirectDrawSurface_Release(texture);
@@ -9604,7 +9604,7 @@ done:
     IDirect3DExecuteBuffer_Release(execute_buffer);
     IDirect3DDevice_Release(device);
     refcount = IDirectDraw_Release(ddraw);
-    ok(refcount == 0, "Ddraw object not properly released, refcount %u.\n", refcount);
+    ok(refcount == 0, "Ddraw object not properly released, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -9622,7 +9622,7 @@ static void test_range_colorkey(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -9641,85 +9641,85 @@ static void test_range_colorkey(void)
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000000;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000001;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     /* Same for DDSCAPS_OFFSCREENPLAIN. */
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000000;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000001;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000000;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* Setting a range color key without DDCKEY_COLORSPACE collapses the key. */
     ckey.dwColorSpaceLowValue = 0x00000000;
     ckey.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_GetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(!ckey.dwColorSpaceLowValue, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceLowValue);
-    ok(!ckey.dwColorSpaceHighValue, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(!ckey.dwColorSpaceLowValue, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceLowValue);
+    ok(!ckey.dwColorSpaceHighValue, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceHighValue);
 
     ckey.dwColorSpaceLowValue = 0x00000001;
     ckey.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_GetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(ckey.dwColorSpaceLowValue == 0x00000001, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceLowValue);
-    ok(ckey.dwColorSpaceHighValue == 0x00000001, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(ckey.dwColorSpaceLowValue == 0x00000001, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceLowValue);
+    ok(ckey.dwColorSpaceHighValue == 0x00000001, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceHighValue);
 
     /* DDCKEY_COLORSPACE is ignored if the key is a single value. */
     ckey.dwColorSpaceLowValue = 0x00000000;
     ckey.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     /* Using it with a range key results in DDERR_NOCOLORKEYHW. */
     ckey.dwColorSpaceLowValue = 0x00000001;
     ckey.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
     ckey.dwColorSpaceLowValue = 0x00000000;
     ckey.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
     /* Range destination keys don't work either. */
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_DESTBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     /* Just to show it's not because of A, R, and G having equal values. */
     ckey.dwColorSpaceLowValue = 0x00000000;
     ckey.dwColorSpaceHighValue = 0x01010101;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     /* None of these operations modified the key. */
     hr = IDirectDrawSurface_GetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(!ckey.dwColorSpaceLowValue, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceLowValue);
-    ok(!ckey.dwColorSpaceHighValue, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(!ckey.dwColorSpaceLowValue, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceLowValue);
+    ok(!ckey.dwColorSpaceHighValue, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceHighValue);
 
     IDirectDrawSurface_Release(surface);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -9782,7 +9782,7 @@ static void test_shademode(void)
     }
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     background = create_diffuse_material(device, 1.0f, 1.0f, 1.0f, 1.0f);
     viewport = create_viewport(device, 0, 0, 640, 480);
@@ -9795,7 +9795,7 @@ static void test_shademode(void)
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
 
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#lx.\n", hr);
 
     /* Try it first with a TRIANGLESTRIP.  Do it with different geometry because
      * the color fixups we have to do for FLAT shading will be dependent on that. */
@@ -9803,10 +9803,10 @@ static void test_shademode(void)
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
         hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-        ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#lx.\n", hr);
 
         quad = tests[i].primtype == D3DPT_TRIANGLESTRIP ? quad_strip : quad_list;
         memcpy(exec_desc.lpData, quad, sizeof(quad_strip));
@@ -9826,14 +9826,14 @@ static void test_shademode(void)
         inst_length -= sizeof(quad_strip);
 
         hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-        ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice_BeginScene(device);
         set_execute_data(execute_buffer, 4, sizeof(quad_strip), inst_length);
         hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-        ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx.\n", hr);
         hr = IDirect3DDevice_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color0 = get_surface_color(rt, 100, 100); /* Inside first triangle */
         color1 = get_surface_color(rt, 500, 350); /* Inside second triangle */
@@ -9843,9 +9843,9 @@ static void test_shademode(void)
          * functionality being available. */
         /* PHONG should be the same as GOURAUD, since no hardware implements
          * this. */
-        ok(compare_color(color0, tests[i].color0, 1), "Test %u shading has color0 %08x, expected %08x.\n",
+        ok(compare_color(color0, tests[i].color0, 1), "Test %u shading has color0 %08lx, expected %08lx.\n",
                 i, color0, tests[i].color0);
-        ok(compare_color(color1, tests[i].color1, 1), "Test %u shading has color1 %08x, expected %08x.\n",
+        ok(compare_color(color1, tests[i].color1, 1), "Test %u shading has color1 %08lx, expected %08lx.\n",
                 i, color1, tests[i].color1);
     }
 
@@ -9854,7 +9854,7 @@ static void test_shademode(void)
     destroy_material(background);
     IDirectDrawSurface_Release(rt);
     refcount = IDirect3DDevice_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirectDraw_Release(ddraw);
     DestroyWindow(window);
 }
@@ -9908,12 +9908,12 @@ static void test_lockrect_invalid(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & needed_caps) != needed_caps)
     {
         skip("Required surface types not supported, skipping test.\n");
@@ -9936,10 +9936,10 @@ static void test_lockrect_invalid(void)
         U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x0000ff;
 
         hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx, type %s.\n", hr, resources[r].name);
 
         hr = IDirectDrawSurface_Lock(surface, NULL, NULL, DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name);
+        ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx, type %s.\n", hr, resources[r].name);
 
         for (i = 0; i < ARRAY_SIZE(valid); ++i)
         {
@@ -9949,11 +9949,11 @@ static void test_lockrect_invalid(void)
             surface_desc.dwSize = sizeof(surface_desc);
 
             hr = IDirectDrawSurface_Lock(surface, rect, &surface_desc, DDLOCK_WAIT, NULL);
-            ok(SUCCEEDED(hr), "Lock failed (%#x) for rect %s, type %s.\n",
+            ok(SUCCEEDED(hr), "Lock failed (%#lx) for rect %s, type %s.\n",
                     hr, wine_dbgstr_rect(rect), resources[r].name);
 
             hr = IDirectDrawSurface_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
         }
 
         for (i = 0; i < ARRAY_SIZE(invalid); ++i)
@@ -9964,37 +9964,37 @@ static void test_lockrect_invalid(void)
             surface_desc.dwSize = sizeof(surface_desc);
 
             hr = IDirectDrawSurface_Lock(surface, rect, &surface_desc, DDLOCK_WAIT, NULL);
-            ok(hr == resources[r].hr, "Lock returned %#x for rect %s, type %s.\n",
+            ok(hr == resources[r].hr, "Lock returned %#lx for rect %s, type %s.\n",
                     hr, wine_dbgstr_rect(rect), resources[r].name);
             if (SUCCEEDED(hr))
             {
                 hr = IDirectDrawSurface_Unlock(surface, NULL);
-                ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+                ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
             }
             else
                 ok(!surface_desc.lpSurface, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
         }
 
         hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Lock(rect = NULL) failed, hr %#x, type %s.\n",
+        ok(SUCCEEDED(hr), "Lock(rect = NULL) failed, hr %#lx, type %s.\n",
                 hr, resources[r].name);
         hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_SURFACEBUSY, "Double lock(rect = NULL) returned %#x, type %s.\n",
+        ok(hr == DDERR_SURFACEBUSY, "Double lock(rect = NULL) returned %#lx, type %s.\n",
                 hr, resources[r].name);
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
 
         hr = IDirectDrawSurface_Lock(surface, &valid[0], &surface_desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Lock(rect = %s) failed (%#x).\n", wine_dbgstr_rect(&valid[0]), hr);
+        ok(SUCCEEDED(hr), "Lock(rect = %s) failed (%#lx).\n", wine_dbgstr_rect(&valid[0]), hr);
         hr = IDirectDrawSurface_Lock(surface, &valid[0], &surface_desc, DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_SURFACEBUSY, "Double lock(rect = %s) failed (%#x).\n",
+        ok(hr == DDERR_SURFACEBUSY, "Double lock(rect = %s) failed (%#lx).\n",
                 wine_dbgstr_rect(&valid[0]), hr);
 
         /* Locking a different rectangle returns DD_OK, but it seems to break the surface.
          * Afterwards unlocking the surface fails(NULL rectangle or both locked rectangles) */
 
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
 
         IDirectDrawSurface_Release(surface);
     }
@@ -10019,7 +10019,7 @@ static void test_yv12_overlay(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     if (!(src_surface = create_overlay(ddraw, 256, 256, MAKEFOURCC('Y','V','1','2'))))
     {
@@ -10030,17 +10030,17 @@ static void test_yv12_overlay(void)
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
     hr = IDirectDrawSurface_Lock(src_surface, NULL, &desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
 
     ok(desc.dwFlags == (DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS | DDSD_PITCH),
-            "Got unexpected flags %#x.\n", desc.dwFlags);
+            "Got unexpected flags %#lx.\n", desc.dwFlags);
     ok(desc.ddsCaps.dwCaps == (DDSCAPS_OVERLAY | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM | DDSCAPS_HWCODEC)
             || desc.ddsCaps.dwCaps == (DDSCAPS_OVERLAY | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM),
-            "Got unexpected caps %#x.\n", desc.ddsCaps.dwCaps);
-    ok(desc.dwWidth == 256, "Got unexpected width %u.\n", desc.dwWidth);
-    ok(desc.dwHeight == 256, "Got unexpected height %u.\n", desc.dwHeight);
+            "Got unexpected caps %#lx.\n", desc.ddsCaps.dwCaps);
+    ok(desc.dwWidth == 256, "Got unexpected width %lu.\n", desc.dwWidth);
+    ok(desc.dwHeight == 256, "Got unexpected height %lu.\n", desc.dwHeight);
     /* The overlay pitch seems to have 256 byte alignment. */
-    ok(!(U1(desc).lPitch & 0xff), "Got unexpected pitch %u.\n", U1(desc).lPitch);
+    ok(!(U1(desc).lPitch & 0xff), "Got unexpected pitch %lu.\n", U1(desc).lPitch);
 
     /* Fill the surface with some data for the blit test. */
     base = desc.lpSurface;
@@ -10061,7 +10061,7 @@ static void test_yv12_overlay(void)
     }
 
     hr = IDirectDrawSurface_Unlock(src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* YV12 uses 2x2 blocks with 6 bytes per block (4*Y, 1*U, 1*V). Unlike
      * other block-based formats like DXT the entire Y channel is stored in
@@ -10069,12 +10069,12 @@ static void test_yv12_overlay(void)
      * locks do not really make sense. Show that they are allowed nevertheless
      * and the offset points into the luminance data. */
     hr = IDirectDrawSurface_Lock(src_surface, &rect, &desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     offset = ((const unsigned char *)desc.lpSurface - base);
-    ok(offset == rect.top * U1(desc).lPitch + rect.left, "Got unexpected offset %u, expected %u.\n",
+    ok(offset == rect.top * U1(desc).lPitch + rect.left, "Got unexpected offset %u, expected %lu.\n",
             offset, rect.top * U1(desc).lPitch + rect.left);
     hr = IDirectDrawSurface_Unlock(src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     if (!(dst_surface = create_overlay(ddraw, 256, 256, MAKEFOURCC('Y','V','1','2'))))
     {
@@ -10088,14 +10088,14 @@ static void test_yv12_overlay(void)
     hr = IDirectDrawSurface_Blt(dst_surface, NULL, src_surface, NULL, DDBLT_WAIT, NULL);
     /* VMware rejects YV12 blits. This behavior has not been seen on real
      * hardware yet, so mark it broken. */
-    ok(SUCCEEDED(hr) || broken(hr == E_NOTIMPL), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == E_NOTIMPL), "Failed to blit, hr %#lx.\n", hr);
 
     if (SUCCEEDED(hr))
     {
         memset(&desc, 0, sizeof(desc));
         desc.dwSize = sizeof(desc);
         hr = IDirectDrawSurface_Lock(dst_surface, NULL, &desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
 
         base = desc.lpSurface;
         ok(base[0] == 0x10, "Got unexpected Y data 0x%02x.\n", base[0]);
@@ -10105,7 +10105,7 @@ static void test_yv12_overlay(void)
         ok(base[0] == 0x30, "Got unexpected U data 0x%02x.\n", base[0]);
 
         hr = IDirectDrawSurface_Unlock(dst_surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
     }
 
     IDirectDrawSurface_Release(dst_surface);
@@ -10141,7 +10141,7 @@ static void test_offscreen_overlay(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     if (!(overlay = create_overlay(ddraw, 64, 64, MAKEFOURCC('U','Y','V','Y'))))
     {
@@ -10154,21 +10154,21 @@ static void test_offscreen_overlay(void)
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     /* On Windows 7, and probably Vista, UpdateOverlay() will return
      * DDERR_OUTOFCAPS if the dwm is active. Calling GetDC() on the primary
      * surface prevents this by disabling the dwm. */
     hr = IDirectDrawSurface_GetDC(primary, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_ReleaseDC(primary, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     /* Try to overlay a NULL surface. */
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_SHOW, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_HIDE, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Try to overlay an offscreen surface. */
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -10185,18 +10185,18 @@ static void test_offscreen_overlay(void)
     U3(surface_desc.ddpfPixelFormat).dwGBitMask = 0x07e0;
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x001f;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &offscreen, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, offscreen, NULL, DDOVER_SHOW, NULL);
     ok(SUCCEEDED(hr) || broken(hr == DDERR_OUTOFCAPS && dwm_enabled())
             || broken(hr == E_NOTIMPL && ddraw_is_vmware(ddraw)),
-            "Failed to update overlay, hr %#x.\n", hr);
+            "Failed to update overlay, hr %#lx.\n", hr);
 
     /* Try to overlay the primary with a non-overlay surface. */
     hr = IDirectDrawSurface_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_SHOW, NULL);
-    ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_HIDE, NULL);
-    ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(offscreen);
     IDirectDrawSurface_Release(primary);
@@ -10221,7 +10221,7 @@ static void test_overlay_rect(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     if (!(overlay = create_overlay(ddraw, 64, 64, MAKEFOURCC('U','Y','V','Y'))))
     {
@@ -10234,15 +10234,15 @@ static void test_overlay_rect(void)
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     /* On Windows 7, and probably Vista, UpdateOverlay() will return
      * DDERR_OUTOFCAPS if the dwm is active. Calling GetDC() on the primary
      * surface prevents this by disabling the dwm. */
     hr = IDirectDrawSurface_GetDC(primary, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_ReleaseDC(primary, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     /* On Windows 8 and newer DWM can't be turned off, making overlays unusable. */
     if (dwm_enabled())
@@ -10255,48 +10255,48 @@ static void test_overlay_rect(void)
      * used. This is not true in Windows Vista and earlier, but changed in
      * Windows 7. */
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, primary, &rect, DDOVER_SHOW, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, primary, NULL, DDOVER_HIDE, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, primary, NULL, DDOVER_SHOW, NULL);
-    ok(hr == DD_OK || hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Show that the overlay position is the (top, left) coordinate of the
      * destination rectangle. */
     OffsetRect(&rect, 32, 16);
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, primary, &rect, DDOVER_SHOW, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#lx.\n", hr);
     pos_x = -1; pos_y = -1;
     hr = IDirectDrawSurface_GetOverlayPosition(overlay, &pos_x, &pos_y);
-    ok(SUCCEEDED(hr), "Failed to get overlay position, hr %#x.\n", hr);
-    ok(pos_x == rect.left, "Got unexpected pos_x %d, expected %d.\n", pos_x, rect.left);
-    ok(pos_y == rect.top, "Got unexpected pos_y %d, expected %d.\n", pos_y, rect.top);
+    ok(SUCCEEDED(hr), "Failed to get overlay position, hr %#lx.\n", hr);
+    ok(pos_x == rect.left, "Got unexpected pos_x %ld, expected %ld.\n", pos_x, rect.left);
+    ok(pos_y == rect.top, "Got unexpected pos_y %ld, expected %ld.\n", pos_y, rect.top);
 
     /* Passing a NULL dest rect sets the position to 0/0. Visually it can be
      * seen that the overlay overlays the whole primary(==screen). */
     hr2 = IDirectDrawSurface_UpdateOverlay(overlay, NULL, primary, NULL, 0, NULL);
-    ok(hr2 == DD_OK || hr2 == DDERR_INVALIDPARAMS || hr2 == DDERR_OUTOFCAPS, "Got unexpected hr %#x.\n", hr2);
+    ok(hr2 == DD_OK || hr2 == DDERR_INVALIDPARAMS || hr2 == DDERR_OUTOFCAPS, "Got unexpected hr %#lx.\n", hr2);
     hr = IDirectDrawSurface_GetOverlayPosition(overlay, &pos_x, &pos_y);
-    ok(SUCCEEDED(hr), "Failed to get overlay position, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get overlay position, hr %#lx.\n", hr);
     if (SUCCEEDED(hr2))
     {
-        ok(!pos_x, "Got unexpected pos_x %d.\n", pos_x);
-        ok(!pos_y, "Got unexpected pos_y %d.\n", pos_y);
+        ok(!pos_x, "Got unexpected pos_x %ld.\n", pos_x);
+        ok(!pos_y, "Got unexpected pos_y %ld.\n", pos_y);
     }
     else
     {
-        ok(pos_x == 32, "Got unexpected pos_x %d.\n", pos_x);
-        ok(pos_y == 16, "Got unexpected pos_y %d.\n", pos_y);
+        ok(pos_x == 32, "Got unexpected pos_x %ld.\n", pos_x);
+        ok(pos_y == 16, "Got unexpected pos_y %ld.\n", pos_y);
     }
 
     /* The position cannot be retrieved when the overlay is not shown. */
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, primary, &rect, DDOVER_HIDE, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#lx.\n", hr);
     pos_x = -1; pos_y = -1;
     hr = IDirectDrawSurface_GetOverlayPosition(overlay, &pos_x, &pos_y);
-    ok(hr == DDERR_OVERLAYNOTVISIBLE, "Got unexpected hr %#x.\n", hr);
-    ok(!pos_x, "Got unexpected pos_x %d.\n", pos_x);
-    ok(!pos_y, "Got unexpected pos_y %d.\n", pos_y);
+    ok(hr == DDERR_OVERLAYNOTVISIBLE, "Got unexpected hr %#lx.\n", hr);
+    ok(!pos_x, "Got unexpected pos_x %ld.\n", pos_x);
+    ok(!pos_y, "Got unexpected pos_y %ld.\n", pos_y);
 
 done:
     if (primary)
@@ -10350,7 +10350,7 @@ static void test_blt(void)
     }
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -10359,36 +10359,36 @@ static void test_blt(void)
     surface_desc.dwHeight = 480;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Blt(surface, NULL, surface, NULL, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Blt(surface, NULL, rt, NULL, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect,
                 surface, &test_data[i].src_rect, DDBLT_WAIT, NULL);
-        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
 
         hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect,
                 rt, &test_data[i].src_rect, DDBLT_WAIT, NULL);
-        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
 
         hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect,
                 NULL, &test_data[i].src_rect, DDBLT_WAIT, NULL);
-        ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect, NULL, NULL, DDBLT_WAIT, NULL);
-        ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#lx.\n", i, hr);
     }
 
     IDirectDrawSurface_Release(surface);
     IDirectDrawSurface_Release(rt);
     refcount = IDirect3DDevice_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirectDraw_Release(ddraw);
     DestroyWindow(window);
 }
@@ -10430,7 +10430,7 @@ static void test_blt_z_alpha(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&pf, 0, sizeof(pf));
     pf.dwSize = sizeof(pf);
@@ -10450,9 +10450,9 @@ static void test_blt_z_alpha(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
 
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#lx.\n", hr);
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &dst_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
@@ -10472,23 +10472,23 @@ static void test_blt_z_alpha(void)
     {
         U5(fx).dwFillColor = 0x3300ff00;
         hr = IDirectDrawSurface_Blt(src_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         U5(fx).dwFillColor = 0xccff0000;
         hr = IDirectDrawSurface_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirectDrawSurface_Blt(dst_surface, NULL, src_surface, NULL, blt_flags[i] | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         color = get_surface_color(dst_surface, 32, 32);
-        ok(compare_color(color, 0x0000ff00, 0), "Test %u: Got unexpected color 0x%08x.\n", i, color);
+        ok(compare_color(color, 0x0000ff00, 0), "Test %u: Got unexpected color 0x%08lx.\n", i, color);
     }
 
     IDirectDrawSurface_Release(dst_surface);
     IDirectDrawSurface_Release(src_surface);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -10534,7 +10534,7 @@ static void test_cross_device_blt(void)
     surface_desc.dwHeight = 480;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -10542,7 +10542,7 @@ static void test_cross_device_blt(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_VIDEOMEMORY;
     surface_desc.dwBackBufferCount = 2;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -10557,37 +10557,37 @@ static void test_cross_device_blt(void)
     U3(surface_desc.ddpfPixelFormat).dwGBitMask = 0x000003e0;
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x0000001f;
     hr = IDirectDraw_CreateSurface(ddraw2, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 0xff0000ff;
     hr = IDirectDrawSurface_Blt(surface2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(surface, 320, 240);
-    ok(color == 0x00000000, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00000000, "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirectDrawSurface_Blt(sysmem_surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(sysmem_surface, 320, 240);
-    ok(color == 0x00000000, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00000000, "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Blt(sysmem_surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(sysmem_surface, 320, 240);
-    ok(color == 0x00000000, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00000000, "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface_Release(surface2);
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -10597,22 +10597,22 @@ static void test_cross_device_blt(void)
     surface_desc.dwHeight = 480;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw_CreateSurface(ddraw2, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Blt(sysmem_surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    todo_wine ok(hr == D3D_OK, "Failed to blit, hr %#x.\n", hr);
+    todo_wine ok(hr == D3D_OK, "Failed to blit, hr %#lx.\n", hr);
     color = get_surface_color(sysmem_surface, 320, 240);
-    todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface_Release(surface);
     IDirectDrawSurface_Release(surface2);
     IDirectDrawSurface_Release(sysmem_surface);
     refcount = IDirect3DDevice_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     refcount = IDirect3DDevice_Release(device2);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirectDraw_Release(ddraw);
     IDirectDraw_Release(ddraw2);
     DestroyWindow(window);
@@ -10687,11 +10687,11 @@ static void test_getdc(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw_GetDisplayMode(ddraw, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#lx.\n", hr);
     screen_bpp = U1(surface_desc.ddpfPixelFormat).dwRGBBitCount;
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
@@ -10709,7 +10709,7 @@ static void test_getdc(void)
             surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
             if (FAILED(hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL)))
             {
-                skip("Failed to create surface for format %s (hr %#x), skipping tests.\n", test_data[i].name, hr);
+                skip("Failed to create surface for format %s (hr %#lx), skipping tests.\n", test_data[i].name, hr);
                 continue;
             }
         }
@@ -10718,9 +10718,9 @@ static void test_getdc(void)
         hr = IDirectDrawSurface_GetDC(surface, &dc);
         if (test_data[i].getdc_supported)
             ok(SUCCEEDED(hr) || broken(hr == test_data[i].alt_result || ddraw_is_vmware(ddraw)),
-                    "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+                    "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         else
-            ok(FAILED(hr), "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+            ok(FAILED(hr), "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         if (SUCCEEDED(hr))
         {
@@ -10731,10 +10731,10 @@ static void test_getdc(void)
             int size;
 
             type = GetObjectType(dc);
-            ok(type == OBJ_MEMDC, "Got unexpected object type %#x for format %s.\n", type, test_data[i].name);
+            ok(type == OBJ_MEMDC, "Got unexpected object type %#lx for format %s.\n", type, test_data[i].name);
             bitmap = GetCurrentObject(dc, OBJ_BITMAP);
             type = GetObjectType(bitmap);
-            ok(type == OBJ_BITMAP, "Got unexpected object type %#x for format %s.\n", type, test_data[i].name);
+            ok(type == OBJ_BITMAP, "Got unexpected object type %#lx for format %s.\n", type, test_data[i].name);
 
             size = GetObjectA(bitmap, sizeof(dib), &dib);
             ok(size == sizeof(dib), "Got unexpected size %d for format %s.\n", size, test_data[i].name);
@@ -10758,11 +10758,11 @@ static void test_getdc(void)
             ok(!!dib.dsBm.bmBits || broken(!pDwmIsCompositionEnabled && dib.dsBm.bmBitsPixel == screen_bpp),
                     "Got unexpected bits %p for format %s.\n", dib.dsBm.bmBits, test_data[i].name);
 
-            ok(dib.dsBmih.biSize == sizeof(dib.dsBmih), "Got unexpected size %u for format %s.\n",
+            ok(dib.dsBmih.biSize == sizeof(dib.dsBmih), "Got unexpected size %lu for format %s.\n",
                     dib.dsBmih.biSize, test_data[i].name);
-            ok(dib.dsBmih.biWidth == surface_desc.dwWidth, "Got unexpected width %d for format %s.\n",
+            ok(dib.dsBmih.biWidth == surface_desc.dwWidth, "Got unexpected width %ld for format %s.\n",
                     dib.dsBmih.biHeight, test_data[i].name);
-            ok(dib.dsBmih.biHeight == surface_desc.dwHeight, "Got unexpected height %d for format %s.\n",
+            ok(dib.dsBmih.biHeight == surface_desc.dwHeight, "Got unexpected height %ld for format %s.\n",
                     dib.dsBmih.biHeight, test_data[i].name);
             ok(dib.dsBmih.biPlanes == 1, "Got unexpected plane count %u for format %s.\n",
                     dib.dsBmih.biPlanes, test_data[i].name);
@@ -10771,17 +10771,17 @@ static void test_getdc(void)
                     dib.dsBmih.biBitCount, test_data[i].name);
             ok(dib.dsBmih.biCompression == (U1(test_data[i].format).dwRGBBitCount == 16 ? BI_BITFIELDS : BI_RGB)
                     || broken(U1(test_data[i].format).dwRGBBitCount == 32 && dib.dsBmih.biCompression == BI_BITFIELDS),
-                    "Got unexpected compression %#x for format %s.\n",
+                    "Got unexpected compression %#lx for format %s.\n",
                     dib.dsBmih.biCompression, test_data[i].name);
-            ok(!dib.dsBmih.biSizeImage, "Got unexpected image size %u for format %s.\n",
+            ok(!dib.dsBmih.biSizeImage, "Got unexpected image size %lu for format %s.\n",
                     dib.dsBmih.biSizeImage, test_data[i].name);
-            ok(!dib.dsBmih.biXPelsPerMeter, "Got unexpected horizontal resolution %d for format %s.\n",
+            ok(!dib.dsBmih.biXPelsPerMeter, "Got unexpected horizontal resolution %ld for format %s.\n",
                     dib.dsBmih.biXPelsPerMeter, test_data[i].name);
-            ok(!dib.dsBmih.biYPelsPerMeter, "Got unexpected vertical resolution %d for format %s.\n",
+            ok(!dib.dsBmih.biYPelsPerMeter, "Got unexpected vertical resolution %ld for format %s.\n",
                     dib.dsBmih.biYPelsPerMeter, test_data[i].name);
-            ok(!dib.dsBmih.biClrUsed, "Got unexpected used colour count %u for format %s.\n",
+            ok(!dib.dsBmih.biClrUsed, "Got unexpected used colour count %lu for format %s.\n",
                     dib.dsBmih.biClrUsed, test_data[i].name);
-            ok(!dib.dsBmih.biClrImportant, "Got unexpected important colour count %u for format %s.\n",
+            ok(!dib.dsBmih.biClrImportant, "Got unexpected important colour count %lu for format %s.\n",
                     dib.dsBmih.biClrImportant, test_data[i].name);
 
             if (dib.dsBmih.biCompression == BI_BITFIELDS)
@@ -10790,20 +10790,20 @@ static void test_getdc(void)
                         && dib.dsBitfields[1] == U3(test_data[i].format).dwGBitMask
                         && dib.dsBitfields[2] == U4(test_data[i].format).dwBBitMask)
                         || broken(!dib.dsBitfields[0] && !dib.dsBitfields[1] && !dib.dsBitfields[2]),
-                        "Got unexpected colour masks 0x%08x 0x%08x 0x%08x for format %s.\n",
+                        "Got unexpected colour masks 0x%08lx 0x%08lx 0x%08lx for format %s.\n",
                         dib.dsBitfields[0], dib.dsBitfields[1], dib.dsBitfields[2], test_data[i].name);
             }
             else
             {
                 ok(!dib.dsBitfields[0] && !dib.dsBitfields[1] && !dib.dsBitfields[2],
-                        "Got unexpected colour masks 0x%08x 0x%08x 0x%08x for format %s.\n",
+                        "Got unexpected colour masks 0x%08lx 0x%08lx 0x%08lx for format %s.\n",
                         dib.dsBitfields[0], dib.dsBitfields[1], dib.dsBitfields[2], test_data[i].name);
             }
             ok(!dib.dshSection, "Got unexpected section %p for format %s.\n", dib.dshSection, test_data[i].name);
-            ok(!dib.dsOffset, "Got unexpected offset %u for format %s.\n", dib.dsOffset, test_data[i].name);
+            ok(!dib.dsOffset, "Got unexpected offset %lu for format %s.\n", dib.dsOffset, test_data[i].name);
 
             hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-            ok(hr == DD_OK, "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+            ok(hr == DD_OK, "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         }
         else
         {
@@ -10818,152 +10818,152 @@ static void test_getdc(void)
         surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
         if (FAILED(hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL)))
         {
-            skip("Failed to create mip-mapped texture for format %s (hr %#x), skipping tests.\n",
+            skip("Failed to create mip-mapped texture for format %s (hr %#lx), skipping tests.\n",
                     test_data[i].name, hr);
             continue;
         }
 
         hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &tmp);
-        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_GetAttachedSurface(tmp, &caps, &surface2);
-        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         IDirectDrawSurface_Release(tmp);
 
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         dc2 = (void *)0x1234;
         hr = IDirectDrawSurface_GetDC(surface, &dc2);
-        ok(hr == DDERR_DCALREADYCREATED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_DCALREADYCREATED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         ok(dc2 == (void *)0x1234, "Got unexpected dc %p for format %s.\n", dc, test_data[i].name);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(hr == DDERR_NODC, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NODC, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         map_desc.dwSize = sizeof(map_desc);
         hr = IDirectDrawSurface_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_SURFACEBUSY, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_SURFACEBUSY, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_SURFACEBUSY, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_SURFACEBUSY, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         /* Geforce 9600, Windows 7 returns E_FAIL. The unlock still seems to work as intended, after-
          * wards the surface can be locked again. ReleaseDC() does not unlock the surface, trying to
          * Lock it after ReleaseDC returns DDERR_SURFACEBUSY. ddraw4 and 7 are unaffected. */
         hr = IDirectDrawSurface_Unlock(surface, NULL);
         ok(SUCCEEDED(hr) || broken(ddraw_is_nvidia(ddraw) && hr == E_FAIL),
-                "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+                "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_GetDC(surface2, &dc2);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface2, dc2);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_GetDC(surface, &dc2);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc2);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Lock(surface2, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface2, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface, NULL);
         ok(SUCCEEDED(hr) || broken(ddraw_is_nvidia(ddraw) && hr == E_FAIL),
-                "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+                "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_Lock(surface2, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface2, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Lock(surface2, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface2, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         hr = IDirectDrawSurface_Unlock(surface2, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface2, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface2, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         IDirectDrawSurface_Release(surface2);
         IDirectDrawSurface_Release(surface);
@@ -11088,11 +11088,11 @@ static void test_transform_vertices(void)
     }
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 256, 256);
     hr = IDirect3DViewport_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
 
     memset(&transformdata, 0, sizeof(transformdata));
     transformdata.dwSize = sizeof(transformdata);
@@ -11104,8 +11104,8 @@ static void test_transform_vertices(void)
 
     hr = IDirect3DViewport_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
 
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
@@ -11120,19 +11120,19 @@ static void test_transform_vertices(void)
                 out[i].x, out[i].y, out[i].z, out[i].w);
         ok(out[i].v1 == position_tests[i].v1 && out[i].v2 == position_tests[i].v2
                 && out[i].v3 == position_tests[i].v3 && out[i].v4 == position_tests[i].v4,
-                "Vertex %u payload is %u %u %u %u.\n", i, out[i].v1, out[i].v2, out[i].v3, out[i].v4);
+                "Vertex %u payload is %lu %lu %lu %lu.\n", i, out[i].v1, out[i].v2, out[i].v3, out[i].v4);
         ok(out[i].unused3 == 0xdeadbeef && out[i].unused4 == 0xcafecafe,
-                "Vertex %u unused data is %#x, %#x.\n", i, out[i].unused3, out[i].unused4);
+                "Vertex %u unused data is %#lx, %#lx.\n", i, out[i].unused3, out[i].unused4);
     }
 
     vp_data = vp_template;
     hr = IDirect3DViewport_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
 
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
@@ -11149,12 +11149,12 @@ static void test_transform_vertices(void)
     vp_data.dwX = 10;
     vp_data.dwY = 20;
     hr = IDirect3DViewport_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
         static const struct vec4 cmp[] =
@@ -11171,8 +11171,8 @@ static void test_transform_vertices(void)
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
         static const D3DHVERTEX cmp_h[] =
@@ -11185,7 +11185,7 @@ static void test_transform_vertices(void)
                 && compare_float(U2(cmp_h[i]).hy, U2(out_h[i]).hy, 4096)
                 && compare_float(U3(cmp_h[i]).hz, U3(out_h[i]).hz, 4096)
                 && cmp_h[i].dwFlags == out_h[i].dwFlags,
-                "HVertex %u differs. Got %#x %f %f %f.\n", i,
+                "HVertex %u differs. Got %#lx %f %f %f.\n", i,
                 out_h[i].dwFlags, U1(out_h[i]).hx, U2(out_h[i]).hy, U3(out_h[i]).hz);
 
         /* No scheme has been found behind those return values. It seems to be
@@ -11210,8 +11210,8 @@ static void test_transform_vertices(void)
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport_TransformVertices(viewport, ARRAY_SIZE(cliptest),
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(cliptest); ++i)
     {
         static const DWORD flags[] =
@@ -11221,19 +11221,19 @@ static void test_transform_vertices(void)
             0,
             D3DCLIP_LEFT  | D3DCLIP_BOTTOM | D3DCLIP_FRONT,
         };
-        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#x.\n", i, out_h[i].dwFlags);
+        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#lx.\n", i, out_h[i].dwFlags);
     }
 
     vp_data = vp_template;
     vp_data.dwWidth = 10;
     vp_data.dwHeight = 1000;
     hr = IDirect3DViewport_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport_TransformVertices(viewport, ARRAY_SIZE(cliptest),
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(cliptest); ++i)
     {
         static const DWORD flags[] =
@@ -11243,7 +11243,7 @@ static void test_transform_vertices(void)
             D3DCLIP_LEFT,
             D3DCLIP_LEFT  | D3DCLIP_FRONT,
         };
-        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#x.\n", i, out_h[i].dwFlags);
+        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#lx.\n", i, out_h[i].dwFlags);
     }
 
     vp_data = vp_template;
@@ -11252,11 +11252,11 @@ static void test_transform_vertices(void)
     vp_data.dvScaleX = 1;
     vp_data.dvScaleY = 1;
     hr = IDirect3DViewport_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     hr = IDirect3DViewport_TransformVertices(viewport, ARRAY_SIZE(cliptest),
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(cliptest); ++i)
     {
         static const DWORD flags[] =
@@ -11266,7 +11266,7 @@ static void test_transform_vertices(void)
             0,
             D3DCLIP_FRONT,
         };
-        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#x.\n", i, out_h[i].dwFlags);
+        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#lx.\n", i, out_h[i].dwFlags);
     }
 
     /* Finally try to figure out how the DWORD dwOffscreen works.
@@ -11277,51 +11277,51 @@ static void test_transform_vertices(void)
     vp_data.dvScaleX = 10000.0f;
     vp_data.dvScaleY = 10000.0f;
     hr = IDirect3DViewport_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     transformdata.lpIn = cliptest;
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
 
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %lx.\n", offscreen);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport_TransformVertices(viewport, 2,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %lx.\n", offscreen);
     hr = IDirect3DViewport_TransformVertices(viewport, 3,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
 
     transformdata.lpIn = cliptest + 1;
     hr = IDirect3DViewport_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_BACK | D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_BACK | D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %lx.\n", offscreen);
 
     transformdata.lpIn = cliptest + 2;
     hr = IDirect3DViewport_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %lx.\n", offscreen);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport_TransformVertices(viewport, 2,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %lx.\n", offscreen);
 
     transformdata.lpIn = cliptest + 3;
     hr = IDirect3DViewport_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_FRONT | D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_FRONT | D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %lx.\n", offscreen);
 
     transformdata.lpIn = offscreentest;
     transformdata.dwInSize = sizeof(offscreentest[0]);
@@ -11331,21 +11331,21 @@ static void test_transform_vertices(void)
     vp_data.dvScaleX = 1.0f;
     vp_data.dvScaleY = 1.0f;
     hr = IDirect3DViewport_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
 
     vp_data.dwWidth = 256;
     vp_data.dwHeight = 256;
     hr = IDirect3DViewport_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     hr = IDirect3DViewport_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == D3DCLIP_RIGHT, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == D3DCLIP_RIGHT, "Offscreen is %lx.\n", offscreen);
 
     /* Test the effect of Matrices.
      *
@@ -11361,22 +11361,22 @@ static void test_transform_vertices(void)
     vp_data.dvMinZ = 0.0f;
     vp_data.dvMaxZ = 1.0f;
     hr = IDirect3DViewport_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice_CreateMatrix(device, &world_handle);
-    ok(hr == D3D_OK, "Creating a matrix object failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Creating a matrix object failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice_SetMatrix(device, world_handle, &mat_translate1);
-    ok(hr == D3D_OK, "Setting a matrix object failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Setting a matrix object failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice_CreateMatrix(device, &view_handle);
-    ok(hr == D3D_OK, "Creating a matrix object failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Creating a matrix object failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice_SetMatrix(device, view_handle, &mat_scale);
-    ok(hr == D3D_OK, "Setting a matrix object failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Setting a matrix object failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice_CreateMatrix(device, &proj_handle);
-    ok(hr == D3D_OK, "Creating a matrix object failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Creating a matrix object failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice_SetMatrix(device, proj_handle, &mat_translate2);
-    ok(hr == D3D_OK, "Setting a matrix object failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Setting a matrix object failed, hr %#lx.\n", hr);
 
     memset(&exec_desc, 0, sizeof(exec_desc));
     exec_desc.dwSize = sizeof(exec_desc);
@@ -11384,10 +11384,10 @@ static void test_transform_vertices(void)
     exec_desc.dwBufferSize = 1024;
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#lx.\n", hr);
     ptr = (BYTE *)exec_desc.lpData;
     emit_set_ts(&ptr, D3DTRANSFORMSTATE_WORLD, world_handle);
     emit_set_ts(&ptr, D3DTRANSFORMSTATE_VIEW, view_handle);
@@ -11395,21 +11395,21 @@ static void test_transform_vertices(void)
     emit_end(&ptr);
     inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData;
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#lx.\n", hr);
 
     set_execute_data(execute_buffer, 0, 0, inst_length);
     hr = IDirect3DDevice_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     transformdata.lpIn = position_tests;
     transformdata.dwInSize = sizeof(position_tests[0]);
     hr = IDirect3DViewport_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
@@ -11428,48 +11428,48 @@ static void test_transform_vertices(void)
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, 0, &offscreen);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
-    ok(offscreen == 0xdeadbeef, "Offscreen is %x.\n", offscreen);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
+    ok(offscreen == 0xdeadbeef, "Offscreen is %lx.\n", offscreen);
 
     /* NULL transform data. */
     hr = IDirect3DViewport_TransformVertices(viewport, 1,
             NULL, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
-    ok(offscreen == 0xdeadbeef, "Offscreen is %x.\n", offscreen);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
+    ok(offscreen == 0xdeadbeef, "Offscreen is %lx.\n", offscreen);
     hr = IDirect3DViewport_TransformVertices(viewport, 0,
             NULL, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
-    ok(offscreen == 0xdeadbeef, "Offscreen is %x.\n", offscreen);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
+    ok(offscreen == 0xdeadbeef, "Offscreen is %lx.\n", offscreen);
 
     /* NULL transform data and NULL dwOffscreen.
      *
      * Valid transform data + NULL dwOffscreen -> crash. */
     hr = IDirect3DViewport_TransformVertices(viewport, 1,
             NULL, D3DTRANSFORM_UNCLIPPED, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
 
     /* No vertices. */
     hr = IDirect3DViewport_TransformVertices(viewport, 0,
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     hr = IDirect3DViewport_TransformVertices(viewport, 0,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == ~0U, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == ~0U, "Offscreen is %lx.\n", offscreen);
 
     /* Invalid sizes. */
     offscreen = 0xdeadbeef;
     transformdata.dwSize = sizeof(transformdata) - 1;
     hr = IDirect3DViewport_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
-    ok(offscreen == 0xdeadbeef, "Offscreen is %x.\n", offscreen);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
+    ok(offscreen == 0xdeadbeef, "Offscreen is %lx.\n", offscreen);
     transformdata.dwSize = sizeof(transformdata) + 1;
     hr = IDirect3DViewport_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
-    ok(offscreen == 0xdeadbeef, "Offscreen is %x.\n", offscreen);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
+    ok(offscreen == 0xdeadbeef, "Offscreen is %lx.\n", offscreen);
 
     /* NULL lpIn or lpOut -> crash, except when transforming 0 vertices. */
     transformdata.dwSize = sizeof(transformdata);
@@ -11478,8 +11478,8 @@ static void test_transform_vertices(void)
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport_TransformVertices(viewport, 0,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == ~0U, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == ~0U, "Offscreen is %lx.\n", offscreen);
 
     /* Test how vertices are transformed by execute buffers. */
     vp_data.dwX = 20;
@@ -11491,15 +11491,15 @@ static void test_transform_vertices(void)
     vp_data.dvMinZ = 0.0f;
     vp_data.dvMaxZ = 1.0f;
     hr = IDirect3DViewport_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
 
     background = create_diffuse_material(device, 0.0f, 0.0f, 1.0f, 0.0f);
     viewport_set_background(device, viewport, background);
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#lx.\n", hr);
     memcpy(exec_desc.lpData, quad, sizeof(quad));
     ptr = ((BYTE *)exec_desc.lpData) + sizeof(quad);
     emit_process_vertices(&ptr, D3DPROCESSVERTICES_TRANSFORM, 0, 4);
@@ -11507,33 +11507,33 @@ static void test_transform_vertices(void)
     emit_end(&ptr);
     inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData;
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#lx.\n", hr);
 
     set_execute_data(execute_buffer, 4, sizeof(quad), inst_length);
     hr = IDirect3DDevice_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 128, 143);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 132, 143);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 128, 147);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 132, 147);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 177, 217);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 181, 217);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 177, 221);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 181, 221);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirect3DDevice_DeleteMatrix(device, world_handle);
     IDirect3DDevice_DeleteMatrix(device, view_handle);
@@ -11544,7 +11544,7 @@ static void test_transform_vertices(void)
     destroy_viewport(device, viewport);
     IDirect3DMaterial_Release(background);
     refcount = IDirect3DDevice_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirectDraw_Release(ddraw);
     DestroyWindow(window);
 }
@@ -11567,14 +11567,14 @@ static void test_display_mode_surface_pixel_format(void)
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw_GetDisplayMode(ddraw, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#lx.\n", hr);
     width = surface_desc.dwWidth;
     height = surface_desc.dwHeight;
 
     window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
             0, 0, width, height, NULL, NULL, NULL, NULL);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     bpp = 0;
     if (SUCCEEDED(IDirectDraw_SetDisplayMode(ddraw, width, height, 16)))
@@ -11587,10 +11587,10 @@ static void test_display_mode_surface_pixel_format(void)
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw_GetDisplayMode(ddraw, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == width, "Got width %u, expected %u.\n", surface_desc.dwWidth, width);
-    ok(surface_desc.dwHeight == height, "Got height %u, expected %u.\n", surface_desc.dwHeight, height);
-    ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == width, "Got width %lu, expected %u.\n", surface_desc.dwWidth, width);
+    ok(surface_desc.dwHeight == height, "Got height %lu, expected %u.\n", surface_desc.dwHeight, height);
+    ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %lu, expected %u.\n",
             U1(surface_desc.ddpfPixelFormat).dwRGBBitCount, bpp);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -11599,14 +11599,14 @@ static void test_display_mode_surface_pixel_format(void)
     surface_desc.dwBackBufferCount = 1;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == width, "Got width %u, expected %u.\n", surface_desc.dwWidth, width);
-    ok(surface_desc.dwHeight == height, "Got height %u, expected %u.\n", surface_desc.dwHeight, height);
-    ok(surface_desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#x.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == width, "Got width %lu, expected %u.\n", surface_desc.dwWidth, width);
+    ok(surface_desc.dwHeight == height, "Got height %lu, expected %u.\n", surface_desc.dwHeight, height);
+    ok(surface_desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#lx.\n",
             surface_desc.ddpfPixelFormat.dwFlags);
-    ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
+    ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %lu, expected %u.\n",
             U1(surface_desc.ddpfPixelFormat).dwRGBBitCount, bpp);
     IDirectDrawSurface_Release(surface);
 
@@ -11617,17 +11617,17 @@ static void test_display_mode_surface_pixel_format(void)
     surface_desc.dwHeight = height;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#x.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#lx.\n",
             surface_desc.ddpfPixelFormat.dwFlags);
-    ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
+    ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %lu, expected %u.\n",
             U1(surface_desc.ddpfPixelFormat).dwRGBBitCount, bpp);
     IDirectDrawSurface_Release(surface);
 
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -11684,7 +11684,7 @@ static void test_surface_desc_size(void)
         return;
     }
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(surface_caps); ++i)
     {
@@ -11700,7 +11700,7 @@ static void test_surface_desc_size(void)
             continue;
         }
         hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void **)&surface7);
-        ok(hr == DD_OK, "Failed to query IDirectDrawSurface7, hr %#x, type %s.\n", hr, surface_caps[i].name);
+        ok(hr == DD_OK, "Failed to query IDirectDrawSurface7, hr %#lx, type %s.\n", hr, surface_caps[i].name);
 
         /* GetSurfaceDesc() */
         for (j = 0; j < ARRAY_SIZE(desc_sizes); ++j)
@@ -11709,14 +11709,14 @@ static void test_surface_desc_size(void)
             desc.dwSize = desc_sizes[j];
             expected_hr = desc.dwSize == sizeof(DDSURFACEDESC) ? DD_OK : DDERR_INVALIDPARAMS;
             hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc.desc1);
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
 
             memset(&desc, 0, sizeof(desc));
             desc.dwSize = desc_sizes[j];
             expected_hr = desc.dwSize == sizeof(DDSURFACEDESC2) ? DD_OK : DDERR_INVALIDPARAMS;
             hr = IDirectDrawSurface7_GetSurfaceDesc(surface7, &desc.desc2);
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
         }
 
@@ -11733,22 +11733,22 @@ static void test_surface_desc_size(void)
             desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
             hr = IDirectDrawSurface_Lock(surface, NULL, &desc.desc1, 0, 0);
             expected_hr = valid_size ? DD_OK : DDERR_INVALIDPARAMS;
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
-            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
+            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %lu, type %s.\n",
                     desc_sizes[j], desc.dwSize, surface_caps[i].name);
             ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
                     desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
             if (SUCCEEDED(hr))
             {
-                ok(desc.desc1.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
+                ok(desc.desc1.dwWidth == 128, "Got unexpected width %lu, dwSize %u, type %s.\n",
                         desc.desc1.dwWidth, desc_sizes[j], surface_caps[i].name);
-                ok(desc.desc1.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
+                ok(desc.desc1.dwHeight == 128, "Got unexpected height %lu, dwSize %u, type %s.\n",
                         desc.desc1.dwHeight, desc_sizes[j], surface_caps[i].name);
                 expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
                 todo_wine_if(!expected_texture_stage)
                 ok(desc.desc2.dwTextureStage == expected_texture_stage,
-                        "Got unexpected texture stage %#x, dwSize %u, type %s.\n",
+                        "Got unexpected texture stage %#lx, dwSize %u, type %s.\n",
                         desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
                 IDirectDrawSurface_Unlock(surface, NULL);
             }
@@ -11759,21 +11759,21 @@ static void test_surface_desc_size(void)
             desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
             hr = IDirectDrawSurface7_Lock(surface7, NULL, &desc.desc2, 0, 0);
             expected_hr = valid_size ? DD_OK : DDERR_INVALIDPARAMS;
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
-            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
+            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %lu, type %s.\n",
                     desc_sizes[j], desc.dwSize, surface_caps[i].name);
             ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
                     desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
             if (SUCCEEDED(hr))
             {
-                ok(desc.desc2.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
+                ok(desc.desc2.dwWidth == 128, "Got unexpected width %lu, dwSize %u, type %s.\n",
                         desc.desc2.dwWidth, desc_sizes[j], surface_caps[i].name);
-                ok(desc.desc2.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
+                ok(desc.desc2.dwHeight == 128, "Got unexpected height %lu, dwSize %u, type %s.\n",
                         desc.desc2.dwHeight, desc_sizes[j], surface_caps[i].name);
                 expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
                 ok(desc.desc2.dwTextureStage == expected_texture_stage,
-                        "Got unexpected texture stage %#x, dwSize %u, type %s.\n",
+                        "Got unexpected texture stage %#lx, dwSize %u, type %s.\n",
                         desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
                 IDirectDrawSurface7_Unlock(surface7, NULL);
             }
@@ -11791,17 +11791,17 @@ static void test_surface_desc_size(void)
         expected_hr = (desc.dwSize == sizeof(DDSURFACEDESC) || desc.dwSize == sizeof(DDSURFACEDESC2))
                 ? DD_OK : DDERR_INVALIDPARAMS;
         hr = IDirectDraw_GetDisplayMode(ddraw, &desc.desc1);
-        ok(hr == expected_hr, "Got hr %#x, expected %#x, size %u.\n", hr, expected_hr, desc_sizes[j]);
+        ok(hr == expected_hr, "Got hr %#lx, expected %#lx, size %u.\n", hr, expected_hr, desc_sizes[j]);
         if (SUCCEEDED(hr))
         {
-            ok(desc.dwSize == sizeof(DDSURFACEDESC), "Wrong size %u for %u.\n", desc.dwSize, desc_sizes[j]);
+            ok(desc.dwSize == sizeof(DDSURFACEDESC), "Wrong size %lu for %u.\n", desc.dwSize, desc_sizes[j]);
             ok(desc.blob[desc_sizes[j]] == 0xcc, "Overflow for size %u.\n", desc_sizes[j]);
             ok(desc.blob[desc_sizes[j] - 1] != 0xcc, "Struct not cleared for size %u.\n", desc_sizes[j]);
         }
     }
 
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
 }
 
 static void test_texture_load(void)
@@ -11845,7 +11845,7 @@ static void test_texture_load(void)
     }
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     background = create_diffuse_material(device, 1.0f, 1.0f, 1.0f, 1.0f);
     viewport = create_viewport(device, 0, 0, 640, 480);
@@ -11857,7 +11857,7 @@ static void test_texture_load(void)
     exec_desc.dwBufferSize = 1024;
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -11873,29 +11873,29 @@ static void test_texture_load(void)
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff;
 
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(src_surface, &IID_IDirect3DTexture, (void **)&texture);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirect3DTexture_GetHandle(texture, device, &src_texture_handle);
-    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#lx.\n", hr);
     IDirect3DTexture_Release(texture);
 
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &dst_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(dst_surface, &IID_IDirect3DTexture, (void **)&texture);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirect3DTexture_GetHandle(texture, device, &dst_texture_handle);
-    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#lx.\n", hr);
     IDirect3DTexture_Release(texture);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 0x0000ffff;
     hr = IDirectDrawSurface_Blt(src_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#lx.\n", hr);
 
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#lx.\n", hr);
     memcpy(exec_desc.lpData, tquad, sizeof(tquad));
     ptr = (BYTE *)exec_desc.lpData + sizeof(tquad);
     emit_process_vertices(&ptr, D3DPROCESSVERTICES_COPY, 0, 4);
@@ -11907,41 +11907,41 @@ static void test_texture_load(void)
     emit_end(&ptr);
     inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData - sizeof(tquad);
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", color);
     set_execute_data(execute_buffer, 4, sizeof(tquad), inst_length);
     hr = IDirect3DDevice_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x0000ffff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ffff, 1), "Got unexpected color 0x%08lx.\n", color);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 0x000000ff;
     hr = IDirectDrawSurface_Blt(src_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", color);
     set_execute_data(execute_buffer, 4, sizeof(tquad), inst_length);
     hr = IDirect3DDevice_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface_Release(dst_surface);
     IDirectDrawSurface_Release(src_surface);
@@ -11951,7 +11951,7 @@ static void test_texture_load(void)
     destroy_viewport(device, viewport);
     IDirect3DDevice_Release(device);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -11973,7 +11973,7 @@ static void test_ck_operation(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -11987,16 +11987,16 @@ static void test_ck_operation(void)
     U3(surface_desc.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     surface_desc.dwFlags |= DDSD_CKSRCBLT;
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00ff00ff;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00ff00ff;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &src, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(src, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ok(!(surface_desc.dwFlags & DDSD_LPSURFACE), "Surface desc has LPSURFACE Flags set.\n");
     color = surface_desc.lpSurface;
     color[0] = 0x77010203;
@@ -12004,33 +12004,33 @@ static void test_ck_operation(void)
     color[2] = 0x77ff00ff;
     color[3] = 0x00ff00ff;
     hr = IDirectDrawSurface_Unlock(src, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     for (i = 0; i < 2; ++i)
     {
         hr = IDirectDrawSurface_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         color = surface_desc.lpSurface;
         color[0] = 0xcccccccc;
         color[1] = 0xcccccccc;
         color[2] = 0xcccccccc;
         color[3] = 0xcccccccc;
         hr = IDirectDrawSurface_Unlock(dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         if (i)
         {
             hr = IDirectDrawSurface_BltFast(dst, 0, 0, src, NULL, DDBLTFAST_SRCCOLORKEY);
-            ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
         }
         else
         {
             hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC, NULL);
-            ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
         }
 
         hr = IDirectDrawSurface_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT | DDLOCK_READONLY, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         ok(!(surface_desc.dwFlags & DDSD_LPSURFACE), "Surface desc has LPSURFACE Flags set.\n");
         color = surface_desc.lpSurface;
         /* Different behavior on some drivers / windows versions. Some versions ignore the X channel when
@@ -12045,69 +12045,69 @@ static void test_ck_operation(void)
                 && color[2] == 0xcccccccc && color[3] == 0xcccccccc) /* Nvidia */
                 || broken(color[0] == 0xff010203 && color[1] == 0xff010203
                 && color[2] == 0xcccccccc && color[3] == 0xcccccccc) /* Testbot */,
-                "Destination data after blitting is %08x %08x %08x %08x, i=%u.\n",
+                "Destination data after blitting is %08lx %08lx %08lx %08lx, i=%u.\n",
                 color[0], color[1], color[2], color[3], i);
         hr = IDirectDrawSurface_Unlock(dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
     }
 
     hr = IDirectDrawSurface_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x00ff00ff && ckey.dwColorSpaceHighValue == 0x00ff00ff,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x0000ff00 && ckey.dwColorSpaceHighValue == 0x0000ff00,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface_GetSurfaceDesc(src, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue == 0x0000ff00
             && surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue == 0x0000ff00,
-            "Got unexpected color key low=%08x high=%08x.\n", surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue,
+            "Got unexpected color key low=%08lx high=%08lx.\n", surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue,
             surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue);
 
     /* Test SetColorKey with dwColorSpaceHighValue < dwColorSpaceLowValue */
     ckey.dwColorSpaceLowValue = 0x000000ff;
     ckey.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDrawSurface_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x000000ff && ckey.dwColorSpaceHighValue == 0x000000ff,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     ckey.dwColorSpaceLowValue = 0x000000ff;
     ckey.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDrawSurface_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x000000ff && ckey.dwColorSpaceHighValue == 0x000000ff,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     ckey.dwColorSpaceLowValue = 0x000000fe;
     ckey.dwColorSpaceHighValue = 0x000000fd;
     hr = IDirectDrawSurface_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x000000fe && ckey.dwColorSpaceHighValue == 0x000000fe,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     IDirectDrawSurface_Release(src);
     IDirectDrawSurface_Release(dst);
@@ -12127,18 +12127,18 @@ static void test_ck_operation(void)
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(surface_desc.ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &src, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = 0x0000ff00;
     ckey.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface_SetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     ckey.dwColorSpaceLowValue = 0x00ff0000;
     ckey.dwColorSpaceHighValue = 0x00ff0000;
     hr = IDirectDrawSurface_SetColorKey(dst, DDCKEY_DESTBLT, &ckey);
-    ok(SUCCEEDED(hr) || hr == DDERR_NOCOLORKEYHW, "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || hr == DDERR_NOCOLORKEYHW, "Failed to set color key, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
         /* Nvidia reject dest keys, AMD allows them. This applies to vidmem and sysmem surfaces. */
@@ -12149,11 +12149,11 @@ static void test_ck_operation(void)
     ckey.dwColorSpaceLowValue = 0x000000ff;
     ckey.dwColorSpaceHighValue = 0x000000ff;
     hr = IDirectDrawSurface_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     ckey.dwColorSpaceLowValue = 0x000000aa;
     ckey.dwColorSpaceHighValue = 0x000000aa;
     hr = IDirectDrawSurface_SetColorKey(src, DDCKEY_DESTBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
@@ -12163,7 +12163,7 @@ static void test_ck_operation(void)
     fx.ddckDestColorkey.dwColorSpaceLowValue = 0x00001100;
 
     hr = IDirectDrawSurface_Lock(src, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     color[0] = 0x000000ff; /* Applies to src blt key in src surface. */
     color[1] = 0x000000aa; /* Applies to dst blt key in src surface. */
@@ -12172,77 +12172,77 @@ static void test_ck_operation(void)
     color[4] = 0x00001100; /* Src color key in ddbltfx. */
     color[5] = 0x00110000; /* Dst color key in ddbltfx. */
     hr = IDirectDrawSurface_Unlock(src, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0x55555555;
     hr = IDirectDrawSurface_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Test a blit without keying. */
     hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, 0, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Should have copied src data unmodified to dst. */
     ok(color[0] == 0x000000ff && color[1] == 0x000000aa && color[2] == 0x00ff0000 &&
             color[3] == 0x0000ff00 && color[4] == 0x00001100 && color[5] == 0x00110000,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0x55555555;
     hr = IDirectDrawSurface_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Src key. */
     hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Src key applied to color[0]. It is unmodified, the others are copied. */
     ok(color[0] == 0x55555555 && color[1] == 0x000000aa && color[2] == 0x00ff0000 &&
             color[3] == 0x0000ff00 && color[4] == 0x00001100 && color[5] == 0x00110000,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0x55555555;
     hr = IDirectDrawSurface_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Src override. */
     hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_KEYSRCOVERRIDE, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Override key applied to color[5]. It is unmodified, the others are copied. */
     ok(color[0] == 0x000000ff && color[1] == 0x000000aa && color[2] == 0x00ff0000 &&
             color[3] == 0x0000ff00 && color[4] == 0x00001100 && color[5] == 0x55555555,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0x55555555;
     hr = IDirectDrawSurface_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Src override AND src key. That is not supposed to work. */
     hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC | DDBLT_KEYSRCOVERRIDE, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Ensure the destination was not changed. */
     ok(color[0] == 0x55555555 && color[1] == 0x55555555 && color[2] == 0x55555555 &&
             color[3] == 0x55555555 && color[4] == 0x55555555 && color[5] == 0x55555555,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     /* Use different dst colors for the dst key test. */
@@ -12253,18 +12253,18 @@ static void test_ck_operation(void)
     color[4] = 0x000000aa; /* Dest key in src surface. */
     color[5] = 0x000000aa; /* Dest key in src surface. */
     hr = IDirectDrawSurface_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Dst key applied to color[4,5], they are the only changed pixels. */
     ok(color[0] == 0x00ff0000 && color[1] == 0x00ff0000 && color[2] == 0x00001100 &&
             color[3] == 0x00001100 && color[4] == 0x00001100 && color[5] == 0x00110000,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = 0x00ff0000; /* Dest key in dst surface. */
@@ -12274,28 +12274,28 @@ static void test_ck_operation(void)
     color[4] = 0x000000aa; /* Dest key in src surface. */
     color[5] = 0x000000aa; /* Dest key in src surface. */
     hr = IDirectDrawSurface_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* What happens with a QI'd newer version of the interface? It takes the key
      * from the destination surface. */
     hr = IDirectDrawSurface_QueryInterface(src, &IID_IDirectDrawSurface7, (void **)&src7);
-    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(dst, &IID_IDirectDrawSurface7, (void **)&dst7);
-    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Blt(dst7, NULL, src7, NULL, DDBLT_KEYDEST, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(dst7);
     IDirectDrawSurface7_Release(src7);
 
     hr = IDirectDrawSurface_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Dst key applied to color[0,1], they are the only changed pixels. */
     todo_wine ok(color[0] == 0x000000ff && color[1] == 0x000000aa && color[2] == 0x00001100 &&
             color[3] == 0x00001100 && color[4] == 0x000000aa && color[5] == 0x000000aa,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = 0x00ff0000; /* Dest key in dst surface. */
@@ -12305,19 +12305,19 @@ static void test_ck_operation(void)
     color[4] = 0x000000aa; /* Dest key in src surface. */
     color[5] = 0x000000aa; /* Dest key in src surface. */
     hr = IDirectDrawSurface_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Dest override key blit. */
     hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_KEYDESTOVERRIDE, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Dst key applied to color[2,3], they are the only changed pixels. */
     ok(color[0] == 0x00ff0000 && color[1] == 0x00ff0000 && color[2] == 0x00ff0000 &&
             color[3] == 0x0000ff00 && color[4] == 0x000000aa && color[5] == 0x000000aa,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = 0x00ff0000; /* Dest key in dst surface. */
@@ -12327,38 +12327,38 @@ static void test_ck_operation(void)
     color[4] = 0x000000aa; /* Dest key in src surface. */
     color[5] = 0x000000aa; /* Dest key in src surface. */
     hr = IDirectDrawSurface_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Dest override together with surface key. Supposed to fail. */
     hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST | DDBLT_KEYDESTOVERRIDE, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Destination is unchanged. */
     ok(color[0] == 0x00ff0000 && color[1] == 0x00ff0000 && color[2] == 0x00001100 &&
             color[3] == 0x00001100 && color[4] == 0x000000aa && color[5] == 0x000000aa,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
     hr = IDirectDrawSurface_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Source and destination key. This is driver dependent. New HW treats it like
      * DDBLT_KEYSRC. Older HW and some software renderers apply both keys. */
     if (0)
     {
         hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST | DDBLT_KEYSRC, &fx);
-        ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
         hr = IDirectDrawSurface_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         color = surface_desc.lpSurface;
         /* Color[0] is filtered by the src key, 2-5 are filtered by the dst key, if
          * the driver applies it. */
         ok(color[0] == 0x00ff0000 && color[1] == 0x000000aa && color[2] == 0x00ff0000 &&
                 color[3] == 0x0000ff00 && color[4] == 0x00001100 && color[5] == 0x00110000,
-                "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+                "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
                 color[0], color[1], color[2], color[3], color[4], color[5]);
 
         color[0] = 0x00ff0000; /* Dest key in dst surface. */
@@ -12368,70 +12368,70 @@ static void test_ck_operation(void)
         color[4] = 0x000000aa; /* Dest key in src surface. */
         color[5] = 0x000000aa; /* Dest key in src surface. */
         hr = IDirectDrawSurface_Unlock(dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
     }
 
     /* Override keys without ddbltfx parameter fail */
     hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_KEYDESTOVERRIDE, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_KEYSRCOVERRIDE, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Try blitting without keys in the source surface. */
     hr = IDirectDrawSurface_SetColorKey(src, DDCKEY_SRCBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_SetColorKey(src, DDCKEY_DESTBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     /* That fails now. Do not bother to check that the data is unmodified. */
     hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Surprisingly this still works. It uses the old key from the src surface. */
     hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Dst key applied to color[4,5], they are the only changed pixels. */
     ok(color[0] == 0x00ff0000 && color[1] == 0x00ff0000 && color[2] == 0x00001100 &&
             color[3] == 0x00001100 && color[4] == 0x00001100 && color[5] == 0x00110000,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
     hr = IDirectDrawSurface_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* This returns DDERR_NOCOLORKEY as expected. */
     hr = IDirectDrawSurface_GetColorKey(src, DDCKEY_DESTBLT, &ckey);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
 
     /* GetSurfaceDesc returns a zeroed key as expected. */
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x12345678;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x12345678;
     hr = IDirectDrawSurface_GetSurfaceDesc(src, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue
             && !surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue,
-            "Got unexpected color key low=%08x high=%08x.\n", surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue,
+            "Got unexpected color key low=%08lx high=%08lx.\n", surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue,
             surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue);
 
     /* Try blitting without keys in the destination surface. */
     hr = IDirectDrawSurface_SetColorKey(dst, DDCKEY_SRCBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_SetColorKey(dst, DDCKEY_DESTBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     /* This is weird. It makes sense in v4 and v7, but because v1
      * uses the key from the src surface it makes no sense here. */
     hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
 done:
     IDirectDrawSurface_Release(src);
     IDirectDrawSurface_Release(dst);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -12487,7 +12487,7 @@ static void test_depth_readback(void)
     }
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     z_depth = get_device_z_depth(device);
     z_mask = 0xffffffff >> (32 - z_depth);
     ds = get_depth_stencil(device);
@@ -12505,10 +12505,10 @@ static void test_depth_readback(void)
     exec_desc.dwBufferSize = 1024;
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#lx.\n", hr);
 
     memcpy(exec_desc.lpData, quad, sizeof(quad));
     ptr = (BYTE *)exec_desc.lpData + sizeof(quad);
@@ -12519,22 +12519,22 @@ static void test_depth_readback(void)
     inst_length = ((BYTE *)ptr - sizeof(quad)) - (BYTE *)exec_desc.lpData;
 
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     set_execute_data(execute_buffer, 4, sizeof(quad), inst_length);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_UNCLIPPED);
-    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_Lock(ds, NULL, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
 
     for (y = 60; y < 480; y += 120)
     {
@@ -12547,13 +12547,13 @@ static void test_depth_readback(void)
             expected_depth = (x * (0.9 / 640.0) + y * (0.1 / 480.0)) * z_mask;
             max_diff = ((0.5f * 0.9f) / 640.0f) * z_mask;
             ok(compare_uint(expected_depth, depth, max_diff),
-                    "z_depth %u: Got depth 0x%08x (diff %d), expected 0x%08x+/-%u, at %u, %u.\n",
+                    "z_depth %lu: Got depth 0x%08lx (diff %ld), expected 0x%08lx+/-%lu, at %u, %u.\n",
                     z_depth, depth, expected_depth - depth, expected_depth, max_diff, x, y);
         }
     }
 
     hr = IDirectDrawSurface_Unlock(ds, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     IDirect3DExecuteBuffer_Release(execute_buffer);
     destroy_viewport(device, viewport);
@@ -12561,7 +12561,7 @@ static void test_depth_readback(void)
     IDirectDrawSurface_Release(ds);
     IDirect3DDevice_Release(device);
     refcount = IDirectDrawSurface_Release(rt);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirectDraw_Release(ddraw);
     DestroyWindow(window);
 }
@@ -12591,7 +12591,7 @@ static void test_clear(void)
         return;
     }
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
 
@@ -12602,7 +12602,7 @@ static void test_clear(void)
 
     viewport_set_background(device, viewport, white);
     hr = IDirect3DViewport_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     /* Positive x, negative y. */
     U1(rect[0]).x1 = 0;
@@ -12620,20 +12620,20 @@ static void test_clear(void)
      * refuse negative rectangles, but it will not clear them either. */
     viewport_set_background(device, viewport, red);
     hr = IDirect3DViewport_Clear(viewport, 2, rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 360);
-    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3 (pos, neg) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3 (pos, neg) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 160, 120);
-    ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1 (pos, pos) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1 (pos, pos) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 360);
-    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4 (NULL) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4 (NULL) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 120);
-    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4 (neg, neg) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4 (neg, neg) has color 0x%08lx.\n", color);
 
     viewport_set_background(device, viewport, white);
     hr = IDirect3DViewport_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     /* negative x, negative y.
      * Also ignored, except on WARP, which clears the entire screen. */
@@ -12643,34 +12643,34 @@ static void test_clear(void)
     U4(rect_negneg).y2 = 0;
     viewport_set_background(device, viewport, green);
     hr = IDirect3DViewport_Clear(viewport, 1, &rect_negneg, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 360);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 160, 120);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 360);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 120);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
 
     /* Test how the viewport affects clears. */
     viewport_set_background(device, viewport, white);
     hr = IDirect3DViewport_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     viewport2 = create_viewport(device, 160, 120, 160, 120);
     viewport_set_background(device, viewport2, blue);
     hr = IDirect3DViewport_Clear(viewport2, 1, &rect_full, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     viewport3 = create_viewport(device, 320, 240, 320, 240);
     viewport_set_background(device, viewport3, green);
@@ -12680,7 +12680,7 @@ static void test_clear(void)
     U3(rect[0]).x2 = 480;
     U4(rect[0]).y2 = 360;
     hr = IDirect3DViewport_Clear(viewport3, 1, &rect[0], D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     /* AMD drivers do not limit the clear area to the viewport rectangle in
      * d3d1. It works as intended on other drivers and on d3d2 and newer on
@@ -12688,96 +12688,96 @@ static void test_clear(void)
     color = get_surface_color(rt, 158, 118);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_amd(ddraw) && compare_color(color, 0x000000ff, 0)),
-            "(158, 118) has color 0x%08x.\n", color);
+            "(158, 118) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 162, 118);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_amd(ddraw) && compare_color(color, 0x000000ff, 0)),
-            "(162, 118) has color 0x%08x.\n", color);
+            "(162, 118) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 158, 122);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_amd(ddraw) && compare_color(color, 0x000000ff, 0)),
-            "(158, 122) has color 0x%08x.\n", color);
+            "(158, 122) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 162, 122);
     ok(compare_color(color, 0x000000ff, 0)
             || broken(ddraw_is_amd(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "(162, 122) has color 0x%08x.\n", color);
+            "(162, 122) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 318, 238);
     ok(compare_color(color, 0x000000ff, 0)
             || broken(ddraw_is_amd(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "(318, 238) has color 0x%08x.\n", color);
+            "(318, 238) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 322, 238);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_amd(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "(322, 328) has color 0x%08x.\n", color);
+            "(322, 328) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 318, 242);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_amd(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "(318, 242) has color 0x%08x.\n", color);
+            "(318, 242) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 322, 242);
-    ok(compare_color(color, 0x0000ff00, 0), "(322, 242) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(322, 242) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 478, 358);
-    ok(compare_color(color, 0x0000ff00, 0), "(478, 358) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(478, 358) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 482, 358);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_amd(ddraw) && compare_color(color, 0x000000ff, 0)),
-            "(482, 358) has color 0x%08x.\n", color);
+            "(482, 358) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 478, 362);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_amd(ddraw) && compare_color(color, 0x000000ff, 0)),
-            "(478, 362) has color 0x%08x.\n", color);
+            "(478, 362) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 482, 362);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_amd(ddraw) && compare_color(color, 0x000000ff, 0)),
-            "(482, 362) has color 0x%08x.\n", color);
+            "(482, 362) has color 0x%08lx.\n", color);
 
     /* The clear rectangle is rendertarget absolute, not relative to the
      * viewport. */
     hr = IDirect3DViewport_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     U1(rect[0]).x1 = 330;
     U2(rect[0]).y1 = 250;
     U3(rect[0]).x2 = 340;
     U4(rect[0]).y2 = 260;
     hr = IDirect3DViewport_Clear(viewport3, 1, &rect[0], D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 328, 248);
-    ok(compare_color(color, 0x00ffffff, 0), "(328, 248) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(328, 248) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 332, 248);
-    ok(compare_color(color, 0x00ffffff, 0), "(332, 248) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(332, 248) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 328, 252);
-    ok(compare_color(color, 0x00ffffff, 0), "(328, 252) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(328, 252) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 332, 252);
-    ok(compare_color(color, 0x0000ff00, 0), "(332, 252) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(332, 252) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 338, 248);
-    ok(compare_color(color, 0x00ffffff, 0), "(338, 248) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(338, 248) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 342, 248);
-    ok(compare_color(color, 0x00ffffff, 0), "(342, 248) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(342, 248) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 338, 252);
-    ok(compare_color(color, 0x0000ff00, 0), "(338, 252) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(338, 252) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 342, 252);
-    ok(compare_color(color, 0x00ffffff, 0), "(342, 252) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(342, 252) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 328, 258);
-    ok(compare_color(color, 0x00ffffff, 0), "(328, 258) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(328, 258) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 332, 258);
-    ok(compare_color(color, 0x0000ff00, 0), "(332, 258) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(332, 258) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 328, 262);
-    ok(compare_color(color, 0x00ffffff, 0), "(328, 262) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(328, 262) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 332, 262);
-    ok(compare_color(color, 0x00ffffff, 0), "(332, 262) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(332, 262) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 338, 258);
-    ok(compare_color(color, 0x0000ff00, 0), "(338, 258) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(338, 258) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 342, 258);
-    ok(compare_color(color, 0x00ffffff, 0), "(342, 258) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(342, 258) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 338, 262);
-    ok(compare_color(color, 0x00ffffff, 0), "(338, 262) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(338, 262) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 342, 262);
-    ok(compare_color(color, 0x00ffffff, 0), "(342, 262) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(342, 262) has color 0x%08lx.\n", color);
 
     /* COLORWRITEENABLE, SRGBWRITEENABLE and scissor rectangles do not exist
      * in d3d1. */
@@ -12791,9 +12791,9 @@ static void test_clear(void)
     IDirect3DMaterial_Release(blue);
     IDirectDrawSurface_Release(rt);
     refcount = IDirect3DDevice_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Ddraw object has %u references left.\n", refcount);
+    ok(!refcount, "Ddraw object has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -12851,12 +12851,12 @@ static HRESULT WINAPI enum_surfaces_create_cb(IDirectDrawSurface *surface, DDSUR
     struct enum_surfaces_param *param = context;
 
     ok(!surface, "Unexpected surface %p.\n", surface);
-    ok((desc->dwFlags & expect_flags) == expect_flags, "Got unexpected flags %#x.\n", desc->dwFlags);
+    ok((desc->dwFlags & expect_flags) == expect_flags, "Got unexpected flags %#lx.\n", desc->dwFlags);
     if (param->count < ARRAY_SIZE(param->modes))
     {
         const DDSURFACEDESC *expect = &param->modes[param->count];
-        ok(desc->dwWidth == expect->dwWidth, "Expected width %u, got %u.\n", expect->dwWidth, desc->dwWidth);
-        ok(desc->dwHeight == expect->dwHeight, "Expected height %u, got %u.\n", expect->dwHeight, desc->dwHeight);
+        ok(desc->dwWidth == expect->dwWidth, "Expected width %lu, got %lu.\n", expect->dwWidth, desc->dwWidth);
+        ok(desc->dwHeight == expect->dwHeight, "Expected height %lu, got %lu.\n", expect->dwHeight, desc->dwHeight);
         ok(!memcmp(&U4(*desc).ddpfPixelFormat, &U4(*expect).ddpfPixelFormat, sizeof(U4(*desc).ddpfPixelFormat)),
                 "Pixel formats didn't match.\n");
     }
@@ -12881,18 +12881,18 @@ static void test_enum_surfaces(void)
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
     hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
-    ok(hr == DD_OK, "Failed to get display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to get display mode, hr %#lx.\n", hr);
     current_format = desc.ddpfPixelFormat;
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set cooperative level, hr %#lx.\n", hr);
 
     hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_ALL, NULL, NULL, enum_surfaces_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL,
             NULL, NULL, enum_surfaces_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
@@ -12902,52 +12902,52 @@ static void test_enum_surfaces(void)
     desc.dwWidth = 32;
     desc.dwHeight = 32;
     hr = IDirectDraw_CreateSurface(ddraw, &desc, &param.surfaces[0], NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_GetAttachedSurface(param.surfaces[0], &desc.ddsCaps, &param.surfaces[1]);
-    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetAttachedSurface(param.surfaces[1], &desc.ddsCaps, &param.surfaces[2]);
-    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetAttachedSurface(param.surfaces[2], &desc.ddsCaps, &param.surfaces[3]);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
 
     param.count = 0;
     hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
             &desc, &param, enum_surfaces_cb);
-    ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     param.count = 0;
     hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
             NULL, &param, enum_surfaces_cb);
-    ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
     param.count = 0;
     hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     param.count = 0;
     hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH,
             &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 2, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     desc.dwFlags = 0;
     param.count = 0;
     hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     desc.dwFlags = 0;
     param.count = 0;
     hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST, &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     IDirectDrawSurface_Release(param.surfaces[2]);
@@ -12957,7 +12957,7 @@ static void test_enum_surfaces(void)
     param.count = 0;
     hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
             NULL, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(!param.count, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     memset(&desc, 0, sizeof(desc));
@@ -12967,15 +12967,15 @@ static void test_enum_surfaces(void)
 
     hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#lx.\n", hr);
 
     hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_NOMATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#lx.\n", hr);
 
     hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#lx.\n", hr);
 
     /* When not passed width and height, the callback is called with every
      * available display resolution. */
@@ -12984,13 +12984,13 @@ static void test_enum_surfaces(void)
     desc.dwFlags |= DDSD_PIXELFORMAT;
     U4(desc).ddpfPixelFormat = current_format;
     hr = IDirectDraw_EnumDisplayModes(ddraw, 0, &desc, &param, build_mode_list_cb);
-    ok(hr == DD_OK, "Failed to build mode list, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to build mode list, hr %#lx.\n", hr);
 
     param.count = 0;
     desc.dwFlags &= ~DDSD_PIXELFORMAT;
     hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == param.mode_count, "Expected %u surfaces, got %u.\n", param.mode_count, param.count);
 
     desc.dwFlags |= DDSD_WIDTH | DDSD_HEIGHT;
@@ -13001,15 +13001,15 @@ static void test_enum_surfaces(void)
     param.count = 0;
     hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     hr = IDirectDraw_CreateSurface(ddraw, &desc, &param.surfaces[0], NULL);
-    ok(hr == DD_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to create surface, hr %#lx.\n", hr);
     param.count = 0;
     hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count);
     IDirectDrawSurface_Release(param.surfaces[0]);
 
@@ -13021,7 +13021,7 @@ static void test_enum_surfaces(void)
     param.count = 0;
     hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(!param.count, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     IDirectDraw_Release(ddraw);
@@ -13055,7 +13055,7 @@ static void test_execute_data(void)
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
 
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#lx.\n", hr);
 
     memset(&exec_data, 0, sizeof(exec_data));
 
@@ -13065,87 +13065,87 @@ static void test_execute_data(void)
     exec_data.dwInstructionOffset = 3 * sizeof(D3DVERTEX);
     exec_data.dwInstructionLength = 10;
     hr = IDirect3DExecuteBuffer_SetExecuteData(execute_buffer, &exec_data);
-    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#lx.\n", hr);
 
     /* dwSize is checked against the expected struct size. */
     exec_data.dwSize = sizeof(exec_data) - 1;
     hr = IDirect3DExecuteBuffer_SetExecuteData(execute_buffer, &exec_data);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     exec_data.dwSize = sizeof(exec_data) + 1;
     hr = IDirect3DExecuteBuffer_SetExecuteData(execute_buffer, &exec_data);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* The rest of the data is not checked for plausibility. */
     exec_data.dwSize = sizeof(exec_data);
     exec_data.dwVertexCount = 0;
     hr = IDirect3DExecuteBuffer_SetExecuteData(execute_buffer, &exec_data);
-    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#lx.\n", hr);
     exec_data.dwVertexCount = exec_desc.dwBufferSize / sizeof(D3DVERTEX) - 1;
     hr = IDirect3DExecuteBuffer_SetExecuteData(execute_buffer, &exec_data);
-    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#lx.\n", hr);
     exec_data.dwVertexCount = exec_desc.dwBufferSize / sizeof(D3DVERTEX);
     hr = IDirect3DExecuteBuffer_SetExecuteData(execute_buffer, &exec_data);
-    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#lx.\n", hr);
     exec_data.dwVertexCount = exec_desc.dwBufferSize / sizeof(D3DVERTEX) + 1;
     hr = IDirect3DExecuteBuffer_SetExecuteData(execute_buffer, &exec_data);
-    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#lx.\n", hr);
     exec_data.dwVertexCount = 999999;
     hr = IDirect3DExecuteBuffer_SetExecuteData(execute_buffer, &exec_data);
-    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#lx.\n", hr);
     exec_data.dwInstructionOffset = 999999 * sizeof(D3DVERTEX);
     hr = IDirect3DExecuteBuffer_SetExecuteData(execute_buffer, &exec_data);
-    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#lx.\n", hr);
     exec_data.dwInstructionLength = 10240;
     hr = IDirect3DExecuteBuffer_SetExecuteData(execute_buffer, &exec_data);
-    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set execute data, hr %#lx.\n", hr);
 
     /* The input structure is not modified. */
-    ok(exec_data.dwSize == sizeof(exec_data), "Got unexpected struct size %u\n",
+    ok(exec_data.dwSize == sizeof(exec_data), "Got unexpected struct size %lu\n",
             exec_data.dwSize);
-    ok(exec_data.dwVertexCount == 999999, "Got unexpected vertex count %u\n",
+    ok(exec_data.dwVertexCount == 999999, "Got unexpected vertex count %lu\n",
             exec_data.dwVertexCount);
-    ok(exec_data.dwInstructionOffset == 999999 * sizeof(D3DVERTEX), "Got unexpected instruction offset %u\n",
+    ok(exec_data.dwInstructionOffset == 999999 * sizeof(D3DVERTEX), "Got unexpected instruction offset %lu\n",
             exec_data.dwInstructionOffset);
-    ok(exec_data.dwInstructionLength == 10240, "Got unexpected instruction length %u\n",
+    ok(exec_data.dwInstructionLength == 10240, "Got unexpected instruction length %lu\n",
             exec_data.dwInstructionLength);
 
     /* No validation in GetExecuteData. */
     memset(&exec_data, 0, sizeof(exec_data));
     exec_desc.dwSize = sizeof(exec_desc);
     hr = IDirect3DExecuteBuffer_GetExecuteData(execute_buffer, &exec_data);
-    ok(SUCCEEDED(hr), "Failed to get execute data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get execute data, hr %#lx.\n", hr);
 
-    ok(exec_data.dwSize == sizeof(exec_data), "Got unexpected struct size %u\n",
+    ok(exec_data.dwSize == sizeof(exec_data), "Got unexpected struct size %lu\n",
             exec_data.dwSize);
-    ok(exec_data.dwVertexCount == 999999, "Got unexpected vertex count %u\n",
+    ok(exec_data.dwVertexCount == 999999, "Got unexpected vertex count %lu\n",
             exec_data.dwVertexCount);
-    ok(exec_data.dwInstructionOffset == 999999 * sizeof(D3DVERTEX), "Got unexpected instruction offset %u\n",
+    ok(exec_data.dwInstructionOffset == 999999 * sizeof(D3DVERTEX), "Got unexpected instruction offset %lu\n",
             exec_data.dwInstructionOffset);
-    ok(exec_data.dwInstructionLength == 10240, "Got unexpected instruction length %u\n",
+    ok(exec_data.dwInstructionLength == 10240, "Got unexpected instruction length %lu\n",
             exec_data.dwInstructionLength);
 
     memset(&exec_data, 0xaa, sizeof(exec_data));
     exec_desc.dwSize = sizeof(exec_desc) - 1;
     hr = IDirect3DExecuteBuffer_GetExecuteData(execute_buffer, &exec_data);
-    ok(SUCCEEDED(hr), "Failed to get execute data, hr %#x.\n", hr);
-    ok(exec_data.dwSize == sizeof(exec_data), "Got unexpected struct size %u\n",
+    ok(SUCCEEDED(hr), "Failed to get execute data, hr %#lx.\n", hr);
+    ok(exec_data.dwSize == sizeof(exec_data), "Got unexpected struct size %lu\n",
        exec_data.dwSize);
-    ok(exec_data.dwVertexCount == 999999, "Got unexpected vertex count %u\n",
+    ok(exec_data.dwVertexCount == 999999, "Got unexpected vertex count %lu\n",
        exec_data.dwVertexCount);
-    ok(exec_data.dwInstructionOffset == 999999 * sizeof(D3DVERTEX), "Got unexpected instruction offset %u\n",
+    ok(exec_data.dwInstructionOffset == 999999 * sizeof(D3DVERTEX), "Got unexpected instruction offset %lu\n",
        exec_data.dwInstructionOffset);
-    ok(exec_data.dwInstructionLength == 10240, "Got unexpected instruction length %u\n",
+    ok(exec_data.dwInstructionLength == 10240, "Got unexpected instruction length %lu\n",
        exec_data.dwInstructionLength);
 
     exec_desc.dwSize = 0;
     hr = IDirect3DExecuteBuffer_GetExecuteData(execute_buffer, &exec_data);
-    ok(SUCCEEDED(hr), "Failed to get execute data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get execute data, hr %#lx.\n", hr);
     exec_desc.dwSize = sizeof(exec_desc) + 1;
     hr = IDirect3DExecuteBuffer_GetExecuteData(execute_buffer, &exec_data);
-    ok(SUCCEEDED(hr), "Failed to get execute data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get execute data, hr %#lx.\n", hr);
     exec_desc.dwSize = ~0U;
     hr = IDirect3DExecuteBuffer_GetExecuteData(execute_buffer, &exec_data);
-    ok(SUCCEEDED(hr), "Failed to get execute data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get execute data, hr %#lx.\n", hr);
 
     IDirect3DExecuteBuffer_Release(execute_buffer);
     IDirect3DDevice_Release(device);
@@ -13215,25 +13215,25 @@ static void test_viewport(void)
     }
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#lx.\n", hr);
 
     black_background = create_diffuse_material(device, 0.0f, 0.0f, 0.0f, 0.0f);
 
     hr = IDirect3DDevice_CreateMatrix(device, &world_handle);
-    ok(SUCCEEDED(hr), "Creating a matrix object failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Creating a matrix object failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice_SetMatrix(device, world_handle, &mat);
-    ok(SUCCEEDED(hr), "Setting a matrix object failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Setting a matrix object failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice_CreateMatrix(device, &view_handle);
-    ok(SUCCEEDED(hr), "Creating a matrix object failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Creating a matrix object failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice_SetMatrix(device, view_handle, &mat);
-    ok(SUCCEEDED(hr), "Setting a matrix object failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Setting a matrix object failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice_CreateMatrix(device, &proj_handle);
-    ok(SUCCEEDED(hr), "Creating a matrix object failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Creating a matrix object failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice_SetMatrix(device, proj_handle, &mat);
-    ok(SUCCEEDED(hr), "Setting a matrix object failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Setting a matrix object failed, hr %#lx.\n", hr);
 
     memset(&exec_desc, 0, sizeof(exec_desc));
     exec_desc.dwSize = sizeof(exec_desc);
@@ -13242,10 +13242,10 @@ static void test_viewport(void)
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
 
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create execute buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#lx.\n", hr);
 
     memcpy(exec_desc.lpData, quad, sizeof(quad));
     ptr = ((BYTE *)exec_desc.lpData) + sizeof(quad);
@@ -13262,7 +13262,7 @@ static void test_viewport(void)
     inst_length -= sizeof(quad);
 
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#lx.\n", hr);
 
     full_viewport = create_viewport(device, 0, 0, 640, 480);
     viewport_set_background(device, full_viewport, black_background);
@@ -13276,10 +13276,10 @@ static void test_viewport(void)
         winetest_push_context(tests[j].message);
 
         hr = IDirect3DViewport_Clear(full_viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3D_CreateViewport(d3d, &viewport, NULL);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         memset(&vp, 0, sizeof(vp));
         vp.dwSize = sizeof(vp);
         vp.dwX = tests[j].vp.dwX;
@@ -13293,21 +13293,21 @@ static void test_viewport(void)
         vp.dvMinZ = 0.0f;
         vp.dvMaxZ = 1.0f;
         hr = IDirect3DViewport_SetViewport(viewport, &vp);
-        ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice_AddViewport(device, viewport);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DViewport_SetViewport(viewport, &vp);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice_BeginScene(device);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         set_execute_data(execute_buffer, 4, sizeof(quad), inst_length);
         hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice_EndScene(device);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         check_rect(rt, tests[j].expected_rect);
 
@@ -13325,7 +13325,7 @@ static void test_viewport(void)
     IDirect3DDevice_DeleteMatrix(device, proj_handle);
     destroy_material(black_background);
     refcount = IDirect3DDevice_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D2_Release(d3d);
     IDirectDraw_Release(ddraw);
     DestroyWindow(window);
@@ -13387,48 +13387,48 @@ static void test_find_device(void)
     result.dwSize = sizeof(result);
     search.dwSize = sizeof(search);
     hr = IDirect3D_FindDevice(d3d, NULL, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D_FindDevice(d3d, NULL, &result);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D_FindDevice(d3d, &search, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D_FindDevice(d3d, &search, &result);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(result.dwSize == sizeof(result), "Got unexpected result size %u.\n", result.dwSize);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(result.dwSize == sizeof(result), "Got unexpected result size %lu.\n", result.dwSize);
     ok(result.ddHwDesc.dwSize == sizeof(result_v1.hw_desc),
-            "Got unexpected HW desc size %u.\n", result.ddHwDesc.dwSize);
+            "Got unexpected HW desc size %lu.\n", result.ddHwDesc.dwSize);
     ok(result.ddSwDesc.dwSize == sizeof(result_v1.sw_desc),
-            "Got unexpected SW desc size %u.\n", result.ddSwDesc.dwSize);
+            "Got unexpected SW desc size %lu.\n", result.ddSwDesc.dwSize);
 
     memset(&search, 0, sizeof(search));
     memset(&result, 0, sizeof(result));
     hr = IDirect3D_FindDevice(d3d, &search, &result);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     search.dwSize = sizeof(search) + 1;
     result.dwSize = sizeof(result) + 1;
     hr = IDirect3D_FindDevice(d3d, &search, &result);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     search.dwSize = sizeof(search);
 
     memset(&result_v1, 0, sizeof(result_v1));
     result_v1.size = sizeof(result_v1);
     hr = IDirect3D_FindDevice(d3d, &search, (D3DFINDDEVICERESULT *)&result_v1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(result_v1.hw_desc.dwSize == sizeof(result_v1.hw_desc),
-            "Got unexpected HW desc size %u.\n", result_v1.hw_desc.dwSize);
+            "Got unexpected HW desc size %lu.\n", result_v1.hw_desc.dwSize);
     ok(result_v1.sw_desc.dwSize == sizeof(result_v1.sw_desc),
-            "Got unexpected SW desc size %u.\n", result_v1.sw_desc.dwSize);
+            "Got unexpected SW desc size %lu.\n", result_v1.sw_desc.dwSize);
 
     memset(&result_v2, 0, sizeof(result_v2));
     result_v2.size = sizeof(result_v2);
     hr = IDirect3D_FindDevice(d3d, &search, (D3DFINDDEVICERESULT *)&result_v2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(result_v2.hw_desc.dwSize == sizeof(result_v1.hw_desc),
-            "Got unexpected HW desc size %u.\n", result_v2.hw_desc.dwSize);
+            "Got unexpected HW desc size %lu.\n", result_v2.hw_desc.dwSize);
     ok(result_v2.sw_desc.dwSize == sizeof(result_v1.sw_desc),
-            "Got unexpected SW desc size %u.\n", result_v2.sw_desc.dwSize);
+            "Got unexpected SW desc size %lu.\n", result_v2.sw_desc.dwSize);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -13441,21 +13441,21 @@ static void test_find_device(void)
         result.dwSize = sizeof(result);
 
         hr = IDirect3D_FindDevice(d3d, &search, &result);
-        ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
-        ok(result.dwSize == sizeof(result), "Test %u: Got unexpected result size %u.\n", i, result.dwSize);
+        ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx.\n", i, hr);
+        ok(result.dwSize == sizeof(result), "Test %u: Got unexpected result size %lu.\n", i, result.dwSize);
         if (SUCCEEDED(hr))
         {
             ok(result.ddHwDesc.dwSize == sizeof(result_v1.hw_desc),
-                    "Test %u: Got unexpected HW desc size %u.\n", i, result.ddHwDesc.dwSize);
+                    "Test %u: Got unexpected HW desc size %lu.\n", i, result.ddHwDesc.dwSize);
             ok(result.ddSwDesc.dwSize == sizeof(result_v1.sw_desc),
-                    "Test %u: Got unexpected SW desc size %u.\n", i, result.ddSwDesc.dwSize);
+                    "Test %u: Got unexpected SW desc size %lu.\n", i, result.ddSwDesc.dwSize);
         }
         else
         {
             ok(!result.ddHwDesc.dwSize,
-                    "Test %u: Got unexpected HW desc size %u.\n", i, result.ddHwDesc.dwSize);
+                    "Test %u: Got unexpected HW desc size %lu.\n", i, result.ddHwDesc.dwSize);
             ok(!result.ddSwDesc.dwSize,
-                    "Test %u: Got unexpected SW desc size %u.\n", i, result.ddSwDesc.dwSize);
+                    "Test %u: Got unexpected SW desc size %lu.\n", i, result.ddSwDesc.dwSize);
         }
     }
 
@@ -13482,7 +13482,7 @@ static void test_find_device(void)
     search.dcmColorModel = 0xdeadbeef;
     result.dwSize = sizeof(result);
     hr = IDirect3D_FindDevice(d3d, &search, &result);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3D_Release(d3d);
     IDirectDraw_Release(ddraw);
@@ -13498,9 +13498,9 @@ static LRESULT CALLBACK killfocus_proc(HWND window, UINT message, WPARAM wparam,
     if (message == WM_KILLFOCUS)
     {
         ref = IDirectDrawSurface_Release(killfocus_surface);
-        ok(!ref, "Unexpected surface refcount %u.\n", ref);
+        ok(!ref, "Unexpected surface refcount %lu.\n", ref);
         ref = IDirectDraw_Release(killfocus_ddraw);
-        ok(!ref, "Unexpected ddraw refcount %u.\n", ref);
+        ok(!ref, "Unexpected ddraw refcount %lu.\n", ref);
         killfocus_ddraw = NULL;
     }
 
@@ -13525,14 +13525,14 @@ static void test_killfocus(void)
     ok(!!killfocus_ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw_SetCooperativeLevel(killfocus_ddraw, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw_CreateSurface(killfocus_ddraw, &surface_desc, &killfocus_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     SetForegroundWindow(GetDesktopWindow());
     ok(!killfocus_ddraw, "WM_KILLFOCUS was not received.\n");
@@ -13555,38 +13555,38 @@ static void test_gdi_surface(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Retrieving the GDI surface requires a primary surface to exist. */
     gdi_surface = (void *)0xc0dec0de;
     hr = IDirectDraw_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!gdi_surface, "Got unexpected surface %p.\n", gdi_surface);
 
     hr = IDirectDraw_FlipToGDISurface(ddraw);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(gdi_surface == primary, "Got unexpected surface %p, expected %p.\n", gdi_surface, primary);
     IDirectDrawSurface_Release(gdi_surface);
 
     /* Flipping to the GDI surface requires the primary surface to be
      * flippable. */
     hr = IDirectDraw_FlipToGDISurface(ddraw);
-    ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(primary);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -13594,40 +13594,40 @@ static void test_gdi_surface(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     U5(surface_desc).dwBackBufferCount = 1;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetAttachedSurface(primary, &caps, &backbuffer);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(backbuffer != primary, "Got unexpected backbuffer %p.\n", backbuffer);
 
     hr = IDirectDraw_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(gdi_surface == primary, "Got unexpected surface %p, expected %p.\n", gdi_surface, primary);
     IDirectDrawSurface_Release(gdi_surface);
 
     hr = IDirectDrawSurface_Flip(primary, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(gdi_surface == backbuffer || broken(gdi_surface == primary),
             "Got unexpected surface %p, expected %p.\n", gdi_surface, backbuffer);
     IDirectDrawSurface_Release(gdi_surface);
 
     hr = IDirectDraw_FlipToGDISurface(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(gdi_surface == primary, "Got unexpected surface %p, expected %p.\n", gdi_surface, primary);
     IDirectDrawSurface_Release(gdi_surface);
 
     hr = IDirectDraw_FlipToGDISurface(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(backbuffer);
     IDirectDrawSurface_Release(primary);
 
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -13688,7 +13688,7 @@ static void test_alphatest(void)
         return;
     }
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     blue = create_diffuse_material(device, 0.0f, 0.0f, 1.0f, 1.0f);
     failed = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f);
@@ -13697,7 +13697,7 @@ static void test_alphatest(void)
 
     viewport_set_background(device, viewport, blue);
     hr = IDirect3DViewport_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&exec_desc, 0, sizeof(exec_desc));
     exec_desc.dwSize = sizeof(exec_desc);
@@ -13706,10 +13706,10 @@ static void test_alphatest(void)
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
 
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     ptr = exec_desc.lpData;
     emit_set_rs(&ptr, D3DRENDERSTATE_LIGHTING, FALSE);
@@ -13719,17 +13719,17 @@ static void test_alphatest(void)
     inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData;
 
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     set_execute_data(execute_buffer, 0, 0, inst_length);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     viewport_set_background(device, viewport, failed);
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         memcpy(exec_desc.lpData, quad, sizeof(quad));
         ptr = ((BYTE *)exec_desc.lpData) + sizeof(quad);
@@ -13742,24 +13742,24 @@ static void test_alphatest(void)
         inst_length -= sizeof(quad);
 
         hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DViewport_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         set_execute_data(execute_buffer, ARRAY_SIZE(quad), sizeof(quad), inst_length);
         hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, test_data[i].color_greater, 0),
-                "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n",
+                "Alphatest failed, color 0x%08lx, expected 0x%08lx, alpha > ref, func %u.\n",
                 color, test_data[i].color_greater, test_data[i].func);
 
         hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         memcpy(exec_desc.lpData, quad, sizeof(quad));
         ptr = ((BYTE *)exec_desc.lpData) + sizeof(quad);
@@ -13771,20 +13771,20 @@ static void test_alphatest(void)
         inst_length -= sizeof(quad);
 
         hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DViewport_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         set_execute_data(execute_buffer, ARRAY_SIZE(quad), sizeof(quad), inst_length);
         hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, test_data[i].color_greater, 0),
-                "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n",
+                "Alphatest failed, color 0x%08lx, expected 0x%08lx, alpha > ref, func %u.\n",
                 color, test_data[i].color_greater, test_data[i].func);
     }
 
@@ -13794,9 +13794,9 @@ static void test_alphatest(void)
     destroy_material(blue);
     IDirectDrawSurface_Release(rt);
     refcount = IDirect3DDevice_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -13816,24 +13816,24 @@ static void test_clipper_refcount(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw_CreateClipper(ddraw, 0, &clipper, NULL);
-    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     /* Show that clipper validation doesn't somehow happen through per-clipper vtable
      * pointers. */
     hr = IDirectDraw_CreateClipper(ddraw, 0, &clipper2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
     ok(clipper->lpVtbl == clipper2->lpVtbl, "Got different clipper vtables %p and %p.\n",
             clipper->lpVtbl, clipper2->lpVtbl);
     orig_vtbl = clipper->lpVtbl;
@@ -13841,50 +13841,50 @@ static void test_clipper_refcount(void)
 
     /* Surfaces hold a reference to clippers. No surprises there. */
     hr = IDirectDrawSurface_SetClipper(surface, clipper);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface_GetClipper(surface, &clipper2);
-    ok(SUCCEEDED(hr), "Failed to get clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get clipper, hr %#lx.\n", hr);
     ok(clipper == clipper2, "Got clipper %p, expected %p.\n", clipper2, clipper);
     refcount = IDirectDrawClipper_Release(clipper2);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface_SetClipper(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface_SetClipper(surface, clipper);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     refcount = IDirectDrawSurface_Release(surface);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     /* SetClipper with an invalid pointer crashes. */
 
     /* Clipper methods work with a broken vtable, with the exception of Release. */
     clipper->lpVtbl = (void *)0xdeadbeef;
     refcount = orig_vtbl->AddRef(clipper);
-    todo_wine ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    todo_wine ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
     refcount = orig_vtbl->Release(clipper);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     clipper->lpVtbl = orig_vtbl;
     refcount = orig_vtbl->Release(clipper);
-    todo_wine ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    todo_wine ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     /* Fix the refcount difference because Wine did not increase the ref in the
      * AddRef call above. */
     if (refcount)
     {
         refcount = IDirectDrawClipper_Release(clipper);
-        ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+        ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     }
 
     /* Steal the reference and see what happens - releasing the surface works fine.
@@ -13892,11 +13892,11 @@ static void test_clipper_refcount(void)
      * release it after the GetClipper call is likely to crash, and certain to crash
      * if we allocate and zero as much heap memory as we can get. */
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw_CreateClipper(ddraw, 0, &clipper, NULL);
-    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_SetClipper(surface, clipper);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
 
     IDirectDrawClipper_Release(clipper);
     IDirectDrawClipper_Release(clipper);
@@ -13912,7 +13912,7 @@ static void test_clipper_refcount(void)
          * The same Windows and driver versions run the test without heap corruption on
          * a Geforce 1060 GTX card. I have not seen the problem on AMD GPUs either. */
         hr = IDirectDrawSurface_GetClipper(surface, &clipper2);
-        ok(SUCCEEDED(hr), "Failed to get clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get clipper, hr %#lx.\n", hr);
         ok(clipper == clipper2, "Got clipper %p, expected %p.\n", clipper2, clipper);
     }
 
@@ -13920,10 +13920,10 @@ static void test_clipper_refcount(void)
      * vtable through the clipper pointer because it is no longer pointing to
      * valid memory. */
     refcount = orig_vtbl->Release(clipper);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
 
     refcount = IDirectDrawSurface_Release(surface);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
 
     /* It looks like the protection against invalid thispointers is part of
      * the IDirectDrawClipper method implementation, not IDirectDrawSurface. */
@@ -13936,28 +13936,28 @@ static void test_clipper_refcount(void)
     clipper->lpVtbl = orig_vtbl;
 
     refcount = orig_vtbl->AddRef(clipper);
-    todo_wine ok(!refcount, "Got refcount %u.\n", refcount);
+    todo_wine ok(!refcount, "Got refcount %lu.\n", refcount);
     refcount = orig_vtbl->AddRef((IDirectDrawClipper *)(ULONG_PTR)0xdeadbeef);
-    ok(!refcount, "Got refcount %u.\n", refcount);
+    ok(!refcount, "Got refcount %lu.\n", refcount);
 
     changed = 0x1234;
     hr = orig_vtbl->IsClipListChanged(clipper, &changed);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     todo_wine ok(changed == 0x1234, "'changed' changed: %x.\n", changed);
 
     changed = 0x1234;
     hr = orig_vtbl->IsClipListChanged((IDirectDrawClipper *)(ULONG_PTR)0xdeadbeef, &changed);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     ok(changed == 0x1234, "'changed' changed: %x.\n", changed);
 
     /* Nope, we can't initialize our fake clipper. */
     hr = orig_vtbl->Initialize(clipper, ddraw, 0);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     HeapFree(GetProcessHeap(), 0, clipper);
 
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -14009,68 +14009,68 @@ static void test_caps(void)
     hal_caps.dwSize = sizeof(hal_caps);
     hel_caps.dwSize = sizeof(hel_caps);
     hr = IDirectDraw_GetCaps(ddraw, &hal_caps, &hel_caps);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(hal_caps.ddsOldCaps.dwCaps == hal_caps.ddsCaps.dwCaps,
-            "Got unexpected caps %#x, expected %#x.\n",
+            "Got unexpected caps %#lx, expected %#lx.\n",
             hal_caps.ddsOldCaps.dwCaps, hal_caps.ddsCaps.dwCaps);
     ok(hel_caps.ddsOldCaps.dwCaps == hel_caps.ddsCaps.dwCaps,
-            "Got unexpected caps %#x, expected %#x.\n",
+            "Got unexpected caps %#lx, expected %#lx.\n",
             hel_caps.ddsOldCaps.dwCaps, hel_caps.ddsCaps.dwCaps);
 
     no3d = !(hal_caps.ddsCaps.dwCaps & DDSCAPS_3DDEVICE);
     if (hal_caps.ddsCaps.dwCaps)
     {
-        ok(!(hal_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
-        ok(!(~hal_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(hal_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(~hal_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
         todo_wine_if(no3d) ok(!(~hal_caps.ddsCaps.dwCaps & caps_hal),
-                "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
+                "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
     }
-    ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
-    ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+    ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
+    ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
     todo_wine_if(!no3d) ok(!(hel_caps.ddsCaps.dwCaps & caps_hal),
-            "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+            "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
 
     IDirectDraw_Release(ddraw);
 
     if (hal_caps.ddsCaps.dwCaps)
     {
         hr = DirectDrawCreate((GUID *)DDCREATE_HARDWAREONLY, &ddraw, NULL);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         memset(&hal_caps, 0, sizeof(hal_caps));
         memset(&hel_caps, 0, sizeof(hel_caps));
         hal_caps.dwSize = sizeof(hal_caps);
         hel_caps.dwSize = sizeof(hel_caps);
         hr = IDirectDraw_GetCaps(ddraw, &hal_caps, &hel_caps);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         ok(hal_caps.ddsOldCaps.dwCaps == hal_caps.ddsCaps.dwCaps,
-                "Got unexpected caps %#x, expected %#x.\n",
+                "Got unexpected caps %#lx, expected %#lx.\n",
                 hal_caps.ddsOldCaps.dwCaps, hal_caps.ddsCaps.dwCaps);
         ok(hel_caps.ddsOldCaps.dwCaps == hel_caps.ddsCaps.dwCaps,
-                "Got unexpected caps %#x, expected %#x.\n",
+                "Got unexpected caps %#lx, expected %#lx.\n",
                 hel_caps.ddsOldCaps.dwCaps, hel_caps.ddsCaps.dwCaps);
 
-        ok(!(hal_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
-        ok(!(~hal_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(hal_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(~hal_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
         todo_wine_if(no3d) ok(!(~hal_caps.ddsCaps.dwCaps & caps_hal),
-                "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
+                "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
         if (is_ddraw64)
         {
-            ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
-            ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+            ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
+            ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
             todo_wine_if(!no3d) ok(!(hel_caps.ddsCaps.dwCaps & caps_hal),
-                    "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+                    "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
         }
         else
         {
-            todo_wine ok(!hel_caps.ddsCaps.dwCaps, "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+            todo_wine ok(!hel_caps.ddsCaps.dwCaps, "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
         }
 
         IDirectDraw_Release(ddraw);
     }
 
     hr = DirectDrawCreate((GUID *)DDCREATE_EMULATIONONLY, &ddraw, NULL);
-    ok(hr == DD_OK || (is_ddraw64 && hr == E_FAIL), "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK || (is_ddraw64 && hr == E_FAIL), "Got unexpected hr %#lx.\n", hr);
     if (SUCCEEDED(hr))
     {
         memset(&hal_caps, 0, sizeof(hal_caps));
@@ -14078,19 +14078,19 @@ static void test_caps(void)
         hal_caps.dwSize = sizeof(hal_caps);
         hel_caps.dwSize = sizeof(hel_caps);
         hr = IDirectDraw_GetCaps(ddraw, &hal_caps, &hel_caps);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         ok(hal_caps.ddsOldCaps.dwCaps == hal_caps.ddsCaps.dwCaps,
-                "Got unexpected caps %#x, expected %#x.\n",
+                "Got unexpected caps %#lx, expected %#lx.\n",
                 hal_caps.ddsOldCaps.dwCaps, hal_caps.ddsCaps.dwCaps);
         ok(hel_caps.ddsOldCaps.dwCaps == hel_caps.ddsCaps.dwCaps,
-                "Got unexpected caps %#x, expected %#x.\n",
+                "Got unexpected caps %#lx, expected %#lx.\n",
                 hel_caps.ddsOldCaps.dwCaps, hel_caps.ddsCaps.dwCaps);
 
-        todo_wine ok(!hal_caps.ddsCaps.dwCaps, "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
-        ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
-        ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+        todo_wine ok(!hal_caps.ddsCaps.dwCaps, "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
+        ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
         todo_wine_if(!no3d) ok(!(hel_caps.ddsCaps.dwCaps & caps_hal),
-                "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+                "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
 
         IDirectDraw_Release(ddraw);
     }
@@ -14109,7 +14109,7 @@ static void test_d32_support(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -14119,21 +14119,21 @@ static void test_d32_support(void)
     surface_desc.dwWidth = 64;
     surface_desc.dwHeight = 64;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok((surface_desc.dwFlags & DDSD_ZBUFFERBITDEPTH), "Got unexpected flags %#x.\n", surface_desc.dwFlags);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok((surface_desc.dwFlags & DDSD_ZBUFFERBITDEPTH), "Got unexpected flags %#lx.\n", surface_desc.dwFlags);
     ok(U2(surface_desc).dwZBufferBitDepth == 32,
-            "Got unexpected dwZBufferBitDepth %u.\n", U2(surface_desc).dwZBufferBitDepth);
+            "Got unexpected dwZBufferBitDepth %lu.\n", U2(surface_desc).dwZBufferBitDepth);
     ok(!(surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY),
-            "Got unexpected surface caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+            "Got unexpected surface caps %#lx.\n", surface_desc.ddsCaps.dwCaps);
     IDirectDrawSurface_Release(surface);
 
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -14180,13 +14180,13 @@ static void test_cursor_clipping(void)
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "GetDisplayMode failed, hr %#lx.\n", hr);
 
     memset(&param, 0, sizeof(param));
     param.old_width = surface_desc.dwWidth;
     param.old_height = surface_desc.dwHeight;
     hr = IDirectDraw_EnumDisplayModes(ddraw, 0, NULL, &param, find_different_mode_callback);
-    ok(hr == DD_OK, "EnumDisplayModes failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "EnumDisplayModes failed, hr %#lx.\n", hr);
     if (!(param.new_width && param.new_height))
     {
         skip("Failed to find a different mode than %ux%u.\n", param.old_width, param.old_height);
@@ -14194,87 +14194,87 @@ static void test_cursor_clipping(void)
     }
 
     ret = ClipCursor(NULL);
-    ok(ret, "ClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "ClipCursor failed, error %#lx.\n", GetLastError());
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     /* Set cooperative level to normal */
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     flush_events();
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     hr = set_display_mode(ddraw, param.new_width, param.new_height);
-    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode failed, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
-        win_skip("SetDisplayMode failed, hr %#x.\n", hr);
+        win_skip("SetDisplayMode failed, hr %#lx.\n", hr);
         goto done;
     }
     flush_events();
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     hr = IDirectDraw_RestoreDisplayMode(ddraw);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
     flush_events();
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     /* Switch to full screen cooperative level */
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     flush_events();
     SetRect(&rect, 0, 0, param.old_width, param.old_height);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     hr = set_display_mode(ddraw, param.new_width, param.new_height);
-    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode failed, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
-        win_skip("SetDisplayMode failed, hr %#x.\n", hr);
+        win_skip("SetDisplayMode failed, hr %#lx.\n", hr);
         goto done;
     }
     flush_events();
     SetRect(&rect, 0, 0, param.new_width, param.new_height);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     /* Restore display mode */
     hr = IDirectDraw_RestoreDisplayMode(ddraw);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
     flush_events();
     SetRect(&rect, 0, 0, param.old_width, param.old_height);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     /* Switch to normal cooperative level */
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     flush_events();
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
@@ -14288,7 +14288,7 @@ static void check_vtbl_protection_(int line, const void *vtbl)
     MEMORY_BASIC_INFORMATION info;
     SIZE_T ret = VirtualQuery(vtbl, &info, sizeof(info));
     ok_(__FILE__, line)(ret == sizeof(info), "Failed to query memory.\n");
-    ok_(__FILE__, line)(info.Protect & (PAGE_READWRITE | PAGE_WRITECOPY), "Got protection %#x.\n", info.Protect);
+    ok_(__FILE__, line)(info.Protect & (PAGE_READWRITE | PAGE_WRITECOPY), "Got protection %#lx.\n", info.Protect);
 }
 #define check_vtbl_protection(a) check_vtbl_protection_(__LINE__, a)
 
@@ -14311,27 +14311,27 @@ static void test_vtbl_protection(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface2, (void **)&surface2);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface3, (void **)&surface3);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface4, (void **)&surface4);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface7, (void **)&surface7);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     hr = IDirectDraw_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     check_vtbl_protection(ddraw->lpVtbl);
     check_vtbl_protection(palette->lpVtbl);
@@ -14348,7 +14348,7 @@ static void test_vtbl_protection(void)
     IDirectDrawSurface4_Release(surface4);
     IDirectDrawSurface7_Release(surface7);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -14370,10 +14370,10 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
     flush_events();
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     flush_events();
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "GetWindowRect failed, error %#x.\n", GetLastError());
+    ok(ret, "GetWindowRect failed, error %#lx.\n", GetLastError());
     SetRect(&primary_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
     ok(EqualRect(&window_rect, &primary_rect), "Expect window rect %s, got %s.\n",
             wine_dbgstr_rect(&primary_rect), wine_dbgstr_rect(&window_rect));
@@ -14384,9 +14384,9 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
 
     ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left,
             new_rect.bottom - new_rect.top, TRUE);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ok(EqualRect(&window_rect, &new_rect),
             "Expected window rect %s, got %s.\n",
             wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect));
@@ -14394,7 +14394,7 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
      * on the second resize remains. */
     flush_events();
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     /* Both Windows and Wine change the size of the window. On Windows it is exactly the new size but in Wine
      * it may get adjusted depending on window manager. */
     ok(window_rect.right != monitor_rect->right && window_rect.bottom != monitor_rect->bottom,
@@ -14403,15 +14403,15 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
 
     ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left,
             new_rect.bottom - new_rect.top, TRUE);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ok(EqualRect(&window_rect, &new_rect),
             "Expected window rect %s, got %s.\n",
             wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect));
     flush_events();
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ok(window_rect.right != monitor_rect->right && window_rect.bottom != monitor_rect->bottom,
             "Expected window rect %s, got %s.\n",
             wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect));
@@ -14419,25 +14419,25 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
     /* Window activation should restore the window to fit the whole primary monitor */
     ret = SetWindowPos(window, 0, monitor_rect->left, monitor_rect->top, 0, 0,
             SWP_NOZORDER | SWP_NOSIZE);
-    ok(ret, "SetWindowPos failed, error %#x.\n", GetLastError());
+    ok(ret, "SetWindowPos failed, error %#lx.\n", GetLastError());
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     flush_events();
     ret = ShowWindow(window, SW_RESTORE);
-    ok(ret, "Failed to restore window, error %#x.\n", GetLastError());
+    ok(ret, "Failed to restore window, error %#lx.\n", GetLastError());
     flush_events();
     ret = SetForegroundWindow(window);
-    ok(ret, "SetForegroundWindow failed, error %#x.\n", GetLastError());
+    ok(ret, "SetForegroundWindow failed, error %#lx.\n", GetLastError());
     flush_events();
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "GetWindowRect failed, error %#x.\n", GetLastError());
+    ok(ret, "GetWindowRect failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&window_rect, &primary_rect), "Expect window rect %s, got %s.\n",
             wine_dbgstr_rect(&primary_rect), wine_dbgstr_rect(&window_rect));
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "GetWindowRect failed, error %#x.\n", GetLastError());
+    ok(ret, "GetWindowRect failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&window_rect, &primary_rect), "Expect window rect %s, got %s.\n",
             wine_dbgstr_rect(&primary_rect), wine_dbgstr_rect(&window_rect));
 
@@ -14468,14 +14468,14 @@ static BOOL CALLBACK test_get_display_mode_cb(HMONITOR monitor, HDC hdc, RECT *m
     /* Test that DirectDraw doesn't use the device window to determine which monitor to use */
     ret = SetWindowPos(window, 0, monitor_rect->left, monitor_rect->top, 0, 0,
             SWP_NOZORDER | SWP_NOSIZE);
-    ok(ret, "SetWindowPos failed, error %#x.\n", GetLastError());
+    ok(ret, "SetWindowPos failed, error %#lx.\n", GetLastError());
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == GetSystemMetrics(SM_CXSCREEN), "Expect width %d, got %d.\n",
+    ok(hr == DD_OK, "GetDisplayMode failed, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == GetSystemMetrics(SM_CXSCREEN), "Expect width %d, got %ld.\n",
             GetSystemMetrics(SM_CXSCREEN), surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == GetSystemMetrics(SM_CYSCREEN), "Expect height %d, got %d.\n",
+    ok(surface_desc.dwHeight == GetSystemMetrics(SM_CYSCREEN), "Expect height %d, got %ld.\n",
             GetSystemMetrics(SM_CYSCREEN), surface_desc.dwHeight);
 
     DestroyWindow(window);
@@ -14500,29 +14500,29 @@ static void test_get_display_mode(void)
     memset(&devmode, 0, sizeof(devmode));
     devmode.dmSize = sizeof(devmode);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
-    ok(surface_desc.dwSize == sizeof(surface_desc), "Expected dwSize %u, got %u.\n",
+    ok(hr == DD_OK, "GetDisplayMode failed, hr %#lx.\n", hr);
+    ok(surface_desc.dwSize == sizeof(surface_desc), "Expected dwSize %Iu, got %lu.\n",
             sizeof(surface_desc), surface_desc.dwSize);
-    ok(surface_desc.dwFlags == flags, "Expected dwFlags %#x, got %#x.\n", flags,
+    ok(surface_desc.dwFlags == flags, "Expected dwFlags %#lx, got %#lx.\n", flags,
             surface_desc.dwFlags);
-    ok(surface_desc.dwWidth == devmode.dmPelsWidth, "Expected width %u, got %u.\n",
+    ok(surface_desc.dwWidth == devmode.dmPelsWidth, "Expected width %lu, got %lu.\n",
             devmode.dmPelsWidth, surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == devmode.dmPelsHeight, "Expected height %u, got %u.\n",
+    ok(surface_desc.dwHeight == devmode.dmPelsHeight, "Expected height %lu, got %lu.\n",
             devmode.dmPelsHeight, surface_desc.dwHeight);
-    ok(surface_desc.dwRefreshRate == devmode.dmDisplayFrequency, "Expected frequency %u, got %u.\n",
+    ok(surface_desc.dwRefreshRate == devmode.dmDisplayFrequency, "Expected frequency %lu, got %lu.\n",
             devmode.dmDisplayFrequency, surface_desc.dwRefreshRate);
     ok(surface_desc.ddpfPixelFormat.dwSize == sizeof(surface_desc.ddpfPixelFormat),
-            "Expected ddpfPixelFormat.dwSize %u, got %u.\n", sizeof(surface_desc.ddpfPixelFormat),
+            "Expected ddpfPixelFormat.dwSize %Iu, got %lu.\n", sizeof(surface_desc.ddpfPixelFormat),
             surface_desc.ddpfPixelFormat.dwSize);
     ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == devmode.dmBitsPerPel,
-            "Expected ddpfPixelFormat.dwRGBBitCount %u, got %u.\n", devmode.dmBitsPerPel,
+            "Expected ddpfPixelFormat.dwRGBBitCount %lu, got %lu.\n", devmode.dmBitsPerPel,
             surface_desc.ddpfPixelFormat.dwRGBBitCount);
     ok(surface_desc.lPitch == devmode.dmPelsWidth * devmode.dmBitsPerPel / 8,
-            "Expected pitch %u, got %u.\n", devmode.dmPelsWidth * devmode.dmBitsPerPel / 8,
+            "Expected pitch %lu, got %lu.\n", devmode.dmPelsWidth * devmode.dmBitsPerPel / 8,
             surface_desc.lPitch);
 
     IDirectDraw_Release(ddraw);
@@ -14576,7 +14576,7 @@ static void test_texture_wrong_caps(const GUID *device_guid)
         return;
     }
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
 
@@ -14588,11 +14588,11 @@ static void test_texture_wrong_caps(const GUID *device_guid)
     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     U4(ddsd).ddpfPixelFormat = fmt;
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture, (void **)&texture);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture_GetHandle(texture, device, &texture_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     fill_surface(surface, 0xff00ff00);
 
@@ -14600,7 +14600,7 @@ static void test_texture_wrong_caps(const GUID *device_guid)
     viewport_set_background(device, viewport, background);
 
     hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     if (is_software_device_type(device_guid))
         fill_surface(rt, 0xffff0000);
 
@@ -14610,10 +14610,10 @@ static void test_texture_wrong_caps(const GUID *device_guid)
     exec_desc.dwBufferSize = 1024;
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(exec_desc.lpData, quad, sizeof(quad));
     ptr = (BYTE *)exec_desc.lpData + sizeof(quad);
     emit_process_vertices(&ptr, D3DPROCESSVERTICES_COPY, 0, 4);
@@ -14622,20 +14622,20 @@ static void test_texture_wrong_caps(const GUID *device_guid)
     emit_end(&ptr);
     inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData - sizeof(quad);
     hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     set_execute_data(execute_buffer, 4, sizeof(quad), inst_length);
 
     hr = IDirect3DDevice_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     expected_color = is_software_device_type(device_guid) ? 0x0000ff00 : 0x00ffffff;
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, expected_color, 1), "Got color 0x%08x, expected 0x%08x.\n", color, expected_color);
+    ok(compare_color(color, expected_color, 1), "Got color 0x%08lx, expected 0x%08lx.\n", color, expected_color);
 
     IDirect3DTexture_Release(texture);
     IDirectDrawSurface_Release(surface);
@@ -14646,7 +14646,7 @@ static void test_texture_wrong_caps(const GUID *device_guid)
 
     IDirect3DDevice_Release(device);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -14993,7 +14993,7 @@ static void test_filling_convention(void)
     }
 
     hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&backbuffer);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, vp_size, vp_size);
     background = create_diffuse_material(device, 0.0f, 0.0f, 1.0f, 1.0f);
@@ -15006,15 +15006,15 @@ static void test_filling_convention(void)
     exec_desc.dwCaps = D3DDEBCAPS_SYSTEMMEMORY;
 
     hr = IDirect3DDevice_CreateExecuteBuffer(device, &exec_desc, &execute_buffer, NULL);
-    ok(hr == D3D_OK, "Failed to create execute buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create execute buffer, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DViewport_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DExecuteBuffer_Lock(execute_buffer, &exec_desc);
-        ok(hr == D3D_OK, "Failed to lock execute buffer, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to lock execute buffer, hr %#lx.\n", hr);
 
         /* All test geometry has the same vertex count and vertex size. */
         memcpy(exec_desc.lpData, tests[i].geometry, sizeof(center_tris));
@@ -15030,16 +15030,16 @@ static void test_filling_convention(void)
         inst_length -= sizeof(center_tris);
 
         hr = IDirect3DExecuteBuffer_Unlock(execute_buffer);
-        ok(hr == D3D_OK, "Failed to lock execute buffer, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to lock execute buffer, hr %#lx.\n", hr);
 
         set_execute_data(execute_buffer, 12, sizeof(center_tris), inst_length);
 
         hr = IDirect3DDevice_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         for (y = 0; y < 8; y++)
         {
@@ -15077,7 +15077,7 @@ static void test_filling_convention(void)
                  * convention, but because wined3d will nudge geometry to the left to
                  * keep diagonals (the 'R' in test case 'edge_tris') intact. */
                 todo_wine_if(todo && !compare_color(colour, expected, 1))
-                    ok(compare_color(colour, expected, 1), "Got unexpected colour %08x, %ux%u, case %u.\n",
+                    ok(compare_color(colour, expected, 1), "Got unexpected colour %08lx, %ux%u, case %u.\n",
                             colour, x, y, i);
             }
         }
@@ -15087,7 +15087,7 @@ static void test_filling_convention(void)
     IDirectDrawSurface_Release(backbuffer);
     IDirect3DDevice_Release(device);
     refcount = IDirectDraw_Release(ddraw);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index eea87f4bac29..752690faf079 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -122,9 +122,9 @@ static BOOL ddraw_get_identifier(IDirectDraw2 *ddraw, DDDEVICEIDENTIFIER *identi
     HRESULT hr;
 
     hr = IDirectDraw2_QueryInterface(ddraw, &IID_IDirectDraw4, (void **)&ddraw4);
-    ok(SUCCEEDED(hr), "Failed to get IDirectDraw4 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get IDirectDraw4 interface, hr %#lx.\n", hr);
     hr = IDirectDraw4_GetDeviceIdentifier(ddraw4, identifier, 0);
-    ok(SUCCEEDED(hr), "Failed to get device identifier, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device identifier, hr %#lx.\n", hr);
     IDirectDraw4_Release(ddraw4);
 
     return SUCCEEDED(hr);
@@ -212,7 +212,7 @@ static DWORD WINAPI create_window_thread_proc(void *param)
 
     p->window = create_window();
     ret = SetEvent(p->window_created);
-    ok(ret, "SetEvent failed, last error %#x.\n", GetLastError());
+    ok(ret, "SetEvent failed, last error %#lx.\n", GetLastError());
 
     for (;;)
     {
@@ -225,7 +225,7 @@ static DWORD WINAPI create_window_thread_proc(void *param)
             break;
         if (res != WAIT_TIMEOUT)
         {
-            ok(0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+            ok(0, "Wait failed (%#lx), last error %#lx.\n", res, GetLastError());
             break;
         }
     }
@@ -240,13 +240,13 @@ static void create_window_thread(struct create_window_thread_param *p)
     DWORD res, tid;
 
     p->window_created = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(!!p->window_created, "CreateEvent failed, last error %#x.\n", GetLastError());
+    ok(!!p->window_created, "CreateEvent failed, last error %#lx.\n", GetLastError());
     p->destroy_window = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(!!p->destroy_window, "CreateEvent failed, last error %#x.\n", GetLastError());
+    ok(!!p->destroy_window, "CreateEvent failed, last error %#lx.\n", GetLastError());
     p->thread = CreateThread(NULL, 0, create_window_thread_proc, p, 0, &tid);
-    ok(!!p->thread, "Failed to create thread, last error %#x.\n", GetLastError());
+    ok(!!p->thread, "Failed to create thread, last error %#lx.\n", GetLastError());
     res = WaitForSingleObject(p->window_created, INFINITE);
-    ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+    ok(res == WAIT_OBJECT_0, "Wait failed (%#lx), last error %#lx.\n", res, GetLastError());
 }
 
 static void destroy_window_thread(struct create_window_thread_param *p)
@@ -265,9 +265,9 @@ static IDirectDrawSurface *get_depth_stencil(IDirect3DDevice2 *device)
     HRESULT hr;
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetAttachedSurface(rt, &caps, &ret);
-    ok(SUCCEEDED(hr) || hr == DDERR_NOTFOUND, "Failed to get the z buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || hr == DDERR_NOTFOUND, "Failed to get the z buffer, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(rt);
     return ret;
 }
@@ -353,14 +353,14 @@ static D3DCOLOR get_surface_color(IDirectDrawSurface *surface, UINT x, UINT y)
     surface_desc.dwSize = sizeof(surface_desc);
 
     hr = IDirectDrawSurface_Lock(surface, &rect, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     if (FAILED(hr))
         return 0xdeadbeef;
 
     color = *((DWORD *)surface_desc.lpSurface) & 0x00ffffff;
 
     hr = IDirectDrawSurface_Unlock(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     return color;
 }
@@ -373,7 +373,7 @@ static void fill_surface(IDirectDrawSurface *surface, D3DCOLOR color)
     DWORD *ptr;
 
     hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (y = 0; y < surface_desc.dwHeight; ++y)
     {
@@ -385,7 +385,7 @@ static void fill_surface(IDirectDrawSurface *surface, D3DCOLOR color)
     }
 
     hr = IDirectDrawSurface_Unlock(surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 }
 
 static void check_rect(IDirectDrawSurface *surface, RECT r)
@@ -419,7 +419,7 @@ static void check_rect(IDirectDrawSurface *surface, RECT r)
                     if (x < 0 || x >= 640 || y < 0 || y >= 480)
                         continue;
                     color = get_surface_color(surface, x, y);
-                    ok(color == expected, "Pixel (%d, %d) has color %08x, expected %08x.\n", x, y, color, expected);
+                    ok(color == expected, "Pixel (%ld, %ld) has color %08lx, expected %08lx.\n", x, y, color, expected);
                 }
             }
         }
@@ -482,7 +482,7 @@ static IDirect3DDevice2 *create_device_ex(IDirectDraw2 *ddraw, HWND window, DWOR
     HRESULT hr;
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, coop_level);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -494,18 +494,18 @@ static IDirect3DDevice2 *create_device_ex(IDirectDraw2 *ddraw, HWND window, DWOR
     surface_desc.dwHeight = 480;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     if (coop_level & DDSCL_NORMAL)
     {
         IDirectDrawClipper *clipper;
 
         hr = IDirectDraw2_CreateClipper(ddraw, 0, &clipper, NULL);
-        ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
         hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
-        ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
         hr = IDirectDrawSurface_SetClipper(surface, clipper);
-        ok(SUCCEEDED(hr), "Failed to set surface clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set surface clipper, hr %#lx.\n", hr);
         IDirectDrawClipper_Release(clipper);
     }
 
@@ -534,7 +534,7 @@ static IDirect3DDevice2 *create_device_ex(IDirectDraw2 *ddraw, HWND window, DWOR
             continue;
 
         hr = IDirectDrawSurface_AddAttachedSurface(surface, ds);
-        ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
         IDirectDrawSurface_Release(ds);
         if (FAILED(hr))
             continue;
@@ -563,11 +563,11 @@ static IDirect3DViewport2 *create_viewport(IDirect3DDevice2 *device, UINT x, UIN
     HRESULT hr;
 
     hr = IDirect3DDevice2_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D2_CreateViewport(d3d, &viewport, NULL);
-    ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_AddViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to add viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to add viewport, hr %#lx.\n", hr);
     memset(&vp, 0, sizeof(vp));
     vp.dwSize = sizeof(vp);
     vp.dwX = x;
@@ -581,7 +581,7 @@ static IDirect3DViewport2 *create_viewport(IDirect3DDevice2 *device, UINT x, UIN
     vp.dvMinZ = 0.0f;
     vp.dvMaxZ = 1.0f;
     hr = IDirect3DViewport2_SetViewport2(viewport, &vp);
-    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#lx.\n", hr);
     IDirect3D2_Release(d3d);
 
     return viewport;
@@ -594,9 +594,9 @@ static void viewport_set_background(IDirect3DDevice2 *device, IDirect3DViewport2
     HRESULT hr;
 
     hr = IDirect3DMaterial2_GetHandle(material, device, &material_handle);
-    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#lx.\n", hr);
     hr = IDirect3DViewport2_SetBackground(viewport, material_handle);
-    ok(SUCCEEDED(hr), "Failed to set viewport background, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport background, hr %#lx.\n", hr);
 }
 
 static void destroy_viewport(IDirect3DDevice2 *device, IDirect3DViewport2 *viewport)
@@ -604,7 +604,7 @@ static void destroy_viewport(IDirect3DDevice2 *device, IDirect3DViewport2 *viewp
     HRESULT hr;
 
     hr = IDirect3DDevice2_DeleteViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to delete viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to delete viewport, hr %#lx.\n", hr);
     IDirect3DViewport2_Release(viewport);
 }
 
@@ -615,11 +615,11 @@ static IDirect3DMaterial2 *create_material(IDirect3DDevice2 *device, D3DMATERIAL
     HRESULT hr;
 
     hr = IDirect3DDevice2_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D2_CreateMaterial(d3d, &material, NULL);
-    ok(SUCCEEDED(hr), "Failed to create material, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create material, hr %#lx.\n", hr);
     hr = IDirect3DMaterial2_SetMaterial(material, mat);
-    ok(SUCCEEDED(hr), "Failed to set material data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set material data, hr %#lx.\n", hr);
     IDirect3D2_Release(d3d);
 
     return material;
@@ -709,7 +709,7 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
     {
         if (expect_messages->check_wparam)
             ok (wparam == expect_messages->expect_wparam,
-                    "Got unexpected wparam %lx for message %x, expected %lx.\n",
+                    "Got unexpected wparam %Ix for message %x, expected %Ix.\n",
                     wparam, message, expect_messages->expect_wparam);
 
         ++expect_messages;
@@ -731,9 +731,9 @@ static void fix_wndproc(HWND window, LONG_PTR proc)
 
     SetWindowLongPtrA(window, GWLP_WNDPROC, proc);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     IDirectDraw2_Release(ddraw);
 }
@@ -741,7 +741,7 @@ static void fix_wndproc(HWND window, LONG_PTR proc)
 static HRESULT CALLBACK restore_callback(IDirectDrawSurface *surface, DDSURFACEDESC *desc, void *context)
 {
     HRESULT hr = IDirectDrawSurface_Restore(surface);
-    ok(SUCCEEDED(hr) || hr == DDERR_IMPLICITLYCREATED, "Failed to restore surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || hr == DDERR_IMPLICITLYCREATED, "Failed to restore surface, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface);
 
     return DDENUMRET_OK;
@@ -764,23 +764,23 @@ static void test_coop_level_create_device_window(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
 
@@ -794,48 +794,48 @@ static void test_coop_level_create_device_window(void)
     }
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, focus_window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
             | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOHWND, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!!device_window, "Device window not found.\n");
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
             | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!!device_window, "Device window not found.\n");
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!!device_window, "Device window not found.\n");
 
@@ -909,22 +909,22 @@ static void test_clipper_blt(void)
     ok(ret, "Failed to map client rect.\n");
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     hr = IDirectDraw2_CreateClipper(ddraw, 0, &clipper, NULL);
-    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
-    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#lx.\n", hr);
     rgn_data = HeapAlloc(GetProcessHeap(), 0, ret);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, rgn_data, &ret);
-    ok(SUCCEEDED(hr), "Failed to get clip list, hr %#x.\n", hr);
-    ok(rgn_data->rdh.dwSize == sizeof(rgn_data->rdh), "Got unexpected structure size %#x.\n", rgn_data->rdh.dwSize);
-    ok(rgn_data->rdh.iType == RDH_RECTANGLES, "Got unexpected type %#x.\n", rgn_data->rdh.iType);
-    ok(rgn_data->rdh.nCount >= 1, "Got unexpected count %u.\n", rgn_data->rdh.nCount);
+    ok(SUCCEEDED(hr), "Failed to get clip list, hr %#lx.\n", hr);
+    ok(rgn_data->rdh.dwSize == sizeof(rgn_data->rdh), "Got unexpected structure size %#lx.\n", rgn_data->rdh.dwSize);
+    ok(rgn_data->rdh.iType == RDH_RECTANGLES, "Got unexpected type %#lx.\n", rgn_data->rdh.iType);
+    ok(rgn_data->rdh.nCount >= 1, "Got unexpected count %lu.\n", rgn_data->rdh.nCount);
     ok(EqualRect(&rgn_data->rdh.rcBound, &client_rect),
             "Got unexpected bounding rect %s, expected %s.\n",
             wine_dbgstr_rect(&rgn_data->rdh.rcBound), wine_dbgstr_rect(&client_rect));
@@ -944,11 +944,11 @@ static void test_clipper_blt(void)
     DeleteObject(r1);
 
     hr = IDirectDrawClipper_SetClipList(clipper, rgn_data, 0);
-    ok(hr == DDERR_CLIPPERISUSINGHWND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CLIPPERISUSINGHWND, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetHWnd(clipper, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetClipList(clipper, rgn_data, 0);
-    ok(SUCCEEDED(hr), "Failed to set clip list, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clip list, hr %#lx.\n", hr);
 
     HeapFree(GetProcessHeap(), 0, rgn_data);
 
@@ -966,33 +966,33 @@ static void test_clipper_blt(void)
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#lx.\n", hr);
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &dst_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     hr = IDirectDrawSurface_Blt(src_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(src_surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#x.\n", hr);
-    ok(U1(surface_desc).lPitch == 2560, "Got unexpected surface pitch %u.\n", U1(surface_desc).lPitch);
+    ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#lx.\n", hr);
+    ok(U1(surface_desc).lPitch == 2560, "Got unexpected surface pitch %lu.\n", U1(surface_desc).lPitch);
     ptr = surface_desc.lpSurface;
     memcpy(&ptr[   0], &src_data[ 0], 6 * sizeof(DWORD));
     memcpy(&ptr[ 640], &src_data[ 6], 6 * sizeof(DWORD));
     memcpy(&ptr[1280], &src_data[12], 6 * sizeof(DWORD));
     hr = IDirectDrawSurface_Unlock(src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_SetClipper(dst_surface, clipper);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
 
     SetRect(&src_rect, 1, 1, 5, 2);
     hr = IDirectDrawSurface_Blt(dst_surface, NULL, src_surface, &src_rect, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
     for (i = 0; i < 4; ++i)
     {
         for (j = 0; j < 4; ++j)
@@ -1002,13 +1002,13 @@ static void test_clipper_blt(void)
             color = get_surface_color(dst_surface, x, y);
             ok(compare_color(color, expected1[i * 4 + j], 1)
                     || broken(compare_color(color, expected1_broken[i * 4 + j], 1)),
-                    "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected1[i * 4 + j], x, y, color);
+                    "Expected color 0x%08lx at %u,%u, got 0x%08lx.\n", expected1[i * 4 + j], x, y, color);
         }
     }
 
     U5(fx).dwFillColor = 0xff0000ff;
     hr = IDirectDrawSurface_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#lx.\n", hr);
     for (i = 0; i < 4; ++i)
     {
         for (j = 0; j < 4; ++j)
@@ -1017,35 +1017,35 @@ static void test_clipper_blt(void)
             y = 60 * ((2 * i) + 1);
             color = get_surface_color(dst_surface, x, y);
             ok(compare_color(color, expected2[i * 4 + j], 1),
-                    "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
+                    "Expected color 0x%08lx at %u,%u, got 0x%08lx.\n", expected2[i * 4 + j], x, y, color);
         }
     }
 
     hr = IDirectDrawSurface_BltFast(dst_surface, 0, 0, src_surface, NULL, DDBLTFAST_WAIT);
-    ok(hr == DDERR_BLTFASTCANTCLIP || broken(hr == E_NOTIMPL /* NT4 */), "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_BLTFASTCANTCLIP || broken(hr == E_NOTIMPL /* NT4 */), "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
-    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#lx.\n", hr);
     DestroyWindow(window);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetHWnd(clipper, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetClipList(clipper, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to set clip list, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clip list, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(dst_surface);
     IDirectDrawSurface_Release(src_surface);
     refcount = IDirectDrawClipper_Release(clipper);
-    ok(!refcount, "Clipper has %u references left.\n", refcount);
+    ok(!refcount, "Clipper has %lu references left.\n", refcount);
     IDirectDraw2_Release(ddraw);
 }
 
@@ -1099,44 +1099,44 @@ static void test_coop_level_d3d_state(void)
     viewport_set_background(device, viewport, background);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_DESTALPHA);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_ZENABLE, &value);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok(!!value, "Got unexpected z-enable state %#x.\n", value);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(!!value, "Got unexpected z-enable state %#lx.\n", value);
     hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, &value);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok(!value, "Got unexpected alpha blend enable state %#x.\n", value);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(!value, "Got unexpected alpha blend enable state %#lx.\n", value);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(rt);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     memset(&lock, 0, sizeof(lock));
     lock.dwSize = sizeof(lock);
     lock.lpSurface = (void *)0xdeadbeef;
     hr = IDirectDrawSurface2_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     ok(lock.lpSurface == (void *)0xdeadbeef, "Got unexpected lock.lpSurface %p.\n", lock.lpSurface);
 
     hr = restore_surfaces(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface2_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface2_Unlock(rt, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&material, 0, sizeof(material));
     material.dwSize = sizeof(material);
@@ -1145,33 +1145,33 @@ static void test_coop_level_d3d_state(void)
     U3(U(material).diffuse).b = 0.0f;
     U4(U(material).diffuse).a = 1.0f;
     hr = IDirect3DMaterial2_SetMaterial(background, &material);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(surface == rt, "Got unexpected surface %p.\n", surface);
     hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_ZENABLE, &value);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok(!!value, "Got unexpected z-enable state %#x.\n", value);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(!!value, "Got unexpected z-enable state %#lx.\n", value);
     hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, &value);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok(!!value, "Got unexpected alpha blend enable state %#x.\n", value);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(!!value, "Got unexpected alpha blend enable state %#lx.\n", value);
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
     ok(compare_color(color, 0x0000ff00, 1) || broken(compare_color(color, 0x00000000, 1)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, quad, ARRAY_SIZE(quad), 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x0000ff80, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff80, 1), "Got unexpected color 0x%08lx.\n", color);
 
     destroy_viewport(device, viewport);
     destroy_material(background);
@@ -1222,7 +1222,7 @@ static void test_surface_interface_mismatch(void)
     surface_desc.dwHeight = 480;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface2_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3);
     if (FAILED(hr))
@@ -1245,15 +1245,15 @@ static void test_surface_interface_mismatch(void)
     surface_desc.dwWidth = 640;
     surface_desc.dwHeight = 480;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &ds, NULL);
-    ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#lx.\n", hr);
     if (FAILED(hr))
         goto cleanup;
 
     /* Using a different surface interface version still works */
     hr = IDirectDrawSurface3_AddAttachedSurface(surface3, (IDirectDrawSurface3 *)ds);
-    ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
     refcount = IDirectDrawSurface_Release(ds);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     if (FAILED(hr))
         goto cleanup;
 
@@ -1268,9 +1268,9 @@ static void test_surface_interface_mismatch(void)
     viewport_set_background(device, viewport, background);
 
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
     color = get_surface_color(surface, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
 cleanup:
     if (viewport)
@@ -1296,7 +1296,7 @@ static void test_coop_level_threaded(void)
     create_window_thread(&p);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, p.window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     destroy_window_thread(&p);
     IDirectDraw2_Release(ddraw);
@@ -1352,7 +1352,7 @@ static void test_depth_blit(const GUID *device_guid)
     memset(&ddsd_existing, 0, sizeof(ddsd_existing));
     ddsd_existing.dwSize = sizeof(ddsd_existing);
     hr = IDirectDrawSurface_GetSurfaceDesc(ds1, &ddsd_existing);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ddsd_new.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
     ddsd_new.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
     if (is_software_device_type(device_guid))
@@ -1361,71 +1361,71 @@ static void test_depth_blit(const GUID *device_guid)
     ddsd_new.dwHeight = ddsd_existing.dwHeight;
     ddsd_new.ddpfPixelFormat = ddsd_existing.ddpfPixelFormat;
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd_new, &ds2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create a surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create a surface, hr %#lx.\n", hr);
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd_new, &ds3, NULL);
-    ok(SUCCEEDED(hr), "Failed to create a surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create a surface, hr %#lx.\n", hr);
 
     background = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f);
     viewport = create_viewport(device, 0, 0, ddsd_existing.dwWidth, ddsd_existing.dwHeight);
     viewport_set_background(device, viewport, background);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable z testing, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable z testing, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZFUNC, D3DCMP_LESSEQUAL);
-    ok(SUCCEEDED(hr), "Failed to set the z function, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set the z function, hr %#lx.\n", hr);
 
     U1(d3drect).x1 = U2(d3drect).y1 = 0;
     U3(d3drect).x2 = ddsd_existing.dwWidth; U4(d3drect).y2 = ddsd_existing.dwHeight;
     hr = IDirect3DViewport2_Clear(viewport, 1, &d3drect, D3DCLEAR_ZBUFFER);
-    ok(SUCCEEDED(hr), "Failed to clear the z buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear the z buffer, hr %#lx.\n", hr);
 
     /* Partial blit. */
     SetRect(&src_rect, 0, 0, 320, 240);
     SetRect(&dst_rect, 0, 0, 320, 240);
     hr = IDirectDrawSurface_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* Different locations. */
     SetRect(&src_rect, 0, 0, 320, 240);
     SetRect(&dst_rect, 320, 240, 640, 480);
     hr = IDirectDrawSurface_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* Stretched. */
     SetRect(&src_rect, 0, 0, 320, 240);
     SetRect(&dst_rect, 0, 0, 640, 480);
     hr = IDirectDrawSurface_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* Flipped. */
     SetRect(&src_rect, 0, 480, 640, 0);
     SetRect(&dst_rect, 0, 0, 640, 480);
     hr = IDirectDrawSurface_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     SetRect(&src_rect, 0, 0, 640, 480);
     SetRect(&dst_rect, 0, 480, 640, 0);
     hr = IDirectDrawSurface_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     /* Full, explicit. */
     SetRect(&src_rect, 0, 0, 640, 480);
     SetRect(&dst_rect, 0, 0, 640, 480);
     hr = IDirectDrawSurface_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* Depth -> color blit: Succeeds on Win7 + Radeon HD 5700, fails on WinXP + Radeon X1600 */
 
     /* Depth blit inside a BeginScene / EndScene pair */
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to start a scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to start a scene, hr %#lx.\n", hr);
     /* From the current depth stencil */
     hr = IDirectDrawSurface_Blt(ds2, NULL, ds1, NULL, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* To the current depth stencil */
     hr = IDirectDrawSurface_Blt(ds1, NULL, ds2, NULL, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* Between unbound surfaces */
     hr = IDirectDrawSurface_Blt(ds3, NULL, ds2, NULL, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end a scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end a scene, hr %#lx.\n", hr);
 
     /* Avoid changing the depth stencil, it doesn't work properly on Windows.
      * Instead use DDBLT_DEPTHFILL to clear the depth stencil. Unfortunately
@@ -1436,42 +1436,42 @@ static void test_depth_blit(const GUID *device_guid)
     U5(fx).dwFillDepth = 0;
     hr = IDirectDrawSurface_Blt(ds2, NULL, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
     ok(hr == D3D_OK || broken(is_software_device_type(device_guid)
-            && hr == 0x8876086c /* D3DERR_INVALIDCALL */), "Got unexpected hr %#x.\n", hr);
+            && hr == 0x8876086c /* D3DERR_INVALIDCALL */), "Got unexpected hr %#lx.\n", hr);
     if (hr != D3D_OK)
         depth_fill_broken = TRUE;
 
     /* This clears the Z buffer with 1.0 */
     hr = IDirect3DViewport2_Clear(viewport, 1, &d3drect, D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 80, 60);
     /* For some reason clears and colour fill blits randomly fail with software render target. */
     ok(color == 0x00ff0000 || broken(is_software_device_type(device_guid) && !color),
-            "Got unexpected colour 0x%08x.\n", color);
+            "Got unexpected colour 0x%08lx.\n", color);
     if (!color)
     {
         fill_surface(rt, 0xffff0000);
 
         color = get_surface_color(rt, 80, 60);
-        ok(color == 0x00ff0000, "Got unexpected colour 0x%08x.\n", color);
+        ok(color == 0x00ff0000, "Got unexpected colour 0x%08lx.\n", color);
     }
 
     SetRect(&dst_rect, 0, 0, 320, 240);
     hr = IDirectDrawSurface_Blt(ds1, &dst_rect, ds2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface_Release(ds3);
     IDirectDrawSurface_Release(ds2);
     IDirectDrawSurface_Release(ds1);
 
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, quad1, 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < 4; ++i)
     {
@@ -1481,7 +1481,7 @@ static void test_depth_blit(const GUID *device_guid)
             unsigned int y = 60 * ((2 * i) + 1);
             color = get_surface_color(rt, x, y);
             ok(compare_color(color, expected_colors[i][j], 1) || broken(depth_fill_broken && color == 0x0000ff00),
-                    "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected_colors[i][j], x, y, color);
+                    "Expected color 0x%08lx at %u,%u, got 0x%08lx.\n", expected_colors[i][j], x, y, color);
         }
     }
     IDirectDrawSurface_Release(rt);
@@ -1507,7 +1507,7 @@ static void test_texture_load_ckey(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -1516,13 +1516,13 @@ static void test_texture_load_ckey(void)
     ddsd.dwWidth = 128;
     ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &src, NULL);
-    ok(SUCCEEDED(hr), "Failed to create source texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create source texture, hr %#lx.\n", hr);
     ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to create destination texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create destination texture, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_QueryInterface(src, &IID_IDirect3DTexture, (void **)&src_tex);
-    ok(SUCCEEDED(hr) || hr == E_NOINTERFACE, "Failed to get Direct3DTexture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || hr == E_NOINTERFACE, "Failed to get Direct3DTexture interface, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
         /* 64 bit ddraw does not support d3d */
@@ -1530,11 +1530,11 @@ static void test_texture_load_ckey(void)
         goto done;
     }
     hr = IDirectDrawSurface_QueryInterface(dst, &IID_IDirect3DTexture, (void **)&dst_tex);
-    ok(SUCCEEDED(hr), "Failed to get Direct3DTexture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3DTexture interface, hr %#lx.\n", hr);
 
     /* No surface has a color key */
     hr = IDirect3DTexture_Load(dst_tex, src_tex);
-    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDCAPS), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDCAPS), "Got unexpected hr %#lx.\n", hr);
     if (FAILED(hr))
     {
         /* Testbot Windows NT VMs */
@@ -1544,43 +1544,43 @@ static void test_texture_load_ckey(void)
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0xdeadbeef;
     hr = IDirectDrawSurface_GetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
-    ok(ckey.dwColorSpaceLowValue == 0xdeadbeef, "dwColorSpaceLowValue is %#x.\n", ckey.dwColorSpaceLowValue);
-    ok(ckey.dwColorSpaceHighValue == 0xdeadbeef, "dwColorSpaceHighValue is %#x.\n", ckey.dwColorSpaceHighValue);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
+    ok(ckey.dwColorSpaceLowValue == 0xdeadbeef, "dwColorSpaceLowValue is %#lx.\n", ckey.dwColorSpaceLowValue);
+    ok(ckey.dwColorSpaceHighValue == 0xdeadbeef, "dwColorSpaceHighValue is %#lx.\n", ckey.dwColorSpaceHighValue);
 
     /* Source surface has a color key */
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirect3DTexture_Load(dst_tex, src_tex);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
-    ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#x.\n", ckey.dwColorSpaceLowValue);
-    ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
+    ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#lx.\n", ckey.dwColorSpaceLowValue);
+    ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#lx.\n", ckey.dwColorSpaceHighValue);
 
     /* Both surfaces have a color key: Dest ckey is overwritten */
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0x000000ff;
     hr = IDirectDrawSurface_SetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirect3DTexture_Load(dst_tex, src_tex);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
-    ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#x.\n", ckey.dwColorSpaceLowValue);
-    ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
+    ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#lx.\n", ckey.dwColorSpaceLowValue);
+    ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#lx.\n", ckey.dwColorSpaceHighValue);
 
     /* Only the destination has a color key: It is not deleted */
     hr = IDirectDrawSurface_SetColorKey(src, DDCKEY_SRCBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture_Load(dst_tex, src_tex);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
-    ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#x.\n", ckey.dwColorSpaceLowValue);
-    ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
+    ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#lx.\n", ckey.dwColorSpaceLowValue);
+    ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#lx.\n", ckey.dwColorSpaceHighValue);
 
 done:
     if (dst_tex) IDirect3DTexture_Release(dst_tex);
@@ -1638,7 +1638,7 @@ static void test_viewport_object(void)
     }
 
     hr = IDirectDraw2_QueryInterface(ddraw, &IID_IDirect3D2, (void **)&d3d);
-    ok(SUCCEEDED(hr) || hr == E_NOINTERFACE, "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || hr == E_NOINTERFACE, "Failed to get d3d interface, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
         skip("D3D interface is not available, skipping test.\n");
@@ -1648,106 +1648,106 @@ static void test_viewport_object(void)
     old_d3d_ref = get_refcount((IUnknown *)d3d);
 
     hr = IDirect3D2_CreateViewport(d3d, &viewport2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create viewport, hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *)viewport2);
-    ok(ref == 1, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 1, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount((IUnknown *)d3d);
-    ok(ref == old_d3d_ref, "Got unexpected refcount %u.\n", ref);
+    ok(ref == old_d3d_ref, "Got unexpected refcount %lu.\n", ref);
 
     memset(&desc, 0, sizeof(desc));
     hr = IDirect3DViewport2_GetViewport(viewport2, &desc.vp1);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     desc.vp1.dwSize = sizeof(desc.vp1) + 1;
     hr = IDirect3DViewport2_GetViewport(viewport2, &desc.vp1);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     desc.vp1.dwSize = sizeof(desc.vp1) - 1;
     hr = IDirect3DViewport2_GetViewport(viewport2, &desc.vp1);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     desc.vp1.dwSize = sizeof(desc.vp1);
     hr = IDirect3DViewport2_GetViewport(viewport2, &desc.vp1);
-    ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
-    ok(desc.vp1.dwSize == sizeof(desc.vp1), "Got unexpected dwSize %u.\n", desc.vp1.dwSize);
+    ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#lx.\n", hr);
+    ok(desc.vp1.dwSize == sizeof(desc.vp1), "Got unexpected dwSize %lu.\n", desc.vp1.dwSize);
     hr = IDirect3DViewport2_GetViewport2(viewport2, &desc.vp2);
-    ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
-    ok(desc.vp2.dwSize == sizeof(desc.vp2), "Got unexpected dwSize %u.\n", desc.vp2.dwSize);
+    ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#lx.\n", hr);
+    ok(desc.vp2.dwSize == sizeof(desc.vp2), "Got unexpected dwSize %lu.\n", desc.vp2.dwSize);
     desc.vp2.dwSize = sizeof(desc.vp2) + 1;
     hr = IDirect3DViewport2_GetViewport2(viewport2, &desc.vp2);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     gamma = (IDirectDrawGammaControl *)0xdeadbeef;
     hr = IDirect3DViewport2_QueryInterface(viewport2, &IID_IDirectDrawGammaControl, (void **)&gamma);
-    ok(hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
     ok(!gamma, "Interface not set to NULL by failed QI call: %p\n", gamma);
     /* NULL iid: Segfaults */
 
     hr = IDirect3DViewport2_QueryInterface(viewport2, &IID_IDirect3DViewport, (void **)&viewport);
-    ok(SUCCEEDED(hr), "Failed to QI IDirect3DViewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to QI IDirect3DViewport, hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *)viewport);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount((IUnknown *)viewport2);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
     IDirect3DViewport_Release(viewport);
     viewport = NULL;
 
     hr = IDirect3DViewport2_QueryInterface(viewport2, &IID_IDirect3DViewport3, (void **)&viewport3);
-    ok(SUCCEEDED(hr) || hr == E_NOINTERFACE, "Failed to QI IDirect3DViewport3, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || hr == E_NOINTERFACE, "Failed to QI IDirect3DViewport3, hr %#lx.\n", hr);
     if (viewport3)
     {
         ref = get_refcount((IUnknown *)viewport2);
-        ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+        ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
         ref = get_refcount((IUnknown *)viewport3);
-        ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+        ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
         IDirect3DViewport3_Release(viewport3);
     }
 
     hr = IDirect3DViewport2_QueryInterface(viewport2, &IID_IUnknown, (void **)&unknown);
-    ok(SUCCEEDED(hr), "Failed to QI IUnknown, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to QI IUnknown, hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *)viewport2);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount(unknown);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
     IUnknown_Release(unknown);
 
     hr = IDirect3DDevice2_DeleteViewport(device, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_GetCurrentViewport(device, NULL);
-    ok(hr == D3DERR_NOCURRENTVIEWPORT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOCURRENTVIEWPORT, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3D2_CreateViewport(d3d, &another_vp, NULL);
-    ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create viewport, hr %#lx.\n", hr);
 
     /* Setting a viewport not in the viewport list fails */
     hr = IDirect3DDevice2_SetCurrentViewport(device, another_vp);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* AddViewport(NULL): Segfault */
     hr = IDirect3DDevice2_AddViewport(device, viewport2);
-    ok(SUCCEEDED(hr), "Failed to add viewport to device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to add viewport to device, hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *) viewport2);
-    ok(ref == 2, "viewport2 refcount is %u.\n", ref);
+    ok(ref == 2, "viewport2 refcount is %lu.\n", ref);
     hr = IDirect3DDevice2_AddViewport(device, another_vp);
-    ok(SUCCEEDED(hr), "Failed to add viewport to device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to add viewport to device, hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *) another_vp);
-    ok(ref == 2, "another_vp refcount is %u.\n", ref);
+    ok(ref == 2, "another_vp refcount is %lu.\n", ref);
 
     test_vp = (IDirect3DViewport2 *) 0xbaadc0de;
     hr = IDirect3DDevice2_GetCurrentViewport(device, &test_vp);
-    ok(hr == D3DERR_NOCURRENTVIEWPORT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOCURRENTVIEWPORT, "Got unexpected hr %#lx.\n", hr);
     ok(test_vp == (IDirect3DViewport2 *) 0xbaadc0de, "Got unexpected pointer %p\n", test_vp);
 
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport2);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *) viewport2);
-    ok(ref == 3, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 3, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount((IUnknown *) device);
-    ok(ref == 1, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 1, "Got unexpected refcount %lu.\n", ref);
 
     test_vp = NULL;
     hr = IDirect3DDevice2_GetCurrentViewport(device, &test_vp);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(test_vp == viewport2, "Got unexpected viewport %p\n", test_vp);
     ref = get_refcount((IUnknown *) viewport2);
-    ok(ref == 4, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 4, "Got unexpected refcount %lu.\n", ref);
     if (test_vp)
         IDirect3DViewport2_Release(test_vp);
 
@@ -1755,43 +1755,43 @@ static void test_viewport_object(void)
 
     /* Cannot set the viewport to NULL */
     hr = IDirect3DDevice2_SetCurrentViewport(device, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Failed to set viewport to NULL, hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Failed to set viewport to NULL, hr %#lx.\n", hr);
     test_vp = NULL;
     hr = IDirect3DDevice2_GetCurrentViewport(device, &test_vp);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(test_vp == viewport2, "Got unexpected viewport %p\n", test_vp);
     if (test_vp)
         IDirect3DViewport2_Release(test_vp);
 
     /* SetCurrentViewport properly releases the old viewport's reference */
     hr = IDirect3DDevice2_SetCurrentViewport(device, another_vp);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *) viewport2);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount((IUnknown *) another_vp);
-    ok(ref == 3, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 3, "Got unexpected refcount %lu.\n", ref);
 
     /* Deleting the viewport removes the reference added by AddViewport, but not
      * the one added by SetCurrentViewport. */
     hr = IDirect3DDevice2_DeleteViewport(device, another_vp);
-    ok(SUCCEEDED(hr), "Failed to delete viewport from device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to delete viewport from device, hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *) another_vp);
-    todo_wine ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    todo_wine ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
 
     /* GetCurrentViewport fails though */
     test_vp = NULL;
     hr = IDirect3DDevice2_GetCurrentViewport(device, &test_vp);
-    ok(hr == D3DERR_NOCURRENTVIEWPORT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOCURRENTVIEWPORT, "Got unexpected hr %#lx.\n", hr);
     ok(!test_vp, "Got unexpected viewport %p\n", test_vp);
 
     /* Setting a different viewport does not free the leaked reference. How
      * do I get rid of it? Leak the viewport for now. */
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport2);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *) viewport2);
-    ok(ref == 3, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 3, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount((IUnknown *) another_vp);
-    todo_wine ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    todo_wine ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
 
     memset(&vp, 0, sizeof(vp));
     memset(&vp, 0, sizeof(vp2));
@@ -1810,29 +1810,29 @@ static void test_viewport_object(void)
     vp2.dvClipWidth = 2.0f;
     vp2.dvClipHeight = 2.0f;
     hr = IDirect3DViewport2_SetViewport(viewport2, &vp);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport2_SetViewport2(viewport2, &vp2);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     vp.dwSize = sizeof(vp);
     hr = IDirect3DViewport2_SetViewport(viewport2, &vp);
-    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#lx.\n", hr);
     vp2.dwSize = sizeof(vp2);
     hr = IDirect3DViewport2_SetViewport2(viewport2, &vp2);
-    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#lx.\n", hr);
 
     /* Destroying the device removes the viewport, but does not free the reference
      * added by SetCurrentViewport. */
     IDirect3DDevice2_Release(device);
     ref = get_refcount((IUnknown *) viewport2);
-    todo_wine ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    todo_wine ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
 
     vp.dwSize = sizeof(vp);
     hr = IDirect3DViewport2_SetViewport(viewport2, &vp);
-    ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#lx.\n", hr);
     vp2.dwSize = sizeof(vp2);
     hr = IDirect3DViewport2_SetViewport2(viewport2, &vp2);
-    ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DViewport2_Release(another_vp);
     IDirect3DViewport2_Release(viewport2);
@@ -1877,35 +1877,35 @@ static void test_zenable(const GUID *device_guid)
     viewport = create_viewport(device, 0, 0, 640, 480);
     viewport_set_background(device, viewport, background);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 80, 60);
     /* For some reason clears and colour fill blits randomly fail with software render target. */
     ok(color == 0x00ff0000 || broken(is_software_device_type(device_guid) && !color),
-            "Got unexpected colour 0x%08x.\n", color);
+            "Got unexpected colour 0x%08lx.\n", color);
     if (!color)
     {
         fill_surface(rt, 0xffff0000);
 
         color = get_surface_color(rt, 80, 60);
-        ok(color == 0x00ff0000, "Got unexpected colour 0x%08x.\n", color);
+        ok(color == 0x00ff0000, "Got unexpected colour 0x%08lx.\n", color);
     }
 
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_TLVERTEX, tquad, 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < 4; ++i)
     {
@@ -1915,7 +1915,7 @@ static void test_zenable(const GUID *device_guid)
             y = 60 * ((2 * i) + 1);
             color = get_surface_color(rt, x, y);
             ok(compare_color(color, 0x0000ff00, 1),
-                    "Expected color 0x0000ff00 at %u, %u, got 0x%08x.\n", x, y, color);
+                    "Expected color 0x0000ff00 at %u, %u, got 0x%08lx.\n", x, y, color);
         }
     }
     IDirectDrawSurface_Release(rt);
@@ -1993,7 +1993,7 @@ static void test_ck_rgba(const GUID *device_guid)
     viewport = create_viewport(device, 0, 0, 640, 480);
     viewport_set_background(device, viewport, background);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -2013,76 +2013,76 @@ static void test_ck_rgba(const GUID *device_guid)
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0xff00ff00;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0xff00ff00;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture2_GetHandle(texture, device, &texture_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3DTexture2_Release(texture);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, tests[i].color_key);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, tests[i].blend);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         memset(&fx, 0, sizeof(fx));
         fx.dwSize = sizeof(fx);
         U5(fx).dwFillColor = tests[i].fill_color;
         hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         /* RT clears are broken on Windows for software render target. */
         if (is_software_device_type(device_guid))
             fill_surface(rt, 0xffff0000);
 
         hr = IDirect3DDevice2_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_TLVERTEX, &tquad[0], 4, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice2_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, tests[i].result1, 2) || compare_color(color, tests[i].result1_broken, 1),
-                "Expected color 0x%08x for test %u, got 0x%08x.\n",
+                "Expected color 0x%08lx for test %u, got 0x%08lx.\n",
                 tests[i].result1, i, color);
 
         U5(fx).dwFillColor = 0xff0000ff;
         hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice2_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_TLVERTEX, &tquad[4], 4, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice2_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         /* This tests that fragments that are masked out by the color key are
          * discarded, instead of just fully transparent. */
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, tests[i].result2, 2) || compare_color(color, tests[i].result2_broken, 1),
-                "Expected color 0x%08x for test %u, got 0x%08x.\n",
+                "Expected color 0x%08lx for test %u, got 0x%08lx.\n",
                 tests[i].result2, i, color);
     }
 
     IDirectDrawSurface_Release(rt);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface);
     destroy_viewport(device, viewport);
     destroy_material(background);
@@ -2127,13 +2127,13 @@ static void test_ck_default(void)
     }
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     background = create_diffuse_material(device, 0.0, 1.0f, 0.0f, 1.0f);
     viewport = create_viewport(device, 0, 0, 640, 480);
     viewport_set_background(device, viewport, background);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -2150,52 +2150,52 @@ static void test_ck_default(void)
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x000000ff;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x000000ff;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirect3DTexture2_GetHandle(texture, device, &texture_handle);
-    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#lx.\n", hr);
     IDirect3DTexture_Release(texture);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 0x000000ff;
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle);
-    ok(SUCCEEDED(hr), "Failed to set texture handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture handle, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, &value);
-    ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
-    ok(!value, "Got unexpected color keying state %#x.\n", value);
+    ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
+    ok(!value, "Got unexpected color keying state %#lx.\n", value);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_TLVERTEX, &tquad[0], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable color keying, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable color keying, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_TLVERTEX, &tquad[0], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, &value);
-    ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
-    ok(!!value, "Got unexpected color keying state %#x.\n", value);
+    ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
+    ok(!!value, "Got unexpected color keying state %#lx.\n", value);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, 0);
-    ok(SUCCEEDED(hr), "Failed to set texture handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture handle, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface_Release(surface);
     destroy_viewport(device, viewport);
@@ -2238,20 +2238,20 @@ static void test_ck_complex(void)
     surface_desc.dwWidth = 128;
     surface_desc.dwHeight = 128;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
     color_key.dwColorSpaceLowValue = 0x0000ff00;
     color_key.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     memset(&color_key, 0, sizeof(color_key));
     hr = IDirectDrawSurface_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceLowValue);
-    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceHighValue);
 
     mipmap = surface;
@@ -2259,20 +2259,20 @@ static void test_ck_complex(void)
     for (i = 0; i < 7; ++i)
     {
         hr = IDirectDrawSurface_GetAttachedSurface(mipmap, &caps, &tmp);
-        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#lx.\n", i, hr);
 
         hr = IDirectDrawSurface_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-        ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x, i %u.\n", hr, i);
+        ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx, i %u.\n", hr, i);
         color_key.dwColorSpaceLowValue = 0x000000ff;
         color_key.dwColorSpaceHighValue = 0x000000ff;
         hr = IDirectDrawSurface_SetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-        ok(SUCCEEDED(hr), "Failed to set color key, hr %#x, i %u.\n", hr, i);
+        ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx, i %u.\n", hr, i);
         memset(&color_key, 0, sizeof(color_key));
         hr = IDirectDrawSurface_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-        ok(SUCCEEDED(hr), "Failed to get color key, hr %#x, i %u.\n", hr, i);
-        ok(color_key.dwColorSpaceLowValue == 0x000000ff, "Got unexpected value 0x%08x, i %u.\n",
+        ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx, i %u.\n", hr, i);
+        ok(color_key.dwColorSpaceLowValue == 0x000000ff, "Got unexpected value 0x%08lx, i %u.\n",
                 color_key.dwColorSpaceLowValue, i);
-        ok(color_key.dwColorSpaceHighValue == 0x000000ff, "Got unexpected value 0x%08x, i %u.\n",
+        ok(color_key.dwColorSpaceHighValue == 0x000000ff, "Got unexpected value 0x%08lx, i %u.\n",
                 color_key.dwColorSpaceHighValue, i);
 
         IDirectDrawSurface_Release(mipmap);
@@ -2281,17 +2281,17 @@ static void test_ck_complex(void)
 
     memset(&color_key, 0, sizeof(color_key));
     hr = IDirectDrawSurface_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceLowValue);
-    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceHighValue);
 
     hr = IDirectDrawSurface_GetAttachedSurface(mipmap, &caps, &tmp);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface_Release(mipmap);
     refcount = IDirectDrawSurface_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -2299,45 +2299,45 @@ static void test_ck_complex(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     surface_desc.dwBackBufferCount = 1;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
     color_key.dwColorSpaceLowValue = 0x0000ff00;
     color_key.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     memset(&color_key, 0, sizeof(color_key));
     hr = IDirectDrawSurface_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceLowValue);
-    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceHighValue);
 
     hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &tmp);
-    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x, i %u.\n", hr, i);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx, i %u.\n", hr, i);
     color_key.dwColorSpaceLowValue = 0x0000ff00;
     color_key.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface_SetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     memset(&color_key, 0, sizeof(color_key));
     hr = IDirectDrawSurface_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceLowValue);
-    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceHighValue);
 
     IDirectDrawSurface_Release(tmp);
 
     refcount = IDirectDrawSurface_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -2359,13 +2359,13 @@ static void test_qi(const char *test_name, IUnknown *base_iface,
     for (i = 0; i < entry_count; ++i)
     {
         hr = IUnknown_QueryInterface(base_iface, tests[i].iid, (void **)&iface1);
-        ok(hr == tests[i].hr, "Got hr %#x for test \"%s\" %u.\n", hr, test_name, i);
+        ok(hr == tests[i].hr, "Got hr %#lx for test \"%s\" %u.\n", hr, test_name, i);
         if (SUCCEEDED(hr))
         {
             for (j = 0; j < entry_count; ++j)
             {
                 hr = IUnknown_QueryInterface(iface1, tests[j].iid, (void **)&iface2);
-                ok(hr == tests[j].hr, "Got hr %#x for test \"%s\" %u, %u.\n", hr, test_name, i, j);
+                ok(hr == tests[j].hr, "Got hr %#lx for test \"%s\" %u, %u.\n", hr, test_name, i, j);
                 if (SUCCEEDED(hr))
                 {
                     expected_refcount = 0;
@@ -2374,7 +2374,7 @@ static void test_qi(const char *test_name, IUnknown *base_iface,
                     if (IsEqualGUID(tests[i].refcount_iid, tests[j].refcount_iid))
                         ++expected_refcount;
                     refcount = IUnknown_Release(iface2);
-                    ok(refcount == expected_refcount, "Got refcount %u for test \"%s\" %u, %u, expected %u.\n",
+                    ok(refcount == expected_refcount, "Got refcount %lu for test \"%s\" %u, %u, expected %lu.\n",
                             refcount, test_name, i, j, expected_refcount);
                 }
             }
@@ -2383,7 +2383,7 @@ static void test_qi(const char *test_name, IUnknown *base_iface,
             if (IsEqualGUID(refcount_iid, tests[i].refcount_iid))
                 ++expected_refcount;
             refcount = IUnknown_Release(iface1);
-            ok(refcount == expected_refcount, "Got refcount %u for test \"%s\" %u, expected %u.\n",
+            ok(refcount == expected_refcount, "Got refcount %lu for test \"%s\" %u, expected %lu.\n",
                     refcount, test_name, i, expected_refcount);
         }
     }
@@ -2466,9 +2466,9 @@ static void test_surface_qi(void)
     surface_desc.dwWidth = 512;
     surface_desc.dwHeight = 512;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, (IDirectDrawSurface **)0xdeadbeef, NULL);
-    ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     test_qi("surface_qi", (IUnknown *)surface, &IID_IDirectDrawSurface, tests, ARRAY_SIZE(tests));
 
@@ -2579,36 +2579,36 @@ static void test_wndproc(void)
             WS_MAXIMIZE | WS_CAPTION , 0, 0, 640, 480, 0, 0, 0, 0);
 
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     expect_messages = messages;
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     /* DDSCL_NORMAL doesn't. */
     ddraw = create_ddraw();
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     /* The original window proc is only restored by ddraw if the current
@@ -2616,53 +2616,53 @@ static void test_wndproc(void)
      * from DDSCL_NORMAL to DDSCL_EXCLUSIVE. */
     ddraw = create_ddraw();
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     ddraw_proc = proc;
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)DefWindowProcA, proc);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = SetWindowLongPtrA(window, GWLP_WNDPROC, ddraw_proc);
-    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)DefWindowProcA, proc);
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     ddraw = create_ddraw();
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)DefWindowProcA, proc);
 
     fix_wndproc(window, (LONG_PTR)test_proc);
@@ -2693,12 +2693,12 @@ static void test_window_style(void)
     SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    todo_wine ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n",
@@ -2710,9 +2710,9 @@ static void test_window_style(void)
     ok(ret, "Failed to set foreground window.\n");
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    todo_wine ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
@@ -2721,77 +2721,77 @@ static void test_window_style(void)
     ShowWindow(window, SW_HIDE);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_NOWINDOWCHANGES);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    todo_wine ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ShowWindow(window, SW_HIDE);
     tmp = GetWindowLongA(window, GWL_STYLE);
-    todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    todo_wine ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_NOWINDOWCHANGES);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ShowWindow(window, SW_HIDE);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     ShowWindow(window, SW_SHOW);
     ret = SetForegroundWindow(GetDesktopWindow());
@@ -2799,20 +2799,20 @@ static void test_window_style(void)
     SetActiveWindow(window);
     ok(GetActiveWindow() == window, "Unexpected active window.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n",
             wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r));
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     SetWindowPos(window, NULL, 0, 0, 100, 100, SWP_NOZORDER | SWP_NOACTIVATE);
     GetWindowRect(window, &r);
@@ -2822,13 +2822,13 @@ static void test_window_style(void)
     ret = SetForegroundWindow(window2);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n",
@@ -2837,46 +2837,46 @@ static void test_window_style(void)
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ShowWindow(window, SW_HIDE);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     ShowWindow(window, SW_SHOW);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE | WS_MINIMIZE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     DestroyWindow(window2);
     DestroyWindow(window);
@@ -2897,15 +2897,15 @@ static void test_redundant_mode_set(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw2_GetDisplayMode(ddraw, &surface_desc);
-    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw2_SetDisplayMode(ddraw, surface_desc.dwWidth, surface_desc.dwHeight,
             U1(surface_desc.ddpfPixelFormat).dwRGBBitCount, 0, 0);
-    ok(SUCCEEDED(hr), "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetDisplayMode failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &q);
     r = q;
@@ -2917,14 +2917,14 @@ static void test_redundant_mode_set(void)
 
     hr = IDirectDraw2_SetDisplayMode(ddraw, surface_desc.dwWidth, surface_desc.dwHeight,
             U1(surface_desc.ddpfPixelFormat).dwRGBBitCount, 0, 0);
-    ok(SUCCEEDED(hr), "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetDisplayMode failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &s);
     ok(EqualRect(&r, &s) || broken(EqualRect(&q, &s) /* Windows 10 */),
             "Expected %s, got %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&s));
 
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     DestroyWindow(window);
 }
@@ -3074,10 +3074,10 @@ static void test_coop_level_mode_set(void)
     memset(&devmode, 0, sizeof(devmode));
     devmode.dmSize = sizeof(devmode);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
 
     ret = save_display_modes(&original_modes, &display_count);
@@ -3088,9 +3088,9 @@ static void test_coop_level_mode_set(void)
 
     memset(&param, 0, sizeof(param));
     hr = IDirectDraw2_EnumDisplayModes(ddraw, 0, NULL, &param, test_coop_level_mode_set_enum_cb);
-    ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#lx.\n", hr);
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     if (!param.user32_height)
     {
@@ -3109,7 +3109,7 @@ static void test_coop_level_mode_set(void)
     devmode.dmPelsWidth = param.user32_width;
     devmode.dmPelsHeight = param.user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
@@ -3127,7 +3127,7 @@ static void test_coop_level_mode_set(void)
             0, 0, 100, 100, 0, 0, 0, 0);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &user32_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&user32_rect),
@@ -3139,12 +3139,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.user32_width, "Expected surface width %lu, got %lu.\n",
             param.user32_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.user32_height, "Expected surface height %lu, got %lu.\n",
             param.user32_height, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3157,16 +3157,16 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
-            "Expected screen size %ux%u, got %ux%u.\n",
+            "Expected screen size %lux%lu, got %lux%lu.\n",
             param.ddraw_width, param.ddraw_height, screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
@@ -3174,10 +3174,10 @@ static void test_coop_level_mode_set(void)
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.user32_width, "Expected surface width %lu, got %lu.\n",
             param.user32_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.user32_height, "Expected surface height %lu, got %lu.\n",
             param.user32_height, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
@@ -3187,12 +3187,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3205,16 +3205,16 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
-            "Expected screen size %ux%u, got %ux%u.\n",
+            "Expected screen size %lux%lu, got %lux%lu.\n",
             param.user32_width, param.user32_height, screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
@@ -3230,7 +3230,7 @@ static void test_coop_level_mode_set(void)
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
-            && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected screen size %ux%u.\n",
+            && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected screen size %lux%lu.\n",
             devmode.dmPelsWidth, devmode.dmPelsHeight);
 
     expect_messages = exclusive_focus_restore_messages;
@@ -3243,11 +3243,11 @@ static void test_coop_level_mode_set(void)
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == param.ddraw_width
-            && devmode.dmPelsHeight == param.ddraw_height, "Got unexpected screen size %ux%u.\n",
+            && devmode.dmPelsHeight == param.ddraw_height, "Got unexpected screen size %lux%lu.\n",
             devmode.dmPelsWidth, devmode.dmPelsHeight);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     /* Normally the primary should be restored here. Unfortunately this causes the
      * GetSurfaceDesc call after the next display mode change to crash on the Windows 8
      * testbot. Another Restore call would presumably avoid the crash, but it also moots
@@ -3269,7 +3269,7 @@ static void test_coop_level_mode_set(void)
     expect_messages = NULL;
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
     expect_messages = exclusive_messages;
@@ -3277,17 +3277,17 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw2_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     ok(screen_size.cx == registry_mode.dmPelsWidth
             && screen_size.cy == registry_mode.dmPelsHeight,
-            "Expected screen size %ux%u, got %ux%u.\n",
+            "Expected screen size %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
@@ -3295,16 +3295,16 @@ static void test_coop_level_mode_set(void)
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
     /* For Wine. */
     change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -3312,12 +3312,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3325,17 +3325,17 @@ static void test_coop_level_mode_set(void)
             wine_dbgstr_rect(&r));
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
@@ -3345,12 +3345,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3363,18 +3363,18 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
     devmode.dmPelsWidth = param.user32_width;
     devmode.dmPelsHeight = param.user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
     hr = IDirectDrawSurface_IsLost(primary);
-    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
@@ -3386,7 +3386,7 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
     if (hr == DDERR_NOEXCLUSIVEMODE /* NT4 testbot */)
     {
@@ -3395,25 +3395,25 @@ static void test_coop_level_mode_set(void)
         IDirectDraw2_Release(ddraw);
         goto done;
     }
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
@@ -3423,12 +3423,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3441,25 +3441,25 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw2_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
@@ -3467,11 +3467,11 @@ static void test_coop_level_mode_set(void)
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
             && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n",
+            "Expected resolution %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
             devmode.dmPelsWidth, devmode.dmPelsHeight);
     change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -3479,12 +3479,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3495,17 +3495,17 @@ static void test_coop_level_mode_set(void)
      * Resizing the window on mode changes is a property of DDSCL_EXCLUSIVE,
      * not DDSCL_FULLSCREEN. */
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
@@ -3515,12 +3515,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3533,18 +3533,18 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
     devmode.dmPelsWidth = param.user32_width;
     devmode.dmPelsHeight = param.user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
     hr = IDirectDrawSurface_IsLost(primary);
-    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
@@ -3556,27 +3556,27 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
@@ -3586,12 +3586,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3604,25 +3604,25 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw2_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
@@ -3630,11 +3630,11 @@ static void test_coop_level_mode_set(void)
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
             && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n",
+            "Expected resolution %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
             devmode.dmPelsWidth, devmode.dmPelsHeight);
     change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -3642,12 +3642,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
@@ -3657,9 +3657,9 @@ static void test_coop_level_mode_set(void)
 
     /* Changing the coop level from EXCLUSIVE to NORMAL restores the screen resolution */
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
     expect_messages = exclusive_messages;
@@ -3667,13 +3667,13 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     ok(screen_size.cx == registry_mode.dmPelsWidth
             && screen_size.cy == registry_mode.dmPelsHeight,
-            "Expected screen size %ux%u, got %ux%u.\n",
+            "Expected screen size %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
             screen_size.cx, screen_size.cy);
 
@@ -3687,23 +3687,23 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
     /* The screen restore is a property of DDSCL_EXCLUSIVE  */
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -3711,23 +3711,23 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
     hr = IDirectDraw2_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     /* If the window is changed at the same time, messages are sent to the new window. */
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
     expect_messages = exclusive_messages;
@@ -3737,14 +3737,14 @@ static void test_coop_level_mode_set(void)
     screen_size2.cy = 0;
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n",
             screen_size.cx, screen_size.cy);
     ok(screen_size2.cx == registry_mode.dmPelsWidth && screen_size2.cy == registry_mode.dmPelsHeight,
-            "Expected screen size 2 %ux%u, got %ux%u.\n",
+            "Expected screen size 2 %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size2.cx, screen_size2.cy);
 
     GetWindowRect(window, &r);
@@ -3760,17 +3760,17 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface_Release(primary);
 
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &ddraw_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&ddraw_rect),
@@ -3784,36 +3784,36 @@ static void test_coop_level_mode_set(void)
     devmode.dmPelsWidth = param.user32_width;
     devmode.dmPelsHeight = param.user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     memset(&devmode2, 0, sizeof(devmode2));
     devmode2.dmSize = sizeof(devmode2);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &registry_mode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
 
     /* Test that no mode restorations if no mode changes happened with fullscreen ddraw objects */
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &registry_mode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -3823,19 +3823,19 @@ static void test_coop_level_mode_set(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -3844,23 +3844,23 @@ static void test_coop_level_mode_set(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     hr = IDirectDraw2_RestoreDisplayMode(ddraw);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
 
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
 done:
     expect_messages = NULL;
@@ -3889,10 +3889,10 @@ static void test_coop_level_mode_set_multi(void)
     memset(&devmode, 0, sizeof(devmode));
     devmode.dmSize = sizeof(devmode);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
 
     ret = save_display_modes(&original_modes, &display_count);
@@ -3913,14 +3913,14 @@ static void test_coop_level_mode_set_multi(void)
         DestroyWindow(window);
         return;
     }
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 600, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw2_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3930,7 +3930,7 @@ static void test_coop_level_mode_set_multi(void)
      * the initial mode, before the first SetDisplayMode() call. */
     ddraw1 = create_ddraw();
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3938,21 +3938,21 @@ static void test_coop_level_mode_set_multi(void)
 
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw2_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw2_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3961,7 +3961,7 @@ static void test_coop_level_mode_set_multi(void)
     /* Regardless of release ordering. */
     ddraw1 = create_ddraw();
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3969,21 +3969,21 @@ static void test_coop_level_mode_set_multi(void)
 
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw2_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw2_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3993,21 +3993,21 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw2_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw2_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -4017,7 +4017,7 @@ static void test_coop_level_mode_set_multi(void)
      * restoring the display mode. */
     ddraw1 = create_ddraw();
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -4025,24 +4025,24 @@ static void test_coop_level_mode_set_multi(void)
 
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw2, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     ref = IDirectDraw2_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw2_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -4051,28 +4051,28 @@ static void test_coop_level_mode_set_multi(void)
     /* Exclusive mode blocks mode setting on other ddraw objects in general. */
     ddraw1 = create_ddraw();
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 600, "Got unexpected screen height %u.\n", h);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw1, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
 
     ref = IDirectDraw2_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw2_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -4100,7 +4100,7 @@ static void test_coop_level_mode_set_multi(void)
     memset(&old_devmode, 0, sizeof(old_devmode));
     old_devmode.dmSize = sizeof(old_devmode);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &old_devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
 
     devmode = old_devmode;
     while (EnumDisplaySettingsW(second_monitor_name, mode_idx++, &devmode))
@@ -4117,32 +4117,32 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ok(!!ddraw1, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw1, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     memset(&devmode2, 0, sizeof(devmode2));
     devmode2.dmSize = sizeof(devmode2);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     if (compare_mode_rect(&devmode2, &old_devmode))
     {
         skip("Failed to change display settings of the second monitor.\n");
         ref = IDirectDraw2_Release(ddraw1);
-        ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+        ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
         goto done;
     }
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw1, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     ref = IDirectDraw2_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     memset(&devmode3, 0, sizeof(devmode3));
     devmode3.dmSize = sizeof(devmode3);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode3);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode3, &devmode2), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -4152,19 +4152,19 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ok(!!ddraw1, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     ref = IDirectDraw2_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -4173,23 +4173,23 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ok(!!ddraw1, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     hr = IDirectDraw2_RestoreDisplayMode(ddraw1);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
 
     ref = IDirectDraw2_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
 
@@ -4197,24 +4197,24 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ok(!!ddraw1, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL,
             CDS_UPDATEREGISTRY | CDS_NORESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     ref = IDirectDraw2_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
+            "Expected resolution %lux%lu, got %lux%lu.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
             devmode2.dmPelsWidth, devmode2.dmPelsHeight);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
+            "Expected resolution %lux%lu, got %lux%lu.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
             devmode2.dmPelsWidth, devmode2.dmPelsHeight);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -4226,27 +4226,27 @@ static void test_coop_level_mode_set_multi(void)
     ddraw2 = create_ddraw();
     ok(!!ddraw2, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     hr = IDirectDraw2_RestoreDisplayMode(ddraw2);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
 
     ref = IDirectDraw2_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     ref = IDirectDraw2_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
 
@@ -4257,25 +4257,25 @@ static void test_coop_level_mode_set_multi(void)
     ddraw2 = create_ddraw();
     ok(!!ddraw2, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     ref = IDirectDraw2_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
 
     ref = IDirectDraw2_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
 done:
     DestroyWindow(window);
@@ -4293,16 +4293,16 @@ static void test_initialize(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw2_Initialize(ddraw, NULL);
-    ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x.\n", hr);
+    ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#lx.\n", hr);
     IDirectDraw2_Release(ddraw);
 
     CoInitialize(NULL);
     hr = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectDraw2, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to create IDirectDraw2 instance, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create IDirectDraw2 instance, hr %#lx.\n", hr);
     hr = IDirectDraw2_Initialize(ddraw, NULL);
-    ok(hr == DD_OK, "Initialize returned hr %#x, expected DD_OK.\n", hr);
+    ok(hr == DD_OK, "Initialize returned hr %#lx, expected DD_OK.\n", hr);
     hr = IDirectDraw2_Initialize(ddraw, NULL);
-    ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x, expected DDERR_ALREADYINITIALIZED.\n", hr);
+    ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#lx, expected DDERR_ALREADYINITIALIZED.\n", hr);
     IDirectDraw2_Release(ddraw);
     CoUninitialize();
 }
@@ -4323,20 +4323,20 @@ static void test_coop_level_surf_create(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     surface = (void *)0xdeadbeef;
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "Surface creation returned hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "Surface creation returned hr %#lx.\n", hr);
     ok(surface == (void *)0xdeadbeef, "Got unexpected surface %p.\n", surface);
 
     surface = (void *)0xdeadbeef;
     hr = IDirectDraw2_CreateSurface(ddraw, NULL, &surface, NULL);
-    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "Surface creation returned hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "Surface creation returned hr %#lx.\n", hr);
     ok(surface == (void *)0xdeadbeef, "Got unexpected surface %p.\n", surface);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     surface = (void *)0xdeadbeef;
     hr = IDirectDraw2_CreateSurface(ddraw, NULL, &surface, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Unexpected hr %#lx.\n", hr);
     ok(surface == (void *)0xdeadbeef, "Got unexpected surface %p.\n", surface);
 
     IDirectDraw2_Release(ddraw);
@@ -4354,9 +4354,9 @@ static void test_coop_level_multi_window(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(IsWindow(window1), "Window 1 was destroyed.\n");
     ok(IsWindow(window2), "Window 2 was destroyed.\n");
 
@@ -4389,7 +4389,7 @@ static void test_clear_rect_count(void)
     }
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     white = create_diffuse_material(device, 1.0f, 1.0f, 1.0f, 1.0f);
     red   = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f);
@@ -4398,24 +4398,24 @@ static void test_clear_rect_count(void)
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     viewport_set_background(device, viewport, white);
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     viewport_set_background(device, viewport, red);
     hr = IDirect3DViewport2_Clear(viewport, 0, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     viewport_set_background(device, viewport, green);
     hr = IDirect3DViewport2_Clear(viewport, 0, NULL, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     viewport_set_background(device, viewport, blue);
     hr = IDirect3DViewport2_Clear(viewport, 0, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 320, 240);
     ok(compare_color(color, 0x00ffffff, 1) || broken(compare_color(color, 0x000000ff, 1)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface_Release(rt);
     destroy_viewport(device, viewport);
@@ -4436,21 +4436,21 @@ static BOOL test_mode_restored(IDirectDraw2 *ddraw, HWND window)
     memset(&ddsd1, 0, sizeof(ddsd1));
     ddsd1.dwSize = sizeof(ddsd1);
     hr = IDirectDraw2_GetDisplayMode(ddraw, &ddsd1);
-    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     memset(&ddsd2, 0, sizeof(ddsd2));
     ddsd2.dwSize = sizeof(ddsd2);
     hr = IDirectDraw2_GetDisplayMode(ddraw, &ddsd2);
-    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDraw2_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     return ddsd1.dwWidth == ddsd2.dwWidth && ddsd1.dwHeight == ddsd2.dwHeight;
 }
@@ -4474,16 +4474,16 @@ static void test_coop_level_versions(void)
 
     /* A failing ddraw1::SetCooperativeLevel call does not have an effect */
     hr = IDirectDraw2_QueryInterface(ddraw2, &IID_IDirectDraw, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(FAILED(hr), "SetCooperativeLevel returned %#x, expected failure.\n", hr);
+    ok(FAILED(hr), "SetCooperativeLevel returned %#lx, expected failure.\n", hr);
     restored = test_mode_restored(ddraw2, window);
     ok(restored, "Display mode not restored after bad ddraw1::SetCooperativeLevel call\n");
 
     /* A successful one does */
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     restored = test_mode_restored(ddraw2, window);
     ok(!restored, "Display mode restored after good ddraw1::SetCooperativeLevel call\n");
 
@@ -4493,10 +4493,10 @@ static void test_coop_level_versions(void)
     ddraw2 = create_ddraw();
     ok(!!ddraw2, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_QueryInterface(ddraw2, &IID_IDirectDraw, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_SETFOCUSWINDOW);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     restored = test_mode_restored(ddraw2, window);
     ok(!restored, "Display mode restored after ddraw1::SetCooperativeLevel(SETFOCUSWINDOW) call\n");
 
@@ -4507,12 +4507,12 @@ static void test_coop_level_versions(void)
     ddraw2 = create_ddraw();
     ok(!!ddraw2, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_QueryInterface(ddraw2, &IID_IDirectDraw, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(FAILED(hr), "SetCooperativeLevel returned %#x, expected failure.\n", hr);
+    ok(FAILED(hr), "SetCooperativeLevel returned %#lx, expected failure.\n", hr);
     restored = test_mode_restored(ddraw2, window);
     ok(!restored, "Display mode restored after good-bad ddraw1::SetCooperativeLevel() call sequence\n");
 
@@ -4523,14 +4523,14 @@ static void test_coop_level_versions(void)
     ddraw2 = create_ddraw();
     ok(!!ddraw2, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_QueryInterface(ddraw2, &IID_IDirectDraw, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw2, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw2, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     restored = test_mode_restored(ddraw2, window);
     ok(!restored, "Display mode restored after ddraw1-ddraw2 SetCooperativeLevel() call sequence\n");
@@ -4541,10 +4541,10 @@ static void test_coop_level_versions(void)
     ddraw2 = create_ddraw();
     ok(!!ddraw2, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_QueryInterface(ddraw2, &IID_IDirectDraw, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw2, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -4552,7 +4552,7 @@ static void test_coop_level_versions(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     ddsd.dwWidth = ddsd.dwHeight = 8;
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "CreateSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateSurface failed, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface);
     restored = test_mode_restored(ddraw2, window);
     ok(restored, "Display mode not restored after ddraw1::CreateSurface() call\n");
@@ -4651,49 +4651,49 @@ static void test_lighting_interface_versions(void)
     }
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     emissive = create_emissive_material(device, 0.0f, 1.0f, 0.0f, 0.0f);
     hr = IDirect3DMaterial2_GetHandle(emissive, device, &mat_handle);
-    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetLightState(device, D3DLIGHTSTATE_MATERIAL, mat_handle);
-    ok(SUCCEEDED(hr), "Failed to set material state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set material state, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable z test, hr %#lx.\n", hr);
 
     background = create_diffuse_material(device, 0.1f, 0.1f, 0.1f, 0.1f);
     viewport_set_background(device, viewport, background);
 
     hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_SPECULARENABLE, &rs);
-    ok(SUCCEEDED(hr), "Failed to get specularenable render state, hr %#x.\n", hr);
-    ok(rs == TRUE, "Initial D3DRENDERSTATE_SPECULARENABLE is %#x, expected TRUE.\n", rs);
+    ok(SUCCEEDED(hr), "Failed to get specularenable render state, hr %#lx.\n", hr);
+    ok(rs == TRUE, "Initial D3DRENDERSTATE_SPECULARENABLE is %#lx, expected TRUE.\n", rs);
 
     for (i = 0; i < ARRAY_SIZE(tests); i++)
     {
         hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_LIGHTING, tests[i].d3drs_lighting);
-        ok(SUCCEEDED(hr), "Failed to set lighting render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set lighting render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_SPECULARENABLE,
                 tests[i].d3drs_specular);
-        ok(SUCCEEDED(hr), "Failed to set specularenable render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set specularenable render state, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice2_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
                 tests[i].vertextype, tests[i].data, 4, tests[i].draw_flags | D3DDP_WAIT);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice2_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, tests[i].color, 1),
-                "Got unexpected color 0x%08x, expected 0x%08x, test %u.\n",
+                "Got unexpected color 0x%08lx, expected 0x%08lx, test %u.\n",
                 color, tests[i].color, i);
     }
 
@@ -4703,7 +4703,7 @@ static void test_lighting_interface_versions(void)
     IDirectDrawSurface_Release(rt);
     IDirect3DDevice2_Release(device);
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Ddraw object not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -4725,7 +4725,7 @@ static LRESULT CALLBACK activateapp_test_proc(HWND hwnd, UINT message, WPARAM wp
             activateapp_testdata.received = FALSE;
             hr = IDirectDraw2_SetCooperativeLevel(activateapp_testdata.ddraw,
                     activateapp_testdata.window, activateapp_testdata.coop_level);
-            ok(SUCCEEDED(hr), "Recursive SetCooperativeLevel call failed, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Recursive SetCooperativeLevel call failed, hr %#lx.\n", hr);
             ok(!activateapp_testdata.received, "Received WM_ACTIVATEAPP during recursive SetCooperativeLevel call.\n");
         }
         activateapp_testdata.received = TRUE;
@@ -4757,31 +4757,31 @@ static void test_coop_level_activateapp(void)
     SetForegroundWindow(window);
     activateapp_testdata.received = FALSE;
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(!activateapp_testdata.received, "Received WM_ACTIVATEAPP although window was already active.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Exclusive with window not active. */
     SetForegroundWindow(GetDesktopWindow());
     activateapp_testdata.received = FALSE;
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(activateapp_testdata.received, "Expected WM_ACTIVATEAPP, but did not receive it.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Normal with window not active, then exclusive with the same window. */
     SetForegroundWindow(GetDesktopWindow());
     activateapp_testdata.received = FALSE;
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(!activateapp_testdata.received, "Received WM_ACTIVATEAPP when setting DDSCL_NORMAL.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(activateapp_testdata.received, "Expected WM_ACTIVATEAPP, but did not receive it.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Recursive set of DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN. */
     SetForegroundWindow(GetDesktopWindow());
@@ -4790,10 +4790,10 @@ static void test_coop_level_activateapp(void)
     activateapp_testdata.window = window;
     activateapp_testdata.coop_level = DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN;
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(activateapp_testdata.received, "Expected WM_ACTIVATEAPP, but did not receive it.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* The recursive call seems to have some bad effect on native ddraw, despite (apparently)
      * succeeding. Another switch to exclusive and back to normal is needed to release the
@@ -4801,9 +4801,9 @@ static void test_coop_level_activateapp(void)
      * WM_ACTIVATEAPP messages. */
     activateapp_testdata.ddraw = NULL;
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Setting DDSCL_NORMAL with recursive invocation. */
     SetForegroundWindow(GetDesktopWindow());
@@ -4812,7 +4812,7 @@ static void test_coop_level_activateapp(void)
     activateapp_testdata.window = window;
     activateapp_testdata.coop_level = DDSCL_NORMAL;
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(activateapp_testdata.received, "Expected WM_ACTIVATEAPP, but did not receive it.\n");
 
     /* DDraw is in exclusive mode now. */
@@ -4822,15 +4822,15 @@ static void test_coop_level_activateapp(void)
     ddsd.dwBackBufferCount = 1;
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface);
 
     /* Recover again, just to be sure. */
     activateapp_testdata.ddraw = NULL;
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     DestroyWindow(window);
     UnregisterClassA("ddraw_test_wndproc_wc", GetModuleHandleA(NULL));
@@ -4906,7 +4906,7 @@ static void test_unsupported_formats(void)
     {
         struct format_support_check check = {&formats[i].fmt, FALSE};
         hr = IDirect3DDevice2_EnumTextureFormats(device, test_unsupported_formats_cb, &check);
-        ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#lx.\n", hr);
 
         for (j = 0; j < ARRAY_SIZE(caps); j++)
         {
@@ -4925,7 +4925,7 @@ static void test_unsupported_formats(void)
 
             hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
             ok(SUCCEEDED(hr) == expect_success,
-                    "Got unexpected hr %#x for format %s, caps %#x, expected %s.\n",
+                    "Got unexpected hr %#lx for format %s, caps %#lx, expected %s.\n",
                     hr, formats[i].name, caps[j], expect_success ? "success" : "failure");
             if (FAILED(hr))
                 continue;
@@ -4933,7 +4933,7 @@ static void test_unsupported_formats(void)
             memset(&ddsd, 0, sizeof(ddsd));
             ddsd.dwSize = sizeof(ddsd);
             hr = IDirectDrawSurface_GetSurfaceDesc(surface, &ddsd);
-            ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
 
             if (caps[j] & DDSCAPS_VIDEOMEMORY)
                 expected_caps = DDSCAPS_VIDEOMEMORY;
@@ -4945,7 +4945,7 @@ static void test_unsupported_formats(void)
                 expected_caps = DDSCAPS_SYSTEMMEMORY;
 
             ok(ddsd.ddsCaps.dwCaps & expected_caps,
-                    "Expected capability %#x, format %s, input cap %#x.\n",
+                    "Expected capability %#lx, format %s, input cap %#lx.\n",
                     expected_caps, formats[i].name, caps[j]);
 
             IDirectDrawSurface_Release(surface);
@@ -5175,12 +5175,12 @@ static void test_rt_caps(const GUID *device_guid)
 
     memset(palette_entries, 0, sizeof(palette_entries));
     hr = IDirectDraw2_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, palette_entries, &palette, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw2_GetCaps(ddraw, &hal_caps, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
@@ -5215,7 +5215,7 @@ static void test_rt_caps(const GUID *device_guid)
         hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
         ok(hr == expected_hr || broken(test_data[i].create_may_fail
                 || (software_device && test_data[i].pf == &p8_fmt && hr == DDERR_INVALIDPIXELFORMAT)),
-                "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+                "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
         if (FAILED(hr))
             continue;
 
@@ -5232,7 +5232,7 @@ static void test_rt_caps(const GUID *device_guid)
                 && surface_desc.ddsCaps.dwCaps == (caps_in | DDSCAPS_SYSTEMMEMORY))
                 || (software_device && caps_in & DDSCAPS_ZBUFFER
                 && surface_desc.ddsCaps.dwCaps == (caps_in | DDSCAPS_SYSTEMMEMORY)),
-                "Got unexpected caps %#x, expected %#x, test %u, software_device %u.\n",
+                "Got unexpected caps %#lx, expected %#lx, test %u, software_device %u.\n",
                 surface_desc.ddsCaps.dwCaps, expected_caps, i, software_device);
 
         hr = IDirect3D2_CreateDevice(d3d, device_guid, surface, &device);
@@ -5240,30 +5240,30 @@ static void test_rt_caps(const GUID *device_guid)
         ok((!software_device && hr == test_data[i].create_device_hr)
                 || (software_device && (hr == (test_data[i].create_device_hr == D3DERR_SURFACENOTINVIDMEM
                 ? DD_OK : test_data[i].create_device_hr))),
-                "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+                "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
 
         if (FAILED(hr))
         {
             if (hr == DDERR_NOPALETTEATTACHED)
             {
                 hr = IDirectDrawSurface_SetPalette(surface, palette);
-                ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+                ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
                 hr = IDirect3D2_CreateDevice(d3d, device_guid, surface, &device);
                 if (software_device)
                     todo_wine
-                    ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n",
+                    ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n",
                             hr, i, software_device);
                 else if (surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)
-                    ok(hr == DDERR_INVALIDPIXELFORMAT, "Got unexpected hr %#x, test %u, software_device %u.\n",
+                    ok(hr == DDERR_INVALIDPIXELFORMAT, "Got unexpected hr %#lx, test %u, software_device %u.\n",
                             hr, i, software_device);
                 else
-                    ok(hr == D3DERR_SURFACENOTINVIDMEM, "Got unexpected hr %#x, test %u, software_device %u.\n",
+                    ok(hr == D3DERR_SURFACENOTINVIDMEM, "Got unexpected hr %#lx, test %u, software_device %u.\n",
                             hr, i, software_device);
 
                 if (hr == DD_OK)
                 {
                     refcount = IDirect3DDevice2_Release(device);
-                    ok(!refcount, "Test %u: The device was not properly freed, refcount %u.\n", i, refcount);
+                    ok(!refcount, "Test %u: The device was not properly freed, refcount %lu.\n", i, refcount);
                 }
             }
             IDirectDrawSurface_Release(surface);
@@ -5275,10 +5275,10 @@ static void test_rt_caps(const GUID *device_guid)
             surface_desc.dwWidth = 640;
             surface_desc.dwHeight = 480;
             hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+            ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
 
             hr = IDirect3D2_CreateDevice(d3d, device_guid, surface, &device);
-            ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+            ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
         }
 
         memset(&surface_desc, 0, sizeof(surface_desc));
@@ -5298,12 +5298,12 @@ static void test_rt_caps(const GUID *device_guid)
         surface_desc.dwWidth = 640;
         surface_desc.dwHeight = 480;
         hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &rt, NULL);
-        ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+        ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
 
         hr = IDirect3DDevice2_SetRenderTarget(device, rt, 0);
         ok(hr == test_data[i].set_rt_hr  || (software_device && hr == DDERR_NOPALETTEATTACHED)
                 || broken(hr == test_data[i].alternative_set_rt_hr),
-                "Got unexpected hr %#x, test %u, software_device %u.\n",
+                "Got unexpected hr %#lx, test %u, software_device %u.\n",
                 hr, i, software_device);
 
         if (SUCCEEDED(hr) || hr == DDERR_INVALIDPIXELFORMAT)
@@ -5316,19 +5316,19 @@ static void test_rt_caps(const GUID *device_guid)
         if (hr == DDERR_INVALIDPIXELFORMAT)
         {
             refcount = IDirectDrawSurface_AddRef(rt);
-            ok(refcount == 2, "Test %u: Got unexpected refcount %u.\n", i, refcount);
+            ok(refcount == 2, "Test %u: Got unexpected refcount %lu.\n", i, refcount);
         }
 
         hr = IDirect3DDevice2_GetRenderTarget(device, &tmp);
-        ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+        ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
         ok(tmp == expected_rt, "Got unexpected rt %p, test %u, software_device %u.\n", tmp, i, software_device);
 
         IDirectDrawSurface_Release(tmp);
         IDirectDrawSurface_Release(rt);
         refcount = IDirect3DDevice2_Release(device);
-        ok(refcount == 0, "Test %u: The device was not properly freed, refcount %u.\n", i, refcount);
+        ok(refcount == 0, "Test %u: The device was not properly freed, refcount %lu.\n", i, refcount);
         refcount = IDirectDrawSurface_Release(surface);
-        ok(refcount == 0, "Test %u: The surface was not properly freed, refcount %u.\n", i, refcount);
+        ok(refcount == 0, "Test %u: The surface was not properly freed, refcount %lu.\n", i, refcount);
     }
 
     IDirectDrawPalette_Release(palette);
@@ -5336,7 +5336,7 @@ static void test_rt_caps(const GUID *device_guid)
 
 done:
     refcount = IDirectDraw2_Release(ddraw);
-    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -5461,7 +5461,7 @@ static void test_primary_caps(void)
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, test_data[i].coop_level);
-        ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
@@ -5471,23 +5471,23 @@ static void test_primary_caps(void)
         surface_desc.ddsCaps.dwCaps = test_data[i].caps_in;
         surface_desc.dwBackBufferCount = test_data[i].back_buffer_count;
         hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
         if (FAILED(hr))
             continue;
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#lx.\n", i, hr);
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == test_data[i].caps_out,
-                "Test %u: Got unexpected caps %#x, expected %#x.\n",
+                "Test %u: Got unexpected caps %#lx, expected %#lx.\n",
                 i, surface_desc.ddsCaps.dwCaps, test_data[i].caps_out);
 
         IDirectDrawSurface_Release(surface);
     }
 
     refcount = IDirectDraw2_Release(ddraw);
-    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -5572,27 +5572,27 @@ static void test_surface_lock(void)
         ddsd.ddsCaps.dwCaps = tests[i].caps;
 
         hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, type %s, hr %#x.\n", tests[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to create surface, type %s, hr %#lx.\n", tests[i].name, hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface_Lock(surface, NULL, &ddsd, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, type %s, hr %#x.\n", tests[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, type %s, hr %#lx.\n", tests[i].name, hr);
         if (SUCCEEDED(hr))
         {
             hr = IDirectDrawSurface_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, type %s, hr %#x.\n", tests[i].name, hr);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, type %s, hr %#lx.\n", tests[i].name, hr);
         }
 
         memset(&ddsd, 0, sizeof(ddsd));
         hr = IDirectDrawSurface_Lock(surface, NULL, &ddsd, DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x, type %s.\n", hr, tests[i].name);
+        ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx, type %s.\n", hr, tests[i].name);
 
         IDirectDrawSurface_Release(surface);
     }
 
     refcount = IDirectDraw2_Release(ddraw);
-    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -5643,7 +5643,7 @@ static void test_surface_discard(void)
         }
 
         hr = IDirect3DDevice2_GetRenderTarget(device, &target);
-        ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
@@ -5661,29 +5661,29 @@ static void test_surface_discard(void)
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface_Lock(surface, NULL, &ddsd, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         addr = ddsd.lpSurface;
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface_Lock(surface, NULL, &ddsd, DDLOCK_DISCARDCONTENTS | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr) , "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr) , "Failed to lock surface, hr %#lx.\n", hr);
         discarded = ddsd.lpSurface != addr;
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         hr = IDirectDrawSurface_Blt(target, NULL, surface, NULL, DDBLT_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface_Lock(surface, NULL, &ddsd, DDLOCK_DISCARDCONTENTS | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         discarded |= ddsd.lpSurface != addr;
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         IDirectDrawSurface_Release(surface);
 
@@ -5731,7 +5731,7 @@ static void test_flip(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
@@ -5754,90 +5754,90 @@ static void test_flip(void)
         surface_desc.dwHeight = 512;
         surface_desc.dwBackBufferCount = 3;
         hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
 
         surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_FLIP;
         surface_desc.dwFlags |= DDSD_BACKBUFFERCOUNT;
         hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
 
         surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_COMPLEX;
         surface_desc.ddsCaps.dwCaps |= DDSCAPS_FLIP;
         hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
 
         surface_desc.ddsCaps.dwCaps |= DDSCAPS_COMPLEX;
         hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
         todo_wine_if(test_data[i].caps & DDSCAPS_TEXTURE)
-            ok(SUCCEEDED(hr), "%s: Failed to create surface, hr %#x.\n", test_data[i].name, hr);
+            ok(SUCCEEDED(hr), "%s: Failed to create surface, hr %#lx.\n", test_data[i].name, hr);
         if (FAILED(hr))
             continue;
 
         hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-        ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_IsLost(frontbuffer);
-        ok(hr == DD_OK, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DD_OK, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Flip(frontbuffer, NULL, DDFLIP_WAIT);
         if (test_data[i].caps & DDSCAPS_PRIMARYSURFACE)
-            ok(hr == DDERR_NOEXCLUSIVEMODE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+            ok(hr == DDERR_NOEXCLUSIVEMODE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         else
-            ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+            ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-        ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_IsLost(frontbuffer);
-        todo_wine ok(hr == DDERR_SURFACELOST, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        todo_wine ok(hr == DDERR_SURFACELOST, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = restore_surfaces(ddraw);
-        ok(SUCCEEDED(hr), "%s: Failed to restore surfaces, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to restore surfaces, hr %#lx.\n", test_data[i].name, hr);
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface_GetSurfaceDesc(frontbuffer, &surface_desc);
-        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#lx.\n", test_data[i].name, hr);
         expected_caps = DDSCAPS_FRONTBUFFER | DDSCAPS_COMPLEX | DDSCAPS_FLIP | test_data[i].caps;
         if (test_data[i].caps & DDSCAPS_PRIMARYSURFACE)
             expected_caps |= DDSCAPS_VISIBLE;
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == expected_caps,
-                "%s: Got unexpected caps %#x.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
+                "%s: Got unexpected caps %#lx.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
         sysmem_primary = surface_desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY;
 
         hr = IDirectDrawSurface_GetAttachedSurface(frontbuffer, &caps, &backbuffer1);
-        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#lx.\n", test_data[i].name, hr);
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface_GetSurfaceDesc(backbuffer1, &surface_desc);
-        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#x.\n", test_data[i].name, hr);
-        ok(!surface_desc.dwBackBufferCount, "%s: Got unexpected back buffer count %u.\n",
+        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#lx.\n", test_data[i].name, hr);
+        ok(!surface_desc.dwBackBufferCount, "%s: Got unexpected back buffer count %lu.\n",
                 test_data[i].name, surface_desc.dwBackBufferCount);
         expected_caps &= ~(DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER);
         expected_caps |= DDSCAPS_BACKBUFFER;
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == expected_caps,
-                "%s: Got unexpected caps %#x.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
+                "%s: Got unexpected caps %#lx.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
 
         hr = IDirectDrawSurface_GetAttachedSurface(backbuffer1, &caps, &backbuffer2);
-        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#lx.\n", test_data[i].name, hr);
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface_GetSurfaceDesc(backbuffer2, &surface_desc);
-        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#x.\n", test_data[i].name, hr);
-        ok(!surface_desc.dwBackBufferCount, "%s: Got unexpected back buffer count %u.\n",
+        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#lx.\n", test_data[i].name, hr);
+        ok(!surface_desc.dwBackBufferCount, "%s: Got unexpected back buffer count %lu.\n",
                 test_data[i].name, surface_desc.dwBackBufferCount);
         expected_caps &= ~DDSCAPS_BACKBUFFER;
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == expected_caps,
-                "%s: Got unexpected caps %#x.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
+                "%s: Got unexpected caps %#lx.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
 
         hr = IDirectDrawSurface_GetAttachedSurface(backbuffer2, &caps, &backbuffer3);
-        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#lx.\n", test_data[i].name, hr);
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface_GetSurfaceDesc(backbuffer3, &surface_desc);
-        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#x.\n", test_data[i].name, hr);
-        ok(!surface_desc.dwBackBufferCount, "%s: Got unexpected back buffer count %u.\n",
+        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#lx.\n", test_data[i].name, hr);
+        ok(!surface_desc.dwBackBufferCount, "%s: Got unexpected back buffer count %lu.\n",
                 test_data[i].name, surface_desc.dwBackBufferCount);
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == expected_caps,
-                "%s: Got unexpected caps %#x.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
+                "%s: Got unexpected caps %#lx.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
 
         hr = IDirectDrawSurface_GetAttachedSurface(backbuffer3, &caps, &surface);
-        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#lx.\n", test_data[i].name, hr);
         ok(surface == frontbuffer, "%s: Got unexpected surface %p, expected %p.\n",
                 test_data[i].name, surface, frontbuffer);
         IDirectDrawSurface_Release(surface);
@@ -5849,19 +5849,19 @@ static void test_flip(void)
         surface_desc.dwWidth = 640;
         surface_desc.dwHeight = 480;
         hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(SUCCEEDED(hr), "%s: Failed to create surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to create surface, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Flip(frontbuffer, surface, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         IDirectDrawSurface_Release(surface);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, frontbuffer, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Flip(backbuffer1, NULL, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Flip(backbuffer2, NULL, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Flip(backbuffer3, NULL, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
 
         /* The Nvidia Geforce 7 driver cannot do a color fill on a texture backbuffer after
          * the backbuffer has been locked or GetSurfaceDesc has been called. Do it ourselves
@@ -5871,59 +5871,59 @@ static void test_flip(void)
         fill_surface(backbuffer3, 0xff0000ff);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, NULL, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
         /* The testbot seems to just copy the contents of one surface to all the
          * others, instead of properly flipping. */
         ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
-        ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer3, 0xffff0000);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, NULL, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
         ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
-        ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer3, 0xff00ff00);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, NULL, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
         ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
-        ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer3, 0xff0000ff);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, backbuffer1, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer2, 320, 240);
         ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer3, 320, 240);
-        ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer1, 0xffff0000);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, backbuffer2, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
-        ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer3, 320, 240);
         ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer2, 0xff00ff00);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, backbuffer3, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
         ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
-        ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
 
         IDirectDrawSurface_Release(backbuffer3);
         IDirectDrawSurface_Release(backbuffer2);
@@ -5932,7 +5932,7 @@ static void test_flip(void)
     }
 
     refcount = IDirectDraw2_Release(ddraw);
-    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -5970,7 +5970,7 @@ static void test_set_surface_desc(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
@@ -5985,131 +5985,131 @@ static void test_set_surface_desc(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3);
-    ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface3 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface3 interface, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     /* Redundantly setting the same lpSurface is not an error. */
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
     hr = IDirectDrawSurface3_GetSurfaceDesc(surface3, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!(ddsd.dwFlags & DDSD_LPSURFACE), "DDSD_LPSURFACE is set.\n");
     ok(ddsd.lpSurface == NULL, "lpSurface is %p, expected NULL.\n", ddsd.lpSurface);
 
     hr = IDirectDrawSurface3_Lock(surface3, NULL, &ddsd, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ok(!(ddsd.dwFlags & DDSD_LPSURFACE), "DDSD_LPSURFACE is set.\n");
     ok(ddsd.lpSurface == data, "lpSurface is %p, expected %p.\n", data, data);
     hr = IDirectDrawSurface3_Unlock(surface3, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 1);
-    ok(hr == DDERR_INVALIDPARAMS, "SetSurfaceDesc with flags=1 returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "SetSurfaceDesc with flags=1 returned %#lx.\n", hr);
 
     ddsd.lpSurface = NULL;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting lpSurface=NULL returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting lpSurface=NULL returned %#lx.\n", hr);
 
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, NULL, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "SetSurfaceDesc with NULL desc returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "SetSurfaceDesc with NULL desc returned %#lx.\n", hr);
 
     hr = IDirectDrawSurface3_GetSurfaceDesc(surface3, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(ddsd.ddsCaps.dwCaps == (DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN),
-            "Got unexpected caps %#x.\n", ddsd.ddsCaps.dwCaps);
+            "Got unexpected caps %#lx.\n", ddsd.ddsCaps.dwCaps);
 
     /* Setting the caps is an error. This also means the original description cannot be reapplied. */
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting the original desc returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting the original desc returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_CAPS;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting DDSD_CAPS returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting DDSD_CAPS returned %#lx.\n", hr);
 
     /* dwCaps = 0 is allowed, but ignored. */
     ddsd.dwFlags = DDSD_CAPS | DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDCAPS, "Setting DDSD_CAPS returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDCAPS, "Setting DDSD_CAPS returned %#lx.\n", hr);
     ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDCAPS, "Setting DDSD_CAPS returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDCAPS, "Setting DDSD_CAPS returned %#lx.\n", hr);
     ddsd.ddsCaps.dwCaps = 0;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface3_GetSurfaceDesc(surface3, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(ddsd.ddsCaps.dwCaps == (DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN),
-            "Got unexpected caps %#x.\n", ddsd.ddsCaps.dwCaps);
+            "Got unexpected caps %#lx.\n", ddsd.ddsCaps.dwCaps);
 
     /* Setting the height is allowed, but it cannot be set to 0, and only if LPSURFACE is set too. */
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_HEIGHT;
     ddsd.dwHeight = 16;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting height without lpSurface returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting height without lpSurface returned %#lx.\n", hr);
 
     ddsd.lpSurface = data;
     ddsd.dwFlags = DDSD_HEIGHT | DDSD_LPSURFACE;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     ddsd.dwHeight = 0;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting height=0 returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting height=0 returned %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     hr = IDirectDrawSurface3_GetSurfaceDesc(surface3, &ddsd);
-    ok(SUCCEEDED(hr), "GetSurfaceDesc failed, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == 8, "SetSurfaceDesc: Expected width 8, got %u.\n", ddsd.dwWidth);
-    ok(ddsd.dwHeight == 16, "SetSurfaceDesc: Expected height 16, got %u.\n", ddsd.dwHeight);
+    ok(SUCCEEDED(hr), "GetSurfaceDesc failed, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == 8, "SetSurfaceDesc: Expected width 8, got %lu.\n", ddsd.dwWidth);
+    ok(ddsd.dwHeight == 16, "SetSurfaceDesc: Expected height 16, got %lu.\n", ddsd.dwHeight);
 
     /* Pitch and width can be set, but only together, and only with LPSURFACE. They must not be 0. */
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_PITCH;
     U1(ddsd).lPitch = 8 * 4;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting pitch without lpSurface or width returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting pitch without lpSurface or width returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_WIDTH;
     ddsd.dwWidth = 16;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting width without lpSurface or pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting width without lpSurface or pitch returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_PITCH | DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting pitch and lpSurface without width returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting pitch and lpSurface without width returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_WIDTH | DDSD_LPSURFACE;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting width and lpSurface without pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting width and lpSurface without pitch returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_WIDTH | DDSD_PITCH | DDSD_LPSURFACE;
     U1(ddsd).lPitch = 16 * 4;
     ddsd.dwWidth = 16;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     hr = IDirectDrawSurface3_GetSurfaceDesc(surface3, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == 16, "SetSurfaceDesc: Expected width 8, got %u.\n", ddsd.dwWidth);
-    ok(ddsd.dwHeight == 16, "SetSurfaceDesc: Expected height 16, got %u.\n", ddsd.dwHeight);
-    ok(U1(ddsd).lPitch == 16 * 4, "SetSurfaceDesc: Expected pitch 64, got %u.\n", U1(ddsd).lPitch);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == 16, "SetSurfaceDesc: Expected width 8, got %lu.\n", ddsd.dwWidth);
+    ok(ddsd.dwHeight == 16, "SetSurfaceDesc: Expected height 16, got %lu.\n", ddsd.dwHeight);
+    ok(U1(ddsd).lPitch == 16 * 4, "SetSurfaceDesc: Expected pitch 64, got %lu.\n", U1(ddsd).lPitch);
 
     /* The pitch must be 32 bit aligned and > 0, but is not verified for sanity otherwise.
      *
@@ -6118,27 +6118,27 @@ static void test_set_surface_desc(void)
     U1(ddsd).lPitch = 4 * 4;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDPARAMS), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDPARAMS), "Failed to set surface desc, hr %#lx.\n", hr);
 
     U1(ddsd).lPitch = 4;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDPARAMS), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDPARAMS), "Failed to set surface desc, hr %#lx.\n", hr);
 
     U1(ddsd).lPitch = 16 * 4 + 1;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting misaligned pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting misaligned pitch returned %#lx.\n", hr);
 
     U1(ddsd).lPitch = 16 * 4 + 3;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting misaligned pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting misaligned pitch returned %#lx.\n", hr);
 
     U1(ddsd).lPitch = -4;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting negative pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting negative pitch returned %#lx.\n", hr);
 
     U1(ddsd).lPitch = 16 * 4;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_WIDTH | DDSD_PITCH | DDSD_LPSURFACE;
@@ -6146,13 +6146,13 @@ static void test_set_surface_desc(void)
     ddsd.dwWidth = 16;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting zero pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting zero pitch returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_WIDTH | DDSD_PITCH | DDSD_LPSURFACE;
     U1(ddsd).lPitch = 16 * 4;
     ddsd.dwWidth = 0;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting zero width returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting zero width returned %#lx.\n", hr);
 
     /* Setting the pixelformat without LPSURFACE is an error, but with LPSURFACE it works. */
     ddsd.dwFlags = DDSD_PIXELFORMAT;
@@ -6163,11 +6163,11 @@ static void test_set_surface_desc(void)
     U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
     U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting the pixel format returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting the pixel format returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_LPSURFACE;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     /* Can't set color keys. */
     reset_ddsd(&ddsd);
@@ -6175,12 +6175,12 @@ static void test_set_surface_desc(void)
     ddsd.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00ff0000;
     ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00ff0000;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting ddckCKSrcBlt returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting ddckCKSrcBlt returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_CKSRCBLT | DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting ddckCKSrcBlt returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting ddckCKSrcBlt returned %#lx.\n", hr);
 
     IDirectDrawSurface3_Release(surface3);
 
@@ -6192,7 +6192,7 @@ static void test_set_surface_desc(void)
     U2(ddsd).dwMipMapCount = 3;
     ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW || hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW || hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
 
     if (FAILED(hr))
     {
@@ -6201,19 +6201,19 @@ static void test_set_surface_desc(void)
     else
     {
         hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         IDirectDrawSurface_Release(surface);
 
         /* Changing surface desc for mipmap fails even without changing any
          * parameters. */
         hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-        ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#lx.\n", hr);
 
         reset_ddsd(&ddsd);
         ddsd.dwFlags = DDSD_LPSURFACE;
         ddsd.lpSurface = data;
         hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-        ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#lx.\n", hr);
         IDirectDrawSurface3_Release(surface3);
     }
 
@@ -6226,7 +6226,7 @@ static void test_set_surface_desc(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW || hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW || hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
 
     if (hr == DD_OK)
     {
@@ -6234,15 +6234,15 @@ static void test_set_surface_desc(void)
         IDirectDrawSurface3 *surface2;
 
         hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         IDirectDrawSurface_Release(surface);
 
         hr = IDirectDrawSurface3_GetAttachedSurface(surface3, &caps, &surface2);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         reset_ddsd(&ddsd);
         hr = IDirectDrawSurface3_GetSurfaceDesc(surface2, &ddsd);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-        ok(ddsd.dwWidth == 4, "Got unexpected dwWidth %u.\n", ddsd.dwWidth);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+        ok(ddsd.dwWidth == 4, "Got unexpected dwWidth %lu.\n", ddsd.dwWidth);
 
         reset_ddsd(&ddsd);
         ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH | DDSD_LPSURFACE;
@@ -6251,7 +6251,7 @@ static void test_set_surface_desc(void)
         U1(ddsd).lPitch = 16 * 4;
         ddsd.lpSurface = data;
         hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-        todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        todo_wine ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         reset_ddsd(&ddsd);
         ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH | DDSD_LPSURFACE;
@@ -6260,13 +6260,13 @@ static void test_set_surface_desc(void)
         U1(ddsd).lPitch = 8 * 4;
         ddsd.lpSurface = data;
         hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         if (0)
         {
             /* _Lock causes access violation on Windows. */
             reset_ddsd(&ddsd);
             hr = IDirectDrawSurface3_Lock(surface2, NULL, &ddsd, DDLOCK_WAIT, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             IDirectDrawSurface3_Unlock(surface2, NULL);
         }
 
@@ -6280,7 +6280,7 @@ static void test_set_surface_desc(void)
             U1(ddsd).lPitch = 4 * 4;
             ddsd.lpSurface = data;
             hr = IDirectDrawSurface3_SetSurfaceDesc(surface2, &ddsd, 0);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         }
         IDirectDrawSurface3_Release(surface2);
         IDirectDrawSurface3_Release(surface3);
@@ -6295,7 +6295,7 @@ static void test_set_surface_desc(void)
     U1(ddsd).lPitch = 8 * 4;
     ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* SetSurfaceDesc needs systemmemory surfaces.
      *
@@ -6319,7 +6319,7 @@ static void test_set_surface_desc(void)
         }
 
         hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
-        ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW, "Got unexpected hr %#lx.\n", hr);
         if (FAILED(hr))
         {
             skip("Cannot create a %s surface, skipping vidmem SetSurfaceDesc test.\n",
@@ -6327,7 +6327,7 @@ static void test_set_surface_desc(void)
             goto done;
         }
         hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         IDirectDrawSurface_Release(surface);
 
         reset_ddsd(&ddsd);
@@ -6336,17 +6336,17 @@ static void test_set_surface_desc(void)
         hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
         if (invalid_caps_tests[i].supported)
         {
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         }
         else
         {
-            ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n",
+            ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#lx.\n",
                     invalid_caps_tests[i].name, hr);
 
             /* Check priority of error conditions. */
             ddsd.dwFlags = DDSD_WIDTH;
             hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-            ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n",
+            ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#lx.\n",
                     invalid_caps_tests[i].name, hr);
         }
 
@@ -6355,7 +6355,7 @@ static void test_set_surface_desc(void)
 
 done:
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Ddraw object not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -6380,7 +6380,7 @@ static void test_user_memory_getdc(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
@@ -6394,10 +6394,10 @@ static void test_user_memory_getdc(void)
     U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3);
-    ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface3 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface3 interface, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface);
 
     memset(data, 0xaa, sizeof(data));
@@ -6405,10 +6405,10 @@ static void test_user_memory_getdc(void)
     ddsd.dwFlags = DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface3_GetDC(surface3, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     bitmap = GetCurrentObject(dc, OBJ_BITMAP);
     ok(!!bitmap, "Failed to get bitmap.\n");
     size = GetObjectA(bitmap, sizeof(dib), &dib);
@@ -6417,10 +6417,10 @@ static void test_user_memory_getdc(void)
     BitBlt(dc, 0, 0, 16, 8, NULL, 0, 0, WHITENESS);
     BitBlt(dc, 0, 8, 16, 8, NULL, 0, 0, BLACKNESS);
     hr = IDirectDrawSurface3_ReleaseDC(surface3, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
-    ok(data[0][0] == 0xffffffff, "Expected color 0xffffffff, got %#x.\n", data[0][0]);
-    ok(data[15][15] == 0x00000000, "Expected color 0x00000000, got %#x.\n", data[15][15]);
+    ok(data[0][0] == 0xffffffff, "Expected color 0xffffffff, got %#lx.\n", data[0][0]);
+    ok(data[15][15] == 0x00000000, "Expected color 0x00000000, got %#lx.\n", data[15][15]);
 
     ddsd.dwFlags = DDSD_LPSURFACE | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PITCH;
     ddsd.lpSurface = data;
@@ -6428,40 +6428,40 @@ static void test_user_memory_getdc(void)
     ddsd.dwHeight = 8;
     U1(ddsd).lPitch = sizeof(*data);
     hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     memset(data, 0xaa, sizeof(data));
     hr = IDirectDrawSurface3_GetDC(surface3, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     BitBlt(dc, 0, 0, 4, 8, NULL, 0, 0, BLACKNESS);
     BitBlt(dc, 1, 1, 2, 2, NULL, 0, 0, WHITENESS);
     hr = IDirectDrawSurface3_ReleaseDC(surface3, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     for (y = 0; y < 4; y++)
     {
         for (x = 0; x < 4; x++)
         {
             if ((x == 1 || x == 2) && (y == 1 || y == 2))
-                ok(data[y][x] == 0xffffffff, "Expected color 0xffffffff on position %ux%u, got %#x.\n",
+                ok(data[y][x] == 0xffffffff, "Expected color 0xffffffff on position %ux%u, got %#lx.\n",
                         x, y, data[y][x]);
             else
-                ok(data[y][x] == 0x00000000, "Expected color 0xaaaaaaaa on position %ux%u, got %#x.\n",
+                ok(data[y][x] == 0x00000000, "Expected color 0xaaaaaaaa on position %ux%u, got %#lx.\n",
                         x, y, data[y][x]);
         }
     }
-    ok(data[0][5] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 5x0, got %#x.\n",
+    ok(data[0][5] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 5x0, got %#lx.\n",
             data[0][5]);
-    ok(data[7][3] == 0x00000000, "Expected color 0x00000000 on position 3x7, got %#x.\n",
+    ok(data[7][3] == 0x00000000, "Expected color 0x00000000 on position 3x7, got %#lx.\n",
             data[7][3]);
-    ok(data[7][4] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 4x7, got %#x.\n",
+    ok(data[7][4] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 4x7, got %#lx.\n",
             data[7][4]);
-    ok(data[8][0] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 0x8, got %#x.\n",
+    ok(data[8][0] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 0x8, got %#lx.\n",
             data[8][0]);
 
     IDirectDrawSurface3_Release(surface3);
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Ddraw object not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -6479,7 +6479,7 @@ static void test_sysmem_overlay(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
@@ -6493,10 +6493,10 @@ static void test_sysmem_overlay(void)
     U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
     U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DDERR_NOOVERLAYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOOVERLAYHW, "Got unexpected hr %#lx.\n", hr);
 
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Ddraw object not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -6524,7 +6524,7 @@ static void test_primary_palette(void)
         return;
     }
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -6532,22 +6532,22 @@ static void test_primary_palette(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     surface_desc.dwBackBufferCount = 1;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetAttachedSurface(primary, &surface_caps, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#lx.\n", hr);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     hr = IDirectDraw2_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256, palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)palette);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
-    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
-    ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#x.\n", palette_caps);
+    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#lx.\n", hr);
+    ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#lx.\n", palette_caps);
 
     hr = IDirectDrawSurface_SetPalette(primary, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     /* The Windows 8 testbot attaches the palette to the backbuffer as well,
      * and is generally somewhat broken with respect to 8 bpp / palette
@@ -6560,99 +6560,99 @@ static void test_primary_palette(void)
         /* The Windows 8 testbot keeps extra references to the primary and
          * backbuffer while in 8 bpp mode. */
         hr = IDirectDraw2_RestoreDisplayMode(ddraw);
-        ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#lx.\n", hr);
         goto done;
     }
 
     refcount = get_refcount((IUnknown *)palette);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
-    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#lx.\n", hr);
     ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_PRIMARYSURFACE | DDPCAPS_ALLOW256),
-            "Got unexpected palette caps %#x.\n", palette_caps);
+            "Got unexpected palette caps %#lx.\n", palette_caps);
 
     hr = IDirectDrawSurface_SetPalette(primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)palette);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
-    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
-    ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#x.\n", palette_caps);
+    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#lx.\n", hr);
+    ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#lx.\n", palette_caps);
 
     hr = IDirectDrawSurface_SetPalette(primary, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)palette);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface_GetPalette(primary, &tmp);
-    ok(SUCCEEDED(hr), "Failed to get palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette, hr %#lx.\n", hr);
     ok(tmp == palette, "Got unexpected palette %p, expected %p.\n", tmp, palette);
     IDirectDrawPalette_Release(tmp);
     hr = IDirectDrawSurface_GetPalette(backbuffer, &tmp);
-    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirectDrawPalette_Release(palette);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     /* Note that this only seems to work when the palette is attached to the
      * primary surface. When attached to a regular surface, attempting to get
      * the palette here will cause an access violation. */
     hr = IDirectDrawSurface_GetPalette(primary, &tmp);
-    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
-    ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 8, "Got unexpected bit count %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %lu.\n", surface_desc.dwWidth);
+    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %lu.\n", surface_desc.dwHeight);
+    ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 8, "Got unexpected bit count %lu.\n",
             U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
 
     hr = set_display_mode(ddraw, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %lu.\n", surface_desc.dwWidth);
+    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %lu.\n", surface_desc.dwHeight);
     ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 32
             || U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 24,
-            "Got unexpected bit count %u.\n", U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
+            "Got unexpected bit count %lu.\n", U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
 
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_GetSurfaceDesc(primary, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %lu.\n", surface_desc.dwWidth);
+    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %lu.\n", surface_desc.dwHeight);
     ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 32
             || U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == 24,
-            "Got unexpected bit count %u.\n", U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
+            "Got unexpected bit count %lu.\n", U1(surface_desc.ddpfPixelFormat).dwRGBBitCount);
 
 done:
     refcount = IDirectDrawSurface_Release(backbuffer);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawSurface_Release(primary);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -6681,7 +6681,7 @@ static void test_surface_attachment(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -6691,14 +6691,14 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 128;
     surface_desc.dwHeight = 128;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_GetAttachedSurface(surface1, &caps, &surface2);
-    ok(SUCCEEDED(hr), "Failed to get mip level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get mip level, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetAttachedSurface(surface2, &caps, &surface3);
-    ok(SUCCEEDED(hr), "Failed to get mip level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get mip level, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetAttachedSurface(surface3, &caps, &surface4);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
 
     surface_count = 0;
     IDirectDrawSurface_EnumAttachedSurfaces(surface1, &surface_count, surface_counter);
@@ -6717,20 +6717,20 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 16;
     surface_desc.dwHeight = 16;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface1);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface3, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface3);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface2);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(surface4);
 
@@ -6741,27 +6741,27 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 16;
     surface_desc.dwHeight = 16;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     if (SUCCEEDED(hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4)))
     {
         skip("Running on refrast, skipping some tests.\n");
         hr = IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface4);
-        ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
     }
     else
     {
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface1);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface_AddAttachedSurface(surface3, surface4);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface3);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface4);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface2);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     }
 
     IDirectDrawSurface_Release(surface4);
@@ -6770,7 +6770,7 @@ static void test_surface_attachment(void)
     IDirectDrawSurface_Release(surface1);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Try a single primary and two offscreen plain surfaces. */
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -6778,7 +6778,7 @@ static void test_surface_attachment(void)
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -6787,7 +6787,7 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = registry_mode.dmPelsWidth;
     surface_desc.dwHeight = registry_mode.dmPelsHeight;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -6796,7 +6796,7 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = registry_mode.dmPelsWidth;
     surface_desc.dwHeight = registry_mode.dmPelsHeight;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* This one has a different size. */
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -6806,33 +6806,33 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 128;
     surface_desc.dwHeight = 128;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     /* Try the reverse without detaching first. */
     hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface1);
-    ok(hr == DDERR_SURFACEALREADYATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACEALREADYATTACHED, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface2);
-    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface1);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     /* Try to detach reversed. */
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface2);
-    ok(hr == DDERR_CANNOTDETACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTDETACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface2, 0, surface1);
-    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface3);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface2, 0, surface3);
-    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface1);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(surface4);
     IDirectDrawSurface_Release(surface3);
@@ -6847,7 +6847,7 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 64;
     surface_desc.dwHeight = 64;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -6860,26 +6860,26 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 32;
     surface_desc.dwHeight = 32;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
     surface_desc.dwWidth = 64;
     surface_desc.dwHeight = 64;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
     surface_desc.dwWidth = 128;
     surface_desc.dwHeight = 128;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
-    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     if (SUCCEEDED(hr))
         IDirectDrawSurface2_DeleteAttachedSurface(surface1, 0, surface2);
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface3);
-    ok(hr == D3D_OK, "Failed to attach depth buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to attach depth buffer, hr %#lx.\n", hr);
     hr = IDirectDrawSurface2_DeleteAttachedSurface(surface1, 0, surface3);
-    ok(hr == D3D_OK, "Failed to detach depth buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to detach depth buffer, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4);
-    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface2_Release(surface4);
     IDirectDrawSurface2_Release(surface3);
@@ -6900,47 +6900,47 @@ static void test_surface_attachment(void)
     U3(surface_desc.ddpfPixelFormat).dwGBitMask = 0x07e0;
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x001f;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
     surface_desc.ddpfPixelFormat.dwFlags = DDPF_ZBUFFER;
     U1(surface_desc.ddpfPixelFormat).dwZBufferBitDepth = 16;
     U3(surface_desc.ddpfPixelFormat).dwZBitMask = 0x0000ffff;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)surface2);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
-    ok(hr == DDERR_SURFACEALREADYATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACEALREADYATTACHED, "Got unexpected hr %#lx.\n", hr);
 
     /* Attaching while already attached to other surface. */
     hr = IDirectDrawSurface_AddAttachedSurface(surface3, surface2);
-    todo_wine ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    todo_wine ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface3, 0, surface2);
-    todo_wine ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    todo_wine ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface3);
 
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface2);
-    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)surface2);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     /* Automatic detachment on release. */
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)surface2);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawSurface_Release(surface1);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawSurface_Release(surface2);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -7023,7 +7023,7 @@ static void test_pixel_format(void)
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
     if (FAILED(hr))
     {
-        skip("Failed to set cooperative level, hr %#x.\n", hr);
+        skip("Failed to set cooperative level, hr %#lx.\n", hr);
         goto cleanup;
     }
 
@@ -7033,9 +7033,9 @@ static void test_pixel_format(void)
     if (hdc2)
     {
         hr = IDirectDraw2_CreateClipper(ddraw, 0, &clipper, NULL);
-        ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
         hr = IDirectDrawClipper_SetHWnd(clipper, 0, window2);
-        ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
 
         test_format = GetPixelFormat(hdc);
         ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -7050,7 +7050,7 @@ static void test_pixel_format(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -7064,7 +7064,7 @@ static void test_pixel_format(void)
     if (clipper)
     {
         hr = IDirectDrawSurface_SetClipper(primary, clipper);
-        ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
 
         test_format = GetPixelFormat(hdc);
         ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -7079,18 +7079,18 @@ static void test_pixel_format(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     ddsd.dwWidth = ddsd.dwHeight = 64;
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &offscreen, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     hr = IDirectDrawSurface_Blt(offscreen, NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#lx.\n", hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
 
     hr = IDirectDrawSurface_Blt(primary, NULL, offscreen, NULL, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to blit to primary surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit to primary surface, hr %#lx.\n", hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -7196,7 +7196,7 @@ static void test_create_surface_pitch(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ((63 * 4) + 8) * 63);
 
@@ -7219,33 +7219,33 @@ static void test_create_surface_pitch(void)
         if (test_data[i].flags_in & DDSD_LPSURFACE)
         {
             HRESULT expected_hr = SUCCEEDED(test_data[i].hr) ? DDERR_INVALIDPARAMS : test_data[i].hr;
-            ok(hr == expected_hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, expected_hr);
+            ok(hr == expected_hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, expected_hr);
             surface_desc.lpSurface = mem;
             hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
         }
         if ((test_data[i].caps & DDSCAPS_VIDEOMEMORY) && hr == DDERR_NODIRECTDRAWHW)
             continue;
-        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
         if (FAILED(hr))
             continue;
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#lx.\n", i, hr);
         ok((surface_desc.dwFlags & flags_mask) == test_data[i].flags_out,
-                "Test %u: Got unexpected flags %#x, expected %#x.\n",
+                "Test %u: Got unexpected flags %#lx, expected %#lx.\n",
                 i, surface_desc.dwFlags & flags_mask, test_data[i].flags_out);
         /* The pitch for textures seems to be implementation specific. */
         if (!(test_data[i].caps & DDSCAPS_TEXTURE))
         {
             if (is_ddraw64 && test_data[i].pitch_out32 != test_data[i].pitch_out64)
                 todo_wine ok(U1(surface_desc).lPitch == test_data[i].pitch_out64,
-                        "Test %u: Got unexpected pitch %u, expected %u.\n",
+                        "Test %u: Got unexpected pitch %lu, expected %lu.\n",
                         i, U1(surface_desc).lPitch, test_data[i].pitch_out64);
             else
                 ok(U1(surface_desc).lPitch == test_data[i].pitch_out32,
-                        "Test %u: Got unexpected pitch %u, expected %u.\n",
+                        "Test %u: Got unexpected pitch %lu, expected %lu.\n",
                         i, U1(surface_desc).lPitch, test_data[i].pitch_out32);
         }
         ok(!surface_desc.lpSurface, "Test %u: Got unexpected lpSurface %p.\n", i, surface_desc.lpSurface);
@@ -7255,7 +7255,7 @@ static void test_create_surface_pitch(void)
 
     HeapFree(GetProcessHeap(), 0, mem);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -7296,12 +7296,12 @@ static void test_mipmap(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw2_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) != (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP))
     {
         skip("Mipmapped textures not supported, skipping tests.\n");
@@ -7321,22 +7321,22 @@ static void test_mipmap(void)
         if (tests[i].flags & DDSD_MIPMAPCOUNT)
             U2(surface_desc).dwMipMapCount = tests[i].mipmap_count_in;
         hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-        ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         if (FAILED(hr))
             continue;
 
         hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface2, (void **)&surface);
-        ok(SUCCEEDED(hr), "Test %u: Failed to get IDirectDrawSurface2 interface, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get IDirectDrawSurface2 interface, hr %#lx.\n", i, hr);
         IDirectDrawSurface_Release(surface1);
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface2_GetSurfaceDesc(surface, &surface_desc);
-        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#lx.\n", i, hr);
         ok(surface_desc.dwFlags & DDSD_MIPMAPCOUNT,
-                "Test %u: Got unexpected flags %#x.\n", i, surface_desc.dwFlags);
+                "Test %u: Got unexpected flags %#lx.\n", i, surface_desc.dwFlags);
         ok(U2(surface_desc).dwMipMapCount == tests[i].mipmap_count_out,
-                "Test %u: Got unexpected mipmap count %u.\n", i, U2(surface_desc).dwMipMapCount);
+                "Test %u: Got unexpected mipmap count %lu.\n", i, U2(surface_desc).dwMipMapCount);
 
         surface_base = surface;
         IDirectDrawSurface2_AddRef(surface_base);
@@ -7344,31 +7344,31 @@ static void test_mipmap(void)
         while (mipmap_count > 1)
         {
             hr = IDirectDrawSurface2_GetAttachedSurface(surface_base, &caps, &surface_mip);
-            ok(SUCCEEDED(hr), "Test %u, %u: Failed to get attached surface, hr %#x.\n", i, mipmap_count, hr);
+            ok(SUCCEEDED(hr), "Test %u, %u: Failed to get attached surface, hr %#lx.\n", i, mipmap_count, hr);
 
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface2_GetSurfaceDesc(surface_base, &surface_desc);
-            ok(SUCCEEDED(hr), "Test %u, %u: Failed to get surface desc, hr %#x.\n", i, mipmap_count, hr);
+            ok(SUCCEEDED(hr), "Test %u, %u: Failed to get surface desc, hr %#lx.\n", i, mipmap_count, hr);
             ok(surface_desc.dwFlags & DDSD_MIPMAPCOUNT,
-                    "Test %u, %u: Got unexpected flags %#x.\n", i, mipmap_count, surface_desc.dwFlags);
+                    "Test %u, %u: Got unexpected flags %#lx.\n", i, mipmap_count, surface_desc.dwFlags);
             ok(U2(surface_desc).dwMipMapCount == mipmap_count,
-                    "Test %u, %u: Got unexpected mipmap count %u.\n",
+                    "Test %u, %u: Got unexpected mipmap count %lu.\n",
                     i, mipmap_count, U2(surface_desc).dwMipMapCount);
 
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface2_Lock(surface_base, NULL, &surface_desc, 0, NULL);
-            ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#x.\n", i, mipmap_count, hr);
+            ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#lx.\n", i, mipmap_count, hr);
             ok(surface_desc.dwMipMapCount == mipmap_count,
-                    "Test %u, %u: unexpected change of mipmap count %u.\n",
+                    "Test %u, %u: unexpected change of mipmap count %lu.\n",
                     i, mipmap_count, surface_desc.dwMipMapCount);
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface2_Lock(surface_mip, NULL, &surface_desc, 0, NULL);
-            ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#x.\n", i, mipmap_count, hr);
+            ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#lx.\n", i, mipmap_count, hr);
             ok(surface_desc.dwMipMapCount == mipmap_count - 1,
-                    "Test %u, %u: Child mipmap count unexpected %u\n", i, mipmap_count, surface_desc.dwMipMapCount);
+                    "Test %u, %u: Child mipmap count unexpected %lu\n", i, mipmap_count, surface_desc.dwMipMapCount);
             IDirectDrawSurface2_Unlock(surface_mip, NULL);
             IDirectDrawSurface2_Unlock(surface_base, NULL);
 
@@ -7382,7 +7382,7 @@ static void test_mipmap(void)
     }
 
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -7408,12 +7408,12 @@ static void test_palette_complex(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw2_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) != (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP))
     {
         skip("Mipmapped textures not supported, skipping mipmap palette test.\n");
@@ -7432,31 +7432,31 @@ static void test_palette_complex(void)
     surface_desc.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
     U1(surface_desc.ddpfPixelFormat).dwRGBBitCount = 8;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface2, (void **)&surface);
-    ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface2 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface2 interface, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface1);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     hr = IDirectDraw2_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     palette_entries[1].peRed = 0xff;
     palette_entries[1].peGreen = 0x80;
     hr = IDirectDraw2_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette_mipmap, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     palette2 = (void *)0xdeadbeef;
     hr = IDirectDrawSurface2_GetPalette(surface, &palette2);
-    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx.\n", hr);
     ok(!palette2, "Got unexpected palette %p.\n", palette2);
     hr = IDirectDrawSurface2_SetPalette(surface, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface2_GetPalette(surface, &palette2);
-    ok(SUCCEEDED(hr), "Failed to get palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette, hr %#lx.\n", hr);
     ok(palette == palette2, "Got unexpected palette %p.\n", palette2);
     IDirectDrawPalette_Release(palette2);
 
@@ -7465,46 +7465,46 @@ static void test_palette_complex(void)
     for (i = 0; i < 7; ++i)
     {
         hr = IDirectDrawSurface2_GetAttachedSurface(mipmap, &caps, &tmp);
-        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#lx.\n", i, hr);
         palette2 = (void *)0xdeadbeef;
         hr = IDirectDrawSurface2_GetPalette(tmp, &palette2);
-        ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x, i %u.\n", hr, i);
+        ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx, i %u.\n", hr, i);
         ok(!palette2, "Got unexpected palette %p, i %u.\n", palette2, i);
 
         hr = IDirectDrawSurface2_SetPalette(tmp, palette_mipmap);
-        ok(SUCCEEDED(hr), "Failed to set palette, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to set palette, i %u, hr %#lx.\n", i, hr);
 
         hr = IDirectDrawSurface2_GetPalette(tmp, &palette2);
-        ok(SUCCEEDED(hr), "Failed to get palette, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get palette, i %u, hr %#lx.\n", i, hr);
         ok(palette_mipmap == palette2, "Got unexpected palette %p.\n", palette2);
         IDirectDrawPalette_Release(palette2);
 
         hr = IDirectDrawSurface2_GetDC(tmp, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC, i %u, hr %#lx.\n", i, hr);
         count = GetDIBColorTable(dc, 1, 1, &rgbquad);
         ok(count == 1, "Expected count 1, got %u.\n", count);
         ok(rgbquad.rgbRed == 0xff, "Expected rgbRed = 0xff, got %#x.\n", rgbquad.rgbRed);
         ok(rgbquad.rgbGreen == 0x80, "Expected rgbGreen = 0x80, got %#x.\n", rgbquad.rgbGreen);
         ok(rgbquad.rgbBlue == 0x0, "Expected rgbBlue = 0x0, got %#x.\n", rgbquad.rgbBlue);
         hr = IDirectDrawSurface2_ReleaseDC(tmp, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC, i %u, hr %#lx.\n", i, hr);
 
         IDirectDrawSurface2_Release(mipmap);
         mipmap = tmp;
     }
 
     hr = IDirectDrawSurface2_GetAttachedSurface(mipmap, &caps, &tmp);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface2_Release(mipmap);
     refcount = IDirectDrawSurface2_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette_mipmap);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -7535,7 +7535,7 @@ static void test_p8_blit(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     is_warp = ddraw_is_warp(ddraw);
 
     memset(palette_entries, 0, sizeof(palette_entries));
@@ -7545,14 +7545,14 @@ static void test_p8_blit(void)
     palette_entries[4].peRed = 0xff;
     hr = IDirectDraw2_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
     palette_entries[1].peBlue = 0xff;
     palette_entries[2].peGreen = 0xff;
     palette_entries[3].peRed = 0xff;
     palette_entries[4].peFlags = 0x0;
     hr = IDirectDraw2_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -7564,11 +7564,11 @@ static void test_p8_blit(void)
     surface_desc.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
     U1(surface_desc.ddpfPixelFormat).dwRGBBitCount = 8;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &src, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &dst_p8, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_SetPalette(dst_p8, palette2);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -7584,34 +7584,34 @@ static void test_p8_blit(void)
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(surface_desc.ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_Lock(src, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#lx.\n", hr);
     memcpy(surface_desc.lpSurface, src_data, sizeof(src_data));
     hr = IDirectDrawSurface_Unlock(src, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(dst_p8, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#lx.\n", hr);
     memcpy(surface_desc.lpSurface, src_data2, sizeof(src_data2));
     hr = IDirectDrawSurface_Unlock(dst_p8, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#lx.\n", hr);
 
     fx.dwSize = sizeof(fx);
     fx.dwFillColor = 0xdeadbeef;
     hr = IDirectDrawSurface_Blt(dst, NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
-    ok(SUCCEEDED(hr), "Failed to color fill %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to color fill %#lx.\n", hr);
 
     hr = IDirectDrawSurface_SetPalette(src, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_WAIT, NULL);
     /* The r500 Windows 7 driver returns E_NOTIMPL. r200 on Windows XP works.
      * The Geforce 7 driver on Windows Vista returns E_FAIL. Newer Nvidia GPUs work. */
     ok(SUCCEEDED(hr) || broken(hr == E_NOTIMPL) || broken(hr == E_FAIL),
-            "Failed to blit, hr %#x.\n", hr);
+            "Failed to blit, hr %#lx.\n", hr);
 
     if (SUCCEEDED(hr))
     {
@@ -7622,7 +7622,7 @@ static void test_p8_blit(void)
              * blits see below. */
             todo_wine ok(compare_color(color, expected[x], 0)
                     || broken(is_warp && compare_color(color, 0x00000000, 0)),
-                    "Pixel %u: Got color %#x, expected %#x.\n",
+                    "Pixel %u: Got color %#lx, expected %#lx.\n",
                     x, color, expected[x]);
         }
     }
@@ -7630,10 +7630,10 @@ static void test_p8_blit(void)
     fx.ddckSrcColorkey.dwColorSpaceHighValue = 0x2;
     fx.ddckSrcColorkey.dwColorSpaceLowValue = 0x2;
     hr = IDirectDrawSurface7_Blt(dst_p8, NULL, src, NULL, DDBLT_WAIT | DDBLT_KEYSRCOVERRIDE, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Lock(dst_p8, NULL, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#lx.\n", hr);
     /* A color keyed P8 blit doesn't do anything on WARP - it just leaves the data in the destination
      * surface untouched. Error checking (DDBLT_KEYSRC without a key
      * for example) also works as expected.
@@ -7644,7 +7644,7 @@ static void test_p8_blit(void)
             || broken(is_warp && !memcmp(surface_desc.lpSurface, src_data2, sizeof(src_data2))),
             "Got unexpected P8 color key blit result.\n");
     hr = IDirectDrawSurface_Unlock(dst_p8, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(src);
     IDirectDrawSurface_Release(dst);
@@ -7653,7 +7653,7 @@ static void test_p8_blit(void)
     IDirectDrawPalette_Release(palette2);
 
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -7702,98 +7702,98 @@ static void test_material(void)
     }
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     background = create_diffuse_material(device, 0.0f, 0.0f, 1.0f, 1.0f);
     viewport = create_viewport(device, 0, 0, 640, 480);
     viewport_set_background(device, viewport, background);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     material = create_emissive_material(device, 0.0f, 1.0f, 0.0f, 0.0f);
     hr = IDirect3DMaterial2_GetHandle(material, device, &mat_handle);
-    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_GetLightState(device, D3DLIGHTSTATE_MATERIAL, &tmp);
-    ok(SUCCEEDED(hr), "Failed to get light state, hr %#x.\n", hr);
-    ok(!tmp, "Got unexpected material handle %#x.\n", tmp);
+    ok(SUCCEEDED(hr), "Failed to get light state, hr %#lx.\n", hr);
+    ok(!tmp, "Got unexpected material handle %#lx.\n", tmp);
     hr = IDirect3DDevice2_SetLightState(device, D3DLIGHTSTATE_MATERIAL, mat_handle);
-    ok(SUCCEEDED(hr), "Failed to set material state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set material state, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_GetLightState(device, D3DLIGHTSTATE_MATERIAL, &tmp);
-    ok(SUCCEEDED(hr), "Failed to get light state, hr %#x.\n", hr);
-    ok(tmp == mat_handle, "Got unexpected material handle %#x, expected %#x.\n", tmp, mat_handle);
+    ok(SUCCEEDED(hr), "Failed to get light state, hr %#lx.\n", hr);
+    ok(tmp == mat_handle, "Got unexpected material handle %#lx, expected %#lx.\n", tmp, mat_handle);
     hr = IDirect3DDevice2_SetLightState(device, D3DLIGHTSTATE_MATERIAL, 0);
-    ok(SUCCEEDED(hr), "Failed to set material state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set material state, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_GetLightState(device, D3DLIGHTSTATE_MATERIAL, &tmp);
-    ok(SUCCEEDED(hr), "Failed to get light state, hr %#x.\n", hr);
-    ok(!tmp, "Got unexpected material handle %#x.\n", tmp);
+    ok(SUCCEEDED(hr), "Failed to get light state, hr %#lx.\n", hr);
+    ok(!tmp, "Got unexpected material handle %#lx.\n", tmp);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER);
-        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice2_SetLightState(device, D3DLIGHTSTATE_MATERIAL, test_data[i].material ? mat_handle : 0);
-        ok(SUCCEEDED(hr), "Failed to set material state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set material state, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice2_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_VERTEX, quad, 4, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice2_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, test_data[i].expected_color, 1),
-                "Got unexpected color 0x%08x, test %u.\n", color, i);
+                "Got unexpected color 0x%08lx, test %u.\n", color, i);
     }
 
     destroy_material(material);
     material = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f);
     hr = IDirect3DMaterial2_GetHandle(material, device, &mat_handle);
-    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport2_SetBackground(viewport, mat_handle);
-    ok(SUCCEEDED(hr), "Failed to set viewport background, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport background, hr %#lx.\n", hr);
     hr = IDirect3DViewport2_GetBackground(viewport, &tmp, &valid);
-    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#x.\n", hr);
-    ok(tmp == mat_handle, "Got unexpected material handle %#x, expected %#x.\n", tmp, mat_handle);
+    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#lx.\n", hr);
+    ok(tmp == mat_handle, "Got unexpected material handle %#lx, expected %#lx.\n", tmp, mat_handle);
     ok(valid, "Got unexpected valid %#x.\n", valid);
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DViewport2_SetBackground(viewport, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport2_GetBackground(viewport, &tmp, &valid);
-    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#x.\n", hr);
-    ok(tmp == mat_handle, "Got unexpected material handle %#x, expected %#x.\n", tmp, mat_handle);
+    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#lx.\n", hr);
+    ok(tmp == mat_handle, "Got unexpected material handle %#lx, expected %#lx.\n", tmp, mat_handle);
     ok(valid, "Got unexpected valid %#x.\n", valid);
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     destroy_viewport(device, viewport);
     viewport = create_viewport(device, 0, 0, 640, 480);
 
     hr = IDirect3DViewport2_GetBackground(viewport, &tmp, &valid);
-    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#x.\n", hr);
-    ok(!tmp, "Got unexpected material handle %#x.\n", tmp);
+    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#lx.\n", hr);
+    ok(!tmp, "Got unexpected material handle %#lx.\n", tmp);
     ok(!valid, "Got unexpected valid %#x.\n", valid);
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00000000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     destroy_viewport(device, viewport);
     destroy_material(background);
     destroy_material(material);
     IDirectDrawSurface_Release(rt);
     refcount = IDirect3DDevice2_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Ddraw object has %u references left.\n", refcount);
+    ok(!refcount, "Ddraw object has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -7919,83 +7919,83 @@ static void test_lighting(void)
     }
 
     hr = IDirect3DDevice2_GetDirect3D(device, &d3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     material = create_diffuse_and_ambient_material(device, 1.0f, 1.0f, 1.0f, 1.0f);
     viewport_set_background(device, viewport, material);
 
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat);
-    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable zbuffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable zbuffer, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
-    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     /* There is no D3DRENDERSTATE_LIGHTING on ddraw < 7. */
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, D3DVT_LVERTEX, unlitquad,
             4, indices, 6, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_LIGHTING, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, D3DVT_LVERTEX, litquad,
             4, indices, 6, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, D3DVT_VERTEX, unlitnquad,
             4, indices, 6, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_LIGHTING, TRUE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, D3DVT_VERTEX, litnquad,
             4, indices, 6, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 360);
-    ok(color == 0x00ff0000, "Unlit quad without normals has color 0x%08x.\n", color);
+    ok(color == 0x00ff0000, "Unlit quad without normals has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 160, 120);
-    ok(color == 0x0000ff00, "Lit quad without normals has color 0x%08x.\n", color);
+    ok(color == 0x0000ff00, "Lit quad without normals has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 360);
-    ok(color == 0x00ffffff, "Unlit quad with normals has color 0x%08x.\n", color);
+    ok(color == 0x00ffffff, "Unlit quad with normals has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 120);
-    ok(color == 0x00ffffff, "Lit quad with normals has color 0x%08x.\n", color);
+    ok(color == 0x00ffffff, "Lit quad with normals has color 0x%08lx.\n", color);
 
     hr = IDirect3DMaterial2_GetHandle(material, device, &mat_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetLightState(device, D3DLIGHTSTATE_MATERIAL, mat_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetLightState(device, D3DLIGHTSTATE_AMBIENT, 0xff002000);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3D2_CreateLight(d3d, &light, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memset(&light_desc, 0, sizeof(light_desc));
     light_desc.dwSize = sizeof(light_desc);
     light_desc.dltType = D3DLIGHT_DIRECTIONAL;
@@ -8005,78 +8005,78 @@ static void test_lighting(void)
     U4(light_desc.dcvColor).a = 1.0f;
     U3(light_desc.dvDirection).z = 1.0f;
     hr = IDirect3DLight_SetLight(light, (D3DLIGHT *)&light_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport2_AddLight(viewport, light);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport2_AddLight(viewport, light);
-    ok(hr == D3DERR_LIGHTHASVIEWPORT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_LIGHTHASVIEWPORT, "Got unexpected hr %#lx.\n", hr);
 
     viewport2 = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DViewport2_AddLight(viewport2, light);
-    ok(hr == D3DERR_LIGHTHASVIEWPORT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_LIGHTHASVIEWPORT, "Got unexpected hr %#lx.\n", hr);
     destroy_viewport(device, viewport2);
 
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, D3DVT_VERTEX, nquad,
             4, indices, 6, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 320, 240);
-    ok(color == 0x00002000, "Lit quad with no light has color 0x%08x.\n", color);
+    ok(color == 0x00002000, "Lit quad with no light has color 0x%08lx.\n", color);
 
     light_desc.dwFlags = D3DLIGHT_ACTIVE;
     hr = IDirect3DLight_SetLight(light, (D3DLIGHT *)&light_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport2_DeleteLight(viewport, light);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     light_desc.dwFlags = 0;
     hr = IDirect3DLight_GetLight(light, (D3DLIGHT *)&light_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(light_desc.dwFlags == D3DLIGHT_ACTIVE, "Got unexpected flags %#x.\n", light_desc.dwFlags);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(light_desc.dwFlags == D3DLIGHT_ACTIVE, "Got unexpected flags %#lx.\n", light_desc.dwFlags);
 
     hr = IDirect3DViewport2_AddLight(viewport, light);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_WORLD, tests[i].world_matrix);
-        ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
 
         hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice2_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice2_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, D3DVT_VERTEX,
                 tests[i].quad, 4, indices, 6, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice2_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = get_surface_color(rt, 320, 240);
-        ok(color == tests[i].expected, "%s has color 0x%08x.\n", tests[i].message, color);
+        ok(color == tests[i].expected, "%s has color 0x%08lx.\n", tests[i].message, color);
     }
 
     hr = IDirect3DViewport2_DeleteLight(viewport, light);
-    ok(SUCCEEDED(hr), "Failed to remove a light from the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to remove a light from the viewport, hr %#lx.\n", hr);
     IDirect3DLight_Release(light);
     destroy_material(material);
     destroy_viewport(device, viewport);
     IDirectDrawSurface2_Release(rt);
     refcount = IDirect3DDevice2_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D2_Release(d3d);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Ddraw object has %u references left.\n", refcount);
+    ok(!refcount, "Ddraw object has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -8307,67 +8307,67 @@ static void test_specular_lighting(void)
     }
 
     hr = IDirect3DDevice2_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get D3D interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get D3D interface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat);
-    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#lx.\n", hr);
 
     background_material = create_diffuse_material(device, 1.0f, 1.0f, 1.0f, 1.0f);
     viewport_set_background(device, viewport, background_material);
 
     hr = IDirect3D2_CreateLight(d3d, &light, NULL);
-    ok(SUCCEEDED(hr), "Failed to create a light object, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create a light object, hr %#lx.\n", hr);
     hr = IDirect3DViewport2_AddLight(viewport, light);
-    ok(SUCCEEDED(hr), "Failed to add a light to the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to add a light to the viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_SPECULARENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable specular lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable specular lighting, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         tests[i].light->dwFlags = D3DLIGHT_ACTIVE;
         hr = IDirect3DLight_SetLight(light, (D3DLIGHT *)tests[i].light);
-        ok(SUCCEEDED(hr), "Failed to set light, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set light, hr %#lx.\n", hr);
 
         material = create_specular_material(device, 1.0f, 1.0f, 1.0f, 1.0f, tests[i].specular_power);
         hr = IDirect3DMaterial2_GetHandle(material, device, &mat_handle);
-        ok(SUCCEEDED(hr), "Failed to get material handle, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get material handle, hr %#lx.\n", hr);
         hr = IDirect3DDevice2_SetLightState(device, D3DLIGHTSTATE_MATERIAL, mat_handle);
-        ok(SUCCEEDED(hr), "Failed to set material state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set material state, hr %#lx.\n", hr);
 
         hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice2_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice2_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, D3DVT_VERTEX,
                 quad, vertices_side * vertices_side, indices, indices_count, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice2_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         for (j = 0; j < tests[i].expected_count; ++j)
         {
             color = get_surface_color(rt, tests[i].expected[j].x, tests[i].expected[j].y);
             ok(compare_color(color, tests[i].expected[j].color, 1),
-                    "Expected color 0x%08x at location (%u, %u), got 0x%08x, case %u.\n",
+                    "Expected color 0x%08lx at location (%u, %u), got 0x%08lx, case %u.\n",
                     tests[i].expected[j].color, tests[i].expected[j].x,
                     tests[i].expected[j].y, color, i);
         }
@@ -8376,16 +8376,16 @@ static void test_specular_lighting(void)
     }
 
     hr = IDirect3DViewport2_DeleteLight(viewport, light);
-    ok(SUCCEEDED(hr), "Failed to remove a light from the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to remove a light from the viewport, hr %#lx.\n", hr);
     IDirect3DLight_Release(light);
     destroy_material(background_material);
     destroy_viewport(device, viewport);
     IDirectDrawSurface2_Release(rt);
     refcount = IDirect3DDevice2_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D2_Release(d3d);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Ddraw object has %u references left.\n", refcount);
+    ok(!refcount, "Ddraw object has %lu references left.\n", refcount);
     DestroyWindow(window);
     HeapFree(GetProcessHeap(), 0, indices);
     HeapFree(GetProcessHeap(), 0, quad);
@@ -8433,7 +8433,7 @@ static void test_palette_gdi(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -8445,7 +8445,7 @@ static void test_palette_gdi(void)
     surface_desc.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
     U1(surface_desc.ddpfPixelFormat).dwRGBBitCount = 8;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* Avoid colors from the Windows default palette. */
     memset(palette_entries, 0, sizeof(palette_entries));
@@ -8457,7 +8457,7 @@ static void test_palette_gdi(void)
     palette_entries[4].peBlue = 0x15;
     hr = IDirectDraw2_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     /* If there is no palette assigned and the display mode is not 8 bpp, some
      * drivers refuse to create a DC while others allow it. If a DC is created,
@@ -8470,9 +8470,9 @@ static void test_palette_gdi(void)
      * contains uninitialized garbage. See comments below for the P8 case. */
 
     hr = IDirectDrawSurface_SetPalette(surface, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     ddraw_palette_handle = SelectPalette(dc, GetStockObject(DEFAULT_PALETTE), FALSE);
     ok(ddraw_palette_handle == GetStockObject(DEFAULT_PALETTE),
             "Got unexpected palette %p, expected %p.\n",
@@ -8499,7 +8499,7 @@ static void test_palette_gdi(void)
     palette_entries[4].peGreen = 0x24;
     palette_entries[4].peBlue = 0x25;
     hr = IDirectDrawPalette_SetEntries(palette, 0, 4, 1, &palette_entries[4]);
-    ok(SUCCEEDED(hr), "Failed to set palette entries, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette entries, hr %#lx.\n", hr);
 
     i = GetDIBColorTable(dc, 4, 1, &rgbquad[4]);
     ok(i == 1, "Expected count 1, got %u.\n", i);
@@ -8510,9 +8510,9 @@ static void test_palette_gdi(void)
 
     /* Neither does re-setting the palette. */
     hr = IDirectDrawSurface_SetPalette(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_SetPalette(surface, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     i = GetDIBColorTable(dc, 4, 1, &rgbquad[4]);
     ok(i == 1, "Expected count 1, got %u.\n", i);
@@ -8522,11 +8522,11 @@ static void test_palette_gdi(void)
             expected1[4].rgbRed, expected1[4].rgbGreen, expected1[4].rgbBlue);
 
     hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     /* Refresh the DC. This updates the palette. */
     hr = IDirectDrawSurface_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad);
     ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i);
     for (i = 0; i < ARRAY_SIZE(expected2); i++)
@@ -8543,13 +8543,13 @@ static void test_palette_gdi(void)
                 i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue);
     }
     hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     refcount = IDirectDrawSurface_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     if (FAILED(IDirectDraw2_SetDisplayMode(ddraw, 640, 480, 8, 0, 0)))
     {
         win_skip("Failed to set 8 bpp display mode, skipping test.\n");
@@ -8558,35 +8558,35 @@ static void test_palette_gdi(void)
         DestroyWindow(window);
         return;
     }
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 3;
     SetRect(&r, 0, 0, 319, 479);
     hr = IDirectDrawSurface_Blt(primary, &r, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear surface, hr %#lx.\n", hr);
     SetRect(&r, 320, 0, 639, 479);
     U5(fx).dwFillColor = 4;
     hr = IDirectDrawSurface_Blt(primary, &r, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_SetPalette(primary, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetDC(primary, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
 
     color = GetPixel(dc, 160, 240);
-    ok(color == 0x00030000, "Clear index 3: Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00030000, "Clear index 3: Got unexpected color 0x%08lx.\n", color);
     color = GetPixel(dc, 480, 240);
-    ok(color == 0x00252423, "Clear index 4: Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00252423, "Clear index 4: Got unexpected color 0x%08lx.\n", color);
 
     ddraw_palette_handle = SelectPalette(dc, GetStockObject(DEFAULT_PALETTE), FALSE);
     ok(ddraw_palette_handle == GetStockObject(DEFAULT_PALETTE),
@@ -8616,7 +8616,7 @@ static void test_palette_gdi(void)
                 i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue);
     }
     hr = IDirectDrawSurface_ReleaseDC(primary, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -8625,12 +8625,12 @@ static void test_palette_gdi(void)
     surface_desc.dwHeight = 16;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* Here the offscreen surface appears to use the primary's palette,
      * but in all likelihood it is actually the system palette. */
     hr = IDirectDrawSurface_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad);
     ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i);
     for (i = 0; i < ARRAY_SIZE(expected2); i++)
@@ -8647,7 +8647,7 @@ static void test_palette_gdi(void)
                 i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue);
     }
     hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     /* On real hardware a change to the primary surface's palette applies immediately,
      * even on device contexts from offscreen surfaces that do not have their own
@@ -8663,14 +8663,14 @@ static void test_palette_gdi(void)
     palette_entries[4].peBlue = 0x56;
     hr = IDirectDraw2_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_SetPalette(surface, palette2);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     /* A palette assigned to the offscreen surface overrides the primary / system
      * palette. */
     hr = IDirectDrawSurface_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad);
     ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i);
     for (i = 0; i < ARRAY_SIZE(expected3); i++)
@@ -8687,24 +8687,24 @@ static void test_palette_gdi(void)
                 i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue);
     }
     hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     refcount = IDirectDrawSurface_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     /* The Windows 8 testbot keeps extra references to the primary and
      * backbuffer while in 8 bpp mode. */
     hr = IDirectDraw2_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#lx.\n", hr);
 
     refcount =  IDirectDrawSurface_Release(primary);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette2);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -8744,18 +8744,18 @@ static void test_palette_alpha(void)
         return;
     }
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     palette_entries[1].peFlags = 0x42;
     palette_entries[2].peFlags = 0xff;
     palette_entries[3].peFlags = 0x80;
     hr = IDirectDraw2_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     memset(palette_entries, 0x66, sizeof(palette_entries));
     hr = IDirectDrawPalette_GetEntries(palette, 0, 1, 4, palette_entries);
-    ok(SUCCEEDED(hr), "Failed to get palette entries, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette entries, hr %#lx.\n", hr);
     ok(palette_entries[0].peFlags == 0x42, "Got unexpected peFlags 0x%02x, expected 0xff.\n",
             palette_entries[0].peFlags);
     ok(palette_entries[1].peFlags == 0xff, "Got unexpected peFlags 0x%02x, expected 0xff.\n",
@@ -8774,11 +8774,11 @@ static void test_palette_alpha(void)
     palette_entries[3].peFlags = 0x80;
     hr = IDirectDraw2_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT | DDPCAPS_ALPHA,
             palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     memset(palette_entries, 0x66, sizeof(palette_entries));
     hr = IDirectDrawPalette_GetEntries(palette, 0, 1, 4, palette_entries);
-    ok(SUCCEEDED(hr), "Failed to get palette entries, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette entries, hr %#lx.\n", hr);
     ok(palette_entries[0].peFlags == 0x42, "Got unexpected peFlags 0x%02x, expected 0xff.\n",
             palette_entries[0].peFlags);
     ok(palette_entries[1].peFlags == 0xff, "Got unexpected peFlags 0x%02x, expected 0xff.\n",
@@ -8797,16 +8797,16 @@ static void test_palette_alpha(void)
         surface_desc.dwHeight = 128;
         surface_desc.ddsCaps.dwCaps = test_data[i].caps;
         hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-        ok(SUCCEEDED(hr), "Failed to create %s surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to create %s surface, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface2, (void **)&surface);
-        ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface2 interface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface2 interface, hr %#lx.\n", hr);
         IDirectDrawSurface_Release(surface1);
 
         hr = IDirectDrawSurface2_SetPalette(surface, palette);
         if (test_data[i].attach_allowed)
-            ok(SUCCEEDED(hr), "Failed to attach palette to %s surface, hr %#x.\n", test_data[i].name, hr);
+            ok(SUCCEEDED(hr), "Failed to attach palette to %s surface, hr %#lx.\n", test_data[i].name, hr);
         else
-            ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#x, %s surface.\n", hr, test_data[i].name);
+            ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#lx, %s surface.\n", hr, test_data[i].name);
 
         if (SUCCEEDED(hr))
         {
@@ -8816,7 +8816,7 @@ static void test_palette_alpha(void)
 
             hr = IDirectDrawSurface2_GetDC(surface, &dc);
             ok(SUCCEEDED(hr) || broken(hr == DDERR_CANTCREATEDC) /* Win2k testbot */,
-                    "Failed to get DC, hr %#x, %s surface.\n", hr, test_data[i].name);
+                    "Failed to get DC, hr %#lx, %s surface.\n", hr, test_data[i].name);
             if (SUCCEEDED(hr))
             {
                 retval = GetDIBColorTable(dc, 1, 1, &rgbquad);
@@ -8830,7 +8830,7 @@ static void test_palette_alpha(void)
                 ok(rgbquad.rgbReserved == 0, "Expected rgbReserved = 0, got %u, %s surface.\n",
                         rgbquad.rgbReserved, test_data[i].name);
                 hr = IDirectDrawSurface2_ReleaseDC(surface, dc);
-                ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
             }
         }
         IDirectDrawSurface2_Release(surface);
@@ -8850,24 +8850,24 @@ static void test_palette_alpha(void)
     U3(surface_desc.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface2, (void **)&surface);
-    ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface2 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface2 interface, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface1);
 
     hr = IDirectDrawSurface2_SetPalette(surface, palette);
-    ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface2_Release(surface);
 
     /* The Windows 8 testbot keeps extra references to the primary
      * while in 8 bpp mode. */
     hr = IDirectDraw2_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#lx.\n", hr);
 
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -8890,7 +8890,7 @@ static void test_lost_device(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -8898,7 +8898,7 @@ static void test_lost_device(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     surface_desc.dwBackBufferCount = 1;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -8907,7 +8907,7 @@ static void test_lost_device(void)
     surface_desc.dwWidth = 100;
     surface_desc.dwHeight = 100;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -8928,83 +8928,83 @@ static void test_lost_device(void)
     }
 
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Restore(surface);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Restore(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface_Restore(vidmem_surface);
-        ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     ret = SetForegroundWindow(window1);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = restore_surfaces(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     /* Trying to restore the primary will crash, probably because flippable
@@ -9015,59 +9015,59 @@ static void test_lost_device(void)
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = restore_surfaces(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     ret = SetForegroundWindow(window1);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = restore_surfaces(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     IDirectDrawSurface_Release(surface);
@@ -9077,103 +9077,103 @@ static void test_lost_device(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     surface_desc.dwBackBufferCount = 1;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window2, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     memset(&caps, 0, sizeof(caps));
     caps.dwCaps = DDSCAPS_FLIP;
 
     hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &back_buffer);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Restore(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &back_buffer);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(back_buffer);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface_Release(back_buffer);
 
     if (vidmem_surface)
@@ -9181,7 +9181,7 @@ static void test_lost_device(void)
     IDirectDrawSurface_Release(sysmem_surface);
     IDirectDrawSurface_Release(surface);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window2);
     DestroyWindow(window1);
 }
@@ -9199,7 +9199,7 @@ static void test_surface_desc_lock(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -9208,36 +9208,36 @@ static void test_surface_desc_lock(void)
     surface_desc.dwHeight = 16;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0xaa, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!surface_desc.lpSurface, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
 
     memset(&surface_desc, 0xaa, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ok(surface_desc.lpSurface != NULL, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
     memset(&surface_desc, 0xaa, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!surface_desc.lpSurface, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
     hr = IDirectDrawSurface_Unlock(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0xaa, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!surface_desc.lpSurface, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
 
     IDirectDrawSurface_Release(surface);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -9295,13 +9295,13 @@ static void test_texturemapblend(void)
     }
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     material = create_diffuse_material(device, 0.0f, 0.0f, 0.0f, 1.0f);
     viewport = create_viewport(device, 0, 0, 640, 480);
     viewport_set_background(device, viewport, material);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     /* Test alpha with DDPF_ALPHAPIXELS texture - should be taken from texture alpha channel.
      *
@@ -9321,64 +9321,64 @@ static void test_texturemapblend(void)
     U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(ddsd.ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirect3DTexture2_GetHandle(texture, device, &texture_handle);
-    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 0xff0000ff;
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
     U5(fx).dwFillColor = 0x800000ff;
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
 
     /* Note that the ddraw1 version of this test runs tests 1-3 with D3DRENDERSTATE_COLORKEYENABLE
      * enabled, whereas this version only runs test 4 with color keying on. Because no color key
      * is set on the texture this should not result in different behavior. */
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_TLVERTEX, &test1_quads[0], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_TLVERTEX, &test1_quads[4], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 5, 5);
-    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 5);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 5, 245);
-    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 245);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
 
     IDirect3DTexture2_Release(texture);
     ref = IDirectDrawSurface_Release(surface);
-    ok(ref == 0, "Surface not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Surface not properly released, refcount %lu.\n", ref);
 
     /* Test alpha with texture that has no alpha channel - alpha should be taken from diffuse vertex color. */
     memset(&ddsd, 0, sizeof(ddsd));
@@ -9395,46 +9395,46 @@ static void test_texturemapblend(void)
     U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirect3DTexture2_GetHandle(texture, device, &texture_handle);
-    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     U5(fx).dwFillColor = 0xff0000ff;
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
     U5(fx).dwFillColor = 0x800000ff;
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_TLVERTEX, &test1_quads[0], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_TLVERTEX, &test1_quads[4], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 5, 5);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 5);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 5, 245);
-    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 245);
-    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08lx.\n", color);
 
     IDirect3DTexture2_Release(texture);
     ref = IDirectDrawSurface_Release(surface);
-    ok(ref == 0, "Surface not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Surface not properly released, refcount %lu.\n", ref);
 
     /* Test RGB - should multiply color components from diffuse vertex color and texture. */
     memset(&ddsd, 0, sizeof(ddsd));
@@ -9451,49 +9451,49 @@ static void test_texturemapblend(void)
     U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(ddsd.ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirect3DTexture2_GetHandle(texture, device, &texture_handle);
-    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     U5(fx).dwFillColor = 0x00ffffff;
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
     U5(fx).dwFillColor = 0x00ffff80;
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_TLVERTEX, &test2_quads[0], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_TLVERTEX, &test2_quads[4], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 5, 5);
-    ok(compare_color(color, 0x00ff0040, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0040, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 5);
-    ok(compare_color(color, 0x00ff0080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0080, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 5, 245);
-    ok(compare_color(color, 0x00800080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00800080, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 245);
-    ok(compare_color(color, 0x008000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x008000ff, 2), "Got unexpected color 0x%08lx.\n", color);
 
     IDirect3DTexture2_Release(texture);
     ref = IDirectDrawSurface_Release(surface);
-    ok(ref == 0, "Surface not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Surface not properly released, refcount %lu.\n", ref);
 
     /* Test alpha again, now with color keyed texture (colorkey emulation in wine can interfere). */
     memset(&ddsd, 0, sizeof(ddsd));
@@ -9510,64 +9510,64 @@ static void test_texturemapblend(void)
     U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x001f;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirect3DTexture2_GetHandle(texture, device, &texture_handle);
-    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     U5(fx).dwFillColor = 0xf800;
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
     U5(fx).dwFillColor = 0x001f;
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = 0x001f;
     ckey.dwColorSpaceHighValue = 0x001f;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_TLVERTEX, &test1_quads[0], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_TLVERTEX, &test1_quads[4], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 5, 5);
-    ok(compare_color(color, 0x00000000, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000000, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 5);
-    ok(compare_color(color, 0x00ff0000, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 5, 245);
-    ok(compare_color(color, 0x00000000, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000000, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 245);
-    ok(compare_color(color, 0x00800000, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00800000, 2), "Got unexpected color 0x%08lx.\n", color);
 
     IDirect3DTexture2_Release(texture);
     ref = IDirectDrawSurface_Release(surface);
-    ok(ref == 0, "Surface not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Surface not properly released, refcount %lu.\n", ref);
 
     destroy_viewport(device, viewport);
     ref = IDirect3DMaterial2_Release(material);
-    ok(ref == 0, "Material not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Material not properly released, refcount %lu.\n", ref);
     IDirectDrawSurface_Release(rt);
     IDirect3DDevice2_Release(device);
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Ddraw object not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -9597,32 +9597,32 @@ static void test_viewport_clear_rect(void)
     }
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     red = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f);
     viewport = create_viewport(device, 0, 0, 640, 480);
     viewport_set_background(device, viewport, red);
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
     green = create_diffuse_material(device, 0.0f, 1.0f, 0.0f, 1.0f);
     viewport2 = create_viewport(device, 100, 100, 20, 20);
     viewport_set_background(device, viewport2, green);
     hr = IDirect3DViewport2_Clear(viewport2, 1, &clear_rect2, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 85, 85);  /* Outside both. */
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 95, 95); /* Outside vp, inside rect. */
     /* AMD GPUs ignore the viewport dimensions and only care about the rectangle. */
     ok(compare_color(color, 0x00ff0000, 1) || broken(compare_color(color, 0x0000ff00, 1)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 105, 105); /* Inside both. */
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 115, 115); /* Inside vp, outside rect. */
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 125, 125); /* Outside both. */
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     destroy_viewport(device, viewport2);
     destroy_material(green);
@@ -9631,7 +9631,7 @@ static void test_viewport_clear_rect(void)
     IDirectDrawSurface_Release(rt);
     IDirect3DDevice2_Release(device);
     ref = IDirectDraw2_Release(ddraw);
-    ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Ddraw object not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -9813,13 +9813,13 @@ static void test_color_fill(void)
     }
 
     hr = IDirectDraw2_GetFourCCCodes(ddraw, &num_fourcc_codes, NULL);
-    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#lx.\n", hr);
     fourcc_codes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
             num_fourcc_codes * sizeof(*fourcc_codes));
     if (!fourcc_codes)
         goto done;
     hr = IDirectDraw2_GetFourCCCodes(ddraw, &num_fourcc_codes, fourcc_codes);
-    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#lx.\n", hr);
     for (i = 0; i < num_fourcc_codes; i++)
     {
         if (fourcc_codes[i] == MAKEFOURCC('Y', 'U', 'Y', '2'))
@@ -9832,7 +9832,7 @@ static void test_color_fill(void)
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw2_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
 
     if ((!support_yuy2 && !support_uyvy) || !(hal_caps.dwCaps & DDCAPS_OVERLAY))
         skip("Overlays or some YUV formats not supported, skipping YUV colorfill tests.\n");
@@ -9859,7 +9859,7 @@ static void test_color_fill(void)
         {
             struct format_support_check check = {&tests[i].format, FALSE};
             hr = IDirect3DDevice2_EnumTextureFormats(device, test_unsupported_formats_cb, &check);
-            ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#lx.\n", hr);
             if (!check.supported)
                 continue;
         }
@@ -9894,16 +9894,16 @@ static void test_color_fill(void)
         }
 
         hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x, surface %s.\n", hr, tests[i].name);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx, surface %s.\n", hr, tests[i].name);
 
         hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
         todo_wine_if (tests[i].format.dwFourCC)
-            ok(hr == tests[i].colorfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
+            ok(hr == tests[i].colorfill_hr, "Blt returned %#lx, expected %#lx, surface %s.\n",
                     hr, tests[i].colorfill_hr, tests[i].name);
 
         hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
         todo_wine_if (tests[i].format.dwFourCC)
-            ok(hr == tests[i].colorfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
+            ok(hr == tests[i].colorfill_hr, "Blt returned %#lx, expected %#lx, surface %s.\n",
                     hr, tests[i].colorfill_hr, tests[i].name);
 
         if (SUCCEEDED(hr) && tests[i].check_result)
@@ -9911,19 +9911,19 @@ static void test_color_fill(void)
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
             color = surface_desc.lpSurface;
-            ok(*color == tests[i].result, "Got clear result 0x%08x, expected 0x%08x, surface %s.\n",
+            ok(*color == tests[i].result, "Got clear result 0x%08lx, expected 0x%08lx, surface %s.\n",
                     *color, tests[i].result, tests[i].name);
             hr = IDirectDrawSurface_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
         }
 
         hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-        ok(hr == tests[i].depthfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
+        ok(hr == tests[i].depthfill_hr, "Blt returned %#lx, expected %#lx, surface %s.\n",
                 hr, tests[i].depthfill_hr, tests[i].name);
         hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-        ok(hr == tests[i].depthfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
+        ok(hr == tests[i].depthfill_hr, "Blt returned %#lx, expected %#lx, surface %s.\n",
                 hr, tests[i].depthfill_hr, tests[i].name);
 
         if (SUCCEEDED(hr) && tests[i].check_result)
@@ -9931,23 +9931,23 @@ static void test_color_fill(void)
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
             color = surface_desc.lpSurface;
             todo_wine_if(tests[i].caps & DDSCAPS_VIDEOMEMORY && U2(surface_desc).dwZBufferBitDepth != 16)
                 ok((*color & mask) == (tests[i].result & mask) || broken((*color & mask) == (expected_broken & mask))
                         || broken(is_warp && (*color & mask) == (~0u & mask)) /* Windows 8+ testbot. */,
-                        "Got clear result 0x%08x, expected 0x%08x, surface %s.\n",
+                        "Got clear result 0x%08lx, expected 0x%08lx, surface %s.\n",
                         *color & mask, tests[i].result & mask, tests[i].name);
             hr = IDirectDrawSurface_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
         }
 
         U5(fx).dwFillColor = 0xdeadbeef;
         fx.dwROP = BLACKNESS;
         hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
-        ok(FAILED(hr) == !tests[i].rop_success, "Blt returned %#x, expected %s, surface %s.\n",
+        ok(FAILED(hr) == !tests[i].rop_success, "Blt returned %#lx, expected %s, surface %s.\n",
                 hr, tests[i].rop_success ? "success" : "failure", tests[i].name);
-        ok(U5(fx).dwFillColor == 0xdeadbeef, "dwFillColor was set to 0x%08x, surface %s\n",
+        ok(U5(fx).dwFillColor == 0xdeadbeef, "dwFillColor was set to 0x%08lx, surface %s\n",
                 U5(fx).dwFillColor, tests[i].name);
 
         if (SUCCEEDED(hr) && tests[i].check_result)
@@ -9955,19 +9955,19 @@ static void test_color_fill(void)
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
             color = surface_desc.lpSurface;
-            ok(*color == 0, "Got clear result 0x%08x, expected 0x00000000, surface %s.\n",
+            ok(*color == 0, "Got clear result 0x%08lx, expected 0x00000000, surface %s.\n",
                     *color, tests[i].name);
             hr = IDirectDrawSurface_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
         }
 
         fx.dwROP = WHITENESS;
         hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
-        ok(FAILED(hr) == !tests[i].rop_success, "Blt returned %#x, expected %s, surface %s.\n",
+        ok(FAILED(hr) == !tests[i].rop_success, "Blt returned %#lx, expected %s, surface %s.\n",
                 hr, tests[i].rop_success ? "success" : "failure", tests[i].name);
-        ok(U5(fx).dwFillColor == 0xdeadbeef, "dwFillColor was set to 0x%08x, surface %s\n",
+        ok(U5(fx).dwFillColor == 0xdeadbeef, "dwFillColor was set to 0x%08lx, surface %s\n",
                 U5(fx).dwFillColor, tests[i].name);
 
         if (SUCCEEDED(hr) && tests[i].check_result)
@@ -9975,13 +9975,13 @@ static void test_color_fill(void)
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
             color = surface_desc.lpSurface;
             /* WHITENESS sets the alpha channel to 0x00. Ignore this for now. */
-            ok((*color & 0x00ffffff) == 0x00ffffff, "Got clear result 0x%08x, expected 0xffffffff, surface %s.\n",
+            ok((*color & 0x00ffffff) == 0x00ffffff, "Got clear result 0x%08lx, expected 0xffffffff, surface %s.\n",
                     *color, tests[i].name);
             hr = IDirectDrawSurface_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
         }
 
         IDirectDrawSurface_Release(surface);
@@ -10005,78 +10005,78 @@ static void test_color_fill(void)
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* No DDBLTFX. */
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_COLORFILL | DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_ROP | DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Unused source rectangle. */
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     /* Unused source surface. */
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     /* Inverted destination or source rectangle. */
     SetRect(&rect, 5, 7, 7, 5);
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, &rect, surface2, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
 
     /* Negative rectangle. */
     SetRect(&rect, -1, -1, 5, 5);
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, &rect, surface2, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, &rect, surface2, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
 
     /* Out of bounds rectangle. */
     SetRect(&rect, 0, 0, 65, 65);
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
 
     /* Combine multiple flags. */
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(rops); i++)
     {
         fx.dwROP = rops[i].rop;
         hr = IDirectDrawSurface_Blt(surface, NULL, surface2, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
-        ok(hr == rops[i].hr, "Got unexpected hr %#x for rop %s.\n", hr, rops[i].name);
+        ok(hr == rops[i].hr, "Got unexpected hr %#lx for rop %s.\n", hr, rops[i].name);
     }
 
     IDirectDrawSurface_Release(surface2);
@@ -10090,54 +10090,54 @@ static void test_color_fill(void)
     U2(surface_desc).dwZBufferBitDepth = get_device_z_depth(device);
     surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* No DDBLTFX. */
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Unused source rectangle. */
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     /* Unused source surface. */
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Inverted destination or source rectangle. */
     SetRect(&rect, 5, 7, 7, 5);
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, &rect, surface2, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Negative rectangle. */
     SetRect(&rect, -1, -1, 5, 5);
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, &rect, surface2, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, &rect, surface2, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Out of bounds rectangle. */
     SetRect(&rect, 0, 0, 65, 65);
     hr = IDirectDrawSurface_Blt(surface, &rect, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
 
     /* Combine multiple flags. */
     hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(surface2);
     IDirectDrawSurface_Release(surface);
@@ -10145,7 +10145,7 @@ static void test_color_fill(void)
 done:
     IDirect3DDevice2_Release(device);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(refcount == 0, "Ddraw object not properly released, refcount %u.\n", refcount);
+    ok(refcount == 0, "Ddraw object not properly released, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -10230,7 +10230,7 @@ static void test_colorkey_precision(void)
         return;
     }
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     is_nvidia = ddraw_is_nvidia(ddraw);
     /* The Windows 8 WARP driver has plenty of false negatives in X8R8G8B8
@@ -10245,16 +10245,16 @@ static void test_colorkey_precision(void)
     viewport = create_viewport(device, 0, 0, 640, 480);
     viewport_set_background(device, viewport, green);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable color keying, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable color keying, hr %#lx.\n", hr);
     /* There's no way to ignore the texture color in d3d2, so multiply the texture color
      * with a black vertex color. */
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATEALPHA);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
@@ -10279,9 +10279,9 @@ static void test_colorkey_precision(void)
         /* Windows XP (at least with the r200 driver, other drivers untested) produces
          * garbage when doing color keyed texture->texture blits. */
         hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &src, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
         hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
         U5(fx).dwFillColor = tests[t].clear;
         /* On the w8 testbot (WARP driver) the blit result has different values in the
@@ -10299,21 +10299,21 @@ static void test_colorkey_precision(void)
             surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = c << tests[t].shift;
             surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = c << tests[t].shift;
             hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &texture, NULL);
-            ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
             hr = IDirectDrawSurface4_QueryInterface(texture, &IID_IDirect3DTexture2, (void **)&d3d_texture);
-            ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
             hr = IDirect3DTexture2_GetHandle(d3d_texture, device, &handle);
-            ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to get texture handle, hr %#lx.\n", hr);
             hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, handle);
-            ok(SUCCEEDED(hr), "Failed to set texture handle, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set texture handle, hr %#lx.\n", hr);
             IDirect3DTexture2_Release(d3d_texture);
 
             hr = IDirectDrawSurface_Blt(dst, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-            ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#lx.\n", hr);
 
             hr = IDirectDrawSurface_Lock(src, NULL, &lock_desc, DDLOCK_WAIT, NULL);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
             switch (tests[t].bpp)
             {
                 case 4:
@@ -10331,21 +10331,21 @@ static void test_colorkey_precision(void)
                     break;
             }
             hr = IDirectDrawSurface_Unlock(src, 0);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
             hr = IDirectDrawSurface_Blt(texture, NULL, src, NULL, DDBLT_WAIT, NULL);
-            ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
             ckey.dwColorSpaceLowValue = c << tests[t].shift;
             ckey.dwColorSpaceHighValue = c << tests[t].shift;
             hr = IDirectDrawSurface_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-            ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
             hr = IDirectDrawSurface_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC | DDBLT_WAIT, NULL);
-            ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
             /* Don't make this read only, it somehow breaks the detection of the Nvidia bug below. */
             hr = IDirectDrawSurface_Lock(dst, NULL, &lock_desc, DDLOCK_WAIT, NULL);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
             switch (tests[t].bpp)
             {
                 case 4:
@@ -10363,11 +10363,11 @@ static void test_colorkey_precision(void)
                     break;
             }
             hr = IDirectDrawSurface_Unlock(dst, 0);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
             if (!c)
             {
-                ok(data[0] == tests[t].clear, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+                ok(data[0] == tests[t].clear, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                         tests[t].clear, data[0], tests[t].name, c);
 
                 if (data[3] == tests[t].clear)
@@ -10391,56 +10391,56 @@ static void test_colorkey_precision(void)
                 }
             }
             else
-                ok(data[0] == (c - 1) << tests[t].shift, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+                ok(data[0] == (c - 1) << tests[t].shift, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                         (c - 1) << tests[t].shift, data[0], tests[t].name, c);
 
-            ok(data[1] == tests[t].clear, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+            ok(data[1] == tests[t].clear, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                     tests[t].clear, data[1], tests[t].name, c);
 
             if (c == tests[t].max)
-                ok(data[2] == tests[t].clear, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+                ok(data[2] == tests[t].clear, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                         tests[t].clear, data[2], tests[t].name, c);
             else
-                ok(data[2] == (c + 1) << tests[t].shift, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+                ok(data[2] == (c + 1) << tests[t].shift, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                         (c + 1) << tests[t].shift, data[2], tests[t].name, c);
 
             hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-            ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice2_BeginScene(device);
-            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
             hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, quad, 4, 0);
-            ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
             hr = IDirect3DDevice2_EndScene(device);
-            ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
             color = get_surface_color(rt, 80, 240);
             if (!c)
                 ok(compare_color(color, 0x0000ff00, 1) || broken(is_warp && compare_color(color, 0x00000000, 1)),
-                        "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                        "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                         color, tests[t].name, c);
             else
                 ok(compare_color(color, 0x00000000, 1) || broken(is_warp && compare_color(color, 0x0000ff00, 1)),
-                        "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                        "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                         color, tests[t].name, c);
 
             color = get_surface_color(rt, 240, 240);
             ok(compare_color(color, 0x0000ff00, 1) || broken(is_warp && compare_color(color, 0x00000000, 1)),
-                    "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                    "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                     color, tests[t].name, c);
 
             color = get_surface_color(rt, 400, 240);
             if (c == tests[t].max)
                 ok(compare_color(color, 0x0000ff00, 1) || broken(is_warp && compare_color(color, 0x00000000, 1)),
-                        "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                        "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                         color, tests[t].name, c);
             else
                 ok(compare_color(color, 0x00000000, 1) || broken(is_warp && compare_color(color, 0x0000ff00, 1)),
-                        "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                        "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                         color, tests[t].name, c);
 
             hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, 0);
-            ok(SUCCEEDED(hr), "Failed to set texture handle, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set texture handle, hr %#lx.\n", hr);
             IDirectDrawSurface_Release(texture);
         }
         IDirectDrawSurface_Release(src);
@@ -10453,7 +10453,7 @@ done:
     IDirectDrawSurface_Release(rt);
     IDirect3DDevice2_Release(device);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(refcount == 0, "Ddraw object not properly released, refcount %u.\n", refcount);
+    ok(refcount == 0, "Ddraw object not properly released, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -10471,7 +10471,7 @@ static void test_range_colorkey(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -10490,85 +10490,85 @@ static void test_range_colorkey(void)
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000000;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000001;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     /* Same for DDSCAPS_OFFSCREENPLAIN. */
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000000;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000001;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000000;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* Setting a range color key without DDCKEY_COLORSPACE collapses the key. */
     ckey.dwColorSpaceLowValue = 0x00000000;
     ckey.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_GetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(!ckey.dwColorSpaceLowValue, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceLowValue);
-    ok(!ckey.dwColorSpaceHighValue, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(!ckey.dwColorSpaceLowValue, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceLowValue);
+    ok(!ckey.dwColorSpaceHighValue, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceHighValue);
 
     ckey.dwColorSpaceLowValue = 0x00000001;
     ckey.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_GetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(ckey.dwColorSpaceLowValue == 0x00000001, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceLowValue);
-    ok(ckey.dwColorSpaceHighValue == 0x00000001, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(ckey.dwColorSpaceLowValue == 0x00000001, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceLowValue);
+    ok(ckey.dwColorSpaceHighValue == 0x00000001, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceHighValue);
 
     /* DDCKEY_COLORSPACE is ignored if the key is a single value. */
     ckey.dwColorSpaceLowValue = 0x00000000;
     ckey.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     /* Using it with a range key results in DDERR_NOCOLORKEYHW. */
     ckey.dwColorSpaceLowValue = 0x00000001;
     ckey.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
     ckey.dwColorSpaceLowValue = 0x00000000;
     ckey.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
     /* Range destination keys don't work either. */
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_DESTBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     /* Just to show it's not because of A, R, and G having equal values. */
     ckey.dwColorSpaceLowValue = 0x00000000;
     ckey.dwColorSpaceHighValue = 0x01010101;
     hr = IDirectDrawSurface_SetColorKey(surface, DDCKEY_SRCBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     /* None of these operations modified the key. */
     hr = IDirectDrawSurface_GetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(!ckey.dwColorSpaceLowValue, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceLowValue);
-    ok(!ckey.dwColorSpaceHighValue, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(!ckey.dwColorSpaceLowValue, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceLowValue);
+    ok(!ckey.dwColorSpaceHighValue, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceHighValue);
 
     IDirectDrawSurface_Release(surface);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -10631,16 +10631,16 @@ static void test_shademode(void)
     }
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     background = create_diffuse_material(device, 1.0f, 1.0f, 1.0f, 1.0f);
     viewport = create_viewport(device, 0, 0, 640, 480);
     viewport_set_background(device, viewport, background);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#lx.\n", hr);
 
     /* Try it first with a TRIANGLESTRIP.  Do it with different geometry because
      * the color fixups we have to do for FLAT shading will be dependent on that. */
@@ -10648,19 +10648,19 @@ static void test_shademode(void)
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_SHADEMODE, tests[i].shademode);
-        ok(hr == D3D_OK, "Failed to set shade mode, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to set shade mode, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice2_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         quad = tests[i].primtype == D3DPT_TRIANGLESTRIP ? quad_strip : quad_list;
         count = tests[i].primtype == D3DPT_TRIANGLESTRIP ? 4 : 6;
         hr = IDirect3DDevice2_DrawPrimitive(device, tests[i].primtype, D3DVT_LVERTEX, quad, count, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice2_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color0 = get_surface_color(rt, 100, 100); /* Inside first triangle */
         color1 = get_surface_color(rt, 500, 350); /* Inside second triangle */
@@ -10670,9 +10670,9 @@ static void test_shademode(void)
          * functionality being available. */
         /* PHONG should be the same as GOURAUD, since no hardware implements
          * this. */
-        ok(compare_color(color0, tests[i].color0, 1), "Test %u shading has color0 %08x, expected %08x.\n",
+        ok(compare_color(color0, tests[i].color0, 1), "Test %u shading has color0 %08lx, expected %08lx.\n",
                 i, color0, tests[i].color0);
-        ok(compare_color(color1, tests[i].color1, 1), "Test %u shading has color1 %08x, expected %08x.\n",
+        ok(compare_color(color1, tests[i].color1, 1), "Test %u shading has color1 %08lx, expected %08lx.\n",
                 i, color1, tests[i].color1);
     }
 
@@ -10680,7 +10680,7 @@ static void test_shademode(void)
     destroy_material(background);
     IDirectDrawSurface_Release(rt);
     refcount = IDirect3DDevice2_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirectDraw2_Release(ddraw);
     DestroyWindow(window);
 }
@@ -10735,12 +10735,12 @@ static void test_lockrect_invalid(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw2_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & needed_caps) != needed_caps)
     {
         skip("Required surface types not supported, skipping test.\n");
@@ -10763,13 +10763,13 @@ static void test_lockrect_invalid(void)
         U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x0000ff;
 
         hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx, type %s.\n", hr, resources[r].name);
         hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface2, (void **)&surface);
-        ok(SUCCEEDED(hr), "Failed to QI IDirectDrawSurface2 interface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to QI IDirectDrawSurface2 interface, hr %#lx.\n", hr);
         IDirectDrawSurface_Release(surface1);
 
         hr = IDirectDrawSurface2_Lock(surface, NULL, NULL, DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name);
+        ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx, type %s.\n", hr, resources[r].name);
 
         for (i = 0; i < ARRAY_SIZE(valid); ++i)
         {
@@ -10779,11 +10779,11 @@ static void test_lockrect_invalid(void)
             surface_desc.dwSize = sizeof(surface_desc);
 
             hr = IDirectDrawSurface2_Lock(surface, rect, &surface_desc, DDLOCK_WAIT, NULL);
-            ok(SUCCEEDED(hr), "Lock failed (%#x) for rect %s, type %s.\n",
+            ok(SUCCEEDED(hr), "Lock failed (%#lx) for rect %s, type %s.\n",
                     hr, wine_dbgstr_rect(rect), resources[r].name);
 
             hr = IDirectDrawSurface2_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
         }
 
         for (i = 0; i < ARRAY_SIZE(invalid); ++i)
@@ -10794,37 +10794,37 @@ static void test_lockrect_invalid(void)
             surface_desc.dwSize = sizeof(surface_desc);
 
             hr = IDirectDrawSurface2_Lock(surface, rect, &surface_desc, DDLOCK_WAIT, NULL);
-            ok(hr == resources[r].hr, "Lock returned %#x for rect %s, type %s.\n",
+            ok(hr == resources[r].hr, "Lock returned %#lx for rect %s, type %s.\n",
                     hr, wine_dbgstr_rect(rect), resources[r].name);
             if (SUCCEEDED(hr))
             {
                 hr = IDirectDrawSurface2_Unlock(surface, NULL);
-                ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+                ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
             }
             else
                 ok(!surface_desc.lpSurface, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
         }
 
         hr = IDirectDrawSurface2_Lock(surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Lock(rect = NULL) failed, hr %#x, type %s.\n",
+        ok(SUCCEEDED(hr), "Lock(rect = NULL) failed, hr %#lx, type %s.\n",
                 hr, resources[r].name);
         hr = IDirectDrawSurface2_Lock(surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_SURFACEBUSY, "Double lock(rect = NULL) returned %#x, type %s.\n",
+        ok(hr == DDERR_SURFACEBUSY, "Double lock(rect = NULL) returned %#lx, type %s.\n",
                 hr, resources[r].name);
         hr = IDirectDrawSurface2_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
 
         hr = IDirectDrawSurface2_Lock(surface, &valid[0], &surface_desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Lock(rect = %s) failed (%#x).\n", wine_dbgstr_rect(&valid[0]), hr);
+        ok(SUCCEEDED(hr), "Lock(rect = %s) failed (%#lx).\n", wine_dbgstr_rect(&valid[0]), hr);
         hr = IDirectDrawSurface2_Lock(surface, &valid[0], &surface_desc, DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_SURFACEBUSY, "Double lock(rect = %s) failed (%#x).\n",
+        ok(hr == DDERR_SURFACEBUSY, "Double lock(rect = %s) failed (%#lx).\n",
                 wine_dbgstr_rect(&valid[0]), hr);
 
         /* Locking a different rectangle returns DD_OK, but it seems to break the surface.
          * Afterwards unlocking the surface fails(NULL rectangle or both locked rectangles) */
 
         hr = IDirectDrawSurface2_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
 
         IDirectDrawSurface2_Release(surface);
     }
@@ -10849,7 +10849,7 @@ static void test_yv12_overlay(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     if (!(src_surface = create_overlay(ddraw, 256, 256, MAKEFOURCC('Y','V','1','2'))))
     {
@@ -10860,17 +10860,17 @@ static void test_yv12_overlay(void)
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
     hr = IDirectDrawSurface_Lock(src_surface, NULL, &desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
 
     ok(desc.dwFlags == (DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS | DDSD_PITCH),
-            "Got unexpected flags %#x.\n", desc.dwFlags);
+            "Got unexpected flags %#lx.\n", desc.dwFlags);
     ok(desc.ddsCaps.dwCaps == (DDSCAPS_OVERLAY | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM | DDSCAPS_HWCODEC)
             || desc.ddsCaps.dwCaps == (DDSCAPS_OVERLAY | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM),
-            "Got unexpected caps %#x.\n", desc.ddsCaps.dwCaps);
-    ok(desc.dwWidth == 256, "Got unexpected width %u.\n", desc.dwWidth);
-    ok(desc.dwHeight == 256, "Got unexpected height %u.\n", desc.dwHeight);
+            "Got unexpected caps %#lx.\n", desc.ddsCaps.dwCaps);
+    ok(desc.dwWidth == 256, "Got unexpected width %lu.\n", desc.dwWidth);
+    ok(desc.dwHeight == 256, "Got unexpected height %lu.\n", desc.dwHeight);
     /* The overlay pitch seems to have 256 byte alignment. */
-    ok(!(U1(desc).lPitch & 0xff), "Got unexpected pitch %u.\n", U1(desc).lPitch);
+    ok(!(U1(desc).lPitch & 0xff), "Got unexpected pitch %lu.\n", U1(desc).lPitch);
 
     /* Fill the surface with some data for the blit test. */
     base = desc.lpSurface;
@@ -10891,7 +10891,7 @@ static void test_yv12_overlay(void)
     }
 
     hr = IDirectDrawSurface_Unlock(src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* YV12 uses 2x2 blocks with 6 bytes per block (4*Y, 1*U, 1*V). Unlike
      * other block-based formats like DXT the entire Y channel is stored in
@@ -10899,12 +10899,12 @@ static void test_yv12_overlay(void)
      * locks do not really make sense. Show that they are allowed nevertheless
      * and the offset points into the luminance data. */
     hr = IDirectDrawSurface_Lock(src_surface, &rect, &desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     offset = ((const unsigned char *)desc.lpSurface - base);
-    ok(offset == rect.top * U1(desc).lPitch + rect.left, "Got unexpected offset %u, expected %u.\n",
+    ok(offset == rect.top * U1(desc).lPitch + rect.left, "Got unexpected offset %u, expected %lu.\n",
             offset, rect.top * U1(desc).lPitch + rect.left);
     hr = IDirectDrawSurface_Unlock(src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     if (!(dst_surface = create_overlay(ddraw, 256, 256, MAKEFOURCC('Y','V','1','2'))))
     {
@@ -10918,14 +10918,14 @@ static void test_yv12_overlay(void)
     hr = IDirectDrawSurface_Blt(dst_surface, NULL, src_surface, NULL, DDBLT_WAIT, NULL);
     /* VMware rejects YV12 blits. This behavior has not been seen on real
      * hardware yet, so mark it broken. */
-    ok(SUCCEEDED(hr) || broken(hr == E_NOTIMPL), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == E_NOTIMPL), "Failed to blit, hr %#lx.\n", hr);
 
     if (SUCCEEDED(hr))
     {
         memset(&desc, 0, sizeof(desc));
         desc.dwSize = sizeof(desc);
         hr = IDirectDrawSurface_Lock(dst_surface, NULL, &desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
 
         base = desc.lpSurface;
         ok(base[0] == 0x10, "Got unexpected Y data 0x%02x.\n", base[0]);
@@ -10935,7 +10935,7 @@ static void test_yv12_overlay(void)
         ok(base[0] == 0x30, "Got unexpected U data 0x%02x.\n", base[0]);
 
         hr = IDirectDrawSurface_Unlock(dst_surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
     }
 
     IDirectDrawSurface_Release(dst_surface);
@@ -10971,7 +10971,7 @@ static void test_offscreen_overlay(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     if (!(overlay = create_overlay(ddraw, 64, 64, MAKEFOURCC('U','Y','V','Y'))))
     {
@@ -10984,21 +10984,21 @@ static void test_offscreen_overlay(void)
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     /* On Windows 7, and probably Vista, UpdateOverlay() will return
      * DDERR_OUTOFCAPS if the dwm is active. Calling GetDC() on the primary
      * surface prevents this by disabling the dwm. */
     hr = IDirectDrawSurface_GetDC(primary, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_ReleaseDC(primary, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     /* Try to overlay a NULL surface. */
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_SHOW, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_HIDE, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Try to overlay an offscreen surface. */
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -11015,18 +11015,18 @@ static void test_offscreen_overlay(void)
     U3(surface_desc.ddpfPixelFormat).dwGBitMask = 0x07e0;
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x001f;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &offscreen, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, offscreen, NULL, DDOVER_SHOW, NULL);
     ok(SUCCEEDED(hr) || broken(hr == DDERR_OUTOFCAPS && dwm_enabled())
             || broken(hr == E_NOTIMPL && ddraw_is_vmware(ddraw)),
-            "Failed to update overlay, hr %#x.\n", hr);
+            "Failed to update overlay, hr %#lx.\n", hr);
 
     /* Try to overlay the primary with a non-overlay surface. */
     hr = IDirectDrawSurface_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_SHOW, NULL);
-    ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_HIDE, NULL);
-    ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(offscreen);
     IDirectDrawSurface_Release(primary);
@@ -11051,7 +11051,7 @@ static void test_overlay_rect(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     if (!(overlay = create_overlay(ddraw, 64, 64, MAKEFOURCC('U','Y','V','Y'))))
     {
@@ -11064,15 +11064,15 @@ static void test_overlay_rect(void)
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     /* On Windows 7, and probably Vista, UpdateOverlay() will return
      * DDERR_OUTOFCAPS if the dwm is active. Calling GetDC() on the primary
      * surface prevents this by disabling the dwm. */
     hr = IDirectDrawSurface_GetDC(primary, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_ReleaseDC(primary, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     /* On Windows 8 and newer DWM can't be turned off, making overlays unusable. */
     if (dwm_enabled())
@@ -11085,48 +11085,48 @@ static void test_overlay_rect(void)
      * used. This is not true in Windows Vista and earlier, but changed in
      * Windows 7. */
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, primary, &rect, DDOVER_SHOW, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, primary, NULL, DDOVER_HIDE, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, primary, NULL, DDOVER_SHOW, NULL);
-    ok(hr == DD_OK || hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Show that the overlay position is the (top, left) coordinate of the
      * destination rectangle. */
     OffsetRect(&rect, 32, 16);
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, primary, &rect, DDOVER_SHOW, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#lx.\n", hr);
     pos_x = -1; pos_y = -1;
     hr = IDirectDrawSurface_GetOverlayPosition(overlay, &pos_x, &pos_y);
-    ok(SUCCEEDED(hr), "Failed to get overlay position, hr %#x.\n", hr);
-    ok(pos_x == rect.left, "Got unexpected pos_x %d, expected %d.\n", pos_x, rect.left);
-    ok(pos_y == rect.top, "Got unexpected pos_y %d, expected %d.\n", pos_y, rect.top);
+    ok(SUCCEEDED(hr), "Failed to get overlay position, hr %#lx.\n", hr);
+    ok(pos_x == rect.left, "Got unexpected pos_x %ld, expected %ld.\n", pos_x, rect.left);
+    ok(pos_y == rect.top, "Got unexpected pos_y %ld, expected %ld.\n", pos_y, rect.top);
 
     /* Passing a NULL dest rect sets the position to 0/0. Visually it can be
      * seen that the overlay overlays the whole primary(==screen). */
     hr2 = IDirectDrawSurface_UpdateOverlay(overlay, NULL, primary, NULL, 0, NULL);
-    ok(hr2 == DD_OK || hr2 == DDERR_INVALIDPARAMS || hr2 == DDERR_OUTOFCAPS, "Got unexpected hr %#x.\n", hr2);
+    ok(hr2 == DD_OK || hr2 == DDERR_INVALIDPARAMS || hr2 == DDERR_OUTOFCAPS, "Got unexpected hr %#lx.\n", hr2);
     hr = IDirectDrawSurface_GetOverlayPosition(overlay, &pos_x, &pos_y);
-    ok(SUCCEEDED(hr), "Failed to get overlay position, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get overlay position, hr %#lx.\n", hr);
     if (SUCCEEDED(hr2))
     {
-        ok(!pos_x, "Got unexpected pos_x %d.\n", pos_x);
-        ok(!pos_y, "Got unexpected pos_y %d.\n", pos_y);
+        ok(!pos_x, "Got unexpected pos_x %ld.\n", pos_x);
+        ok(!pos_y, "Got unexpected pos_y %ld.\n", pos_y);
     }
     else
     {
-        ok(pos_x == 32, "Got unexpected pos_x %d.\n", pos_x);
-        ok(pos_y == 16, "Got unexpected pos_y %d.\n", pos_y);
+        ok(pos_x == 32, "Got unexpected pos_x %ld.\n", pos_x);
+        ok(pos_y == 16, "Got unexpected pos_y %ld.\n", pos_y);
     }
 
     /* The position cannot be retrieved when the overlay is not shown. */
     hr = IDirectDrawSurface_UpdateOverlay(overlay, NULL, primary, &rect, DDOVER_HIDE, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#lx.\n", hr);
     pos_x = -1; pos_y = -1;
     hr = IDirectDrawSurface_GetOverlayPosition(overlay, &pos_x, &pos_y);
-    ok(hr == DDERR_OVERLAYNOTVISIBLE, "Got unexpected hr %#x.\n", hr);
-    ok(!pos_x, "Got unexpected pos_x %d.\n", pos_x);
-    ok(!pos_y, "Got unexpected pos_y %d.\n", pos_y);
+    ok(hr == DDERR_OVERLAYNOTVISIBLE, "Got unexpected hr %#lx.\n", hr);
+    ok(!pos_x, "Got unexpected pos_x %ld.\n", pos_x);
+    ok(!pos_y, "Got unexpected pos_y %ld.\n", pos_y);
 
 done:
     if (primary)
@@ -11180,7 +11180,7 @@ static void test_blt(void)
     }
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -11189,36 +11189,36 @@ static void test_blt(void)
     surface_desc.dwHeight = 480;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Blt(surface, NULL, surface, NULL, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Blt(surface, NULL, rt, NULL, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect,
                 surface, &test_data[i].src_rect, DDBLT_WAIT, NULL);
-        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
 
         hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect,
                 rt, &test_data[i].src_rect, DDBLT_WAIT, NULL);
-        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
 
         hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect,
                 NULL, &test_data[i].src_rect, DDBLT_WAIT, NULL);
-        ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect, NULL, NULL, DDBLT_WAIT, NULL);
-        ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#lx.\n", i, hr);
     }
 
     IDirectDrawSurface_Release(surface);
     IDirectDrawSurface_Release(rt);
     refcount = IDirect3DDevice2_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirectDraw2_Release(ddraw);
     DestroyWindow(window);
 }
@@ -11260,7 +11260,7 @@ static void test_blt_z_alpha(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&pf, 0, sizeof(pf));
     pf.dwSize = sizeof(pf);
@@ -11280,9 +11280,9 @@ static void test_blt_z_alpha(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
 
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#lx.\n", hr);
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &dst_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
@@ -11302,23 +11302,23 @@ static void test_blt_z_alpha(void)
     {
         U5(fx).dwFillColor = 0x3300ff00;
         hr = IDirectDrawSurface_Blt(src_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         U5(fx).dwFillColor = 0xccff0000;
         hr = IDirectDrawSurface_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirectDrawSurface_Blt(dst_surface, NULL, src_surface, NULL, blt_flags[i] | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         color = get_surface_color(dst_surface, 32, 32);
-        ok(compare_color(color, 0x0000ff00, 0), "Test %u: Got unexpected color 0x%08x.\n", i, color);
+        ok(compare_color(color, 0x0000ff00, 0), "Test %u: Got unexpected color 0x%08lx.\n", i, color);
     }
 
     IDirectDrawSurface_Release(dst_surface);
     IDirectDrawSurface_Release(src_surface);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -11364,7 +11364,7 @@ static void test_cross_device_blt(void)
     surface_desc.dwHeight = 480;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -11372,7 +11372,7 @@ static void test_cross_device_blt(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_VIDEOMEMORY;
     surface_desc.dwBackBufferCount = 2;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -11387,37 +11387,37 @@ static void test_cross_device_blt(void)
     U3(surface_desc.ddpfPixelFormat).dwGBitMask = 0x000003e0;
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x0000001f;
     hr = IDirectDraw2_CreateSurface(ddraw2, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 0xff0000ff;
     hr = IDirectDrawSurface_Blt(surface2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(surface, 320, 240);
-    ok(color == 0x00000000, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00000000, "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirectDrawSurface_Blt(sysmem_surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(sysmem_surface, 320, 240);
-    ok(color == 0x00000000, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00000000, "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_IsLost(sysmem_surface);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Blt(sysmem_surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(sysmem_surface, 320, 240);
-    ok(color == 0x00000000, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00000000, "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface_Release(surface2);
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -11427,22 +11427,22 @@ static void test_cross_device_blt(void)
     surface_desc.dwHeight = 480;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw2_CreateSurface(ddraw2, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_Blt(surface2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Blt(sysmem_surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    todo_wine ok(hr == D3D_OK, "Failed to blit, hr %#x.\n", hr);
+    todo_wine ok(hr == D3D_OK, "Failed to blit, hr %#lx.\n", hr);
     color = get_surface_color(sysmem_surface, 320, 240);
-    todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface_Release(surface);
     IDirectDrawSurface_Release(surface2);
     IDirectDrawSurface_Release(sysmem_surface);
     refcount = IDirect3DDevice2_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     refcount = IDirect3DDevice2_Release(device2);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirectDraw2_Release(ddraw);
     IDirectDraw2_Release(ddraw2);
     DestroyWindow(window);
@@ -11517,11 +11517,11 @@ static void test_getdc(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw2_GetDisplayMode(ddraw, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#lx.\n", hr);
     screen_bpp = U1(surface_desc.ddpfPixelFormat).dwRGBBitCount;
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
@@ -11539,7 +11539,7 @@ static void test_getdc(void)
             surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
             if (FAILED(hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL)))
             {
-                skip("Failed to create surface for format %s (hr %#x), skipping tests.\n", test_data[i].name, hr);
+                skip("Failed to create surface for format %s (hr %#lx), skipping tests.\n", test_data[i].name, hr);
                 continue;
             }
         }
@@ -11548,9 +11548,9 @@ static void test_getdc(void)
         hr = IDirectDrawSurface_GetDC(surface, &dc);
         if (test_data[i].getdc_supported)
             ok(SUCCEEDED(hr) || broken(hr == test_data[i].alt_result || ddraw_is_vmware(ddraw)),
-                    "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+                    "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         else
-            ok(FAILED(hr), "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+            ok(FAILED(hr), "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         if (SUCCEEDED(hr))
         {
@@ -11561,10 +11561,10 @@ static void test_getdc(void)
             int size;
 
             type = GetObjectType(dc);
-            ok(type == OBJ_MEMDC, "Got unexpected object type %#x for format %s.\n", type, test_data[i].name);
+            ok(type == OBJ_MEMDC, "Got unexpected object type %#lx for format %s.\n", type, test_data[i].name);
             bitmap = GetCurrentObject(dc, OBJ_BITMAP);
             type = GetObjectType(bitmap);
-            ok(type == OBJ_BITMAP, "Got unexpected object type %#x for format %s.\n", type, test_data[i].name);
+            ok(type == OBJ_BITMAP, "Got unexpected object type %#lx for format %s.\n", type, test_data[i].name);
 
             size = GetObjectA(bitmap, sizeof(dib), &dib);
             ok(size == sizeof(dib), "Got unexpected size %d for format %s.\n", size, test_data[i].name);
@@ -11588,11 +11588,11 @@ static void test_getdc(void)
             ok(!!dib.dsBm.bmBits || broken(!pDwmIsCompositionEnabled && dib.dsBm.bmBitsPixel == screen_bpp),
                     "Got unexpected bits %p for format %s.\n", dib.dsBm.bmBits, test_data[i].name);
 
-            ok(dib.dsBmih.biSize == sizeof(dib.dsBmih), "Got unexpected size %u for format %s.\n",
+            ok(dib.dsBmih.biSize == sizeof(dib.dsBmih), "Got unexpected size %lu for format %s.\n",
                     dib.dsBmih.biSize, test_data[i].name);
-            ok(dib.dsBmih.biWidth == surface_desc.dwWidth, "Got unexpected width %d for format %s.\n",
+            ok(dib.dsBmih.biWidth == surface_desc.dwWidth, "Got unexpected width %ld for format %s.\n",
                     dib.dsBmih.biHeight, test_data[i].name);
-            ok(dib.dsBmih.biHeight == surface_desc.dwHeight, "Got unexpected height %d for format %s.\n",
+            ok(dib.dsBmih.biHeight == surface_desc.dwHeight, "Got unexpected height %ld for format %s.\n",
                     dib.dsBmih.biHeight, test_data[i].name);
             ok(dib.dsBmih.biPlanes == 1, "Got unexpected plane count %u for format %s.\n",
                     dib.dsBmih.biPlanes, test_data[i].name);
@@ -11601,17 +11601,17 @@ static void test_getdc(void)
                     dib.dsBmih.biBitCount, test_data[i].name);
             ok(dib.dsBmih.biCompression == (U1(test_data[i].format).dwRGBBitCount == 16 ? BI_BITFIELDS : BI_RGB)
                     || broken(U1(test_data[i].format).dwRGBBitCount == 32 && dib.dsBmih.biCompression == BI_BITFIELDS),
-                    "Got unexpected compression %#x for format %s.\n",
+                    "Got unexpected compression %#lx for format %s.\n",
                     dib.dsBmih.biCompression, test_data[i].name);
-            ok(!dib.dsBmih.biSizeImage, "Got unexpected image size %u for format %s.\n",
+            ok(!dib.dsBmih.biSizeImage, "Got unexpected image size %lu for format %s.\n",
                     dib.dsBmih.biSizeImage, test_data[i].name);
-            ok(!dib.dsBmih.biXPelsPerMeter, "Got unexpected horizontal resolution %d for format %s.\n",
+            ok(!dib.dsBmih.biXPelsPerMeter, "Got unexpected horizontal resolution %ld for format %s.\n",
                     dib.dsBmih.biXPelsPerMeter, test_data[i].name);
-            ok(!dib.dsBmih.biYPelsPerMeter, "Got unexpected vertical resolution %d for format %s.\n",
+            ok(!dib.dsBmih.biYPelsPerMeter, "Got unexpected vertical resolution %ld for format %s.\n",
                     dib.dsBmih.biYPelsPerMeter, test_data[i].name);
-            ok(!dib.dsBmih.biClrUsed, "Got unexpected used colour count %u for format %s.\n",
+            ok(!dib.dsBmih.biClrUsed, "Got unexpected used colour count %lu for format %s.\n",
                     dib.dsBmih.biClrUsed, test_data[i].name);
-            ok(!dib.dsBmih.biClrImportant, "Got unexpected important colour count %u for format %s.\n",
+            ok(!dib.dsBmih.biClrImportant, "Got unexpected important colour count %lu for format %s.\n",
                     dib.dsBmih.biClrImportant, test_data[i].name);
 
             if (dib.dsBmih.biCompression == BI_BITFIELDS)
@@ -11620,20 +11620,20 @@ static void test_getdc(void)
                         && dib.dsBitfields[1] == U3(test_data[i].format).dwGBitMask
                         && dib.dsBitfields[2] == U4(test_data[i].format).dwBBitMask)
                         || broken(!dib.dsBitfields[0] && !dib.dsBitfields[1] && !dib.dsBitfields[2]),
-                        "Got unexpected colour masks 0x%08x 0x%08x 0x%08x for format %s.\n",
+                        "Got unexpected colour masks 0x%08lx 0x%08lx 0x%08lx for format %s.\n",
                         dib.dsBitfields[0], dib.dsBitfields[1], dib.dsBitfields[2], test_data[i].name);
             }
             else
             {
                 ok(!dib.dsBitfields[0] && !dib.dsBitfields[1] && !dib.dsBitfields[2],
-                        "Got unexpected colour masks 0x%08x 0x%08x 0x%08x for format %s.\n",
+                        "Got unexpected colour masks 0x%08lx 0x%08lx 0x%08lx for format %s.\n",
                         dib.dsBitfields[0], dib.dsBitfields[1], dib.dsBitfields[2], test_data[i].name);
             }
             ok(!dib.dshSection, "Got unexpected section %p for format %s.\n", dib.dshSection, test_data[i].name);
-            ok(!dib.dsOffset, "Got unexpected offset %u for format %s.\n", dib.dsOffset, test_data[i].name);
+            ok(!dib.dsOffset, "Got unexpected offset %lu for format %s.\n", dib.dsOffset, test_data[i].name);
 
             hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-            ok(hr == DD_OK, "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+            ok(hr == DD_OK, "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         }
         else
         {
@@ -11648,152 +11648,152 @@ static void test_getdc(void)
         surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
         if (FAILED(hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL)))
         {
-            skip("Failed to create mip-mapped texture for format %s (hr %#x), skipping tests.\n",
+            skip("Failed to create mip-mapped texture for format %s (hr %#lx), skipping tests.\n",
                     test_data[i].name, hr);
             continue;
         }
 
         hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &tmp);
-        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_GetAttachedSurface(tmp, &caps, &surface2);
-        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         IDirectDrawSurface_Release(tmp);
 
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         dc2 = (void *)0x1234;
         hr = IDirectDrawSurface_GetDC(surface, &dc2);
-        ok(hr == DDERR_DCALREADYCREATED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_DCALREADYCREATED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         ok(dc2 == (void *)0x1234, "Got unexpected dc %p for format %s.\n", dc, test_data[i].name);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(hr == DDERR_NODC, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NODC, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         map_desc.dwSize = sizeof(map_desc);
         hr = IDirectDrawSurface_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_SURFACEBUSY, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_SURFACEBUSY, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_SURFACEBUSY, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_SURFACEBUSY, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         /* Geforce 9600, Windows 7 returns E_FAIL. The unlock still seems to work as intended, after-
          * wards the surface can be locked again. ReleaseDC() does not unlock the surface, trying to
          * Lock it after ReleaseDC returns DDERR_SURFACEBUSY. ddraw4 and 7 are unaffected. */
         hr = IDirectDrawSurface_Unlock(surface, NULL);
         ok(SUCCEEDED(hr) || broken(ddraw_is_nvidia(ddraw) && hr == E_FAIL),
-                "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+                "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_GetDC(surface2, &dc2);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface2, dc2);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_GetDC(surface, &dc2);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc2);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Lock(surface2, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface2, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface, NULL);
         ok(SUCCEEDED(hr) || broken(ddraw_is_nvidia(ddraw) && hr == E_FAIL),
-                "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+                "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_Lock(surface2, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface2, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Lock(surface2, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface2, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         hr = IDirectDrawSurface_Unlock(surface2, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface2, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface_Unlock(surface2, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         IDirectDrawSurface_Release(surface2);
         IDirectDrawSurface_Release(surface);
@@ -11834,31 +11834,31 @@ static void test_draw_primitive(void)
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get D3D interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get D3D interface, hr %#lx.\n", hr);
 
     IDirect3D2_Release(d3d);
 
     hr = IDirect3DDevice2_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, NULL, 0, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, NULL, 0, indices, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, indices, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     destroy_viewport(device, viewport);
     refcount = IDirect3DDevice2_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirectDraw2_Release(ddraw);
     DestroyWindow(window);
 }
@@ -11916,14 +11916,14 @@ static void test_edge_antialiasing_blending(void)
     memset(&hel_desc, 0, sizeof(hel_desc));
     hel_desc.dwSize = sizeof(hel_desc);
     hr = IDirect3DDevice2_GetCaps(device, &hal_desc, &hel_desc);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
-    trace("HAL line edge antialiasing support: %#x.\n",
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
+    trace("HAL line edge antialiasing support: %#lx.\n",
             hal_desc.dpcLineCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES);
-    trace("HAL triangle edge antialiasing support: %#x.\n",
+    trace("HAL triangle edge antialiasing support: %#lx.\n",
             hal_desc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES);
-    trace("HEL line edge antialiasing support: %#x.\n",
+    trace("HEL line edge antialiasing support: %#lx.\n",
             hel_desc.dpcLineCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES);
-    trace("HEL triangle edge antialiasing support: %#x.\n",
+    trace("HEL triangle edge antialiasing support: %#lx.\n",
             hel_desc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -11940,127 +11940,127 @@ static void test_edge_antialiasing_blending(void)
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(surface_desc.ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &offscreen, NULL);
-    ok(hr == D3D_OK, "Creating the offscreen render target failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Creating the offscreen render target failed, hr %#lx.\n", hr);
 
     ds = get_depth_stencil(device);
     hr = IDirectDrawSurface_AddAttachedSurface(offscreen, ds);
-    todo_wine ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
+    todo_wine ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(ds);
 
     hr = IDirect3DDevice2_SetRenderTarget(device, offscreen, 0);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     red_background = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 0.8f);
     green_background = create_diffuse_material(device, 0.0f, 1.0f, 0.0f, 0.5f);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat);
-    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
-    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable blending, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable blending, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
-    ok(SUCCEEDED(hr), "Failed to set src blend, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set src blend, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_DESTALPHA);
-    ok(SUCCEEDED(hr), "Failed to set dest blend, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set dest blend, hr %#lx.\n", hr);
 
     viewport_set_background(device, viewport, red_background);
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, green_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x00cc7f00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00cc7f00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     viewport_set_background(device, viewport, green_background);
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, red_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x00cc7f00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00cc7f00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable blending, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable blending, hr %#lx.\n", hr);
 
     viewport_set_background(device, viewport, red_background);
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, green_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     viewport_set_background(device, viewport, green_background);
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, red_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_EDGEANTIALIAS, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable edge antialiasing, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable edge antialiasing, hr %#lx.\n", hr);
 
     viewport_set_background(device, viewport, red_background);
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, green_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     viewport_set_background(device, viewport, green_background);
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, red_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface_Release(offscreen);
     destroy_viewport(device, viewport);
     destroy_material(red_background);
     destroy_material(green_background);
     refcount = IDirect3DDevice2_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirectDraw2_Release(ddraw);
     DestroyWindow(window);
 }
@@ -12190,11 +12190,11 @@ static void test_transform_vertices(void)
         return;
     }
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 256, 256);
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
 
     memset(&transformdata, 0, sizeof(transformdata));
     transformdata.dwSize = sizeof(transformdata);
@@ -12206,8 +12206,8 @@ static void test_transform_vertices(void)
 
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
 
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
@@ -12222,19 +12222,19 @@ static void test_transform_vertices(void)
                 out[i].x, out[i].y, out[i].z, out[i].w);
         ok(out[i].v1 == position_tests[i].v1 && out[i].v2 == position_tests[i].v2
                 && out[i].v3 == position_tests[i].v3 && out[i].v4 == position_tests[i].v4,
-                "Vertex %u payload is %u %u %u %u.\n", i, out[i].v1, out[i].v2, out[i].v3, out[i].v4);
+                "Vertex %u payload is %lu %lu %lu %lu.\n", i, out[i].v1, out[i].v2, out[i].v3, out[i].v4);
         ok(out[i].unused3 == 0xdeadbeef && out[i].unused4 == 0xcafecafe,
-                "Vertex %u unused data is %#x, %#x.\n", i, out[i].unused3, out[i].unused4);
+                "Vertex %u unused data is %#lx, %#lx.\n", i, out[i].unused3, out[i].unused4);
     }
 
     vp_data = vp_template;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
 
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
@@ -12251,12 +12251,12 @@ static void test_transform_vertices(void)
     vp_data.dwX = 10;
     vp_data.dwY = 20;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
         static const struct vec4 cmp[] =
@@ -12273,8 +12273,8 @@ static void test_transform_vertices(void)
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
         static const D3DHVERTEX cmp_h[] =
@@ -12287,7 +12287,7 @@ static void test_transform_vertices(void)
                 && compare_float(U2(cmp_h[i]).hy, U2(out_h[i]).hy, 4096)
                 && compare_float(U3(cmp_h[i]).hz, U3(out_h[i]).hz, 4096)
                 && cmp_h[i].dwFlags == out_h[i].dwFlags,
-                "HVertex %u differs. Got %#x %f %f %f.\n", i,
+                "HVertex %u differs. Got %#lx %f %f %f.\n", i,
                 out_h[i].dwFlags, U1(out_h[i]).hx, U2(out_h[i]).hy, U3(out_h[i]).hz);
 
         /* No scheme has been found behind those return values. It seems to be
@@ -12312,8 +12312,8 @@ static void test_transform_vertices(void)
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(cliptest),
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(cliptest); ++i)
     {
         static const DWORD flags[] =
@@ -12323,19 +12323,19 @@ static void test_transform_vertices(void)
             0,
             D3DCLIP_LEFT  | D3DCLIP_BOTTOM | D3DCLIP_FRONT,
         };
-        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#x.\n", i, out_h[i].dwFlags);
+        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#lx.\n", i, out_h[i].dwFlags);
     }
 
     vp_data = vp_template;
     vp_data.dwWidth = 10;
     vp_data.dwHeight = 480;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(cliptest),
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(cliptest); ++i)
     {
         static const DWORD flags[] =
@@ -12345,7 +12345,7 @@ static void test_transform_vertices(void)
             D3DCLIP_LEFT,
             D3DCLIP_LEFT  | D3DCLIP_FRONT,
         };
-        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#x.\n", i, out_h[i].dwFlags);
+        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#lx.\n", i, out_h[i].dwFlags);
     }
 
     vp_data = vp_template;
@@ -12354,11 +12354,11 @@ static void test_transform_vertices(void)
     vp_data.dvScaleX = 1;
     vp_data.dvScaleY = 1;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(cliptest),
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(cliptest); ++i)
     {
         static const DWORD flags[] =
@@ -12368,7 +12368,7 @@ static void test_transform_vertices(void)
             0,
             D3DCLIP_FRONT,
         };
-        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#x.\n", i, out_h[i].dwFlags);
+        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#lx.\n", i, out_h[i].dwFlags);
     }
 
     /* Finally try to figure out how the DWORD dwOffscreen works.
@@ -12379,51 +12379,51 @@ static void test_transform_vertices(void)
     vp_data.dvScaleX = 10000.0f;
     vp_data.dvScaleY = 10000.0f;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     transformdata.lpIn = cliptest;
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
 
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %lx.\n", offscreen);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, 2,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %lx.\n", offscreen);
     hr = IDirect3DViewport2_TransformVertices(viewport, 3,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
 
     transformdata.lpIn = cliptest + 1;
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_BACK | D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_BACK | D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %lx.\n", offscreen);
 
     transformdata.lpIn = cliptest + 2;
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %lx.\n", offscreen);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, 2,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %lx.\n", offscreen);
 
     transformdata.lpIn = cliptest + 3;
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_FRONT | D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_FRONT | D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %lx.\n", offscreen);
 
     transformdata.lpIn = offscreentest;
     transformdata.dwInSize = sizeof(offscreentest[0]);
@@ -12433,21 +12433,21 @@ static void test_transform_vertices(void)
     vp_data.dvScaleX = 1.0f;
     vp_data.dvScaleY = 1.0f;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
 
     vp_data.dwWidth = 256;
     vp_data.dwHeight = 256;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == D3DCLIP_RIGHT, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == D3DCLIP_RIGHT, "Offscreen is %lx.\n", offscreen);
 
     /* Test the effect of Matrices.
      *
@@ -12463,20 +12463,20 @@ static void test_transform_vertices(void)
     vp_data.dvMinZ = 0.0f;
     vp_data.dvMaxZ = 1.0f;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat_translate1);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat_scale);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat_translate2);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
 
     transformdata.lpIn = position_tests;
     transformdata.dwInSize = sizeof(position_tests[0]);
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
@@ -12495,48 +12495,48 @@ static void test_transform_vertices(void)
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, 0, &offscreen);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
-    ok(offscreen == 0xdeadbeef, "Offscreen is %x.\n", offscreen);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
+    ok(offscreen == 0xdeadbeef, "Offscreen is %lx.\n", offscreen);
 
     /* NULL transform data. */
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             NULL, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
-    ok(offscreen == 0xdeadbeef, "Offscreen is %x.\n", offscreen);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
+    ok(offscreen == 0xdeadbeef, "Offscreen is %lx.\n", offscreen);
     hr = IDirect3DViewport2_TransformVertices(viewport, 0,
             NULL, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
-    ok(offscreen == 0xdeadbeef, "Offscreen is %x.\n", offscreen);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
+    ok(offscreen == 0xdeadbeef, "Offscreen is %lx.\n", offscreen);
 
     /* NULL transform data and NULL dwOffscreen.
      *
      * Valid transform data + NULL dwOffscreen -> crash. */
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             NULL, D3DTRANSFORM_UNCLIPPED, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
 
     /* No vertices. */
     hr = IDirect3DViewport2_TransformVertices(viewport, 0,
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     hr = IDirect3DViewport2_TransformVertices(viewport, 0,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == ~0U, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == ~0U, "Offscreen is %lx.\n", offscreen);
 
     /* Invalid sizes. */
     offscreen = 0xdeadbeef;
     transformdata.dwSize = sizeof(transformdata) - 1;
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
-    ok(offscreen == 0xdeadbeef, "Offscreen is %x.\n", offscreen);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
+    ok(offscreen == 0xdeadbeef, "Offscreen is %lx.\n", offscreen);
     transformdata.dwSize = sizeof(transformdata) + 1;
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
-    ok(offscreen == 0xdeadbeef, "Offscreen is %x.\n", offscreen);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
+    ok(offscreen == 0xdeadbeef, "Offscreen is %lx.\n", offscreen);
 
     /* NULL lpIn or lpOut -> crash, except when transforming 0 vertices. */
     transformdata.dwSize = sizeof(transformdata);
@@ -12545,8 +12545,8 @@ static void test_transform_vertices(void)
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, 0,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == ~0U, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == ~0U, "Offscreen is %lx.\n", offscreen);
 
     /* Test how vertices are transformed during draws. */
     vp_data.dwX = 20;
@@ -12558,40 +12558,40 @@ static void test_transform_vertices(void)
     vp_data.dvMinZ = 0.0f;
     vp_data.dvMaxZ = 1.0f;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#lx.\n", hr);
 
-    ok(SUCCEEDED(hr), "Failed to clear the render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear the render target, hr %#lx.\n", hr);
     background = create_diffuse_material(device, 0.0f, 0.0f, 1.0f, 0.0f);
     viewport_set_background(device, viewport, background);
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 128, 143);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 132, 143);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 128, 147);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 132, 147);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 177, 217);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 181, 217);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 177, 221);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 181, 221);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
 
     /* Test D3DVIEWPORT2 behavior. */
     vp2_data.dwSize = sizeof(vp2_data);
@@ -12606,12 +12606,12 @@ static void test_transform_vertices(void)
     vp2_data.dvMinZ = 0.0f;
     vp2_data.dvMaxZ = 2.0f;
     hr = IDirect3DViewport2_SetViewport2(viewport, &vp2_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#lx.\n", hr);
     transformdata.lpIn = position_tests;
     transformdata.lpOut = out;
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
         static const struct vec4 cmp[] =
@@ -12632,41 +12632,41 @@ static void test_transform_vertices(void)
     U3(U(mat).diffuse).b = 0.0f;
     U4(U(mat).diffuse).a = 0.0f;
     hr = IDirect3DMaterial2_SetMaterial(background, &mat);
-    ok(SUCCEEDED(hr), "Failed to set material data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set material data, hr %#lx.\n", hr);
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 58, 118);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 62, 118);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 58, 122);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 62, 122);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 157, 177);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 161, 177);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 157, 181);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 161, 181);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat_identity);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat_identity);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat_transform3);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
 
     vp2_data.dwX = 0.0;
     vp2_data.dwY = 0.0;
@@ -12679,14 +12679,14 @@ static void test_transform_vertices(void)
     vp2_data.dvMinZ = 0.0f;
     vp2_data.dvMaxZ = 0.5f;
     hr = IDirect3DViewport2_SetViewport2(viewport, &vp2_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#lx.\n", hr);
     transformdata.lpIn = cliptest;
     transformdata.dwInSize = sizeof(cliptest[0]);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(cliptest),
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(cliptest); ++i)
     {
         static const D3DHVERTEX cmp_h[] =
@@ -12700,7 +12700,7 @@ static void test_transform_vertices(void)
                 && compare_float(U2(cmp_h[i]).hy, U2(out_h[i]).hy, 4096)
                 && compare_float(U3(cmp_h[i]).hz, U3(out_h[i]).hz, 4096)
                 && cmp_h[i].dwFlags == out_h[i].dwFlags,
-                "HVertex %u differs. Got %#x %f %f %f.\n", i,
+                "HVertex %u differs. Got %#lx %f %f %f.\n", i,
                 out_h[i].dwFlags, U1(out_h[i]).hx, U2(out_h[i]).hy, U3(out_h[i]).hz);
     }
 
@@ -12708,7 +12708,7 @@ static void test_transform_vertices(void)
     destroy_viewport(device, viewport);
     IDirect3DMaterial2_Release(background);
     refcount = IDirect3DDevice_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirectDraw2_Release(ddraw);
     DestroyWindow(window);
 }
@@ -12731,14 +12731,14 @@ static void test_display_mode_surface_pixel_format(void)
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw2_GetDisplayMode(ddraw, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#lx.\n", hr);
     width = surface_desc.dwWidth;
     height = surface_desc.dwHeight;
 
     window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
             0, 0, width, height, NULL, NULL, NULL, NULL);
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     bpp = 0;
     if (SUCCEEDED(IDirectDraw2_SetDisplayMode(ddraw, width, height, 16, 0, 0)))
@@ -12751,10 +12751,10 @@ static void test_display_mode_surface_pixel_format(void)
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw2_GetDisplayMode(ddraw, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == width, "Got width %u, expected %u.\n", surface_desc.dwWidth, width);
-    ok(surface_desc.dwHeight == height, "Got height %u, expected %u.\n", surface_desc.dwHeight, height);
-    ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == width, "Got width %lu, expected %u.\n", surface_desc.dwWidth, width);
+    ok(surface_desc.dwHeight == height, "Got height %lu, expected %u.\n", surface_desc.dwHeight, height);
+    ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %lu, expected %u.\n",
             U1(surface_desc.ddpfPixelFormat).dwRGBBitCount, bpp);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -12763,14 +12763,14 @@ static void test_display_mode_surface_pixel_format(void)
     surface_desc.dwBackBufferCount = 1;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == width, "Got width %u, expected %u.\n", surface_desc.dwWidth, width);
-    ok(surface_desc.dwHeight == height, "Got height %u, expected %u.\n", surface_desc.dwHeight, height);
-    ok(surface_desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#x.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == width, "Got width %lu, expected %u.\n", surface_desc.dwWidth, width);
+    ok(surface_desc.dwHeight == height, "Got height %lu, expected %u.\n", surface_desc.dwHeight, height);
+    ok(surface_desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#lx.\n",
             surface_desc.ddpfPixelFormat.dwFlags);
-    ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
+    ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %lu, expected %u.\n",
             U1(surface_desc.ddpfPixelFormat).dwRGBBitCount, bpp);
     IDirectDrawSurface_Release(surface);
 
@@ -12781,17 +12781,17 @@ static void test_display_mode_surface_pixel_format(void)
     surface_desc.dwHeight = height;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#x.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#lx.\n",
             surface_desc.ddpfPixelFormat.dwFlags);
-    ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
+    ok(U1(surface_desc.ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %lu, expected %u.\n",
             U1(surface_desc.ddpfPixelFormat).dwRGBBitCount, bpp);
     IDirectDrawSurface_Release(surface);
 
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -12849,7 +12849,7 @@ static void test_surface_desc_size(void)
         return;
     }
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(surface_caps); ++i)
     {
@@ -12865,9 +12865,9 @@ static void test_surface_desc_size(void)
             continue;
         }
         hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface2, (void **)&surface2);
-        ok(hr == DD_OK, "Failed to query IDirectDrawSurface2, hr %#x, type %s.\n", hr, surface_caps[i].name);
+        ok(hr == DD_OK, "Failed to query IDirectDrawSurface2, hr %#lx, type %s.\n", hr, surface_caps[i].name);
         hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void **)&surface7);
-        ok(hr == DD_OK, "Failed to query IDirectDrawSurface7, hr %#x, type %s.\n", hr, surface_caps[i].name);
+        ok(hr == DD_OK, "Failed to query IDirectDrawSurface7, hr %#lx, type %s.\n", hr, surface_caps[i].name);
 
         /* GetSurfaceDesc() */
         for (j = 0; j < ARRAY_SIZE(desc_sizes); ++j)
@@ -12876,21 +12876,21 @@ static void test_surface_desc_size(void)
             desc.dwSize = desc_sizes[j];
             expected_hr = desc.dwSize == sizeof(DDSURFACEDESC) ? DD_OK : DDERR_INVALIDPARAMS;
             hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc.desc1);
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
 
             memset(&desc, 0, sizeof(desc));
             desc.dwSize = desc_sizes[j];
             expected_hr = desc.dwSize == sizeof(DDSURFACEDESC) ? DD_OK : DDERR_INVALIDPARAMS;
             hr = IDirectDrawSurface2_GetSurfaceDesc(surface2, &desc.desc1);
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
 
             memset(&desc, 0, sizeof(desc));
             desc.dwSize = desc_sizes[j];
             expected_hr = desc.dwSize == sizeof(DDSURFACEDESC2) ? DD_OK : DDERR_INVALIDPARAMS;
             hr = IDirectDrawSurface7_GetSurfaceDesc(surface7, &desc.desc2);
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
         }
 
@@ -12907,22 +12907,22 @@ static void test_surface_desc_size(void)
             desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
             hr = IDirectDrawSurface_Lock(surface, NULL, &desc.desc1, 0, 0);
             expected_hr = valid_size ? DD_OK : DDERR_INVALIDPARAMS;
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
-            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
+            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %lu, type %s.\n",
                     desc_sizes[j], desc.dwSize, surface_caps[i].name);
             ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
                     desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
             if (SUCCEEDED(hr))
             {
-                ok(desc.desc1.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
+                ok(desc.desc1.dwWidth == 128, "Got unexpected width %lu, dwSize %u, type %s.\n",
                         desc.desc1.dwWidth, desc_sizes[j], surface_caps[i].name);
-                ok(desc.desc1.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
+                ok(desc.desc1.dwHeight == 128, "Got unexpected height %lu, dwSize %u, type %s.\n",
                         desc.desc1.dwHeight, desc_sizes[j], surface_caps[i].name);
                 expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
                 todo_wine_if(!expected_texture_stage)
                 ok(desc.desc2.dwTextureStage == expected_texture_stage,
-                        "Got unexpected texture stage %#x, dwSize %u, type %s.\n",
+                        "Got unexpected texture stage %#lx, dwSize %u, type %s.\n",
                         desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
                 IDirectDrawSurface_Unlock(surface, NULL);
             }
@@ -12933,22 +12933,22 @@ static void test_surface_desc_size(void)
             desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
             hr = IDirectDrawSurface2_Lock(surface2, NULL, &desc.desc1, 0, 0);
             expected_hr = valid_size ? DD_OK : DDERR_INVALIDPARAMS;
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
-            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
+            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %lu, type %s.\n",
                     desc_sizes[j], desc.dwSize, surface_caps[i].name);
             ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
                     desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
             if (SUCCEEDED(hr))
             {
-                ok(desc.desc2.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
+                ok(desc.desc2.dwWidth == 128, "Got unexpected width %lu, dwSize %u, type %s.\n",
                         desc.desc2.dwWidth, desc_sizes[j], surface_caps[i].name);
-                ok(desc.desc2.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
+                ok(desc.desc2.dwHeight == 128, "Got unexpected height %lu, dwSize %u, type %s.\n",
                         desc.desc2.dwHeight, desc_sizes[j], surface_caps[i].name);
                 expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
                 todo_wine_if(!expected_texture_stage)
                 ok(desc.desc2.dwTextureStage == expected_texture_stage,
-                        "Got unexpected texture stage %#x, dwSize %u, type %s.\n",
+                        "Got unexpected texture stage %#lx, dwSize %u, type %s.\n",
                         desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
                 IDirectDrawSurface2_Unlock(surface2, NULL);
             }
@@ -12959,21 +12959,21 @@ static void test_surface_desc_size(void)
             desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
             hr = IDirectDrawSurface7_Lock(surface7, NULL, &desc.desc2, 0, 0);
             expected_hr = valid_size ? DD_OK : DDERR_INVALIDPARAMS;
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
-            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
+            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %lu, type %s.\n",
                     desc_sizes[j], desc.dwSize, surface_caps[i].name);
             ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
                     desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
             if (SUCCEEDED(hr))
             {
-                ok(desc.desc2.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
+                ok(desc.desc2.dwWidth == 128, "Got unexpected width %lu, dwSize %u, type %s.\n",
                         desc.desc2.dwWidth, desc_sizes[j], surface_caps[i].name);
-                ok(desc.desc2.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
+                ok(desc.desc2.dwHeight == 128, "Got unexpected height %lu, dwSize %u, type %s.\n",
                         desc.desc2.dwHeight, desc_sizes[j], surface_caps[i].name);
                 expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
                 ok(desc.desc2.dwTextureStage == expected_texture_stage,
-                        "Got unexpected texture stage %#x, dwSize %u, type %s.\n",
+                        "Got unexpected texture stage %#lx, dwSize %u, type %s.\n",
                         desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
                 IDirectDrawSurface7_Unlock(surface7, NULL);
             }
@@ -12992,17 +12992,17 @@ static void test_surface_desc_size(void)
         expected_hr = (desc.dwSize == sizeof(DDSURFACEDESC) || desc.dwSize == sizeof(DDSURFACEDESC2))
                 ? DD_OK : DDERR_INVALIDPARAMS;
         hr = IDirectDraw2_GetDisplayMode(ddraw, &desc.desc1);
-        ok(hr == expected_hr, "Got hr %#x, expected %#x, size %u.\n", hr, expected_hr, desc_sizes[j]);
+        ok(hr == expected_hr, "Got hr %#lx, expected %#lx, size %u.\n", hr, expected_hr, desc_sizes[j]);
         if (SUCCEEDED(hr))
         {
-            ok(desc.dwSize == sizeof(DDSURFACEDESC), "Wrong size %u for %u.\n", desc.dwSize, desc_sizes[j]);
+            ok(desc.dwSize == sizeof(DDSURFACEDESC), "Wrong size %lu for %u.\n", desc.dwSize, desc_sizes[j]);
             ok(desc.blob[desc_sizes[j]] == 0xcc, "Overflow for size %u.\n", desc_sizes[j]);
             ok(desc.blob[desc_sizes[j] - 1] != 0xcc, "Struct not cleared for size %u.\n", desc_sizes[j]);
         }
     }
 
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
 }
 
 static void test_ck_operation(void)
@@ -13024,7 +13024,7 @@ static void test_ck_operation(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -13038,22 +13038,22 @@ static void test_ck_operation(void)
     U3(surface_desc.ddpfPixelFormat).dwGBitMask = 0x0000ff00;
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface2, (void **)&dst);
-    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface2, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface2, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface1);
 
     surface_desc.dwFlags |= DDSD_CKSRCBLT;
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00ff00ff;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00ff00ff;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface2, (void **)&src);
-    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface2, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface2, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface1);
 
     hr = IDirectDrawSurface2_Lock(src, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ok(!(surface_desc.dwFlags & DDSD_LPSURFACE), "Surface desc has LPSURFACE Flags set.\n");
     color = surface_desc.lpSurface;
     color[0] = 0x77010203;
@@ -13061,33 +13061,33 @@ static void test_ck_operation(void)
     color[2] = 0x77ff00ff;
     color[3] = 0x00ff00ff;
     hr = IDirectDrawSurface2_Unlock(src, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     for (i = 0; i < 2; ++i)
     {
         hr = IDirectDrawSurface2_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         color = surface_desc.lpSurface;
         color[0] = 0xcccccccc;
         color[1] = 0xcccccccc;
         color[2] = 0xcccccccc;
         color[3] = 0xcccccccc;
         hr = IDirectDrawSurface2_Unlock(dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         if (i)
         {
             hr = IDirectDrawSurface2_BltFast(dst, 0, 0, src, NULL, DDBLTFAST_SRCCOLORKEY);
-            ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
         }
         else
         {
             hr = IDirectDrawSurface2_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC, NULL);
-            ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
         }
 
         hr = IDirectDrawSurface2_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT | DDLOCK_READONLY, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         ok(!(surface_desc.dwFlags & DDSD_LPSURFACE), "Surface desc has LPSURFACE Flags set.\n");
         color = surface_desc.lpSurface;
         /* Different behavior on some drivers / windows versions. Some versions ignore the X channel when
@@ -13102,69 +13102,69 @@ static void test_ck_operation(void)
                 && color[2] == 0xcccccccc && color[3] == 0xcccccccc) /* Nvidia */
                 || broken(color[0] == 0xff010203 && color[1] == 0xff010203
                 && color[2] == 0xcccccccc && color[3] == 0xcccccccc) /* Testbot */,
-                "Destination data after blitting is %08x %08x %08x %08x, i=%u.\n",
+                "Destination data after blitting is %08lx %08lx %08lx %08lx, i=%u.\n",
                 color[0], color[1], color[2], color[3], i);
         hr = IDirectDrawSurface2_Unlock(dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
     }
 
     hr = IDirectDrawSurface2_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x00ff00ff && ckey.dwColorSpaceHighValue == 0x00ff00ff,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface2_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface2_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x0000ff00 && ckey.dwColorSpaceHighValue == 0x0000ff00,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface2_GetSurfaceDesc(src, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue == 0x0000ff00
             && surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue == 0x0000ff00,
-            "Got unexpected color key low=%08x high=%08x.\n", surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue,
+            "Got unexpected color key low=%08lx high=%08lx.\n", surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue,
             surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue);
 
     /* Test SetColorKey with dwColorSpaceHighValue < dwColorSpaceLowValue */
     ckey.dwColorSpaceLowValue = 0x000000ff;
     ckey.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDrawSurface2_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface2_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x000000ff && ckey.dwColorSpaceHighValue == 0x000000ff,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     ckey.dwColorSpaceLowValue = 0x000000ff;
     ckey.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDrawSurface2_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface2_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x000000ff && ckey.dwColorSpaceHighValue == 0x000000ff,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     ckey.dwColorSpaceLowValue = 0x000000fe;
     ckey.dwColorSpaceHighValue = 0x000000fd;
     hr = IDirectDrawSurface2_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface2_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x000000fe && ckey.dwColorSpaceHighValue == 0x000000fe,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     IDirectDrawSurface2_Release(src);
     IDirectDrawSurface2_Release(dst);
@@ -13184,25 +13184,25 @@ static void test_ck_operation(void)
     U4(surface_desc.ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(surface_desc.ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface2, (void **)&dst);
-    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface2, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface2, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface1);
 
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface2, (void **)&src);
-    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface2, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface2, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface1);
 
     ckey.dwColorSpaceLowValue = 0x0000ff00;
     ckey.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface2_SetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     ckey.dwColorSpaceLowValue = 0x00ff0000;
     ckey.dwColorSpaceHighValue = 0x00ff0000;
     hr = IDirectDrawSurface2_SetColorKey(dst, DDCKEY_DESTBLT, &ckey);
-    ok(SUCCEEDED(hr) || hr == DDERR_NOCOLORKEYHW, "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || hr == DDERR_NOCOLORKEYHW, "Failed to set color key, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
         /* Nvidia reject dest keys, AMD allows them. This applies to vidmem and sysmem surfaces. */
@@ -13213,11 +13213,11 @@ static void test_ck_operation(void)
     ckey.dwColorSpaceLowValue = 0x000000ff;
     ckey.dwColorSpaceHighValue = 0x000000ff;
     hr = IDirectDrawSurface2_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     ckey.dwColorSpaceLowValue = 0x000000aa;
     ckey.dwColorSpaceHighValue = 0x000000aa;
     hr = IDirectDrawSurface2_SetColorKey(src, DDCKEY_DESTBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
@@ -13227,7 +13227,7 @@ static void test_ck_operation(void)
     fx.ddckDestColorkey.dwColorSpaceLowValue = 0x00001100;
 
     hr = IDirectDrawSurface2_Lock(src, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     color[0] = 0x000000ff; /* Applies to src blt key in src surface. */
     color[1] = 0x000000aa; /* Applies to dst blt key in src surface. */
@@ -13236,77 +13236,77 @@ static void test_ck_operation(void)
     color[4] = 0x00001100; /* Src color key in ddbltfx. */
     color[5] = 0x00110000; /* Dst color key in ddbltfx. */
     hr = IDirectDrawSurface2_Unlock(src, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface2_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0x55555555;
     hr = IDirectDrawSurface2_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Test a blit without keying. */
     hr = IDirectDrawSurface2_Blt(dst, NULL, src, NULL, 0, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface2_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Should have copied src data unmodified to dst. */
     ok(color[0] == 0x000000ff && color[1] == 0x000000aa && color[2] == 0x00ff0000 &&
             color[3] == 0x0000ff00 && color[4] == 0x00001100 && color[5] == 0x00110000,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0x55555555;
     hr = IDirectDrawSurface2_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Src key. */
     hr = IDirectDrawSurface2_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface2_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Src key applied to color[0]. It is unmodified, the others are copied. */
     ok(color[0] == 0x55555555 && color[1] == 0x000000aa && color[2] == 0x00ff0000 &&
             color[3] == 0x0000ff00 && color[4] == 0x00001100 && color[5] == 0x00110000,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0x55555555;
     hr = IDirectDrawSurface2_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Src override. */
     hr = IDirectDrawSurface2_Blt(dst, NULL, src, NULL, DDBLT_KEYSRCOVERRIDE, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface2_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Override key applied to color[5]. It is unmodified, the others are copied. */
     ok(color[0] == 0x000000ff && color[1] == 0x000000aa && color[2] == 0x00ff0000 &&
             color[3] == 0x0000ff00 && color[4] == 0x00001100 && color[5] == 0x55555555,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0x55555555;
     hr = IDirectDrawSurface2_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Src override AND src key. That is not supposed to work. */
     hr = IDirectDrawSurface2_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC | DDBLT_KEYSRCOVERRIDE, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface2_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Ensure the destination was not changed. */
     ok(color[0] == 0x55555555 && color[1] == 0x55555555 && color[2] == 0x55555555 &&
             color[3] == 0x55555555 && color[4] == 0x55555555 && color[5] == 0x55555555,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     /* Use different dst colors for the dst key test. */
@@ -13317,19 +13317,19 @@ static void test_ck_operation(void)
     color[4] = 0x000000aa; /* Dest key in src surface. */
     color[5] = 0x000000aa; /* Dest key in src surface. */
     hr = IDirectDrawSurface2_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Dest key blit. The key is taken from the SOURCE surface in v2! */
     hr = IDirectDrawSurface2_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface2_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Dst key applied to color[4,5], they are the only changed pixels. */
     ok(color[0] == 0x00ff0000 && color[1] == 0x00ff0000 && color[2] == 0x00001100 &&
             color[3] == 0x00001100 && color[4] == 0x00001100 && color[5] == 0x00110000,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = 0x00ff0000; /* Dest key in dst surface. */
@@ -13339,28 +13339,28 @@ static void test_ck_operation(void)
     color[4] = 0x000000aa; /* Dest key in src surface. */
     color[5] = 0x000000aa; /* Dest key in src surface. */
     hr = IDirectDrawSurface2_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* What happens with a QI'd newer version of the interface? It takes the key
      * from the destination surface. */
     hr = IDirectDrawSurface2_QueryInterface(src, &IID_IDirectDrawSurface7, (void **)&src7);
-    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface2_QueryInterface(dst, &IID_IDirectDrawSurface7, (void **)&dst7);
-    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Blt(dst7, NULL, src7, NULL, DDBLT_KEYDEST, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(dst7);
     IDirectDrawSurface7_Release(src7);
 
     hr = IDirectDrawSurface2_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Dst key applied to color[0,1], they are the only changed pixels. */
     todo_wine ok(color[0] == 0x000000ff && color[1] == 0x000000aa && color[2] == 0x00001100 &&
             color[3] == 0x00001100 && color[4] == 0x000000aa && color[5] == 0x000000aa,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = 0x00ff0000; /* Dest key in dst surface. */
@@ -13370,19 +13370,19 @@ static void test_ck_operation(void)
     color[4] = 0x000000aa; /* Dest key in src surface. */
     color[5] = 0x000000aa; /* Dest key in src surface. */
     hr = IDirectDrawSurface2_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Dest override key blit. */
     hr = IDirectDrawSurface2_Blt(dst, NULL, src, NULL, DDBLT_KEYDESTOVERRIDE, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface2_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Dst key applied to color[2,3], they are the only changed pixels. */
     ok(color[0] == 0x00ff0000 && color[1] == 0x00ff0000 && color[2] == 0x00ff0000 &&
             color[3] == 0x0000ff00 && color[4] == 0x000000aa && color[5] == 0x000000aa,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = 0x00ff0000; /* Dest key in dst surface. */
@@ -13392,38 +13392,38 @@ static void test_ck_operation(void)
     color[4] = 0x000000aa; /* Dest key in src surface. */
     color[5] = 0x000000aa; /* Dest key in src surface. */
     hr = IDirectDrawSurface2_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Dest override together with surface key. Supposed to fail. */
     hr = IDirectDrawSurface2_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST | DDBLT_KEYDESTOVERRIDE, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface2_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Destination is unchanged. */
     ok(color[0] == 0x00ff0000 && color[1] == 0x00ff0000 && color[2] == 0x00001100 &&
             color[3] == 0x00001100 && color[4] == 0x000000aa && color[5] == 0x000000aa,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
     hr = IDirectDrawSurface2_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Source and destination key. This is driver dependent. New HW treats it like
      * DDBLT_KEYSRC. Older HW and some software renderers apply both keys. */
     if (0)
     {
         hr = IDirectDrawSurface2_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST | DDBLT_KEYSRC, &fx);
-        ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
         hr = IDirectDrawSurface2_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         color = surface_desc.lpSurface;
         /* Color[0] is filtered by the src key, 2-5 are filtered by the dst key, if
          * the driver applies it. */
         ok(color[0] == 0x00ff0000 && color[1] == 0x000000aa && color[2] == 0x00ff0000 &&
                 color[3] == 0x0000ff00 && color[4] == 0x00001100 && color[5] == 0x00110000,
-                "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+                "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
                 color[0], color[1], color[2], color[3], color[4], color[5]);
 
         color[0] = 0x00ff0000; /* Dest key in dst surface. */
@@ -13433,69 +13433,69 @@ static void test_ck_operation(void)
         color[4] = 0x000000aa; /* Dest key in src surface. */
         color[5] = 0x000000aa; /* Dest key in src surface. */
         hr = IDirectDrawSurface2_Unlock(dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
     }
 
     /* Override keys without ddbltfx parameter fail */
     hr = IDirectDrawSurface2_Blt(dst, NULL, src, NULL, DDBLT_KEYDESTOVERRIDE, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface2_Blt(dst, NULL, src, NULL, DDBLT_KEYSRCOVERRIDE, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Try blitting without keys in the source surface. */
     hr = IDirectDrawSurface2_SetColorKey(src, DDCKEY_SRCBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirectDrawSurface2_SetColorKey(src, DDCKEY_DESTBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     /* That fails now. Do not bother to check that the data is unmodified. */
     hr = IDirectDrawSurface2_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Surprisingly this still works. It uses the old key from the src surface. */
     hr = IDirectDrawSurface2_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface2_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Dst key applied to color[4,5], they are the only changed pixels. */
     ok(color[0] == 0x00ff0000 && color[1] == 0x00ff0000 && color[2] == 0x00001100 &&
             color[3] == 0x00001100 && color[4] == 0x00001100 && color[5] == 0x00110000,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
     hr = IDirectDrawSurface2_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* This returns DDERR_NOCOLORKEY as expected. */
     hr = IDirectDrawSurface2_GetColorKey(src, DDCKEY_DESTBLT, &ckey);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
 
     /* GetSurfaceDesc returns a zeroed key as expected. */
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x12345678;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x12345678;
     hr = IDirectDrawSurface2_GetSurfaceDesc(src, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue
             && !surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue,
-            "Got unexpected color key low=%08x high=%08x.\n", surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue,
+            "Got unexpected color key low=%08lx high=%08lx.\n", surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue,
             surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue);
 
     /* Try blitting without keys in the destination surface. */
     hr = IDirectDrawSurface2_SetColorKey(dst, DDCKEY_SRCBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirectDrawSurface2_SetColorKey(dst, DDCKEY_DESTBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     /* This fails, as sanity would dictate. */
     hr = IDirectDrawSurface2_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
 done:
     IDirectDrawSurface2_Release(src);
     IDirectDrawSurface2_Release(dst);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -13519,26 +13519,26 @@ static void test_set_render_state(void)
     }
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     state = 0xdeadbeef;
     hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, &state);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(!state, "Got unexpected render state %#x.\n", state);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(!state, "Got unexpected render state %#lx.\n", state);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, &state);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(state == D3DTBLEND_MODULATE, "Got unexpected render state %#x.\n", state);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(state == D3DTBLEND_MODULATE, "Got unexpected render state %#lx.\n", state);
 
     refcount = IDirect3DDevice2_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -13591,16 +13591,16 @@ static void test_depth_readback(void)
     }
 
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     blue_background = create_diffuse_material(device, 0.0f, 0.0f, 1.0f, 1.0f);
     viewport = create_viewport(device, 0, 0, 640, 480);
     viewport_set_background(device, viewport, blue_background);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     ds = get_depth_stencil(device);
     hr = IDirectDrawSurface_DeleteAttachedSurface(rt, 0, ds);
-    ok(SUCCEEDED(hr), "Failed to detach depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach depth buffer, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(ds);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
@@ -13620,23 +13620,23 @@ static void test_depth_readback(void)
         }
 
         hr = IDirectDrawSurface_AddAttachedSurface(rt, ds);
-        ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
         hr = IDirect3DDevice2_SetRenderTarget(device, rt, 0);
-        ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
         hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
         hr = IDirect3DDevice2_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, quad, 4, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice2_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface_Lock(ds, NULL, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
 
         all_pass = TRUE;
         for (y = 60; y < 480; y += 120)
@@ -13654,7 +13654,7 @@ static void test_depth_readback(void)
                  * Accept all nvidia GPUs as broken here, but still expect one of the formats to pass. */
                 ok(compare_uint(expected_depth, depth, max_diff) || ddraw_is_nvidia(ddraw)
                         || (ddraw_is_amd(ddraw) && tests[i].z_depth == 24),
-                        "Test %u: Got depth 0x%08x (diff %d), expected 0x%08x+/-%u, at %u, %u.\n",
+                        "Test %u: Got depth 0x%08lx (diff %ld), expected 0x%08lx+/-%lu, at %u, %u.\n",
                         i, depth, expected_depth - depth, expected_depth, max_diff, x, y);
                 if (!compare_uint(expected_depth, depth, max_diff))
                     all_pass = FALSE;
@@ -13662,13 +13662,13 @@ static void test_depth_readback(void)
         }
 
         hr = IDirectDrawSurface_Unlock(ds, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         if (all_pass)
             passed_fmts++;
 
         hr = IDirectDrawSurface_DeleteAttachedSurface(rt, 0, ds);
-        ok(SUCCEEDED(hr), "Failed to detach depth buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to detach depth buffer, hr %#lx.\n", hr);
         IDirectDrawSurface_Release(ds);
     }
 
@@ -13678,7 +13678,7 @@ static void test_depth_readback(void)
     destroy_material(blue_background);
     IDirectDrawSurface_Release(rt);
     refcount = IDirect3DDevice2_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirectDraw2_Release(ddraw);
     DestroyWindow(window);
 }
@@ -13708,11 +13708,11 @@ static void test_clear(void)
         return;
     }
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     white = create_diffuse_material(device, 1.0f, 1.0f, 1.0f, 1.0f);
     red = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f);
@@ -13721,7 +13721,7 @@ static void test_clear(void)
 
     viewport_set_background(device, viewport, white);
     hr = IDirect3DViewport2_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     /* Positive x, negative y. */
     U1(rect[0]).x1 = 0;
@@ -13739,20 +13739,20 @@ static void test_clear(void)
      * refuse negative rectangles, but it will not clear them either. */
     viewport_set_background(device, viewport, red);
     hr = IDirect3DViewport2_Clear(viewport, 2, rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 360);
-    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3 (pos, neg) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3 (pos, neg) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 160, 120);
-    ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1 (pos, pos) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1 (pos, pos) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 360);
-    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4 (NULL) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4 (NULL) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 120);
-    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4 (neg, neg) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4 (neg, neg) has color 0x%08lx.\n", color);
 
     viewport_set_background(device, viewport, white);
     hr = IDirect3DViewport2_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     /* negative x, negative y.
      * Also ignored, except on WARP, which clears the entire screen. */
@@ -13762,41 +13762,41 @@ static void test_clear(void)
     U4(rect_negneg).y2 = 0;
     viewport_set_background(device, viewport, green);
     hr = IDirect3DViewport2_Clear(viewport, 1, &rect_negneg, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 360);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 160, 120);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 360);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 120);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
 
     /* Test how the viewport affects clears. */
     viewport_set_background(device, viewport, white);
     hr = IDirect3DViewport2_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     viewport2 = create_viewport(device, 160, 120, 160, 120);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport2);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     viewport_set_background(device, viewport2, blue);
     hr = IDirect3DViewport2_Clear(viewport2, 1, &rect_full, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     viewport3 = create_viewport(device, 320, 240, 320, 240);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport3);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     U1(rect[0]).x1 = 160;
     U2(rect[0]).y1 = 120;
@@ -13804,84 +13804,84 @@ static void test_clear(void)
     U4(rect[0]).y2 = 360;
     viewport_set_background(device, viewport3, green);
     hr = IDirect3DViewport2_Clear(viewport3, 1, &rect[0], D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 158, 118);
-    ok(compare_color(color, 0x00ffffff, 0), "(158, 118) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(158, 118) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 162, 118);
-    ok(compare_color(color, 0x00ffffff, 0), "(162, 118) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(162, 118) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 158, 122);
-    ok(compare_color(color, 0x00ffffff, 0), "(158, 122) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(158, 122) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 162, 122);
-    ok(compare_color(color, 0x000000ff, 0), "(162, 122) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 0), "(162, 122) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 318, 238);
-    ok(compare_color(color, 0x000000ff, 0), "(318, 238) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 0), "(318, 238) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 322, 238);
-    ok(compare_color(color, 0x00ffffff, 0), "(322, 238) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(322, 238) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 318, 242);
-    ok(compare_color(color, 0x00ffffff, 0), "(318, 242) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(318, 242) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 322, 242);
-    ok(compare_color(color, 0x0000ff00, 0), "(322, 242) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(322, 242) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 478, 358);
-    ok(compare_color(color, 0x0000ff00, 0), "(478, 358) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(478, 358) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 482, 358);
-    ok(compare_color(color, 0x00ffffff, 0), "(482, 358) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(482, 358) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 478, 362);
-    ok(compare_color(color, 0x00ffffff, 0), "(478, 362) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(478, 362) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 482, 362);
-    ok(compare_color(color, 0x00ffffff, 0), "(482, 362) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(482, 362) has color 0x%08lx.\n", color);
 
     /* The clear rectangle is rendertarget absolute, not relative to the
      * viewport. */
     hr = IDirect3DViewport2_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     U1(rect[0]).x1 = 330;
     U2(rect[0]).y1 = 250;
     U3(rect[0]).x2 = 340;
     U4(rect[0]).y2 = 260;
     hr = IDirect3DViewport2_Clear(viewport3, 1, &rect[0], D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 328, 248);
-    ok(compare_color(color, 0x00ffffff, 0), "(328, 248) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(328, 248) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 332, 248);
-    ok(compare_color(color, 0x00ffffff, 0), "(332, 248) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(332, 248) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 328, 252);
-    ok(compare_color(color, 0x00ffffff, 0), "(328, 252) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(328, 252) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 332, 252);
-    ok(compare_color(color, 0x0000ff00, 0), "(332, 252) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(332, 252) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 338, 248);
-    ok(compare_color(color, 0x00ffffff, 0), "(338, 248) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(338, 248) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 342, 248);
-    ok(compare_color(color, 0x00ffffff, 0), "(342, 248) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(342, 248) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 338, 252);
-    ok(compare_color(color, 0x0000ff00, 0), "(338, 252) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(338, 252) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 342, 252);
-    ok(compare_color(color, 0x00ffffff, 0), "(342, 252) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(342, 252) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 328, 258);
-    ok(compare_color(color, 0x00ffffff, 0), "(328, 258) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(328, 258) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 332, 258);
-    ok(compare_color(color, 0x0000ff00, 0), "(332, 258) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(332, 258) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 328, 262);
-    ok(compare_color(color, 0x00ffffff, 0), "(328, 262) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(328, 262) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 332, 262);
-    ok(compare_color(color, 0x00ffffff, 0), "(332, 262) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(332, 262) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 338, 258);
-    ok(compare_color(color, 0x0000ff00, 0), "(338, 258) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(338, 258) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 342, 258);
-    ok(compare_color(color, 0x00ffffff, 0), "(342, 258) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(342, 258) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 338, 262);
-    ok(compare_color(color, 0x00ffffff, 0), "(338, 262) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(338, 262) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 342, 262);
-    ok(compare_color(color, 0x00ffffff, 0), "(342, 262) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(342, 262) has color 0x%08lx.\n", color);
 
     /* COLORWRITEENABLE, SRGBWRITEENABLE and scissor rectangles do not exist
      * in d3d2. */
@@ -13895,9 +13895,9 @@ static void test_clear(void)
     IDirect3DMaterial2_Release(blue);
     IDirectDrawSurface_Release(rt);
     refcount = IDirect3DDevice2_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Ddraw object has %u references left.\n", refcount);
+    ok(!refcount, "Ddraw object has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -13955,12 +13955,12 @@ static HRESULT WINAPI enum_surfaces_create_cb(IDirectDrawSurface *surface, DDSUR
     struct enum_surfaces_param *param = context;
 
     ok(!surface, "Unexpected surface %p.\n", surface);
-    ok((desc->dwFlags & expect_flags) == expect_flags, "Got unexpected flags %#x.\n", desc->dwFlags);
+    ok((desc->dwFlags & expect_flags) == expect_flags, "Got unexpected flags %#lx.\n", desc->dwFlags);
     if (param->count < ARRAY_SIZE(param->modes))
     {
         const DDSURFACEDESC *expect = &param->modes[param->count];
-        ok(desc->dwWidth == expect->dwWidth, "Expected width %u, got %u.\n", expect->dwWidth, desc->dwWidth);
-        ok(desc->dwHeight == expect->dwHeight, "Expected height %u, got %u.\n", expect->dwHeight, desc->dwHeight);
+        ok(desc->dwWidth == expect->dwWidth, "Expected width %lu, got %lu.\n", expect->dwWidth, desc->dwWidth);
+        ok(desc->dwHeight == expect->dwHeight, "Expected height %lu, got %lu.\n", expect->dwHeight, desc->dwHeight);
         ok(!memcmp(&U4(*desc).ddpfPixelFormat, &U4(*expect).ddpfPixelFormat, sizeof(U4(*desc).ddpfPixelFormat)),
                 "Pixel formats didn't match.\n");
     }
@@ -13985,18 +13985,18 @@ static void test_enum_surfaces(void)
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
     hr = IDirectDraw2_GetDisplayMode(ddraw, &desc);
-    ok(hr == DD_OK, "Failed to get display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to get display mode, hr %#lx.\n", hr);
     current_format = desc.ddpfPixelFormat;
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set cooperative level, hr %#lx.\n", hr);
 
     hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_ALL, NULL, NULL, enum_surfaces_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL,
             NULL, NULL, enum_surfaces_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
@@ -14006,52 +14006,52 @@ static void test_enum_surfaces(void)
     desc.dwWidth = 32;
     desc.dwHeight = 32;
     hr = IDirectDraw2_CreateSurface(ddraw, &desc, &param.surfaces[0], NULL);
-    ok(SUCCEEDED(hr), "Failed to create a surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create a surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_GetAttachedSurface(param.surfaces[0], &desc.ddsCaps, &param.surfaces[1]);
-    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetAttachedSurface(param.surfaces[1], &desc.ddsCaps, &param.surfaces[2]);
-    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetAttachedSurface(param.surfaces[2], &desc.ddsCaps, &param.surfaces[3]);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
 
     param.count = 0;
     hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
             &desc, &param, enum_surfaces_cb);
-    ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     param.count = 0;
     hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
             NULL, &param, enum_surfaces_cb);
-    ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
     param.count = 0;
     hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     param.count = 0;
     hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH,
             &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 2, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     desc.dwFlags = 0;
     param.count = 0;
     hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     desc.dwFlags = 0;
     param.count = 0;
     hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST, &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     IDirectDrawSurface_Release(param.surfaces[2]);
@@ -14061,7 +14061,7 @@ static void test_enum_surfaces(void)
     param.count = 0;
     hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
             NULL, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(!param.count, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     memset(&desc, 0, sizeof(desc));
@@ -14071,15 +14071,15 @@ static void test_enum_surfaces(void)
 
     hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#lx.\n", hr);
 
     hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_NOMATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#lx.\n", hr);
 
     hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#lx.\n", hr);
 
     /* When not passed width and height, the callback is called with every
      * available display resolution. */
@@ -14088,13 +14088,13 @@ static void test_enum_surfaces(void)
     desc.dwFlags |= DDSD_PIXELFORMAT;
     U4(desc).ddpfPixelFormat = current_format;
     hr = IDirectDraw2_EnumDisplayModes(ddraw, 0, &desc, &param, build_mode_list_cb);
-    ok(hr == DD_OK, "Failed to build mode list, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to build mode list, hr %#lx.\n", hr);
 
     param.count = 0;
     desc.dwFlags &= ~DDSD_PIXELFORMAT;
     hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == param.mode_count, "Expected %u surfaces, got %u.\n", param.mode_count, param.count);
 
     desc.dwFlags |= DDSD_WIDTH | DDSD_HEIGHT;
@@ -14105,15 +14105,15 @@ static void test_enum_surfaces(void)
     param.count = 0;
     hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     hr = IDirectDraw2_CreateSurface(ddraw, &desc, &param.surfaces[0], NULL);
-    ok(hr == DD_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to create surface, hr %#lx.\n", hr);
     param.count = 0;
     hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count);
     IDirectDrawSurface2_Release(param.surfaces[0]);
 
@@ -14125,7 +14125,7 @@ static void test_enum_surfaces(void)
     param.count = 0;
     hr = IDirectDraw2_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(!param.count, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     IDirectDraw2_Release(ddraw);
@@ -14199,19 +14199,19 @@ static void test_viewport(void)
     }
 
     hr = IDirect3DDevice2_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D2 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D2 interface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable depth test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable depth test, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
-    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat);
-    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
 
     black_background = create_diffuse_material(device, 0.0f, 0.0f, 0.0f, 0.0f);
 
@@ -14234,23 +14234,23 @@ static void test_viewport(void)
             surface_desc.dwHeight = rt_sizes[i].y;
             surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
             hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &rt, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             surface_desc.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
             surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
             surface_desc.ddpfPixelFormat = z_fmt;
             hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &ds, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirectDrawSurface_AddAttachedSurface(rt, ds);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice2_SetRenderTarget(device, rt, 0);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         }
         else
         {
             hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         }
 
         full_viewport = create_viewport(device, 0, 0, rt_sizes[i].x, rt_sizes[i].y);
@@ -14268,12 +14268,12 @@ static void test_viewport(void)
                     || tests[j].vp.dwY + tests[j].vp.dwHeight > rt_sizes[i].y;
 
             hr = IDirect3DViewport2_Clear(full_viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3D2_CreateViewport(d3d, &viewport, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DViewport2_SetViewport2(viewport, NULL);
-            ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+            ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
             memset(&vp, 0, sizeof(vp));
             vp.dwSize = sizeof(vp);
             vp.dwX = tests[j].vp.dwX;
@@ -14285,14 +14285,14 @@ static void test_viewport(void)
             vp.dvMinZ = 0.0f;
             vp.dvMaxZ = 1.0f;
             hr = IDirect3DViewport2_SetViewport(viewport, &vp);
-            ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice2_AddViewport(device, viewport);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DViewport2_SetViewport(viewport, &vp);
-            ok(hr == (expected_failure ? E_INVALIDARG : DD_OK), "Got unexpected hr %#x.\n", hr);
+            ok(hr == (expected_failure ? E_INVALIDARG : DD_OK), "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             if (expected_failure)
             {
                 destroy_viewport(device, viewport);
@@ -14301,11 +14301,11 @@ static void test_viewport(void)
             }
 
             hr = IDirect3DDevice2_BeginScene(device);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, quad, 4, 0);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice2_EndScene(device);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             check_rect(rt, tests[j].expected_rect);
 
@@ -14316,7 +14316,7 @@ static void test_viewport(void)
         destroy_viewport(device, full_viewport);
 
         hr = IDirectDrawSurface_DeleteAttachedSurface(rt, 0, ds);
-        ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x (i %u).\n", hr, i);
+        ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx (i %u).\n", hr, i);
         IDirectDrawSurface_Release(ds);
 
         IDirectDrawSurface_Release(rt);
@@ -14326,7 +14326,7 @@ static void test_viewport(void)
 
     destroy_material(black_background);
     refcount = IDirect3DDevice2_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D2_Release(d3d);
     IDirectDraw2_Release(ddraw);
     DestroyWindow(window);
@@ -14388,48 +14388,48 @@ static void test_find_device(void)
     result.dwSize = sizeof(result);
     search.dwSize = sizeof(search);
     hr = IDirect3D2_FindDevice(d3d, NULL, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D2_FindDevice(d3d, NULL, &result);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D2_FindDevice(d3d, &search, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D2_FindDevice(d3d, &search, &result);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(result.dwSize == sizeof(result), "Got unexpected result size %u.\n", result.dwSize);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(result.dwSize == sizeof(result), "Got unexpected result size %lu.\n", result.dwSize);
     ok(result.ddHwDesc.dwSize == sizeof(result_v2.hw_desc),
-            "Got unexpected HW desc size %u.\n", result.ddHwDesc.dwSize);
+            "Got unexpected HW desc size %lu.\n", result.ddHwDesc.dwSize);
     ok(result.ddSwDesc.dwSize == sizeof(result_v2.sw_desc),
-            "Got unexpected SW desc size %u.\n", result.ddSwDesc.dwSize);
+            "Got unexpected SW desc size %lu.\n", result.ddSwDesc.dwSize);
 
     memset(&search, 0, sizeof(search));
     memset(&result, 0, sizeof(result));
     hr = IDirect3D2_FindDevice(d3d, &search, &result);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     search.dwSize = sizeof(search) + 1;
     result.dwSize = sizeof(result) + 1;
     hr = IDirect3D2_FindDevice(d3d, &search, &result);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     search.dwSize = sizeof(search);
 
     memset(&result_v1, 0, sizeof(result_v1));
     result_v1.size = sizeof(result_v1);
     hr = IDirect3D2_FindDevice(d3d, &search, (D3DFINDDEVICERESULT *)&result_v1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(result_v1.hw_desc.dwSize == sizeof(result_v2.hw_desc),
-            "Got unexpected HW desc size %u.\n", result_v1.hw_desc.dwSize);
+            "Got unexpected HW desc size %lu.\n", result_v1.hw_desc.dwSize);
     ok(result_v1.sw_desc.dwSize == sizeof(result_v2.sw_desc),
-            "Got unexpected SW desc size %u.\n", result_v1.sw_desc.dwSize);
+            "Got unexpected SW desc size %lu.\n", result_v1.sw_desc.dwSize);
 
     memset(&result_v2, 0, sizeof(result_v2));
     result_v2.size = sizeof(result_v2);
     hr = IDirect3D2_FindDevice(d3d, &search, (D3DFINDDEVICERESULT *)&result_v2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(result_v2.hw_desc.dwSize == sizeof(result_v2.hw_desc),
-            "Got unexpected HW desc size %u.\n", result_v2.hw_desc.dwSize);
+            "Got unexpected HW desc size %lu.\n", result_v2.hw_desc.dwSize);
     ok(result_v2.sw_desc.dwSize == sizeof(result_v2.sw_desc),
-            "Got unexpected SW desc size %u.\n", result_v2.sw_desc.dwSize);
+            "Got unexpected SW desc size %lu.\n", result_v2.sw_desc.dwSize);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -14442,21 +14442,21 @@ static void test_find_device(void)
         result.dwSize = sizeof(result);
 
         hr = IDirect3D2_FindDevice(d3d, &search, &result);
-        ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
-        ok(result.dwSize == sizeof(result), "Test %u: Got unexpected result size %u.\n", i, result.dwSize);
+        ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx.\n", i, hr);
+        ok(result.dwSize == sizeof(result), "Test %u: Got unexpected result size %lu.\n", i, result.dwSize);
         if (SUCCEEDED(hr))
         {
             ok(result.ddHwDesc.dwSize == sizeof(result_v2.hw_desc),
-                    "Test %u: Got unexpected HW desc size %u.\n", i, result.ddHwDesc.dwSize);
+                    "Test %u: Got unexpected HW desc size %lu.\n", i, result.ddHwDesc.dwSize);
             ok(result.ddSwDesc.dwSize == sizeof(result_v2.sw_desc),
-                    "Test %u: Got unexpected SW desc size %u.\n", i, result.ddSwDesc.dwSize);
+                    "Test %u: Got unexpected SW desc size %lu.\n", i, result.ddSwDesc.dwSize);
         }
         else
         {
             ok(!result.ddHwDesc.dwSize,
-                    "Test %u: Got unexpected HW desc size %u.\n", i, result.ddHwDesc.dwSize);
+                    "Test %u: Got unexpected HW desc size %lu.\n", i, result.ddHwDesc.dwSize);
             ok(!result.ddSwDesc.dwSize,
-                    "Test %u: Got unexpected SW desc size %u.\n", i, result.ddSwDesc.dwSize);
+                    "Test %u: Got unexpected SW desc size %lu.\n", i, result.ddSwDesc.dwSize);
         }
     }
 
@@ -14483,7 +14483,7 @@ static void test_find_device(void)
     search.dcmColorModel = 0xdeadbeef;
     result.dwSize = sizeof(result);
     hr = IDirect3D2_FindDevice(d3d, &search, &result);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3D2_Release(d3d);
     IDirectDraw2_Release(ddraw);
@@ -14499,9 +14499,9 @@ static LRESULT CALLBACK killfocus_proc(HWND window, UINT message, WPARAM wparam,
     if (message == WM_KILLFOCUS)
     {
         ref = IDirectDrawSurface_Release(killfocus_surface);
-        ok(!ref, "Unexpected surface refcount %u.\n", ref);
+        ok(!ref, "Unexpected surface refcount %lu.\n", ref);
         ref = IDirectDraw2_Release(killfocus_ddraw);
-        ok(!ref, "Unexpected ddraw refcount %u.\n", ref);
+        ok(!ref, "Unexpected ddraw refcount %lu.\n", ref);
         killfocus_ddraw = NULL;
     }
 
@@ -14526,14 +14526,14 @@ static void test_killfocus(void)
     ok(!!killfocus_ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw2_SetCooperativeLevel(killfocus_ddraw, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw2_CreateSurface(killfocus_ddraw, &surface_desc, &killfocus_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     SetForegroundWindow(GetDesktopWindow());
     ok(!killfocus_ddraw, "WM_KILLFOCUS was not received.\n");
@@ -14556,38 +14556,38 @@ static void test_gdi_surface(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Retrieving the GDI surface requires a primary surface to exist. */
     gdi_surface = (void *)0xc0dec0de;
     hr = IDirectDraw2_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!gdi_surface, "Got unexpected surface %p.\n", gdi_surface);
 
     hr = IDirectDraw2_FlipToGDISurface(ddraw);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw2_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(gdi_surface == primary, "Got unexpected surface %p, expected %p.\n", gdi_surface, primary);
     IDirectDrawSurface_Release(gdi_surface);
 
     /* Flipping to the GDI surface requires the primary surface to be
      * flippable. */
     hr = IDirectDraw2_FlipToGDISurface(ddraw);
-    ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(primary);
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -14595,40 +14595,40 @@ static void test_gdi_surface(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     U5(surface_desc).dwBackBufferCount = 1;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_GetAttachedSurface(primary, &caps, &backbuffer);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(backbuffer != primary, "Got unexpected backbuffer %p.\n", backbuffer);
 
     hr = IDirectDraw2_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(gdi_surface == primary, "Got unexpected surface %p, expected %p.\n", gdi_surface, primary);
     IDirectDrawSurface_Release(gdi_surface);
 
     hr = IDirectDrawSurface_Flip(primary, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw2_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(gdi_surface == backbuffer || broken(gdi_surface == primary),
             "Got unexpected surface %p, expected %p.\n", gdi_surface, backbuffer);
     IDirectDrawSurface_Release(gdi_surface);
 
     hr = IDirectDraw2_FlipToGDISurface(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw2_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(gdi_surface == primary, "Got unexpected surface %p, expected %p.\n", gdi_surface, primary);
     IDirectDrawSurface_Release(gdi_surface);
 
     hr = IDirectDraw2_FlipToGDISurface(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(backbuffer);
     IDirectDrawSurface_Release(primary);
 
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -14686,64 +14686,64 @@ static void test_alphatest(void)
         return;
     }
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     blue = create_diffuse_material(device, 0.0f, 0.0f, 1.0f, 1.0f);
     failed = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     viewport_set_background(device, viewport, blue);
     hr = IDirect3DViewport2_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ALPHATESTENABLE, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     viewport_set_background(device, viewport, failed);
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ALPHAFUNC, test_data[i].func);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DViewport2_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ALPHAREF, 0x70);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice2_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
                 D3DVT_LVERTEX, quad, ARRAY_SIZE(quad), 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice2_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, test_data[i].color_greater, 0),
-                "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n",
+                "Alphatest failed, color 0x%08lx, expected 0x%08lx, alpha > ref, func %u.\n",
                 color, test_data[i].color_greater, test_data[i].func);
 
         hr = IDirect3DViewport2_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ALPHAREF, 0xff70);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice2_GetRenderState(device, D3DRENDERSTATE_ALPHAREF, &value);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-        ok(value == 0xff70, "Got unexpected value %#x.\n", value);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+        ok(value == 0xff70, "Got unexpected value %#lx.\n", value);
         hr = IDirect3DDevice2_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
                 D3DVT_LVERTEX, quad, ARRAY_SIZE(quad), 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice2_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, test_data[i].color_greater, 0),
-                "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n",
+                "Alphatest failed, color 0x%08lx, expected 0x%08lx, alpha > ref, func %u.\n",
                 color, test_data[i].color_greater, test_data[i].func);
     }
 
@@ -14752,9 +14752,9 @@ static void test_alphatest(void)
     destroy_material(blue);
     IDirectDrawSurface_Release(rt);
     refcount = IDirect3DDevice2_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -14775,24 +14775,24 @@ static void test_clipper_refcount(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw2_CreateClipper(ddraw, 0, &clipper, NULL);
-    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     /* Show that clipper validation doesn't somehow happen through per-clipper vtable
      * pointers. */
     hr = IDirectDraw2_CreateClipper(ddraw, 0, &clipper2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
     ok(clipper->lpVtbl == clipper2->lpVtbl, "Got different clipper vtables %p and %p.\n",
             clipper->lpVtbl, clipper2->lpVtbl);
     orig_vtbl = clipper->lpVtbl;
@@ -14800,50 +14800,50 @@ static void test_clipper_refcount(void)
 
     /* Surfaces hold a reference to clippers. No surprises there. */
     hr = IDirectDrawSurface_SetClipper(surface, clipper);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface_GetClipper(surface, &clipper2);
-    ok(SUCCEEDED(hr), "Failed to get clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get clipper, hr %#lx.\n", hr);
     ok(clipper == clipper2, "Got clipper %p, expected %p.\n", clipper2, clipper);
     refcount = IDirectDrawClipper_Release(clipper2);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface_SetClipper(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface_SetClipper(surface, clipper);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     refcount = IDirectDrawSurface_Release(surface);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     /* SetClipper with an invalid pointer crashes. */
 
     /* Clipper methods work with a broken vtable, with the exception of Release. */
     clipper->lpVtbl = (void *)0xdeadbeef;
     refcount = orig_vtbl->AddRef(clipper);
-    todo_wine ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    todo_wine ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
     refcount = orig_vtbl->Release(clipper);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     clipper->lpVtbl = orig_vtbl;
     refcount = orig_vtbl->Release(clipper);
-    todo_wine ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    todo_wine ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     /* Fix the refcount difference because Wine did not increase the ref in the
      * AddRef call above. */
     if (refcount)
     {
         refcount = IDirectDrawClipper_Release(clipper);
-        ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+        ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     }
 
     /* Steal the reference and see what happens - releasing the surface works fine.
@@ -14851,11 +14851,11 @@ static void test_clipper_refcount(void)
      * release it after the GetClipper call is likely to crash, and certain to crash
      * if we allocate and zero as much heap memory as we can get. */
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw2_CreateClipper(ddraw, 0, &clipper, NULL);
-    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_SetClipper(surface, clipper);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
 
     IDirectDrawClipper_Release(clipper);
     IDirectDrawClipper_Release(clipper);
@@ -14871,7 +14871,7 @@ static void test_clipper_refcount(void)
          * The same Windows and driver versions run the test without heap corruption on
          * a Geforce 1060 GTX card. I have not seen the problem on AMD GPUs either. */
         hr = IDirectDrawSurface_GetClipper(surface, &clipper2);
-        ok(SUCCEEDED(hr), "Failed to get clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get clipper, hr %#lx.\n", hr);
         ok(clipper == clipper2, "Got clipper %p, expected %p.\n", clipper2, clipper);
     }
 
@@ -14879,10 +14879,10 @@ static void test_clipper_refcount(void)
      * vtable through the clipper pointer because it is no longer pointing to
      * valid memory. */
     refcount = orig_vtbl->Release(clipper);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
 
     refcount = IDirectDrawSurface_Release(surface);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
 
     /* It looks like the protection against invalid thispointers is part of
      * the IDirectDrawClipper method implementation, not IDirectDrawSurface. */
@@ -14895,33 +14895,33 @@ static void test_clipper_refcount(void)
     clipper->lpVtbl = orig_vtbl;
 
     refcount = orig_vtbl->AddRef(clipper);
-    todo_wine ok(!refcount, "Got refcount %u.\n", refcount);
+    todo_wine ok(!refcount, "Got refcount %lu.\n", refcount);
     refcount = orig_vtbl->AddRef((IDirectDrawClipper *)(ULONG_PTR)0xdeadbeef);
-    ok(!refcount, "Got refcount %u.\n", refcount);
+    ok(!refcount, "Got refcount %lu.\n", refcount);
 
     changed = 0x1234;
     hr = orig_vtbl->IsClipListChanged(clipper, &changed);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     todo_wine ok(changed == 0x1234, "'changed' changed: %x.\n", changed);
 
     changed = 0x1234;
     hr = orig_vtbl->IsClipListChanged((IDirectDrawClipper *)(ULONG_PTR)0xdeadbeef, &changed);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     ok(changed == 0x1234, "'changed' changed: %x.\n", changed);
 
     /* Nope, we can't initialize our fake clipper. */
     hr = IDirectDraw2_QueryInterface(ddraw, &IID_IDirectDraw, (void **)&ddraw1);
-    ok(SUCCEEDED(hr), "Failed to get ddraw1 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw1 interface, hr %#lx.\n", hr);
 
     hr = orig_vtbl->Initialize(clipper, ddraw1, 0);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDraw_Release(ddraw1);
 
     HeapFree(GetProcessHeap(), 0, clipper);
 
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -14974,35 +14974,35 @@ static void test_caps(void)
     hal_caps.dwSize = sizeof(hal_caps);
     hel_caps.dwSize = sizeof(hel_caps);
     hr = IDirectDraw2_GetCaps(ddraw, &hal_caps, &hel_caps);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(hal_caps.ddsOldCaps.dwCaps == hal_caps.ddsCaps.dwCaps,
-            "Got unexpected caps %#x, expected %#x.\n",
+            "Got unexpected caps %#lx, expected %#lx.\n",
             hal_caps.ddsOldCaps.dwCaps, hal_caps.ddsCaps.dwCaps);
     ok(hel_caps.ddsOldCaps.dwCaps == hel_caps.ddsCaps.dwCaps,
-            "Got unexpected caps %#x, expected %#x.\n",
+            "Got unexpected caps %#lx, expected %#lx.\n",
             hel_caps.ddsOldCaps.dwCaps, hel_caps.ddsCaps.dwCaps);
 
     no3d = !(hal_caps.ddsCaps.dwCaps & DDSCAPS_3DDEVICE);
     if (hal_caps.ddsCaps.dwCaps)
     {
-        ok(!(hal_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
-        ok(!(~hal_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(hal_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(~hal_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
         todo_wine_if(no3d) ok(!(~hal_caps.ddsCaps.dwCaps & caps_hal),
-                "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
+                "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
     }
-    ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
-    ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+    ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
+    ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
     todo_wine_if(!no3d) ok(!(hel_caps.ddsCaps.dwCaps & caps_hal),
-            "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+            "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
 
     IDirectDraw2_Release(ddraw);
 
     if (hal_caps.ddsCaps.dwCaps)
     {
         hr = DirectDrawCreate((GUID *)DDCREATE_HARDWAREONLY, &ddraw1, NULL);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirectDraw2, (void **)&ddraw);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         IDirectDraw_Release(ddraw1);
 
         memset(&hal_caps, 0, sizeof(hal_caps));
@@ -15010,39 +15010,39 @@ static void test_caps(void)
         hal_caps.dwSize = sizeof(hal_caps);
         hel_caps.dwSize = sizeof(hel_caps);
         hr = IDirectDraw2_GetCaps(ddraw, &hal_caps, &hel_caps);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         ok(hal_caps.ddsOldCaps.dwCaps == hal_caps.ddsCaps.dwCaps,
-                "Got unexpected caps %#x, expected %#x.\n",
+                "Got unexpected caps %#lx, expected %#lx.\n",
                 hal_caps.ddsOldCaps.dwCaps, hal_caps.ddsCaps.dwCaps);
         ok(hel_caps.ddsOldCaps.dwCaps == hel_caps.ddsCaps.dwCaps,
-                "Got unexpected caps %#x, expected %#x.\n",
+                "Got unexpected caps %#lx, expected %#lx.\n",
                 hel_caps.ddsOldCaps.dwCaps, hel_caps.ddsCaps.dwCaps);
 
-        ok(!(hal_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
-        ok(!(~hal_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(hal_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(~hal_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
         todo_wine_if(no3d) ok(!(~hal_caps.ddsCaps.dwCaps & caps_hal),
-                "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
+                "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
         if (is_ddraw64)
         {
-            ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
-            ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+            ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
+            ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
             todo_wine_if(!no3d) ok(!(hel_caps.ddsCaps.dwCaps & caps_hal),
-                    "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+                    "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
         }
         else
         {
-            todo_wine ok(!hel_caps.ddsCaps.dwCaps, "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+            todo_wine ok(!hel_caps.ddsCaps.dwCaps, "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
         }
 
         IDirectDraw2_Release(ddraw);
     }
 
     hr = DirectDrawCreate((GUID *)DDCREATE_EMULATIONONLY, &ddraw1, NULL);
-    ok(hr == DD_OK || (is_ddraw64 && hr == E_FAIL), "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK || (is_ddraw64 && hr == E_FAIL), "Got unexpected hr %#lx.\n", hr);
     if (SUCCEEDED(hr))
     {
         hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirectDraw2, (void **)&ddraw);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         IDirectDraw_Release(ddraw1);
 
         memset(&hal_caps, 0, sizeof(hal_caps));
@@ -15050,19 +15050,19 @@ static void test_caps(void)
         hal_caps.dwSize = sizeof(hal_caps);
         hel_caps.dwSize = sizeof(hel_caps);
         hr = IDirectDraw2_GetCaps(ddraw, &hal_caps, &hel_caps);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         ok(hal_caps.ddsOldCaps.dwCaps == hal_caps.ddsCaps.dwCaps,
-                "Got unexpected caps %#x, expected %#x.\n",
+                "Got unexpected caps %#lx, expected %#lx.\n",
                 hal_caps.ddsOldCaps.dwCaps, hal_caps.ddsCaps.dwCaps);
         ok(hel_caps.ddsOldCaps.dwCaps == hel_caps.ddsCaps.dwCaps,
-                "Got unexpected caps %#x, expected %#x.\n",
+                "Got unexpected caps %#lx, expected %#lx.\n",
                 hel_caps.ddsOldCaps.dwCaps, hel_caps.ddsCaps.dwCaps);
 
-        todo_wine ok(!hal_caps.ddsCaps.dwCaps, "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
-        ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
-        ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+        todo_wine ok(!hal_caps.ddsCaps.dwCaps, "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
+        ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
         todo_wine_if(!no3d) ok(!(hel_caps.ddsCaps.dwCaps & caps_hal),
-                "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+                "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
 
         IDirectDraw2_Release(ddraw);
     }
@@ -15081,7 +15081,7 @@ static void test_d32_support(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -15091,21 +15091,21 @@ static void test_d32_support(void)
     surface_desc.dwWidth = 64;
     surface_desc.dwHeight = 64;
     hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok((surface_desc.dwFlags & DDSD_ZBUFFERBITDEPTH), "Got unexpected flags %#x.\n", surface_desc.dwFlags);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok((surface_desc.dwFlags & DDSD_ZBUFFERBITDEPTH), "Got unexpected flags %#lx.\n", surface_desc.dwFlags);
     ok(U2(surface_desc).dwZBufferBitDepth == 32,
-            "Got unexpected dwZBufferBitDepth %u.\n", U2(surface_desc).dwZBufferBitDepth);
+            "Got unexpected dwZBufferBitDepth %lu.\n", U2(surface_desc).dwZBufferBitDepth);
     ok(!(surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY),
-            "Got unexpected surface caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+            "Got unexpected surface caps %#lx.\n", surface_desc.ddsCaps.dwCaps);
     IDirectDrawSurface_Release(surface);
 
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -15159,13 +15159,13 @@ static void test_cursor_clipping(void)
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw2_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "GetDisplayMode failed, hr %#lx.\n", hr);
 
     memset(&param, 0, sizeof(param));
     param.old_width = surface_desc.dwWidth;
     param.old_height = surface_desc.dwHeight;
     hr = IDirectDraw2_EnumDisplayModes(ddraw, 0, NULL, &param, find_different_mode_callback);
-    ok(hr == DD_OK, "EnumDisplayModes failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "EnumDisplayModes failed, hr %#lx.\n", hr);
     if (!(param.new_width && param.new_height))
     {
         skip("Failed to find a different mode than %ux%u.\n", param.old_width, param.old_height);
@@ -15173,87 +15173,87 @@ static void test_cursor_clipping(void)
     }
 
     ret = ClipCursor(NULL);
-    ok(ret, "ClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "ClipCursor failed, error %#lx.\n", GetLastError());
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     /* Set cooperative level to normal */
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     flush_events();
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     hr = set_display_mode(ddraw, param.new_width, param.new_height);
-    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode failed, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
-        win_skip("SetDisplayMode failed, hr %#x.\n", hr);
+        win_skip("SetDisplayMode failed, hr %#lx.\n", hr);
         goto done;
     }
     flush_events();
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     hr = IDirectDraw2_RestoreDisplayMode(ddraw);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
     flush_events();
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     /* Switch to full screen cooperative level */
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     flush_events();
     SetRect(&rect, 0, 0, param.old_width, param.old_height);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     hr = set_display_mode(ddraw, param.new_width, param.new_height);
-    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode failed, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
-        win_skip("SetDisplayMode failed, hr %#x.\n", hr);
+        win_skip("SetDisplayMode failed, hr %#lx.\n", hr);
         goto done;
     }
     flush_events();
     SetRect(&rect, 0, 0, param.new_width, param.new_height);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     /* Restore display mode */
     hr = IDirectDraw2_RestoreDisplayMode(ddraw);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
     flush_events();
     SetRect(&rect, 0, 0, param.old_width, param.old_height);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     /* Switch to normal cooperative level */
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     flush_events();
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
@@ -15280,10 +15280,10 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
     flush_events();
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     flush_events();
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "GetWindowRect failed, error %#x.\n", GetLastError());
+    ok(ret, "GetWindowRect failed, error %#lx.\n", GetLastError());
     SetRect(&primary_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
     ok(EqualRect(&window_rect, &primary_rect), "Expect window rect %s, got %s.\n",
             wine_dbgstr_rect(&primary_rect), wine_dbgstr_rect(&window_rect));
@@ -15294,9 +15294,9 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
 
     ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left,
             new_rect.bottom - new_rect.top, TRUE);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ok(EqualRect(&window_rect, &new_rect),
             "Expected window rect %s, got %s.\n",
             wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect));
@@ -15304,7 +15304,7 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
      * on the second resize remains. */
     flush_events();
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     /* Both Windows and Wine change the size of the window. On Windows it is exactly the new size but in Wine
      * it may get adjusted depending on window manager. */
     ok(window_rect.right != monitor_rect->right && window_rect.bottom != monitor_rect->bottom,
@@ -15313,15 +15313,15 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
 
     ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left,
             new_rect.bottom - new_rect.top, TRUE);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ok(EqualRect(&window_rect, &new_rect),
             "Expected window rect %s, got %s.\n",
             wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect));
     flush_events();
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ok(window_rect.right != monitor_rect->right && window_rect.bottom != monitor_rect->bottom,
             "Expected window rect %s, got %s.\n",
             wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect));
@@ -15329,25 +15329,25 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
     /* Window activation should restore the window to fit the whole primary monitor */
     ret = SetWindowPos(window, 0, monitor_rect->left, monitor_rect->top, 0, 0,
             SWP_NOZORDER | SWP_NOSIZE);
-    ok(ret, "SetWindowPos failed, error %#x.\n", GetLastError());
+    ok(ret, "SetWindowPos failed, error %#lx.\n", GetLastError());
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     flush_events();
     ret = ShowWindow(window, SW_RESTORE);
-    ok(ret, "Failed to restore window, error %#x.\n", GetLastError());
+    ok(ret, "Failed to restore window, error %#lx.\n", GetLastError());
     flush_events();
     ret = SetForegroundWindow(window);
-    ok(ret, "SetForegroundWindow failed, error %#x.\n", GetLastError());
+    ok(ret, "SetForegroundWindow failed, error %#lx.\n", GetLastError());
     flush_events();
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "GetWindowRect failed, error %#x.\n", GetLastError());
+    ok(ret, "GetWindowRect failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&window_rect, &primary_rect), "Expect window rect %s, got %s.\n",
             wine_dbgstr_rect(&primary_rect), wine_dbgstr_rect(&window_rect));
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "GetWindowRect failed, error %#x.\n", GetLastError());
+    ok(ret, "GetWindowRect failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&window_rect, &primary_rect), "Expect window rect %s, got %s.\n",
             wine_dbgstr_rect(&primary_rect), wine_dbgstr_rect(&window_rect));
 
@@ -15378,14 +15378,14 @@ static BOOL CALLBACK test_get_display_mode_cb(HMONITOR monitor, HDC hdc, RECT *m
     /* Test that DirectDraw doesn't use the device window to determine which monitor to use */
     ret = SetWindowPos(window, 0, monitor_rect->left, monitor_rect->top, 0, 0,
             SWP_NOZORDER | SWP_NOSIZE);
-    ok(ret, "SetWindowPos failed, error %#x.\n", GetLastError());
+    ok(ret, "SetWindowPos failed, error %#lx.\n", GetLastError());
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw2_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == GetSystemMetrics(SM_CXSCREEN), "Expect width %d, got %d.\n",
+    ok(hr == DD_OK, "GetDisplayMode failed, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == GetSystemMetrics(SM_CXSCREEN), "Expect width %d, got %ld.\n",
             GetSystemMetrics(SM_CXSCREEN), surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == GetSystemMetrics(SM_CYSCREEN), "Expect height %d, got %d.\n",
+    ok(surface_desc.dwHeight == GetSystemMetrics(SM_CYSCREEN), "Expect height %d, got %ld.\n",
             GetSystemMetrics(SM_CYSCREEN), surface_desc.dwHeight);
 
     DestroyWindow(window);
@@ -15412,41 +15412,41 @@ static void test_get_display_mode(void)
     ok(!!window, "Failed to create a window.\n");
 
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     memset(&devmode, 0, sizeof(devmode));
     devmode.dmSize = sizeof(devmode);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw2_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
-    ok(surface_desc.dwSize == sizeof(surface_desc), "Expected dwSize %u, got %u.\n",
+    ok(hr == DD_OK, "GetDisplayMode failed, hr %#lx.\n", hr);
+    ok(surface_desc.dwSize == sizeof(surface_desc), "Expected dwSize %Iu, got %lu.\n",
             sizeof(surface_desc), surface_desc.dwSize);
-    ok(surface_desc.dwFlags == flags, "Expected dwFlags %#x, got %#x.\n", flags,
+    ok(surface_desc.dwFlags == flags, "Expected dwFlags %#lx, got %#lx.\n", flags,
             surface_desc.dwFlags);
-    ok(surface_desc.dwWidth == devmode.dmPelsWidth, "Expected width %u, got %u.\n",
+    ok(surface_desc.dwWidth == devmode.dmPelsWidth, "Expected width %lu, got %lu.\n",
             devmode.dmPelsWidth, surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == devmode.dmPelsHeight, "Expected height %u, got %u.\n",
+    ok(surface_desc.dwHeight == devmode.dmPelsHeight, "Expected height %lu, got %lu.\n",
             devmode.dmPelsHeight, surface_desc.dwHeight);
-    ok(surface_desc.dwRefreshRate == devmode.dmDisplayFrequency, "Expected frequency %u, got %u.\n",
+    ok(surface_desc.dwRefreshRate == devmode.dmDisplayFrequency, "Expected frequency %lu, got %lu.\n",
             devmode.dmDisplayFrequency, surface_desc.dwRefreshRate);
     ok(surface_desc.ddpfPixelFormat.dwSize == sizeof(surface_desc.ddpfPixelFormat),
-            "Expected ddpfPixelFormat.dwSize %u, got %u.\n", sizeof(surface_desc.ddpfPixelFormat),
+            "Expected ddpfPixelFormat.dwSize %Iu, got %lu.\n", sizeof(surface_desc.ddpfPixelFormat),
             surface_desc.ddpfPixelFormat.dwSize);
     ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == devmode.dmBitsPerPel,
-            "Expected ddpfPixelFormat.dwRGBBitCount %u, got %u.\n", devmode.dmBitsPerPel,
+            "Expected ddpfPixelFormat.dwRGBBitCount %lu, got %lu.\n", devmode.dmBitsPerPel,
             surface_desc.ddpfPixelFormat.dwRGBBitCount);
     ok(surface_desc.lPitch == devmode.dmPelsWidth * devmode.dmBitsPerPel / 8,
-            "Expected pitch %u, got %u.\n", devmode.dmPelsWidth * devmode.dmBitsPerPel / 8,
+            "Expected pitch %lu, got %lu.\n", devmode.dmPelsWidth * devmode.dmBitsPerPel / 8,
             surface_desc.lPitch);
 
     memset(&param, 0, sizeof(param));
     param.old_frequency = surface_desc.dwRefreshRate;
     hr = IDirectDraw2_EnumDisplayModes(ddraw, DDEDM_REFRESHRATES, NULL, &param,
             find_different_mode_callback);
-    ok(hr == DD_OK, "EnumDisplayModes failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "EnumDisplayModes failed, hr %#lx.\n", hr);
     if (!param.new_frequency)
     {
         skip("Failed to find a display mode with a different frequency.\n");
@@ -15455,17 +15455,17 @@ static void test_get_display_mode(void)
 
     hr = IDirectDraw2_SetDisplayMode(ddraw, param.new_width, param.new_height, param.new_bpp,
             param.new_frequency, 0);
-    ok(hr == DD_OK, "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDraw2_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == param.new_width, "Expected width %u, got %u.\n", param.new_width,
+    ok(hr == DD_OK, "GetDisplayMode failed, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == param.new_width, "Expected width %u, got %lu.\n", param.new_width,
             surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == param.new_height, "Expected height %u, got %u.\n", param.new_height,
+    ok(surface_desc.dwHeight == param.new_height, "Expected height %u, got %lu.\n", param.new_height,
             surface_desc.dwHeight);
-    ok(surface_desc.dwRefreshRate == param.new_frequency, "Expected frequency %u, got %u.\n",
+    ok(surface_desc.dwRefreshRate == param.new_frequency, "Expected frequency %u, got %lu.\n",
             param.new_frequency, surface_desc.dwRefreshRate);
     ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == param.new_bpp,
-            "Expected ddpfPixelFormat.dwRGBBitCount %u, got %u.\n", devmode.dmBitsPerPel,
+            "Expected ddpfPixelFormat.dwRGBBitCount %lu, got %lu.\n", devmode.dmBitsPerPel,
             surface_desc.ddpfPixelFormat.dwRGBBitCount);
 
 done:
@@ -15511,11 +15511,11 @@ static void test_texture_wrong_caps(const GUID *device_guid)
         return;
     }
     hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -15525,37 +15525,37 @@ static void test_texture_wrong_caps(const GUID *device_guid)
     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     U4(ddsd).ddpfPixelFormat = fmt;
     hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture2_GetHandle(texture, device, &texture_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     fill_surface(surface, 0xff00ff00);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, texture_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     background = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f);
     viewport_set_background(device, viewport, background);
 
     hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     if (is_software_device_type(device_guid))
         fill_surface(rt, 0xffff0000);
 
     hr = IDirect3DDevice2_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, quad, ARRAY_SIZE(quad), 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     expected_color = is_software_device_type(device_guid) ? 0x0000ff00 : 0x00ffffff;
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, expected_color, 1), "Got color 0x%08x, expected 0x%08x.\n", color, expected_color);
+    ok(compare_color(color, expected_color, 1), "Got color 0x%08lx, expected 0x%08lx.\n", color, expected_color);
 
     IDirect3DTexture2_Release(texture);
     IDirectDrawSurface_Release(surface);
@@ -15564,7 +15564,7 @@ static void test_texture_wrong_caps(const GUID *device_guid)
     destroy_material(background);
     IDirectDraw2_Release(ddraw);
     refcount = IDirect3DDevice2_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -15908,15 +15908,15 @@ static void test_filling_convention(void)
     }
 
     hr = IDirect3DDevice2_GetDirect3D(device, &d3d);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_GetRenderTarget(device, &backbuffer);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, vp_size, vp_size);
     background = create_diffuse_material(device, 0.0f, 0.0f, 1.0f, 1.0f);
     viewport_set_background(device, viewport, background);
     hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
@@ -15931,7 +15931,7 @@ static void test_filling_convention(void)
     desc.ddpfPixelFormat.dwGBitMask = 0x0000ff00;
     desc.ddpfPixelFormat.dwBBitMask = 0x000000ff;
     hr = IDirectDraw2_CreateSurface(ddraw, &desc, &rt, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Nvidia on Windows 10 refuses to set the offscreen RT
      * if it does not have an attached depth stencil. */
@@ -15940,7 +15940,7 @@ static void test_filling_convention(void)
     desc.dwSize = sizeof(desc);
     desc.ddpfPixelFormat.dwSize = sizeof(desc.ddpfPixelFormat);
     hr = IDirectDrawSurface_GetPixelFormat(ds, &desc.ddpfPixelFormat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface4_Release(ds);
 
     desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
@@ -15948,14 +15948,14 @@ static void test_filling_convention(void)
     desc.dwWidth = vp_size;
     desc.dwHeight = vp_size;
     hr = IDirectDraw2_CreateSurface(ddraw, &desc, &ds, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(rt, ds);
-    ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice2_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -15964,17 +15964,17 @@ static void test_filling_convention(void)
             cur = j ? rt : backbuffer;
 
             hr = IDirect3DDevice2_SetRenderTarget(device, cur, 0);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DViewport2_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice2_BeginScene(device);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLELIST,
                     tests[i].fvf, tests[i].geometry, 12, 0);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice2_EndScene(device);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
             for (y = 0; y < 8; y++)
             {
@@ -16012,7 +16012,7 @@ static void test_filling_convention(void)
                      * convention, but because wined3d will nudge geometry to the left to
                      * keep diagonals (the 'R' in test case 'edge_tris') intact. */
                     todo_wine_if(todo && !compare_color(colour, expected, 1))
-                        ok(compare_color(colour, expected, 1), "Got unexpected colour %08x, %ux%u, case %u, j %u.\n",
+                        ok(compare_color(colour, expected, 1), "Got unexpected colour %08lx, %ux%u, case %u, j %u.\n",
                                 colour, x, y, i, j);
                 }
             }
@@ -16025,9 +16025,9 @@ static void test_filling_convention(void)
     IDirectDrawSurface_Release(ds);
     IDirect3D2_Release(d3d);
     refcount = IDirect3DDevice2_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     refcount = IDirectDraw2_Release(ddraw);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 136cf90fa601..0b68977eb5a5 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -126,7 +126,7 @@ static BOOL ddraw_get_identifier(IDirectDraw4 *ddraw, DDDEVICEIDENTIFIER *identi
     HRESULT hr;
 
     hr = IDirectDraw4_GetDeviceIdentifier(ddraw, identifier, 0);
-    ok(SUCCEEDED(hr), "Failed to get device identifier, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device identifier, hr %#lx.\n", hr);
 
     return SUCCEEDED(hr);
 }
@@ -213,7 +213,7 @@ static DWORD WINAPI create_window_thread_proc(void *param)
 
     p->window = create_window();
     ret = SetEvent(p->window_created);
-    ok(ret, "SetEvent failed, last error %#x.\n", GetLastError());
+    ok(ret, "SetEvent failed, last error %#lx.\n", GetLastError());
 
     for (;;)
     {
@@ -226,7 +226,7 @@ static DWORD WINAPI create_window_thread_proc(void *param)
             break;
         if (res != WAIT_TIMEOUT)
         {
-            ok(0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+            ok(0, "Wait failed (%#lx), last error %#lx.\n", res, GetLastError());
             break;
         }
     }
@@ -241,13 +241,13 @@ static void create_window_thread(struct create_window_thread_param *p)
     DWORD res, tid;
 
     p->window_created = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(!!p->window_created, "CreateEvent failed, last error %#x.\n", GetLastError());
+    ok(!!p->window_created, "CreateEvent failed, last error %#lx.\n", GetLastError());
     p->destroy_window = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(!!p->destroy_window, "CreateEvent failed, last error %#x.\n", GetLastError());
+    ok(!!p->destroy_window, "CreateEvent failed, last error %#lx.\n", GetLastError());
     p->thread = CreateThread(NULL, 0, create_window_thread_proc, p, 0, &tid);
-    ok(!!p->thread, "Failed to create thread, last error %#x.\n", GetLastError());
+    ok(!!p->thread, "Failed to create thread, last error %#lx.\n", GetLastError());
     res = WaitForSingleObject(p->window_created, INFINITE);
-    ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+    ok(res == WAIT_OBJECT_0, "Wait failed (%#lx), last error %#lx.\n", res, GetLastError());
 }
 
 static void destroy_window_thread(struct create_window_thread_param *p)
@@ -266,9 +266,9 @@ static IDirectDrawSurface4 *get_depth_stencil(IDirect3DDevice3 *device)
     HRESULT hr;
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get the render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get the render target, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetAttachedSurface(rt, &caps, &ret);
-    ok(SUCCEEDED(hr) || hr == DDERR_NOTFOUND, "Failed to get the z buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || hr == DDERR_NOTFOUND, "Failed to get the z buffer, hr %#lx.\n", hr);
     IDirectDrawSurface4_Release(rt);
     return ret;
 }
@@ -354,14 +354,14 @@ static D3DCOLOR get_surface_color(IDirectDrawSurface4 *surface, UINT x, UINT y)
     surface_desc.dwSize = sizeof(surface_desc);
 
     hr = IDirectDrawSurface4_Lock(surface, &rect, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     if (FAILED(hr))
         return 0xdeadbeef;
 
     color = *((DWORD *)surface_desc.lpSurface) & 0x00ffffff;
 
     hr = IDirectDrawSurface4_Unlock(surface, &rect);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     return color;
 }
@@ -374,7 +374,7 @@ static void fill_surface(IDirectDrawSurface4 *surface, D3DCOLOR color)
     DWORD *ptr;
 
     hr = IDirectDrawSurface4_Lock(surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (y = 0; y < surface_desc.dwHeight; ++y)
     {
@@ -386,7 +386,7 @@ static void fill_surface(IDirectDrawSurface4 *surface, D3DCOLOR color)
     }
 
     hr = IDirectDrawSurface4_Unlock(surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 }
 
 static void check_rect(IDirectDrawSurface4 *surface, RECT r)
@@ -420,7 +420,7 @@ static void check_rect(IDirectDrawSurface4 *surface, RECT r)
                     if (x < 0 || x >= 640 || y < 0 || y >= 480)
                         continue;
                     color = get_surface_color(surface, x, y);
-                    ok(color == expected, "Pixel (%d, %d) has color %08x, expected %08x.\n", x, y, color, expected);
+                    ok(color == expected, "Pixel (%ld, %ld) has color %08lx, expected %08lx.\n", x, y, color, expected);
                 }
             }
         }
@@ -468,7 +468,7 @@ static IDirect3DDevice3 *create_device_ex(HWND window, DWORD coop_level, const G
         return NULL;
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw4, window, coop_level);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -480,18 +480,18 @@ static IDirect3DDevice3 *create_device_ex(HWND window, DWORD coop_level, const G
     surface_desc.dwHeight = 480;
 
     hr = IDirectDraw4_CreateSurface(ddraw4, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     if (coop_level & DDSCL_NORMAL)
     {
         IDirectDrawClipper *clipper;
 
         hr = IDirectDraw4_CreateClipper(ddraw4, 0, &clipper, NULL);
-        ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
         hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
-        ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
         hr = IDirectDrawSurface4_SetClipper(surface, clipper);
-        ok(SUCCEEDED(hr), "Failed to set surface clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set surface clipper, hr %#lx.\n", hr);
         IDirectDrawClipper_Release(clipper);
     }
 
@@ -523,7 +523,7 @@ static IDirect3DDevice3 *create_device_ex(HWND window, DWORD coop_level, const G
     surface_desc.dwWidth = 640;
     surface_desc.dwHeight = 480;
     hr = IDirectDraw4_CreateSurface(ddraw4, &surface_desc, &ds, NULL);
-    ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
         IDirect3D3_Release(d3d3);
@@ -532,7 +532,7 @@ static IDirect3DDevice3 *create_device_ex(HWND window, DWORD coop_level, const G
     }
 
     hr = IDirectDrawSurface4_AddAttachedSurface(surface, ds);
-    ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
     IDirectDrawSurface4_Release(ds);
     if (FAILED(hr))
     {
@@ -563,11 +563,11 @@ static IDirect3DViewport3 *create_viewport(IDirect3DDevice3 *device, UINT x, UIN
     HRESULT hr;
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D3_CreateViewport(d3d, &viewport, NULL);
-    ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_AddViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to add viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to add viewport, hr %#lx.\n", hr);
     memset(&vp, 0, sizeof(vp));
     vp.dwSize = sizeof(vp);
     vp.dwX = x;
@@ -581,7 +581,7 @@ static IDirect3DViewport3 *create_viewport(IDirect3DDevice3 *device, UINT x, UIN
     vp.dvMinZ = 0.0f;
     vp.dvMaxZ = 1.0f;
     hr = IDirect3DViewport3_SetViewport2(viewport, &vp);
-    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#lx.\n", hr);
     IDirect3D3_Release(d3d);
 
     return viewport;
@@ -592,7 +592,7 @@ static void destroy_viewport(IDirect3DDevice3 *device, IDirect3DViewport3 *viewp
     HRESULT hr;
 
     hr = IDirect3DDevice3_DeleteViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to delete viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to delete viewport, hr %#lx.\n", hr);
     IDirect3DViewport3_Release(viewport);
 }
 
@@ -603,11 +603,11 @@ static IDirect3DMaterial3 *create_material(IDirect3DDevice3 *device, D3DMATERIAL
     HRESULT hr;
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D3_CreateMaterial(d3d, &material, NULL);
-    ok(SUCCEEDED(hr), "Failed to create material, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create material, hr %#lx.\n", hr);
     hr = IDirect3DMaterial3_SetMaterial(material, mat);
-    ok(SUCCEEDED(hr), "Failed to set material data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set material data, hr %#lx.\n", hr);
     IDirect3D3_Release(d3d);
 
     return material;
@@ -701,13 +701,13 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
     {
         if (expect_messages->check_wparam)
             ok (wparam == expect_messages->expect_wparam,
-                    "Got unexpected wparam %lx for message %x, expected %lx.\n",
+                    "Got unexpected wparam %Ix for message %x, expected %Ix.\n",
                     wparam, message, expect_messages->expect_wparam);
 
         if (focus_test_ddraw)
         {
             hr = IDirectDraw4_TestCooperativeLevel(focus_test_ddraw);
-            ok(hr == expect_messages->ddraw_state, "Got ddraw state %#x on message %#x, expected %#x.\n",
+            ok(hr == expect_messages->ddraw_state, "Got ddraw state %#lx on message %#x, expected %#lx.\n",
                     hr, message, expect_messages->ddraw_state);
         }
 
@@ -730,9 +730,9 @@ static void fix_wndproc(HWND window, LONG_PTR proc)
 
     SetWindowLongPtrA(window, GWLP_WNDPROC, proc);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     IDirectDraw4_Release(ddraw);
 }
@@ -775,17 +775,17 @@ static void test_process_vertices(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d3);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = D3DFVF_XYZ;
     vb_desc.dwNumVertices = 3;
     hr = IDirect3D3_CreateVertexBuffer(d3d3, &vb_desc, &src_vb, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to create source vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create source vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_Lock(src_vb, DDLOCK_WRITEONLY, (void **)&src_data, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock source vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock source vertex buffer, hr %#lx.\n", hr);
     src_data[0].x = -1.0f;
     src_data[0].y = -1.0f;
     src_data[0].z = -1.0f;
@@ -796,19 +796,19 @@ static void test_process_vertices(void)
     src_data[2].y = 1.0f;
     src_data[2].z = 1.0f;
     hr = IDirect3DVertexBuffer_Unlock(src_vb);
-    ok(SUCCEEDED(hr), "Failed to unlock source vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock source vertex buffer, hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = D3DFVF_XYZRHW;
     vb_desc.dwNumVertices = 3;
     hr = IDirect3D3_CreateVertexBuffer(d3d3, &vb_desc, &dst_vb, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to create destination vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create destination vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3D3_CreateViewport(d3d3, &viewport, NULL);
-    ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_AddViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to add viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to add viewport, hr %#lx.\n", hr);
     vp2.dwSize = sizeof(vp2);
     vp2.dwX = 10;
     vp2.dwY = 20;
@@ -821,22 +821,22 @@ static void test_process_vertices(void)
     vp2.dvMinZ = -2.0f;
     vp2.dvMaxZ = 3.0f;
     hr = IDirect3DViewport3_SetViewport2(viewport, &vp2);
-    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &identity);
-    ok(SUCCEEDED(hr), "Failed to set world transformation, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transformation, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &identity);
-    ok(SUCCEEDED(hr), "Failed to set view transformation, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set view transformation, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &identity);
-    ok(SUCCEEDED(hr), "Failed to set projection transformation, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transformation, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 0, 3, src_vb, 0, device, 0);
-    ok(SUCCEEDED(hr), "Failed to process vertices, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to process vertices, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_Lock(dst_vb, DDLOCK_READONLY, (void **)&dst_data, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#lx.\n", hr);
     ok(compare_vec4(&dst_data[0], -6.500e+1f, +1.800e+2f, +2.000e-1f, +1.000e+0f, 4096),
             "Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
@@ -847,16 +847,16 @@ static void test_process_vertices(void)
             "Got unexpected vertex 2 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[2].x, dst_data[2].y, dst_data[2].z, dst_data[2].w);
     hr = IDirect3DVertexBuffer_Unlock(dst_vb);
-    ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_MultiplyTransform(device, D3DTRANSFORMSTATE_PROJECTION, &projection);
-    ok(SUCCEEDED(hr), "Failed to set projection transformation, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transformation, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 0, 3, src_vb, 0, device, 0);
-    ok(SUCCEEDED(hr), "Failed to process vertices, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to process vertices, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_Lock(dst_vb, DDLOCK_READONLY, (void **)&dst_data, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#lx.\n", hr);
     ok(compare_vec4(&dst_data[0], +8.500e+1f, -1.000e+2f, +1.800e+0f, +1.000e+0f, 4096),
             "Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
@@ -867,7 +867,7 @@ static void test_process_vertices(void)
             "Got unexpected vertex 2 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[2].x, dst_data[2].y, dst_data[2].z, dst_data[2].w);
     hr = IDirect3DVertexBuffer_Unlock(dst_vb);
-    ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#lx.\n", hr);
 
     vp2.dwSize = sizeof(vp2);
     vp2.dwX = 30;
@@ -881,13 +881,13 @@ static void test_process_vertices(void)
     vp2.dvMinZ = 3.0f;
     vp2.dvMaxZ = -2.0f;
     hr = IDirect3DViewport3_SetViewport2(viewport, &vp2);
-    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 0, 3, src_vb, 0, device, 0);
-    ok(SUCCEEDED(hr), "Failed to process vertices, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to process vertices, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_Lock(dst_vb, DDLOCK_READONLY, (void **)&dst_data, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#lx.\n", hr);
     ok(compare_vec4(&dst_data[0], +7.500e+1f, +4.000e+1f, -8.000e-1f, +1.000e+0f, 4096),
             "Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
@@ -898,7 +898,7 @@ static void test_process_vertices(void)
             "Got unexpected vertex 2 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[2].x, dst_data[2].y, dst_data[2].z, dst_data[2].w);
     hr = IDirect3DVertexBuffer_Unlock(dst_vb);
-    ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#lx.\n", hr);
 
     vp1.dwSize = sizeof(vp1);
     vp1.dwX = 30;
@@ -912,13 +912,13 @@ static void test_process_vertices(void)
     vp1.dvMinZ = -2.0f;
     vp1.dvMaxZ = 3.0f;
     hr = IDirect3DViewport3_SetViewport(viewport, &vp1);
-    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 0, 3, src_vb, 0, device, 0);
-    ok(SUCCEEDED(hr), "Failed to process vertices, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to process vertices, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_Lock(dst_vb, DDLOCK_READONLY, (void **)&dst_data, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock destination vertex buffer, hr %#lx.\n", hr);
     ok(compare_vec4(&dst_data[0], +1.100e+2f, +6.800e+1f, +7.000e+0f, +1.000e+0f, 4096),
             "Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
@@ -929,10 +929,10 @@ static void test_process_vertices(void)
             "Got unexpected vertex 2 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[2].x, dst_data[2].y, dst_data[2].z, dst_data[2].w);
     hr = IDirect3DVertexBuffer_Unlock(dst_vb);
-    ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock destination vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_DeleteViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to delete viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to delete viewport, hr %#lx.\n", hr);
 
     IDirect3DVertexBuffer_Release(dst_vb);
     IDirect3DVertexBuffer_Release(src_vb);
@@ -953,23 +953,23 @@ static void test_coop_level_create_device_window(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
 
@@ -983,48 +983,48 @@ static void test_coop_level_create_device_window(void)
     }
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
             | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOHWND, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!!device_window, "Device window not found.\n");
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
             | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!!device_window, "Device window not found.\n");
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!!device_window, "Device window not found.\n");
 
@@ -1098,22 +1098,22 @@ static void test_clipper_blt(void)
     ok(ret, "Failed to map client rect.\n");
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     hr = IDirectDraw4_CreateClipper(ddraw, 0, &clipper, NULL);
-    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
-    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#lx.\n", hr);
     rgn_data = HeapAlloc(GetProcessHeap(), 0, ret);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, rgn_data, &ret);
-    ok(SUCCEEDED(hr), "Failed to get clip list, hr %#x.\n", hr);
-    ok(rgn_data->rdh.dwSize == sizeof(rgn_data->rdh), "Got unexpected structure size %#x.\n", rgn_data->rdh.dwSize);
-    ok(rgn_data->rdh.iType == RDH_RECTANGLES, "Got unexpected type %#x.\n", rgn_data->rdh.iType);
-    ok(rgn_data->rdh.nCount >= 1, "Got unexpected count %u.\n", rgn_data->rdh.nCount);
+    ok(SUCCEEDED(hr), "Failed to get clip list, hr %#lx.\n", hr);
+    ok(rgn_data->rdh.dwSize == sizeof(rgn_data->rdh), "Got unexpected structure size %#lx.\n", rgn_data->rdh.dwSize);
+    ok(rgn_data->rdh.iType == RDH_RECTANGLES, "Got unexpected type %#lx.\n", rgn_data->rdh.iType);
+    ok(rgn_data->rdh.nCount >= 1, "Got unexpected count %lu.\n", rgn_data->rdh.nCount);
     ok(EqualRect(&rgn_data->rdh.rcBound, &client_rect),
             "Got unexpected bounding rect %s, expected %s.\n",
             wine_dbgstr_rect(&rgn_data->rdh.rcBound), wine_dbgstr_rect(&client_rect));
@@ -1133,11 +1133,11 @@ static void test_clipper_blt(void)
     DeleteObject(r1);
 
     hr = IDirectDrawClipper_SetClipList(clipper, rgn_data, 0);
-    ok(hr == DDERR_CLIPPERISUSINGHWND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CLIPPERISUSINGHWND, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetHWnd(clipper, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetClipList(clipper, rgn_data, 0);
-    ok(SUCCEEDED(hr), "Failed to set clip list, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clip list, hr %#lx.\n", hr);
 
     HeapFree(GetProcessHeap(), 0, rgn_data);
 
@@ -1155,33 +1155,33 @@ static void test_clipper_blt(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#lx.\n", hr);
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &dst_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     hr = IDirectDrawSurface4_Blt(src_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Lock(src_surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#x.\n", hr);
-    ok(U1(surface_desc).lPitch == 2560, "Got unexpected surface pitch %u.\n", U1(surface_desc).lPitch);
+    ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#lx.\n", hr);
+    ok(U1(surface_desc).lPitch == 2560, "Got unexpected surface pitch %lu.\n", U1(surface_desc).lPitch);
     ptr = surface_desc.lpSurface;
     memcpy(&ptr[   0], &src_data[ 0], 6 * sizeof(DWORD));
     memcpy(&ptr[ 640], &src_data[ 6], 6 * sizeof(DWORD));
     memcpy(&ptr[1280], &src_data[12], 6 * sizeof(DWORD));
     hr = IDirectDrawSurface4_Unlock(src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_SetClipper(dst_surface, clipper);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
 
     SetRect(&src_rect, 1, 1, 5, 2);
     hr = IDirectDrawSurface4_Blt(dst_surface, NULL, src_surface, &src_rect, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
     for (i = 0; i < 4; ++i)
     {
         for (j = 0; j < 4; ++j)
@@ -1191,13 +1191,13 @@ static void test_clipper_blt(void)
             color = get_surface_color(dst_surface, x, y);
             ok(compare_color(color, expected1[i * 4 + j], 1)
                     || broken(compare_color(color, expected1_broken[i * 4 + j], 1)),
-                    "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected1[i * 4 + j], x, y, color);
+                    "Expected color 0x%08lx at %u,%u, got 0x%08lx.\n", expected1[i * 4 + j], x, y, color);
         }
     }
 
     U5(fx).dwFillColor = 0xff0000ff;
     hr = IDirectDrawSurface4_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#lx.\n", hr);
     for (i = 0; i < 4; ++i)
     {
         for (j = 0; j < 4; ++j)
@@ -1206,35 +1206,35 @@ static void test_clipper_blt(void)
             y = 60 * ((2 * i) + 1);
             color = get_surface_color(dst_surface, x, y);
             ok(compare_color(color, expected2[i * 4 + j], 1),
-                    "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
+                    "Expected color 0x%08lx at %u,%u, got 0x%08lx.\n", expected2[i * 4 + j], x, y, color);
         }
     }
 
     hr = IDirectDrawSurface4_BltFast(dst_surface, 0, 0, src_surface, NULL, DDBLTFAST_WAIT);
-    ok(hr == DDERR_BLTFASTCANTCLIP, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_BLTFASTCANTCLIP, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
-    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#lx.\n", hr);
     DestroyWindow(window);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetHWnd(clipper, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetClipList(clipper, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to set clip list, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clip list, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface4_Release(dst_surface);
     IDirectDrawSurface4_Release(src_surface);
     refcount = IDirectDrawClipper_Release(clipper);
-    ok(!refcount, "Clipper has %u references left.\n", refcount);
+    ok(!refcount, "Clipper has %lu references left.\n", refcount);
     IDirectDraw4_Release(ddraw);
 }
 
@@ -1276,29 +1276,29 @@ static void test_coop_level_d3d_state(void)
     viewport = create_viewport(device, 0, 0, 640, 480);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_DESTALPHA);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_ZENABLE, &value);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok(!!value, "Got unexpected z-enable state %#x.\n", value);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(!!value, "Got unexpected z-enable state %#lx.\n", value);
     hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, &value);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok(!value, "Got unexpected alpha blend enable state %#x.\n", value);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(!value, "Got unexpected alpha blend enable state %#lx.\n", value);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3D3_Release(d3d);
 
     if (ddraw_is_warp(ddraw))
@@ -1309,53 +1309,53 @@ static void test_coop_level_d3d_state(void)
     }
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(rt);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     memset(&lock, 0, sizeof(lock));
     lock.dwSize = sizeof(lock);
     lock.lpSurface = (void *)0xdeadbeef;
     hr = IDirectDrawSurface4_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     ok(lock.lpSurface == (void *)0xdeadbeef, "Got unexpected lock.lpSurface %p.\n", lock.lpSurface);
 
     hr = IDirectDraw4_RestoreAllSurfaces(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Unlock(rt, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(surface == rt, "Got unexpected surface %p.\n", surface);
     IDirectDrawSurface4_Release(surface);
     hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_ZENABLE, &value);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok(!!value, "Got unexpected z-enable state %#x.\n", value);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(!!value, "Got unexpected z-enable state %#lx.\n", value);
     hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, &value);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok(!!value, "Got unexpected alpha blend enable state %#x.\n", value);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(!!value, "Got unexpected alpha blend enable state %#lx.\n", value);
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ff00, 1.0f, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZ | D3DFVF_DIFFUSE, quad, ARRAY_SIZE(quad), 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
     ok(compare_color(color, 0x0000ff80, 1)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
 
 done:
     destroy_viewport(device, viewport);
@@ -1385,7 +1385,7 @@ static void test_surface_interface_mismatch(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -1395,10 +1395,10 @@ static void test_surface_interface_mismatch(void)
     surface_desc.dwHeight = 480;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3);
-    ok(SUCCEEDED(hr), "Failed to QI IDirectDrawSurface3, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to QI IDirectDrawSurface3, hr %#lx.\n", hr);
 
     if (FAILED(IDirectDraw4_QueryInterface(ddraw, &IID_IDirect3D3, (void **)&d3d)))
     {
@@ -1422,15 +1422,15 @@ static void test_surface_interface_mismatch(void)
     surface_desc.dwWidth = 640;
     surface_desc.dwHeight = 480;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &ds, NULL);
-    ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#lx.\n", hr);
     if (FAILED(hr))
         goto cleanup;
 
     /* Using a different surface interface version still works */
     hr = IDirectDrawSurface3_AddAttachedSurface(surface3, (IDirectDrawSurface3 *)ds);
-    ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
     refcount = IDirectDrawSurface4_Release(ds);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     if (FAILED(hr))
         goto cleanup;
 
@@ -1443,9 +1443,9 @@ static void test_surface_interface_mismatch(void)
     viewport = create_viewport(device, 0, 0, 640, 480);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     color = get_surface_color(surface, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
 cleanup:
     if (viewport)
@@ -1469,7 +1469,7 @@ static void test_coop_level_threaded(void)
     create_window_thread(&p);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, p.window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     destroy_window_thread(&p);
     IDirectDraw4_Release(ddraw);
@@ -1520,9 +1520,9 @@ static void test_depth_blit(const GUID *device_guid)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3D3_Release(d3d);
 
     ds1 = get_depth_stencil(device);
@@ -1532,7 +1532,7 @@ static void test_depth_blit(const GUID *device_guid)
     memset(&ddsd_existing, 0, sizeof(ddsd_existing));
     ddsd_existing.dwSize = sizeof(ddsd_existing);
     hr = IDirectDrawSurface4_GetSurfaceDesc(ds1, &ddsd_existing);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ddsd_new.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
     ddsd_new.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
     if (is_software_device_type(device_guid))
@@ -1541,70 +1541,70 @@ static void test_depth_blit(const GUID *device_guid)
     ddsd_new.dwHeight = ddsd_existing.dwHeight;
     U4(ddsd_new).ddpfPixelFormat = U4(ddsd_existing).ddpfPixelFormat;
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd_new, &ds2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create a surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create a surface, hr %#lx.\n", hr);
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd_new, &ds3, NULL);
-    ok(SUCCEEDED(hr), "Failed to create a surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create a surface, hr %#lx.\n", hr);
     IDirectDraw4_Release(ddraw);
 
     viewport = create_viewport(device, 0, 0, ddsd_existing.dwWidth, ddsd_existing.dwHeight);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable z testing, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable z testing, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZFUNC, D3DCMP_LESSEQUAL);
-    ok(SUCCEEDED(hr), "Failed to set the z function, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set the z function, hr %#lx.\n", hr);
 
     U1(d3drect).x1 = U2(d3drect).y1 = 0;
     U3(d3drect).x2 = ddsd_existing.dwWidth; U4(d3drect).y2 = ddsd_existing.dwHeight;
     hr = IDirect3DViewport3_Clear2(viewport, 1, &d3drect, D3DCLEAR_ZBUFFER, 0, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear the z buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear the z buffer, hr %#lx.\n", hr);
 
     /* Partial blit. */
     SetRect(&src_rect, 0, 0, 320, 240);
     SetRect(&dst_rect, 0, 0, 320, 240);
     hr = IDirectDrawSurface4_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* Different locations. */
     SetRect(&src_rect, 0, 0, 320, 240);
     SetRect(&dst_rect, 320, 240, 640, 480);
     hr = IDirectDrawSurface4_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* Stretched. */
     SetRect(&src_rect, 0, 0, 320, 240);
     SetRect(&dst_rect, 0, 0, 640, 480);
     hr = IDirectDrawSurface4_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* Flipped. */
     SetRect(&src_rect, 0, 480, 640, 0);
     SetRect(&dst_rect, 0, 0, 640, 480);
     hr = IDirectDrawSurface4_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     SetRect(&src_rect, 0, 0, 640, 480);
     SetRect(&dst_rect, 0, 480, 640, 0);
     hr = IDirectDrawSurface4_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     /* Full, explicit. */
     SetRect(&src_rect, 0, 0, 640, 480);
     SetRect(&dst_rect, 0, 0, 640, 480);
     hr = IDirectDrawSurface4_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* Depth -> color blit: Succeeds on Win7 + Radeon HD 5700, fails on WinXP + Radeon X1600 */
 
     /* Depth blit inside a BeginScene / EndScene pair */
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to start a scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to start a scene, hr %#lx.\n", hr);
     /* From the current depth stencil */
     hr = IDirectDrawSurface4_Blt(ds2, NULL, ds1, NULL, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* To the current depth stencil */
     hr = IDirectDrawSurface4_Blt(ds1, NULL, ds2, NULL, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* Between unbound surfaces */
     hr = IDirectDrawSurface4_Blt(ds3, NULL, ds2, NULL, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end a scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end a scene, hr %#lx.\n", hr);
 
     /* Avoid changing the depth stencil, it doesn't work properly on Windows.
      * Instead use DDBLT_DEPTHFILL to clear the depth stencil. Unfortunately
@@ -1613,40 +1613,40 @@ static void test_depth_blit(const GUID *device_guid)
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     hr = IDirectDrawSurface4_Blt(ds2, NULL, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &d3drect, D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET, 0xffff0000, 1.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 80, 60);
     /* For some reason clears and colour fill blits randomly fail with software render target. */
     ok(color == 0x00ff0000 || broken(is_software_device_type(device_guid) && !color),
-            "Got unexpected colour 0x%08x.\n", color);
+            "Got unexpected colour 0x%08lx.\n", color);
     if (!color)
     {
         fill_surface(rt, 0xffff0000);
 
         color = get_surface_color(rt, 80, 60);
-        ok(color == 0x00ff0000, "Got unexpected colour 0x%08x.\n", color);
+        ok(color == 0x00ff0000, "Got unexpected colour 0x%08lx.\n", color);
     }
 
     SetRect(&dst_rect, 0, 0, 320, 240);
     hr = IDirectDrawSurface4_Blt(ds1, &dst_rect, ds2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface4_Release(ds3);
     IDirectDrawSurface4_Release(ds2);
     IDirectDrawSurface4_Release(ds1);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             quad1, 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < 4; ++i)
     {
@@ -1656,7 +1656,7 @@ static void test_depth_blit(const GUID *device_guid)
             unsigned int y = 60 * ((2 * i) + 1);
             color = get_surface_color(rt, x, y);
             ok(compare_color(color, expected_colors[i][j], 1),
-                    "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected_colors[i][j], x, y, color);
+                    "Expected color 0x%08lx at %u,%u, got 0x%08lx.\n", expected_colors[i][j], x, y, color);
         }
     }
     IDirectDrawSurface4_Release(rt);
@@ -1680,7 +1680,7 @@ static void test_texture_load_ckey(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -1689,13 +1689,13 @@ static void test_texture_load_ckey(void)
     ddsd.dwWidth = 128;
     ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &src, NULL);
-    ok(SUCCEEDED(hr), "Failed to create source texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create source texture, hr %#lx.\n", hr);
     ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to create destination texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create destination texture, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_QueryInterface(src, &IID_IDirect3DTexture2, (void **)&src_tex);
-    ok(SUCCEEDED(hr) || hr == E_NOINTERFACE, "Failed to get Direct3DTexture2 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || hr == E_NOINTERFACE, "Failed to get Direct3DTexture2 interface, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
         /* 64 bit ddraw does not support d3d */
@@ -1706,50 +1706,50 @@ static void test_texture_load_ckey(void)
         return;
     }
     hr = IDirectDrawSurface4_QueryInterface(dst, &IID_IDirect3DTexture2, (void **)&dst_tex);
-    ok(SUCCEEDED(hr), "Failed to get Direct3DTexture2 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3DTexture2 interface, hr %#lx.\n", hr);
 
     /* No surface has a color key */
     hr = IDirect3DTexture2_Load(dst_tex, src_tex);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0xdeadbeef;
     hr = IDirectDrawSurface4_GetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
-    ok(ckey.dwColorSpaceLowValue == 0xdeadbeef, "dwColorSpaceLowValue is %#x.\n", ckey.dwColorSpaceLowValue);
-    ok(ckey.dwColorSpaceHighValue == 0xdeadbeef, "dwColorSpaceHighValue is %#x.\n", ckey.dwColorSpaceHighValue);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
+    ok(ckey.dwColorSpaceLowValue == 0xdeadbeef, "dwColorSpaceLowValue is %#lx.\n", ckey.dwColorSpaceLowValue);
+    ok(ckey.dwColorSpaceHighValue == 0xdeadbeef, "dwColorSpaceHighValue is %#lx.\n", ckey.dwColorSpaceHighValue);
 
     /* Source surface has a color key */
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface4_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirect3DTexture2_Load(dst_tex, src_tex);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
-    ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#x.\n", ckey.dwColorSpaceLowValue);
-    ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
+    ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#lx.\n", ckey.dwColorSpaceLowValue);
+    ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#lx.\n", ckey.dwColorSpaceHighValue);
 
     /* Both surfaces have a color key: Dest ckey is overwritten */
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0x000000ff;
     hr = IDirectDrawSurface4_SetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirect3DTexture2_Load(dst_tex, src_tex);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
-    ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#x.\n", ckey.dwColorSpaceLowValue);
-    ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
+    ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#lx.\n", ckey.dwColorSpaceLowValue);
+    ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#lx.\n", ckey.dwColorSpaceHighValue);
 
     /* Only the destination has a color key: It is not deleted */
     hr = IDirectDrawSurface4_SetColorKey(src, DDCKEY_SRCBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DTexture2_Load(dst_tex, src_tex);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
-    ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#x.\n", ckey.dwColorSpaceLowValue);
-    ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
+    ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#lx.\n", ckey.dwColorSpaceLowValue);
+    ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#lx.\n", ckey.dwColorSpaceHighValue);
 
     IDirect3DTexture2_Release(dst_tex);
     IDirect3DTexture2_Release(src_tex);
@@ -1802,109 +1802,109 @@ static void test_viewport_object(void)
         return;
     }
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     old_d3d_ref = get_refcount((IUnknown *) d3d);
 
     hr = IDirect3D3_CreateViewport(d3d, &viewport3, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *)viewport3);
-    ok(ref == 1, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 1, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount((IUnknown *)d3d);
-    ok(ref == old_d3d_ref, "Got unexpected refcount %u.\n", ref);
+    ok(ref == old_d3d_ref, "Got unexpected refcount %lu.\n", ref);
 
     memset(&desc, 0, sizeof(desc));
     hr = IDirect3DViewport3_GetViewport(viewport3, &desc.vp1);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     desc.vp1.dwSize = sizeof(desc.vp1) + 1;
     hr = IDirect3DViewport3_GetViewport(viewport3, &desc.vp1);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     desc.vp1.dwSize = sizeof(desc.vp1) - 1;
     hr = IDirect3DViewport3_GetViewport(viewport3, &desc.vp1);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     desc.vp1.dwSize = sizeof(desc.vp1);
     hr = IDirect3DViewport3_GetViewport(viewport3, &desc.vp1);
-    ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
-    ok(desc.vp1.dwSize == sizeof(desc.vp1), "Got unexpected dwSize %u.\n", desc.vp1.dwSize);
+    ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#lx.\n", hr);
+    ok(desc.vp1.dwSize == sizeof(desc.vp1), "Got unexpected dwSize %lu.\n", desc.vp1.dwSize);
     hr = IDirect3DViewport3_GetViewport2(viewport3, &desc.vp2);
-    ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
-    ok(desc.vp2.dwSize == sizeof(desc.vp2), "Got unexpected dwSize %u.\n", desc.vp2.dwSize);
+    ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#lx.\n", hr);
+    ok(desc.vp2.dwSize == sizeof(desc.vp2), "Got unexpected dwSize %lu.\n", desc.vp2.dwSize);
     desc.vp2.dwSize = sizeof(desc.vp2) + 1;
     hr = IDirect3DViewport3_GetViewport2(viewport3, &desc.vp2);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     gamma = (IDirectDrawGammaControl *)0xdeadbeef;
     hr = IDirect3DViewport2_QueryInterface(viewport3, &IID_IDirectDrawGammaControl, (void **)&gamma);
-    ok(hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
     ok(!gamma, "Interface not set to NULL by failed QI call: %p.\n", gamma);
     /* NULL iid: Segfaults */
 
     hr = IDirect3DViewport3_QueryInterface(viewport3, &IID_IDirect3DViewport, (void **)&viewport);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *)viewport);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount((IUnknown *)viewport3);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
     IDirect3DViewport_Release(viewport);
     viewport = NULL;
 
     hr = IDirect3DViewport3_QueryInterface(viewport3, &IID_IDirect3DViewport3, (void **)&viewport2);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *)viewport2);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount((IUnknown *)viewport3);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
     IDirect3DViewport3_Release(viewport2);
 
     hr = IDirect3DViewport3_QueryInterface(viewport3, &IID_IUnknown, (void **)&unknown);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *)viewport3);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount(unknown);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
     IUnknown_Release(unknown);
 
     hr = IDirect3DDevice3_DeleteViewport(device, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_GetCurrentViewport(device, NULL);
-    ok(hr == D3DERR_NOCURRENTVIEWPORT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOCURRENTVIEWPORT, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3D3_CreateViewport(d3d, &another_vp, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Setting a viewport not in the viewport list fails */
     hr = IDirect3DDevice3_SetCurrentViewport(device, another_vp);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* AddViewport(NULL): Segfault */
     hr = IDirect3DDevice3_AddViewport(device, viewport3);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *) viewport3);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
     hr = IDirect3DDevice3_AddViewport(device, another_vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *) another_vp);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
 
     test_vp = (IDirect3DViewport3 *) 0xbaadc0de;
     hr = IDirect3DDevice3_GetCurrentViewport(device, &test_vp);
-    ok(hr == D3DERR_NOCURRENTVIEWPORT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOCURRENTVIEWPORT, "Got unexpected hr %#lx.\n", hr);
     ok(test_vp == (IDirect3DViewport3 *) 0xbaadc0de, "Got unexpected pointer %p.\n", test_vp);
 
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport3);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *) viewport3);
-    ok(ref == 3, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 3, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount((IUnknown *) device);
-    ok(ref == 1, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 1, "Got unexpected refcount %lu.\n", ref);
 
     test_vp = NULL;
     hr = IDirect3DDevice3_GetCurrentViewport(device, &test_vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(test_vp == viewport3, "Got unexpected viewport %p.\n", test_vp);
     ref = get_refcount((IUnknown *) viewport3);
-    ok(ref == 4, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 4, "Got unexpected refcount %lu.\n", ref);
     if (test_vp)
         IDirect3DViewport3_Release(test_vp);
 
@@ -1912,42 +1912,42 @@ static void test_viewport_object(void)
 
     /* Cannot set the viewport to NULL */
     hr = IDirect3DDevice3_SetCurrentViewport(device, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     test_vp = NULL;
     hr = IDirect3DDevice3_GetCurrentViewport(device, &test_vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(test_vp == viewport3, "Got unexpected viewport %p.\n", test_vp);
     if (test_vp)
         IDirect3DViewport3_Release(test_vp);
 
     /* SetCurrentViewport properly releases the old viewport's reference */
     hr = IDirect3DDevice3_SetCurrentViewport(device, another_vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *) viewport3);
-    ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 2, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount((IUnknown *) another_vp);
-    ok(ref == 3, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 3, "Got unexpected refcount %lu.\n", ref);
 
     /* Unlike device2::DeleteViewport, device3::DeleteViewport releases the
      * reference held by SetCurrentViewport */
     hr = IDirect3DDevice3_DeleteViewport(device, another_vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *) another_vp);
-    ok(ref == 1, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 1, "Got unexpected refcount %lu.\n", ref);
 
     /* GetCurrentViewport still fails */
     test_vp = NULL;
     hr = IDirect3DDevice3_GetCurrentViewport(device, &test_vp);
-    ok(hr == D3DERR_NOCURRENTVIEWPORT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_NOCURRENTVIEWPORT, "Got unexpected hr %#lx.\n", hr);
     ok(!test_vp, "Got unexpected viewport %p.\n", test_vp);
 
     /* Setting a different viewport doesn't have any surprises now */
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport3);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ref = get_refcount((IUnknown *) viewport3);
-    ok(ref == 3, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 3, "Got unexpected refcount %lu.\n", ref);
     ref = get_refcount((IUnknown *) another_vp);
-    ok(ref == 1, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 1, "Got unexpected refcount %lu.\n", ref);
 
     memset(&vp, 0, sizeof(vp));
     memset(&vp, 0, sizeof(vp2));
@@ -1967,16 +1967,16 @@ static void test_viewport_object(void)
     vp2.dvClipWidth = 2.0f;
     vp2.dvClipHeight = 2.0f;
     hr = IDirect3DViewport3_SetViewport(viewport3, &vp);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport3_SetViewport2(viewport3, &vp2);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     vp.dwSize = sizeof(vp);
     hr = IDirect3DViewport3_SetViewport(viewport3, &vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     vp2.dwSize = sizeof(vp2);
     hr = IDirect3DViewport3_SetViewport2(viewport3, &vp2);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     vp2.dwSize = sizeof(vp2);
     vp2.dwX = 160;
@@ -1990,12 +1990,12 @@ static void test_viewport_object(void)
     vp2.dvMinZ = 0.5f;
     vp2.dvMaxZ = 2.0f;
     hr = IDirect3DViewport3_SetViewport2(viewport3, &vp2);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vp, 0xff, sizeof(vp));
     vp.dwSize = sizeof(vp);
     hr = IDirect3DViewport3_GetViewport(viewport3, &vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(vp.dvMaxX == 4.5f && vp.dvMaxY == -1.75f && vp.dvScaleX == 192.0f
             && vp.dvScaleY == -240.0f && vp.dvMinZ == 0.0f && vp.dvMaxZ == 1.0f,
             "Got unexpected values %g, %g, %g, %g, %g, %g.\n",
@@ -2009,12 +2009,12 @@ static void test_viewport_object(void)
     vp2.dvMaxZ = 0.5f;
 
     hr = IDirect3DViewport3_SetViewport2(viewport3, &vp2);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vp, 0xff, sizeof(vp));
     vp.dwSize = sizeof(vp);
     hr = IDirect3DViewport3_GetViewport(viewport3, &vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(vp.dvMaxX == -3.0f && vp.dvMaxY == 1.75f && vp.dvScaleX == -320.0f
             && vp.dvScaleY == 180.0f && vp.dvMinZ == 0.0f && vp.dvMaxZ == 1.0f,
             "Got unexpected values %g, %g, %g, %g, %g, %g.\n",
@@ -2024,12 +2024,12 @@ static void test_viewport_object(void)
     vp.dvMinZ = 0.5f;
     vp.dvMaxZ = 2.0f;
     hr = IDirect3DViewport3_SetViewport(viewport3, &vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vp2, 0xff, sizeof(vp2));
     vp2.dwSize = sizeof(vp2);
     hr = IDirect3DViewport3_GetViewport2(viewport3, &vp2);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(vp2.dvClipX == 0.75f && vp2.dvClipY == 1.0f && vp2.dvClipWidth == -1.5f
             && vp2.dvClipHeight == 2.0f && vp2.dvMinZ == 0.0f && vp2.dvMaxZ == 1.0f,
             "Got unexpected values %g, %g, %g, %g, %g, %g.\n",
@@ -2043,12 +2043,12 @@ static void test_viewport_object(void)
     vp.dvMaxZ = 0.5f;
 
     hr = IDirect3DViewport3_SetViewport(viewport3, &vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vp2, 0xff, sizeof(vp2));
     vp2.dwSize = sizeof(vp2);
     hr = IDirect3DViewport3_GetViewport2(viewport3, &vp2);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(vp2.dvClipX == -1.25f && vp2.dvClipY == -0.75f && vp2.dvClipWidth == 2.5f
             && vp2.dvClipHeight == -1.5f && vp2.dvMinZ == 0.0f && vp2.dvMaxZ == 1.0f,
             "Got unexpected values %g, %g, %g, %g, %g, %g.\n",
@@ -2057,12 +2057,12 @@ static void test_viewport_object(void)
     /* Destroying the device removes the viewport and releases the reference */
     IDirect3DDevice3_Release(device);
     ref = get_refcount((IUnknown *) viewport3);
-    ok(ref == 1, "Got unexpected refcount %u.\n", ref);
+    ok(ref == 1, "Got unexpected refcount %lu.\n", ref);
 
     memset(&vp2, 0xff, sizeof(vp2));
     vp2.dwSize = sizeof(vp2);
     hr = IDirect3DViewport3_GetViewport2(viewport3, &vp2);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(vp2.dvClipX == -1.25f && vp2.dvClipY == -0.75f && vp2.dvClipWidth == 2.5f
             && vp2.dvClipHeight == -1.5f && vp2.dvMinZ == 0.0f && vp2.dvMaxZ == 1.0f,
             "Got unexpected values %g, %g, %g, %g, %g, %g.\n",
@@ -2070,15 +2070,15 @@ static void test_viewport_object(void)
 
     vp.dwSize = sizeof(vp);
     hr = IDirect3DViewport3_SetViewport(viewport3, &vp);
-    ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#lx.\n", hr);
     vp2.dwSize = sizeof(vp2);
     hr = IDirect3DViewport3_SetViewport2(viewport3, &vp2);
-    ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#lx.\n", hr);
 
     ref = IDirect3DViewport3_Release(another_vp);
-    ok(!ref, "Got unexpected refcount %u.\n", ref);
+    ok(!ref, "Got unexpected refcount %lu.\n", ref);
     ref = IDirect3DViewport3_Release(viewport3);
-    ok(!ref, "Got unexpected refcount %u.\n", ref);
+    ok(!ref, "Got unexpected refcount %lu.\n", ref);
     IDirect3D3_Release(d3d);
     DestroyWindow(window);
     IDirectDraw4_Release(ddraw);
@@ -2118,35 +2118,35 @@ static void test_zenable(const GUID *device_guid)
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 80, 60);
     /* For some reason clears and colour fill blits randomly fail with software render target. */
     ok(color == 0x00ff0000 || broken(is_software_device_type(device_guid) && !color),
-            "Got unexpected colour 0x%08x.\n", color);
+            "Got unexpected colour 0x%08lx.\n", color);
     if (!color)
     {
         fill_surface(rt, 0xffff0000);
 
         color = get_surface_color(rt, 80, 60);
-        ok(color == 0x00ff0000, "Got unexpected colour 0x%08x.\n", color);
+        ok(color == 0x00ff0000, "Got unexpected colour 0x%08lx.\n", color);
     }
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_DIFFUSE, tquad, 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < 4; ++i)
     {
@@ -2156,7 +2156,7 @@ static void test_zenable(const GUID *device_guid)
             y = 60 * ((2 * i) + 1);
             color = get_surface_color(rt, x, y);
             ok(compare_color(color, 0x0000ff00, 1),
-                    "Expected color 0x0000ff00 at %u, %u, got 0x%08x.\n", x, y, color);
+                    "Expected color 0x0000ff00 at %u, %u, got 0x%08lx.\n", x, y, color);
         }
     }
     IDirectDrawSurface4_Release(rt);
@@ -2231,12 +2231,12 @@ static void test_ck_rgba(const GUID *device_guid)
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3D3_Release(d3d);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -2257,66 +2257,66 @@ static void test_ck_rgba(const GUID *device_guid)
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0xff00ff00;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0xff00ff00;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetTexture(device, 0, texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, tests[i].color_key);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, tests[i].blend);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         memset(&fx, 0, sizeof(fx));
         fx.dwSize = sizeof(fx);
         U5(fx).dwFillColor = tests[i].fill_color;
         hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect,
                 D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 1.0f, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         if (is_software_device_type(device_guid))
             fill_surface(rt, 0xffff0000);
         hr = IDirect3DDevice3_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_TEX1, &tquad[0], 4, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice3_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, tests[i].result1, 2) || compare_color(color, tests[i].result1_broken, 1),
-                "Expected color 0x%08x for test %u, got 0x%08x.\n",
+                "Expected color 0x%08lx for test %u, got 0x%08lx.\n",
                 tests[i].result1, i, color);
 
         U5(fx).dwFillColor = 0xff0000ff;
         hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice3_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_TEX1, &tquad[4], 4, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice3_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         /* This tests that fragments that are masked out by the color key are
          * discarded, instead of just fully transparent. */
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, tests[i].result2, 2) || compare_color(color, tests[i].result2_broken, 1),
-                "Expected color 0x%08x for test %u, got 0x%08x.\n",
+                "Expected color 0x%08lx for test %u, got 0x%08lx.\n",
                 tests[i].result2, i, color);
     }
 
@@ -2366,17 +2366,17 @@ static void test_ck_default(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
     IDirect3D3_Release(d3d);
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -2393,47 +2393,47 @@ static void test_ck_default(void)
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x000000ff;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x000000ff;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTexture(device, 0, texture);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 0x000000ff;
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xff00ff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, &value);
-    ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
-    ok(!value, "Got unexpected color keying state %#x.\n", value);
+    ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
+    ok(!value, "Got unexpected color keying state %#lx.\n", value);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_TEX1, &tquad[0], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xff00ff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable color keying, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable color keying, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_TEX1, &tquad[0], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, &value);
-    ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
-    ok(!!value, "Got unexpected color keying state %#x.\n", value);
+    ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
+    ok(!!value, "Got unexpected color keying state %#lx.\n", value);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirect3DTexture_Release(texture);
     IDirectDrawSurface4_Release(surface);
@@ -2466,9 +2466,9 @@ static void test_ck_complex(void)
         return;
     }
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
     IDirect3D3_Release(d3d);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -2478,20 +2478,20 @@ static void test_ck_complex(void)
     surface_desc.dwWidth = 128;
     surface_desc.dwHeight = 128;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
     color_key.dwColorSpaceLowValue = 0x0000ff00;
     color_key.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface4_SetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     memset(&color_key, 0, sizeof(color_key));
     hr = IDirectDrawSurface4_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceLowValue);
-    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceHighValue);
 
     mipmap = surface;
@@ -2499,20 +2499,20 @@ static void test_ck_complex(void)
     for (i = 0; i < 7; ++i)
     {
         hr = IDirectDrawSurface4_GetAttachedSurface(mipmap, &caps, &tmp);
-        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#lx.\n", i, hr);
 
         hr = IDirectDrawSurface4_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-        ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x, i %u.\n", hr, i);
+        ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx, i %u.\n", hr, i);
         color_key.dwColorSpaceLowValue = 0x000000ff;
         color_key.dwColorSpaceHighValue = 0x000000ff;
         hr = IDirectDrawSurface4_SetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-        ok(SUCCEEDED(hr), "Failed to set color key, hr %#x, i %u.\n", hr, i);
+        ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx, i %u.\n", hr, i);
         memset(&color_key, 0, sizeof(color_key));
         hr = IDirectDrawSurface4_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-        ok(SUCCEEDED(hr), "Failed to get color key, hr %#x, i %u.\n", hr, i);
-        ok(color_key.dwColorSpaceLowValue == 0x000000ff, "Got unexpected value 0x%08x, i %u.\n",
+        ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx, i %u.\n", hr, i);
+        ok(color_key.dwColorSpaceLowValue == 0x000000ff, "Got unexpected value 0x%08lx, i %u.\n",
                 color_key.dwColorSpaceLowValue, i);
-        ok(color_key.dwColorSpaceHighValue == 0x000000ff, "Got unexpected value 0x%08x, i %u.\n",
+        ok(color_key.dwColorSpaceHighValue == 0x000000ff, "Got unexpected value 0x%08lx, i %u.\n",
                 color_key.dwColorSpaceHighValue, i);
 
         IDirectDrawSurface_Release(mipmap);
@@ -2521,17 +2521,17 @@ static void test_ck_complex(void)
 
     memset(&color_key, 0, sizeof(color_key));
     hr = IDirectDrawSurface4_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceLowValue);
-    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceHighValue);
 
     hr = IDirectDrawSurface4_GetAttachedSurface(mipmap, &caps, &tmp);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface_Release(mipmap);
     refcount = IDirectDrawSurface4_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -2539,46 +2539,46 @@ static void test_ck_complex(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     U5(surface_desc).dwBackBufferCount = 1;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
     color_key.dwColorSpaceLowValue = 0x0000ff00;
     color_key.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface4_SetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     memset(&color_key, 0, sizeof(color_key));
     hr = IDirectDrawSurface4_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceLowValue);
-    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceHighValue);
 
     hr = IDirectDrawSurface4_GetAttachedSurface(surface, &caps, &tmp);
-    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x, i %u.\n", hr, i);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx, i %u.\n", hr, i);
     color_key.dwColorSpaceLowValue = 0x0000ff00;
     color_key.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface4_SetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     memset(&color_key, 0, sizeof(color_key));
     hr = IDirectDrawSurface4_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceLowValue);
-    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceHighValue);
 
     IDirectDrawSurface_Release(tmp);
 
     refcount = IDirectDrawSurface4_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     IDirectDraw4_Release(ddraw);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -2600,13 +2600,13 @@ static void test_qi(const char *test_name, IUnknown *base_iface,
     for (i = 0; i < entry_count; ++i)
     {
         hr = IUnknown_QueryInterface(base_iface, tests[i].iid, (void **)&iface1);
-        ok(hr == tests[i].hr, "Got hr %#x for test \"%s\" %u.\n", hr, test_name, i);
+        ok(hr == tests[i].hr, "Got hr %#lx for test \"%s\" %u.\n", hr, test_name, i);
         if (SUCCEEDED(hr))
         {
             for (j = 0; j < entry_count; ++j)
             {
                 hr = IUnknown_QueryInterface(iface1, tests[j].iid, (void **)&iface2);
-                ok(hr == tests[j].hr, "Got hr %#x for test \"%s\" %u, %u.\n", hr, test_name, i, j);
+                ok(hr == tests[j].hr, "Got hr %#lx for test \"%s\" %u, %u.\n", hr, test_name, i, j);
                 if (SUCCEEDED(hr))
                 {
                     expected_refcount = 0;
@@ -2615,7 +2615,7 @@ static void test_qi(const char *test_name, IUnknown *base_iface,
                     if (IsEqualGUID(tests[i].refcount_iid, tests[j].refcount_iid))
                         ++expected_refcount;
                     refcount = IUnknown_Release(iface2);
-                    ok(refcount == expected_refcount, "Got refcount %u for test \"%s\" %u, %u, expected %u.\n",
+                    ok(refcount == expected_refcount, "Got refcount %lu for test \"%s\" %u, %u, expected %lu.\n",
                             refcount, test_name, i, j, expected_refcount);
                 }
             }
@@ -2624,7 +2624,7 @@ static void test_qi(const char *test_name, IUnknown *base_iface,
             if (IsEqualGUID(refcount_iid, tests[i].refcount_iid))
                 ++expected_refcount;
             refcount = IUnknown_Release(iface1);
-            ok(refcount == expected_refcount, "Got refcount %u for test \"%s\" %u, expected %u.\n",
+            ok(refcount == expected_refcount, "Got refcount %lu for test \"%s\" %u, expected %lu.\n",
                     refcount, test_name, i, expected_refcount);
         }
     }
@@ -2699,7 +2699,7 @@ static void test_surface_qi(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -2708,9 +2708,9 @@ static void test_surface_qi(void)
     surface_desc.dwWidth = 512;
     surface_desc.dwHeight = 512;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, (IDirectDrawSurface4 **)0xdeadbeef, NULL);
-    ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     test_qi("surface_qi", (IUnknown *)surface, &IID_IDirectDrawSurface4, tests, ARRAY_SIZE(tests));
 
@@ -2816,36 +2816,36 @@ static void test_wndproc(void)
             WS_MAXIMIZE | WS_CAPTION , 0, 0, 640, 480, 0, 0, 0, 0);
 
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     expect_messages = messages;
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     ref = IDirectDraw4_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     /* DDSCL_NORMAL doesn't. */
     ddraw = create_ddraw();
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     ref = IDirectDraw4_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     /* The original window proc is only restored by ddraw if the current
@@ -2853,53 +2853,53 @@ static void test_wndproc(void)
      * from DDSCL_NORMAL to DDSCL_EXCLUSIVE. */
     ddraw = create_ddraw();
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     ddraw_proc = proc;
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)DefWindowProcA, proc);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = SetWindowLongPtrA(window, GWLP_WNDPROC, ddraw_proc);
-    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)DefWindowProcA, proc);
     ref = IDirectDraw4_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     ddraw = create_ddraw();
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     ref = IDirectDraw4_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)DefWindowProcA, proc);
 
     fix_wndproc(window, (LONG_PTR)test_proc);
@@ -2930,12 +2930,12 @@ static void test_window_style(void)
     SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    todo_wine ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n",
@@ -2947,9 +2947,9 @@ static void test_window_style(void)
     ok(ret, "Failed to set foreground window.\n");
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    todo_wine ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
@@ -2958,77 +2958,77 @@ static void test_window_style(void)
     ShowWindow(window, SW_HIDE);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_NOWINDOWCHANGES);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    todo_wine ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ShowWindow(window, SW_HIDE);
     tmp = GetWindowLongA(window, GWL_STYLE);
-    todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    todo_wine ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_NOWINDOWCHANGES);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ShowWindow(window, SW_HIDE);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     ShowWindow(window, SW_SHOW);
     ret = SetForegroundWindow(GetDesktopWindow());
@@ -3036,20 +3036,20 @@ static void test_window_style(void)
     SetActiveWindow(window);
     ok(GetActiveWindow() == window, "Unexpected active window.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n",
             wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r));
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     SetWindowPos(window, NULL, 0, 0, 100, 100, SWP_NOZORDER | SWP_NOACTIVATE);
     GetWindowRect(window, &r);
@@ -3059,13 +3059,13 @@ static void test_window_style(void)
     ret = SetForegroundWindow(window2);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n",
@@ -3074,46 +3074,46 @@ static void test_window_style(void)
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ShowWindow(window, SW_HIDE);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     ShowWindow(window, SW_SHOW);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE | WS_MINIMIZE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ref = IDirectDraw4_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     DestroyWindow(window2);
     DestroyWindow(window);
@@ -3134,15 +3134,15 @@ static void test_redundant_mode_set(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw4_GetDisplayMode(ddraw, &surface_desc);
-    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw4_SetDisplayMode(ddraw, surface_desc.dwWidth, surface_desc.dwHeight,
             U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount, 0, 0);
-    ok(SUCCEEDED(hr), "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetDisplayMode failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &q);
     r = q;
@@ -3154,14 +3154,14 @@ static void test_redundant_mode_set(void)
 
     hr = IDirectDraw4_SetDisplayMode(ddraw, surface_desc.dwWidth, surface_desc.dwHeight,
             U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount, 0, 0);
-    ok(SUCCEEDED(hr), "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetDisplayMode failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &s);
     ok(EqualRect(&r, &s) || broken(EqualRect(&q, &s) /* Windows 10 */),
             "Expected %s, got %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&s));
 
     ref = IDirectDraw4_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     DestroyWindow(window);
 }
@@ -3311,10 +3311,10 @@ static void test_coop_level_mode_set(void)
     memset(&devmode, 0, sizeof(devmode));
     devmode.dmSize = sizeof(devmode);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
 
     ret = save_display_modes(&original_modes, &display_count);
@@ -3325,9 +3325,9 @@ static void test_coop_level_mode_set(void)
 
     memset(&param, 0, sizeof(param));
     hr = IDirectDraw4_EnumDisplayModes(ddraw, 0, NULL, &param, test_coop_level_mode_set_enum_cb);
-    ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#lx.\n", hr);
     ref = IDirectDraw4_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     if (!param.user32_height)
     {
@@ -3346,7 +3346,7 @@ static void test_coop_level_mode_set(void)
     devmode.dmPelsWidth = param.user32_width;
     devmode.dmPelsHeight = param.user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
@@ -3364,7 +3364,7 @@ static void test_coop_level_mode_set(void)
             0, 0, 100, 100, 0, 0, 0, 0);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &user32_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&user32_rect),
@@ -3376,12 +3376,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.user32_width, "Expected surface width %lu, got %lu.\n",
             param.user32_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.user32_height, "Expected surface height %lu, got %lu.\n",
             param.user32_height, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3394,16 +3394,16 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
-            "Expected screen size %ux%u, got %ux%u.\n",
+            "Expected screen size %lux%lu, got %lux%lu.\n",
             param.ddraw_width, param.ddraw_height, screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
@@ -3411,10 +3411,10 @@ static void test_coop_level_mode_set(void)
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.user32_width, "Expected surface width %lu, got %lu.\n",
             param.user32_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.user32_height, "Expected surface height %lu, got %lu.\n",
             param.user32_height, ddsd.dwHeight);
     IDirectDrawSurface4_Release(primary);
 
@@ -3424,12 +3424,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3442,16 +3442,16 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
-            "Expected screen size %ux%u, got %ux%u.\n",
+            "Expected screen size %lux%lu, got %lux%lu.\n",
             param.user32_width, param.user32_height, screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
@@ -3470,7 +3470,7 @@ static void test_coop_level_mode_set(void)
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
-            && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected screen size %ux%u.\n",
+            && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected screen size %lux%lu.\n",
             devmode.dmPelsWidth, devmode.dmPelsHeight);
 
     expect_messages = exclusive_focus_restore_messages;
@@ -3483,11 +3483,11 @@ static void test_coop_level_mode_set(void)
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == param.ddraw_width
-            && devmode.dmPelsHeight == param.ddraw_height, "Got unexpected screen size %ux%u.\n",
+            && devmode.dmPelsHeight == param.ddraw_height, "Got unexpected screen size %lux%lu.\n",
             devmode.dmPelsWidth, devmode.dmPelsHeight);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     /* Normally the primary should be restored here. Unfortunately this causes the
      * GetSurfaceDesc call after the next display mode change to crash on the Windows 8
      * testbot. Another Restore call would presumably avoid the crash, but it also moots
@@ -3509,7 +3509,7 @@ static void test_coop_level_mode_set(void)
     expect_messages = NULL;
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
     expect_messages = exclusive_messages;
@@ -3517,17 +3517,17 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     ok(screen_size.cx == registry_mode.dmPelsWidth
             && screen_size.cy == registry_mode.dmPelsHeight,
-            "Expected screen size %ux%u, got %ux%u.\n",
+            "Expected screen size %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
@@ -3535,16 +3535,16 @@ static void test_coop_level_mode_set(void)
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
     IDirectDrawSurface4_Release(primary);
 
     /* For Wine. */
     change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -3552,12 +3552,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3565,17 +3565,17 @@ static void test_coop_level_mode_set(void)
             wine_dbgstr_rect(&r));
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface4_Release(primary);
 
@@ -3585,12 +3585,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3603,18 +3603,18 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
     devmode.dmPelsWidth = param.user32_width;
     devmode.dmPelsHeight = param.user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
     hr = IDirectDrawSurface4_IsLost(primary);
-    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
@@ -3626,27 +3626,27 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface4_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface4_Release(primary);
 
@@ -3656,12 +3656,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3674,25 +3674,25 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
     IDirectDrawSurface4_Release(primary);
 
@@ -3700,11 +3700,11 @@ static void test_coop_level_mode_set(void)
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
             && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n",
+            "Expected resolution %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
             devmode.dmPelsWidth, devmode.dmPelsHeight);
     change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -3712,12 +3712,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3728,17 +3728,17 @@ static void test_coop_level_mode_set(void)
      * Resizing the window on mode changes is a property of DDSCL_EXCLUSIVE,
      * not DDSCL_FULLSCREEN. */
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface4_Release(primary);
 
@@ -3748,12 +3748,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3766,18 +3766,18 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
     devmode.dmPelsWidth = param.user32_width;
     devmode.dmPelsHeight = param.user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
     hr = IDirectDrawSurface4_IsLost(primary);
-    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
@@ -3789,27 +3789,27 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface4_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface4_Release(primary);
 
@@ -3819,12 +3819,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3837,25 +3837,25 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
     IDirectDrawSurface4_Release(primary);
 
@@ -3863,11 +3863,11 @@ static void test_coop_level_mode_set(void)
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
             && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n",
+            "Expected resolution %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
             devmode.dmPelsWidth, devmode.dmPelsHeight);
     change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -3875,12 +3875,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface4_Release(primary);
 
@@ -3890,9 +3890,9 @@ static void test_coop_level_mode_set(void)
 
     /* Changing the coop level from EXCLUSIVE to NORMAL restores the screen resolution */
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
     expect_messages = exclusive_messages;
@@ -3900,13 +3900,13 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     ok(screen_size.cx == registry_mode.dmPelsWidth
             && screen_size.cy == registry_mode.dmPelsHeight,
-            "Expected screen size %ux%u, got %ux%u.\n",
+            "Expected screen size %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
             screen_size.cx, screen_size.cy);
 
@@ -3920,23 +3920,23 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface4_Release(primary);
 
     /* The screen restore is a property of DDSCL_EXCLUSIVE  */
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -3944,23 +3944,23 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
     IDirectDrawSurface4_Release(primary);
 
     hr = IDirectDraw4_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     /* If the window is changed at the same time, messages are sent to the new window. */
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
     expect_messages = exclusive_messages;
@@ -3970,14 +3970,14 @@ static void test_coop_level_mode_set(void)
     screen_size2.cy = 0;
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n",
             screen_size.cx, screen_size.cy);
     ok(screen_size2.cx == registry_mode.dmPelsWidth && screen_size2.cy == registry_mode.dmPelsHeight,
-            "Expected screen size 2 %ux%u, got %ux%u.\n",
+            "Expected screen size 2 %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size2.cx, screen_size2.cy);
 
     GetWindowRect(window, &r);
@@ -3993,17 +3993,17 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface4_Release(primary);
 
     ref = IDirectDraw4_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &ddraw_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&ddraw_rect),
@@ -4017,36 +4017,36 @@ static void test_coop_level_mode_set(void)
     devmode.dmPelsWidth = param.user32_width;
     devmode.dmPelsHeight = param.user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     ref = IDirectDraw4_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     memset(&devmode2, 0, sizeof(devmode2));
     devmode2.dmSize = sizeof(devmode2);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &registry_mode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
 
     /* Test that no mode restorations if no mode changes happened with fullscreen ddraw objects */
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     ref = IDirectDraw4_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &registry_mode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -4056,19 +4056,19 @@ static void test_coop_level_mode_set(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     ref = IDirectDraw4_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -4077,23 +4077,23 @@ static void test_coop_level_mode_set(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     hr = IDirectDraw4_RestoreDisplayMode(ddraw);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
 
     ref = IDirectDraw4_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     expect_messages = NULL;
     DestroyWindow(window);
@@ -4121,10 +4121,10 @@ static void test_coop_level_mode_set_multi(void)
     memset(&devmode, 0, sizeof(devmode));
     devmode.dmSize = sizeof(devmode);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
 
     ret = save_display_modes(&original_modes, &display_count);
@@ -4138,14 +4138,14 @@ static void test_coop_level_mode_set_multi(void)
     /* With just a single ddraw object, the display mode is restored on
      * release. */
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 600, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw4_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -4155,7 +4155,7 @@ static void test_coop_level_mode_set_multi(void)
      * the initial mode, before the first SetDisplayMode() call. */
     ddraw1 = create_ddraw();
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -4163,21 +4163,21 @@ static void test_coop_level_mode_set_multi(void)
 
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw4_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw4_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -4186,7 +4186,7 @@ static void test_coop_level_mode_set_multi(void)
     /* Regardless of release ordering. */
     ddraw1 = create_ddraw();
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -4194,21 +4194,21 @@ static void test_coop_level_mode_set_multi(void)
 
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw4_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw4_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -4218,21 +4218,21 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw4_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw4_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -4242,7 +4242,7 @@ static void test_coop_level_mode_set_multi(void)
      * restoring the display mode. */
     ddraw1 = create_ddraw();
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -4250,24 +4250,24 @@ static void test_coop_level_mode_set_multi(void)
 
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw2, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     ref = IDirectDraw4_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw4_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -4276,28 +4276,28 @@ static void test_coop_level_mode_set_multi(void)
     /* Exclusive mode blocks mode setting on other ddraw objects in general. */
     ddraw1 = create_ddraw();
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 600, "Got unexpected screen height %u.\n", h);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw1, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
 
     ref = IDirectDraw4_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw4_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -4325,7 +4325,7 @@ static void test_coop_level_mode_set_multi(void)
     memset(&old_devmode, 0, sizeof(old_devmode));
     old_devmode.dmSize = sizeof(old_devmode);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &old_devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
 
     devmode = old_devmode;
     while (EnumDisplaySettingsW(second_monitor_name, mode_idx++, &devmode))
@@ -4342,32 +4342,32 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ok(!!ddraw1, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw1, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     memset(&devmode2, 0, sizeof(devmode2));
     devmode2.dmSize = sizeof(devmode2);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     if (compare_mode_rect(&devmode2, &old_devmode))
     {
         skip("Failed to change display settings of the second monitor.\n");
         ref = IDirectDraw4_Release(ddraw1);
-        ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+        ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
         goto done;
     }
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw1, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     ref = IDirectDraw4_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     memset(&devmode3, 0, sizeof(devmode3));
     devmode3.dmSize = sizeof(devmode3);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode3);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode3, &devmode2), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -4377,19 +4377,19 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ok(!!ddraw1, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     ref = IDirectDraw4_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -4398,23 +4398,23 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ok(!!ddraw1, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     hr = IDirectDraw4_RestoreDisplayMode(ddraw1);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
 
     ref = IDirectDraw4_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
 
@@ -4422,24 +4422,24 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ok(!!ddraw1, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL,
             CDS_UPDATEREGISTRY | CDS_NORESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     ref = IDirectDraw4_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
+            "Expected resolution %lux%lu, got %lux%lu.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
             devmode2.dmPelsWidth, devmode2.dmPelsHeight);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
+            "Expected resolution %lux%lu, got %lux%lu.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
             devmode2.dmPelsWidth, devmode2.dmPelsHeight);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -4451,27 +4451,27 @@ static void test_coop_level_mode_set_multi(void)
     ddraw2 = create_ddraw();
     ok(!!ddraw2, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     hr = IDirectDraw4_RestoreDisplayMode(ddraw2);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
 
     ref = IDirectDraw4_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     ref = IDirectDraw4_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
 
@@ -4482,25 +4482,25 @@ static void test_coop_level_mode_set_multi(void)
     ddraw2 = create_ddraw();
     ok(!!ddraw2, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     ref = IDirectDraw4_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
 
     ref = IDirectDraw4_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
 done:
     DestroyWindow(window);
@@ -4518,16 +4518,16 @@ static void test_initialize(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw4_Initialize(ddraw, NULL);
-    ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x.\n", hr);
+    ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#lx.\n", hr);
     IDirectDraw4_Release(ddraw);
 
     CoInitialize(NULL);
     hr = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to create IDirectDraw4 instance, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create IDirectDraw4 instance, hr %#lx.\n", hr);
     hr = IDirectDraw4_Initialize(ddraw, NULL);
-    ok(hr == DD_OK, "Initialize returned hr %#x, expected DD_OK.\n", hr);
+    ok(hr == DD_OK, "Initialize returned hr %#lx, expected DD_OK.\n", hr);
     hr = IDirectDraw4_Initialize(ddraw, NULL);
-    ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x, expected DDERR_ALREADYINITIALIZED.\n", hr);
+    ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#lx, expected DDERR_ALREADYINITIALIZED.\n", hr);
     IDirectDraw4_Release(ddraw);
     CoUninitialize();
 }
@@ -4548,20 +4548,20 @@ static void test_coop_level_surf_create(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     surface = (void *)0xdeadbeef;
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "Surface creation returned hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "Surface creation returned hr %#lx.\n", hr);
     ok(surface == (void *)0xdeadbeef, "Got unexpected surface %p.\n", surface);
 
     surface = (void *)0xdeadbeef;
     hr = IDirectDraw4_CreateSurface(ddraw, NULL, &surface, NULL);
-    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "Surface creation returned hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "Surface creation returned hr %#lx.\n", hr);
     ok(surface == (void *)0xdeadbeef, "Got unexpected surface %p.\n", surface);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     surface = (void *)0xdeadbeef;
     hr = IDirectDraw4_CreateSurface(ddraw, NULL, &surface, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Unexpected hr %#lx.\n", hr);
     ok(surface == (void *)0xdeadbeef, "Got unexpected surface %p.\n", surface);
 
     IDirectDraw4_Release(ddraw);
@@ -4596,7 +4596,7 @@ static void test_vb_discard(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
 
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
@@ -4604,29 +4604,29 @@ static void test_vb_discard(void)
     desc.dwFVF = D3DFVF_XYZRHW;
     desc.dwNumVertices = vbsize;
     hr = IDirect3D3_CreateVertexBuffer(d3d, &desc, &buffer, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_Lock(buffer, DDLOCK_DISCARDCONTENTS, (void **)&data, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     memcpy(data, quad, sizeof(quad));
     hr = IDirect3DVertexBuffer_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, buffer, 0, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_Lock(buffer, DDLOCK_DISCARDCONTENTS, (void **)&data, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     memset(data, 0xaa, sizeof(struct vec4) * vbsize);
     hr = IDirect3DVertexBuffer_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_Lock(buffer, DDLOCK_DISCARDCONTENTS, (void **)&data, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     for (i = 0; i < sizeof(struct vec4) * vbsize; i++)
     {
         if (data[i] != 0xaa)
@@ -4636,7 +4636,7 @@ static void test_vb_discard(void)
         }
     }
     hr = IDirect3DVertexBuffer_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     IDirect3DVertexBuffer_Release(buffer);
     IDirect3D3_Release(d3d);
@@ -4656,9 +4656,9 @@ static void test_coop_level_multi_window(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(IsWindow(window1), "Window 1 was destroyed.\n");
     ok(IsWindow(window2), "Window 2 was destroyed.\n");
 
@@ -4703,15 +4703,15 @@ static void test_draw_strided(void)
     }
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#lx.\n", hr);
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0x00000000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear the viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     memset(&strided, 0x55, sizeof(strided));
     strided.position.lpvData = position;
@@ -4720,13 +4720,13 @@ static void test_draw_strided(void)
     strided.diffuse.dwStride = sizeof(*diffuse);
     hr = IDirect3DDevice3_DrawIndexedPrimitiveStrided(device, D3DPT_TRIANGLELIST, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             &strided, 4, indices, 6, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirect3DViewport3_Release(viewport);
     IDirectDrawSurface4_Release(rt);
@@ -4876,153 +4876,153 @@ static void test_lighting(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_STENCILENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = fvf;
     vb_desc.dwNumVertices = 2;
     hr = IDirect3D3_CreateVertexBuffer(d3d, &vb_desc, &src_vb1, 0, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = nfvf;
     vb_desc.dwNumVertices = 2;
     hr = IDirect3D3_CreateVertexBuffer(d3d, &vb_desc, &src_vb2, 0, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR;
     vb_desc.dwNumVertices = 4;
     hr = IDirect3D3_CreateVertexBuffer(d3d, &vb_desc, &dst_vb, 0, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_Lock(src_vb1, 0, (void **)&src_data1, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(src_data1, unlitquad, sizeof(*src_data1));
     memcpy(&src_data1[1], litquad, sizeof(*src_data1));
     hr = IDirect3DVertexBuffer_Unlock(src_vb1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_Lock(src_vb2, 0, (void **)&src_data2, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(src_data2, unlitnquad, sizeof(*src_data2));
     memcpy(&src_data2[1], litnquad, sizeof(*src_data2));
     hr = IDirect3DVertexBuffer_Unlock(src_vb2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* There is no D3DRENDERSTATE_LIGHTING on ddraw < 7. */
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 0,
             1, src_vb1, 0, device, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, fvf, unlitquad, 4,
             indices, 6, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_LIGHTING, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 1,
             1, src_vb1, 1, device, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, fvf, litquad, 4,
             indices, 6, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 2,
             1, src_vb2, 0, device, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, unlitnquad, 4,
             indices, 6, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_LIGHTING, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 3,
             1, src_vb2, 1, device, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, litnquad, 4,
             indices, 6, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_Lock(dst_vb, 0, (void **)&dst_data, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 360);
-    ok(color == 0x00ff0000, "Unlit quad without normals has color 0x%08x.\n", color);
+    ok(color == 0x00ff0000, "Unlit quad without normals has color 0x%08lx.\n", color);
     ok(dst_data[0].diffuse == 0xffff0000,
-            "Unlit quad without normals has color 0x%08x, expected 0xffff0000.\n", dst_data[0].diffuse);
+            "Unlit quad without normals has color 0x%08lx, expected 0xffff0000.\n", dst_data[0].diffuse);
     ok(!dst_data[0].specular,
-            "Unexpected specular color 0x%08x.\n", dst_data[0].specular);
+            "Unexpected specular color 0x%08lx.\n", dst_data[0].specular);
 
     color = get_surface_color(rt, 160, 120);
-    ok(color == 0x0000ff00, "Lit quad without normals has color 0x%08x.\n", color);
+    ok(color == 0x0000ff00, "Lit quad without normals has color 0x%08lx.\n", color);
     ok(dst_data[1].diffuse == 0xff00ff00,
-            "Lit quad without normals has color 0x%08x, expected 0xff000000.\n", dst_data[1].diffuse);
+            "Lit quad without normals has color 0x%08lx, expected 0xff000000.\n", dst_data[1].diffuse);
     ok(!dst_data[1].specular,
-            "Unexpected specular color 0x%08x.\n", dst_data[1].specular);
+            "Unexpected specular color 0x%08lx.\n", dst_data[1].specular);
 
     color = get_surface_color(rt, 480, 360);
-    ok(color == 0x000000ff, "Unlit quad with normals has color 0x%08x.\n", color);
+    ok(color == 0x000000ff, "Unlit quad with normals has color 0x%08lx.\n", color);
     ok(dst_data[2].diffuse == 0xff0000ff,
-            "Unlit quad with normals has color 0x%08x, expected 0xff0000ff.\n", dst_data[2].diffuse);
+            "Unlit quad with normals has color 0x%08lx, expected 0xff0000ff.\n", dst_data[2].diffuse);
     ok(!dst_data[2].specular,
-            "Unexpected specular color 0x%08x.\n", dst_data[2].specular);
+            "Unexpected specular color 0x%08lx.\n", dst_data[2].specular);
 
     color = get_surface_color(rt, 480, 120);
-    ok(color == 0x00ffff00, "Lit quad with normals has color 0x%08x.\n", color);
+    ok(color == 0x00ffff00, "Lit quad with normals has color 0x%08lx.\n", color);
     ok(dst_data[3].diffuse == 0xffffff00,
-            "Lit quad with normals has color 0x%08x, expected 0xff000000.\n", dst_data[3].diffuse);
+            "Lit quad with normals has color 0x%08lx, expected 0xff000000.\n", dst_data[3].diffuse);
     ok(!dst_data[3].specular,
-            "Unexpected specular color 0x%08x.\n", dst_data[3].specular);
+            "Unexpected specular color 0x%08lx.\n", dst_data[3].specular);
 
     hr = IDirect3DVertexBuffer_Unlock(dst_vb);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     material = create_diffuse_and_ambient_material(device, 0.0f, 1.0f, 1.0f, 0.5f);
     hr = IDirect3DMaterial3_GetHandle(material, device, &mat_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetLightState(device, D3DLIGHTSTATE_MATERIAL, mat_handle);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetLightState(device, D3DLIGHTSTATE_AMBIENT, 0xff008000);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3D3_CreateLight(d3d, &light, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memset(&light_desc, 0, sizeof(light_desc));
     light_desc.dwSize = sizeof(light_desc);
     light_desc.dltType = D3DLIGHT_DIRECTIONAL;
@@ -5032,85 +5032,85 @@ static void test_lighting(void)
     U4(light_desc.dcvColor).a = 0.5f;
     U3(light_desc.dvDirection).z = 1.0f;
     hr = IDirect3DLight_SetLight(light, (D3DLIGHT *)&light_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport3_AddLight(viewport, light);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport3_AddLight(viewport, light);
-    ok(hr == D3DERR_LIGHTHASVIEWPORT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_LIGHTHASVIEWPORT, "Got unexpected hr %#lx.\n", hr);
 
     viewport2 = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DViewport3_AddLight(viewport2, light);
-    ok(hr == D3DERR_LIGHTHASVIEWPORT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_LIGHTHASVIEWPORT, "Got unexpected hr %#lx.\n", hr);
     IDirect3DViewport3_Release(viewport2);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, nquad,
             4, indices, 6, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 320, 240);
-    ok(color == 0x00008000, "Lit quad with no light has color 0x%08x.\n", color);
+    ok(color == 0x00008000, "Lit quad with no light has color 0x%08lx.\n", color);
 
     light_desc.dwFlags = D3DLIGHT_ACTIVE;
     hr = IDirect3DLight_SetLight(light, (D3DLIGHT *)&light_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport3_DeleteLight(viewport, light);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     light_desc.dwFlags = 0;
     hr = IDirect3DLight_GetLight(light, (D3DLIGHT *)&light_desc);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(light_desc.dwFlags == D3DLIGHT_ACTIVE, "Got unexpected flags %#x.\n", light_desc.dwFlags);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(light_desc.dwFlags == D3DLIGHT_ACTIVE, "Got unexpected flags %#lx.\n", light_desc.dwFlags);
 
     hr = IDirect3DViewport3_AddLight(viewport, light);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DVertexBuffer_Lock(src_vb2, 0, (void **)&src_data2, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         memcpy(src_data2, tests[i].quad, sizeof(*src_data2));
         hr = IDirect3DVertexBuffer_Unlock(src_vb2);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_WORLD, tests[i].world_matrix);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice3_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 0,
                 1, src_vb2, 0, device, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, tests[i].quad,
                 4, indices, 6, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice3_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DVertexBuffer_Lock(dst_vb, 0, (void **)&dst_data, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         color = get_surface_color(rt, 320, 240);
-        ok(color == tests[i].expected, "%s has color 0x%08x.\n", tests[i].message, color);
+        ok(color == tests[i].expected, "%s has color 0x%08lx.\n", tests[i].message, color);
         ok(dst_data[0].diffuse == (tests[i].expected | 0xff000000),
-                "%s has color 0x%08x.\n", tests[i].message, dst_data[0].diffuse);
+                "%s has color 0x%08lx.\n", tests[i].message, dst_data[0].diffuse);
         ok(!dst_data[0].specular,
-                "%s has specular color 0x%08x.\n", tests[i].message, dst_data[0].specular);
+                "%s has specular color 0x%08lx.\n", tests[i].message, dst_data[0].specular);
 
         hr = IDirect3DVertexBuffer_Unlock(dst_vb);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     IDirect3DVertexBuffer_Release(src_vb1);
@@ -5118,13 +5118,13 @@ static void test_lighting(void)
     IDirect3DVertexBuffer_Release(dst_vb);
 
     hr = IDirect3DViewport3_DeleteLight(viewport, light);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3DLight_Release(light);
     destroy_material(material);
     IDirect3DViewport3_Release(viewport);
     IDirectDrawSurface4_Release(rt);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D3_Release(d3d);
     DestroyWindow(window);
 }
@@ -5385,25 +5385,25 @@ static void test_specular_lighting(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&light_desc, 0, sizeof(light_desc));
     light_desc.dwSize = sizeof(light_desc);
@@ -5414,95 +5414,95 @@ static void test_specular_lighting(void)
     for (i = 0; i < ARRAY_SIZE(dummy_lights); ++i)
     {
         hr = IDirect3D3_CreateLight(d3d, &dummy_lights[i], NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DViewport3_AddLight(viewport, dummy_lights[i]);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DLight_SetLight(dummy_lights[i], (D3DLIGHT *)&light_desc);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirect3D3_CreateLight(d3d, &light, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport3_AddLight(viewport, light);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_SPECULARENABLE, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = fvf;
     vb_desc.dwNumVertices = ARRAY_SIZE(vertices);
     hr = IDirect3D3_CreateVertexBuffer(d3d, &vb_desc, &src_vb, 0, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer_Lock(src_vb, 0, (void **)&src_data, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(src_data, vertices, sizeof(vertices));
     hr = IDirect3DVertexBuffer_Unlock(src_vb);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR;
     vb_desc.dwNumVertices = ARRAY_SIZE(vertices);
     hr = IDirect3D3_CreateVertexBuffer(d3d, &vb_desc, &dst_vb, 0, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         tests[i].light->dwFlags = D3DLIGHT_ACTIVE;
         hr = IDirect3DLight_SetLight(light, (D3DLIGHT *)tests[i].light);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_LOCALVIEWER, tests[i].local_viewer);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         material = create_specular_material(device, 1.0f, 1.0f, 1.0f, 0.5f, tests[i].specular_power);
         hr = IDirect3DMaterial3_GetHandle(material, device, &mat_handle);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice3_SetLightState(device, D3DLIGHTSTATE_MATERIAL, mat_handle);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice3_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DVertexBuffer_Lock(dst_vb, 0, (void **)&dst_data, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         memset(dst_data, 0, sizeof(*dst_data) * ARRAY_SIZE(vertices));
         hr = IDirect3DVertexBuffer_Unlock(dst_vb);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DVertexBuffer_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 0,
                 ARRAY_SIZE(vertices), src_vb, 0, device, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, fvf, quad,
                 vertices_side * vertices_side, indices, indices_count, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice3_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DVertexBuffer_Lock(dst_vb, 0, (void **)&dst_data, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         for (j = 0; j < tests[i].expected_count; ++j)
         {
             color = get_surface_color(rt, tests[i].expected[j].x, tests[i].expected[j].y);
             ok(compare_color(color, tests[i].expected[j].color, 1),
-                    "Expected color 0x%08x at location (%u, %u), got 0x%08x, case %u.\n",
+                    "Expected color 0x%08lx at location (%u, %u), got 0x%08lx, case %u.\n",
                     tests[i].expected[j].color, tests[i].expected[j].x,
                     tests[i].expected[j].y, color, i);
-            ok(!dst_data[j].diffuse, "Expected color 0x00000000 for vertex %u, got 0x%08x, case %u.\n",
+            ok(!dst_data[j].diffuse, "Expected color 0x00000000 for vertex %u, got 0x%08lx, case %u.\n",
                     j, dst_data[j].diffuse, i);
             ok(compare_color(dst_data[j].specular, tests[i].expected[j].color, 1),
-                    "Expected color 0x%08x for vertex %u, got 0x%08x, case %u.\n",
+                    "Expected color 0x%08lx for vertex %u, got 0x%08lx, case %u.\n",
                     tests[i].expected[j].color, j, dst_data[j].specular, i);
         }
         hr = IDirect3DVertexBuffer_Unlock(dst_vb);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         destroy_material(material);
     }
@@ -5514,12 +5514,12 @@ static void test_specular_lighting(void)
     IDirect3DVertexBuffer_Release(src_vb);
 
     hr = IDirect3DViewport3_DeleteLight(viewport, light);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3DLight_Release(light);
     IDirect3DViewport3_Release(viewport);
     IDirectDrawSurface4_Release(rt);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D3_Release(d3d);
     DestroyWindow(window);
     heap_free(indices);
@@ -5545,23 +5545,23 @@ static void test_clear_rect_count(void)
     }
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#lx.\n", hr);
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0x00ffffff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear the viewport, hr %#lx.\n", hr);
     hr = IDirect3DViewport3_Clear2(viewport, 0, &clear_rect, D3DCLEAR_TARGET, 0x00ff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear the viewport, hr %#lx.\n", hr);
     hr = IDirect3DViewport3_Clear2(viewport, 0, NULL, D3DCLEAR_TARGET, 0x0000ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear the viewport, hr %#lx.\n", hr);
     hr = IDirect3DViewport3_Clear2(viewport, 1, NULL, D3DCLEAR_TARGET, 0x000000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear the viewport, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 320, 240);
     ok(compare_color(color, 0x00ffffff, 1) || broken(compare_color(color, 0x000000ff, 1)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
 
     IDirect3DViewport3_Release(viewport);
     IDirectDrawSurface4_Release(rt);
@@ -5577,21 +5577,21 @@ static BOOL test_mode_restored(IDirectDraw4 *ddraw, HWND window)
     memset(&ddsd1, 0, sizeof(ddsd1));
     ddsd1.dwSize = sizeof(ddsd1);
     hr = IDirectDraw4_GetDisplayMode(ddraw, &ddsd1);
-    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     memset(&ddsd2, 0, sizeof(ddsd2));
     ddsd2.dwSize = sizeof(ddsd2);
     hr = IDirectDraw4_GetDisplayMode(ddraw, &ddsd2);
-    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDraw4_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     return ddsd1.dwWidth == ddsd2.dwWidth && ddsd1.dwHeight == ddsd2.dwHeight;
 }
@@ -5615,16 +5615,16 @@ static void test_coop_level_versions(void)
 
     /* A failing ddraw1::SetCooperativeLevel call does not have an effect */
     hr = IDirectDraw4_QueryInterface(ddraw4, &IID_IDirectDraw, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(FAILED(hr), "SetCooperativeLevel returned %#x, expected failure.\n", hr);
+    ok(FAILED(hr), "SetCooperativeLevel returned %#lx, expected failure.\n", hr);
     restored = test_mode_restored(ddraw4, window);
     ok(restored, "Display mode not restored after bad ddraw1::SetCooperativeLevel call\n");
 
     /* A successful one does */
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     restored = test_mode_restored(ddraw4, window);
     ok(!restored, "Display mode restored after good ddraw1::SetCooperativeLevel call\n");
 
@@ -5634,10 +5634,10 @@ static void test_coop_level_versions(void)
     ddraw4 = create_ddraw();
     ok(!!ddraw4, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_QueryInterface(ddraw4, &IID_IDirectDraw, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_SETFOCUSWINDOW);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     restored = test_mode_restored(ddraw4, window);
     ok(!restored, "Display mode restored after ddraw1::SetCooperativeLevel(SETFOCUSWINDOW) call\n");
 
@@ -5648,12 +5648,12 @@ static void test_coop_level_versions(void)
     ddraw4 = create_ddraw();
     ok(!!ddraw4, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_QueryInterface(ddraw4, &IID_IDirectDraw, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(FAILED(hr), "SetCooperativeLevel returned %#x, expected failure.\n", hr);
+    ok(FAILED(hr), "SetCooperativeLevel returned %#lx, expected failure.\n", hr);
     restored = test_mode_restored(ddraw4, window);
     ok(!restored, "Display mode restored after good-bad ddraw1::SetCooperativeLevel() call sequence\n");
 
@@ -5664,14 +5664,14 @@ static void test_coop_level_versions(void)
     ddraw4 = create_ddraw();
     ok(!!ddraw4, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_QueryInterface(ddraw4, &IID_IDirectDraw, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw4, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw4, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     restored = test_mode_restored(ddraw4, window);
     ok(!restored, "Display mode restored after ddraw1-ddraw4 SetCooperativeLevel() call sequence\n");
@@ -5682,10 +5682,10 @@ static void test_coop_level_versions(void)
     ddraw4 = create_ddraw();
     ok(!!ddraw4, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_QueryInterface(ddraw4, &IID_IDirectDraw, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw4, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -5693,7 +5693,7 @@ static void test_coop_level_versions(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     ddsd.dwWidth = ddsd.dwHeight = 8;
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "CreateSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateSurface failed, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface);
     restored = test_mode_restored(ddraw4, window);
     ok(restored, "Display mode not restored after ddraw1::CreateSurface() call\n");
@@ -5851,46 +5851,46 @@ static void test_lighting_interface_versions(void)
     }
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     emissive = create_emissive_material(device, 0.0f, 1.0f, 0.0f, 0.0f);
     hr = IDirect3DMaterial3_GetHandle(emissive, device, &mat_handle);
-    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetLightState(device, D3DLIGHTSTATE_MATERIAL, mat_handle);
-    ok(SUCCEEDED(hr), "Failed to set material state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set material state, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable z test, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_SPECULARENABLE, &rs);
-    ok(SUCCEEDED(hr), "Failed to get specularenable render state, hr %#x.\n", hr);
-    ok(rs == FALSE, "Initial D3DRENDERSTATE_SPECULARENABLE is %#x, expected FALSE.\n", rs);
+    ok(SUCCEEDED(hr), "Failed to get specularenable render state, hr %#lx.\n", hr);
+    ok(rs == FALSE, "Initial D3DRENDERSTATE_SPECULARENABLE is %#lx, expected FALSE.\n", rs);
 
     for (i = 0; i < ARRAY_SIZE(tests); i++)
     {
         hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xff202020, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_LIGHTING, tests[i].d3drs_lighting);
-        ok(SUCCEEDED(hr), "Failed to set lighting render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set lighting render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_SPECULARENABLE,
                 tests[i].d3drs_specular);
-        ok(SUCCEEDED(hr), "Failed to set specularenable render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set specularenable render state, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice3_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
                 tests[i].vertextype, tests[i].data, 4, tests[i].draw_flags | D3DDP_WAIT);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice3_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, tests[i].color, 1),
-                "Got unexpected color 0x%08x, expected 0x%08x, test %u.\n",
+                "Got unexpected color 0x%08lx, expected 0x%08lx, test %u.\n",
                 color, tests[i].color, i);
     }
 
@@ -5898,7 +5898,7 @@ static void test_lighting_interface_versions(void)
     destroy_viewport(device, viewport);
     IDirectDrawSurface4_Release(rt);
     ref = IDirect3DDevice3_Release(device);
-    ok(ref == 0, "Device not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Device not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -5920,7 +5920,7 @@ static LRESULT CALLBACK activateapp_test_proc(HWND hwnd, UINT message, WPARAM wp
             activateapp_testdata.received = FALSE;
             hr = IDirectDraw4_SetCooperativeLevel(activateapp_testdata.ddraw,
                     activateapp_testdata.window, activateapp_testdata.coop_level);
-            ok(SUCCEEDED(hr), "Recursive SetCooperativeLevel call failed, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Recursive SetCooperativeLevel call failed, hr %#lx.\n", hr);
             ok(!activateapp_testdata.received, "Received WM_ACTIVATEAPP during recursive SetCooperativeLevel call.\n");
         }
         activateapp_testdata.received = TRUE;
@@ -5952,31 +5952,31 @@ static void test_coop_level_activateapp(void)
     SetForegroundWindow(window);
     activateapp_testdata.received = FALSE;
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(!activateapp_testdata.received, "Received WM_ACTIVATEAPP although window was already active.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Exclusive with window not active. */
     SetForegroundWindow(GetDesktopWindow());
     activateapp_testdata.received = FALSE;
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(activateapp_testdata.received, "Expected WM_ACTIVATEAPP, but did not receive it.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Normal with window not active, then exclusive with the same window. */
     SetForegroundWindow(GetDesktopWindow());
     activateapp_testdata.received = FALSE;
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(!activateapp_testdata.received, "Received WM_ACTIVATEAPP when setting DDSCL_NORMAL.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(activateapp_testdata.received, "Expected WM_ACTIVATEAPP, but did not receive it.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Recursive set of DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN. */
     SetForegroundWindow(GetDesktopWindow());
@@ -5985,10 +5985,10 @@ static void test_coop_level_activateapp(void)
     activateapp_testdata.window = window;
     activateapp_testdata.coop_level = DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN;
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(activateapp_testdata.received, "Expected WM_ACTIVATEAPP, but did not receive it.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* The recursive call seems to have some bad effect on native ddraw, despite (apparently)
      * succeeding. Another switch to exclusive and back to normal is needed to release the
@@ -5996,9 +5996,9 @@ static void test_coop_level_activateapp(void)
      * WM_ACTIVATEAPP messages. */
     activateapp_testdata.ddraw = NULL;
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Setting DDSCL_NORMAL with recursive invocation. */
     SetForegroundWindow(GetDesktopWindow());
@@ -6007,7 +6007,7 @@ static void test_coop_level_activateapp(void)
     activateapp_testdata.window = window;
     activateapp_testdata.coop_level = DDSCL_NORMAL;
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(activateapp_testdata.received, "Expected WM_ACTIVATEAPP, but did not receive it.\n");
 
     /* DDraw is in exclusive mode now. */
@@ -6017,15 +6017,15 @@ static void test_coop_level_activateapp(void)
     U5(ddsd).dwBackBufferCount = 1;
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     IDirectDrawSurface4_Release(surface);
 
     /* Recover again, just to be sure. */
     activateapp_testdata.ddraw = NULL;
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     DestroyWindow(window);
     UnregisterClassA("ddraw_test_wndproc_wc", GetModuleHandleA(NULL));
@@ -6087,14 +6087,14 @@ static void test_texturemanage(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     memset(&hel_caps, 0, sizeof(hel_caps));
     hel_caps.dwSize = sizeof(hel_caps);
     hr = IDirectDraw4_GetCaps(ddraw, &hal_caps, &hel_caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & needed_caps) != needed_caps)
     {
         skip("Managed textures not supported, skipping managed texture test.\n");
@@ -6113,20 +6113,20 @@ static void test_texturemanage(void)
         ddsd.dwHeight = 4;
 
         hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
-        ok(hr == tests[i].hr, "Got unexpected, hr %#x, case %u.\n", hr, i);
+        ok(hr == tests[i].hr, "Got unexpected, hr %#lx, case %u.\n", hr, i);
         if (FAILED(hr))
             continue;
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &ddsd);
-        ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
 
         ok(ddsd.ddsCaps.dwCaps == tests[i].caps_out,
-                "Input caps %#x, %#x, expected output caps %#x, got %#x, case %u.\n",
+                "Input caps %#lx, %#lx, expected output caps %#lx, got %#lx, case %u.\n",
                 tests[i].caps_in, tests[i].caps2_in, tests[i].caps_out, ddsd.ddsCaps.dwCaps, i);
         ok(ddsd.ddsCaps.dwCaps2 == tests[i].caps2_out,
-                "Input caps %#x, %#x, expected output caps %#x, got %#x, case %u.\n",
+                "Input caps %#lx, %#lx, expected output caps %#lx, got %#lx, case %u.\n",
                 tests[i].caps_in, tests[i].caps2_in, tests[i].caps2_out, ddsd.ddsCaps.dwCaps2, i);
 
         IDirectDrawSurface4_Release(surface);
@@ -6286,23 +6286,23 @@ static void test_block_formats_creation(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **) &ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
     IDirect3D3_Release(d3d);
 
     hr = IDirect3DDevice3_EnumTextureFormats(device, test_block_formats_creation_cb,
             &supported_fmts);
-    ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#lx.\n", hr);
 
     hr = IDirectDraw4_GetFourCCCodes(ddraw, &num_fourcc_codes, NULL);
-    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#lx.\n", hr);
     fourcc_codes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
             num_fourcc_codes * sizeof(*fourcc_codes));
     if (!fourcc_codes)
         goto cleanup;
     hr = IDirectDraw4_GetFourCCCodes(ddraw, &num_fourcc_codes, fourcc_codes);
-    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#lx.\n", hr);
     for (i = 0; i < num_fourcc_codes; i++)
     {
         for (j = 0; j < ARRAY_SIZE(formats); j++)
@@ -6316,7 +6316,7 @@ static void test_block_formats_creation(void)
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw4_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
 
     mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2 * 2 * 16 + 1);
 
@@ -6374,7 +6374,7 @@ static void test_block_formats_creation(void)
                     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
                     todo_wine_if (todo)
                         ok(hr == expect_hr,
-                                "Got unexpected hr %#x for format %s, resource type %s, size %ux%u, expected %#x.\n",
+                                "Got unexpected hr %#lx for format %s, resource type %s, size %ux%u, expected %#lx.\n",
                                 hr, formats[i].name, types[j].name, w, h, expect_hr);
 
                     if (SUCCEEDED(hr))
@@ -6417,7 +6417,7 @@ static void test_block_formats_creation(void)
             ddsd.dwHeight = 8;
 
             hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
-            ok(hr == user_mem_tests[j].hr, "Test %u: Got unexpected hr %#x, format %s.\n", j, hr, formats[i].name);
+            ok(hr == user_mem_tests[j].hr, "Test %u: Got unexpected hr %#lx, format %s.\n", j, hr, formats[i].name);
 
             if (FAILED(hr))
                 continue;
@@ -6425,15 +6425,15 @@ static void test_block_formats_creation(void)
             memset(&ddsd, 0, sizeof(ddsd));
             ddsd.dwSize = sizeof(ddsd);
             hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &ddsd);
-            ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", j, hr);
+            ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#lx.\n", j, hr);
             ok(ddsd.dwFlags == (DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_LINEARSIZE),
-                    "Test %u: Got unexpected flags %#x.\n", j, ddsd.dwFlags);
+                    "Test %u: Got unexpected flags %#lx.\n", j, ddsd.dwFlags);
             if (user_mem_tests[j].flags & DDSD_LPSURFACE)
-                ok(U1(ddsd).dwLinearSize == ~0u, "Test %u: Got unexpected linear size %#x.\n",
+                ok(U1(ddsd).dwLinearSize == ~0u, "Test %u: Got unexpected linear size %#lx.\n",
                         j, U1(ddsd).dwLinearSize);
             else
                 ok(U1(ddsd).dwLinearSize == 2 * 2 * formats[i].block_size,
-                        "Test %u: Got unexpected linear size %#x, expected %#x.\n",
+                        "Test %u: Got unexpected linear size %#lx, expected %#x.\n",
                         j, U1(ddsd).dwLinearSize, 2 * 2 * formats[i].block_size);
             IDirectDrawSurface4_Release(surface);
         }
@@ -6510,16 +6510,16 @@ static void test_unsupported_formats(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **) &ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
     IDirect3D3_Release(d3d);
 
     for (i = 0; i < ARRAY_SIZE(formats); i++)
     {
         struct format_support_check check = {&formats[i].fmt, FALSE};
         hr = IDirect3DDevice3_EnumTextureFormats(device, test_unsupported_formats_cb, &check);
-        ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#lx.\n", hr);
 
         for (j = 0; j < ARRAY_SIZE(caps); j++)
         {
@@ -6538,7 +6538,7 @@ static void test_unsupported_formats(void)
 
             hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
             ok(SUCCEEDED(hr) == expect_success,
-                    "Got unexpected hr %#x for format %s, caps %#x, expected %s.\n",
+                    "Got unexpected hr %#lx for format %s, caps %#lx, expected %s.\n",
                     hr, formats[i].name, caps[j], expect_success ? "success" : "failure");
             if (FAILED(hr))
                 continue;
@@ -6546,7 +6546,7 @@ static void test_unsupported_formats(void)
             memset(&ddsd, 0, sizeof(ddsd));
             ddsd.dwSize = sizeof(ddsd);
             hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &ddsd);
-            ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
 
             if (caps[j] & DDSCAPS_VIDEOMEMORY)
                 expected_caps = DDSCAPS_VIDEOMEMORY;
@@ -6558,7 +6558,7 @@ static void test_unsupported_formats(void)
                 expected_caps = DDSCAPS_SYSTEMMEMORY;
 
             ok(ddsd.ddsCaps.dwCaps & expected_caps,
-                    "Expected capability %#x, format %s, input cap %#x.\n",
+                    "Expected capability %#lx, format %s, input cap %#lx.\n",
                     expected_caps, formats[i].name, caps[j]);
 
             IDirectDrawSurface4_Release(surface);
@@ -6784,7 +6784,7 @@ static void test_rt_caps(const GUID *device_guid)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     if (FAILED(IDirectDraw4_QueryInterface(ddraw, &IID_IDirect3D3, (void **)&d3d)))
     {
@@ -6803,12 +6803,12 @@ static void test_rt_caps(const GUID *device_guid)
 
     memset(palette_entries, 0, sizeof(palette_entries));
     hr = IDirectDraw4_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, palette_entries, &palette, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw4_GetCaps(ddraw, &hal_caps, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
@@ -6840,14 +6840,14 @@ static void test_rt_caps(const GUID *device_guid)
         ok(hr == expected_hr || (software_device && (surface_desc.ddsCaps.dwCaps & (DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER))
                 == (DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER) && hr == DDERR_UNSUPPORTED)
                 || broken(software_device && test_data[i].pf == &p8_fmt && hr == DDERR_INVALIDPIXELFORMAT),
-                "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+                "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
         if (FAILED(hr))
             continue;
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &surface_desc);
-        ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+        ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
 
         if ((caps_in & DDSCAPS_SYSTEMMEMORY) || (test_data[i].caps2_in & (DDSCAPS2_D3DTEXTUREMANAGE
                 | DDSCAPS2_TEXTUREMANAGE)) || !(hal_caps.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
@@ -6859,11 +6859,11 @@ static void test_rt_caps(const GUID *device_guid)
                 && surface_desc.ddsCaps.dwCaps == (caps_in | DDSCAPS_SYSTEMMEMORY))
                 || (software_device && test_data[i].pf == &z_fmt
                 && surface_desc.ddsCaps.dwCaps == (caps_in | DDSCAPS_SYSTEMMEMORY)),
-                "Got unexpected caps %#x, expected %#x, test %u, software_device %u.\n",
+                "Got unexpected caps %#lx, expected %#lx, test %u, software_device %u.\n",
                 surface_desc.ddsCaps.dwCaps, expected_caps, i, software_device);
 
         ok(surface_desc.ddsCaps.dwCaps2 == test_data[i].caps2_in,
-                "Got unexpected caps2 %#x, expected %#x, test %u, software_device %u.\n",
+                "Got unexpected caps2 %#lx, expected %#lx, test %u, software_device %u.\n",
                 surface_desc.ddsCaps.dwCaps2, test_data[i].caps2_in, i, software_device);
 
         hr = IDirect3D3_CreateDevice(d3d, device_guid, surface, &device, NULL);
@@ -6871,13 +6871,13 @@ static void test_rt_caps(const GUID *device_guid)
         ok((!software_device && hr == test_data[i].create_device_hr)
                 || (software_device && (hr == (test_data[i].create_device_hr == D3DERR_SURFACENOTINVIDMEM
                 ? DD_OK : test_data[i].create_device_hr))),
-                "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+                "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
         if (FAILED(hr))
         {
             if (hr == DDERR_NOPALETTEATTACHED)
             {
                 hr = IDirectDrawSurface4_SetPalette(surface, palette);
-                ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+                ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
                 if (software_device)
                 {
                     /* _CreateDevice succeeds with software device, but the palette gets extra reference
@@ -6888,10 +6888,10 @@ static void test_rt_caps(const GUID *device_guid)
                 }
                 hr = IDirect3D3_CreateDevice(d3d, device_guid, surface, &device, NULL);
                 if (surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)
-                    ok(hr == DDERR_INVALIDPIXELFORMAT, "Got unexpected hr %#x, test %u, software_device %u.\n",
+                    ok(hr == DDERR_INVALIDPIXELFORMAT, "Got unexpected hr %#lx, test %u, software_device %u.\n",
                             hr, i, software_device);
                 else
-                    ok(hr == D3DERR_SURFACENOTINVIDMEM, "Got unexpected hr %#x, test %u, software_device %u.\n",
+                    ok(hr == D3DERR_SURFACENOTINVIDMEM, "Got unexpected hr %#lx, test %u, software_device %u.\n",
                             hr, i, software_device);
             }
             IDirectDrawSurface4_Release(surface);
@@ -6903,10 +6903,10 @@ static void test_rt_caps(const GUID *device_guid)
             surface_desc.dwWidth = 640;
             surface_desc.dwHeight = 480;
             hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+            ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
 
             hr = IDirect3D3_CreateDevice(d3d, device_guid, surface, &device, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+            ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
         }
 
         memset(&surface_desc, 0, sizeof(surface_desc));
@@ -6922,12 +6922,12 @@ static void test_rt_caps(const GUID *device_guid)
         surface_desc.dwWidth = 640;
         surface_desc.dwHeight = 480;
         hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &rt, NULL);
-        ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+        ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
 
         hr = IDirect3DDevice3_SetRenderTarget(device, rt, 0);
         ok(hr == test_data[i].set_rt_hr || (software_device && hr == DDERR_NOPALETTEATTACHED)
                 || broken(hr == test_data[i].alternative_set_rt_hr),
-                "Got unexpected hr %#x, test %u, software_device %u.\n",
+                "Got unexpected hr %#lx, test %u, software_device %u.\n",
                 hr, i, software_device);
         if (SUCCEEDED(hr) || hr == DDERR_INVALIDPIXELFORMAT)
             expected_rt = rt;
@@ -6935,24 +6935,24 @@ static void test_rt_caps(const GUID *device_guid)
             expected_rt = surface;
 
         hr = IDirect3DDevice3_GetRenderTarget(device, &tmp);
-        ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+        ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
         ok(tmp == expected_rt, "Got unexpected rt %p, test %u, software_device %u.\n", tmp, i, software_device);
 
         IDirectDrawSurface4_Release(tmp);
         IDirectDrawSurface4_Release(rt);
         refcount = IDirect3DDevice3_Release(device);
-        ok(refcount == 0, "Test %u: The device was not properly freed, refcount %u.\n", i, refcount);
+        ok(refcount == 0, "Test %u: The device was not properly freed, refcount %lu.\n", i, refcount);
         refcount = IDirectDrawSurface4_Release(surface);
-        ok(refcount == 0, "Test %u: The surface was not properly freed, refcount %u.\n", i, refcount);
+        ok(refcount == 0, "Test %u: The surface was not properly freed, refcount %lu.\n", i, refcount);
     }
 
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     IDirect3D3_Release(d3d);
 
 done:
     refcount = IDirectDraw4_Release(ddraw);
-    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -7077,7 +7077,7 @@ static void test_primary_caps(void)
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, test_data[i].coop_level);
-        ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
@@ -7087,23 +7087,23 @@ static void test_primary_caps(void)
         surface_desc.ddsCaps.dwCaps = test_data[i].caps_in;
         U5(surface_desc).dwBackBufferCount = test_data[i].back_buffer_count;
         hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
         if (FAILED(hr))
             continue;
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &surface_desc);
-        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#lx.\n", i, hr);
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == test_data[i].caps_out,
-                "Test %u: Got unexpected caps %#x, expected %#x.\n",
+                "Test %u: Got unexpected caps %#lx, expected %#lx.\n",
                 i, surface_desc.ddsCaps.dwCaps, test_data[i].caps_out);
 
         IDirectDrawSurface4_Release(surface);
     }
 
     refcount = IDirectDraw4_Release(ddraw);
-    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -7192,7 +7192,7 @@ static void test_surface_lock(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     if (FAILED(IDirectDraw4_QueryInterface(ddraw, &IID_IDirect3D3, (void **)&d3d)))
     {
@@ -7228,21 +7228,21 @@ static void test_surface_lock(void)
         ddsd.ddsCaps.dwCaps2 = tests[i].caps2;
 
         hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, type %s, hr %#x.\n", tests[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to create surface, type %s, hr %#lx.\n", tests[i].name, hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface4_Lock(surface, NULL, &ddsd, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, type %s, hr %#x.\n", tests[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, type %s, hr %#lx.\n", tests[i].name, hr);
         if (SUCCEEDED(hr))
         {
             hr = IDirectDrawSurface4_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, type %s, hr %#x.\n", tests[i].name, hr);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, type %s, hr %#lx.\n", tests[i].name, hr);
         }
 
         memset(&ddsd, 0, sizeof(ddsd));
         hr = IDirectDrawSurface4_Lock(surface, NULL, &ddsd, DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x, type %s.\n", hr, tests[i].name);
+        ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx, type %s.\n", hr, tests[i].name);
 
         IDirectDrawSurface4_Release(surface);
     }
@@ -7251,7 +7251,7 @@ done:
     if (d3d)
         IDirect3D3_Release(d3d);
     refcount = IDirectDraw4_Release(ddraw);
-    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -7303,11 +7303,11 @@ static void test_surface_discard(void)
             return;
         }
         hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-        ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
         hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-        ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
         hr = IDirect3DDevice3_GetRenderTarget(device, &target);
-        ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
@@ -7317,34 +7317,34 @@ static void test_surface_discard(void)
         ddsd.dwWidth = 64;
         ddsd.dwHeight = 64;
         hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create offscreen surface, hr %#x, case %u.\n", hr, i);
+        ok(SUCCEEDED(hr), "Failed to create offscreen surface, hr %#lx, case %u.\n", hr, i);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface4_Lock(surface, NULL, &ddsd, 0, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         addr = ddsd.lpSurface;
         hr = IDirectDrawSurface4_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface4_Lock(surface, NULL, &ddsd, DDLOCK_DISCARDCONTENTS, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         discarded = ddsd.lpSurface != addr;
         hr = IDirectDrawSurface4_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         hr = IDirectDrawSurface4_Blt(target, NULL, surface, NULL, DDBLT_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface4_Lock(surface, NULL, &ddsd, DDLOCK_DISCARDCONTENTS, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         discarded |= ddsd.lpSurface != addr;
         hr = IDirectDrawSurface4_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         IDirectDrawSurface4_Release(surface);
 
@@ -7393,7 +7393,7 @@ static void test_flip(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
@@ -7416,93 +7416,93 @@ static void test_flip(void)
         surface_desc.dwHeight = 512;
         U5(surface_desc).dwBackBufferCount = 3;
         hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
 
         surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_FLIP;
         surface_desc.dwFlags |= DDSD_BACKBUFFERCOUNT;
         hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
 
         surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_COMPLEX;
         surface_desc.ddsCaps.dwCaps |= DDSCAPS_FLIP;
         hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
 
         surface_desc.ddsCaps.dwCaps |= DDSCAPS_COMPLEX;
         hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
         todo_wine_if(test_data[i].caps & DDSCAPS_TEXTURE)
-            ok(SUCCEEDED(hr), "%s: Failed to create surface, hr %#x.\n", test_data[i].name, hr);
+            ok(SUCCEEDED(hr), "%s: Failed to create surface, hr %#lx.\n", test_data[i].name, hr);
         if (FAILED(hr))
             continue;
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface4_GetSurfaceDesc(frontbuffer, &surface_desc);
-        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#lx.\n", test_data[i].name, hr);
         expected_caps = DDSCAPS_FRONTBUFFER | DDSCAPS_COMPLEX | DDSCAPS_FLIP | test_data[i].caps;
         if (test_data[i].caps & DDSCAPS_PRIMARYSURFACE)
             expected_caps |= DDSCAPS_VISIBLE;
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == expected_caps,
-                "%s: Got unexpected caps %#x.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
+                "%s: Got unexpected caps %#lx.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
         sysmem_primary = surface_desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY;
 
         hr = IDirectDrawSurface4_GetAttachedSurface(frontbuffer, &caps, &backbuffer1);
-        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#lx.\n", test_data[i].name, hr);
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface4_GetSurfaceDesc(backbuffer1, &surface_desc);
-        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#x.\n", test_data[i].name, hr);
-        ok(!U5(surface_desc).dwBackBufferCount, "%s: Got unexpected back buffer count %u.\n",
+        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#lx.\n", test_data[i].name, hr);
+        ok(!U5(surface_desc).dwBackBufferCount, "%s: Got unexpected back buffer count %lu.\n",
                 test_data[i].name, U5(surface_desc).dwBackBufferCount);
         expected_caps &= ~(DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER);
         expected_caps |= DDSCAPS_BACKBUFFER;
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == expected_caps,
-                "%s: Got unexpected caps %#x.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
+                "%s: Got unexpected caps %#lx.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
 
         hr = IDirectDrawSurface4_GetAttachedSurface(backbuffer1, &caps, &backbuffer2);
-        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#lx.\n", test_data[i].name, hr);
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface4_GetSurfaceDesc(backbuffer2, &surface_desc);
-        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#x.\n", test_data[i].name, hr);
-        ok(!U5(surface_desc).dwBackBufferCount, "%s: Got unexpected back buffer count %u.\n",
+        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#lx.\n", test_data[i].name, hr);
+        ok(!U5(surface_desc).dwBackBufferCount, "%s: Got unexpected back buffer count %lu.\n",
                 test_data[i].name, U5(surface_desc).dwBackBufferCount);
         expected_caps &= ~DDSCAPS_BACKBUFFER;
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == expected_caps,
-                "%s: Got unexpected caps %#x.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
+                "%s: Got unexpected caps %#lx.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
 
         hr = IDirectDrawSurface4_GetAttachedSurface(backbuffer2, &caps, &backbuffer3);
-        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#lx.\n", test_data[i].name, hr);
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface4_GetSurfaceDesc(backbuffer3, &surface_desc);
-        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#x.\n", test_data[i].name, hr);
-        ok(!U5(surface_desc).dwBackBufferCount, "%s: Got unexpected back buffer count %u.\n",
+        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#lx.\n", test_data[i].name, hr);
+        ok(!U5(surface_desc).dwBackBufferCount, "%s: Got unexpected back buffer count %lu.\n",
                 test_data[i].name, U5(surface_desc).dwBackBufferCount);
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == expected_caps,
-                "%s: Got unexpected caps %#x.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
+                "%s: Got unexpected caps %#lx.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
 
         hr = IDirectDrawSurface4_GetAttachedSurface(backbuffer3, &caps, &surface);
-        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#lx.\n", test_data[i].name, hr);
         ok(surface == frontbuffer, "%s: Got unexpected surface %p, expected %p.\n",
                 test_data[i].name, surface, frontbuffer);
         IDirectDrawSurface4_Release(surface);
 
         hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-        ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_IsLost(frontbuffer);
-        ok(hr == DD_OK, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DD_OK, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Flip(frontbuffer, NULL, DDFLIP_WAIT);
         if (test_data[i].caps & DDSCAPS_PRIMARYSURFACE)
-            ok(hr == DDERR_NOEXCLUSIVEMODE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+            ok(hr == DDERR_NOEXCLUSIVEMODE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         else
-            ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+            ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-        ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_IsLost(frontbuffer);
-        todo_wine ok(hr == DDERR_SURFACELOST, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        todo_wine ok(hr == DDERR_SURFACELOST, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDraw4_RestoreAllSurfaces(ddraw);
-        ok(SUCCEEDED(hr), "%s: Failed to restore surfaces, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to restore surfaces, hr %#lx.\n", test_data[i].name, hr);
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
@@ -7511,19 +7511,19 @@ static void test_flip(void)
         surface_desc.dwWidth = 640;
         surface_desc.dwHeight = 480;
         hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(SUCCEEDED(hr), "%s: Failed to create surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to create surface, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Flip(frontbuffer, surface, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         IDirectDrawSurface4_Release(surface);
 
         hr = IDirectDrawSurface4_Flip(frontbuffer, frontbuffer, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Flip(backbuffer1, NULL, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Flip(backbuffer2, NULL, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Flip(backbuffer3, NULL, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
 
         /* The Nvidia Geforce 7 driver cannot do a color fill on a texture backbuffer after
          * the backbuffer has been locked. Do it ourselves as a workaround. Unlike ddraw1
@@ -7533,59 +7533,59 @@ static void test_flip(void)
         fill_surface(backbuffer3, 0xff0000ff);
 
         hr = IDirectDrawSurface4_Flip(frontbuffer, NULL, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
         /* The testbot seems to just copy the contents of one surface to all the
          * others, instead of properly flipping. */
         ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
-        ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer3, 0xffff0000);
 
         hr = IDirectDrawSurface4_Flip(frontbuffer, NULL, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
         ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
-        ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer3, 0xff00ff00);
 
         hr = IDirectDrawSurface4_Flip(frontbuffer, NULL, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
         ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
-        ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer3, 0xff0000ff);
 
         hr = IDirectDrawSurface4_Flip(frontbuffer, backbuffer1, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer2, 320, 240);
         ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer3, 320, 240);
-        ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer1, 0xffff0000);
 
         hr = IDirectDrawSurface4_Flip(frontbuffer, backbuffer2, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
-        ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer3, 320, 240);
         ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer2, 0xff00ff00);
 
         hr = IDirectDrawSurface4_Flip(frontbuffer, backbuffer3, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
         ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
-        ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
 
         IDirectDrawSurface4_Release(backbuffer3);
         IDirectDrawSurface4_Release(backbuffer2);
@@ -7594,7 +7594,7 @@ static void test_flip(void)
     }
 
     refcount = IDirectDraw4_Release(ddraw);
-    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -7633,7 +7633,7 @@ static void test_set_surface_desc(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
@@ -7648,73 +7648,73 @@ static void test_set_surface_desc(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     /* Redundantly setting the same lpSurface is not an error. */
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!(ddsd.dwFlags & DDSD_LPSURFACE), "DDSD_LPSURFACE is set.\n");
     ok(ddsd.lpSurface == NULL, "lpSurface is %p, expected NULL.\n", ddsd.lpSurface);
 
     hr = IDirectDrawSurface4_Lock(surface, NULL, &ddsd, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ok(!(ddsd.dwFlags & DDSD_LPSURFACE), "DDSD_LPSURFACE is set.\n");
     ok(ddsd.lpSurface == data, "lpSurface is %p, expected %p.\n", data, data);
     hr = IDirectDrawSurface4_Unlock(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 1);
-    ok(hr == DDERR_INVALIDPARAMS, "SetSurfaceDesc with flags=1 returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "SetSurfaceDesc with flags=1 returned %#lx.\n", hr);
 
     ddsd.lpSurface = NULL;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting lpSurface=NULL returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting lpSurface=NULL returned %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, NULL, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "SetSurfaceDesc with NULL desc returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "SetSurfaceDesc with NULL desc returned %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(ddsd.ddsCaps.dwCaps == (DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN),
-            "Got unexpected caps %#x.\n", ddsd.ddsCaps.dwCaps);
+            "Got unexpected caps %#lx.\n", ddsd.ddsCaps.dwCaps);
     ok(ddsd.ddsCaps.dwCaps2 == 0, "Got unexpected caps2 %#x.\n", 0);
 
     /* Setting the caps is an error. This also means the original description cannot be reapplied. */
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting the original desc returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting the original desc returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_CAPS;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting DDSD_CAPS returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting DDSD_CAPS returned %#lx.\n", hr);
 
     /* dwCaps = 0 is allowed, but ignored. Caps2 can be anything and is ignored too. */
     ddsd.dwFlags = DDSD_CAPS | DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDCAPS, "Setting DDSD_CAPS returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDCAPS, "Setting DDSD_CAPS returned %#lx.\n", hr);
     ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDCAPS, "Setting DDSD_CAPS returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDCAPS, "Setting DDSD_CAPS returned %#lx.\n", hr);
     ddsd.ddsCaps.dwCaps = 0;
     ddsd.ddsCaps.dwCaps2 = 0xdeadbeef;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(ddsd.ddsCaps.dwCaps == (DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN),
-            "Got unexpected caps %#x.\n", ddsd.ddsCaps.dwCaps);
+            "Got unexpected caps %#lx.\n", ddsd.ddsCaps.dwCaps);
     ok(ddsd.ddsCaps.dwCaps2 == 0, "Got unexpected caps2 %#x.\n", 0);
 
     /* Setting the height is allowed, but it cannot be set to 0, and only if LPSURFACE is set too. */
@@ -7722,56 +7722,56 @@ static void test_set_surface_desc(void)
     ddsd.dwFlags = DDSD_HEIGHT;
     ddsd.dwHeight = 16;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting height without lpSurface returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting height without lpSurface returned %#lx.\n", hr);
 
     ddsd.lpSurface = data;
     ddsd.dwFlags = DDSD_HEIGHT | DDSD_LPSURFACE;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     ddsd.dwHeight = 0;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting height=0 returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting height=0 returned %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &ddsd);
-    ok(SUCCEEDED(hr), "GetSurfaceDesc failed, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == 8, "SetSurfaceDesc: Expected width 8, got %u.\n", ddsd.dwWidth);
-    ok(ddsd.dwHeight == 16, "SetSurfaceDesc: Expected height 16, got %u.\n", ddsd.dwHeight);
+    ok(SUCCEEDED(hr), "GetSurfaceDesc failed, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == 8, "SetSurfaceDesc: Expected width 8, got %lu.\n", ddsd.dwWidth);
+    ok(ddsd.dwHeight == 16, "SetSurfaceDesc: Expected height 16, got %lu.\n", ddsd.dwHeight);
 
     /* Pitch and width can be set, but only together, and only with LPSURFACE. They must not be 0 */
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_PITCH;
     U1(ddsd).lPitch = 8 * 4;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting pitch without lpSurface or width returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting pitch without lpSurface or width returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_WIDTH;
     ddsd.dwWidth = 16;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting width without lpSurface or pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting width without lpSurface or pitch returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_PITCH | DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting pitch and lpSurface without width returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting pitch and lpSurface without width returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_WIDTH | DDSD_LPSURFACE;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting width and lpSurface without pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting width and lpSurface without pitch returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_WIDTH | DDSD_PITCH | DDSD_LPSURFACE;
     U1(ddsd).lPitch = 16 * 4;
     ddsd.dwWidth = 16;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == 16, "SetSurfaceDesc: Expected width 8, got %u.\n", ddsd.dwWidth);
-    ok(ddsd.dwHeight == 16, "SetSurfaceDesc: Expected height 16, got %u.\n", ddsd.dwHeight);
-    ok(U1(ddsd).lPitch == 16 * 4, "SetSurfaceDesc: Expected pitch 64, got %u.\n", U1(ddsd).lPitch);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == 16, "SetSurfaceDesc: Expected width 8, got %lu.\n", ddsd.dwWidth);
+    ok(ddsd.dwHeight == 16, "SetSurfaceDesc: Expected height 16, got %lu.\n", ddsd.dwHeight);
+    ok(U1(ddsd).lPitch == 16 * 4, "SetSurfaceDesc: Expected pitch 64, got %lu.\n", U1(ddsd).lPitch);
 
     /* The pitch must be 32 bit aligned and > 0, but is not verified for sanity otherwise.
      *
@@ -7780,27 +7780,27 @@ static void test_set_surface_desc(void)
     U1(ddsd).lPitch = 4 * 4;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDPARAMS), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDPARAMS), "Failed to set surface desc, hr %#lx.\n", hr);
 
     U1(ddsd).lPitch = 4;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDPARAMS), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDPARAMS), "Failed to set surface desc, hr %#lx.\n", hr);
 
     U1(ddsd).lPitch = 16 * 4 + 1;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting misaligned pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting misaligned pitch returned %#lx.\n", hr);
 
     U1(ddsd).lPitch = 16 * 4 + 3;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting misaligned pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting misaligned pitch returned %#lx.\n", hr);
 
     U1(ddsd).lPitch = -4;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting negative pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting negative pitch returned %#lx.\n", hr);
 
     U1(ddsd).lPitch = 16 * 4;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_WIDTH | DDSD_PITCH | DDSD_LPSURFACE;
@@ -7808,13 +7808,13 @@ static void test_set_surface_desc(void)
     ddsd.dwWidth = 16;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting zero pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting zero pitch returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_WIDTH | DDSD_PITCH | DDSD_LPSURFACE;
     U1(ddsd).lPitch = 16 * 4;
     ddsd.dwWidth = 0;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting zero width returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting zero width returned %#lx.\n", hr);
 
     /* Setting the pixelformat without LPSURFACE is an error, but with LPSURFACE it works. */
     ddsd.dwFlags = DDSD_PIXELFORMAT;
@@ -7825,11 +7825,11 @@ static void test_set_surface_desc(void)
     U3(U4(ddsd).ddpfPixelFormat).dwGBitMask = 0x0000ff00;
     U4(U4(ddsd).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting the pixel format returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting the pixel format returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_LPSURFACE;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     /* Can't set color keys. */
     reset_ddsd(&ddsd);
@@ -7837,12 +7837,12 @@ static void test_set_surface_desc(void)
     ddsd.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00ff0000;
     ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00ff0000;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting ddckCKSrcBlt returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting ddckCKSrcBlt returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_CKSRCBLT | DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting ddckCKSrcBlt returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting ddckCKSrcBlt returned %#lx.\n", hr);
 
     IDirectDrawSurface4_Release(surface);
 
@@ -7855,7 +7855,7 @@ static void test_set_surface_desc(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW || hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW || hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
 
     if (FAILED(hr))
     {
@@ -7866,13 +7866,13 @@ static void test_set_surface_desc(void)
         /* Changing surface desc for mipmap fails even without changing any
          * parameters. */
         hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-        ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#lx.\n", hr);
 
         reset_ddsd(&ddsd);
         ddsd.dwFlags = DDSD_LPSURFACE;
         ddsd.lpSurface = data;
         hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-        ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#lx.\n", hr);
         IDirectDrawSurface4_Release(surface);
     }
 
@@ -7885,7 +7885,7 @@ static void test_set_surface_desc(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW || hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW || hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
 
     if (hr == DD_OK)
     {
@@ -7893,11 +7893,11 @@ static void test_set_surface_desc(void)
         IDirectDrawSurface4 *surface2;
 
         hr = IDirectDrawSurface4_GetAttachedSurface(surface, &caps, &surface2);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         reset_ddsd(&ddsd);
         hr = IDirectDrawSurface4_GetSurfaceDesc(surface2, &ddsd);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-        ok(ddsd.dwWidth == 4, "Got unexpected dwWidth %u.\n", ddsd.dwWidth);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+        ok(ddsd.dwWidth == 4, "Got unexpected dwWidth %lu.\n", ddsd.dwWidth);
 
         reset_ddsd(&ddsd);
         ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH | DDSD_LPSURFACE;
@@ -7906,7 +7906,7 @@ static void test_set_surface_desc(void)
         U1(ddsd).lPitch = 16 * 4;
         ddsd.lpSurface = data;
         hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-        todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        todo_wine ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         reset_ddsd(&ddsd);
         ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH | DDSD_LPSURFACE;
@@ -7915,13 +7915,13 @@ static void test_set_surface_desc(void)
         U1(ddsd).lPitch = 8 * 4;
         ddsd.lpSurface = data;
         hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         if (0)
         {
             /* _Lock causes access violation on Windows. */
             reset_ddsd(&ddsd);
             hr = IDirectDrawSurface4_Lock(surface2, NULL, &ddsd, DDLOCK_WAIT, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             IDirectDrawSurface4_Unlock(surface2, NULL);
         }
 
@@ -7932,12 +7932,12 @@ static void test_set_surface_desc(void)
         U1(ddsd).lPitch = 4 * 4;
         ddsd.lpSurface = data;
         hr = IDirectDrawSurface4_SetSurfaceDesc(surface2, &ddsd, 0);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         reset_ddsd(&ddsd);
         /* Does not crash now after setting user memory for the level. */
         hr = IDirectDrawSurface4_Lock(surface2, NULL, &ddsd, DDLOCK_WAIT, NULL);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         ok(ddsd.lpSurface == data, "Got unexpected lpSurface %p.\n", ddsd.lpSurface);
         IDirectDrawSurface4_Unlock(surface2, NULL);
 
@@ -7948,7 +7948,7 @@ static void test_set_surface_desc(void)
         U1(ddsd).lPitch = 16 * 4;
         ddsd.lpSurface = data;
         hr = IDirectDrawSurface4_SetSurfaceDesc(surface2, &ddsd, 0);
-        todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        todo_wine ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         IDirectDrawSurface4_Release(surface2);
         IDirectDrawSurface4_Release(surface);
@@ -7963,10 +7963,10 @@ static void test_set_surface_desc(void)
     U1(ddsd).lPitch = 8 * 4;
     ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
@@ -7974,7 +7974,7 @@ static void test_set_surface_desc(void)
     ddsd.dwHeight = 8;
     /* Cannot reset lpSurface. */
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_LPSURFACE | DDSD_PITCH;
@@ -7984,7 +7984,7 @@ static void test_set_surface_desc(void)
     U1(ddsd).lPitch = 8 * 4;
     /* Can change the parameters of surface created with DDSD_LPSURFACE. */
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface4_Release(surface);
 
@@ -8011,7 +8011,7 @@ static void test_set_surface_desc(void)
         }
 
         hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
-        ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW, "Got unexpected hr %#lx.\n", hr);
         if (FAILED(hr))
         {
             skip("Cannot create a %s surface, skipping vidmem SetSurfaceDesc test.\n",
@@ -8025,17 +8025,17 @@ static void test_set_surface_desc(void)
         hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
         if (invalid_caps_tests[i].supported)
         {
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         }
         else
         {
-            ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n",
+            ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#lx.\n",
                     invalid_caps_tests[i].name, hr);
 
             /* Check priority of error conditions. */
             ddsd.dwFlags = DDSD_WIDTH;
             hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-            ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n",
+            ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#lx.\n",
                     invalid_caps_tests[i].name, hr);
         }
 
@@ -8044,7 +8044,7 @@ static void test_set_surface_desc(void)
 
 done:
     ref = IDirectDraw4_Release(ddraw);
-    ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Ddraw object not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -8068,7 +8068,7 @@ static void test_user_memory_getdc(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
@@ -8082,17 +8082,17 @@ static void test_user_memory_getdc(void)
     U4(U4(ddsd).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(data, 0xaa, sizeof(data));
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     bitmap = GetCurrentObject(dc, OBJ_BITMAP);
     ok(!!bitmap, "Failed to get bitmap.\n");
     size = GetObjectA(bitmap, sizeof(dib), &dib);
@@ -8101,10 +8101,10 @@ static void test_user_memory_getdc(void)
     BitBlt(dc, 0, 0, 16, 8, NULL, 0, 0, WHITENESS);
     BitBlt(dc, 0, 8, 16, 8, NULL, 0, 0, BLACKNESS);
     hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
-    ok(data[0][0] == 0xffffffff, "Expected color 0xffffffff, got %#x.\n", data[0][0]);
-    ok(data[15][15] == 0x00000000, "Expected color 0x00000000, got %#x.\n", data[15][15]);
+    ok(data[0][0] == 0xffffffff, "Expected color 0xffffffff, got %#lx.\n", data[0][0]);
+    ok(data[15][15] == 0x00000000, "Expected color 0x00000000, got %#lx.\n", data[15][15]);
 
     ddsd.dwFlags = DDSD_LPSURFACE | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PITCH;
     ddsd.lpSurface = data;
@@ -8112,40 +8112,40 @@ static void test_user_memory_getdc(void)
     ddsd.dwHeight = 8;
     U1(ddsd).lPitch = sizeof(*data);
     hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     memset(data, 0xaa, sizeof(data));
     hr = IDirectDrawSurface4_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     BitBlt(dc, 0, 0, 4, 8, NULL, 0, 0, BLACKNESS);
     BitBlt(dc, 1, 1, 2, 2, NULL, 0, 0, WHITENESS);
     hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     for (y = 0; y < 4; y++)
     {
         for (x = 0; x < 4; x++)
         {
             if ((x == 1 || x == 2) && (y == 1 || y == 2))
-                ok(data[y][x] == 0xffffffff, "Expected color 0xffffffff on position %ux%u, got %#x.\n",
+                ok(data[y][x] == 0xffffffff, "Expected color 0xffffffff on position %ux%u, got %#lx.\n",
                         x, y, data[y][x]);
             else
-                ok(data[y][x] == 0x00000000, "Expected color 0x00000000 on position %ux%u, got %#x.\n",
+                ok(data[y][x] == 0x00000000, "Expected color 0x00000000 on position %ux%u, got %#lx.\n",
                         x, y, data[y][x]);
         }
     }
-    ok(data[0][5] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 5x0, got %#x.\n",
+    ok(data[0][5] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 5x0, got %#lx.\n",
             data[0][5]);
-    ok(data[7][3] == 0x00000000, "Expected color 0x00000000 on position 3x7, got %#x.\n",
+    ok(data[7][3] == 0x00000000, "Expected color 0x00000000 on position 3x7, got %#lx.\n",
             data[7][3]);
-    ok(data[7][4] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 4x7, got %#x.\n",
+    ok(data[7][4] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 4x7, got %#lx.\n",
             data[7][4]);
-    ok(data[8][0] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 0x8, got %#x.\n",
+    ok(data[8][0] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 0x8, got %#lx.\n",
             data[8][0]);
 
     IDirectDrawSurface4_Release(surface);
     ref = IDirectDraw4_Release(ddraw);
-    ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Ddraw object not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -8163,7 +8163,7 @@ static void test_sysmem_overlay(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
@@ -8177,10 +8177,10 @@ static void test_sysmem_overlay(void)
     U3(U4(ddsd).ddpfPixelFormat).dwGBitMask = 0x0000ff00;
     U4(U4(ddsd).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DDERR_NOOVERLAYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOOVERLAYHW, "Got unexpected hr %#lx.\n", hr);
 
     ref = IDirectDraw4_Release(ddraw);
-    ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Ddraw object not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -8208,7 +8208,7 @@ static void test_primary_palette(void)
         return;
     }
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -8216,22 +8216,22 @@ static void test_primary_palette(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     U5(surface_desc).dwBackBufferCount = 1;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetAttachedSurface(primary, &surface_caps, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#lx.\n", hr);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     hr = IDirectDraw4_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256, palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)palette);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
-    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
-    ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#x.\n", palette_caps);
+    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#lx.\n", hr);
+    ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#lx.\n", palette_caps);
 
     hr = IDirectDrawSurface4_SetPalette(primary, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     /* The Windows 8 testbot attaches the palette to the backbuffer as well,
      * and is generally somewhat broken with respect to 8 bpp / palette
@@ -8244,99 +8244,99 @@ static void test_primary_palette(void)
         /* The Windows 8 testbot keeps extra references to the primary and
          * backbuffer while in 8 bpp mode. */
         hr = IDirectDraw4_RestoreDisplayMode(ddraw);
-        ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#lx.\n", hr);
         goto done;
     }
 
     refcount = get_refcount((IUnknown *)palette);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
-    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#lx.\n", hr);
     ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_PRIMARYSURFACE | DDPCAPS_ALLOW256),
-            "Got unexpected palette caps %#x.\n", palette_caps);
+            "Got unexpected palette caps %#lx.\n", palette_caps);
 
     hr = IDirectDrawSurface4_SetPalette(primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)palette);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
-    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
-    ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#x.\n", palette_caps);
+    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#lx.\n", hr);
+    ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#lx.\n", palette_caps);
 
     hr = IDirectDrawSurface4_SetPalette(primary, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)palette);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface4_GetPalette(primary, &tmp);
-    ok(SUCCEEDED(hr), "Failed to get palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette, hr %#lx.\n", hr);
     ok(tmp == palette, "Got unexpected palette %p, expected %p.\n", tmp, palette);
     IDirectDrawPalette_Release(tmp);
     hr = IDirectDrawSurface4_GetPalette(backbuffer, &tmp);
-    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirectDrawPalette_Release(palette);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     /* Note that this only seems to work when the palette is attached to the
      * primary surface. When attached to a regular surface, attempting to get
      * the palette here will cause an access violation. */
     hr = IDirectDrawSurface4_GetPalette(primary, &tmp);
-    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
-    ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 8, "Got unexpected bit count %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %lu.\n", surface_desc.dwWidth);
+    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %lu.\n", surface_desc.dwHeight);
+    ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 8, "Got unexpected bit count %lu.\n",
             U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount);
 
     hr = set_display_mode(ddraw, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %lu.\n", surface_desc.dwWidth);
+    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %lu.\n", surface_desc.dwHeight);
     ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 32
             || U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 24,
-            "Got unexpected bit count %u.\n", U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount);
+            "Got unexpected bit count %lu.\n", U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount);
 
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface4_GetSurfaceDesc(primary, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %lu.\n", surface_desc.dwWidth);
+    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %lu.\n", surface_desc.dwHeight);
     ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 32
             || U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 24,
-            "Got unexpected bit count %u.\n", U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount);
+            "Got unexpected bit count %lu.\n", U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount);
 
 done:
     refcount = IDirectDrawSurface4_Release(backbuffer);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawSurface4_Release(primary);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -8366,7 +8366,7 @@ static void test_surface_attachment(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -8376,14 +8376,14 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 128;
     surface_desc.dwHeight = 128;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_GetAttachedSurface(surface1, &caps, &surface2);
-    ok(SUCCEEDED(hr), "Failed to get mip level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get mip level, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetAttachedSurface(surface2, &caps, &surface3);
-    ok(SUCCEEDED(hr), "Failed to get mip level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get mip level, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetAttachedSurface(surface3, &caps, &surface4);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
 
     surface_count = 0;
     IDirectDrawSurface4_EnumAttachedSurfaces(surface1, &surface_count, surface_counter);
@@ -8402,20 +8402,20 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 16;
     surface_desc.dwHeight = 16;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_AddAttachedSurface(surface1, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_AddAttachedSurface(surface4, surface1);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_AddAttachedSurface(surface3, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_AddAttachedSurface(surface4, surface3);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_AddAttachedSurface(surface2, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_AddAttachedSurface(surface4, surface2);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface4_Release(surface4);
 
@@ -8426,27 +8426,27 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 16;
     surface_desc.dwHeight = 16;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     if (SUCCEEDED(hr = IDirectDrawSurface4_AddAttachedSurface(surface1, surface4)))
     {
         skip("Running on refrast, skipping some tests.\n");
         hr = IDirectDrawSurface4_DeleteAttachedSurface(surface1, 0, surface4);
-        ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
     }
     else
     {
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface4_AddAttachedSurface(surface4, surface1);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface4_AddAttachedSurface(surface3, surface4);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface4_AddAttachedSurface(surface4, surface3);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface4_AddAttachedSurface(surface2, surface4);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface4_AddAttachedSurface(surface4, surface2);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     }
 
     IDirectDrawSurface4_Release(surface4);
@@ -8455,7 +8455,7 @@ static void test_surface_attachment(void)
     IDirectDrawSurface4_Release(surface1);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Try a single primary and two offscreen plain surfaces. */
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -8463,7 +8463,7 @@ static void test_surface_attachment(void)
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -8472,7 +8472,7 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = registry_mode.dmPelsWidth;
     surface_desc.dwHeight = registry_mode.dmPelsHeight;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -8481,7 +8481,7 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = registry_mode.dmPelsWidth;
     surface_desc.dwHeight = registry_mode.dmPelsHeight;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* This one has a different size. */
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -8491,33 +8491,33 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 128;
     surface_desc.dwHeight = 128;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_AddAttachedSurface(surface1, surface2);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     /* Try the reverse without detaching first. */
     hr = IDirectDrawSurface4_AddAttachedSurface(surface2, surface1);
-    ok(hr == DDERR_SURFACEALREADYATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACEALREADYATTACHED, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_DeleteAttachedSurface(surface1, 0, surface2);
-    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_AddAttachedSurface(surface2, surface1);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     /* Try to detach reversed. */
     hr = IDirectDrawSurface4_DeleteAttachedSurface(surface1, 0, surface2);
-    ok(hr == DDERR_CANNOTDETACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTDETACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_DeleteAttachedSurface(surface2, 0, surface1);
-    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_AddAttachedSurface(surface2, surface3);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_DeleteAttachedSurface(surface2, 0, surface3);
-    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_AddAttachedSurface(surface1, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_AddAttachedSurface(surface4, surface1);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface4_Release(surface4);
     IDirectDrawSurface4_Release(surface3);
@@ -8532,7 +8532,7 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 64;
     surface_desc.dwHeight = 64;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -8545,26 +8545,26 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 32;
     surface_desc.dwHeight = 32;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
     surface_desc.dwWidth = 64;
     surface_desc.dwHeight = 64;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
     surface_desc.dwWidth = 128;
     surface_desc.dwHeight = 128;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
-    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     if (SUCCEEDED(hr))
         IDirectDrawSurface4_DeleteAttachedSurface(surface1, 0, surface2);
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface3);
-    ok(hr == D3D_OK, "Failed to attach depth buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to attach depth buffer, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_DeleteAttachedSurface(surface1, 0, surface3);
-    ok(hr == D3D_OK, "Failed to detach depth buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to detach depth buffer, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4);
-    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface4_Release(surface4);
     IDirectDrawSurface4_Release(surface3);
@@ -8585,72 +8585,72 @@ static void test_surface_attachment(void)
     U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x07e0;
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x001f;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
     U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_ZBUFFER;
     U1(U4(surface_desc).ddpfPixelFormat).dwZBufferBitDepth = 16;
     U3(U4(surface_desc).ddpfPixelFormat).dwZBitMask = 0x0000ffff;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_QueryInterface(surface1, &IID_IDirectDrawSurface, (void **)&surface1v1);
-    ok(SUCCEEDED(hr), "Failed to get interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get interface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_QueryInterface(surface2, &IID_IDirectDrawSurface, (void **)&surface2v1);
-    ok(SUCCEEDED(hr), "Failed to get interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get interface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_AddAttachedSurface(surface1, surface2);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)surface2);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
     refcount = get_refcount((IUnknown *)surface2v1);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     hr = IDirectDrawSurface4_AddAttachedSurface(surface1, surface2);
-    ok(hr == DDERR_SURFACEALREADYATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACEALREADYATTACHED, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface1v1, surface2v1);
-    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface1v1, 0, surface2v1);
-    ok(hr == DDERR_SURFACENOTATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACENOTATTACHED, "Got unexpected hr %#lx.\n", hr);
 
     /* Attaching while already attached to other surface. */
     hr = IDirectDrawSurface4_AddAttachedSurface(surface3, surface2);
-    todo_wine ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    todo_wine ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_DeleteAttachedSurface(surface3, 0, surface2);
-    todo_wine ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    todo_wine ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
     IDirectDrawSurface4_Release(surface3);
 
     hr = IDirectDrawSurface4_DeleteAttachedSurface(surface1, 0, surface2);
-    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)surface2);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     refcount = get_refcount((IUnknown *)surface2v1);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     /* DeleteAttachedSurface() when attaching via IDirectDrawSurface. */
     hr = IDirectDrawSurface_AddAttachedSurface(surface1v1, surface2v1);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_DeleteAttachedSurface(surface1, 0, surface2);
-    ok(hr == DDERR_SURFACENOTATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACENOTATTACHED, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface1v1, 0, surface2v1);
-    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
     refcount = IDirectDrawSurface4_Release(surface2);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawSurface4_Release(surface1);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     /* Automatic detachment on release. */
     hr = IDirectDrawSurface_AddAttachedSurface(surface1v1, surface2v1);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)surface2v1);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawSurface_Release(surface1v1);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawSurface_Release(surface2v1);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -8686,7 +8686,7 @@ static void test_private_data(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     reset_ddsd(&surface_desc);
     surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
@@ -8694,27 +8694,27 @@ static void test_private_data(void)
     surface_desc.dwHeight = 4;
     surface_desc.dwWidth = 4;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* NULL pointers are not valid, but don't cause a crash. */
     hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL,
             sizeof(IUnknown *), DDSPD_IUNKNOWNPOINTER);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, 0, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, 1, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* DDSPD_IUNKNOWNPOINTER needs sizeof(IUnknown *) bytes of data. */
     hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
             0, DDSPD_IUNKNOWNPOINTER);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
             5, DDSPD_IUNKNOWNPOINTER);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
             sizeof(ddraw) * 2, DDSPD_IUNKNOWNPOINTER);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Note that with a size != 0 and size != sizeof(IUnknown *) and
      * DDSPD_IUNKNOWNPOINTER set SetPrivateData in ddraw4 and ddraw7
@@ -8723,85 +8723,85 @@ static void test_private_data(void)
      * that depends on this we don't care about this behavior. */
     hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
             sizeof(ddraw), DDSPD_IUNKNOWNPOINTER);
-    ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
             0, DDSPD_IUNKNOWNPOINTER);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     size = sizeof(ptr);
     hr = IDirectDrawSurface4_GetPrivateData(surface, &ddraw_private_data_test_guid, &ptr, &size);
-    ok(SUCCEEDED(hr), "Failed to get private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get private data, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_FreePrivateData(surface, &ddraw_private_data_test_guid);
-    ok(SUCCEEDED(hr), "Failed to free private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to free private data, hr %#lx.\n", hr);
 
     refcount = get_refcount((IUnknown *)ddraw);
     hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
             sizeof(ddraw), DDSPD_IUNKNOWNPOINTER);
-    ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
     refcount2 = get_refcount((IUnknown *)ddraw);
-    ok(refcount2 == refcount + 1, "Got unexpected refcount %u.\n", refcount2);
+    ok(refcount2 == refcount + 1, "Got unexpected refcount %lu.\n", refcount2);
 
     hr = IDirectDrawSurface4_FreePrivateData(surface, &ddraw_private_data_test_guid);
-    ok(SUCCEEDED(hr), "Failed to free private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to free private data, hr %#lx.\n", hr);
     refcount2 = get_refcount((IUnknown *)ddraw);
-    ok(refcount2 == refcount, "Got unexpected refcount %u.\n", refcount2);
+    ok(refcount2 == refcount, "Got unexpected refcount %lu.\n", refcount2);
 
     hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
             sizeof(ddraw), DDSPD_IUNKNOWNPOINTER);
-    ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, surface,
             sizeof(surface), DDSPD_IUNKNOWNPOINTER);
-    ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
     refcount2 = get_refcount((IUnknown *)ddraw);
-    ok(refcount2 == refcount, "Got unexpected refcount %u.\n", refcount2);
+    ok(refcount2 == refcount, "Got unexpected refcount %lu.\n", refcount2);
 
     hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
             sizeof(ddraw), DDSPD_IUNKNOWNPOINTER);
-    ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
     size = 2 * sizeof(ptr);
     hr = IDirectDrawSurface4_GetPrivateData(surface, &ddraw_private_data_test_guid, &ptr, &size);
-    ok(SUCCEEDED(hr), "Failed to get private data, hr %#x.\n", hr);
-    ok(size == sizeof(ddraw), "Got unexpected size %u.\n", size);
+    ok(SUCCEEDED(hr), "Failed to get private data, hr %#lx.\n", hr);
+    ok(size == sizeof(ddraw), "Got unexpected size %lu.\n", size);
     refcount2 = get_refcount(ptr);
     /* Object is NOT addref'ed by the getter. */
     ok(ptr == (IUnknown *)ddraw, "Returned interface pointer is %p, expected %p.\n", ptr, ddraw);
-    ok(refcount2 == refcount + 1, "Got unexpected refcount %u.\n", refcount2);
+    ok(refcount2 == refcount + 1, "Got unexpected refcount %lu.\n", refcount2);
 
     ptr = (IUnknown *)0xdeadbeef;
     size = 1;
     hr = IDirectDrawSurface4_GetPrivateData(surface, &ddraw_private_data_test_guid, NULL, &size);
-    ok(hr == DDERR_MOREDATA, "Got unexpected hr %#x.\n", hr);
-    ok(size == sizeof(ddraw), "Got unexpected size %u.\n", size);
+    ok(hr == DDERR_MOREDATA, "Got unexpected hr %#lx.\n", hr);
+    ok(size == sizeof(ddraw), "Got unexpected size %lu.\n", size);
     size = 2 * sizeof(ptr);
     hr = IDirectDrawSurface4_GetPrivateData(surface, &ddraw_private_data_test_guid, NULL, &size);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
-    ok(size == 2 * sizeof(ptr), "Got unexpected size %u.\n", size);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
+    ok(size == 2 * sizeof(ptr), "Got unexpected size %lu.\n", size);
     size = 1;
     hr = IDirectDrawSurface4_GetPrivateData(surface, &ddraw_private_data_test_guid, &ptr, &size);
-    ok(hr == DDERR_MOREDATA, "Got unexpected hr %#x.\n", hr);
-    ok(size == sizeof(ddraw), "Got unexpected size %u.\n", size);
+    ok(hr == DDERR_MOREDATA, "Got unexpected hr %#lx.\n", hr);
+    ok(size == sizeof(ddraw), "Got unexpected size %lu.\n", size);
     ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
     hr = IDirectDrawSurface4_GetPrivateData(surface, &ddraw_private_data_test_guid2, NULL, NULL);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     size = 0xdeadbabe;
     hr = IDirectDrawSurface4_GetPrivateData(surface, &ddraw_private_data_test_guid2, &ptr, &size);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
-    ok(size == 0xdeadbabe, "Got unexpected size %u.\n", size);
+    ok(size == 0xdeadbabe, "Got unexpected size %lu.\n", size);
     hr = IDirectDrawSurface4_GetPrivateData(surface, &ddraw_private_data_test_guid, NULL, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     refcount3 = IDirectDrawSurface4_Release(surface);
-    ok(!refcount3, "Got unexpected refcount %u.\n", refcount3);
+    ok(!refcount3, "Got unexpected refcount %lu.\n", refcount3);
 
     /* Destroying the surface frees the reference held on the private data. It also frees
      * the reference the surface is holding on its creating object. */
     refcount2 = get_refcount((IUnknown *)ddraw);
-    ok(refcount2 == refcount - 1, "Got unexpected refcount %u.\n", refcount2);
+    ok(refcount2 == refcount - 1, "Got unexpected refcount %lu.\n", refcount2);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw4_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) == (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP))
     {
         reset_ddsd(&surface_desc);
@@ -8811,14 +8811,14 @@ static void test_private_data(void)
         surface_desc.dwWidth = 4;
         U2(surface_desc).dwMipMapCount = 2;
         hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
         hr = IDirectDrawSurface4_GetAttachedSurface(surface, &caps, &surface2);
-        ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#lx.\n", hr);
 
         hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, data, sizeof(data), 0);
-        ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
         hr = IDirectDrawSurface4_GetPrivateData(surface2, &ddraw_private_data_test_guid, NULL, NULL);
-        ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
 
         IDirectDrawSurface4_Release(surface2);
         IDirectDrawSurface4_Release(surface);
@@ -8827,7 +8827,7 @@ static void test_private_data(void)
         skip("Mipmapped textures not supported, skipping mipmap private data test.\n");
 
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -8910,7 +8910,7 @@ static void test_pixel_format(void)
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
     if (FAILED(hr))
     {
-        skip("Failed to set cooperative level, hr %#x.\n", hr);
+        skip("Failed to set cooperative level, hr %#lx.\n", hr);
         goto cleanup;
     }
 
@@ -8920,9 +8920,9 @@ static void test_pixel_format(void)
     if (hdc2)
     {
         hr = IDirectDraw4_CreateClipper(ddraw, 0, &clipper, NULL);
-        ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
         hr = IDirectDrawClipper_SetHWnd(clipper, 0, window2);
-        ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
 
         test_format = GetPixelFormat(hdc);
         ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -8937,7 +8937,7 @@ static void test_pixel_format(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -8951,7 +8951,7 @@ static void test_pixel_format(void)
     if (clipper)
     {
         hr = IDirectDrawSurface4_SetClipper(primary, clipper);
-        ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
 
         test_format = GetPixelFormat(hdc);
         ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -8966,18 +8966,18 @@ static void test_pixel_format(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     ddsd.dwWidth = ddsd.dwHeight = 64;
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &offscreen, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     hr = IDirectDrawSurface4_Blt(offscreen, NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#lx.\n", hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
 
     hr = IDirectDrawSurface4_Blt(primary, NULL, offscreen, NULL, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to blit to primary surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit to primary surface, hr %#lx.\n", hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -9102,7 +9102,7 @@ static void test_create_surface_pitch(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ((63 * 4) + 8) * 63);
 
@@ -9125,33 +9125,33 @@ static void test_create_surface_pitch(void)
         if (test_data[i].flags_in & DDSD_LPSURFACE)
         {
             HRESULT expected_hr = SUCCEEDED(test_data[i].hr) ? DDERR_INVALIDPARAMS : test_data[i].hr;
-            ok(hr == expected_hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, expected_hr);
+            ok(hr == expected_hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, expected_hr);
             surface_desc.lpSurface = mem;
             hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
         }
         if ((test_data[i].caps & DDSCAPS_VIDEOMEMORY) && hr == DDERR_NODIRECTDRAWHW)
             continue;
-        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
         if (FAILED(hr))
             continue;
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &surface_desc);
-        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#lx.\n", i, hr);
         ok((surface_desc.dwFlags & flags_mask) == test_data[i].flags_out,
-                "Test %u: Got unexpected flags %#x, expected %#x.\n",
+                "Test %u: Got unexpected flags %#lx, expected %#lx.\n",
                 i, surface_desc.dwFlags & flags_mask, test_data[i].flags_out);
         /* The pitch for textures seems to be implementation specific. */
         if (!(test_data[i].caps & DDSCAPS_TEXTURE))
         {
             if (is_ddraw64 && test_data[i].pitch_out32 != test_data[i].pitch_out64)
                 todo_wine ok(U1(surface_desc).lPitch == test_data[i].pitch_out64,
-                        "Test %u: Got unexpected pitch %u, expected %u.\n",
+                        "Test %u: Got unexpected pitch %lu, expected %lu.\n",
                         i, U1(surface_desc).lPitch, test_data[i].pitch_out64);
             else
                 ok(U1(surface_desc).lPitch == test_data[i].pitch_out32,
-                        "Test %u: Got unexpected pitch %u, expected %u.\n",
+                        "Test %u: Got unexpected pitch %lu, expected %lu.\n",
                         i, U1(surface_desc).lPitch, test_data[i].pitch_out32);
         }
         ok(!surface_desc.lpSurface, "Test %u: Got unexpected lpSurface %p.\n", i, surface_desc.lpSurface);
@@ -9161,7 +9161,7 @@ static void test_create_surface_pitch(void)
 
     HeapFree(GetProcessHeap(), 0, mem);
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -9201,12 +9201,12 @@ static void test_mipmap(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw4_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) != (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP))
     {
         skip("Mipmapped textures not supported, skipping tests.\n");
@@ -9226,18 +9226,18 @@ static void test_mipmap(void)
         if (tests[i].flags & DDSD_MIPMAPCOUNT)
             U2(surface_desc).dwMipMapCount = tests[i].mipmap_count_in;
         hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         if (FAILED(hr))
             continue;
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &surface_desc);
-        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#lx.\n", i, hr);
         ok(surface_desc.dwFlags & DDSD_MIPMAPCOUNT,
-                "Test %u: Got unexpected flags %#x.\n", i, surface_desc.dwFlags);
+                "Test %u: Got unexpected flags %#lx.\n", i, surface_desc.dwFlags);
         ok(U2(surface_desc).dwMipMapCount == tests[i].mipmap_count_out,
-                "Test %u: Got unexpected mipmap count %u.\n", i, U2(surface_desc).dwMipMapCount);
+                "Test %u: Got unexpected mipmap count %lu.\n", i, U2(surface_desc).dwMipMapCount);
 
         surface_base = surface;
         IDirectDrawSurface4_AddRef(surface_base);
@@ -9245,31 +9245,31 @@ static void test_mipmap(void)
         while (mipmap_count > 1)
         {
             hr = IDirectDrawSurface4_GetAttachedSurface(surface_base, &caps, &surface_mip);
-            ok(SUCCEEDED(hr), "Test %u, %u: Failed to get attached surface, hr %#x.\n", i, mipmap_count, hr);
+            ok(SUCCEEDED(hr), "Test %u, %u: Failed to get attached surface, hr %#lx.\n", i, mipmap_count, hr);
 
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface4_GetSurfaceDesc(surface_base, &surface_desc);
-            ok(SUCCEEDED(hr), "Test %u, %u: Failed to get surface desc, hr %#x.\n", i, mipmap_count, hr);
+            ok(SUCCEEDED(hr), "Test %u, %u: Failed to get surface desc, hr %#lx.\n", i, mipmap_count, hr);
             ok(surface_desc.dwFlags & DDSD_MIPMAPCOUNT,
-                    "Test %u, %u: Got unexpected flags %#x.\n", i, mipmap_count, surface_desc.dwFlags);
+                    "Test %u, %u: Got unexpected flags %#lx.\n", i, mipmap_count, surface_desc.dwFlags);
             ok(U2(surface_desc).dwMipMapCount == mipmap_count,
-                    "Test %u, %u: Got unexpected mipmap count %u.\n",
+                    "Test %u, %u: Got unexpected mipmap count %lu.\n",
                     i, mipmap_count, U2(surface_desc).dwMipMapCount);
 
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface4_Lock(surface_base, NULL, &surface_desc, 0, NULL);
-            ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#x.\n", i, mipmap_count, hr);
+            ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#lx.\n", i, mipmap_count, hr);
             ok(surface_desc.dwMipMapCount == mipmap_count,
-                    "Test %u, %u: unexpected change of mipmap count %u.\n",
+                    "Test %u, %u: unexpected change of mipmap count %lu.\n",
                     i, mipmap_count, surface_desc.dwMipMapCount);
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface4_Lock(surface_mip, NULL, &surface_desc, 0, NULL);
-            ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#x.\n", i, mipmap_count, hr);
+            ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#lx.\n", i, mipmap_count, hr);
             ok(surface_desc.dwMipMapCount == mipmap_count - 1,
-                    "Test %u, %u: Child mipmap count unexpected %u\n", i, mipmap_count, surface_desc.dwMipMapCount);
+                    "Test %u, %u: Child mipmap count unexpected %lu\n", i, mipmap_count, surface_desc.dwMipMapCount);
             IDirectDrawSurface4_Unlock(surface_mip, NULL);
             IDirectDrawSurface4_Unlock(surface_base, NULL);
 
@@ -9283,7 +9283,7 @@ static void test_mipmap(void)
     }
 
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -9308,12 +9308,12 @@ static void test_palette_complex(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw4_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) != (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP))
     {
         skip("Mipmapped textures not supported, skipping mipmap palette test.\n");
@@ -9332,28 +9332,28 @@ static void test_palette_complex(void)
     U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
     U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount = 8;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     hr = IDirectDraw4_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     palette_entries[1].peRed = 0xff;
     palette_entries[1].peGreen = 0x80;
     hr = IDirectDraw4_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette_mipmap, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     palette2 = (void *)0xdeadbeef;
     hr = IDirectDrawSurface4_GetPalette(surface, &palette2);
-    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx.\n", hr);
     ok(!palette2, "Got unexpected palette %p.\n", palette2);
     hr = IDirectDrawSurface4_SetPalette(surface, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetPalette(surface, &palette2);
-    ok(SUCCEEDED(hr), "Failed to get palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette, hr %#lx.\n", hr);
     ok(palette == palette2, "Got unexpected palette %p.\n", palette2);
     IDirectDrawPalette_Release(palette2);
 
@@ -9362,46 +9362,46 @@ static void test_palette_complex(void)
     for (i = 0; i < 7; ++i)
     {
         hr = IDirectDrawSurface4_GetAttachedSurface(mipmap, &caps, &tmp);
-        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#lx.\n", i, hr);
         palette2 = (void *)0xdeadbeef;
         hr = IDirectDrawSurface4_GetPalette(tmp, &palette2);
-        ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x, i %u.\n", hr, i);
+        ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx, i %u.\n", hr, i);
         ok(!palette2, "Got unexpected palette %p, i %u.\n", palette2, i);
 
         hr = IDirectDrawSurface4_SetPalette(tmp, palette_mipmap);
-        ok(SUCCEEDED(hr), "Failed to set palette, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to set palette, i %u, hr %#lx.\n", i, hr);
 
         hr = IDirectDrawSurface4_GetPalette(tmp, &palette2);
-        ok(SUCCEEDED(hr), "Failed to get palette, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get palette, i %u, hr %#lx.\n", i, hr);
         ok(palette_mipmap == palette2, "Got unexpected palette %p.\n", palette2);
         IDirectDrawPalette_Release(palette2);
 
         hr = IDirectDrawSurface4_GetDC(tmp, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC, i %u, hr %#lx.\n", i, hr);
         count = GetDIBColorTable(dc, 1, 1, &rgbquad);
         ok(count == 1, "Expected count 1, got %u.\n", count);
         ok(rgbquad.rgbRed == 0xff, "Expected rgbRed = 0xff, got %#x.\n", rgbquad.rgbRed);
         ok(rgbquad.rgbGreen == 0x80, "Expected rgbGreen = 0x80, got %#x.\n", rgbquad.rgbGreen);
         ok(rgbquad.rgbBlue == 0x0, "Expected rgbBlue = 0x0, got %#x.\n", rgbquad.rgbBlue);
         hr = IDirectDrawSurface4_ReleaseDC(tmp, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC, i %u, hr %#lx.\n", i, hr);
 
         IDirectDrawSurface4_Release(mipmap);
         mipmap = tmp;
     }
 
     hr = IDirectDrawSurface4_GetAttachedSurface(mipmap, &caps, &tmp);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface4_Release(mipmap);
     refcount = IDirectDrawSurface4_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette_mipmap);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -9432,7 +9432,7 @@ static void test_p8_blit(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     is_warp = ddraw_is_warp(ddraw);
 
     memset(palette_entries, 0, sizeof(palette_entries));
@@ -9442,14 +9442,14 @@ static void test_p8_blit(void)
     palette_entries[4].peRed = 0xff;
     hr = IDirectDraw4_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
     palette_entries[1].peBlue = 0xff;
     palette_entries[2].peGreen = 0xff;
     palette_entries[3].peRed = 0xff;
     palette_entries[4].peFlags = 0x0;
     hr = IDirectDraw4_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -9461,11 +9461,11 @@ static void test_p8_blit(void)
     U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
     U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount = 8;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &src, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &dst_p8, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_SetPalette(dst_p8, palette2);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -9481,34 +9481,34 @@ static void test_p8_blit(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(U4(surface_desc).ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface4_Lock(src, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#lx.\n", hr);
     memcpy(surface_desc.lpSurface, src_data, sizeof(src_data));
     hr = IDirectDrawSurface4_Unlock(src, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Lock(dst_p8, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#lx.\n", hr);
     memcpy(surface_desc.lpSurface, src_data2, sizeof(src_data2));
     hr = IDirectDrawSurface4_Unlock(dst_p8, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#lx.\n", hr);
 
     fx.dwSize = sizeof(fx);
     fx.dwFillColor = 0xdeadbeef;
     hr = IDirectDrawSurface4_Blt(dst, NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
-    ok(SUCCEEDED(hr), "Failed to color fill %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to color fill %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_SetPalette(src, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(dst, NULL, src, NULL, DDBLT_WAIT, NULL);
     /* The r500 Windows 7 driver returns E_NOTIMPL. r200 on Windows XP works.
      * The Geforce 7 driver on Windows Vista returns E_FAIL. Newer Nvidia GPUs work. */
     ok(SUCCEEDED(hr) || broken(hr == E_NOTIMPL) || broken(hr == E_FAIL),
-            "Failed to blit, hr %#x.\n", hr);
+            "Failed to blit, hr %#lx.\n", hr);
 
     if (SUCCEEDED(hr))
     {
@@ -9519,7 +9519,7 @@ static void test_p8_blit(void)
              * blits see below. */
             todo_wine ok(compare_color(color, expected[x], 0)
                     || broken(is_warp && compare_color(color, 0x00000000, 0)),
-                    "Pixel %u: Got color %#x, expected %#x.\n",
+                    "Pixel %u: Got color %#lx, expected %#lx.\n",
                     x, color, expected[x]);
         }
     }
@@ -9527,10 +9527,10 @@ static void test_p8_blit(void)
     fx.ddckSrcColorkey.dwColorSpaceHighValue = 0x2;
     fx.ddckSrcColorkey.dwColorSpaceLowValue = 0x2;
     hr = IDirectDrawSurface4_Blt(dst_p8, NULL, src, NULL, DDBLT_WAIT | DDBLT_KEYSRCOVERRIDE, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Lock(dst_p8, NULL, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#lx.\n", hr);
     /* A color keyed P8 blit doesn't do anything on WARP - it just leaves the data in the destination
      * surface untouched. Error checking (DDBLT_KEYSRC without a key
      * for example) also works as expected.
@@ -9541,7 +9541,7 @@ static void test_p8_blit(void)
             || broken(is_warp && !memcmp(surface_desc.lpSurface, src_data2, sizeof(src_data2))),
             "Got unexpected P8 color key blit result.\n");
     hr = IDirectDrawSurface4_Unlock(dst_p8, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#lx.\n", hr);
 
     IDirectDrawSurface4_Release(src);
     IDirectDrawSurface4_Release(dst);
@@ -9550,7 +9550,7 @@ static void test_p8_blit(void)
     IDirectDrawPalette_Release(palette2);
 
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -9612,95 +9612,95 @@ static void test_material(void)
     }
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     material = create_emissive_material(device, 0.0f, 1.0f, 0.0f, 0.0f);
     hr = IDirect3DMaterial3_GetHandle(material, device, &mat_handle);
-    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetLightState(device, D3DLIGHTSTATE_MATERIAL, &tmp);
-    ok(SUCCEEDED(hr), "Failed to get light state, hr %#x.\n", hr);
-    ok(!tmp, "Got unexpected material handle %#x.\n", tmp);
+    ok(SUCCEEDED(hr), "Failed to get light state, hr %#lx.\n", hr);
+    ok(!tmp, "Got unexpected material handle %#lx.\n", tmp);
     hr = IDirect3DDevice3_SetLightState(device, D3DLIGHTSTATE_MATERIAL, mat_handle);
-    ok(SUCCEEDED(hr), "Failed to set material state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set material state, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_GetLightState(device, D3DLIGHTSTATE_MATERIAL, &tmp);
-    ok(SUCCEEDED(hr), "Failed to get light state, hr %#x.\n", hr);
-    ok(tmp == mat_handle, "Got unexpected material handle %#x, expected %#x.\n", tmp, mat_handle);
+    ok(SUCCEEDED(hr), "Failed to get light state, hr %#lx.\n", hr);
+    ok(tmp == mat_handle, "Got unexpected material handle %#lx, expected %#lx.\n", tmp, mat_handle);
     hr = IDirect3DDevice3_SetLightState(device, D3DLIGHTSTATE_MATERIAL, 0);
-    ok(SUCCEEDED(hr), "Failed to set material state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set material state, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_GetLightState(device, D3DLIGHTSTATE_MATERIAL, &tmp);
-    ok(SUCCEEDED(hr), "Failed to get light state, hr %#x.\n", hr);
-    ok(!tmp, "Got unexpected material handle %#x.\n", tmp);
+    ok(SUCCEEDED(hr), "Failed to get light state, hr %#lx.\n", hr);
+    ok(!tmp, "Got unexpected material handle %#lx.\n", tmp);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect,
                 D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice3_SetLightState(device, D3DLIGHTSTATE_MATERIAL, test_data[i].material ? mat_handle : 0);
-        ok(SUCCEEDED(hr), "Failed to set material state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set material state, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice3_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
                 D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE, test_data[i].data, 4, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice3_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, test_data[i].expected_color, 1),
-                "Got unexpected color 0x%08x, test %u.\n", color, i);
+                "Got unexpected color 0x%08lx, test %u.\n", color, i);
     }
 
     destroy_material(material);
     material = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f);
     hr = IDirect3DMaterial3_GetHandle(material, device, &mat_handle);
-    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get material handle, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_SetBackground(viewport, mat_handle);
-    ok(SUCCEEDED(hr), "Failed to set viewport background, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport background, hr %#lx.\n", hr);
     hr = IDirect3DViewport3_GetBackground(viewport, &tmp, &valid);
-    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#x.\n", hr);
-    ok(tmp == mat_handle, "Got unexpected material handle %#x, expected %#x.\n", tmp, mat_handle);
+    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#lx.\n", hr);
+    ok(tmp == mat_handle, "Got unexpected material handle %#lx, expected %#lx.\n", tmp, mat_handle);
     ok(valid, "Got unexpected valid %#x.\n", valid);
     hr = IDirect3DViewport3_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DViewport3_SetBackground(viewport, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport3_GetBackground(viewport, &tmp, &valid);
-    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#x.\n", hr);
-    ok(tmp == mat_handle, "Got unexpected material handle %#x, expected %#x.\n", tmp, mat_handle);
+    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#lx.\n", hr);
+    ok(tmp == mat_handle, "Got unexpected material handle %#lx, expected %#lx.\n", tmp, mat_handle);
     ok(valid, "Got unexpected valid %#x.\n", valid);
     hr = IDirect3DViewport3_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     destroy_viewport(device, viewport);
     viewport = create_viewport(device, 0, 0, 640, 480);
 
     hr = IDirect3DViewport3_GetBackground(viewport, &tmp, &valid);
-    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#x.\n", hr);
-    ok(!tmp, "Got unexpected material handle %#x.\n", tmp);
+    ok(SUCCEEDED(hr), "Failed to get viewport background, hr %#lx.\n", hr);
+    ok(!tmp, "Got unexpected material handle %#lx.\n", tmp);
     ok(!valid, "Got unexpected valid %#x.\n", valid);
     hr = IDirect3DViewport3_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00000000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     destroy_viewport(device, viewport);
     destroy_material(material);
     IDirectDrawSurface4_Release(rt);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -9746,7 +9746,7 @@ static void test_palette_gdi(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -9758,7 +9758,7 @@ static void test_palette_gdi(void)
     U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
     U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount = 8;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* Avoid colors from the Windows default palette. */
     memset(palette_entries, 0, sizeof(palette_entries));
@@ -9770,7 +9770,7 @@ static void test_palette_gdi(void)
     palette_entries[4].peBlue = 0x15;
     hr = IDirectDraw4_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     /* If there is no palette assigned and the display mode is not 8 bpp, some
      * drivers refuse to create a DC while others allow it. If a DC is created,
@@ -9783,9 +9783,9 @@ static void test_palette_gdi(void)
      * contains uninitialized garbage. See comments below for the P8 case. */
 
     hr = IDirectDrawSurface4_SetPalette(surface, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     ddraw_palette_handle = SelectPalette(dc, GetStockObject(DEFAULT_PALETTE), FALSE);
     ok(ddraw_palette_handle == GetStockObject(DEFAULT_PALETTE),
             "Got unexpected palette %p, expected %p.\n",
@@ -9812,7 +9812,7 @@ static void test_palette_gdi(void)
     palette_entries[4].peGreen = 0x24;
     palette_entries[4].peBlue = 0x25;
     hr = IDirectDrawPalette_SetEntries(palette, 0, 4, 1, &palette_entries[4]);
-    ok(SUCCEEDED(hr), "Failed to set palette entries, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette entries, hr %#lx.\n", hr);
 
     i = GetDIBColorTable(dc, 4, 1, &rgbquad[4]);
     ok(i == 1, "Expected count 1, got %u.\n", i);
@@ -9823,9 +9823,9 @@ static void test_palette_gdi(void)
 
     /* Neither does re-setting the palette. */
     hr = IDirectDrawSurface4_SetPalette(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_SetPalette(surface, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     i = GetDIBColorTable(dc, 4, 1, &rgbquad[4]);
     ok(i == 1, "Expected count 1, got %u.\n", i);
@@ -9835,11 +9835,11 @@ static void test_palette_gdi(void)
             expected1[4].rgbRed, expected1[4].rgbGreen, expected1[4].rgbBlue);
 
     hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     /* Refresh the DC. This updates the palette. */
     hr = IDirectDrawSurface4_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad);
     ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i);
     for (i = 0; i < ARRAY_SIZE(expected2); i++)
@@ -9856,13 +9856,13 @@ static void test_palette_gdi(void)
                 i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue);
     }
     hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     refcount = IDirectDrawSurface4_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     if (FAILED(IDirectDraw4_SetDisplayMode(ddraw, 640, 480, 8, 0, 0)))
     {
         win_skip("Failed to set 8 bpp display mode, skipping test.\n");
@@ -9871,35 +9871,35 @@ static void test_palette_gdi(void)
         DestroyWindow(window);
         return;
     }
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 3;
     SetRect(&r, 0, 0, 319, 479);
     hr = IDirectDrawSurface4_Blt(primary, &r, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear surface, hr %#lx.\n", hr);
     SetRect(&r, 320, 0, 639, 479);
     U5(fx).dwFillColor = 4;
     hr = IDirectDrawSurface4_Blt(primary, &r, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_SetPalette(primary, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetDC(primary, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
 
     color = GetPixel(dc, 160, 240);
-    ok(color == 0x00030000, "Clear index 3: Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00030000, "Clear index 3: Got unexpected color 0x%08lx.\n", color);
     color = GetPixel(dc, 480, 240);
-    ok(color == 0x00252423, "Clear index 4: Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00252423, "Clear index 4: Got unexpected color 0x%08lx.\n", color);
 
     ddraw_palette_handle = SelectPalette(dc, GetStockObject(DEFAULT_PALETTE), FALSE);
     ok(ddraw_palette_handle == GetStockObject(DEFAULT_PALETTE),
@@ -9929,7 +9929,7 @@ static void test_palette_gdi(void)
                 i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue);
     }
     hr = IDirectDrawSurface4_ReleaseDC(primary, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -9938,12 +9938,12 @@ static void test_palette_gdi(void)
     surface_desc.dwHeight = 16;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* Here the offscreen surface appears to use the primary's palette,
      * but in all likelihood it is actually the system palette. */
     hr = IDirectDrawSurface4_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad);
     ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i);
     for (i = 0; i < ARRAY_SIZE(expected2); i++)
@@ -9960,7 +9960,7 @@ static void test_palette_gdi(void)
                 i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue);
     }
     hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     /* On real hardware a change to the primary surface's palette applies immediately,
      * even on device contexts from offscreen surfaces that do not have their own
@@ -9976,14 +9976,14 @@ static void test_palette_gdi(void)
     palette_entries[4].peBlue = 0x56;
     hr = IDirectDraw4_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_SetPalette(surface, palette2);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     /* A palette assigned to the offscreen surface overrides the primary / system
      * palette. */
     hr = IDirectDrawSurface4_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad);
     ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i);
     for (i = 0; i < ARRAY_SIZE(expected3); i++)
@@ -10000,24 +10000,24 @@ static void test_palette_gdi(void)
                 i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue);
     }
     hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     refcount = IDirectDrawSurface4_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     /* The Windows 8 testbot keeps extra references to the primary and
      * backbuffer while in 8 bpp mode. */
     hr = IDirectDraw4_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#lx.\n", hr);
 
     refcount = IDirectDrawSurface4_Release(primary);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette2);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -10056,18 +10056,18 @@ static void test_palette_alpha(void)
         return;
     }
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     palette_entries[1].peFlags = 0x42;
     palette_entries[2].peFlags = 0xff;
     palette_entries[3].peFlags = 0x80;
     hr = IDirectDraw4_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     memset(palette_entries, 0x66, sizeof(palette_entries));
     hr = IDirectDrawPalette_GetEntries(palette, 0, 1, 4, palette_entries);
-    ok(SUCCEEDED(hr), "Failed to get palette entries, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette entries, hr %#lx.\n", hr);
     ok(palette_entries[0].peFlags == 0x42, "Got unexpected peFlags 0x%02x, expected 0xff.\n",
             palette_entries[0].peFlags);
     ok(palette_entries[1].peFlags == 0xff, "Got unexpected peFlags 0x%02x, expected 0xff.\n",
@@ -10086,11 +10086,11 @@ static void test_palette_alpha(void)
     palette_entries[3].peFlags = 0x80;
     hr = IDirectDraw4_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT | DDPCAPS_ALPHA,
             palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     memset(palette_entries, 0x66, sizeof(palette_entries));
     hr = IDirectDrawPalette_GetEntries(palette, 0, 1, 4, palette_entries);
-    ok(SUCCEEDED(hr), "Failed to get palette entries, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette entries, hr %#lx.\n", hr);
     ok(palette_entries[0].peFlags == 0x42, "Got unexpected peFlags 0x%02x, expected 0xff.\n",
             palette_entries[0].peFlags);
     ok(palette_entries[1].peFlags == 0xff, "Got unexpected peFlags 0x%02x, expected 0xff.\n",
@@ -10109,13 +10109,13 @@ static void test_palette_alpha(void)
         surface_desc.dwHeight = 128;
         surface_desc.ddsCaps.dwCaps = test_data[i].caps;
         hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create %s surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to create %s surface, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface4_SetPalette(surface, palette);
         if (test_data[i].attach_allowed)
-            ok(SUCCEEDED(hr), "Failed to attach palette to %s surface, hr %#x.\n", test_data[i].name, hr);
+            ok(SUCCEEDED(hr), "Failed to attach palette to %s surface, hr %#lx.\n", test_data[i].name, hr);
         else
-            ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#x, %s surface.\n", hr, test_data[i].name);
+            ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#lx, %s surface.\n", hr, test_data[i].name);
 
         if (SUCCEEDED(hr))
         {
@@ -10124,7 +10124,7 @@ static void test_palette_alpha(void)
             UINT retval;
 
             hr = IDirectDrawSurface4_GetDC(surface, &dc);
-            ok(SUCCEEDED(hr), "Failed to get DC, hr %#x, %s surface.\n", hr, test_data[i].name);
+            ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx, %s surface.\n", hr, test_data[i].name);
             retval = GetDIBColorTable(dc, 1, 1, &rgbquad);
             ok(retval == 1, "GetDIBColorTable returned unexpected result %u.\n", retval);
             ok(rgbquad.rgbRed == 0xff, "Expected rgbRed = 0xff, got %#x, %s surface.\n",
@@ -10136,7 +10136,7 @@ static void test_palette_alpha(void)
             ok(rgbquad.rgbReserved == 0, "Expected rgbReserved = 0, got %u, %s surface.\n",
                     rgbquad.rgbReserved, test_data[i].name);
             hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-            ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
         }
         IDirectDrawSurface4_Release(surface);
     }
@@ -10155,20 +10155,20 @@ static void test_palette_alpha(void)
     U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x0000ff00;
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_SetPalette(surface, palette);
-    ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface4_Release(surface);
 
     /* The Windows 8 testbot keeps extra references to the primary
      * while in 8 bpp mode. */
     hr = IDirectDraw4_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#lx.\n", hr);
 
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -10198,7 +10198,7 @@ static void test_vb_writeonly(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
 
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
@@ -10206,32 +10206,32 @@ static void test_vb_writeonly(void)
     desc.dwFVF = D3DFVF_XYZRHW;
     desc.dwNumVertices = ARRAY_SIZE(quad);
     hr = IDirect3D3_CreateVertexBuffer(d3d, &desc, &buffer, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_Lock(buffer, DDLOCK_DISCARDCONTENTS, &ptr, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     memcpy(ptr, quad, sizeof(quad));
     hr = IDirect3DVertexBuffer_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, buffer, 0, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_Lock(buffer, 0, &ptr, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     ok (!memcmp(ptr, quad, sizeof(quad)), "Got unexpected vertex buffer data.\n");
     hr = IDirect3DVertexBuffer_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_Lock(buffer, DDLOCK_READONLY, &ptr, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     ok (!memcmp(ptr, quad, sizeof(quad)), "Got unexpected vertex buffer data.\n");
     hr = IDirect3DVertexBuffer_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     IDirect3DVertexBuffer_Release(buffer);
     IDirect3D3_Release(d3d);
@@ -10258,7 +10258,7 @@ static void test_lost_device(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -10266,7 +10266,7 @@ static void test_lost_device(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     U5(surface_desc).dwBackBufferCount = 1;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -10275,7 +10275,7 @@ static void test_lost_device(void)
     surface_desc.dwWidth = 100;
     surface_desc.dwHeight = 100;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -10296,93 +10296,93 @@ static void test_lost_device(void)
     }
 
     hr = IDirectDraw4_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDraw4_TestCooperativeLevel(ddraw);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Restore(surface);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Restore(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface4_Restore(vidmem_surface);
-        ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     ret = SetForegroundWindow(window1);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDraw4_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw4_RestoreAllSurfaces(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT);
-    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     /* Trying to restore the primary will crash, probably because flippable
@@ -10393,76 +10393,76 @@ static void test_lost_device(void)
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_RestoreAllSurfaces(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw4_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDraw4_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     ret = SetForegroundWindow(window1);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDraw4_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw4_RestoreAllSurfaces(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     IDirectDrawSurface4_Release(surface);
@@ -10472,116 +10472,116 @@ static void test_lost_device(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     U5(surface_desc).dwBackBufferCount = 1;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window2, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface4_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     memset(&caps, 0, sizeof(caps));
     caps.dwCaps = DDSCAPS_FLIP;
 
     hr = IDirectDrawSurface4_GetAttachedSurface(surface, &caps, &back_buffer);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Restore(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetAttachedSurface(surface, &caps, &back_buffer);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(back_buffer);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface4_Release(back_buffer);
 
     if (vidmem_surface)
@@ -10589,7 +10589,7 @@ static void test_lost_device(void)
     IDirectDrawSurface4_Release(sysmem_surface);
     IDirectDrawSurface4_Release(surface);
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window2);
     DestroyWindow(window1);
 }
@@ -10607,7 +10607,7 @@ static void test_surface_desc_lock(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -10616,36 +10616,36 @@ static void test_surface_desc_lock(void)
     surface_desc.dwHeight = 16;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0xaa, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!surface_desc.lpSurface, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
 
     memset(&surface_desc, 0xaa, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface4_Lock(surface, NULL, &surface_desc, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ok(surface_desc.lpSurface != NULL, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
     memset(&surface_desc, 0xaa, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!surface_desc.lpSurface, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
     hr = IDirectDrawSurface4_Unlock(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0xaa, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!surface_desc.lpSurface, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
 
     IDirectDrawSurface4_Release(surface);
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -10707,23 +10707,23 @@ static void test_texturemapblend(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, &texturemapblend);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(texturemapblend == D3DTBLEND_MODULATE, "Got unexpected texture map blend %#x.\n", texturemapblend);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(texturemapblend == D3DTBLEND_MODULATE, "Got unexpected texture map blend %#lx.\n", texturemapblend);
 
     hr = IDirect3DDevice3_GetTextureStageState(device, 0, D3DTSS_ALPHAOP, &value);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(value == D3DTOP_SELECTARG1, "Got unexpected D3DTSS_ALPHAOP value %#x.\n", value);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(value == D3DTOP_SELECTARG1, "Got unexpected D3DTSS_ALPHAOP value %#lx.\n", value);
 
     /* Test alpha with DDPF_ALPHAPIXELS texture - should be taken from texture
      * alpha channel.
@@ -10745,53 +10745,53 @@ static void test_texturemapblend(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(U4(surface_desc).ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTexture(device, 0, texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetTextureStageState(device, 0, D3DTSS_ALPHAOP, &value);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(value == D3DTOP_SELECTARG1, "Got unexpected D3DTSS_ALPHAOP value %#x.\n", value);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(value == D3DTOP_SELECTARG1, "Got unexpected D3DTSS_ALPHAOP value %#lx.\n", value);
 
     hr = IDirect3DDevice3_SetTexture(device, 0, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetTextureStageState(device, 0, D3DTSS_ALPHAOP, &value);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(value == D3DTOP_SELECTARG1, "Got unexpected D3DTSS_ALPHAOP value %#x.\n", value);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(value == D3DTOP_SELECTARG1, "Got unexpected D3DTSS_ALPHAOP value %#lx.\n", value);
 
     hr = IDirect3DDevice3_SetTexture(device, 0, texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 0xff0000ff;
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     U5(fx).dwFillColor = 0x800000ff;
     hr = IDirectDrawSurface4_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Note that the ddraw1 version of this test runs tests 1-3 with
      * D3DRENDERSTATE_COLORKEYENABLE enabled, whereas this version only runs
      * test 4 with color keying on. Because no color key is set on the texture
      * this should not result in different behavior. */
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
 #if 0
     /* Disable the call to test that the device has this state by default. */
@@ -10801,117 +10801,117 @@ static void test_texturemapblend(void)
 
     /* Texture stage state does not change so legacy texture blending stays enabled. */
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_MODULATE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, &test1_quads[0], 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, &test1_quads[4], 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 5, 5);
-    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 5);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 5, 245);
-    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 245);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
 
     /* Turn legacy texture blending off. */
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTexture(device, 0, texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport3_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, &test1_quads[0], 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, &test1_quads[4], 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 5, 5);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 5);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 5, 245);
-    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 245);
-    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08lx.\n", color);
 
     /* This doesn't turn legacy texture blending on again, as setting the same
      * _TEXTUREMAPBLEND value. */
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTexture(device, 0, texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport3_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, &test1_quads[0], 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, &test1_quads[4], 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 5, 5);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 5);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 5, 245);
-    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 245);
-    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08lx.\n", color);
 
     /* Turn legacy texture blending on again. */
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_ADD);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTexture(device, 0, texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport3_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, &test1_quads[0], 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, &test1_quads[4], 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 5, 5);
-    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 5);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 5, 245);
-    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 245);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice3_SetTexture(device, 0, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3DTexture2_Release(texture);
     refcount = IDirectDrawSurface4_Release(surface);
-    ok(!refcount, "Surface not properly released, refcount %u.\n", refcount);
+    ok(!refcount, "Surface not properly released, refcount %lu.\n", refcount);
 
     /* Test alpha with texture that has no alpha channel - alpha should be
      * taken from diffuse vertex color. */
@@ -10929,52 +10929,52 @@ static void test_texturemapblend(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTexture(device, 0, texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetTextureStageState(device, 0, D3DTSS_ALPHAOP, &value);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(value == D3DTOP_SELECTARG2, "Got unexpected D3DTSS_ALPHAOP value %#x.\n", value);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(value == D3DTOP_SELECTARG2, "Got unexpected D3DTSS_ALPHAOP value %#lx.\n", value);
 
     hr = IDirect3DViewport3_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     U5(fx).dwFillColor = 0xff0000ff;
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     U5(fx).dwFillColor = 0x800000ff;
     hr = IDirectDrawSurface4_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, &test1_quads[0], 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, &test1_quads[4], 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 5, 5);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 5);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 5, 245);
-    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 245);
-    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000080, 2), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice3_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     IDirect3DTexture2_Release(texture);
     refcount = IDirectDrawSurface4_Release(surface);
-    ok(!refcount, "Surface not properly released, refcount %u.\n", refcount);
+    ok(!refcount, "Surface not properly released, refcount %lu.\n", refcount);
 
     /* Test RGB - should multiply color components from diffuse vertex color
      * and texture. */
@@ -10992,51 +10992,51 @@ static void test_texturemapblend(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(U4(surface_desc).ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTexture(device, 0, texture);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     U5(fx).dwFillColor = 0x00ffffff;
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
     U5(fx).dwFillColor = 0x00ffff80;
     hr = IDirectDrawSurface4_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, &test2_quads[0], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, &test2_quads[4], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 5, 5);
-    ok(compare_color(color, 0x00ff0040, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0040, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 5);
-    ok(compare_color(color, 0x00ff0080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0080, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 5, 245);
-    ok(compare_color(color, 0x00800080, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00800080, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 245);
-    ok(compare_color(color, 0x008000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x008000ff, 2), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice3_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     IDirect3DTexture2_Release(texture);
     refcount = IDirectDrawSurface4_Release(surface);
-    ok(!refcount, "Surface not properly released, refcount %u.\n", refcount);
+    ok(!refcount, "Surface not properly released, refcount %lu.\n", refcount);
 
     /* Test alpha again, now with color keyed texture (colorkey emulation in
      * wine can interfere). */
@@ -11054,65 +11054,65 @@ static void test_texturemapblend(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x001f;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTexture(device, 0, texture);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     U5(fx).dwFillColor = 0xf800;
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
     U5(fx).dwFillColor = 0x001f;
     hr = IDirectDrawSurface4_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear texture, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = 0x001f;
     ckey.dwColorSpaceHighValue = 0x001f;
     hr = IDirectDrawSurface4_SetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, &test1_quads[0], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, &test1_quads[4], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 5, 5);
-    ok(compare_color(color, 0x00000000, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000000, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 5);
-    ok(compare_color(color, 0x00ff0000, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 5, 245);
-    ok(compare_color(color, 0x00000000, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000000, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 400, 245);
-    ok(compare_color(color, 0x00800000, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00800000, 2), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice3_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     IDirect3DTexture2_Release(texture);
     refcount = IDirectDrawSurface4_Release(surface);
-    ok(!refcount, "Surface not properly released, refcount %u.\n", refcount);
+    ok(!refcount, "Surface not properly released, refcount %lu.\n", refcount);
 
     destroy_viewport(device, viewport);
     IDirectDrawSurface4_Release(rt);
     IDirect3DDevice3_Release(device);
     IDirect3D3_Release(d3d);
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "Ddraw object not properly released, refcount %u.\n", refcount);
+    ok(!refcount, "Ddraw object not properly released, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -11223,7 +11223,7 @@ static void test_signed_formats(void)
     memset(&hel_desc, 0, sizeof(hel_desc));
     hel_desc.dwSize = sizeof(hel_desc);
     hr = IDirect3DDevice3_GetCaps(device, &device_desc, &hel_desc);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(device_desc.dwTextureOpCaps & D3DTEXOPCAPS_BLENDFACTORALPHA))
     {
         skip("D3DTOP_BLENDFACTORALPHA not supported, skipping bumpmap format tests.\n");
@@ -11231,43 +11231,43 @@ static void test_signed_formats(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface4_GetSurfaceDesc(rt, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     viewport = create_viewport(device, 0, 0, surface_desc.dwWidth, surface_desc.dwHeight);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#lx.\n", hr);
     U1(clear_rect).x1 = 0;
     U2(clear_rect).y1 = 0;
     U3(clear_rect).x2 = surface_desc.dwWidth;
     U4(clear_rect).y2 = surface_desc.dwHeight;
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     /* dst = tex * 0.5 + 1.0 * (1.0 - 0.5) = tex * 0.5 + 0.5 */
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_TEXTUREFACTOR, 0x80ffffff);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_BLENDFACTORALPHA);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(formats); i++)
     {
         for (width = 1; width < 5; width += 3)
         {
             hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0x00000000, 0.0f, 0);
-            ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
@@ -11282,19 +11282,19 @@ static void test_signed_formats(void)
                 skip("%s textures not supported, skipping.\n", formats[i].name);
                 continue;
             }
-            ok(SUCCEEDED(hr), "Failed to create surface, hr %#x, format %s.\n", hr, formats[i].name);
+            ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx, format %s.\n", hr, formats[i].name);
 
             hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-            ok(SUCCEEDED(hr), "Failed to get Direct3DTexture2 interface, hr %#x, format %s.\n",
+            ok(SUCCEEDED(hr), "Failed to get Direct3DTexture2 interface, hr %#lx, format %s.\n",
                     hr, formats[i].name);
             hr = IDirect3DDevice3_SetTexture(device, 0, texture);
-            ok(SUCCEEDED(hr), "Failed to set texture, hr %#x, format %s.\n", hr, formats[i].name);
+            ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx, format %s.\n", hr, formats[i].name);
             IDirect3DTexture2_Release(texture);
 
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface4_Lock(surface, NULL, &surface_desc, 0, NULL);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, format %s.\n", hr, formats[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, format %s.\n", hr, formats[i].name);
             for (y = 0; y < 4; y++)
             {
                 memcpy((char *)surface_desc.lpSurface + y * U1(surface_desc).lPitch,
@@ -11302,15 +11302,15 @@ static void test_signed_formats(void)
                         width * formats[i].pixel_size);
             }
             hr = IDirectDrawSurface4_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, format %s.\n", hr, formats[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, format %s.\n", hr, formats[i].name);
 
             hr = IDirect3DDevice3_BeginScene(device);
-            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
             hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
                     D3DFVF_XYZ | D3DFVF_TEX1, quad, 4, 0);
-            ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
             hr = IDirect3DDevice3_EndScene(device);
-            ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
             for (y = 0; y < 4; y++)
             {
@@ -11323,7 +11323,7 @@ static void test_signed_formats(void)
                     color = get_surface_color(rt, 80 + 160 * x, 60 + 120 * y);
                     ok(compare_color(color, expected_color, formats[i].slop)
                             || broken(compare_color(color, expected_color, formats[i].slop_broken)),
-                            "Expected color 0x%08x, got 0x%08x, format %s, location %ux%u.\n",
+                            "Expected color 0x%08lx, got 0x%08lx, format %s, location %ux%u.\n",
                             expected_color, color, formats[i].name, x, y);
                 }
             }
@@ -11339,7 +11339,7 @@ static void test_signed_formats(void)
 
 done:
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -11530,9 +11530,9 @@ static void test_color_fill(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
 
     memset(&z_fmt, 0, sizeof(z_fmt));
     IDirect3D3_EnumZBufferFormats(d3d, &IID_IDirect3DHALDevice, enum_z_fmt, &z_fmt);
@@ -11546,13 +11546,13 @@ static void test_color_fill(void)
     IDirect3D3_Release(d3d);
 
     hr = IDirectDraw4_GetFourCCCodes(ddraw, &num_fourcc_codes, NULL);
-    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#lx.\n", hr);
     fourcc_codes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
             num_fourcc_codes * sizeof(*fourcc_codes));
     if (!fourcc_codes)
         goto done;
     hr = IDirectDraw4_GetFourCCCodes(ddraw, &num_fourcc_codes, fourcc_codes);
-    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#lx.\n", hr);
     for (i = 0; i < num_fourcc_codes; i++)
     {
         if (fourcc_codes[i] == MAKEFOURCC('Y', 'U', 'Y', '2'))
@@ -11565,7 +11565,7 @@ static void test_color_fill(void)
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw4_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
 
     if (!(supported_fmts & (SUPPORT_YUY2 | SUPPORT_UYVY)) || !(hal_caps.dwCaps & DDCAPS_OVERLAY))
         skip("Overlays or some YUV formats not supported, skipping YUV colorfill tests.\n");
@@ -11620,16 +11620,16 @@ static void test_color_fill(void)
         }
 
         hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x, surface %s.\n", hr, tests[i].name);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx, surface %s.\n", hr, tests[i].name);
 
         hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
         todo_wine_if (tests[i].format.dwFourCC)
-            ok(hr == tests[i].colorfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
+            ok(hr == tests[i].colorfill_hr, "Blt returned %#lx, expected %#lx, surface %s.\n",
                     hr, tests[i].colorfill_hr, tests[i].name);
 
         hr = IDirectDrawSurface4_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
         todo_wine_if (tests[i].format.dwFourCC)
-            ok(hr == tests[i].colorfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
+            ok(hr == tests[i].colorfill_hr, "Blt returned %#lx, expected %#lx, surface %s.\n",
                     hr, tests[i].colorfill_hr, tests[i].name);
 
         if (SUCCEEDED(hr) && tests[i].check_result)
@@ -11637,19 +11637,19 @@ static void test_color_fill(void)
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface4_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
             color = surface_desc.lpSurface;
-            ok(*color == tests[i].result, "Got clear result 0x%08x, expected 0x%08x, surface %s.\n",
+            ok(*color == tests[i].result, "Got clear result 0x%08lx, expected 0x%08lx, surface %s.\n",
                     *color, tests[i].result, tests[i].name);
             hr = IDirectDrawSurface4_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
         }
 
         hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-        ok(hr == tests[i].depthfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
+        ok(hr == tests[i].depthfill_hr, "Blt returned %#lx, expected %#lx, surface %s.\n",
                 hr, tests[i].depthfill_hr, tests[i].name);
         hr = IDirectDrawSurface4_Blt(surface, &rect, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-        ok(hr == tests[i].depthfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
+        ok(hr == tests[i].depthfill_hr, "Blt returned %#lx, expected %#lx, surface %s.\n",
                 hr, tests[i].depthfill_hr, tests[i].name);
 
         if (SUCCEEDED(hr) && tests[i].check_result)
@@ -11657,22 +11657,22 @@ static void test_color_fill(void)
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface4_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
             color = surface_desc.lpSurface;
             ok((*color & U3(z_fmt).dwZBitMask) == (tests[i].result & U3(z_fmt).dwZBitMask)
                     || broken((*color & U3(z_fmt).dwZBitMask) == (expected_broken & U3(z_fmt).dwZBitMask)),
-                    "Got clear result 0x%08x, expected 0x%08x, surface %s.\n",
+                    "Got clear result 0x%08lx, expected 0x%08lx, surface %s.\n",
                     *color & U3(z_fmt).dwZBitMask, tests[i].result & U3(z_fmt).dwZBitMask, tests[i].name);
             hr = IDirectDrawSurface4_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
         }
 
         U5(fx).dwFillColor = 0xdeadbeef;
         fx.dwROP = BLACKNESS;
         hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
-        ok(FAILED(hr) == !tests[i].rop_success, "Blt returned %#x, expected %s, surface %s.\n",
+        ok(FAILED(hr) == !tests[i].rop_success, "Blt returned %#lx, expected %s, surface %s.\n",
                 hr, tests[i].rop_success ? "success" : "failure", tests[i].name);
-        ok(U5(fx).dwFillColor == 0xdeadbeef, "dwFillColor was set to 0x%08x, surface %s\n",
+        ok(U5(fx).dwFillColor == 0xdeadbeef, "dwFillColor was set to 0x%08lx, surface %s\n",
                 U5(fx).dwFillColor, tests[i].name);
 
         if (SUCCEEDED(hr) && tests[i].check_result)
@@ -11680,19 +11680,19 @@ static void test_color_fill(void)
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface4_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
             color = surface_desc.lpSurface;
-            ok(*color == 0, "Got clear result 0x%08x, expected 0x00000000, surface %s.\n",
+            ok(*color == 0, "Got clear result 0x%08lx, expected 0x00000000, surface %s.\n",
                     *color, tests[i].name);
             hr = IDirectDrawSurface4_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
         }
 
         fx.dwROP = WHITENESS;
         hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
-        ok(FAILED(hr) == !tests[i].rop_success, "Blt returned %#x, expected %s, surface %s.\n",
+        ok(FAILED(hr) == !tests[i].rop_success, "Blt returned %#lx, expected %s, surface %s.\n",
                 hr, tests[i].rop_success ? "success" : "failure", tests[i].name);
-        ok(U5(fx).dwFillColor == 0xdeadbeef, "dwFillColor was set to 0x%08x, surface %s\n",
+        ok(U5(fx).dwFillColor == 0xdeadbeef, "dwFillColor was set to 0x%08lx, surface %s\n",
                 U5(fx).dwFillColor, tests[i].name);
 
         if (SUCCEEDED(hr) && tests[i].check_result)
@@ -11700,13 +11700,13 @@ static void test_color_fill(void)
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface4_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
             color = surface_desc.lpSurface;
             /* WHITENESS sets the alpha channel to 0x00. Ignore this for now. */
-            ok((*color & 0x00ffffff) == 0x00ffffff, "Got clear result 0x%08x, expected 0xffffffff, surface %s.\n",
+            ok((*color & 0x00ffffff) == 0x00ffffff, "Got clear result 0x%08lx, expected 0xffffffff, surface %s.\n",
                     *color, tests[i].name);
             hr = IDirectDrawSurface4_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
         }
 
         IDirectDrawSurface4_Release(surface);
@@ -11730,78 +11730,78 @@ static void test_color_fill(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* No DDBLTFX. */
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, &rect, DDBLT_COLORFILL | DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, &rect, DDBLT_ROP | DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Unused source rectangle. */
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     /* Unused source surface. */
     hr = IDirectDrawSurface4_Blt(surface, NULL, surface2, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, surface2, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, surface2, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, surface2, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     /* Inverted destination or source rectangle. */
     SetRect(&rect, 5, 7, 7, 5);
     hr = IDirectDrawSurface4_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, &rect, surface2, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, surface2, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, surface2, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
 
     /* Negative rectangle. */
     SetRect(&rect, -1, -1, 5, 5);
     hr = IDirectDrawSurface4_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, &rect, surface2, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, &rect, surface2, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, surface2, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
 
     /* Out of bounds rectangle. */
     SetRect(&rect, 0, 0, 65, 65);
     hr = IDirectDrawSurface4_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, surface2, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
 
     /* Combine multiple flags. */
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(rops); i++)
     {
         fx.dwROP = rops[i].rop;
         hr = IDirectDrawSurface4_Blt(surface, NULL, surface2, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
-        ok(hr == rops[i].hr, "Got unexpected hr %#x for rop %s.\n", hr, rops[i].name);
+        ok(hr == rops[i].hr, "Got unexpected hr %#lx for rop %s.\n", hr, rops[i].name);
     }
 
     IDirectDrawSurface4_Release(surface2);
@@ -11818,54 +11818,54 @@ static void test_color_fill(void)
     U4(surface_desc).ddpfPixelFormat = z_fmt;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* No DDBLTFX. */
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Unused source rectangle. */
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     /* Unused source surface. */
     hr = IDirectDrawSurface4_Blt(surface, NULL, surface2, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, surface2, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Inverted destination or source rectangle. */
     SetRect(&rect, 5, 7, 7, 5);
     hr = IDirectDrawSurface4_Blt(surface, &rect, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, &rect, surface2, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, surface2, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Negative rectangle. */
     SetRect(&rect, -1, -1, 5, 5);
     hr = IDirectDrawSurface4_Blt(surface, &rect, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, &rect, surface2, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, &rect, surface2, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Out of bounds rectangle. */
     SetRect(&rect, 0, 0, 65, 65);
     hr = IDirectDrawSurface4_Blt(surface, &rect, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
 
     /* Combine multiple flags. */
     hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface4_Release(surface2);
     IDirectDrawSurface4_Release(surface);
@@ -11873,7 +11873,7 @@ static void test_color_fill(void)
 done:
     IDirectDraw4_Release(ddraw);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -11918,13 +11918,13 @@ static void test_texcoordindex(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get DirectDraw4 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DirectDraw4 interface, hr %#lx.\n", hr);
     IDirect3D3_Release(d3d);
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -11940,14 +11940,14 @@ static void test_texcoordindex(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(U4(surface_desc).ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface4_Lock(surface1, 0, &surface_desc, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ptr = surface_desc.lpSurface;
     ptr[0] = 0xff000000;
     ptr[1] = 0xff00ff00;
@@ -11955,12 +11955,12 @@ static void test_texcoordindex(void)
     ptr[0] = 0xff0000ff;
     ptr[1] = 0xff00ffff;
     hr = IDirectDrawSurface4_Unlock(surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface4_Lock(surface2, 0, &surface_desc, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ptr = surface_desc.lpSurface;
     ptr[0] = 0xff000000;
     ptr[1] = 0xff0000ff;
@@ -11968,83 +11968,83 @@ static void test_texcoordindex(void)
     ptr[0] = 0xffff0000;
     ptr[1] = 0xffff00ff;
     hr = IDirectDrawSurface4_Unlock(surface2, 0);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_QueryInterface(surface1, &IID_IDirect3DTexture2, (void **)&texture1);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_QueryInterface(surface2, &IID_IDirect3DTexture2, (void **)&texture2);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTexture(device, 0, texture1);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTexture(device, 1, texture2);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_ADD);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 1, D3DTSS_COLORARG2, D3DTA_CURRENT);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 2, D3DTSS_COLOROP, D3DTOP_DISABLE);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_TEXCOORDINDEX, 1);
-    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 1, D3DTSS_TEXCOORDINDEX, 0);
-    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xffffff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, fvf, quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 120);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 120);
-    ok(compare_color(color, 0x0000ffff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ffff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 160, 360);
-    ok(compare_color(color, 0x00ff0000, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 360);
-    ok(compare_color(color, 0x00ffffff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 2), "Got unexpected color 0x%08lx.\n", color);
 
     /* D3DTSS_TEXTURETRANSFORMFLAGS was introduced in D3D7, can't test it here. */
 
     hr = IDirect3DDevice3_SetTextureStageState(device, 1, D3DTSS_TEXCOORDINDEX, 2);
-    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xffffff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, fvf, quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 120);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 120);
-    ok(compare_color(color, 0x0000ffff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ffff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 160, 360);
-    ok(compare_color(color, 0x00ff00ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff00ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 360);
-    ok(compare_color(color, 0x00ffff00, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffff00, 2), "Got unexpected color 0x%08lx.\n", color);
 
     IDirect3DTexture2_Release(texture2);
     IDirect3DTexture2_Release(texture1);
@@ -12056,7 +12056,7 @@ static void test_texcoordindex(void)
     IDirectDrawSurface4_Release(rt);
     IDirectDraw4_Release(ddraw);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -12143,12 +12143,12 @@ static void test_colorkey_precision(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get DirectDraw4 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DirectDraw4 interface, hr %#lx.\n", hr);
     IDirect3D3_Release(d3d);
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     is_nvidia = ddraw_is_nvidia(ddraw);
     /* The Windows 8 WARP driver has plenty of false negatives in X8R8G8B8
@@ -12161,24 +12161,24 @@ static void test_colorkey_precision(void)
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable color keying, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable color keying, hr %#lx.\n", hr);
     /* Multiply the texture read result with 0, that way the result color if the key doesn't
      * match is constant. In theory color keying works without reading the texture result
      * (meaning we could just op=arg1, arg1=tfactor), but the Geforce7 Windows driver begs
      * to differ. */
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_MODULATE);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_TEXTUREFACTOR, 0x00000000);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
@@ -12203,9 +12203,9 @@ static void test_colorkey_precision(void)
         /* Windows XP (at least with the r200 driver, other drivers untested) produces
          * garbage when doing color keyed texture->texture blits. */
         hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &src, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
         hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
         U5(fx).dwFillColor = tests[t].clear;
         /* On the w8 testbot (WARP driver) the blit result has different values in the
@@ -12223,17 +12223,17 @@ static void test_colorkey_precision(void)
             surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = c << tests[t].shift;
             surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = c << tests[t].shift;
             hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &texture, NULL);
-            ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
             hr = IDirectDrawSurface4_QueryInterface(texture, &IID_IDirect3DTexture2, (void **)&d3d_texture);
-            ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
             hr = IDirect3DDevice3_SetTexture(device, 0, d3d_texture);
-            ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
 
             hr = IDirectDrawSurface4_Blt(dst, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-            ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#lx.\n", hr);
 
             hr = IDirectDrawSurface4_Lock(src, NULL, &lock_desc, DDLOCK_WAIT, NULL);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
             switch (tests[t].bpp)
             {
                 case 4:
@@ -12251,21 +12251,21 @@ static void test_colorkey_precision(void)
                     break;
             }
             hr = IDirectDrawSurface4_Unlock(src, 0);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
             hr = IDirectDrawSurface4_Blt(texture, NULL, src, NULL, DDBLT_WAIT, NULL);
-            ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
             ckey.dwColorSpaceLowValue = c << tests[t].shift;
             ckey.dwColorSpaceHighValue = c << tests[t].shift;
             hr = IDirectDrawSurface4_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-            ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
             hr = IDirectDrawSurface4_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC | DDBLT_WAIT, NULL);
-            ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
             /* Don't make this read only, it somehow breaks the detection of the Nvidia bug below. */
             hr = IDirectDrawSurface4_Lock(dst, NULL, &lock_desc, DDLOCK_WAIT, NULL);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
             switch (tests[t].bpp)
             {
                 case 4:
@@ -12283,11 +12283,11 @@ static void test_colorkey_precision(void)
                     break;
             }
             hr = IDirectDrawSurface4_Unlock(dst, 0);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
             if (!c)
             {
-                ok(data[0] == tests[t].clear, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+                ok(data[0] == tests[t].clear, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                         tests[t].clear, data[0], tests[t].name, c);
 
                 if (data[3] == tests[t].clear)
@@ -12312,52 +12312,52 @@ static void test_colorkey_precision(void)
                 }
             }
             else
-                ok(data[0] == (c - 1) << tests[t].shift, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+                ok(data[0] == (c - 1) << tests[t].shift, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                         (c - 1) << tests[t].shift, data[0], tests[t].name, c);
 
-            ok(data[1] == tests[t].clear, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+            ok(data[1] == tests[t].clear, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                     tests[t].clear, data[1], tests[t].name, c);
 
             if (c == tests[t].max)
-                ok(data[2] == tests[t].clear, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+                ok(data[2] == tests[t].clear, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                         tests[t].clear, data[2], tests[t].name, c);
             else
-                ok(data[2] == (c + 1) << tests[t].shift, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+                ok(data[2] == (c + 1) << tests[t].shift, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                         (c + 1) << tests[t].shift, data[2], tests[t].name, c);
 
             hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0x0000ff00, 1.0f, 0);
-            ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
             hr = IDirect3DDevice3_BeginScene(device);
-            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
             hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_TEX1, quad, 4, 0);
-            ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
             hr = IDirect3DDevice3_EndScene(device);
-            ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
             color = get_surface_color(rt, 80, 240);
             if (!c)
                 ok(compare_color(color, 0x0000ff00, 1) || broken(is_warp && compare_color(color, 0x00000000, 1)),
-                        "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                        "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                         color, tests[t].name, c);
             else
                 ok(compare_color(color, 0x00000000, 1) || broken(is_warp && compare_color(color, 0x0000ff00, 1)),
-                        "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                        "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                         color, tests[t].name, c);
 
             color = get_surface_color(rt, 240, 240);
             ok(compare_color(color, 0x0000ff00, 1) || broken(is_warp && compare_color(color, 0x00000000, 1)),
-                    "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                    "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                     color, tests[t].name, c);
 
             color = get_surface_color(rt, 400, 240);
             if (c == tests[t].max)
                 ok(compare_color(color, 0x0000ff00, 1) || broken(is_warp && compare_color(color, 0x00000000, 1)),
-                        "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                        "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                         color, tests[t].name, c);
             else
                 ok(compare_color(color, 0x00000000, 1) || broken(is_warp && compare_color(color, 0x0000ff00, 1)),
-                        "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                        "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                         color, tests[t].name, c);
 
             IDirect3DTexture2_Release(d3d_texture);
@@ -12372,7 +12372,7 @@ static void test_colorkey_precision(void)
     IDirectDrawSurface4_Release(rt);
     IDirectDraw4_Release(ddraw);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -12390,7 +12390,7 @@ static void test_range_colorkey(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -12409,85 +12409,85 @@ static void test_range_colorkey(void)
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000000;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000001;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     /* Same for DDSCAPS_OFFSCREENPLAIN. */
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000000;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000001;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000000;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* Setting a range color key without DDCKEY_COLORSPACE collapses the key. */
     ckey.dwColorSpaceLowValue = 0x00000000;
     ckey.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDrawSurface4_SetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_GetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(!ckey.dwColorSpaceLowValue, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceLowValue);
-    ok(!ckey.dwColorSpaceHighValue, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(!ckey.dwColorSpaceLowValue, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceLowValue);
+    ok(!ckey.dwColorSpaceHighValue, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceHighValue);
 
     ckey.dwColorSpaceLowValue = 0x00000001;
     ckey.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDrawSurface4_SetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_GetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(ckey.dwColorSpaceLowValue == 0x00000001, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceLowValue);
-    ok(ckey.dwColorSpaceHighValue == 0x00000001, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(ckey.dwColorSpaceLowValue == 0x00000001, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceLowValue);
+    ok(ckey.dwColorSpaceHighValue == 0x00000001, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceHighValue);
 
     /* DDCKEY_COLORSPACE is ignored if the key is a single value. */
     ckey.dwColorSpaceLowValue = 0x00000000;
     ckey.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDrawSurface4_SetColorKey(surface, DDCKEY_SRCBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     /* Using it with a range key results in DDERR_NOCOLORKEYHW. */
     ckey.dwColorSpaceLowValue = 0x00000001;
     ckey.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDrawSurface4_SetColorKey(surface, DDCKEY_SRCBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
     ckey.dwColorSpaceLowValue = 0x00000000;
     ckey.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDrawSurface4_SetColorKey(surface, DDCKEY_SRCBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
     /* Range destination keys don't work either. */
     hr = IDirectDrawSurface4_SetColorKey(surface, DDCKEY_DESTBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     /* Just to show it's not because of A, R, and G having equal values. */
     ckey.dwColorSpaceLowValue = 0x00000000;
     ckey.dwColorSpaceHighValue = 0x01010101;
     hr = IDirectDrawSurface4_SetColorKey(surface, DDCKEY_SRCBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     /* None of these operations modified the key. */
     hr = IDirectDrawSurface4_GetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(!ckey.dwColorSpaceLowValue, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceLowValue);
-    ok(!ckey.dwColorSpaceHighValue, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(!ckey.dwColorSpaceLowValue, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceLowValue);
+    ok(!ckey.dwColorSpaceHighValue, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceHighValue);
 
     IDirectDrawSurface4_Release(surface);
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -12553,16 +12553,16 @@ static void test_shademode(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#lx.\n", hr);
 
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
@@ -12570,21 +12570,21 @@ static void test_shademode(void)
     desc.dwFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE;
     desc.dwNumVertices = ARRAY_SIZE(quad_strip);
     hr = IDirect3D3_CreateVertexBuffer(d3d, &desc, &vb_strip, 0, NULL);
-    ok(hr == D3D_OK, "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create vertex buffer, hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer_Lock(vb_strip, 0, &data, NULL);
-    ok(hr == D3D_OK, "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to lock vertex buffer, hr %#lx.\n", hr);
     memcpy(data, quad_strip, sizeof(quad_strip));
     hr = IDirect3DVertexBuffer_Unlock(vb_strip);
-    ok(hr == D3D_OK, "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     desc.dwNumVertices = ARRAY_SIZE(quad_list);
     hr = IDirect3D3_CreateVertexBuffer(d3d, &desc, &vb_list, 0, NULL);
-    ok(hr == D3D_OK, "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create vertex buffer, hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer_Lock(vb_list, 0, &data, NULL);
-    ok(hr == D3D_OK, "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to lock vertex buffer, hr %#lx.\n", hr);
     memcpy(data, quad_list, sizeof(quad_list));
     hr = IDirect3DVertexBuffer_Unlock(vb_list);
-    ok(hr == D3D_OK, "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     /* Try it first with a TRIANGLESTRIP.  Do it with different geometry because
      * the color fixups we have to do for FLAT shading will be dependent on that. */
@@ -12592,19 +12592,19 @@ static void test_shademode(void)
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_SHADEMODE, tests[i].shademode);
-        ok(hr == D3D_OK, "Failed to set shade mode, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to set shade mode, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice3_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         buffer = tests[i].primtype == D3DPT_TRIANGLESTRIP ? vb_strip : vb_list;
         count = tests[i].primtype == D3DPT_TRIANGLESTRIP ? 4 : 6;
         hr = IDirect3DDevice3_DrawPrimitiveVB(device, tests[i].primtype, buffer, 0, count, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice3_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color0 = get_surface_color(rt, 100, 100); /* Inside first triangle */
         color1 = get_surface_color(rt, 500, 350); /* Inside second triangle */
@@ -12614,9 +12614,9 @@ static void test_shademode(void)
          * functionality being available. */
         /* PHONG should be the same as GOURAUD, since no hardware implements
          * this. */
-        ok(compare_color(color0, tests[i].color0, 1), "Test %u shading has color0 %08x, expected %08x.\n",
+        ok(compare_color(color0, tests[i].color0, 1), "Test %u shading has color0 %08lx, expected %08lx.\n",
                 i, color0, tests[i].color0);
-        ok(compare_color(color1, tests[i].color1, 1), "Test %u shading has color1 %08x, expected %08x.\n",
+        ok(compare_color(color1, tests[i].color1, 1), "Test %u shading has color1 %08lx, expected %08lx.\n",
                 i, color1, tests[i].color1);
     }
 
@@ -12626,7 +12626,7 @@ static void test_shademode(void)
     IDirectDrawSurface4_Release(rt);
     IDirect3D3_Release(d3d);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -12687,12 +12687,12 @@ static void test_lockrect_invalid(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw4_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & needed_caps) != needed_caps
             || !(hal_caps.ddsCaps.dwCaps & DDSCAPS2_TEXTUREMANAGE))
     {
@@ -12719,13 +12719,13 @@ static void test_lockrect_invalid(void)
         hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
         if (!resources[r].allowed)
         {
-            ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name);
+            ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#lx, type %s.\n", hr, resources[r].name);
             continue;
         }
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx, type %s.\n", hr, resources[r].name);
 
         hr = IDirectDrawSurface4_Lock(surface, NULL, NULL, DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name);
+        ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx, type %s.\n", hr, resources[r].name);
 
         for (i = 0; i < ARRAY_SIZE(valid); ++i)
         {
@@ -12735,11 +12735,11 @@ static void test_lockrect_invalid(void)
             surface_desc.dwSize = sizeof(surface_desc);
 
             hr = IDirectDrawSurface4_Lock(surface, rect, &surface_desc, DDLOCK_WAIT, NULL);
-            ok(SUCCEEDED(hr), "Lock failed (%#x) for rect %s, type %s.\n",
+            ok(SUCCEEDED(hr), "Lock failed (%#lx) for rect %s, type %s.\n",
                     hr, wine_dbgstr_rect(rect), resources[r].name);
 
             hr = IDirectDrawSurface4_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
         }
 
         for (i = 0; i < ARRAY_SIZE(invalid); ++i)
@@ -12750,37 +12750,37 @@ static void test_lockrect_invalid(void)
             surface_desc.dwSize = sizeof(surface_desc);
 
             hr = IDirectDrawSurface4_Lock(surface, rect, &surface_desc, DDLOCK_WAIT, NULL);
-            ok(hr == resources[r].hr, "Lock returned %#x for rect %s, type %s.\n",
+            ok(hr == resources[r].hr, "Lock returned %#lx for rect %s, type %s.\n",
                     hr, wine_dbgstr_rect(rect), resources[r].name);
             if (SUCCEEDED(hr))
             {
                 hr = IDirectDrawSurface4_Unlock(surface, NULL);
-                ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+                ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
             }
             else
                 ok(!surface_desc.lpSurface, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
         }
 
         hr = IDirectDrawSurface4_Lock(surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Lock(rect = NULL) failed, hr %#x, type %s.\n",
+        ok(SUCCEEDED(hr), "Lock(rect = NULL) failed, hr %#lx, type %s.\n",
                 hr, resources[r].name);
         hr = IDirectDrawSurface4_Lock(surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_SURFACEBUSY, "Double lock(rect = NULL) returned %#x, type %s.\n",
+        ok(hr == DDERR_SURFACEBUSY, "Double lock(rect = NULL) returned %#lx, type %s.\n",
                 hr, resources[r].name);
         hr = IDirectDrawSurface4_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
 
         hr = IDirectDrawSurface4_Lock(surface, &valid[0], &surface_desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Lock(rect = %s) failed (%#x).\n", wine_dbgstr_rect(&valid[0]), hr);
+        ok(SUCCEEDED(hr), "Lock(rect = %s) failed (%#lx).\n", wine_dbgstr_rect(&valid[0]), hr);
         hr = IDirectDrawSurface4_Lock(surface, &valid[0], &surface_desc, DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_SURFACEBUSY, "Double lock(rect = %s) failed (%#x).\n",
+        ok(hr == DDERR_SURFACEBUSY, "Double lock(rect = %s) failed (%#lx).\n",
                 wine_dbgstr_rect(&valid[0]), hr);
 
         /* Locking a different rectangle returns DD_OK, but it seems to break the surface.
          * Afterwards unlocking the surface fails(NULL rectangle or both locked rectangles) */
 
         hr = IDirectDrawSurface4_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
 
         IDirectDrawSurface4_Release(surface);
     }
@@ -12805,7 +12805,7 @@ static void test_yv12_overlay(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     if (!(src_surface = create_overlay(ddraw, 256, 256, MAKEFOURCC('Y','V','1','2'))))
     {
@@ -12816,17 +12816,17 @@ static void test_yv12_overlay(void)
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
     hr = IDirectDrawSurface4_Lock(src_surface, NULL, &desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
 
     ok(desc.dwFlags == (DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS | DDSD_PITCH),
-            "Got unexpected flags %#x.\n", desc.dwFlags);
+            "Got unexpected flags %#lx.\n", desc.dwFlags);
     ok(desc.ddsCaps.dwCaps == (DDSCAPS_OVERLAY | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM | DDSCAPS_HWCODEC)
             || desc.ddsCaps.dwCaps == (DDSCAPS_OVERLAY | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM),
-            "Got unexpected caps %#x.\n", desc.ddsCaps.dwCaps);
-    ok(desc.dwWidth == 256, "Got unexpected width %u.\n", desc.dwWidth);
-    ok(desc.dwHeight == 256, "Got unexpected height %u.\n", desc.dwHeight);
+            "Got unexpected caps %#lx.\n", desc.ddsCaps.dwCaps);
+    ok(desc.dwWidth == 256, "Got unexpected width %lu.\n", desc.dwWidth);
+    ok(desc.dwHeight == 256, "Got unexpected height %lu.\n", desc.dwHeight);
     /* The overlay pitch seems to have 256 byte alignment. */
-    ok(!(U1(desc).lPitch & 0xff), "Got unexpected pitch %u.\n", U1(desc).lPitch);
+    ok(!(U1(desc).lPitch & 0xff), "Got unexpected pitch %lu.\n", U1(desc).lPitch);
 
     /* Fill the surface with some data for the blit test. */
     base = desc.lpSurface;
@@ -12847,7 +12847,7 @@ static void test_yv12_overlay(void)
     }
 
     hr = IDirectDrawSurface4_Unlock(src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* YV12 uses 2x2 blocks with 6 bytes per block (4*Y, 1*U, 1*V). Unlike
      * other block-based formats like DXT the entire Y channel is stored in
@@ -12855,12 +12855,12 @@ static void test_yv12_overlay(void)
      * locks do not really make sense. Show that they are allowed nevertheless
      * and the offset points into the luminance data. */
     hr = IDirectDrawSurface4_Lock(src_surface, &rect, &desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     offset = ((const unsigned char *)desc.lpSurface - base);
-    ok(offset == rect.top * U1(desc).lPitch + rect.left, "Got unexpected offset %u, expected %u.\n",
+    ok(offset == rect.top * U1(desc).lPitch + rect.left, "Got unexpected offset %u, expected %lu.\n",
             offset, rect.top * U1(desc).lPitch + rect.left);
     hr = IDirectDrawSurface4_Unlock(src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     if (!(dst_surface = create_overlay(ddraw, 256, 256, MAKEFOURCC('Y','V','1','2'))))
     {
@@ -12874,14 +12874,14 @@ static void test_yv12_overlay(void)
     hr = IDirectDrawSurface4_Blt(dst_surface, NULL, src_surface, NULL, DDBLT_WAIT, NULL);
     /* VMware rejects YV12 blits. This behavior has not been seen on real
      * hardware yet, so mark it broken. */
-    ok(SUCCEEDED(hr) || broken(hr == E_NOTIMPL), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == E_NOTIMPL), "Failed to blit, hr %#lx.\n", hr);
 
     if (SUCCEEDED(hr))
     {
         memset(&desc, 0, sizeof(desc));
         desc.dwSize = sizeof(desc);
         hr = IDirectDrawSurface4_Lock(dst_surface, NULL, &desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
 
         base = desc.lpSurface;
         ok(base[0] == 0x10, "Got unexpected Y data 0x%02x.\n", base[0]);
@@ -12891,7 +12891,7 @@ static void test_yv12_overlay(void)
         ok(base[0] == 0x30, "Got unexpected U data 0x%02x.\n", base[0]);
 
         hr = IDirectDrawSurface4_Unlock(dst_surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
     }
 
     IDirectDrawSurface4_Release(dst_surface);
@@ -12927,7 +12927,7 @@ static void test_offscreen_overlay(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     if (!(overlay = create_overlay(ddraw, 64, 64, MAKEFOURCC('U','Y','V','Y'))))
     {
@@ -12940,21 +12940,21 @@ static void test_offscreen_overlay(void)
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     /* On Windows 7, and probably Vista, UpdateOverlay() will return
      * DDERR_OUTOFCAPS if the dwm is active. Calling GetDC() on the primary
      * surface prevents this by disabling the dwm. */
     hr = IDirectDrawSurface4_GetDC(primary, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_ReleaseDC(primary, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     /* Try to overlay a NULL surface. */
     hr = IDirectDrawSurface4_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_SHOW, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_HIDE, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Try to overlay an offscreen surface. */
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -12971,18 +12971,18 @@ static void test_offscreen_overlay(void)
     U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x07e0;
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x001f;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &offscreen, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     hr = IDirectDrawSurface4_UpdateOverlay(overlay, NULL, offscreen, NULL, DDOVER_SHOW, NULL);
     ok(SUCCEEDED(hr) || broken(hr == DDERR_OUTOFCAPS && dwm_enabled())
             || broken(hr == E_NOTIMPL && ddraw_is_vmware(ddraw)),
-            "Failed to update overlay, hr %#x.\n", hr);
+            "Failed to update overlay, hr %#lx.\n", hr);
 
     /* Try to overlay the primary with a non-overlay surface. */
     hr = IDirectDrawSurface4_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_SHOW, NULL);
-    ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_HIDE, NULL);
-    ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface4_Release(offscreen);
     IDirectDrawSurface4_Release(primary);
@@ -13007,7 +13007,7 @@ static void test_overlay_rect(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     if (!(overlay = create_overlay(ddraw, 64, 64, MAKEFOURCC('U','Y','V','Y'))))
     {
@@ -13020,15 +13020,15 @@ static void test_overlay_rect(void)
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     /* On Windows 7, and probably Vista, UpdateOverlay() will return
      * DDERR_OUTOFCAPS if the dwm is active. Calling GetDC() on the primary
      * surface prevents this by disabling the dwm. */
     hr = IDirectDrawSurface4_GetDC(primary, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_ReleaseDC(primary, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     /* On Windows 8 and newer DWM can't be turned off, making overlays unusable. */
     if (dwm_enabled())
@@ -13041,48 +13041,48 @@ static void test_overlay_rect(void)
      * used. This is not true in Windows Vista and earlier, but changed in
      * Windows 7. */
     hr = IDirectDrawSurface4_UpdateOverlay(overlay, NULL, primary, &rect, DDOVER_SHOW, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_UpdateOverlay(overlay, NULL, primary, NULL, DDOVER_HIDE, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_UpdateOverlay(overlay, NULL, primary, NULL, DDOVER_SHOW, NULL);
-    ok(hr == DD_OK || hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Show that the overlay position is the (top, left) coordinate of the
      * destination rectangle. */
     OffsetRect(&rect, 32, 16);
     hr = IDirectDrawSurface4_UpdateOverlay(overlay, NULL, primary, &rect, DDOVER_SHOW, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#lx.\n", hr);
     pos_x = -1; pos_y = -1;
     hr = IDirectDrawSurface4_GetOverlayPosition(overlay, &pos_x, &pos_y);
-    ok(SUCCEEDED(hr), "Failed to get overlay position, hr %#x.\n", hr);
-    ok(pos_x == rect.left, "Got unexpected pos_x %d, expected %d.\n", pos_x, rect.left);
-    ok(pos_y == rect.top, "Got unexpected pos_y %d, expected %d.\n", pos_y, rect.top);
+    ok(SUCCEEDED(hr), "Failed to get overlay position, hr %#lx.\n", hr);
+    ok(pos_x == rect.left, "Got unexpected pos_x %ld, expected %ld.\n", pos_x, rect.left);
+    ok(pos_y == rect.top, "Got unexpected pos_y %ld, expected %ld.\n", pos_y, rect.top);
 
     /* Passing a NULL dest rect sets the position to 0/0. Visually it can be
      * seen that the overlay overlays the whole primary(==screen). */
     hr2 = IDirectDrawSurface4_UpdateOverlay(overlay, NULL, primary, NULL, 0, NULL);
-    ok(hr2 == DD_OK || hr2 == DDERR_INVALIDPARAMS || hr2 == DDERR_OUTOFCAPS, "Got unexpected hr %#x.\n", hr2);
+    ok(hr2 == DD_OK || hr2 == DDERR_INVALIDPARAMS || hr2 == DDERR_OUTOFCAPS, "Got unexpected hr %#lx.\n", hr2);
     hr = IDirectDrawSurface4_GetOverlayPosition(overlay, &pos_x, &pos_y);
-    ok(SUCCEEDED(hr), "Failed to get overlay position, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get overlay position, hr %#lx.\n", hr);
     if (SUCCEEDED(hr2))
     {
-        ok(!pos_x, "Got unexpected pos_x %d.\n", pos_x);
-        ok(!pos_y, "Got unexpected pos_y %d.\n", pos_y);
+        ok(!pos_x, "Got unexpected pos_x %ld.\n", pos_x);
+        ok(!pos_y, "Got unexpected pos_y %ld.\n", pos_y);
     }
     else
     {
-        ok(pos_x == 32, "Got unexpected pos_x %d.\n", pos_x);
-        ok(pos_y == 16, "Got unexpected pos_y %d.\n", pos_y);
+        ok(pos_x == 32, "Got unexpected pos_x %ld.\n", pos_x);
+        ok(pos_y == 16, "Got unexpected pos_y %ld.\n", pos_y);
     }
 
     /* The position cannot be retrieved when the overlay is not shown. */
     hr = IDirectDrawSurface4_UpdateOverlay(overlay, NULL, primary, &rect, DDOVER_HIDE, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#lx.\n", hr);
     pos_x = -1; pos_y = -1;
     hr = IDirectDrawSurface4_GetOverlayPosition(overlay, &pos_x, &pos_y);
-    ok(hr == DDERR_OVERLAYNOTVISIBLE, "Got unexpected hr %#x.\n", hr);
-    ok(!pos_x, "Got unexpected pos_x %d.\n", pos_x);
-    ok(!pos_y, "Got unexpected pos_y %d.\n", pos_y);
+    ok(hr == DDERR_OVERLAYNOTVISIBLE, "Got unexpected hr %#lx.\n", hr);
+    ok(!pos_x, "Got unexpected pos_x %ld.\n", pos_x);
+    ok(!pos_y, "Got unexpected pos_y %ld.\n", pos_y);
 
 done:
     if (primary)
@@ -13134,12 +13134,12 @@ static void test_blt(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get DirectDraw4 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DirectDraw4 interface, hr %#lx.\n", hr);
     IDirect3D3_Release(d3d);
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -13148,37 +13148,37 @@ static void test_blt(void)
     surface_desc.dwHeight = 480;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Blt(surface, NULL, surface, NULL, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Blt(surface, NULL, rt, NULL, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirectDrawSurface4_Blt(surface, &test_data[i].dst_rect,
                 surface, &test_data[i].src_rect, DDBLT_WAIT, NULL);
-        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
 
         hr = IDirectDrawSurface4_Blt(surface, &test_data[i].dst_rect,
                 rt, &test_data[i].src_rect, DDBLT_WAIT, NULL);
-        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
 
         hr = IDirectDrawSurface4_Blt(surface, &test_data[i].dst_rect,
                 NULL, &test_data[i].src_rect, DDBLT_WAIT, NULL);
-        ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirectDrawSurface4_Blt(surface, &test_data[i].dst_rect, NULL, NULL, DDBLT_WAIT, NULL);
-        ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#lx.\n", i, hr);
     }
 
     IDirectDrawSurface4_Release(surface);
     IDirectDrawSurface4_Release(rt);
     IDirectDraw4_Release(ddraw);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -13219,7 +13219,7 @@ static void test_blt_z_alpha(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&pf, 0, sizeof(pf));
     pf.dwSize = sizeof(pf);
@@ -13239,9 +13239,9 @@ static void test_blt_z_alpha(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#lx.\n", hr);
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &dst_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
@@ -13261,23 +13261,23 @@ static void test_blt_z_alpha(void)
     {
         U5(fx).dwFillColor = 0x3300ff00;
         hr = IDirectDrawSurface4_Blt(src_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         U5(fx).dwFillColor = 0xccff0000;
         hr = IDirectDrawSurface4_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirectDrawSurface4_Blt(dst_surface, NULL, src_surface, NULL, blt_flags[i] | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         color = get_surface_color(dst_surface, 32, 32);
-        ok(compare_color(color, 0x0000ff00, 0), "Test %u: Got unexpected color 0x%08x.\n", i, color);
+        ok(compare_color(color, 0x0000ff00, 0), "Test %u: Got unexpected color 0x%08lx.\n", i, color);
     }
 
     IDirectDrawSurface4_Release(dst_surface);
     IDirectDrawSurface4_Release(src_surface);
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -13313,15 +13313,15 @@ static void test_cross_device_blt(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get DirectDraw4 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DirectDraw4 interface, hr %#lx.\n", hr);
     IDirect3D3_Release(d3d);
 
     hr = IDirect3DDevice3_GetDirect3D(device2, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw2);
-    ok(SUCCEEDED(hr), "Failed to get DirectDraw4 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DirectDraw4 interface, hr %#lx.\n", hr);
     IDirect3D3_Release(d3d);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -13331,7 +13331,7 @@ static void test_cross_device_blt(void)
     surface_desc.dwHeight = 480;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -13339,7 +13339,7 @@ static void test_cross_device_blt(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_VIDEOMEMORY;
     U5(surface_desc).dwBackBufferCount = 2;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -13354,37 +13354,37 @@ static void test_cross_device_blt(void)
     U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x000003e0;
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x0000001f;
     hr = IDirectDraw4_CreateSurface(ddraw2, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 0xff0000ff;
     hr = IDirectDrawSurface4_Blt(surface2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Blt(surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(surface, 320, 240);
-    ok(color == 0x00000000, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00000000, "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirectDrawSurface4_Blt(sysmem_surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(sysmem_surface, 320, 240);
-    ok(color == 0x00000000, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00000000, "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_IsLost(sysmem_surface);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Blt(sysmem_surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(sysmem_surface, 320, 240);
-    ok(color == 0x00000000, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00000000, "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface4_Release(surface2);
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -13394,14 +13394,14 @@ static void test_cross_device_blt(void)
     surface_desc.dwHeight = 480;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw4_CreateSurface(ddraw2, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(surface2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Blt(sysmem_surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    todo_wine ok(hr == D3D_OK, "Failed to blit, hr %#x.\n", hr);
+    todo_wine ok(hr == D3D_OK, "Failed to blit, hr %#lx.\n", hr);
     color = get_surface_color(sysmem_surface, 320, 240);
-    todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface4_Release(surface);
     IDirectDrawSurface4_Release(surface2);
@@ -13409,9 +13409,9 @@ static void test_cross_device_blt(void)
     IDirectDraw4_Release(ddraw);
     IDirectDraw4_Release(ddraw2);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     refcount = IDirect3DDevice3_Release(device2);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
     DestroyWindow(window2);
 }
@@ -13450,61 +13450,61 @@ static void test_color_clamping(void)
     }
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat);
-    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_STENCILENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
-    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_TEXTUREFACTOR, 0xff404040);
-    ok(SUCCEEDED(hr), "Failed to set texture factor, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture factor, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_ADD);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_SPECULAR);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_MODULATE);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 1, D3DTSS_COLORARG1, D3DTA_TFACTOR);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 1, D3DTSS_COLORARG2, D3DTA_CURRENT);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xff00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00404040, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00404040, 1), "Got unexpected color 0x%08lx.\n", color);
 
     destroy_viewport(device, viewport);
     IDirectDrawSurface4_Release(rt);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -13576,11 +13576,11 @@ static void test_getdc(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw4_GetDisplayMode(ddraw, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#lx.\n", hr);
     screen_bpp = U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount;
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
@@ -13599,7 +13599,7 @@ static void test_getdc(void)
             surface_desc.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE;
             if (FAILED(hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL)))
             {
-                skip("Failed to create surface for format %s (hr %#x), skipping tests.\n", test_data[i].name, hr);
+                skip("Failed to create surface for format %s (hr %#lx), skipping tests.\n", test_data[i].name, hr);
                 continue;
             }
         }
@@ -13608,9 +13608,9 @@ static void test_getdc(void)
         hr = IDirectDrawSurface4_GetDC(surface, &dc);
         if (test_data[i].getdc_supported)
             ok(SUCCEEDED(hr) || broken(hr == test_data[i].alt_result),
-                    "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+                    "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         else
-            ok(FAILED(hr), "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+            ok(FAILED(hr), "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         if (SUCCEEDED(hr))
         {
@@ -13621,10 +13621,10 @@ static void test_getdc(void)
             int size;
 
             type = GetObjectType(dc);
-            ok(type == OBJ_MEMDC, "Got unexpected object type %#x for format %s.\n", type, test_data[i].name);
+            ok(type == OBJ_MEMDC, "Got unexpected object type %#lx for format %s.\n", type, test_data[i].name);
             bitmap = GetCurrentObject(dc, OBJ_BITMAP);
             type = GetObjectType(bitmap);
-            ok(type == OBJ_BITMAP, "Got unexpected object type %#x for format %s.\n", type, test_data[i].name);
+            ok(type == OBJ_BITMAP, "Got unexpected object type %#lx for format %s.\n", type, test_data[i].name);
 
             size = GetObjectA(bitmap, sizeof(dib), &dib);
             ok(size == sizeof(dib), "Got unexpected size %d for format %s.\n", size, test_data[i].name);
@@ -13648,11 +13648,11 @@ static void test_getdc(void)
             ok(!!dib.dsBm.bmBits || broken(!pDwmIsCompositionEnabled && dib.dsBm.bmBitsPixel == screen_bpp),
                     "Got unexpected bits %p for format %s.\n", dib.dsBm.bmBits, test_data[i].name);
 
-            ok(dib.dsBmih.biSize == sizeof(dib.dsBmih), "Got unexpected size %u for format %s.\n",
+            ok(dib.dsBmih.biSize == sizeof(dib.dsBmih), "Got unexpected size %lu for format %s.\n",
                     dib.dsBmih.biSize, test_data[i].name);
-            ok(dib.dsBmih.biWidth == surface_desc.dwWidth, "Got unexpected width %d for format %s.\n",
+            ok(dib.dsBmih.biWidth == surface_desc.dwWidth, "Got unexpected width %ld for format %s.\n",
                     dib.dsBmih.biHeight, test_data[i].name);
-            ok(dib.dsBmih.biHeight == surface_desc.dwHeight, "Got unexpected height %d for format %s.\n",
+            ok(dib.dsBmih.biHeight == surface_desc.dwHeight, "Got unexpected height %ld for format %s.\n",
                     dib.dsBmih.biHeight, test_data[i].name);
             ok(dib.dsBmih.biPlanes == 1, "Got unexpected plane count %u for format %s.\n",
                     dib.dsBmih.biPlanes, test_data[i].name);
@@ -13661,17 +13661,17 @@ static void test_getdc(void)
                     dib.dsBmih.biBitCount, test_data[i].name);
             ok(dib.dsBmih.biCompression == (U1(test_data[i].format).dwRGBBitCount == 16 ? BI_BITFIELDS : BI_RGB)
                     || broken(U1(test_data[i].format).dwRGBBitCount == 32 && dib.dsBmih.biCompression == BI_BITFIELDS),
-                    "Got unexpected compression %#x for format %s.\n",
+                    "Got unexpected compression %#lx for format %s.\n",
                     dib.dsBmih.biCompression, test_data[i].name);
-            ok(!dib.dsBmih.biSizeImage, "Got unexpected image size %u for format %s.\n",
+            ok(!dib.dsBmih.biSizeImage, "Got unexpected image size %lu for format %s.\n",
                     dib.dsBmih.biSizeImage, test_data[i].name);
-            ok(!dib.dsBmih.biXPelsPerMeter, "Got unexpected horizontal resolution %d for format %s.\n",
+            ok(!dib.dsBmih.biXPelsPerMeter, "Got unexpected horizontal resolution %ld for format %s.\n",
                     dib.dsBmih.biXPelsPerMeter, test_data[i].name);
-            ok(!dib.dsBmih.biYPelsPerMeter, "Got unexpected vertical resolution %d for format %s.\n",
+            ok(!dib.dsBmih.biYPelsPerMeter, "Got unexpected vertical resolution %ld for format %s.\n",
                     dib.dsBmih.biYPelsPerMeter, test_data[i].name);
-            ok(!dib.dsBmih.biClrUsed, "Got unexpected used colour count %u for format %s.\n",
+            ok(!dib.dsBmih.biClrUsed, "Got unexpected used colour count %lu for format %s.\n",
                     dib.dsBmih.biClrUsed, test_data[i].name);
-            ok(!dib.dsBmih.biClrImportant, "Got unexpected important colour count %u for format %s.\n",
+            ok(!dib.dsBmih.biClrImportant, "Got unexpected important colour count %lu for format %s.\n",
                     dib.dsBmih.biClrImportant, test_data[i].name);
 
             if (dib.dsBmih.biCompression == BI_BITFIELDS)
@@ -13680,20 +13680,20 @@ static void test_getdc(void)
                         && dib.dsBitfields[1] == U3(test_data[i].format).dwGBitMask
                         && dib.dsBitfields[2] == U4(test_data[i].format).dwBBitMask)
                         || broken(!dib.dsBitfields[0] && !dib.dsBitfields[1] && !dib.dsBitfields[2]),
-                        "Got unexpected colour masks 0x%08x 0x%08x 0x%08x for format %s.\n",
+                        "Got unexpected colour masks 0x%08lx 0x%08lx 0x%08lx for format %s.\n",
                         dib.dsBitfields[0], dib.dsBitfields[1], dib.dsBitfields[2], test_data[i].name);
             }
             else
             {
                 ok(!dib.dsBitfields[0] && !dib.dsBitfields[1] && !dib.dsBitfields[2],
-                        "Got unexpected colour masks 0x%08x 0x%08x 0x%08x for format %s.\n",
+                        "Got unexpected colour masks 0x%08lx 0x%08lx 0x%08lx for format %s.\n",
                         dib.dsBitfields[0], dib.dsBitfields[1], dib.dsBitfields[2], test_data[i].name);
             }
             ok(!dib.dshSection, "Got unexpected section %p for format %s.\n", dib.dshSection, test_data[i].name);
-            ok(!dib.dsOffset, "Got unexpected offset %u for format %s.\n", dib.dsOffset, test_data[i].name);
+            ok(!dib.dsOffset, "Got unexpected offset %lu for format %s.\n", dib.dsOffset, test_data[i].name);
 
             hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-            ok(hr == DD_OK, "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+            ok(hr == DD_OK, "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         }
         else
         {
@@ -13709,147 +13709,147 @@ static void test_getdc(void)
         surface_desc.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE;
         if (FAILED(hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL)))
         {
-            skip("Failed to create mip-mapped texture for format %s (hr %#x), skipping tests.\n",
+            skip("Failed to create mip-mapped texture for format %s (hr %#lx), skipping tests.\n",
                     test_data[i].name, hr);
             continue;
         }
 
         hr = IDirectDrawSurface4_GetAttachedSurface(surface, &caps, &tmp);
-        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_GetAttachedSurface(tmp, &caps, &surface2);
-        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         IDirectDrawSurface4_Release(tmp);
 
         hr = IDirectDrawSurface4_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface4_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         dc2 = (void *)0x1234;
         hr = IDirectDrawSurface4_GetDC(surface, &dc2);
-        ok(hr == DDERR_DCALREADYCREATED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_DCALREADYCREATED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         ok(dc2 == (void *)0x1234, "Got unexpected dc %p for format %s.\n", dc, test_data[i].name);
         hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-        ok(hr == DDERR_NODC, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NODC, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         map_desc.dwSize = sizeof(map_desc);
         hr = IDirectDrawSurface4_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_SURFACEBUSY, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_SURFACEBUSY, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface4_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Unlock(surface, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         hr = IDirectDrawSurface4_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_SURFACEBUSY, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_SURFACEBUSY, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface4_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface4_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_GetDC(surface2, &dc2);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_ReleaseDC(surface2, dc2);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface4_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_GetDC(surface, &dc2);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_ReleaseDC(surface, dc2);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface4_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Lock(surface2, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Unlock(surface2, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface4_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface4_Lock(surface2, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Unlock(surface2, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface4_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Lock(surface2, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Unlock(surface2, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface4_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface4_Unlock(surface, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface4_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Unlock(surface, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface4_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Unlock(surface, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         hr = IDirectDrawSurface4_Unlock(surface2, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface4_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Unlock(surface2, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface4_Unlock(surface2, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         IDirectDrawSurface4_Release(surface2);
         IDirectDrawSurface4_Release(surface);
@@ -13890,77 +13890,77 @@ static void test_draw_primitive(void)
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get D3D interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get D3D interface, hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = D3DFVF_XYZ;
     vb_desc.dwNumVertices = 4;
     hr = IDirect3D3_CreateVertexBuffer(d3d, &vb_desc, &vb, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
 
     IDirect3D3_Release(d3d);
 
     memset(&strided, 0, sizeof(strided));
 
     hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, NULL, 0, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawIndexedPrimitiveStrided(device,
             D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, &strided, 0, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawIndexedPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitiveStrided(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, &strided, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, 0, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, NULL, 0, indices, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawIndexedPrimitiveStrided(device,
             D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, &strided, 0, indices, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawIndexedPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, indices, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     strided.position.lpvData = quad;
     strided.position.dwStride = sizeof(*quad);
     hr = IDirect3DVertexBuffer_Lock(vb, 0, &data, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     memcpy(data, quad, sizeof(quad));
     hr = IDirect3DVertexBuffer_Unlock(vb);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawIndexedPrimitiveStrided(device,
             D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, &strided, 4, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawIndexedPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitiveStrided(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, &strided, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, 0, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, indices, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawIndexedPrimitiveStrided(device,
             D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, &strided, 4, indices, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawIndexedPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, indices, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     IDirect3DVertexBuffer_Release(vb);
     destroy_viewport(device, viewport);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -14024,20 +14024,20 @@ static void test_edge_antialiasing_blending(void)
     memset(&hel_desc, 0, sizeof(hel_desc));
     hel_desc.dwSize = sizeof(hel_desc);
     hr = IDirect3DDevice3_GetCaps(device, &hal_desc, &hel_desc);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
-    trace("HAL line edge antialiasing support: %#x.\n",
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
+    trace("HAL line edge antialiasing support: %#lx.\n",
             hal_desc.dpcLineCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES);
-    trace("HAL triangle edge antialiasing support: %#x.\n",
+    trace("HAL triangle edge antialiasing support: %#lx.\n",
             hal_desc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES);
-    trace("HEL line edge antialiasing support: %#x.\n",
+    trace("HEL line edge antialiasing support: %#lx.\n",
             hel_desc.dpcLineCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES);
-    trace("HEL triangle edge antialiasing support: %#x.\n",
+    trace("HEL triangle edge antialiasing support: %#lx.\n",
             hel_desc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES);
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get D3D interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get D3D interface, hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get DirectDraw4 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DirectDraw4 interface, hr %#lx.\n", hr);
     IDirect3D3_Release(d3d);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -14053,134 +14053,134 @@ static void test_edge_antialiasing_blending(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(U4(surface_desc).ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &offscreen, NULL);
-    ok(hr == D3D_OK, "Creating the offscreen render target failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Creating the offscreen render target failed, hr %#lx.\n", hr);
 
     ds = get_depth_stencil(device);
     hr = IDirectDrawSurface4_AddAttachedSurface(offscreen, ds);
-    todo_wine ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
+    todo_wine ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
     IDirectDrawSurface4_Release(ds);
 
     hr = IDirect3DDevice3_SetRenderTarget(device, offscreen, 0);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat);
-    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_STENCILENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
-    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable blending, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable blending, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
-    ok(SUCCEEDED(hr), "Failed to set src blend, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set src blend, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_DESTALPHA);
-    ok(SUCCEEDED(hr), "Failed to set dest blend, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set dest blend, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set alpha op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set alpha op, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set alpha arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set alpha arg, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xccff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             green_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x00cc7f00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00cc7f00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0x7f00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             red_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x00cc7f00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00cc7f00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable blending, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable blending, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xccff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             green_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0x7f00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             red_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_EDGEANTIALIAS, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable edge antialiasing, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable edge antialiasing, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xccff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             green_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0x7f00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             red_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface4_Release(offscreen);
     IDirectDraw4_Release(ddraw);
     destroy_viewport(device, viewport);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -14307,11 +14307,11 @@ static void test_transform_vertices(void)
         return;
     }
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 256, 256);
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
 
     memset(&transformdata, 0, sizeof(transformdata));
     transformdata.dwSize = sizeof(transformdata);
@@ -14323,8 +14323,8 @@ static void test_transform_vertices(void)
 
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
 
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
@@ -14339,19 +14339,19 @@ static void test_transform_vertices(void)
                 out[i].x, out[i].y, out[i].z, out[i].w);
         ok(out[i].v1 == position_tests[i].v1 && out[i].v2 == position_tests[i].v2
                 && out[i].v3 == position_tests[i].v3 && out[i].v4 == position_tests[i].v4,
-                "Vertex %u payload is %u %u %u %u.\n", i, out[i].v1, out[i].v2, out[i].v3, out[i].v4);
+                "Vertex %u payload is %lu %lu %lu %lu.\n", i, out[i].v1, out[i].v2, out[i].v3, out[i].v4);
         ok(out[i].unused3 == 0xdeadbeef && out[i].unused4 == 0xcafecafe,
-                "Vertex %u unused data is %#x, %#x.\n", i, out[i].unused3, out[i].unused4);
+                "Vertex %u unused data is %#lx, %#lx.\n", i, out[i].unused3, out[i].unused4);
     }
 
     vp_data = vp_template;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
 
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
@@ -14368,12 +14368,12 @@ static void test_transform_vertices(void)
     vp_data.dwX = 10;
     vp_data.dwY = 20;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
         static const struct vec4 cmp[] =
@@ -14390,8 +14390,8 @@ static void test_transform_vertices(void)
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
         static const D3DHVERTEX cmp_h[] =
@@ -14404,7 +14404,7 @@ static void test_transform_vertices(void)
                 && compare_float(U2(cmp_h[i]).hy, U2(out_h[i]).hy, 4096)
                 && compare_float(U3(cmp_h[i]).hz, U3(out_h[i]).hz, 4096)
                 && cmp_h[i].dwFlags == out_h[i].dwFlags,
-                "HVertex %u differs. Got %#x %f %f %f.\n", i,
+                "HVertex %u differs. Got %#lx %f %f %f.\n", i,
                 out_h[i].dwFlags, U1(out_h[i]).hx, U2(out_h[i]).hy, U3(out_h[i]).hz);
 
         /* No scheme has been found behind those return values. It seems to be
@@ -14429,8 +14429,8 @@ static void test_transform_vertices(void)
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(cliptest),
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(cliptest); ++i)
     {
         static const DWORD flags[] =
@@ -14440,19 +14440,19 @@ static void test_transform_vertices(void)
             0,
             D3DCLIP_LEFT  | D3DCLIP_BOTTOM | D3DCLIP_FRONT,
         };
-        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#x.\n", i, out_h[i].dwFlags);
+        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#lx.\n", i, out_h[i].dwFlags);
     }
 
     vp_data = vp_template;
     vp_data.dwWidth = 10;
     vp_data.dwHeight = 480;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(cliptest),
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(cliptest); ++i)
     {
         static const DWORD flags[] =
@@ -14462,7 +14462,7 @@ static void test_transform_vertices(void)
             D3DCLIP_LEFT,
             D3DCLIP_LEFT  | D3DCLIP_FRONT,
         };
-        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#x.\n", i, out_h[i].dwFlags);
+        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#lx.\n", i, out_h[i].dwFlags);
     }
 
     vp_data = vp_template;
@@ -14471,11 +14471,11 @@ static void test_transform_vertices(void)
     vp_data.dvScaleX = 1;
     vp_data.dvScaleY = 1;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(cliptest),
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(cliptest); ++i)
     {
         static const DWORD flags[] =
@@ -14485,7 +14485,7 @@ static void test_transform_vertices(void)
             0,
             D3DCLIP_FRONT,
         };
-        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#x.\n", i, out_h[i].dwFlags);
+        ok(flags[i] == out_h[i].dwFlags, "Cliptest %u returned %#lx.\n", i, out_h[i].dwFlags);
     }
 
     /* Finally try to figure out how the DWORD dwOffscreen works.
@@ -14496,51 +14496,51 @@ static void test_transform_vertices(void)
     vp_data.dvScaleX = 10000.0f;
     vp_data.dvScaleY = 10000.0f;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     transformdata.lpIn = cliptest;
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
 
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %lx.\n", offscreen);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, 2,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %lx.\n", offscreen);
     hr = IDirect3DViewport2_TransformVertices(viewport, 3,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
 
     transformdata.lpIn = cliptest + 1;
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_BACK | D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_BACK | D3DCLIP_RIGHT | D3DCLIP_TOP), "Offscreen is %lx.\n", offscreen);
 
     transformdata.lpIn = cliptest + 2;
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %lx.\n", offscreen);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, 2,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %lx.\n", offscreen);
 
     transformdata.lpIn = cliptest + 3;
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == (D3DCLIP_FRONT | D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == (D3DCLIP_FRONT | D3DCLIP_BOTTOM | D3DCLIP_LEFT), "Offscreen is %lx.\n", offscreen);
 
     transformdata.lpIn = offscreentest;
     transformdata.dwInSize = sizeof(offscreentest[0]);
@@ -14550,21 +14550,21 @@ static void test_transform_vertices(void)
     vp_data.dvScaleX = 1.0f;
     vp_data.dvScaleY = 1.0f;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
 
     vp_data.dwWidth = 256;
     vp_data.dwHeight = 256;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == D3DCLIP_RIGHT, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == D3DCLIP_RIGHT, "Offscreen is %lx.\n", offscreen);
 
     /* Test the effect of Matrices.
      *
@@ -14580,20 +14580,20 @@ static void test_transform_vertices(void)
     vp_data.dvMinZ = 0.0f;
     vp_data.dvMaxZ = 1.0f;
     hr = IDirect3DViewport2_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat_translate1);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat_scale);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat_translate2);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
 
     transformdata.lpIn = position_tests;
     transformdata.dwInSize = sizeof(position_tests[0]);
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
@@ -14612,48 +14612,48 @@ static void test_transform_vertices(void)
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, 0, &offscreen);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
-    ok(offscreen == 0xdeadbeef, "Offscreen is %x.\n", offscreen);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
+    ok(offscreen == 0xdeadbeef, "Offscreen is %lx.\n", offscreen);
 
     /* NULL transform data. */
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             NULL, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
-    ok(offscreen == 0xdeadbeef, "Offscreen is %x.\n", offscreen);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
+    ok(offscreen == 0xdeadbeef, "Offscreen is %lx.\n", offscreen);
     hr = IDirect3DViewport2_TransformVertices(viewport, 0,
             NULL, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
-    ok(offscreen == 0xdeadbeef, "Offscreen is %x.\n", offscreen);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
+    ok(offscreen == 0xdeadbeef, "Offscreen is %lx.\n", offscreen);
 
     /* NULL transform data and NULL dwOffscreen.
      *
      * Valid transform data + NULL dwOffscreen -> crash. */
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             NULL, D3DTRANSFORM_UNCLIPPED, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
 
     /* No vertices. */
     hr = IDirect3DViewport2_TransformVertices(viewport, 0,
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     hr = IDirect3DViewport2_TransformVertices(viewport, 0,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == ~0U, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == ~0U, "Offscreen is %lx.\n", offscreen);
 
     /* Invalid sizes. */
     offscreen = 0xdeadbeef;
     transformdata.dwSize = sizeof(transformdata) - 1;
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
-    ok(offscreen == 0xdeadbeef, "Offscreen is %x.\n", offscreen);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
+    ok(offscreen == 0xdeadbeef, "Offscreen is %lx.\n", offscreen);
     transformdata.dwSize = sizeof(transformdata) + 1;
     hr = IDirect3DViewport2_TransformVertices(viewport, 1,
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#x.\n", hr);
-    ok(offscreen == 0xdeadbeef, "Offscreen is %x.\n", offscreen);
+    ok(hr == DDERR_INVALIDPARAMS, "TransformVertices returned %#lx.\n", hr);
+    ok(offscreen == 0xdeadbeef, "Offscreen is %lx.\n", offscreen);
 
     /* NULL lpIn or lpOut -> crash, except when transforming 0 vertices. */
     transformdata.dwSize = sizeof(transformdata);
@@ -14662,8 +14662,8 @@ static void test_transform_vertices(void)
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport2_TransformVertices(viewport, 0,
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(offscreen == ~0U, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(offscreen == ~0U, "Offscreen is %lx.\n", offscreen);
 
     /* Test how vertices are transformed during draws. */
     vp_data.dwX = 20;
@@ -14675,38 +14675,38 @@ static void test_transform_vertices(void)
     vp_data.dvMinZ = 0.0f;
     vp_data.dvMaxZ = 1.0f;
     hr = IDirect3DViewport3_SetViewport(viewport, &vp_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to activate the viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0x000000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 128, 143);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 132, 143);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 128, 147);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 132, 147);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 177, 217);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 181, 217);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 177, 221);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 181, 221);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
 
     /* Test D3DVIEWPORT2 behavior. */
     vp2_data.dwSize = sizeof(vp2_data);
@@ -14721,12 +14721,12 @@ static void test_transform_vertices(void)
     vp2_data.dvMinZ = 0.0f;
     vp2_data.dvMaxZ = 2.0f;
     hr = IDirect3DViewport3_SetViewport2(viewport, &vp2_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#lx.\n", hr);
     transformdata.lpIn = position_tests;
     transformdata.lpOut = out;
     hr = IDirect3DViewport3_TransformVertices(viewport, ARRAY_SIZE(position_tests),
             &transformdata, D3DTRANSFORM_UNCLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
     for (i = 0; i < ARRAY_SIZE(position_tests); ++i)
     {
         static const struct vec4 cmp[] =
@@ -14741,40 +14741,40 @@ static void test_transform_vertices(void)
     }
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0x0000ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 58, 118);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 62, 118);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 58, 122);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 62, 122);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 157, 177);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 161, 177);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 157, 181);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 161, 181);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat_identity);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat_identity);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat_transform3);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
 
     vp2_data.dwX = 0.0;
     vp2_data.dwY = 0.0;
@@ -14787,14 +14787,14 @@ static void test_transform_vertices(void)
     vp2_data.dvMinZ = 0.0f;
     vp2_data.dvMaxZ = 0.5f;
     hr = IDirect3DViewport3_SetViewport2(viewport, &vp2_data);
-    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#lx.\n", hr);
     transformdata.lpIn = cliptest;
     transformdata.dwInSize = sizeof(cliptest[0]);
     offscreen = 0xdeadbeef;
     hr = IDirect3DViewport3_TransformVertices(viewport, ARRAY_SIZE(cliptest),
             &transformdata, D3DTRANSFORM_CLIPPED, &offscreen);
-    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#x.\n", hr);
-    ok(!offscreen, "Offscreen is %x.\n", offscreen);
+    ok(SUCCEEDED(hr), "Failed to transform vertices, hr %#lx.\n", hr);
+    ok(!offscreen, "Offscreen is %lx.\n", offscreen);
     for (i = 0; i < ARRAY_SIZE(cliptest); ++i)
     {
         static const D3DHVERTEX cmp_h[] =
@@ -14808,14 +14808,14 @@ static void test_transform_vertices(void)
                 && compare_float(U2(cmp_h[i]).hy, U2(out_h[i]).hy, 4096)
                 && compare_float(U3(cmp_h[i]).hz, U3(out_h[i]).hz, 4096)
                 && cmp_h[i].dwFlags == out_h[i].dwFlags,
-                "HVertex %u differs. Got %#x %f %f %f.\n", i,
+                "HVertex %u differs. Got %#lx %f %f %f.\n", i,
                 out_h[i].dwFlags, U1(out_h[i]).hx, U2(out_h[i]).hy, U3(out_h[i]).hz);
     }
 
     destroy_viewport(device, viewport);
     IDirectDrawSurface4_Release(rt);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -14837,14 +14837,14 @@ static void test_display_mode_surface_pixel_format(void)
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw4_GetDisplayMode(ddraw, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#lx.\n", hr);
     width = surface_desc.dwWidth;
     height = surface_desc.dwHeight;
 
     window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
             0, 0, width, height, NULL, NULL, NULL, NULL);
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     bpp = 0;
     if (SUCCEEDED(IDirectDraw4_SetDisplayMode(ddraw, width, height, 16, 0, 0)))
@@ -14857,10 +14857,10 @@ static void test_display_mode_surface_pixel_format(void)
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw4_GetDisplayMode(ddraw, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == width, "Got width %u, expected %u.\n", surface_desc.dwWidth, width);
-    ok(surface_desc.dwHeight == height, "Got height %u, expected %u.\n", surface_desc.dwHeight, height);
-    ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == width, "Got width %lu, expected %u.\n", surface_desc.dwWidth, width);
+    ok(surface_desc.dwHeight == height, "Got height %lu, expected %u.\n", surface_desc.dwHeight, height);
+    ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %lu, expected %u.\n",
             U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount, bpp);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -14869,14 +14869,14 @@ static void test_display_mode_surface_pixel_format(void)
     U5(surface_desc).dwBackBufferCount = 1;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == width, "Got width %u, expected %u.\n", surface_desc.dwWidth, width);
-    ok(surface_desc.dwHeight == height, "Got height %u, expected %u.\n", surface_desc.dwHeight, height);
-    ok(U4(surface_desc).ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#x.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == width, "Got width %lu, expected %u.\n", surface_desc.dwWidth, width);
+    ok(surface_desc.dwHeight == height, "Got height %lu, expected %u.\n", surface_desc.dwHeight, height);
+    ok(U4(surface_desc).ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#lx.\n",
             U4(surface_desc).ddpfPixelFormat.dwFlags);
-    ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
+    ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %lu, expected %u.\n",
             U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount, bpp);
     IDirectDrawSurface4_Release(surface);
 
@@ -14887,17 +14887,17 @@ static void test_display_mode_surface_pixel_format(void)
     surface_desc.dwHeight = height;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(U4(surface_desc).ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#x.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(U4(surface_desc).ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#lx.\n",
             U4(surface_desc).ddpfPixelFormat.dwFlags);
-    ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
+    ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %lu, expected %u.\n",
             U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount, bpp);
     IDirectDrawSurface4_Release(surface);
 
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -14955,7 +14955,7 @@ static void test_surface_desc_size(void)
         return;
     }
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(surface_caps); ++i)
     {
@@ -14971,9 +14971,9 @@ static void test_surface_desc_size(void)
             continue;
         }
         hr = IDirectDrawSurface_QueryInterface(surface4, &IID_IDirectDrawSurface, (void **)&surface);
-        ok(hr == DD_OK, "Failed to query IDirectDrawSurface, hr %#x, type %s.\n", hr, surface_caps[i].name);
+        ok(hr == DD_OK, "Failed to query IDirectDrawSurface, hr %#lx, type %s.\n", hr, surface_caps[i].name);
         hr = IDirectDrawSurface_QueryInterface(surface4, &IID_IDirectDrawSurface3, (void **)&surface3);
-        ok(hr == DD_OK, "Failed to query IDirectDrawSurface3, hr %#x, type %s.\n", hr, surface_caps[i].name);
+        ok(hr == DD_OK, "Failed to query IDirectDrawSurface3, hr %#lx, type %s.\n", hr, surface_caps[i].name);
 
         /* GetSurfaceDesc() */
         for (j = 0; j < ARRAY_SIZE(desc_sizes); ++j)
@@ -14982,21 +14982,21 @@ static void test_surface_desc_size(void)
             desc.dwSize = desc_sizes[j];
             expected_hr = desc.dwSize == sizeof(DDSURFACEDESC) ? DD_OK : DDERR_INVALIDPARAMS;
             hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc.desc1);
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
 
             memset(&desc, 0, sizeof(desc));
             desc.dwSize = desc_sizes[j];
             expected_hr = desc.dwSize == sizeof(DDSURFACEDESC) ? DD_OK : DDERR_INVALIDPARAMS;
             hr = IDirectDrawSurface3_GetSurfaceDesc(surface3, &desc.desc1);
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
 
             memset(&desc, 0, sizeof(desc));
             desc.dwSize = desc_sizes[j];
             expected_hr = desc.dwSize == sizeof(DDSURFACEDESC2) ? DD_OK : DDERR_INVALIDPARAMS;
             hr = IDirectDrawSurface4_GetSurfaceDesc(surface4, &desc.desc2);
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
         }
 
@@ -15013,22 +15013,22 @@ static void test_surface_desc_size(void)
             desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
             hr = IDirectDrawSurface_Lock(surface, NULL, &desc.desc1, 0, 0);
             expected_hr = valid_size ? DD_OK : DDERR_INVALIDPARAMS;
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
-            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
+            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %lu, type %s.\n",
                     desc_sizes[j], desc.dwSize, surface_caps[i].name);
             ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
                     desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
             if (SUCCEEDED(hr))
             {
-                ok(desc.desc1.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
+                ok(desc.desc1.dwWidth == 128, "Got unexpected width %lu, dwSize %u, type %s.\n",
                         desc.desc1.dwWidth, desc_sizes[j], surface_caps[i].name);
-                ok(desc.desc1.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
+                ok(desc.desc1.dwHeight == 128, "Got unexpected height %lu, dwSize %u, type %s.\n",
                         desc.desc1.dwHeight, desc_sizes[j], surface_caps[i].name);
                 expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
                 todo_wine_if(!expected_texture_stage)
                 ok(desc.desc2.dwTextureStage == expected_texture_stage,
-                        "Got unexpected texture stage %#x, dwSize %u, type %s.\n",
+                        "Got unexpected texture stage %#lx, dwSize %u, type %s.\n",
                         desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
                 IDirectDrawSurface_Unlock(surface, NULL);
             }
@@ -15039,22 +15039,22 @@ static void test_surface_desc_size(void)
             desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
             hr = IDirectDrawSurface3_Lock(surface3, NULL, &desc.desc1, 0, 0);
             expected_hr = valid_size ? DD_OK : DDERR_INVALIDPARAMS;
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
-            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
+            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %lu, type %s.\n",
                     desc_sizes[j], desc.dwSize, surface_caps[i].name);
             ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
                     desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
             if (SUCCEEDED(hr))
             {
-                ok(desc.desc1.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
+                ok(desc.desc1.dwWidth == 128, "Got unexpected width %lu, dwSize %u, type %s.\n",
                         desc.desc1.dwWidth, desc_sizes[j], surface_caps[i].name);
-                ok(desc.desc1.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
+                ok(desc.desc1.dwHeight == 128, "Got unexpected height %lu, dwSize %u, type %s.\n",
                         desc.desc1.dwHeight, desc_sizes[j], surface_caps[i].name);
                 expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
                 todo_wine_if(!expected_texture_stage)
                 ok(desc.desc2.dwTextureStage == expected_texture_stage,
-                        "Got unexpected texture stage %#x, dwSize %u, type %s.\n",
+                        "Got unexpected texture stage %#lx, dwSize %u, type %s.\n",
                         desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
                 IDirectDrawSurface3_Unlock(surface3, NULL);
             }
@@ -15065,21 +15065,21 @@ static void test_surface_desc_size(void)
             desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
             hr = IDirectDrawSurface4_Lock(surface4, NULL, &desc.desc2, 0, 0);
             expected_hr = valid_size ? DD_OK : DDERR_INVALIDPARAMS;
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
-            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
+            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %lu, type %s.\n",
                     desc_sizes[j], desc.dwSize, surface_caps[i].name);
             ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
                     desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
             if (SUCCEEDED(hr))
             {
-                ok(desc.desc2.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
+                ok(desc.desc2.dwWidth == 128, "Got unexpected width %lu, dwSize %u, type %s.\n",
                         desc.desc2.dwWidth, desc_sizes[j], surface_caps[i].name);
-                ok(desc.desc2.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
+                ok(desc.desc2.dwHeight == 128, "Got unexpected height %lu, dwSize %u, type %s.\n",
                         desc.desc2.dwHeight, desc_sizes[j], surface_caps[i].name);
                 expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
                 ok(desc.desc2.dwTextureStage == expected_texture_stage,
-                        "Got unexpected texture stage %#x, dwSize %u, type %s.\n",
+                        "Got unexpected texture stage %#lx, dwSize %u, type %s.\n",
                         desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
                 IDirectDrawSurface4_Unlock(surface4, NULL);
             }
@@ -15098,17 +15098,17 @@ static void test_surface_desc_size(void)
         expected_hr = (desc.dwSize == sizeof(DDSURFACEDESC) || desc.dwSize == sizeof(DDSURFACEDESC2))
                 ? DD_OK : DDERR_INVALIDPARAMS;
         hr = IDirectDraw4_GetDisplayMode(ddraw, &desc.desc2);
-        ok(hr == expected_hr, "Got hr %#x, expected %#x, size %u.\n", hr, expected_hr, desc_sizes[j]);
+        ok(hr == expected_hr, "Got hr %#lx, expected %#lx, size %u.\n", hr, expected_hr, desc_sizes[j]);
         if (SUCCEEDED(hr))
         {
-            ok(desc.dwSize == sizeof(DDSURFACEDESC2), "Wrong size %u for %u.\n", desc.dwSize, desc_sizes[j]);
+            ok(desc.dwSize == sizeof(DDSURFACEDESC2), "Wrong size %lu for %u.\n", desc.dwSize, desc_sizes[j]);
             ok(desc.blob[desc_sizes[j]] == 0xcc, "Overflow for size %u.\n", desc_sizes[j]);
             ok(desc.blob[desc_sizes[j] - 1] != 0xcc, "Struct not cleared for size %u.\n", desc_sizes[j]);
         }
     }
 
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
 }
 
 static void test_get_surface_from_dc(void)
@@ -15127,7 +15127,7 @@ static void test_get_surface_from_dc(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -15137,59 +15137,59 @@ static void test_get_surface_from_dc(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
 
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirectDrawSurface, (void **)&surface1);
-    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#lx.\n", hr);
 
     refcount = get_refcount((IUnknown *)surface1);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     refcount = get_refcount((IUnknown *)surface);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface4_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
 
     tmp = (void *)0xdeadbeef;
     device_dc = (void *)0xdeadbeef;
     hr = GetSurfaceFromDC(NULL, &tmp, &device_dc);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!tmp, "Got unexpected surface %p.\n", tmp);
     ok(!device_dc, "Got unexpected device_dc %p.\n", device_dc);
 
     device_dc = (void *)0xdeadbeef;
     hr = GetSurfaceFromDC(dc, NULL, &device_dc);
-    ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
     ok(device_dc == (void *)0xdeadbeef, "Got unexpected device_dc %p.\n", device_dc);
 
     tmp = (void *)0xdeadbeef;
     hr = GetSurfaceFromDC(dc, &tmp, NULL);
-    ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
     ok(!tmp, "Got unexpected surface %p.\n", tmp);
 
     hr = GetSurfaceFromDC(dc, &tmp, &device_dc);
-    ok(SUCCEEDED(hr), "GetSurfaceFromDC failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetSurfaceFromDC failed, hr %#lx.\n", hr);
     ok(tmp == surface1, "Got unexpected surface %p, expected %p.\n", tmp, surface1);
     IDirectDrawSurface_Release(tmp);
 
     ret = GetObjectType(device_dc);
-    todo_wine ok(ret == OBJ_DC, "Got unexpected object type %#x.\n", ret);
+    todo_wine ok(ret == OBJ_DC, "Got unexpected object type %#lx.\n", ret);
     ret = GetDeviceCaps(device_dc, TECHNOLOGY);
-    todo_wine ok(ret == DT_RASDISPLAY, "Got unexpected technology %#x.\n", ret);
+    todo_wine ok(ret == DT_RASDISPLAY, "Got unexpected technology %#lx.\n", ret);
 
     hr = IDirectDraw4_GetSurfaceFromDC(ddraw, dc, NULL);
-    ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw4_GetSurfaceFromDC(ddraw, dc, (IDirectDrawSurface4 **)&tmp);
-    ok(SUCCEEDED(hr), "GetSurfaceFromDC failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetSurfaceFromDC failed, hr %#lx.\n", hr);
     ok(tmp == surface1, "Got unexpected surface %p, expected %p.\n", tmp, surface1);
 
     refcount = get_refcount((IUnknown *)surface1);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
     refcount = get_refcount((IUnknown *)surface);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface4_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "ReleaseDC failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "ReleaseDC failed, hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(tmp);
 
@@ -15199,20 +15199,20 @@ static void test_get_surface_from_dc(void)
     tmp = (void *)0xdeadbeef;
     device_dc = (void *)0xdeadbeef;
     hr = GetSurfaceFromDC(dc, &tmp, &device_dc);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!tmp, "Got unexpected surface %p.\n", tmp);
     ok(!device_dc, "Got unexpected device_dc %p.\n", device_dc);
 
     tmp = (void *)0xdeadbeef;
     hr = IDirectDraw4_GetSurfaceFromDC(ddraw, dc, (IDirectDrawSurface4 **)&tmp);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!tmp, "Got unexpected surface %p.\n", tmp);
 
     ok(DeleteDC(dc), "DeleteDC failed.\n");
 
     tmp = (void *)0xdeadbeef;
     hr = IDirectDraw4_GetSurfaceFromDC(ddraw, NULL, (IDirectDrawSurface4 **)&tmp);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!tmp, "Got unexpected surface %p.\n", tmp);
 
     IDirectDrawSurface4_Release(surface);
@@ -15239,7 +15239,7 @@ static void test_ck_operation(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -15253,16 +15253,16 @@ static void test_ck_operation(void)
     U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x0000ff00;
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     surface_desc.dwFlags |= DDSD_CKSRCBLT;
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00ff00ff;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00ff00ff;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &src, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Lock(src, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ok(!(surface_desc.dwFlags & DDSD_LPSURFACE), "Surface desc has LPSURFACE Flags set.\n");
     color = surface_desc.lpSurface;
     color[0] = 0x77010203;
@@ -15270,33 +15270,33 @@ static void test_ck_operation(void)
     color[2] = 0x77ff00ff;
     color[3] = 0x00ff00ff;
     hr = IDirectDrawSurface4_Unlock(src, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     for (i = 0; i < 2; ++i)
     {
         hr = IDirectDrawSurface4_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         color = surface_desc.lpSurface;
         color[0] = 0xcccccccc;
         color[1] = 0xcccccccc;
         color[2] = 0xcccccccc;
         color[3] = 0xcccccccc;
         hr = IDirectDrawSurface4_Unlock(dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         if (i)
         {
             hr = IDirectDrawSurface4_BltFast(dst, 0, 0, src, NULL, DDBLTFAST_SRCCOLORKEY);
-            ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
         }
         else
         {
             hr = IDirectDrawSurface4_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC, NULL);
-            ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
         }
 
         hr = IDirectDrawSurface4_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT | DDLOCK_READONLY, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         ok(!(surface_desc.dwFlags & DDSD_LPSURFACE), "Surface desc has LPSURFACE Flags set.\n");
         color = surface_desc.lpSurface;
         /* Different behavior on some drivers / windows versions. Some versions ignore the X channel when
@@ -15311,69 +15311,69 @@ static void test_ck_operation(void)
                 && color[2] == 0xcccccccc && color[3] == 0xcccccccc) /* Nvidia */
                 || broken(color[0] == 0xff010203 && color[1] == 0xff010203
                 && color[2] == 0xcccccccc && color[3] == 0xcccccccc) /* Testbot */,
-                "Destination data after blitting is %08x %08x %08x %08x, i=%u.\n",
+                "Destination data after blitting is %08lx %08lx %08lx %08lx, i=%u.\n",
                 color[0], color[1], color[2], color[3], i);
         hr = IDirectDrawSurface4_Unlock(dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
     }
 
     hr = IDirectDrawSurface4_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x00ff00ff && ckey.dwColorSpaceHighValue == 0x00ff00ff,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface4_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface4_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x0000ff00 && ckey.dwColorSpaceHighValue == 0x0000ff00,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface4_GetSurfaceDesc(src, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue == 0x0000ff00
             && surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue == 0x0000ff00,
-            "Got unexpected color key low=%08x high=%08x.\n", surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue,
+            "Got unexpected color key low=%08lx high=%08lx.\n", surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue,
             surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue);
 
     /* Test SetColorKey with dwColorSpaceHighValue < dwColorSpaceLowValue */
     ckey.dwColorSpaceLowValue = 0x000000ff;
     ckey.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDrawSurface4_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface4_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x000000ff && ckey.dwColorSpaceHighValue == 0x000000ff,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     ckey.dwColorSpaceLowValue = 0x000000ff;
     ckey.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDrawSurface4_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface4_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x000000ff && ckey.dwColorSpaceHighValue == 0x000000ff,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     ckey.dwColorSpaceLowValue = 0x000000fe;
     ckey.dwColorSpaceHighValue = 0x000000fd;
     hr = IDirectDrawSurface4_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface4_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x000000fe && ckey.dwColorSpaceHighValue == 0x000000fe,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     IDirectDrawSurface4_Release(src);
     IDirectDrawSurface4_Release(dst);
@@ -15393,18 +15393,18 @@ static void test_ck_operation(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(U4(surface_desc).ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &src, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = 0x0000ff00;
     ckey.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface4_SetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     ckey.dwColorSpaceLowValue = 0x00ff0000;
     ckey.dwColorSpaceHighValue = 0x00ff0000;
     hr = IDirectDrawSurface4_SetColorKey(dst, DDCKEY_DESTBLT, &ckey);
-    ok(SUCCEEDED(hr) || hr == DDERR_NOCOLORKEYHW, "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || hr == DDERR_NOCOLORKEYHW, "Failed to set color key, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
         /* Nvidia reject dest keys, AMD allows them. This applies to vidmem and sysmem surfaces. */
@@ -15415,11 +15415,11 @@ static void test_ck_operation(void)
     ckey.dwColorSpaceLowValue = 0x000000ff;
     ckey.dwColorSpaceHighValue = 0x000000ff;
     hr = IDirectDrawSurface4_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     ckey.dwColorSpaceLowValue = 0x000000aa;
     ckey.dwColorSpaceHighValue = 0x000000aa;
     hr = IDirectDrawSurface4_SetColorKey(src, DDCKEY_DESTBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
@@ -15429,7 +15429,7 @@ static void test_ck_operation(void)
     fx.ddckDestColorkey.dwColorSpaceLowValue = 0x00001100;
 
     hr = IDirectDrawSurface4_Lock(src, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     color[0] = 0x000000ff; /* Applies to src blt key in src surface. */
     color[1] = 0x000000aa; /* Applies to dst blt key in src surface. */
@@ -15438,77 +15438,77 @@ static void test_ck_operation(void)
     color[4] = 0x00001100; /* Src color key in ddbltfx. */
     color[5] = 0x00110000; /* Dst color key in ddbltfx. */
     hr = IDirectDrawSurface4_Unlock(src, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0x55555555;
     hr = IDirectDrawSurface4_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Test a blit without keying. */
     hr = IDirectDrawSurface4_Blt(dst, NULL, src, NULL, 0, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Should have copied src data unmodified to dst. */
     ok(color[0] == 0x000000ff && color[1] == 0x000000aa && color[2] == 0x00ff0000 &&
             color[3] == 0x0000ff00 && color[4] == 0x00001100 && color[5] == 0x00110000,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0x55555555;
     hr = IDirectDrawSurface4_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Src key. */
     hr = IDirectDrawSurface4_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Src key applied to color[0]. It is unmodified, the others are copied. */
     ok(color[0] == 0x55555555 && color[1] == 0x000000aa && color[2] == 0x00ff0000 &&
             color[3] == 0x0000ff00 && color[4] == 0x00001100 && color[5] == 0x00110000,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0x55555555;
     hr = IDirectDrawSurface4_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Src override. */
     hr = IDirectDrawSurface4_Blt(dst, NULL, src, NULL, DDBLT_KEYSRCOVERRIDE, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Override key applied to color[5]. It is unmodified, the others are copied. */
     ok(color[0] == 0x000000ff && color[1] == 0x000000aa && color[2] == 0x00ff0000 &&
             color[3] == 0x0000ff00 && color[4] == 0x00001100 && color[5] == 0x55555555,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0x55555555;
     hr = IDirectDrawSurface4_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Src override AND src key. That is not supposed to work. */
     hr = IDirectDrawSurface4_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC | DDBLT_KEYSRCOVERRIDE, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Ensure the destination was not changed. */
     ok(color[0] == 0x55555555 && color[1] == 0x55555555 && color[2] == 0x55555555 &&
             color[3] == 0x55555555 && color[4] == 0x55555555 && color[5] == 0x55555555,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     /* Use different dst colors for the dst key test. */
@@ -15519,19 +15519,19 @@ static void test_ck_operation(void)
     color[4] = 0x000000aa; /* Dest key in src surface. */
     color[5] = 0x000000aa; /* Dest key in src surface. */
     hr = IDirectDrawSurface4_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Dest key blit. The key is taken from the DESTINATION surface in v4! */
     hr = IDirectDrawSurface4_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Dst key applied to color[0,1], they are the only changed pixels. */
     todo_wine ok(color[0] == 0x000000ff && color[1] == 0x000000aa && color[2] == 0x00001100 &&
             color[3] == 0x00001100 && color[4] == 0x000000aa && color[5] == 0x000000aa,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = 0x00ff0000; /* Dest key in dst surface. */
@@ -15541,28 +15541,28 @@ static void test_ck_operation(void)
     color[4] = 0x000000aa; /* Dest key in src surface. */
     color[5] = 0x000000aa; /* Dest key in src surface. */
     hr = IDirectDrawSurface4_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* What happens with a QI'd older version of the interface? It takes the key
      * from the source surface. */
     hr = IDirectDrawSurface4_QueryInterface(src, &IID_IDirectDrawSurface, (void **)&src1);
-    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_QueryInterface(dst, &IID_IDirectDrawSurface, (void **)&dst1);
-    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Blt(dst1, NULL, src1, NULL, DDBLT_KEYDEST, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(dst1);
     IDirectDrawSurface_Release(src1);
 
     hr = IDirectDrawSurface7_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Dst key applied to color[4,5], they are the only changed pixels. */
     ok(color[0] == 0x00ff0000 && color[1] == 0x00ff0000 && color[2] == 0x00001100 &&
             color[3] == 0x00001100 && color[4] == 0x00001100 && color[5] == 0x00110000,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = 0x00ff0000; /* Dest key in dst surface. */
@@ -15572,19 +15572,19 @@ static void test_ck_operation(void)
     color[4] = 0x000000aa; /* Dest key in src surface. */
     color[5] = 0x000000aa; /* Dest key in src surface. */
     hr = IDirectDrawSurface7_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Dest override key blit. */
     hr = IDirectDrawSurface4_Blt(dst, NULL, src, NULL, DDBLT_KEYDESTOVERRIDE, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Dst key applied to color[2,3], they are the only changed pixels. */
     ok(color[0] == 0x00ff0000 && color[1] == 0x00ff0000 && color[2] == 0x00ff0000 &&
             color[3] == 0x0000ff00 && color[4] == 0x000000aa && color[5] == 0x000000aa,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = 0x00ff0000; /* Dest key in dst surface. */
@@ -15594,38 +15594,38 @@ static void test_ck_operation(void)
     color[4] = 0x000000aa; /* Dest key in src surface. */
     color[5] = 0x000000aa; /* Dest key in src surface. */
     hr = IDirectDrawSurface4_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Dest override together with surface key. Supposed to fail. */
     hr = IDirectDrawSurface4_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST | DDBLT_KEYDESTOVERRIDE, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Destination is unchanged. */
     ok(color[0] == 0x00ff0000 && color[1] == 0x00ff0000 && color[2] == 0x00001100 &&
             color[3] == 0x00001100 && color[4] == 0x000000aa && color[5] == 0x000000aa,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
     hr = IDirectDrawSurface4_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Source and destination key. This is driver dependent. New HW treats it like
      * DDBLT_KEYSRC. Older HW and some software renderers apply both keys. */
     if (0)
     {
         hr = IDirectDrawSurface4_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST | DDBLT_KEYSRC, &fx);
-        ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
         hr = IDirectDrawSurface4_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         color = surface_desc.lpSurface;
         /* Color[0] is filtered by the src key, 2-5 are filtered by the dst key, if
          * the driver applies it. */
         ok(color[0] == 0x00ff0000 && color[1] == 0x000000aa && color[2] == 0x00ff0000 &&
                 color[3] == 0x0000ff00 && color[4] == 0x00001100 && color[5] == 0x00110000,
-                "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+                "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
                 color[0], color[1], color[2], color[3], color[4], color[5]);
 
         color[0] = 0x00ff0000; /* Dest key in dst surface. */
@@ -15635,55 +15635,55 @@ static void test_ck_operation(void)
         color[4] = 0x000000aa; /* Dest key in src surface. */
         color[5] = 0x000000aa; /* Dest key in src surface. */
         hr = IDirectDrawSurface4_Unlock(dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
     }
 
     /* Override keys without ddbltfx parameter fail */
     hr = IDirectDrawSurface4_Blt(dst, NULL, src, NULL, DDBLT_KEYDESTOVERRIDE, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_Blt(dst, NULL, src, NULL, DDBLT_KEYSRCOVERRIDE, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Try blitting without keys in the source surface. */
     hr = IDirectDrawSurface4_SetColorKey(src, DDCKEY_SRCBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_SetColorKey(src, DDCKEY_DESTBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     /* That fails now. Do not bother to check that the data is unmodified. */
     hr = IDirectDrawSurface4_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Dest key blit still works, the destination surface key is used in v4. */
     hr = IDirectDrawSurface4_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Dst key applied to color[0,1], they are the only changed pixels. */
     todo_wine ok(color[0] == 0x000000ff && color[1] == 0x000000aa && color[2] == 0x00001100 &&
             color[3] == 0x00001100 && color[4] == 0x000000aa && color[5] == 0x000000aa,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
     hr = IDirectDrawSurface4_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Try blitting without keys in the destination surface. */
     hr = IDirectDrawSurface4_SetColorKey(dst, DDCKEY_SRCBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_SetColorKey(dst, DDCKEY_DESTBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     /* This fails, as sanity would dictate. */
     hr = IDirectDrawSurface4_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
 done:
     IDirectDrawSurface4_Release(src);
     IDirectDrawSurface4_Release(dst);
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -15710,7 +15710,7 @@ static void test_vb_refcount(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#lx.\n", hr);
 
     prev_d3d_refcount = get_refcount((IUnknown *)d3d);
     prev_device_refcount = get_refcount((IUnknown *)device);
@@ -15720,33 +15720,33 @@ static void test_vb_refcount(void)
     vb_desc.dwFVF = D3DFVF_XYZ;
     vb_desc.dwNumVertices = 4;
     hr = IDirect3D3_CreateVertexBuffer(d3d, &vb_desc, &vb, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
 
     cur_d3d_refcount = get_refcount((IUnknown *)d3d);
     cur_device_refcount = get_refcount((IUnknown *)device);
-    ok(cur_d3d_refcount == prev_d3d_refcount, "D3D object refcount changed from %u to %u.\n",
+    ok(cur_d3d_refcount == prev_d3d_refcount, "D3D object refcount changed from %lu to %lu.\n",
             prev_d3d_refcount, cur_d3d_refcount);
-    ok(cur_device_refcount == prev_device_refcount, "Device refcount changed from %u to %u.\n",
+    ok(cur_device_refcount == prev_device_refcount, "Device refcount changed from %lu to %lu.\n",
             prev_device_refcount, cur_device_refcount);
 
     hr = IDirect3DVertexBuffer_QueryInterface(vb, &IID_IDirect3DVertexBuffer, (void **)&vb1);
-    ok(hr == DD_OK, "Failed to query IDirect3DVertexBuffer, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to query IDirect3DVertexBuffer, hr %#lx.\n", hr);
     IDirect3DVertexBuffer_Release(vb1);
 
     hr = IDirect3DVertexBuffer_QueryInterface(vb, &IID_IDirect3DVertexBuffer7, (void **)&vb7);
-    ok(hr == E_NOINTERFACE, "Querying IDirect3DVertexBuffer7 returned unexpected hr %#x.\n", hr);
+    ok(hr == E_NOINTERFACE, "Querying IDirect3DVertexBuffer7 returned unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_QueryInterface(vb, &IID_IUnknown, (void **)&unk);
-    ok(hr == DD_OK, "Failed to query IUnknown, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to query IUnknown, hr %#lx.\n", hr);
     ok((IUnknown *)vb == unk,
             "IDirect3DVertexBuffer and IUnknown interface pointers don't match, %p != %p.\n", vb, unk);
     IUnknown_Release(unk);
 
     refcount = IDirect3DVertexBuffer_Release(vb);
-    ok(!refcount, "Vertex buffer has %u references left.\n", refcount);
+    ok(!refcount, "Vertex buffer has %lu references left.\n", refcount);
     IDirect3D3_Release(d3d);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -15825,7 +15825,7 @@ static void test_compute_sphere_visibility(void)
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &identity);
 
@@ -15836,17 +15836,17 @@ static void test_compute_sphere_visibility(void)
 
         hr = IDirect3DDevice3_ComputeSphereVisibility(device, tests[i].center, tests[i].radius,
                 tests[i].sphere_count, 0, result);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         for (j = 0; j < tests[i].sphere_count; ++j)
             todo_wine_if(tests[i].todo)
-                ok(result[j] == tests[i].expected[j], "Test %u sphere %u: expected %#x, got %#x.\n",
+                ok(result[j] == tests[i].expected[j], "Test %u sphere %u: expected %#lx, got %#lx.\n",
                         i, j, tests[i].expected[j], result[j]);
     }
 
     destroy_viewport(device, viewport);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -15871,9 +15871,9 @@ static void test_texture_stages_limits(void)
         return;
     }
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D interface, hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get DirectDraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DirectDraw interface, hr %#lx.\n", hr);
     IDirect3D3_Release(d3d);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -15883,25 +15883,25 @@ static void test_texture_stages_limits(void)
     surface_desc.dwWidth = 16;
     surface_desc.dwHeight = 16;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#lx.\n", hr);
     IDirectDrawSurface4_Release(surface);
 
     for (i = 0; i < 8; ++i)
     {
         hr = IDirect3DDevice3_SetTexture(device, i, texture);
-        ok(hr == D3D_OK, "Failed to set texture %u, hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Failed to set texture %u, hr %#lx.\n", i, hr);
         hr = IDirect3DDevice3_SetTexture(device, i, NULL);
-        ok(hr == D3D_OK, "Failed to set texture %u, hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Failed to set texture %u, hr %#lx.\n", i, hr);
         hr = IDirect3DDevice3_SetTextureStageState(device, i, D3DTSS_COLOROP, D3DTOP_ADD);
-        ok(hr == D3D_OK, "Failed to set texture stage state %u, hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Failed to set texture stage state %u, hr %#lx.\n", i, hr);
     }
 
     IDirectDraw4_Release(ddraw);
     IDirect3DTexture2_Release(texture);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -15922,24 +15922,24 @@ static void test_set_render_state(void)
     }
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     state = 0xdeadbeef;
     hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, &state);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(!state, "Got unexpected render state %#x.\n", state);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(!state, "Got unexpected render state %#lx.\n", state);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, &state);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(state == D3DTBLEND_MODULATE, "Got unexpected render state %#x.\n", state);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(state == D3DTBLEND_MODULATE, "Got unexpected render state %#lx.\n", state);
 
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -16015,13 +16015,13 @@ static void test_map_synchronisation(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     tri_count = 0x1000;
 
@@ -16033,25 +16033,25 @@ static void test_map_synchronisation(void)
     vb_desc.dwFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE;
     vb_desc.dwNumVertices = tri_count + 2;
     hr = IDirect3D3_CreateVertexBuffer(d3d, &vb_desc, &buffer, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer_Lock(buffer, DDLOCK_DISCARDCONTENTS, (void **)&quads, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     for (j = 0; j < vb_desc.dwNumVertices / 4; ++j)
     {
         quads[j] = quad1;
     }
     hr = IDirect3DVertexBuffer_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     /* Initial draw to initialise states, compile shaders, etc. */
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, buffer, 0, vb_desc.dwNumVertices, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     /* Read the result to ensure the GPU has finished drawing. */
     colour = get_surface_color(rt, 320, 240);
 
@@ -16059,25 +16059,25 @@ static void test_map_synchronisation(void)
     ret = QueryPerformanceCounter(&ts[0]);
     ok(ret, "Failed to read performance counter.\n");
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, buffer, 0, vb_desc.dwNumVertices, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     colour = get_surface_color(rt, 320, 240);
     /* Time drawing a single triangle. */
     ret = QueryPerformanceCounter(&ts[1]);
     ok(ret, "Failed to read performance counter.\n");
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, buffer, 0, 3, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     colour = get_surface_color(rt, 320, 240);
     ret = QueryPerformanceCounter(&ts[2]);
     ok(ret, "Failed to read performance counter.\n");
@@ -16093,32 +16093,32 @@ static void test_map_synchronisation(void)
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3D3_CreateVertexBuffer(d3d, &vb_desc, &buffer, 0, NULL);
-        ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
         hr = IDirect3DVertexBuffer_Lock(buffer, DDLOCK_DISCARDCONTENTS, (void **)&quads, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
         for (j = 0; j < vb_desc.dwNumVertices / 4; ++j)
         {
             quads[j] = quad1;
         }
         hr = IDirect3DVertexBuffer_Unlock(buffer);
-        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
         /* Start a draw operation. */
         hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
         hr = IDirect3DDevice3_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice3_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, buffer, 0, vb_desc.dwNumVertices, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice3_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         /* Map the last quad while the draw is in progress. */
         hr = IDirect3DVertexBuffer_Lock(buffer, DDLOCK_WAIT | tests[i].flags, (void **)&quads, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
         quads[(vb_desc.dwNumVertices / 4) - 1] = quad2;
         hr = IDirect3DVertexBuffer_Unlock(buffer);
-        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
         colour = get_surface_color(rt, 320, 240);
         unsynchronised = compare_color(colour, 0x00ffff00, 1);
@@ -16132,7 +16132,7 @@ static void test_map_synchronisation(void)
     IDirectDrawSurface4_Release(rt);
     IDirect3D3_Release(d3d);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -16191,19 +16191,19 @@ static void test_depth_readback(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     ds = get_depth_stencil(device);
     hr = IDirectDrawSurface4_DeleteAttachedSurface(rt, 0, ds);
-    ok(SUCCEEDED(hr), "Failed to detach depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach depth buffer, hr %#lx.\n", hr);
     IDirectDrawSurface4_Release(ds);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
@@ -16230,19 +16230,19 @@ static void test_depth_readback(void)
         }
 
         hr = IDirectDrawSurface_AddAttachedSurface(rt, ds);
-        ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
         hr = IDirect3DDevice3_SetRenderTarget(device, rt, 0);
-        ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
         hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect,
                 D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
         hr = IDirect3DDevice3_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE, quad, 4, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice3_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         all_pass = TRUE;
         for (y = 60; y < 480; y += 120)
@@ -16253,7 +16253,7 @@ static void test_depth_readback(void)
                 memset(&surface_desc, 0, sizeof(surface_desc));
                 surface_desc.dwSize = sizeof(surface_desc);
                 hr = IDirectDrawSurface4_Lock(ds, &r, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-                ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
 
                 depth = *((DWORD *)surface_desc.lpSurface) & tests[i].z_mask;
                 expected_depth = (x * (0.9 / 640.0) + y * (0.1 / 480.0)) * tests[i].z_mask;
@@ -16267,13 +16267,13 @@ static void test_depth_readback(void)
                 todo_wine_if(tests[i].todo && !compare_uint(expected_depth, depth, max_diff))
                     ok(compare_uint(expected_depth, depth, max_diff) || ddraw_is_nvidia(ddraw)
                             || (ddraw_is_amd(ddraw) && !tests[i].s_depth && tests[i].z_mask == 0x00ffffff),
-                             "Test %u: Got depth 0x%08x (diff %d), expected 0x%08x+/-%u, at %u, %u.\n",
+                             "Test %u: Got depth 0x%08lx (diff %ld), expected 0x%08lx+/-%lu, at %u, %u.\n",
                              i, depth, expected_depth - depth, expected_depth, max_diff, x, y);
                 if (!compare_uint(expected_depth, depth, max_diff))
                     all_pass = FALSE;
 
                 hr = IDirectDrawSurface4_Unlock(ds, &r);
-                ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
             }
         }
 
@@ -16281,7 +16281,7 @@ static void test_depth_readback(void)
             passed_fmts++;
 
         hr = IDirectDrawSurface4_DeleteAttachedSurface(rt, 0, ds);
-        ok(SUCCEEDED(hr), "Failed to detach depth buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to detach depth buffer, hr %#lx.\n", hr);
         IDirectDrawSurface4_Release(ds);
     }
 
@@ -16292,7 +16292,7 @@ static void test_depth_readback(void)
     IDirectDraw4_Release(ddraw);
     IDirect3D3_Release(d3d);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -16319,19 +16319,19 @@ static void test_clear(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_full, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     /* Positive x, negative y. */
     U1(rect[0]).x1 = 0;
@@ -16348,19 +16348,19 @@ static void test_clear(void)
     /* Clear 2 rectangles with one call. Unlike d3d8/9, the refrast does not
      * refuse negative rectangles, but it will not clear them either. */
     hr = IDirect3DViewport3_Clear2(viewport, 2, rect, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 360);
-    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3 (pos, neg) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3 (pos, neg) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 160, 120);
-    ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1 (pos, pos) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1 (pos, pos) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 360);
-    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4 (NULL) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4 (NULL) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 120);
-    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4 (neg, neg) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4 (neg, neg) has color 0x%08lx.\n", color);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_full, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     /* negative x, negative y.
      * Also ignored, except on WARP, which clears the entire screen. */
     U1(rect_negneg).x1 = 640;
@@ -16368,123 +16368,123 @@ static void test_clear(void)
     U3(rect_negneg).x2 = 320;
     U4(rect_negneg).y2 = 0;
     hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_negneg, D3DCLEAR_TARGET, 0xff00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 360);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 160, 120);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 360);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 120);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
 
     /* Test how the viewport affects clears. */
     hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_full, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     viewport2 = create_viewport(device, 160, 120, 160, 120);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport2);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear2(viewport2, 1, &rect_full, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     viewport3 = create_viewport(device, 320, 240, 320, 240);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport3);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     U1(rect[0]).x1 = 160;
     U2(rect[0]).y1 = 120;
     U3(rect[0]).x2 = 480;
     U4(rect[0]).y2 = 360;
     hr = IDirect3DViewport3_Clear2(viewport3, 1, &rect[0], D3DCLEAR_TARGET, 0xff00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 158, 118);
-    ok(compare_color(color, 0x00ffffff, 0), "(158, 118) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(158, 118) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 162, 118);
-    ok(compare_color(color, 0x00ffffff, 0), "(162, 118) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(162, 118) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 158, 122);
-    ok(compare_color(color, 0x00ffffff, 0), "(158, 122) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(158, 122) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 162, 122);
-    ok(compare_color(color, 0x000000ff, 0), "(162, 122) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 0), "(162, 122) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 318, 238);
-    ok(compare_color(color, 0x000000ff, 0), "(318, 238) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 0), "(318, 238) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 322, 238);
-    ok(compare_color(color, 0x00ffffff, 0), "(322, 328) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(322, 328) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 318, 242);
-    ok(compare_color(color, 0x00ffffff, 0), "(318, 242) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(318, 242) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 322, 242);
-    ok(compare_color(color, 0x0000ff00, 0), "(322, 242) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(322, 242) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 478, 358);
-    ok(compare_color(color, 0x0000ff00, 0), "(478, 358) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(478, 358) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 482, 358);
-    ok(compare_color(color, 0x00ffffff, 0), "(482, 358) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(482, 358) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 478, 362);
-    ok(compare_color(color, 0x00ffffff, 0), "(478, 362) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(478, 362) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 482, 362);
-    ok(compare_color(color, 0x00ffffff, 0), "(482, 362) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(482, 362) has color 0x%08lx.\n", color);
 
     /* The clear rectangle is rendertarget absolute, not relative to the
      * viewport. */
     hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_full, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     U1(rect[0]).x1 = 330;
     U2(rect[0]).y1 = 250;
     U3(rect[0]).x2 = 340;
     U4(rect[0]).y2 = 260;
     hr = IDirect3DViewport3_Clear2(viewport3, 1, &rect[0], D3DCLEAR_TARGET, 0xff00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 328, 248);
-    ok(compare_color(color, 0x00ffffff, 0), "(328, 248) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(328, 248) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 332, 248);
-    ok(compare_color(color, 0x00ffffff, 0), "(332, 248) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(332, 248) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 328, 252);
-    ok(compare_color(color, 0x00ffffff, 0), "(328, 252) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(328, 252) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 332, 252);
-    ok(compare_color(color, 0x0000ff00, 0), "(332, 252) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(332, 252) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 338, 248);
-    ok(compare_color(color, 0x00ffffff, 0), "(338, 248) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(338, 248) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 342, 248);
-    ok(compare_color(color, 0x00ffffff, 0), "(342, 248) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(342, 248) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 338, 252);
-    ok(compare_color(color, 0x0000ff00, 0), "(338, 252) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(338, 252) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 342, 252);
-    ok(compare_color(color, 0x00ffffff, 0), "(342, 252) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(342, 252) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 328, 258);
-    ok(compare_color(color, 0x00ffffff, 0), "(328, 258) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(328, 258) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 332, 258);
-    ok(compare_color(color, 0x0000ff00, 0), "(332, 258) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(332, 258) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 328, 262);
-    ok(compare_color(color, 0x00ffffff, 0), "(328, 262) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(328, 262) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 332, 262);
-    ok(compare_color(color, 0x00ffffff, 0), "(332, 262) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(332, 262) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 338, 258);
-    ok(compare_color(color, 0x0000ff00, 0), "(338, 258) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(338, 258) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 342, 258);
-    ok(compare_color(color, 0x00ffffff, 0), "(342, 258) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(342, 258) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 338, 262);
-    ok(compare_color(color, 0x00ffffff, 0), "(338, 262) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(338, 262) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 342, 262);
-    ok(compare_color(color, 0x00ffffff, 0), "(342, 262) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(342, 262) has color 0x%08lx.\n", color);
 
     /* COLORWRITEENABLE, SRGBWRITEENABLE and scissor rectangles do not exist
      * in d3d3. */
@@ -16496,7 +16496,7 @@ static void test_clear(void)
     IDirectDraw4_Release(ddraw);
     IDirect3D3_Release(d3d);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -16554,12 +16554,12 @@ static HRESULT WINAPI enum_surfaces_create_cb(IDirectDrawSurface4 *surface, DDSU
     struct enum_surfaces_param *param = context;
 
     ok(!surface, "Unexpected surface %p.\n", surface);
-    ok((desc->dwFlags & expect_flags) == expect_flags, "Got unexpected flags %#x.\n", desc->dwFlags);
+    ok((desc->dwFlags & expect_flags) == expect_flags, "Got unexpected flags %#lx.\n", desc->dwFlags);
     if (param->count < ARRAY_SIZE(param->modes))
     {
         const DDSURFACEDESC2 *expect = &param->modes[param->count];
-        ok(desc->dwWidth == expect->dwWidth, "Expected width %u, got %u.\n", expect->dwWidth, desc->dwWidth);
-        ok(desc->dwHeight == expect->dwHeight, "Expected height %u, got %u.\n", expect->dwHeight, desc->dwHeight);
+        ok(desc->dwWidth == expect->dwWidth, "Expected width %lu, got %lu.\n", expect->dwWidth, desc->dwWidth);
+        ok(desc->dwHeight == expect->dwHeight, "Expected height %lu, got %lu.\n", expect->dwHeight, desc->dwHeight);
         ok(!memcmp(&U4(*desc).ddpfPixelFormat, &U4(*expect).ddpfPixelFormat, sizeof(U4(*desc).ddpfPixelFormat)),
                 "Pixel formats didn't match.\n");
     }
@@ -16584,18 +16584,18 @@ static void test_enum_surfaces(void)
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
     hr = IDirectDraw4_GetDisplayMode(ddraw, &desc);
-    ok(hr == DD_OK, "Failed to get display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to get display mode, hr %#lx.\n", hr);
     current_format = U4(desc).ddpfPixelFormat;
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set cooperative level, hr %#lx.\n", hr);
 
     hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_ALL, NULL, NULL, enum_surfaces_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL,
             NULL, NULL, enum_surfaces_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
@@ -16605,52 +16605,52 @@ static void test_enum_surfaces(void)
     desc.dwWidth = 32;
     desc.dwHeight = 32;
     hr = IDirectDraw4_CreateSurface(ddraw, &desc, &param.surfaces[0], NULL);
-    ok(hr == DD_OK, "Failed to create a surface, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to create a surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface4_GetAttachedSurface(param.surfaces[0], &desc.ddsCaps, &param.surfaces[1]);
-    ok(hr == DD_OK, "Failed to get attached surface, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to get attached surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetAttachedSurface(param.surfaces[1], &desc.ddsCaps, &param.surfaces[2]);
-    ok(hr == DD_OK, "Failed to get attached surface, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to get attached surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetAttachedSurface(param.surfaces[2], &desc.ddsCaps, &param.surfaces[3]);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
 
     param.count = 0;
     hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
             &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     param.count = 0;
     hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
             NULL, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
     param.count = 0;
     hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     param.count = 0;
     hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH,
             &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 2, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     desc.dwFlags = 0;
     param.count = 0;
     hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     desc.dwFlags = 0;
     param.count = 0;
     hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST, &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     IDirectDrawSurface4_Release(param.surfaces[2]);
@@ -16660,7 +16660,7 @@ static void test_enum_surfaces(void)
     param.count = 0;
     hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
             NULL, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(!param.count, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     memset(&desc, 0, sizeof(desc));
@@ -16670,15 +16670,15 @@ static void test_enum_surfaces(void)
 
     hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#lx.\n", hr);
 
     hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_NOMATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#lx.\n", hr);
 
     hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#lx.\n", hr);
 
     /* When not passed width and height, the callback is called with every
      * available display resolution. */
@@ -16687,13 +16687,13 @@ static void test_enum_surfaces(void)
     desc.dwFlags |= DDSD_PIXELFORMAT;
     U4(desc).ddpfPixelFormat = current_format;
     hr = IDirectDraw4_EnumDisplayModes(ddraw, 0, &desc, &param, build_mode_list_cb);
-    ok(hr == DD_OK, "Failed to build mode list, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to build mode list, hr %#lx.\n", hr);
 
     param.count = 0;
     desc.dwFlags &= ~DDSD_PIXELFORMAT;
     hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == param.mode_count, "Expected %u surfaces, got %u.\n", param.mode_count, param.count);
 
     desc.dwFlags |= DDSD_WIDTH | DDSD_HEIGHT;
@@ -16704,15 +16704,15 @@ static void test_enum_surfaces(void)
     param.count = 0;
     hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     hr = IDirectDraw4_CreateSurface(ddraw, &desc, &param.surfaces[0], NULL);
-    ok(hr == DD_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to create surface, hr %#lx.\n", hr);
     param.count = 0;
     hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count);
     IDirectDrawSurface4_Release(param.surfaces[0]);
 
@@ -16724,7 +16724,7 @@ static void test_enum_surfaces(void)
     param.count = 0;
     hr = IDirectDraw4_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(!param.count, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     IDirectDraw4_Release(ddraw);
@@ -16794,21 +16794,21 @@ static void test_viewport(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D3 interface, hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable depth test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable depth test, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
-    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat);
-    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
 
     ds = get_depth_stencil(device);
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -16829,23 +16829,23 @@ static void test_viewport(void)
             surface_desc.dwHeight = rt_sizes[i].y;
             surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
             hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &rt, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             surface_desc.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
             surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
             U4(surface_desc).ddpfPixelFormat = z_fmt;
             hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &ds, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirectDrawSurface4_AddAttachedSurface(rt, ds);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice3_SetRenderTarget(device, rt, 0);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         }
         else
         {
             hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         }
 
         full_viewport = create_viewport(device, 0, 0, rt_sizes[i].x, rt_sizes[i].y);
@@ -16862,12 +16862,12 @@ static void test_viewport(void)
                     || tests[j].vp.dwY + tests[j].vp.dwHeight > rt_sizes[i].y;
 
             hr = IDirect3DViewport3_Clear2(full_viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xff000000, 0.0f, 0);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3D3_CreateViewport(d3d, &viewport, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DViewport3_SetViewport2(viewport, NULL);
-            ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+            ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
             memset(&vp, 0, sizeof(vp));
             vp.dwSize = sizeof(vp);
             vp.dwX = tests[j].vp.dwX;
@@ -16881,14 +16881,14 @@ static void test_viewport(void)
             vp.dvMinZ = 0.0f;
             vp.dvMaxZ = 1.0f;
             hr = IDirect3DViewport3_SetViewport2(viewport, &vp);
-            ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice3_AddViewport(device, viewport);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DViewport3_SetViewport2(viewport, &vp);
-            ok(hr == (expected_failure ? E_INVALIDARG : DD_OK), "Got unexpected hr %#x.\n", hr);
+            ok(hr == (expected_failure ? E_INVALIDARG : DD_OK), "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             if (expected_failure)
             {
                 destroy_viewport(device, viewport);
@@ -16897,11 +16897,11 @@ static void test_viewport(void)
             }
 
             hr = IDirect3DDevice3_BeginScene(device);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, 0);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice3_EndScene(device);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             check_rect(rt, tests[j].expected_rect);
 
@@ -16912,7 +16912,7 @@ static void test_viewport(void)
         destroy_viewport(device, full_viewport);
 
         hr = IDirectDrawSurface4_DeleteAttachedSurface(rt, 0, ds);
-        ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x (i %u).\n", hr, i);
+        ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx (i %u).\n", hr, i);
         IDirectDrawSurface4_Release(ds);
 
         IDirectDrawSurface4_Release(rt);
@@ -16921,7 +16921,7 @@ static void test_viewport(void)
     }
 
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirect3D3_Release(d3d);
     IDirectDraw4_Release(ddraw);
     DestroyWindow(window);
@@ -16983,48 +16983,48 @@ static void test_find_device(void)
     result.dwSize = sizeof(result);
     search.dwSize = sizeof(search);
     hr = IDirect3D3_FindDevice(d3d, NULL, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D3_FindDevice(d3d, NULL, &result);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D3_FindDevice(d3d, &search, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D3_FindDevice(d3d, &search, &result);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(result.dwSize == sizeof(result), "Got unexpected result size %u.\n", result.dwSize);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(result.dwSize == sizeof(result), "Got unexpected result size %lu.\n", result.dwSize);
     ok(result.ddHwDesc.dwSize == sizeof(result.ddHwDesc),
-            "Got unexpected HW desc size %u.\n", result.ddHwDesc.dwSize);
+            "Got unexpected HW desc size %lu.\n", result.ddHwDesc.dwSize);
     ok(result.ddSwDesc.dwSize == sizeof(result.ddSwDesc),
-            "Got unexpected SW desc size %u.\n", result.ddSwDesc.dwSize);
+            "Got unexpected SW desc size %lu.\n", result.ddSwDesc.dwSize);
 
     memset(&search, 0, sizeof(search));
     memset(&result, 0, sizeof(result));
     hr = IDirect3D3_FindDevice(d3d, &search, &result);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     search.dwSize = sizeof(search) + 1;
     result.dwSize = sizeof(result) + 1;
     hr = IDirect3D3_FindDevice(d3d, &search, &result);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     search.dwSize = sizeof(search);
 
     memset(&result_v1, 0, sizeof(result_v1));
     result_v1.size = sizeof(result_v1);
     hr = IDirect3D3_FindDevice(d3d, &search, (D3DFINDDEVICERESULT *)&result_v1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(result_v1.hw_desc.dwSize == sizeof(result.ddHwDesc),
-            "Got unexpected HW desc size %u.\n", result_v1.hw_desc.dwSize);
+            "Got unexpected HW desc size %lu.\n", result_v1.hw_desc.dwSize);
     ok(result_v1.sw_desc.dwSize == sizeof(result.ddSwDesc),
-            "Got unexpected SW desc size %u.\n", result_v1.sw_desc.dwSize);
+            "Got unexpected SW desc size %lu.\n", result_v1.sw_desc.dwSize);
 
     memset(&result_v2, 0, sizeof(result_v2));
     result_v2.size = sizeof(result_v2);
     hr = IDirect3D3_FindDevice(d3d, &search, (D3DFINDDEVICERESULT *)&result_v2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ok(result_v2.hw_desc.dwSize == sizeof(result.ddHwDesc),
-            "Got unexpected HW desc size %u.\n", result_v2.hw_desc.dwSize);
+            "Got unexpected HW desc size %lu.\n", result_v2.hw_desc.dwSize);
     ok(result_v2.sw_desc.dwSize == sizeof(result.ddSwDesc),
-            "Got unexpected SW desc size %u.\n", result_v2.sw_desc.dwSize);
+            "Got unexpected SW desc size %lu.\n", result_v2.sw_desc.dwSize);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -17037,21 +17037,21 @@ static void test_find_device(void)
         result.dwSize = sizeof(result);
 
         hr = IDirect3D3_FindDevice(d3d, &search, &result);
-        ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
-        ok(result.dwSize == sizeof(result), "Test %u: Got unexpected result size %u.\n", i, result.dwSize);
+        ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx.\n", i, hr);
+        ok(result.dwSize == sizeof(result), "Test %u: Got unexpected result size %lu.\n", i, result.dwSize);
         if (SUCCEEDED(hr))
         {
             ok(result.ddHwDesc.dwSize == sizeof(result.ddHwDesc),
-                    "Test %u: Got unexpected HW desc size %u.\n", i, result.ddHwDesc.dwSize);
+                    "Test %u: Got unexpected HW desc size %lu.\n", i, result.ddHwDesc.dwSize);
             ok(result.ddSwDesc.dwSize == sizeof(result.ddSwDesc),
-                    "Test %u: Got unexpected SW desc size %u.\n", i, result.ddSwDesc.dwSize);
+                    "Test %u: Got unexpected SW desc size %lu.\n", i, result.ddSwDesc.dwSize);
         }
         else
         {
             ok(!result.ddHwDesc.dwSize,
-                    "Test %u: Got unexpected HW desc size %u.\n", i, result.ddHwDesc.dwSize);
+                    "Test %u: Got unexpected HW desc size %lu.\n", i, result.ddHwDesc.dwSize);
             ok(!result.ddSwDesc.dwSize,
-                    "Test %u: Got unexpected SW desc size %u.\n", i, result.ddSwDesc.dwSize);
+                    "Test %u: Got unexpected SW desc size %lu.\n", i, result.ddSwDesc.dwSize);
         }
     }
 
@@ -17078,7 +17078,7 @@ static void test_find_device(void)
     search.dcmColorModel = 0xdeadbeef;
     result.dwSize = sizeof(result);
     hr = IDirect3D3_FindDevice(d3d, &search, &result);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3D3_Release(d3d);
     IDirectDraw4_Release(ddraw);
@@ -17094,9 +17094,9 @@ static LRESULT CALLBACK killfocus_proc(HWND window, UINT message, WPARAM wparam,
     if (message == WM_KILLFOCUS)
     {
         ref = IDirectDrawSurface4_Release(killfocus_surface);
-        ok(!ref, "Unexpected surface refcount %u.\n", ref);
+        ok(!ref, "Unexpected surface refcount %lu.\n", ref);
         ref = IDirectDraw4_Release(killfocus_ddraw);
-        ok(!ref, "Unexpected ddraw refcount %u.\n", ref);
+        ok(!ref, "Unexpected ddraw refcount %lu.\n", ref);
         killfocus_ddraw = NULL;
     }
 
@@ -17121,14 +17121,14 @@ static void test_killfocus(void)
     ok(!!killfocus_ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw4_SetCooperativeLevel(killfocus_ddraw, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw4_CreateSurface(killfocus_ddraw, &surface_desc, &killfocus_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     SetForegroundWindow(GetDesktopWindow());
     ok(!killfocus_ddraw, "WM_KILLFOCUS was not received.\n");
@@ -17184,57 +17184,57 @@ static void test_sysmem_draw(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwCaps = D3DVBCAPS_SYSTEMMEMORY;
     vb_desc.dwFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE;
     vb_desc.dwNumVertices = ARRAY_SIZE(quad);
     hr = IDirect3D3_CreateVertexBuffer(d3d, &vb_desc, &vb, 0, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_Lock(vb, 0, (void **)&data, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(data, quad, sizeof(quad));
     hr = IDirect3DVertexBuffer_Unlock(vb);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_full, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, 4, 4, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00007f7f, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00007f7f, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_full, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawIndexedPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, indices, 4, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00007f7f, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00007f7f, 1), "Got unexpected color 0x%08lx.\n", color);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -17250,22 +17250,22 @@ static void test_sysmem_draw(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(U4(surface_desc).ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface4_Release(surface);
     hr = IDirect3DDevice3_SetTexture(device, 0, texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_full, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, 0, 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(hr == D3D_OK || hr == D3DERR_SCENE_END_FAILED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK || hr == D3DERR_SCENE_END_FAILED, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DTexture2_Release(texture);
     IDirect3DVertexBuffer_Release(vb);
@@ -17274,7 +17274,7 @@ static void test_sysmem_draw(void)
     IDirectDraw4_Release(ddraw);
     IDirect3D3_Release(d3d);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -17292,38 +17292,38 @@ static void test_gdi_surface(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Retrieving the GDI surface requires a primary surface to exist. */
     gdi_surface = (void *)0xc0dec0de;
     hr = IDirectDraw4_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!gdi_surface, "Got unexpected surface %p.\n", gdi_surface);
 
     hr = IDirectDraw4_FlipToGDISurface(ddraw);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw4_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(gdi_surface == primary, "Got unexpected surface %p, expected %p.\n", gdi_surface, primary);
     IDirectDrawSurface4_Release(gdi_surface);
 
     /* Flipping to the GDI surface requires the primary surface to be
      * flippable. */
     hr = IDirectDraw4_FlipToGDISurface(ddraw);
-    ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface4_Release(primary);
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -17331,40 +17331,40 @@ static void test_gdi_surface(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     U5(surface_desc).dwBackBufferCount = 1;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_GetAttachedSurface(primary, &caps, &backbuffer);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(backbuffer != primary, "Got unexpected backbuffer %p.\n", backbuffer);
 
     hr = IDirectDraw4_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(gdi_surface == primary, "Got unexpected surface %p, expected %p.\n", gdi_surface, primary);
     IDirectDrawSurface4_Release(gdi_surface);
 
     hr = IDirectDrawSurface4_Flip(primary, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(gdi_surface == backbuffer || broken(gdi_surface == primary),
             "Got unexpected surface %p, expected %p.\n", gdi_surface, backbuffer);
     IDirectDrawSurface4_Release(gdi_surface);
 
     hr = IDirectDraw4_FlipToGDISurface(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw4_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(gdi_surface == primary, "Got unexpected surface %p, expected %p.\n", gdi_surface, primary);
     IDirectDrawSurface4_Release(gdi_surface);
 
     hr = IDirectDraw4_FlipToGDISurface(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface4_Release(backbuffer);
     IDirectDrawSurface4_Release(primary);
 
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -17422,66 +17422,66 @@ static void test_alphatest(void)
         return;
     }
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_full, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ALPHATESTENABLE, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ALPHAFUNC, test_data[i].func);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_full, D3DCLEAR_TARGET, ALPHATEST_FAILED, 0.0f, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ALPHAREF, 0x70);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice3_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
                 D3DFVF_XYZ | D3DFVF_DIFFUSE, quad, ARRAY_SIZE(quad), 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice3_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, test_data[i].color_greater, 0),
-                "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n",
+                "Alphatest failed, color 0x%08lx, expected 0x%08lx, alpha > ref, func %u.\n",
                 color, test_data[i].color_greater, test_data[i].func);
 
         hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_full, D3DCLEAR_TARGET, ALPHATEST_FAILED, 0.0f, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ALPHAREF, 0xff70);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_ALPHAREF, &value);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-        ok(value == 0xff70, "Got unexpected value %#x.\n", value);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+        ok(value == 0xff70, "Got unexpected value %#lx.\n", value);
         hr = IDirect3DDevice3_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
                 D3DFVF_XYZ | D3DFVF_DIFFUSE, quad, ARRAY_SIZE(quad), 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice3_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, test_data[i].color_greater, 0),
-                "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n",
+                "Alphatest failed, color 0x%08lx, expected 0x%08lx, alpha > ref, func %u.\n",
                 color, test_data[i].color_greater, test_data[i].func);
     }
 
     destroy_viewport(device, viewport);
     IDirectDrawSurface4_Release(rt);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -17502,24 +17502,24 @@ static void test_clipper_refcount(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw4_CreateClipper(ddraw, 0, &clipper, NULL);
-    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     /* Show that clipper validation doesn't somehow happen through per-clipper vtable
      * pointers. */
     hr = IDirectDraw4_CreateClipper(ddraw, 0, &clipper2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
     ok(clipper->lpVtbl == clipper2->lpVtbl, "Got different clipper vtables %p and %p.\n",
             clipper->lpVtbl, clipper2->lpVtbl);
     orig_vtbl = clipper->lpVtbl;
@@ -17527,50 +17527,50 @@ static void test_clipper_refcount(void)
 
     /* Surfaces hold a reference to clippers. No surprises there. */
     hr = IDirectDrawSurface4_SetClipper(surface, clipper);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface4_GetClipper(surface, &clipper2);
-    ok(SUCCEEDED(hr), "Failed to get clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get clipper, hr %#lx.\n", hr);
     ok(clipper == clipper2, "Got clipper %p, expected %p.\n", clipper2, clipper);
     refcount = IDirectDrawClipper_Release(clipper2);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface4_SetClipper(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface4_SetClipper(surface, clipper);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     refcount = IDirectDrawSurface4_Release(surface);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     /* SetClipper with an invalid pointer crashes. */
 
     /* Clipper methods work with a broken vtable, with the exception of Release. */
     clipper->lpVtbl = (void *)0xdeadbeef;
     refcount = orig_vtbl->AddRef(clipper);
-    todo_wine ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    todo_wine ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
     refcount = orig_vtbl->Release(clipper);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     clipper->lpVtbl = orig_vtbl;
     refcount = orig_vtbl->Release(clipper);
-    todo_wine ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    todo_wine ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     /* Fix the refcount difference because Wine did not increase the ref in the
      * AddRef call above. */
     if (refcount)
     {
         refcount = IDirectDrawClipper_Release(clipper);
-        ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+        ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     }
 
     /* Steal the reference and see what happens - releasing the surface works fine.
@@ -17578,11 +17578,11 @@ static void test_clipper_refcount(void)
      * release it after the GetClipper call is likely to crash, and certain to crash
      * if we allocate and zero as much heap memory as we can get. */
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw4_CreateClipper(ddraw, 0, &clipper, NULL);
-    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_SetClipper(surface, clipper);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
 
     IDirectDrawClipper_Release(clipper);
     IDirectDrawClipper_Release(clipper);
@@ -17598,7 +17598,7 @@ static void test_clipper_refcount(void)
          * The same Windows and driver versions run the test without heap corruption on
          * a Geforce 1060 GTX card. I have not seen the problem on AMD GPUs either. */
         hr = IDirectDrawSurface4_GetClipper(surface, &clipper2);
-        ok(SUCCEEDED(hr), "Failed to get clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get clipper, hr %#lx.\n", hr);
         ok(clipper == clipper2, "Got clipper %p, expected %p.\n", clipper2, clipper);
     }
 
@@ -17606,10 +17606,10 @@ static void test_clipper_refcount(void)
      * vtable through the clipper pointer because it is no longer pointing to
      * valid memory. */
     refcount = orig_vtbl->Release(clipper);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
 
     refcount = IDirectDrawSurface4_Release(surface);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
 
     /* It looks like the protection against invalid thispointers is part of
      * the IDirectDrawClipper method implementation, not IDirectDrawSurface. */
@@ -17622,33 +17622,33 @@ static void test_clipper_refcount(void)
     clipper->lpVtbl = orig_vtbl;
 
     refcount = orig_vtbl->AddRef(clipper);
-    todo_wine ok(!refcount, "Got refcount %u.\n", refcount);
+    todo_wine ok(!refcount, "Got refcount %lu.\n", refcount);
     refcount = orig_vtbl->AddRef((IDirectDrawClipper *)(ULONG_PTR)0xdeadbeef);
-    ok(!refcount, "Got refcount %u.\n", refcount);
+    ok(!refcount, "Got refcount %lu.\n", refcount);
 
     changed = 0x1234;
     hr = orig_vtbl->IsClipListChanged(clipper, &changed);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     todo_wine ok(changed == 0x1234, "'changed' changed: %x.\n", changed);
 
     changed = 0x1234;
     hr = orig_vtbl->IsClipListChanged((IDirectDrawClipper *)(ULONG_PTR)0xdeadbeef, &changed);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     ok(changed == 0x1234, "'changed' changed: %x.\n", changed);
 
     /* Nope, we can't initialize our fake clipper. */
     hr = IDirectDraw4_QueryInterface(ddraw, &IID_IDirectDraw, (void **)&ddraw1);
-    ok(SUCCEEDED(hr), "Failed to get ddraw1 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw1 interface, hr %#lx.\n", hr);
 
     hr = orig_vtbl->Initialize(clipper, ddraw1, 0);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDraw_Release(ddraw1);
 
     HeapFree(GetProcessHeap(), 0, clipper);
 
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -17701,35 +17701,35 @@ static void test_caps(void)
     hal_caps.dwSize = sizeof(hal_caps);
     hel_caps.dwSize = sizeof(hel_caps);
     hr = IDirectDraw4_GetCaps(ddraw, &hal_caps, &hel_caps);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(hal_caps.ddsOldCaps.dwCaps == hal_caps.ddsCaps.dwCaps,
-            "Got unexpected caps %#x, expected %#x.\n",
+            "Got unexpected caps %#lx, expected %#lx.\n",
             hal_caps.ddsOldCaps.dwCaps, hal_caps.ddsCaps.dwCaps);
     ok(hel_caps.ddsOldCaps.dwCaps == hel_caps.ddsCaps.dwCaps,
-            "Got unexpected caps %#x, expected %#x.\n",
+            "Got unexpected caps %#lx, expected %#lx.\n",
             hel_caps.ddsOldCaps.dwCaps, hel_caps.ddsCaps.dwCaps);
 
     no3d = !(hal_caps.ddsCaps.dwCaps & DDSCAPS_3DDEVICE);
     if (hal_caps.ddsCaps.dwCaps)
     {
-        ok(!(hal_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
-        ok(!(~hal_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(hal_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(~hal_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
         todo_wine_if(no3d) ok(!(~hal_caps.ddsCaps.dwCaps & caps_hal),
-                "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
+                "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
     }
-    ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
-    ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+    ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
+    ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
     todo_wine_if(!no3d) ok(!(hel_caps.ddsCaps.dwCaps & caps_hal),
-            "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+            "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
 
     IDirectDraw4_Release(ddraw);
 
     if (hal_caps.ddsCaps.dwCaps)
     {
         hr = DirectDrawCreate((GUID *)DDCREATE_HARDWAREONLY, &ddraw1, NULL);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirectDraw4, (void **)&ddraw);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         IDirectDraw_Release(ddraw1);
 
         memset(&hal_caps, 0, sizeof(hal_caps));
@@ -17737,27 +17737,27 @@ static void test_caps(void)
         hal_caps.dwSize = sizeof(hal_caps);
         hel_caps.dwSize = sizeof(hel_caps);
         hr = IDirectDraw4_GetCaps(ddraw, &hal_caps, &hel_caps);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         ok(hal_caps.ddsOldCaps.dwCaps == hal_caps.ddsCaps.dwCaps,
-                "Got unexpected caps %#x, expected %#x.\n",
+                "Got unexpected caps %#lx, expected %#lx.\n",
                 hal_caps.ddsOldCaps.dwCaps, hal_caps.ddsCaps.dwCaps);
         ok(hel_caps.ddsOldCaps.dwCaps == hel_caps.ddsCaps.dwCaps,
-                "Got unexpected caps %#x, expected %#x.\n",
+                "Got unexpected caps %#lx, expected %#lx.\n",
                 hel_caps.ddsOldCaps.dwCaps, hel_caps.ddsCaps.dwCaps);
 
-        ok(!(hal_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
-        ok(!(~hal_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(hal_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(~hal_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
         todo_wine_if(no3d) ok(!(~hal_caps.ddsCaps.dwCaps & caps_hal),
-                "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
-        todo_wine ok(!hel_caps.ddsCaps.dwCaps, "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+                "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
+        todo_wine ok(!hel_caps.ddsCaps.dwCaps, "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
 
         IDirectDraw4_Release(ddraw);
     }
 
     hr = DirectDrawCreate((GUID *)DDCREATE_EMULATIONONLY, &ddraw1, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw_QueryInterface(ddraw1, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     IDirectDraw_Release(ddraw1);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
@@ -17765,19 +17765,19 @@ static void test_caps(void)
     hal_caps.dwSize = sizeof(hal_caps);
     hel_caps.dwSize = sizeof(hel_caps);
     hr = IDirectDraw4_GetCaps(ddraw, &hal_caps, &hel_caps);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(hal_caps.ddsOldCaps.dwCaps == hal_caps.ddsCaps.dwCaps,
-            "Got unexpected caps %#x, expected %#x.\n",
+            "Got unexpected caps %#lx, expected %#lx.\n",
             hal_caps.ddsOldCaps.dwCaps, hal_caps.ddsCaps.dwCaps);
     ok(hel_caps.ddsOldCaps.dwCaps == hel_caps.ddsCaps.dwCaps,
-            "Got unexpected caps %#x, expected %#x.\n",
+            "Got unexpected caps %#lx, expected %#lx.\n",
             hel_caps.ddsOldCaps.dwCaps, hel_caps.ddsCaps.dwCaps);
 
-    todo_wine ok(!hal_caps.ddsCaps.dwCaps, "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
-    ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
-    ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+    todo_wine ok(!hal_caps.ddsCaps.dwCaps, "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
+    ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
+    ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
     todo_wine_if(!no3d) ok(!(hel_caps.ddsCaps.dwCaps & caps_hal),
-            "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+            "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
 
     IDirectDraw4_Release(ddraw);
 }
@@ -17795,7 +17795,7 @@ static void test_d32_support(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -17808,25 +17808,25 @@ static void test_d32_support(void)
     surface_desc.dwWidth = 64;
     surface_desc.dwHeight = 64;
     hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &surface_desc);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok((surface_desc.dwFlags & DDSD_PIXELFORMAT), "Got unexpected flags %#x.\n", surface_desc.dwFlags);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok((surface_desc.dwFlags & DDSD_PIXELFORMAT), "Got unexpected flags %#lx.\n", surface_desc.dwFlags);
     ok(U4(surface_desc).ddpfPixelFormat.dwFlags & DDPF_ZBUFFER,
-            "Got unexpected format flags %#x.\n", U4(surface_desc).ddpfPixelFormat.dwFlags);
+            "Got unexpected format flags %#lx.\n", U4(surface_desc).ddpfPixelFormat.dwFlags);
     ok(U1(U4(surface_desc).ddpfPixelFormat).dwZBufferBitDepth == 32,
-            "Got unexpected dwZBufferBitDepth %u.\n", U1(U4(surface_desc).ddpfPixelFormat).dwZBufferBitDepth);
+            "Got unexpected dwZBufferBitDepth %lu.\n", U1(U4(surface_desc).ddpfPixelFormat).dwZBufferBitDepth);
     ok(U3(U4(surface_desc).ddpfPixelFormat).dwZBitMask == 0xffffffff,
-            "Got unexpected Z mask 0x%08x.\n", U3(U4(surface_desc).ddpfPixelFormat).dwZBitMask);
+            "Got unexpected Z mask 0x%08lx.\n", U3(U4(surface_desc).ddpfPixelFormat).dwZBitMask);
     ok(!(surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY),
-            "Got unexpected surface caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+            "Got unexpected surface caps %#lx.\n", surface_desc.ddsCaps.dwCaps);
     IDirectDrawSurface4_Release(surface);
 
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -18028,11 +18028,11 @@ static void test_surface_format_conversion_alpha(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_EnumTextureFormats(device, test_block_formats_creation_cb,
             &supported_fmts);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     is_wine = !strcmp(winetest_platform, "wine");
 
@@ -18070,17 +18070,17 @@ static void test_surface_format_conversion_alpha(void)
             U4(surface_desc).ddpfPixelFormat = src_format->fmt;
             surface_desc.ddsCaps.dwCaps = test_caps[j].src_caps;
             hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &src_surf, NULL);
-            ok(hr == DD_OK, "Test (%u, %u), got unexpected hr %#x.\n", j, i, hr);
+            ok(hr == DD_OK, "Test (%u, %u), got unexpected hr %#lx.\n", j, i, hr);
 
             U4(surface_desc).ddpfPixelFormat = dst_format->fmt;
             surface_desc.ddsCaps.dwCaps = test_caps[j].dst_caps;
             hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &dst_surf, NULL);
-            ok(hr == DD_OK, "Test (%u, %u), got unexpected hr %#x.\n", j, i, hr);
+            ok(hr == DD_OK, "Test (%u, %u), got unexpected hr %#lx.\n", j, i, hr);
 
             memset(&lock, 0, sizeof(lock));
             lock.dwSize = sizeof(lock);
             hr = IDirectDrawSurface4_Lock(src_surf, NULL, &lock, 0, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             pitch = U1(lock).lPitch;
             for (y = 0; y < src_format->y_blocks; ++y)
             {
@@ -18089,7 +18089,7 @@ static void test_surface_format_conversion_alpha(void)
                         src_format->block_size * src_format->x_blocks);
             }
             hr = IDirectDrawSurface4_Unlock(src_surf, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirectDrawSurface4_Blt(dst_surf, NULL, src_surf, NULL, DDBLT_WAIT, NULL);
             if (!is_wine && FAILED(hr))
@@ -18097,17 +18097,17 @@ static void test_surface_format_conversion_alpha(void)
                 /* Some software blits are rejected on Windows. */
                 IDirectDrawSurface4_Release(dst_surf);
                 IDirectDrawSurface4_Release(src_surf);
-                skip("Skipping test (%u, %u), cannot blit %s -> %s, hr %#x.\n", j, i,
+                skip("Skipping test (%u, %u), cannot blit %s -> %s, hr %#lx.\n", j, i,
                         src_format->name, dst_format->name, hr);
                 continue;
             }
-            ok(hr == DD_OK, "Test (%u, %s -> %s), got unexpected hr %#x.\n", j,
+            ok(hr == DD_OK, "Test (%u, %s -> %s), got unexpected hr %#lx.\n", j,
                     src_format->name, dst_format->name, hr);
 
             memset(&lock, 0, sizeof(lock));
             lock.dwSize = sizeof(lock);
             hr = IDirectDrawSurface4_Lock(dst_surf, NULL, &lock, 0, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             pitch = U1(lock).lPitch;
 
             for (y = 0; y < dst_format->y_blocks; ++y)
@@ -18135,7 +18135,7 @@ static void test_surface_format_conversion_alpha(void)
                     break;
             }
             hr = IDirectDrawSurface4_Unlock(dst_surf, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             IDirectDrawSurface4_Release(dst_surf);
             IDirectDrawSurface4_Release(src_surf);
@@ -18144,7 +18144,7 @@ static void test_surface_format_conversion_alpha(void)
 
     IDirect3DDevice3_Release(device);
     refcount = IDirectDraw4_Release(ddraw);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -18198,13 +18198,13 @@ static void test_cursor_clipping(void)
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw4_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "GetDisplayMode failed, hr %#lx.\n", hr);
 
     memset(&param, 0, sizeof(param));
     param.old_width = surface_desc.dwWidth;
     param.old_height = surface_desc.dwHeight;
     hr = IDirectDraw4_EnumDisplayModes(ddraw, 0, NULL, &param, find_different_mode_callback);
-    ok(hr == DD_OK, "EnumDisplayModes failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "EnumDisplayModes failed, hr %#lx.\n", hr);
     if (!(param.new_width && param.new_height))
     {
         skip("Failed to find a different mode than %ux%u.\n", param.old_width, param.old_height);
@@ -18212,87 +18212,87 @@ static void test_cursor_clipping(void)
     }
 
     ret = ClipCursor(NULL);
-    ok(ret, "ClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "ClipCursor failed, error %#lx.\n", GetLastError());
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     /* Set cooperative level to normal */
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     flush_events();
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     hr = set_display_mode(ddraw, param.new_width, param.new_height);
-    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode failed, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
-        win_skip("SetDisplayMode failed, hr %#x.\n", hr);
+        win_skip("SetDisplayMode failed, hr %#lx.\n", hr);
         goto done;
     }
     flush_events();
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     hr = IDirectDraw4_RestoreDisplayMode(ddraw);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
     flush_events();
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     /* Switch to full screen cooperative level */
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     flush_events();
     SetRect(&rect, 0, 0, param.old_width, param.old_height);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     hr = set_display_mode(ddraw, param.new_width, param.new_height);
-    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode failed, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
-        win_skip("SetDisplayMode failed, hr %#x.\n", hr);
+        win_skip("SetDisplayMode failed, hr %#lx.\n", hr);
         goto done;
     }
     flush_events();
     SetRect(&rect, 0, 0, param.new_width, param.new_height);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     /* Restore display mode */
     hr = IDirectDraw4_RestoreDisplayMode(ddraw);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
     flush_events();
     SetRect(&rect, 0, 0, param.old_width, param.old_height);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     /* Switch to normal cooperative level */
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     flush_events();
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
@@ -18319,10 +18319,10 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
     flush_events();
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     flush_events();
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "GetWindowRect failed, error %#x.\n", GetLastError());
+    ok(ret, "GetWindowRect failed, error %#lx.\n", GetLastError());
     SetRect(&primary_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
     ok(EqualRect(&window_rect, &primary_rect), "Expect window rect %s, got %s.\n",
             wine_dbgstr_rect(&primary_rect), wine_dbgstr_rect(&window_rect));
@@ -18333,9 +18333,9 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
 
     ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left,
             new_rect.bottom - new_rect.top, TRUE);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ok(EqualRect(&window_rect, &new_rect),
             "Expected window rect %s, got %s.\n",
             wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect));
@@ -18343,7 +18343,7 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
      * on the second resize remains. */
     flush_events();
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     /* Both Windows and Wine change the size of the window. On Windows it is exactly the new size but in Wine
      * it may get adjusted depending on window manager. */
     ok(window_rect.right != monitor_rect->right && window_rect.bottom != monitor_rect->bottom,
@@ -18352,15 +18352,15 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
 
     ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left,
             new_rect.bottom - new_rect.top, TRUE);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ok(EqualRect(&window_rect, &new_rect),
             "Expected window rect %s, got %s.\n",
             wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect));
     flush_events();
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ok(window_rect.right != monitor_rect->right && window_rect.bottom != monitor_rect->bottom,
             "Expected window rect %s, got %s.\n",
             wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect));
@@ -18368,25 +18368,25 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
     /* Window activation should restore the window to fit the whole primary monitor */
     ret = SetWindowPos(window, 0, monitor_rect->left, monitor_rect->top, 0, 0,
             SWP_NOZORDER | SWP_NOSIZE);
-    ok(ret, "SetWindowPos failed, error %#x.\n", GetLastError());
+    ok(ret, "SetWindowPos failed, error %#lx.\n", GetLastError());
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     flush_events();
     ret = ShowWindow(window, SW_RESTORE);
-    ok(ret, "Failed to restore window, error %#x.\n", GetLastError());
+    ok(ret, "Failed to restore window, error %#lx.\n", GetLastError());
     flush_events();
     ret = SetForegroundWindow(window);
-    ok(ret, "SetForegroundWindow failed, error %#x.\n", GetLastError());
+    ok(ret, "SetForegroundWindow failed, error %#lx.\n", GetLastError());
     flush_events();
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "GetWindowRect failed, error %#x.\n", GetLastError());
+    ok(ret, "GetWindowRect failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&window_rect, &primary_rect), "Expect window rect %s, got %s.\n",
             wine_dbgstr_rect(&primary_rect), wine_dbgstr_rect(&window_rect));
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "GetWindowRect failed, error %#x.\n", GetLastError());
+    ok(ret, "GetWindowRect failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&window_rect, &primary_rect), "Expect window rect %s, got %s.\n",
             wine_dbgstr_rect(&primary_rect), wine_dbgstr_rect(&window_rect));
 
@@ -18417,14 +18417,14 @@ static BOOL CALLBACK test_get_display_mode_cb(HMONITOR monitor, HDC hdc, RECT *m
     /* Test that DirectDraw doesn't use the device window to determine which monitor to use */
     ret = SetWindowPos(window, 0, monitor_rect->left, monitor_rect->top, 0, 0,
             SWP_NOZORDER | SWP_NOSIZE);
-    ok(ret, "SetWindowPos failed, error %#x.\n", GetLastError());
+    ok(ret, "SetWindowPos failed, error %#lx.\n", GetLastError());
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw4_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == GetSystemMetrics(SM_CXSCREEN), "Expect width %d, got %d.\n",
+    ok(hr == DD_OK, "GetDisplayMode failed, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == GetSystemMetrics(SM_CXSCREEN), "Expect width %d, got %ld.\n",
             GetSystemMetrics(SM_CXSCREEN), surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == GetSystemMetrics(SM_CYSCREEN), "Expect height %d, got %d.\n",
+    ok(surface_desc.dwHeight == GetSystemMetrics(SM_CYSCREEN), "Expect height %d, got %ld.\n",
             GetSystemMetrics(SM_CYSCREEN), surface_desc.dwHeight);
 
     DestroyWindow(window);
@@ -18451,41 +18451,41 @@ static void test_get_display_mode(void)
     ok(!!window, "Failed to create a window.\n");
 
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     memset(&devmode, 0, sizeof(devmode));
     devmode.dmSize = sizeof(devmode);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw4_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
-    ok(surface_desc.dwSize == sizeof(surface_desc), "Expected dwSize %u, got %u.\n",
+    ok(hr == DD_OK, "GetDisplayMode failed, hr %#lx.\n", hr);
+    ok(surface_desc.dwSize == sizeof(surface_desc), "Expected dwSize %Iu, got %lu.\n",
             sizeof(surface_desc), surface_desc.dwSize);
-    ok(surface_desc.dwFlags == flags, "Expected dwFlags %#x, got %#x.\n", flags,
+    ok(surface_desc.dwFlags == flags, "Expected dwFlags %#lx, got %#lx.\n", flags,
             surface_desc.dwFlags);
-    ok(surface_desc.dwWidth == devmode.dmPelsWidth, "Expected width %u, got %u.\n",
+    ok(surface_desc.dwWidth == devmode.dmPelsWidth, "Expected width %lu, got %lu.\n",
             devmode.dmPelsWidth, surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == devmode.dmPelsHeight, "Expected height %u, got %u.\n",
+    ok(surface_desc.dwHeight == devmode.dmPelsHeight, "Expected height %lu, got %lu.\n",
             devmode.dmPelsHeight, surface_desc.dwHeight);
-    ok(surface_desc.dwRefreshRate == devmode.dmDisplayFrequency, "Expected frequency %u, got %u.\n",
+    ok(surface_desc.dwRefreshRate == devmode.dmDisplayFrequency, "Expected frequency %lu, got %lu.\n",
             devmode.dmDisplayFrequency, surface_desc.dwRefreshRate);
     ok(surface_desc.ddpfPixelFormat.dwSize == sizeof(surface_desc.ddpfPixelFormat),
-            "Expected ddpfPixelFormat.dwSize %u, got %u.\n", sizeof(surface_desc.ddpfPixelFormat),
+            "Expected ddpfPixelFormat.dwSize %Iu, got %lu.\n", sizeof(surface_desc.ddpfPixelFormat),
             surface_desc.ddpfPixelFormat.dwSize);
     ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == devmode.dmBitsPerPel,
-            "Expected ddpfPixelFormat.dwRGBBitCount %u, got %u.\n", devmode.dmBitsPerPel,
+            "Expected ddpfPixelFormat.dwRGBBitCount %lu, got %lu.\n", devmode.dmBitsPerPel,
             surface_desc.ddpfPixelFormat.dwRGBBitCount);
     ok(surface_desc.lPitch == devmode.dmPelsWidth * devmode.dmBitsPerPel / 8,
-            "Expected pitch %u, got %u.\n", devmode.dmPelsWidth * devmode.dmBitsPerPel / 8,
+            "Expected pitch %lu, got %lu.\n", devmode.dmPelsWidth * devmode.dmBitsPerPel / 8,
             surface_desc.lPitch);
 
     memset(&param, 0, sizeof(param));
     param.old_frequency = surface_desc.dwRefreshRate;
     hr = IDirectDraw4_EnumDisplayModes(ddraw, DDEDM_REFRESHRATES, NULL, &param,
             find_different_mode_callback);
-    ok(hr == DD_OK, "EnumDisplayModes failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "EnumDisplayModes failed, hr %#lx.\n", hr);
     if (!param.new_frequency)
     {
         skip("Failed to find a display mode with a different frequency.\n");
@@ -18494,17 +18494,17 @@ static void test_get_display_mode(void)
 
     hr = IDirectDraw4_SetDisplayMode(ddraw, param.new_width, param.new_height, param.new_bpp,
             param.new_frequency, 0);
-    ok(hr == DD_OK, "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDraw4_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == param.new_width, "Expected width %u, got %u.\n", param.new_width,
+    ok(hr == DD_OK, "GetDisplayMode failed, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == param.new_width, "Expected width %u, got %lu.\n", param.new_width,
             surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == param.new_height, "Expected height %u, got %u.\n", param.new_height,
+    ok(surface_desc.dwHeight == param.new_height, "Expected height %u, got %lu.\n", param.new_height,
             surface_desc.dwHeight);
-    ok(surface_desc.dwRefreshRate == param.new_frequency, "Expected frequency %u, got %u.\n",
+    ok(surface_desc.dwRefreshRate == param.new_frequency, "Expected frequency %u, got %lu.\n",
             param.new_frequency, surface_desc.dwRefreshRate);
     ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == param.new_bpp,
-            "Expected ddpfPixelFormat.dwRGBBitCount %u, got %u.\n", devmode.dmBitsPerPel,
+            "Expected ddpfPixelFormat.dwRGBBitCount %lu, got %lu.\n", devmode.dmBitsPerPel,
             surface_desc.ddpfPixelFormat.dwRGBBitCount);
 
 done:
@@ -18558,15 +18558,15 @@ static void test_texture_wrong_caps(const GUID *device_guid)
         return;
     }
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     viewport = create_viewport(device, 0, 0, 640, 480);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -18576,39 +18576,39 @@ static void test_texture_wrong_caps(const GUID *device_guid)
     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     U4(ddsd).ddpfPixelFormat = fmt;
     hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     fill_surface(surface, 0xff00ff00);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
 
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetTexture(device, 0, texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0x000000ff, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZ | D3DFVF_TEX1, quad, 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     expected_color = is_software_device_type(device_guid) ? 0x0000ff00 : 0x00ffffff;
     color = get_surface_color(rt, 320, 240);
-    ok(color == expected_color, "Got color 0x%08x, expected 0x%08x.\n", color, expected_color);
+    ok(color == expected_color, "Got color 0x%08lx, expected 0x%08lx.\n", color, expected_color);
 
     IDirect3DTexture2_Release(texture);
     IDirectDrawSurface4_Release(surface);
@@ -18617,7 +18617,7 @@ static void test_texture_wrong_caps(const GUID *device_guid)
     IDirectDraw4_Release(ddraw);
     IDirect3D3_Release(d3d);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -18968,14 +18968,14 @@ static void test_filling_convention(void)
     }
 
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_GetRenderTarget(device, &backbuffer);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     viewport = create_viewport(device, 0, 0, vp_size, vp_size);
     hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
@@ -18990,7 +18990,7 @@ static void test_filling_convention(void)
     desc.ddpfPixelFormat.dwGBitMask = 0x0000ff00;
     desc.ddpfPixelFormat.dwBBitMask = 0x000000ff;
     hr = IDirectDraw4_CreateSurface(ddraw, &desc, &rt, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Nvidia on Windows 10 refuses to set the offscreen RT
      * if it does not have an attached depth stencil. */
@@ -18999,7 +18999,7 @@ static void test_filling_convention(void)
     desc.dwSize = sizeof(desc);
     desc.ddpfPixelFormat.dwSize = sizeof(desc.ddpfPixelFormat);
     hr = IDirectDrawSurface4_GetPixelFormat(ds, &desc.ddpfPixelFormat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface4_Release(ds);
 
     desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
@@ -19007,14 +19007,14 @@ static void test_filling_convention(void)
     desc.dwWidth = vp_size;
     desc.dwHeight = vp_size;
     hr = IDirectDraw4_CreateSurface(ddraw, &desc, &ds, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface4_AddAttachedSurface(rt, ds);
-    ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -19023,17 +19023,17 @@ static void test_filling_convention(void)
             cur = j ? rt : backbuffer;
 
             hr = IDirect3DDevice3_SetRenderTarget(device, cur, 0);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, colour_clear, 0.0f, 0);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice3_BeginScene(device);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLELIST,
                     tests[i].fvf, tests[i].geometry, 12, 0);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice3_EndScene(device);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
             for (y = 0; y < 8; y++)
             {
@@ -19071,7 +19071,7 @@ static void test_filling_convention(void)
                      * convention, but because wined3d will nudge geometry to the left to
                      * keep diagonals (the 'R' in test case 'edge_tris') intact. */
                     todo_wine_if(todo && !compare_color(colour, expected, 1))
-                        ok(compare_color(colour, expected, 1), "Got unexpected colour %08x, %ux%u, case %u, j %u.\n",
+                        ok(compare_color(colour, expected, 1), "Got unexpected colour %08lx, %ux%u, case %u, j %u.\n",
                                 colour, x, y, i, j);
                 }
             }
@@ -19085,7 +19085,7 @@ static void test_filling_convention(void)
     IDirectDraw4_Release(ddraw);
     IDirect3D3_Release(d3d);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 711eac2a6d68..31a0218922b4 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -148,7 +148,7 @@ static BOOL ddraw_get_identifier(IDirectDraw7 *ddraw, DDDEVICEIDENTIFIER2 *ident
     HRESULT hr;
 
     hr = IDirectDraw7_GetDeviceIdentifier(ddraw, identifier, 0);
-    ok(SUCCEEDED(hr), "Failed to get device identifier, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device identifier, hr %#lx.\n", hr);
 
     return SUCCEEDED(hr);
 }
@@ -235,7 +235,7 @@ static DWORD WINAPI create_window_thread_proc(void *param)
 
     p->window = create_window();
     ret = SetEvent(p->window_created);
-    ok(ret, "SetEvent failed, last error %#x.\n", GetLastError());
+    ok(ret, "SetEvent failed, last error %#lx.\n", GetLastError());
 
     for (;;)
     {
@@ -248,7 +248,7 @@ static DWORD WINAPI create_window_thread_proc(void *param)
             break;
         if (res != WAIT_TIMEOUT)
         {
-            ok(0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+            ok(0, "Wait failed (%#lx), last error %#lx.\n", res, GetLastError());
             break;
         }
     }
@@ -263,13 +263,13 @@ static void create_window_thread(struct create_window_thread_param *p)
     DWORD res, tid;
 
     p->window_created = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(!!p->window_created, "CreateEvent failed, last error %#x.\n", GetLastError());
+    ok(!!p->window_created, "CreateEvent failed, last error %#lx.\n", GetLastError());
     p->destroy_window = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(!!p->destroy_window, "CreateEvent failed, last error %#x.\n", GetLastError());
+    ok(!!p->destroy_window, "CreateEvent failed, last error %#lx.\n", GetLastError());
     p->thread = CreateThread(NULL, 0, create_window_thread_proc, p, 0, &tid);
-    ok(!!p->thread, "Failed to create thread, last error %#x.\n", GetLastError());
+    ok(!!p->thread, "Failed to create thread, last error %#lx.\n", GetLastError());
     res = WaitForSingleObject(p->window_created, INFINITE);
-    ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+    ok(res == WAIT_OBJECT_0, "Wait failed (%#lx), last error %#lx.\n", res, GetLastError());
 }
 
 static void destroy_window_thread(struct create_window_thread_param *p)
@@ -288,9 +288,9 @@ static IDirectDrawSurface7 *get_depth_stencil(IDirect3DDevice7 *device)
     HRESULT hr;
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get the render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get the render target, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetAttachedSurface(rt, &caps, &ret);
-    ok(SUCCEEDED(hr) || hr == DDERR_NOTFOUND, "Failed to get the z buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || hr == DDERR_NOTFOUND, "Failed to get the z buffer, hr %#lx.\n", hr);
     IDirectDrawSurface7_Release(rt);
     return ret;
 }
@@ -376,14 +376,14 @@ static D3DCOLOR get_surface_color(IDirectDrawSurface7 *surface, UINT x, UINT y)
     surface_desc.dwSize = sizeof(surface_desc);
 
     hr = IDirectDrawSurface7_Lock(surface, &rect, &surface_desc, DDLOCK_READONLY, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     if (FAILED(hr))
         return 0xdeadbeef;
 
     color = *((DWORD *)surface_desc.lpSurface) & 0x00ffffff;
 
     hr = IDirectDrawSurface7_Unlock(surface, &rect);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     return color;
 }
@@ -396,7 +396,7 @@ static void fill_surface(IDirectDrawSurface7 *surface, D3DCOLOR color)
     DWORD *ptr;
 
     hr = IDirectDrawSurface7_Lock(surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (y = 0; y < surface_desc.dwHeight; ++y)
     {
@@ -408,7 +408,7 @@ static void fill_surface(IDirectDrawSurface7 *surface, D3DCOLOR color)
     }
 
     hr = IDirectDrawSurface7_Unlock(surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 }
 
 #define check_rect(a, b) check_rect_(__LINE__, a, b)
@@ -443,7 +443,7 @@ static void check_rect_(unsigned int line, IDirectDrawSurface7 *surface, RECT r)
                     if (x < 0 || x >= 640 || y < 0 || y >= 480)
                         continue;
                     color = get_surface_color(surface, x, y);
-                    ok_(__FILE__, line)(color == expected, "Pixel (%d, %d) has color %08x, expected %08x.\n",
+                    ok_(__FILE__, line)(color == expected, "Pixel (%ld, %ld) has color %08lx, expected %08lx.\n",
                             x, y, color, expected);
                 }
             }
@@ -496,7 +496,7 @@ static IDirect3DDevice7 *create_device_ex(HWND window, DWORD coop_level, const G
         return NULL;
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, coop_level);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -508,18 +508,18 @@ static IDirect3DDevice7 *create_device_ex(HWND window, DWORD coop_level, const G
     surface_desc.dwHeight = 480;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     if (coop_level & DDSCL_NORMAL)
     {
         IDirectDrawClipper *clipper;
 
         hr = IDirectDraw7_CreateClipper(ddraw, 0, &clipper, NULL);
-        ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
         hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
-        ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
         hr = IDirectDrawSurface7_SetClipper(surface, clipper);
-        ok(SUCCEEDED(hr), "Failed to set surface clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set surface clipper, hr %#lx.\n", hr);
         IDirectDrawClipper_Release(clipper);
     }
 
@@ -550,7 +550,7 @@ static IDirect3DDevice7 *create_device_ex(HWND window, DWORD coop_level, const G
     surface_desc.dwWidth = 640;
     surface_desc.dwHeight = 480;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &ds, NULL);
-    ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
         IDirect3D7_Release(d3d7);
@@ -559,7 +559,7 @@ static IDirect3DDevice7 *create_device_ex(HWND window, DWORD coop_level, const G
     }
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface, ds);
-    ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
     IDirectDrawSurface7_Release(ds);
     if (FAILED(hr))
     {
@@ -593,7 +593,7 @@ static IDirect3DDevice7 *create_device(HWND window, DWORD coop_level)
         return NULL;
 
     hr = IDirect3D7_EnumDevices(d3d7, enum_devtype_cb, &hal_ok);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (hal_ok)
         device_guid = &IID_IDirect3DTnLHalDevice;
 
@@ -621,13 +621,13 @@ static LRESULT CALLBACK test_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM
     {
         if (expect_messages->check_wparam)
             ok (wparam == expect_messages->expect_wparam,
-                    "Got unexpected wparam %lx for message %x, expected %lx.\n",
+                    "Got unexpected wparam %Ix for message %x, expected %Ix.\n",
                     wparam, message, expect_messages->expect_wparam);
 
         if (focus_test_ddraw)
         {
             hr = IDirectDraw7_TestCooperativeLevel(focus_test_ddraw);
-            ok(hr == expect_messages->ddraw_state, "Got ddraw state %#x on message %#x, expected %#x.\n",
+            ok(hr == expect_messages->ddraw_state, "Got ddraw state %#lx on message %#x, expected %#lx.\n",
                     hr, message, expect_messages->ddraw_state);
         }
 
@@ -650,9 +650,9 @@ static void fix_wndproc(HWND window, LONG_PTR proc)
 
     SetWindowLongPtrA(window, GWLP_WNDPROC, proc);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     IDirectDraw7_Release(ddraw);
 }
@@ -701,17 +701,17 @@ static void test_process_vertices(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d7);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = D3DFVF_XYZ;
     vb_desc.dwNumVertices = 4;
     hr = IDirect3D7_CreateVertexBuffer(d3d7, &vb_desc, &src_vb, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(src_vb, 0, (void **)&src_data, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     src_data[0].x = 0.0f;
     src_data[0].y = 0.0f;
     src_data[0].z = 0.0f;
@@ -725,7 +725,7 @@ static void test_process_vertices(void)
     src_data[3].y = -0.5f;
     src_data[3].z = 0.25f;
     hr = IDirect3DVertexBuffer7_Unlock(src_vb);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
@@ -733,7 +733,7 @@ static void test_process_vertices(void)
     vb_desc.dwNumVertices = 4;
     /* MSDN says that the last parameter must be 0 - check that. */
     hr = IDirect3D7_CreateVertexBuffer(d3d7, &vb_desc, &dst_vb1, 4);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
@@ -741,7 +741,7 @@ static void test_process_vertices(void)
     vb_desc.dwNumVertices = 5;
     /* MSDN says that the last parameter must be 0 - check that. */
     hr = IDirect3D7_CreateVertexBuffer(d3d7, &vb_desc, &dst_vb2, 12345678);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vp, 0, sizeof(vp));
     vp.dwX = 64;
@@ -751,15 +751,15 @@ static void test_process_vertices(void)
     vp.dvMinZ = 0.0f;
     vp.dvMaxZ = 1.0f;
     hr = IDirect3DDevice7_SetViewport(device, &vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb1, D3DVOP_TRANSFORM, 0, 4, src_vb, 0, device, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb2, D3DVOP_TRANSFORM, 0, 4, src_vb, 0, device, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(dst_vb1, 0, (void **)&dst_data, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(compare_vec4(&dst_data[0], +1.280e+2f, +1.280e+2f, +0.000e+0f, +1.000e+0f, 4096),
             "Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
@@ -773,10 +773,10 @@ static void test_process_vertices(void)
             "Got unexpected vertex 3 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[3].x, dst_data[3].y, dst_data[3].z, dst_data[3].w);
     hr = IDirect3DVertexBuffer7_Unlock(dst_vb1);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(dst_vb2, 0, (void **)&dst_data2, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     /* Small thing without much practical meaning, but I stumbled upon it,
      * so let's check for it: If the output vertex buffer has no RHW value,
      * the RHW value of the last vertex is written into the next vertex. */
@@ -784,21 +784,21 @@ static void test_process_vertices(void)
             "Got unexpected vertex 4 {%.8e, %.8e, %.8e}.\n",
             dst_data2[4].x, dst_data2[4].y, dst_data2[4].z);
     hr = IDirect3DVertexBuffer7_Unlock(dst_vb2);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Test degenerate viewport z ranges. */
     vp.dvMinZ = 0.0f;
     vp.dvMaxZ = 0.0f;
     hr = IDirect3DDevice7_SetViewport(device, &vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb1, D3DVOP_TRANSFORM, 0, 4, src_vb, 0, device, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb2, D3DVOP_TRANSFORM, 0, 4, src_vb, 0, device, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(dst_vb1, 0, (void **)&dst_data, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(compare_vec4(&dst_data[0], +1.280e+2f, +1.280e+2f, +0.000e+0f, +1.000e+0f, 4096),
             "Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
@@ -812,20 +812,20 @@ static void test_process_vertices(void)
             "Got unexpected vertex 3 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[3].x, dst_data[3].y, dst_data[3].z, dst_data[3].w);
     hr = IDirect3DVertexBuffer7_Unlock(dst_vb1);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     vp.dvMinZ = 1.0f;
     vp.dvMaxZ = 0.0f;
     hr = IDirect3DDevice7_SetViewport(device, &vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb1, D3DVOP_TRANSFORM, 0, 4, src_vb, 0, device, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb2, D3DVOP_TRANSFORM, 0, 4, src_vb, 0, device, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(dst_vb1, 0, (void **)&dst_data, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(compare_vec4(&dst_data[0], +1.280e+2f, +1.280e+2f, +1.000e+0f, +1.000e+0f, 4096),
             "Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
@@ -839,7 +839,7 @@ static void test_process_vertices(void)
             "Got unexpected vertex 3 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[3].x, dst_data[3].y, dst_data[3].z, dst_data[3].w);
     hr = IDirect3DVertexBuffer7_Unlock(dst_vb1);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Try a more complicated viewport, same vertices. */
     memset(&vp, 0, sizeof(vp));
@@ -850,13 +850,13 @@ static void test_process_vertices(void)
     vp.dvMinZ = -2.0f;
     vp.dvMaxZ = 4.0f;
     hr = IDirect3DDevice7_SetViewport(device, &vp);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb1, D3DVOP_TRANSFORM, 0, 4, src_vb, 0, device, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(dst_vb1, 0, (void **)&dst_data, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(compare_vec4(&dst_data[0], +1.330e+2f, +7.000e+1f, -2.000e+0f, +1.000e+0f, 4096),
             "Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
@@ -870,20 +870,20 @@ static void test_process_vertices(void)
             "Got unexpected vertex 3 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[3].x, dst_data[3].y, dst_data[3].z, dst_data[3].w);
     hr = IDirect3DVertexBuffer7_Unlock(dst_vb1);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &world);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &view);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &proj);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb1, D3DVOP_TRANSFORM, 0, 4, src_vb, 0, device, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(dst_vb1, 0, (void **)&dst_data, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(compare_vec4(&dst_data[0], +2.560e+2f, +7.000e+1f, -2.000e+0f, +3.333e-1f, 4096),
             "Got unexpected vertex 0 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[0].x, dst_data[0].y, dst_data[0].z, dst_data[0].w);
@@ -897,7 +897,7 @@ static void test_process_vertices(void)
             "Got unexpected vertex 3 {%.8e, %.8e, %.8e, %.8e}.\n",
             dst_data[3].x, dst_data[3].y, dst_data[3].z, dst_data[3].w);
     hr = IDirect3DVertexBuffer7_Unlock(dst_vb1);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirect3DVertexBuffer7_Release(dst_vb2);
     IDirect3DVertexBuffer7_Release(dst_vb1);
@@ -918,23 +918,23 @@ static void test_coop_level_create_device_window(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOFOCUSWINDOW || broken(hr == DDERR_INVALIDPARAMS), "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
 
@@ -948,48 +948,48 @@ static void test_coop_level_create_device_window(void)
     }
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, focus_window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_SETFOCUSWINDOW
             | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DDERR_NOHWND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOHWND, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!!device_window, "Device window not found.\n");
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW
             | DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!!device_window, "Device window not found.\n");
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOFOCUSWINDOW, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, focus_window, DDSCL_SETFOCUSWINDOW);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!device_window, "Unexpected device window found.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     device_window = FindWindowA("DirectDrawDeviceWnd", "DirectDrawDeviceWnd");
     ok(!!device_window, "Device window not found.\n");
 
@@ -1063,22 +1063,22 @@ static void test_clipper_blt(void)
     ok(ret, "Failed to map client rect.\n");
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     hr = IDirectDraw7_CreateClipper(ddraw, 0, &clipper, NULL);
-    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
-    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#lx.\n", hr);
     rgn_data = HeapAlloc(GetProcessHeap(), 0, ret);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, rgn_data, &ret);
-    ok(SUCCEEDED(hr), "Failed to get clip list, hr %#x.\n", hr);
-    ok(rgn_data->rdh.dwSize == sizeof(rgn_data->rdh), "Got unexpected structure size %#x.\n", rgn_data->rdh.dwSize);
-    ok(rgn_data->rdh.iType == RDH_RECTANGLES, "Got unexpected type %#x.\n", rgn_data->rdh.iType);
-    ok(rgn_data->rdh.nCount >= 1, "Got unexpected count %u.\n", rgn_data->rdh.nCount);
+    ok(SUCCEEDED(hr), "Failed to get clip list, hr %#lx.\n", hr);
+    ok(rgn_data->rdh.dwSize == sizeof(rgn_data->rdh), "Got unexpected structure size %#lx.\n", rgn_data->rdh.dwSize);
+    ok(rgn_data->rdh.iType == RDH_RECTANGLES, "Got unexpected type %#lx.\n", rgn_data->rdh.iType);
+    ok(rgn_data->rdh.nCount >= 1, "Got unexpected count %lu.\n", rgn_data->rdh.nCount);
     ok(EqualRect(&rgn_data->rdh.rcBound, &client_rect),
             "Got unexpected bounding rect %s, expected %s.\n",
             wine_dbgstr_rect(&rgn_data->rdh.rcBound), wine_dbgstr_rect(&client_rect));
@@ -1098,11 +1098,11 @@ static void test_clipper_blt(void)
     DeleteObject(r1);
 
     hr = IDirectDrawClipper_SetClipList(clipper, rgn_data, 0);
-    ok(hr == DDERR_CLIPPERISUSINGHWND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CLIPPERISUSINGHWND, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetHWnd(clipper, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetClipList(clipper, rgn_data, 0);
-    ok(SUCCEEDED(hr), "Failed to set clip list, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clip list, hr %#lx.\n", hr);
 
     HeapFree(GetProcessHeap(), 0, rgn_data);
 
@@ -1120,33 +1120,33 @@ static void test_clipper_blt(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#lx.\n", hr);
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &dst_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     hr = IDirectDrawSurface7_Blt(src_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Lock(src_surface, NULL, &surface_desc, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#x.\n", hr);
-    ok(U1(surface_desc).lPitch == 2560, "Got unexpected surface pitch %u.\n", U1(surface_desc).lPitch);
+    ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#lx.\n", hr);
+    ok(U1(surface_desc).lPitch == 2560, "Got unexpected surface pitch %lu.\n", U1(surface_desc).lPitch);
     ptr = surface_desc.lpSurface;
     memcpy(&ptr[   0], &src_data[ 0], 6 * sizeof(DWORD));
     memcpy(&ptr[ 640], &src_data[ 6], 6 * sizeof(DWORD));
     memcpy(&ptr[1280], &src_data[12], 6 * sizeof(DWORD));
     hr = IDirectDrawSurface7_Unlock(src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_SetClipper(dst_surface, clipper);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
 
     SetRect(&src_rect, 1, 1, 5, 2);
     hr = IDirectDrawSurface7_Blt(dst_surface, NULL, src_surface, &src_rect, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
     for (i = 0; i < 4; ++i)
     {
         for (j = 0; j < 4; ++j)
@@ -1156,13 +1156,13 @@ static void test_clipper_blt(void)
             color = get_surface_color(dst_surface, x, y);
             ok(compare_color(color, expected1[i * 4 + j], 1)
                     || broken(compare_color(color, expected1_broken[i * 4 + j], 1)),
-                    "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected1[i * 4 + j], x, y, color);
+                    "Expected color 0x%08lx at %u,%u, got 0x%08lx.\n", expected1[i * 4 + j], x, y, color);
         }
     }
 
     U5(fx).dwFillColor = 0xff0000ff;
     hr = IDirectDrawSurface7_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#lx.\n", hr);
     for (i = 0; i < 4; ++i)
     {
         for (j = 0; j < 4; ++j)
@@ -1171,35 +1171,35 @@ static void test_clipper_blt(void)
             y = 60 * ((2 * i) + 1);
             color = get_surface_color(dst_surface, x, y);
             ok(compare_color(color, expected2[i * 4 + j], 1),
-                    "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
+                    "Expected color 0x%08lx at %u,%u, got 0x%08lx.\n", expected2[i * 4 + j], x, y, color);
         }
     }
 
     hr = IDirectDrawSurface7_BltFast(dst_surface, 0, 0, src_surface, NULL, DDBLTFAST_WAIT);
-    ok(hr == DDERR_BLTFASTCANTCLIP, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_BLTFASTCANTCLIP, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
-    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#lx.\n", hr);
     DestroyWindow(window);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetHWnd(clipper, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get clip list size, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_SetClipList(clipper, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to set clip list, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clip list, hr %#lx.\n", hr);
     hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
-    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(dst_surface);
     IDirectDrawSurface7_Release(src_surface);
     refcount = IDirectDrawClipper_Release(clipper);
-    ok(!refcount, "Clipper has %u references left.\n", refcount);
+    ok(!refcount, "Clipper has %lu references left.\n", refcount);
     IDirectDraw7_Release(ddraw);
 }
 
@@ -1238,94 +1238,94 @@ static void test_coop_level_d3d_state(void)
     }
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_DESTALPHA);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_ZENABLE, &value);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok(!!value, "Got unexpected z-enable state %#x.\n", value);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(!!value, "Got unexpected z-enable state %#lx.\n", value);
     hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, &value);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok(!value, "Got unexpected alpha blend enable state %#x.\n", value);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(!value, "Got unexpected alpha blend enable state %#lx.\n", value);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(rt);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     memset(&lock, 0, sizeof(lock));
     lock.dwSize = sizeof(lock);
     lock.lpSurface = (void *)0xdeadbeef;
     hr = IDirectDrawSurface7_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     ok(lock.lpSurface == (void *)0xdeadbeef, "Got unexpected lock.lpSurface %p.\n", lock.lpSurface);
 
     memset(&caps, 0, sizeof(caps));
     caps.dwCaps = DDSCAPS_ZBUFFER;
     hr = IDirectDrawSurface7_GetAttachedSurface(rt, &caps, &surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     caps.dwCaps = DDSCAPS_FLIP;
     hr = IDirectDrawSurface7_GetAttachedSurface(rt, &caps, &surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw7_RestoreAllSurfaces(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Lock(rt, NULL, &lock, DDLOCK_READONLY, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Unlock(rt, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     caps.dwCaps = DDSCAPS_ZBUFFER;
     hr = IDirectDrawSurface7_GetAttachedSurface(rt, &caps, &surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface7_Release(surface);
 
     caps.dwCaps = DDSCAPS_FLIP;
     hr = IDirectDrawSurface7_GetAttachedSurface(rt, &caps, &surface);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDraw7_Release(ddraw);
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(surface == rt, "Got unexpected surface %p.\n", surface);
     hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_ZENABLE, &value);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok(!!value, "Got unexpected z-enable state %#x.\n", value);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(!!value, "Got unexpected z-enable state %#lx.\n", value);
     hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, &value);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok(!!value, "Got unexpected alpha blend enable state %#x.\n", value);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(!!value, "Got unexpected alpha blend enable state %#lx.\n", value);
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ff00, 1.0f, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZ | D3DFVF_DIFFUSE, quad, ARRAY_SIZE(quad), 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x0000ff80, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff80, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface7_Release(surface);
     IDirectDrawSurface7_Release(rt);
@@ -1351,7 +1351,7 @@ static void test_surface_interface_mismatch(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -1361,10 +1361,10 @@ static void test_surface_interface_mismatch(void)
     surface_desc.dwHeight = 480;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3);
-    ok(SUCCEEDED(hr), "Failed to QI IDirectDrawSurface3, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to QI IDirectDrawSurface3, hr %#lx.\n", hr);
 
     if (FAILED(IDirectDraw7_QueryInterface(ddraw, &IID_IDirect3D7, (void **)&d3d)))
     {
@@ -1388,15 +1388,15 @@ static void test_surface_interface_mismatch(void)
     surface_desc.dwWidth = 640;
     surface_desc.dwHeight = 480;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &ds, NULL);
-    ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#lx.\n", hr);
     if (FAILED(hr))
         goto cleanup;
 
     /* Using a different surface interface version still works */
     hr = IDirectDrawSurface3_AddAttachedSurface(surface3, (IDirectDrawSurface3 *)ds);
-    ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
     refcount = IDirectDrawSurface7_Release(ds);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     if (FAILED(hr))
         goto cleanup;
 
@@ -1407,9 +1407,9 @@ static void test_surface_interface_mismatch(void)
         goto cleanup;
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
     color = get_surface_color(surface, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
 cleanup:
     if (surface3) IDirectDrawSurface3_Release(surface3);
@@ -1431,7 +1431,7 @@ static void test_coop_level_threaded(void)
     create_window_thread(&p);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, p.window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     destroy_window_thread(&p);
     IDirectDraw7_Release(ddraw);
@@ -1480,9 +1480,9 @@ static void test_depth_blit(const GUID *device_guid)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get DirectDraw7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DirectDraw7 interface, hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
 
     ds1 = get_depth_stencil(device);
@@ -1492,7 +1492,7 @@ static void test_depth_blit(const GUID *device_guid)
     memset(&ddsd_existing, 0, sizeof(ddsd_existing));
     ddsd_existing.dwSize = sizeof(ddsd_existing);
     hr = IDirectDrawSurface7_GetSurfaceDesc(ds1, &ddsd_existing);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     ddsd_new.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
     ddsd_new.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
     if (is_software_device_type(device_guid))
@@ -1501,66 +1501,66 @@ static void test_depth_blit(const GUID *device_guid)
     ddsd_new.dwHeight = ddsd_existing.dwHeight;
     U4(ddsd_new).ddpfPixelFormat = U4(ddsd_existing).ddpfPixelFormat;
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd_new, &ds2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create a z buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create a z buffer, hr %#lx.\n", hr);
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd_new, &ds3, NULL);
-    ok(SUCCEEDED(hr), "Failed to create a z buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create a z buffer, hr %#lx.\n", hr);
     IDirectDraw7_Release(ddraw);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable z testing, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable z testing, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZFUNC, D3DCMP_LESSEQUAL);
-    ok(SUCCEEDED(hr), "Failed to set the z function, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set the z function, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear the z buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear the z buffer, hr %#lx.\n", hr);
 
     /* Partial blit. */
     SetRect(&src_rect, 0, 0, 320, 240);
     SetRect(&dst_rect, 0, 0, 320, 240);
     hr = IDirectDrawSurface7_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* Different locations. */
     SetRect(&src_rect, 0, 0, 320, 240);
     SetRect(&dst_rect, 320, 240, 640, 480);
     hr = IDirectDrawSurface7_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* Stretched. */
     SetRect(&src_rect, 0, 0, 320, 240);
     SetRect(&dst_rect, 0, 0, 640, 480);
     hr = IDirectDrawSurface7_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* Flipped. */
     SetRect(&src_rect, 0, 480, 640, 0);
     SetRect(&dst_rect, 0, 0, 640, 480);
     hr = IDirectDrawSurface7_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     SetRect(&src_rect, 0, 0, 640, 480);
     SetRect(&dst_rect, 0, 480, 640, 0);
     hr = IDirectDrawSurface7_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     /* Full, explicit. */
     SetRect(&src_rect, 0, 0, 640, 480);
     SetRect(&dst_rect, 0, 0, 640, 480);
     hr = IDirectDrawSurface7_Blt(ds2, &dst_rect, ds1, &src_rect, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* Depth -> color blit: Succeeds on Win7 + Radeon HD 5700, fails on WinXP + Radeon X1600 */
 
     /* Depth blit inside a BeginScene / EndScene pair */
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to start scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to start scene, hr %#lx.\n", hr);
     /* From the current depth stencil */
     hr = IDirectDrawSurface7_Blt(ds2, NULL, ds1, NULL, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* To the current depth stencil */
     hr = IDirectDrawSurface7_Blt(ds1, NULL, ds2, NULL, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     /* Between unbound surfaces */
     hr = IDirectDrawSurface7_Blt(ds3, NULL, ds2, NULL, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     /* Avoid changing the depth stencil, it doesn't work properly on Windows.
      * Instead use DDBLT_DEPTHFILL to clear the depth stencil. Unfortunately
@@ -1569,40 +1569,40 @@ static void test_depth_blit(const GUID *device_guid)
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     hr = IDirectDrawSurface7_Blt(ds2, NULL, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET, 0xffff0000, 1.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(rt, 80, 60);
 
     /* For some reason clears and colour fill blits randomly fail with software render target. */
     ok(color == 0x00ff0000 || broken(is_software_device_type(device_guid) && !color),
-            "Got unexpected colour 0x%08x.\n", color);
+            "Got unexpected colour 0x%08lx.\n", color);
     if (!color)
     {
         fill_surface(rt, 0xffff0000);
 
         color = get_surface_color(rt, 80, 60);
-        ok(color == 0x00ff0000, "Got unexpected colour 0x%08x.\n", color);
+        ok(color == 0x00ff0000, "Got unexpected colour 0x%08lx.\n", color);
     }
 
     SetRect(&dst_rect, 0, 0, 320, 240);
     hr = IDirectDrawSurface7_Blt(ds1, &dst_rect, ds2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface7_Release(ds3);
     IDirectDrawSurface7_Release(ds2);
     IDirectDrawSurface7_Release(ds1);
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             quad1, 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < 4; ++i)
     {
@@ -1612,7 +1612,7 @@ static void test_depth_blit(const GUID *device_guid)
             unsigned int y = 60 * ((2 * i) + 1);
             color = get_surface_color(rt, x, y);
             ok(compare_color(color, expected_colors[i][j], 1),
-                    "Expected color 0x%08x at %u,%u, got 0x%08x, software device %#x.\n",
+                    "Expected color 0x%08lx at %u,%u, got 0x%08lx, software device %#x.\n",
                     expected_colors[i][j], x, y, color, is_software_device_type(device_guid));
         }
     }
@@ -1643,9 +1643,9 @@ static void test_texture_load_ckey(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get DirectDraw7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DirectDraw7 interface, hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
 
     memset(&ddsd, 0, sizeof(ddsd));
@@ -1655,52 +1655,52 @@ static void test_texture_load_ckey(void)
     ddsd.dwWidth = 128;
     ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &src, NULL);
-    ok(SUCCEEDED(hr), "Failed to create source texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create source texture, hr %#lx.\n", hr);
     ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to create destination texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create destination texture, hr %#lx.\n", hr);
 
     /* No surface has a color key */
     hr = IDirect3DDevice7_Load(device, dst, NULL, src, NULL, 0);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0xdeadbeef;
     hr = IDirectDrawSurface7_GetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
-    ok(ckey.dwColorSpaceLowValue == 0xdeadbeef, "dwColorSpaceLowValue is %#x.\n", ckey.dwColorSpaceLowValue);
-    ok(ckey.dwColorSpaceHighValue == 0xdeadbeef, "dwColorSpaceHighValue is %#x.\n", ckey.dwColorSpaceHighValue);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
+    ok(ckey.dwColorSpaceLowValue == 0xdeadbeef, "dwColorSpaceLowValue is %#lx.\n", ckey.dwColorSpaceLowValue);
+    ok(ckey.dwColorSpaceHighValue == 0xdeadbeef, "dwColorSpaceHighValue is %#lx.\n", ckey.dwColorSpaceHighValue);
 
     /* Source surface has a color key */
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface7_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_Load(device, dst, NULL, src, NULL, 0);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
-    ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#x.\n", ckey.dwColorSpaceLowValue);
-    ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
+    ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#lx.\n", ckey.dwColorSpaceLowValue);
+    ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#lx.\n", ckey.dwColorSpaceHighValue);
 
     /* Both surfaces have a color key: Dest ckey is overwritten */
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0x000000ff;
     hr = IDirectDrawSurface7_SetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_Load(device, dst, NULL, src, NULL, 0);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
-    ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#x.\n", ckey.dwColorSpaceLowValue);
-    ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
+    ok(ckey.dwColorSpaceLowValue == 0x0000ff00, "dwColorSpaceLowValue is %#lx.\n", ckey.dwColorSpaceLowValue);
+    ok(ckey.dwColorSpaceHighValue == 0x0000ff00, "dwColorSpaceHighValue is %#lx.\n", ckey.dwColorSpaceHighValue);
 
     /* Only the destination has a color key: It is deleted. This behavior differs from
      * IDirect3DTexture(2)::Load */
     hr = IDirectDrawSurface7_SetColorKey(src, DDCKEY_SRCBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_Load(device, dst, NULL, src, NULL, 0);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    todo_wine ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(dst);
     IDirectDrawSurface7_Release(src);
@@ -1740,32 +1740,32 @@ static void test_zenable(const GUID *device_guid)
     }
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 80, 60);
     /* For some reason clears and colour fill blits randomly fail with software render target. */
     ok(color == 0x00ff0000 || broken(is_software_device_type(device_guid) && !color),
-            "Got unexpected colour 0x%08x.\n", color);
+            "Got unexpected colour 0x%08lx.\n", color);
     if (!color)
     {
         fill_surface(rt, 0xffff0000);
 
         color = get_surface_color(rt, 80, 60);
-        ok(color == 0x00ff0000, "Got unexpected colour 0x%08x.\n", color);
+        ok(color == 0x00ff0000, "Got unexpected colour 0x%08lx.\n", color);
     }
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_DIFFUSE, tquad, 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < 4; ++i)
     {
@@ -1775,7 +1775,7 @@ static void test_zenable(const GUID *device_guid)
             y = 60 * ((2 * i) + 1);
             color = get_surface_color(rt, x, y);
             ok(compare_color(color, 0x0000ff00, 1),
-                    "Expected color 0x0000ff00 at %u, %u, got 0x%08x.\n", x, y, color);
+                    "Expected color 0x0000ff00 at %u, %u, got 0x%08lx.\n", x, y, color);
         }
     }
     IDirectDrawSurface7_Release(rt);
@@ -1845,9 +1845,9 @@ static void test_ck_rgba(const GUID *device_guid)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -1868,65 +1868,65 @@ static void test_ck_rgba(const GUID *device_guid)
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0xff00ff00;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0xff00ff00;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &texture, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetTexture(device, 0, texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, tests[i].color_key);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, tests[i].blend);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         memset(&fx, 0, sizeof(fx));
         fx.dwSize = sizeof(fx);
         U5(fx).dwFillColor = tests[i].fill_color;
         hr = IDirectDrawSurface7_Blt(texture, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 1.0f, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         /* RT clears are broken on Windows for software render target. */
         if (is_software_device_type(device_guid))
             fill_surface(rt, 0xffff0000);
 
         hr = IDirect3DDevice7_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_TEX1, &tquad[0], 4, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice7_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, tests[i].result1, 2) || compare_color(color, tests[i].result1_broken, 1),
-                "Expected color 0x%08x for test %u, got 0x%08x.\n",
+                "Expected color 0x%08lx for test %u, got 0x%08lx.\n",
                 tests[i].result1, i, color);
 
         U5(fx).dwFillColor = 0xff0000ff;
         hr = IDirectDrawSurface7_Blt(texture, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_TEX1, &tquad[4], 4, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice7_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         /* This tests that fragments that are masked out by the color key are
          * discarded, instead of just fully transparent. */
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, tests[i].result2, 2) || compare_color(color, tests[i].result2_broken, 1),
-                "Expected color 0x%08x for test %u, got 0x%08x.\n",
+                "Expected color 0x%08lx for test %u, got 0x%08lx.\n",
                 tests[i].result2, i, color);
     }
 
@@ -1971,13 +1971,13 @@ static void test_ck_default(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -1994,45 +1994,45 @@ static void test_ck_default(void)
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x000000ff;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x000000ff;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTexture(device, 0, surface);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 0x000000ff;
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, &value);
-    ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
-    ok(!value, "Got unexpected color keying state %#x.\n", value);
+    ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
+    ok(!value, "Got unexpected color keying state %#lx.\n", value);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_TEX1, &tquad[0], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable color keying, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable color keying, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_TEX1, &tquad[0], 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, &value);
-    ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
-    ok(!!value, "Got unexpected color keying state %#x.\n", value);
+    ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
+    ok(!!value, "Got unexpected color keying state %#lx.\n", value);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface7_Release(surface);
     IDirectDrawSurface7_Release(rt);
@@ -2064,11 +2064,11 @@ static void test_ck_complex(void)
         return;
     }
     hr = IDirect3DDevice7_GetCaps(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -2078,20 +2078,20 @@ static void test_ck_complex(void)
     surface_desc.dwWidth = 128;
     surface_desc.dwHeight = 128;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
     color_key.dwColorSpaceLowValue = 0x0000ff00;
     color_key.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface7_SetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     memset(&color_key, 0, sizeof(color_key));
     hr = IDirectDrawSurface7_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceLowValue);
-    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceHighValue);
 
     mipmap = surface;
@@ -2099,24 +2099,24 @@ static void test_ck_complex(void)
     for (i = 0; i < 7; ++i)
     {
         hr = IDirectDrawSurface7_GetAttachedSurface(mipmap, &caps, &tmp);
-        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#lx.\n", i, hr);
         hr = IDirectDrawSurface7_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-        ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x, i %u.\n", hr, i);
+        ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx, i %u.\n", hr, i);
 
         color_key.dwColorSpaceLowValue = 0x000000ff;
         color_key.dwColorSpaceHighValue = 0x000000ff;
         hr = IDirectDrawSurface7_SetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-        ok(hr == DDERR_NOTONMIPMAPSUBLEVEL, "Got unexpected hr %#x, i %u.\n", hr, i);
+        ok(hr == DDERR_NOTONMIPMAPSUBLEVEL, "Got unexpected hr %#lx, i %u.\n", hr, i);
 
         IDirectDrawSurface_Release(mipmap);
         mipmap = tmp;
     }
 
     hr = IDirectDrawSurface7_GetAttachedSurface(mipmap, &caps, &tmp);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface_Release(mipmap);
     refcount = IDirectDrawSurface7_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -2124,43 +2124,43 @@ static void test_ck_complex(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     U5(surface_desc).dwBackBufferCount = 1;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
     color_key.dwColorSpaceLowValue = 0x0000ff00;
     color_key.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface7_SetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     memset(&color_key, 0, sizeof(color_key));
     hr = IDirectDrawSurface7_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceLowValue);
-    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceHighValue);
 
     hr = IDirectDrawSurface7_GetAttachedSurface(surface, &caps, &tmp);
-    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x, i %u.\n", hr, i);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx, i %u.\n", hr, i);
     color_key.dwColorSpaceLowValue = 0x0000ff00;
     color_key.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface7_SetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     memset(&color_key, 0, sizeof(color_key));
     hr = IDirectDrawSurface7_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(color_key.dwColorSpaceLowValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceLowValue);
-    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08x.\n",
+    ok(color_key.dwColorSpaceHighValue == 0x0000ff00, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceHighValue);
 
     IDirectDrawSurface_Release(tmp);
 
     refcount = IDirectDrawSurface7_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     if (!(device_desc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_CUBEMAP))
     {
@@ -2175,47 +2175,47 @@ static void test_ck_complex(void)
     surface_desc.dwWidth = 128;
     surface_desc.dwHeight = 128;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_GetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
     color_key.dwColorSpaceLowValue = 0x0000ff00;
     color_key.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface7_SetColorKey(surface, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     caps.dwCaps2 = DDSCAPS2_CUBEMAP_NEGATIVEZ;
     hr = IDirectDrawSurface7_GetAttachedSurface(surface, &caps, &mipmap);
-    ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#x.\n", i, hr);
+    ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#lx.\n", i, hr);
 
     hr = IDirectDrawSurface7_GetColorKey(mipmap, DDCKEY_SRCBLT, &color_key);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
     color_key.dwColorSpaceLowValue = 0x000000ff;
     color_key.dwColorSpaceHighValue = 0x000000ff;
     hr = IDirectDrawSurface7_SetColorKey(mipmap, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     color_key.dwColorSpaceLowValue = 0;
     color_key.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface7_GetColorKey(mipmap, DDCKEY_SRCBLT, &color_key);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(color_key.dwColorSpaceLowValue == 0x000000ff, "Got unexpected value 0x%08x.\n",
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(color_key.dwColorSpaceLowValue == 0x000000ff, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceLowValue);
-    ok(color_key.dwColorSpaceHighValue == 0x000000ff, "Got unexpected value 0x%08x.\n",
+    ok(color_key.dwColorSpaceHighValue == 0x000000ff, "Got unexpected value 0x%08lx.\n",
             color_key.dwColorSpaceHighValue);
 
     IDirectDrawSurface_AddRef(mipmap);
     for (i = 0; i < 7; ++i)
     {
         hr = IDirectDrawSurface7_GetAttachedSurface(mipmap, &caps, &tmp);
-        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#lx.\n", i, hr);
         hr = IDirectDrawSurface7_GetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-        ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x, i %u.\n", hr, i);
+        ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx, i %u.\n", hr, i);
 
         color_key.dwColorSpaceLowValue = 0x000000ff;
         color_key.dwColorSpaceHighValue = 0x000000ff;
         hr = IDirectDrawSurface7_SetColorKey(tmp, DDCKEY_SRCBLT, &color_key);
-        ok(hr == DDERR_NOTONMIPMAPSUBLEVEL, "Got unexpected hr %#x, i %u.\n", hr, i);
+        ok(hr == DDERR_NOTONMIPMAPSUBLEVEL, "Got unexpected hr %#lx, i %u.\n", hr, i);
 
         IDirectDrawSurface_Release(mipmap);
         mipmap = tmp;
@@ -2224,12 +2224,12 @@ static void test_ck_complex(void)
     IDirectDrawSurface7_Release(mipmap);
 
     refcount = IDirectDrawSurface7_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
 cleanup:
     IDirectDraw7_Release(ddraw);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -2251,13 +2251,13 @@ static void test_qi(const char *test_name, IUnknown *base_iface,
     for (i = 0; i < entry_count; ++i)
     {
         hr = IUnknown_QueryInterface(base_iface, tests[i].iid, (void **)&iface1);
-        ok(hr == tests[i].hr, "Got hr %#x for test \"%s\" %u.\n", hr, test_name, i);
+        ok(hr == tests[i].hr, "Got hr %#lx for test \"%s\" %u.\n", hr, test_name, i);
         if (SUCCEEDED(hr))
         {
             for (j = 0; j < entry_count; ++j)
             {
                 hr = IUnknown_QueryInterface(iface1, tests[j].iid, (void **)&iface2);
-                ok(hr == tests[j].hr, "Got hr %#x for test \"%s\" %u, %u.\n", hr, test_name, i, j);
+                ok(hr == tests[j].hr, "Got hr %#lx for test \"%s\" %u, %u.\n", hr, test_name, i, j);
                 if (SUCCEEDED(hr))
                 {
                     expected_refcount = 0;
@@ -2266,7 +2266,7 @@ static void test_qi(const char *test_name, IUnknown *base_iface,
                     if (IsEqualGUID(tests[i].refcount_iid, tests[j].refcount_iid))
                         ++expected_refcount;
                     refcount = IUnknown_Release(iface2);
-                    ok(refcount == expected_refcount, "Got refcount %u for test \"%s\" %u, %u, expected %u.\n",
+                    ok(refcount == expected_refcount, "Got refcount %lu for test \"%s\" %u, %u, expected %lu.\n",
                             refcount, test_name, i, j, expected_refcount);
                 }
             }
@@ -2275,7 +2275,7 @@ static void test_qi(const char *test_name, IUnknown *base_iface,
             if (IsEqualGUID(refcount_iid, tests[i].refcount_iid))
                 ++expected_refcount;
             refcount = IUnknown_Release(iface1);
-            ok(refcount == expected_refcount, "Got refcount %u for test \"%s\" %u, expected %u.\n",
+            ok(refcount == expected_refcount, "Got refcount %lu for test \"%s\" %u, expected %lu.\n",
                     refcount, test_name, i, expected_refcount);
         }
     }
@@ -2351,7 +2351,7 @@ static void test_surface_qi(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -2360,9 +2360,9 @@ static void test_surface_qi(void)
     surface_desc.dwWidth = 512;
     surface_desc.dwHeight = 512;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, (IDirectDrawSurface7 **)0xdeadbeef, NULL);
-    ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     test_qi("surface_qi", (IUnknown *)surface, &IID_IDirectDrawSurface7, tests, ARRAY_SIZE(tests));
 
@@ -2468,36 +2468,36 @@ static void test_wndproc(void)
             WS_MAXIMIZE | WS_CAPTION , 0, 0, 640, 480, 0, 0, 0, 0);
 
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     expect_messages = messages;
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     ref = IDirectDraw7_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     /* DDSCL_NORMAL doesn't. */
     ddraw = create_ddraw();
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     ref = IDirectDraw7_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     /* The original window proc is only restored by ddraw if the current
@@ -2505,53 +2505,53 @@ static void test_wndproc(void)
      * from DDSCL_NORMAL to DDSCL_EXCLUSIVE. */
     ddraw = create_ddraw();
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     ddraw_proc = proc;
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)DefWindowProcA, proc);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = SetWindowLongPtrA(window, GWLP_WNDPROC, ddraw_proc);
-    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)DefWindowProcA, proc);
     ref = IDirectDraw7_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
 
     ddraw = create_ddraw();
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)test_proc, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     proc = SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)DefWindowProcA);
-    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#lx, got %#lx.\n",
+    ok(proc != (LONG_PTR)test_proc, "Expected wndproc != %#Ix, got %#Ix.\n",
             (LONG_PTR)test_proc, proc);
     ref = IDirectDraw7_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
-    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#lx, got %#lx.\n",
+    ok(proc == (LONG_PTR)DefWindowProcA, "Expected wndproc %#Ix, got %#Ix.\n",
             (LONG_PTR)DefWindowProcA, proc);
 
     fix_wndproc(window, (LONG_PTR)test_proc);
@@ -2582,12 +2582,12 @@ static void test_window_style(void)
     SetRect(&fullscreen_rect, 0, 0, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    todo_wine ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n",
@@ -2599,9 +2599,9 @@ static void test_window_style(void)
     ok(ret, "Failed to set foreground window.\n");
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    todo_wine ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
@@ -2610,77 +2610,77 @@ static void test_window_style(void)
     ShowWindow(window, SW_HIDE);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_NOWINDOWCHANGES);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    todo_wine ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ShowWindow(window, SW_HIDE);
     tmp = GetWindowLongA(window, GWL_STYLE);
-    todo_wine ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    todo_wine ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_NOWINDOWCHANGES);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ShowWindow(window, SW_HIDE);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     ShowWindow(window, SW_SHOW);
     ret = SetForegroundWindow(GetDesktopWindow());
@@ -2688,20 +2688,20 @@ static void test_window_style(void)
     SetActiveWindow(window);
     ok(GetActiveWindow() == window, "Unexpected active window.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n",
             wine_dbgstr_rect(&fullscreen_rect), wine_dbgstr_rect(&r));
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     SetWindowPos(window, NULL, 0, 0, 100, 100, SWP_NOZORDER | SWP_NOACTIVATE);
     GetWindowRect(window, &r);
@@ -2711,13 +2711,13 @@ static void test_window_style(void)
     ret = SetForegroundWindow(window2);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    todo_wine ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    todo_wine ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &fullscreen_rect), "Expected %s, got %s.\n",
@@ -2726,46 +2726,46 @@ static void test_window_style(void)
     ret = SetForegroundWindow(window);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ShowWindow(window, SW_HIDE);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
-    ok(tmp == style, "Expected window style %#x, got %#x.\n", style, tmp);
+    ok(tmp == style, "Expected window style %#lx, got %#lx.\n", style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
-    ok(tmp == exstyle, "Expected window extended style %#x, got %#x.\n", exstyle, tmp);
+    ok(tmp == exstyle, "Expected window extended style %#lx, got %#lx.\n", exstyle, tmp);
 
     ShowWindow(window, SW_SHOW);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     tmp = GetWindowLongA(window, GWL_STYLE);
     expected_style = style | WS_VISIBLE | WS_MINIMIZE;
-    todo_wine ok(tmp == expected_style, "Expected window style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window style %#lx, got %#lx.\n", expected_style, tmp);
     tmp = GetWindowLongA(window, GWL_EXSTYLE);
     expected_style = exstyle | WS_EX_TOPMOST;
-    todo_wine ok(tmp == expected_style, "Expected window extended style %#x, got %#x.\n", expected_style, tmp);
+    todo_wine ok(tmp == expected_style, "Expected window extended style %#lx, got %#lx.\n", expected_style, tmp);
 
     ref = IDirectDraw7_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     DestroyWindow(window2);
     DestroyWindow(window);
@@ -2785,15 +2785,15 @@ static void test_redundant_mode_set(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw7_GetDisplayMode(ddraw, &surface_desc);
-    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw7_SetDisplayMode(ddraw, surface_desc.dwWidth, surface_desc.dwHeight,
             U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount, 0, 0);
-    ok(SUCCEEDED(hr), "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetDisplayMode failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &q);
     r = q;
@@ -2805,14 +2805,14 @@ static void test_redundant_mode_set(void)
 
     hr = IDirectDraw7_SetDisplayMode(ddraw, surface_desc.dwWidth, surface_desc.dwHeight,
             U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount, 0, 0);
-    ok(SUCCEEDED(hr), "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetDisplayMode failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &s);
     ok(EqualRect(&r, &s) || broken(EqualRect(&q, &s) /* Windows 10 */),
             "Expected %s, got %s.\n", wine_dbgstr_rect(&r), wine_dbgstr_rect(&s));
 
     ref = IDirectDraw7_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     DestroyWindow(window);
 }
@@ -2962,10 +2962,10 @@ static void test_coop_level_mode_set(void)
     memset(&devmode, 0, sizeof(devmode));
     devmode.dmSize = sizeof(devmode);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
 
     ret = save_display_modes(&original_modes, &display_count);
@@ -2976,9 +2976,9 @@ static void test_coop_level_mode_set(void)
 
     memset(&param, 0, sizeof(param));
     hr = IDirectDraw7_EnumDisplayModes(ddraw, 0, NULL, &param, test_coop_level_mode_set_enum_cb);
-    ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#lx.\n", hr);
     ref = IDirectDraw7_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     if (!param.user32_height)
     {
@@ -2997,7 +2997,7 @@ static void test_coop_level_mode_set(void)
     devmode.dmPelsWidth = param.user32_width;
     devmode.dmPelsHeight = param.user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
@@ -3015,7 +3015,7 @@ static void test_coop_level_mode_set(void)
             0, 0, 100, 100, 0, 0, 0, 0);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &user32_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&user32_rect),
@@ -3027,12 +3027,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.user32_width, "Expected surface width %lu, got %lu.\n",
             param.user32_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.user32_height, "Expected surface height %lu, got %lu.\n",
             param.user32_height, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3045,16 +3045,16 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     ok(screen_size.cx == param.ddraw_width && screen_size.cy == param.ddraw_height,
-            "Expected screen size %ux%u, got %ux%u.\n",
+            "Expected screen size %lux%lu, got %lux%lu.\n",
             param.ddraw_width, param.ddraw_height, screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
@@ -3062,10 +3062,10 @@ static void test_coop_level_mode_set(void)
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.user32_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.user32_width, "Expected surface width %lu, got %lu.\n",
             param.user32_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.user32_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.user32_height, "Expected surface height %lu, got %lu.\n",
             param.user32_height, ddsd.dwHeight);
     IDirectDrawSurface7_Release(primary);
 
@@ -3075,12 +3075,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3093,16 +3093,16 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     ok(screen_size.cx == param.user32_width && screen_size.cy == param.user32_height,
-            "Expected screen size %ux%u, got %ux%u.\n",
+            "Expected screen size %lux%lu, got %lux%lu.\n",
             param.user32_width, param.user32_height, screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
@@ -3121,7 +3121,7 @@ static void test_coop_level_mode_set(void)
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
-            && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected screen size %ux%u.\n",
+            && devmode.dmPelsHeight == registry_mode.dmPelsHeight, "Got unexpected screen size %lux%lu.\n",
             devmode.dmPelsWidth, devmode.dmPelsHeight);
 
     expect_messages = exclusive_focus_restore_messages;
@@ -3134,11 +3134,11 @@ static void test_coop_level_mode_set(void)
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == param.ddraw_width
-            && devmode.dmPelsHeight == param.ddraw_height, "Got unexpected screen size %ux%u.\n",
+            && devmode.dmPelsHeight == param.ddraw_height, "Got unexpected screen size %lux%lu.\n",
             devmode.dmPelsWidth, devmode.dmPelsHeight);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     /* Normally the primary should be restored here. Unfortunately this causes the
      * GetSurfaceDesc call after the next display mode change to crash on the Windows 8
      * testbot. Another Restore call would presumably avoid the crash, but it also moots
@@ -3160,7 +3160,7 @@ static void test_coop_level_mode_set(void)
     expect_messages = NULL;
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
     expect_messages = exclusive_messages;
@@ -3168,17 +3168,17 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     ok(screen_size.cx == registry_mode.dmPelsWidth
             && screen_size.cy == registry_mode.dmPelsHeight,
-            "Expected screen size %ux%u, got %ux%u.\n",
+            "Expected screen size %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
@@ -3186,16 +3186,16 @@ static void test_coop_level_mode_set(void)
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
     IDirectDrawSurface7_Release(primary);
 
     /* For Wine. */
     change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -3203,12 +3203,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3216,17 +3216,17 @@ static void test_coop_level_mode_set(void)
             wine_dbgstr_rect(&r));
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface7_Release(primary);
 
@@ -3236,12 +3236,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3254,18 +3254,18 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
     devmode.dmPelsWidth = param.user32_width;
     devmode.dmPelsHeight = param.user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
     hr = IDirectDrawSurface7_IsLost(primary);
-    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
@@ -3277,27 +3277,27 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface7_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface7_Release(primary);
 
@@ -3307,12 +3307,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3325,25 +3325,25 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
     IDirectDrawSurface7_Release(primary);
 
@@ -3351,11 +3351,11 @@ static void test_coop_level_mode_set(void)
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
             && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n",
+            "Expected resolution %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
             devmode.dmPelsWidth, devmode.dmPelsHeight);
     change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -3363,12 +3363,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3379,17 +3379,17 @@ static void test_coop_level_mode_set(void)
      * Resizing the window on mode changes is a property of DDSCL_EXCLUSIVE,
      * not DDSCL_FULLSCREEN. */
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface7_Release(primary);
 
@@ -3399,12 +3399,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3417,18 +3417,18 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
     devmode.dmPelsWidth = param.user32_width;
     devmode.dmPelsHeight = param.user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
     hr = IDirectDrawSurface7_IsLost(primary);
-    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
@@ -3440,27 +3440,27 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface7_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface7_Release(primary);
 
@@ -3470,12 +3470,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
 
     GetWindowRect(window, &r);
@@ -3488,25 +3488,25 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n", screen_size.cx, screen_size.cy);
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n", screen_size.cx, screen_size.cy);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &registry_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&registry_rect),
             wine_dbgstr_rect(&r));
 
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
     IDirectDrawSurface7_Release(primary);
 
@@ -3514,11 +3514,11 @@ static void test_coop_level_mode_set(void)
     ok(ret, "Failed to get display mode.\n");
     ok(devmode.dmPelsWidth == registry_mode.dmPelsWidth
             && devmode.dmPelsHeight == registry_mode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n",
+            "Expected resolution %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
             devmode.dmPelsWidth, devmode.dmPelsHeight);
     change_ret = ChangeDisplaySettingsW(NULL, CDS_FULLSCREEN);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#x.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "Failed to change display mode, ret %#lx.\n", change_ret);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -3526,12 +3526,12 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface7_Release(primary);
 
@@ -3541,9 +3541,9 @@ static void test_coop_level_mode_set(void)
 
     /* Changing the coop level from EXCLUSIVE to NORMAL restores the screen resolution */
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
     expect_messages = exclusive_messages;
@@ -3551,13 +3551,13 @@ static void test_coop_level_mode_set(void)
     screen_size.cy = 0;
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
     ok(screen_size.cx == registry_mode.dmPelsWidth
             && screen_size.cy == registry_mode.dmPelsHeight,
-            "Expected screen size %ux%u, got %ux%u.\n",
+            "Expected screen size %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight,
             screen_size.cx, screen_size.cy);
 
@@ -3571,23 +3571,23 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface7_Release(primary);
 
     /* The screen restore is a property of DDSCL_EXCLUSIVE  */
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -3595,23 +3595,23 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == param.ddraw_width, "Expected surface width %lu, got %lu.\n",
             param.ddraw_width, ddsd.dwWidth);
-    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == param.ddraw_height, "Expected surface height %lu, got %lu.\n",
             param.ddraw_height, ddsd.dwHeight);
     IDirectDrawSurface7_Release(primary);
 
     hr = IDirectDraw7_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     /* If the window is changed at the same time, messages are sent to the new window. */
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
     expect_messages = exclusive_messages;
@@ -3621,14 +3621,14 @@ static void test_coop_level_mode_set(void)
     screen_size2.cy = 0;
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     ok(!expect_messages->message, "Expected message %#x, but didn't receive it.\n", expect_messages->message);
     expect_messages = NULL;
-    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %ux%u.\n",
+    ok(!screen_size.cx && !screen_size.cy, "Got unexpected screen size %lux%lu.\n",
             screen_size.cx, screen_size.cy);
     ok(screen_size2.cx == registry_mode.dmPelsWidth && screen_size2.cy == registry_mode.dmPelsHeight,
-            "Expected screen size 2 %ux%u, got %ux%u.\n",
+            "Expected screen size 2 %lux%lu, got %lux%lu.\n",
             registry_mode.dmPelsWidth, registry_mode.dmPelsHeight, screen_size2.cx, screen_size2.cy);
 
     GetWindowRect(window, &r);
@@ -3644,17 +3644,17 @@ static void test_coop_level_mode_set(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %u, got %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == registry_mode.dmPelsWidth, "Expected surface width %lu, got %lu.\n",
             registry_mode.dmPelsWidth, ddsd.dwWidth);
-    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %u, got %u.\n",
+    ok(ddsd.dwHeight == registry_mode.dmPelsHeight, "Expected surface height %lu, got %lu.\n",
             registry_mode.dmPelsHeight, ddsd.dwHeight);
     IDirectDrawSurface7_Release(primary);
 
     ref = IDirectDraw7_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     GetWindowRect(window, &r);
     ok(EqualRect(&r, &ddraw_rect), "Expected %s, got %s.\n", wine_dbgstr_rect(&ddraw_rect),
@@ -3668,36 +3668,36 @@ static void test_coop_level_mode_set(void)
     devmode.dmPelsWidth = param.user32_width;
     devmode.dmPelsHeight = param.user32_height;
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     ref = IDirectDraw7_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     memset(&devmode2, 0, sizeof(devmode2));
     devmode2.dmSize = sizeof(devmode2);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &registry_mode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
 
     /* Test that no mode restorations if no mode changes happened with fullscreen ddraw objects */
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     ref = IDirectDraw7_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &registry_mode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -3707,19 +3707,19 @@ static void test_coop_level_mode_set(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw, registry_mode.dmPelsWidth, registry_mode.dmPelsHeight);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     ref = IDirectDraw7_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -3728,23 +3728,23 @@ static void test_coop_level_mode_set(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw, param.ddraw_width, param.ddraw_height);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsW(&devmode, CDS_UPDATEREGISTRY | CDS_NORESET);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsW failed with %ld.\n", change_ret);
 
     hr = IDirectDraw7_RestoreDisplayMode(ddraw);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &devmode), "Got a different mode.\n");
 
     ref = IDirectDraw7_Release(ddraw);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     expect_messages = NULL;
     DestroyWindow(window);
@@ -3772,10 +3772,10 @@ static void test_coop_level_mode_set_multi(void)
     memset(&devmode, 0, sizeof(devmode));
     devmode.dmSize = sizeof(devmode);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(NULL, ENUM_REGISTRY_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode, &registry_mode), "Got a different mode.\n");
 
     ret = save_display_modes(&original_modes, &display_count);
@@ -3789,14 +3789,14 @@ static void test_coop_level_mode_set_multi(void)
     /* With just a single ddraw object, the display mode is restored on
      * release. */
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 600, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw7_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3806,7 +3806,7 @@ static void test_coop_level_mode_set_multi(void)
      * the initial mode, before the first SetDisplayMode() call. */
     ddraw1 = create_ddraw();
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3814,21 +3814,21 @@ static void test_coop_level_mode_set_multi(void)
 
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw7_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw7_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3837,7 +3837,7 @@ static void test_coop_level_mode_set_multi(void)
     /* Regardless of release ordering. */
     ddraw1 = create_ddraw();
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3845,21 +3845,21 @@ static void test_coop_level_mode_set_multi(void)
 
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw7_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw7_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3869,21 +3869,21 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw7_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw7_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3893,7 +3893,7 @@ static void test_coop_level_mode_set_multi(void)
      * restoring the display mode. */
     ddraw1 = create_ddraw();
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3901,24 +3901,24 @@ static void test_coop_level_mode_set_multi(void)
 
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw2, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     ref = IDirectDraw7_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 640, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 480, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw7_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3927,28 +3927,28 @@ static void test_coop_level_mode_set_multi(void)
     /* Exclusive mode blocks mode setting on other ddraw objects in general. */
     ddraw1 = create_ddraw();
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == 800, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == 600, "Got unexpected screen height %u.\n", h);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw1, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     ddraw2 = create_ddraw();
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
 
     ref = IDirectDraw7_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
     ok(h == registry_mode.dmPelsHeight, "Got unexpected screen height %u.\n", h);
 
     ref = IDirectDraw7_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     w = GetSystemMetrics(SM_CXSCREEN);
     ok(w == registry_mode.dmPelsWidth, "Got unexpected screen width %u.\n", w);
     h = GetSystemMetrics(SM_CYSCREEN);
@@ -3976,7 +3976,7 @@ static void test_coop_level_mode_set_multi(void)
     memset(&old_devmode, 0, sizeof(old_devmode));
     old_devmode.dmSize = sizeof(old_devmode);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &old_devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
 
     devmode = old_devmode;
     while (EnumDisplaySettingsW(second_monitor_name, mode_idx++, &devmode))
@@ -3993,32 +3993,32 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ok(!!ddraw1, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw1, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     memset(&devmode2, 0, sizeof(devmode2));
     devmode2.dmSize = sizeof(devmode2);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     if (compare_mode_rect(&devmode2, &old_devmode))
     {
         skip("Failed to change display settings of the second monitor.\n");
         ref = IDirectDraw7_Release(ddraw1);
-        ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+        ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
         goto done;
     }
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw1, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     ref = IDirectDraw7_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     memset(&devmode3, 0, sizeof(devmode3));
     devmode3.dmSize = sizeof(devmode3);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode3);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode3, &devmode2), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -4028,19 +4028,19 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ok(!!ddraw1, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     ref = IDirectDraw7_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -4049,23 +4049,23 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ok(!!ddraw1, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     hr = IDirectDraw7_RestoreDisplayMode(ddraw1);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
 
     ref = IDirectDraw7_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
 
@@ -4073,24 +4073,24 @@ static void test_coop_level_mode_set_multi(void)
     ddraw1 = create_ddraw();
     ok(!!ddraw1, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL,
             CDS_UPDATEREGISTRY | CDS_NORESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     ref = IDirectDraw7_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
+            "Expected resolution %lux%lu, got %lux%lu.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
             devmode2.dmPelsWidth, devmode2.dmPelsHeight);
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(devmode2.dmPelsWidth == devmode.dmPelsWidth && devmode2.dmPelsHeight == devmode.dmPelsHeight,
-            "Expected resolution %ux%u, got %ux%u.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
+            "Expected resolution %lux%lu, got %lux%lu.\n", devmode.dmPelsWidth, devmode.dmPelsHeight,
             devmode2.dmPelsWidth, devmode2.dmPelsHeight);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
@@ -4102,27 +4102,27 @@ static void test_coop_level_mode_set_multi(void)
     ddraw2 = create_ddraw();
     ok(!!ddraw2, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     hr = IDirectDraw7_RestoreDisplayMode(ddraw2);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
 
     ref = IDirectDraw7_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     ref = IDirectDraw7_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
     ret = restore_display_modes(original_modes, display_count);
     ok(ret, "Failed to restore display modes.\n");
 
@@ -4133,25 +4133,25 @@ static void test_coop_level_mode_set_multi(void)
     ddraw2 = create_ddraw();
     ok(!!ddraw2, "Failed to create a ddraw object.\n");
     hr = set_display_mode(ddraw1, 800, 600);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw2, 640, 480);
-    ok(hr == DD_OK, "Failed to set display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set display mode, hr %#lx.\n", hr);
 
     change_ret = ChangeDisplaySettingsExW(second_monitor_name, &devmode, NULL, CDS_RESET, NULL);
-    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %d.\n", change_ret);
+    ok(change_ret == DISP_CHANGE_SUCCESSFUL, "ChangeDisplaySettingsExW failed with %ld.\n", change_ret);
 
     ref = IDirectDraw7_Release(ddraw2);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_CURRENT_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
     ret = EnumDisplaySettingsW(second_monitor_name, ENUM_REGISTRY_SETTINGS, &devmode2);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
     ok(compare_mode_rect(&devmode2, &old_devmode), "Got a different mode.\n");
 
     ref = IDirectDraw7_Release(ddraw1);
-    ok(ref == 0, "The ddraw object was not properly freed: refcount %u.\n", ref);
+    ok(ref == 0, "The ddraw object was not properly freed: refcount %lu.\n", ref);
 
 done:
     DestroyWindow(window);
@@ -4169,16 +4169,16 @@ static void test_initialize(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw7_Initialize(ddraw, NULL);
-    ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x.\n", hr);
+    ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#lx.\n", hr);
     IDirectDraw7_Release(ddraw);
 
     CoInitialize(NULL);
     hr = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to create IDirectDraw7 instance, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create IDirectDraw7 instance, hr %#lx.\n", hr);
     hr = IDirectDraw7_Initialize(ddraw, NULL);
-    ok(hr == DD_OK, "Initialize returned hr %#x, expected DD_OK.\n", hr);
+    ok(hr == DD_OK, "Initialize returned hr %#lx, expected DD_OK.\n", hr);
     hr = IDirectDraw7_Initialize(ddraw, NULL);
-    ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#x, expected DDERR_ALREADYINITIALIZED.\n", hr);
+    ok(hr == DDERR_ALREADYINITIALIZED, "Initialize returned hr %#lx, expected DDERR_ALREADYINITIALIZED.\n", hr);
     IDirectDraw7_Release(ddraw);
     CoUninitialize();
 }
@@ -4199,20 +4199,20 @@ static void test_coop_level_surf_create(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     surface = (void *)0xdeadbeef;
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "Surface creation returned hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "Surface creation returned hr %#lx.\n", hr);
     ok(surface == (void *)0xdeadbeef, "Got unexpected surface %p.\n", surface);
 
     surface = (void *)0xdeadbeef;
     hr = IDirectDraw7_CreateSurface(ddraw, NULL, &surface, NULL);
-    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "Surface creation returned hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "Surface creation returned hr %#lx.\n", hr);
     ok(surface == (void *)0xdeadbeef, "Got unexpected surface %p.\n", surface);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     surface = (void *)0xdeadbeef;
     hr = IDirectDraw7_CreateSurface(ddraw, NULL, &surface, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Unexpected hr %#lx.\n", hr);
     ok(surface == (void *)0xdeadbeef, "Got unexpected surface %p.\n", surface);
 
     IDirectDraw7_Release(ddraw);
@@ -4247,7 +4247,7 @@ static void test_vb_discard(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
 
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
@@ -4255,29 +4255,29 @@ static void test_vb_discard(void)
     desc.dwFVF = D3DFVF_XYZRHW;
     desc.dwNumVertices = vbsize;
     hr = IDirect3D7_CreateVertexBuffer(d3d, &desc, &buffer, 0);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(buffer, DDLOCK_DISCARDCONTENTS, (void **)&data, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     memcpy(data, quad, sizeof(quad));
     hr = IDirect3DVertexBuffer7_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, buffer, 0, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(buffer, DDLOCK_DISCARDCONTENTS, (void **)&data, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     memset(data, 0xaa, sizeof(struct vec4) * vbsize);
     hr = IDirect3DVertexBuffer7_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(buffer, DDLOCK_DISCARDCONTENTS, (void **)&data, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     for (i = 0; i < sizeof(struct vec4) * vbsize; i++)
     {
         if (data[i] != 0xaa)
@@ -4287,7 +4287,7 @@ static void test_vb_discard(void)
         }
     }
     hr = IDirect3DVertexBuffer7_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     IDirect3DVertexBuffer7_Release(buffer);
     IDirect3D7_Release(d3d);
@@ -4307,9 +4307,9 @@ static void test_coop_level_multi_window(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(IsWindow(window1), "Window 1 was destroyed.\n");
     ok(IsWindow(window2), "Window 2 was destroyed.\n");
 
@@ -4352,14 +4352,14 @@ static void test_draw_strided(void)
     }
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00000000, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     memset(&strided, 0x55, sizeof(strided));
     strided.position.lpvData = position;
@@ -4368,13 +4368,13 @@ static void test_draw_strided(void)
     strided.diffuse.dwStride = sizeof(*diffuse);
     hr = IDirect3DDevice7_DrawIndexedPrimitiveStrided(device, D3DPT_TRIANGLELIST, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             &strided, 4, indices, 6, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface7_Release(rt);
     IDirect3DDevice7_Release(device);
@@ -4520,190 +4520,190 @@ static void test_lighting(void)
         return;
     }
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     is_warp = ddraw_is_warp(ddraw);
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_STENCILENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = fvf;
     vb_desc.dwNumVertices = 2;
     hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &src_vb1, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = nfvf;
     vb_desc.dwNumVertices = 2;
     hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &src_vb2, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR;
     vb_desc.dwNumVertices = 4;
     hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &dst_vb, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(src_vb1, 0, (void **)&src_data1, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(src_data1, unlitquad, sizeof(*src_data1));
     memcpy(&src_data1[1], litquad, sizeof(*src_data1));
     hr = IDirect3DVertexBuffer7_Unlock(src_vb1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(src_vb2, 0, (void **)&src_data2, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(src_data2, unlitnquad, sizeof(*src_data2));
     memcpy(&src_data2[1], litnquad, sizeof(*src_data2));
     hr = IDirect3DVertexBuffer7_Unlock(src_vb2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* No lights are defined... That means, lit vertices should be entirely black. */
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 0,
             1, src_vb1, 0, device, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, fvf, unlitquad, 4,
             indices, 6, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 1,
             1, src_vb1, 1, device, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, fvf, litquad, 4,
             indices, 6, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb, D3DVOP_TRANSFORM, 2,
             1, src_vb2, 0, device, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, unlitnquad, 4,
             indices, 6, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 3,
             1, src_vb2, 1, device, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, litnquad, 4,
             indices, 6, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(dst_vb, 0, (void **)&dst_data, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 360);
-    ok(color == 0x00ff0000, "Unlit quad without normals has color 0x%08x, expected 0x00ff0000.\n", color);
+    ok(color == 0x00ff0000, "Unlit quad without normals has color 0x%08lx, expected 0x00ff0000.\n", color);
     ok(dst_data[0].diffuse == 0xffff0000,
-            "Unlit quad without normals has color 0x%08x, expected 0xffff0000.\n", dst_data[0].diffuse);
+            "Unlit quad without normals has color 0x%08lx, expected 0xffff0000.\n", dst_data[0].diffuse);
     ok(!dst_data[0].specular,
-            "Unexpected specular color 0x%08x.\n", dst_data[0].specular);
+            "Unexpected specular color 0x%08lx.\n", dst_data[0].specular);
     color = get_surface_color(rt, 160, 120);
     /* Broken on some of WARP drivers. */
     ok(color == 0x00000000 || broken(is_warp && (color == 0x000000ff || color == 0x00ff00ff)),
-            "Lit quad without normals has color 0x%08x, expected 0x00000000.\n", color);
+            "Lit quad without normals has color 0x%08lx, expected 0x00000000.\n", color);
     ok(dst_data[1].diffuse == 0xff000000,
-            "Lit quad without normals has color 0x%08x, expected 0xff000000.\n", dst_data[1].diffuse);
+            "Lit quad without normals has color 0x%08lx, expected 0xff000000.\n", dst_data[1].diffuse);
     ok(!dst_data[1].specular,
-            "Unexpected specular color 0x%08x.\n", dst_data[1].specular);
+            "Unexpected specular color 0x%08lx.\n", dst_data[1].specular);
     color = get_surface_color(rt, 480, 360);
-    ok(color == 0x000000ff, "Unlit quad with normals has color 0x%08x, expected 0x000000ff.\n", color);
+    ok(color == 0x000000ff, "Unlit quad with normals has color 0x%08lx, expected 0x000000ff.\n", color);
     ok(dst_data[2].diffuse == 0xff0000ff,
-            "Unlit quad with normals has color 0x%08x, expected 0xff0000ff.\n", dst_data[2].diffuse);
+            "Unlit quad with normals has color 0x%08lx, expected 0xff0000ff.\n", dst_data[2].diffuse);
     ok(!dst_data[2].specular,
-            "Unexpected specular color 0x%08x.\n", dst_data[2].specular);
+            "Unexpected specular color 0x%08lx.\n", dst_data[2].specular);
     color = get_surface_color(rt, 480, 120);
     ok(color == 0x00000000 || broken(is_warp && (color == 0x000000ff || color == 0x00ff00ff)),
-            "Lit quad with normals has color 0x%08x, expected 0x00000000.\n", color);
+            "Lit quad with normals has color 0x%08lx, expected 0x00000000.\n", color);
     ok(dst_data[3].diffuse == 0xff000000,
-            "Lit quad with normals has color 0x%08x, expected 0xff000000.\n", dst_data[3].diffuse);
+            "Lit quad with normals has color 0x%08lx, expected 0xff000000.\n", dst_data[3].diffuse);
     ok(!dst_data[3].specular,
-            "Unexpected specular color 0x%08x.\n", dst_data[3].specular);
+            "Unexpected specular color 0x%08lx.\n", dst_data[3].specular);
 
     hr = IDirect3DVertexBuffer7_Unlock(dst_vb);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_LightEnable(device, 0, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DVertexBuffer7_Lock(src_vb2, 0, (void **)&src_data2, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         memcpy(src_data2, tests[i].quad, sizeof(*src_data2));
         hr = IDirect3DVertexBuffer7_Unlock(src_vb2);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, tests[i].world_matrix);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 0,
                 1, src_vb2, 0, device, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, tests[i].quad,
                 4, indices, 6, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DVertexBuffer7_Lock(dst_vb, 0, (void **)&dst_data, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         color = get_surface_color(rt, 320, 240);
         ok(color == tests[i].expected || broken(is_warp && (color == 0x000000ff || color == 0x00ff00ff)),
-                "%s has color 0x%08x.\n", tests[i].message, color);
+                "%s has color 0x%08lx.\n", tests[i].message, color);
         todo_wine_if(tests[i].process_vertices_todo)
         ok(dst_data[0].diffuse == tests[i].expected_process_vertices,
-                "%s has color 0x%08x.\n", tests[i].message, dst_data[0].diffuse);
+                "%s has color 0x%08lx.\n", tests[i].message, dst_data[0].diffuse);
         ok(!dst_data[0].specular,
-                "%s has specular color 0x%08x.\n", tests[i].message, dst_data[0].specular);
+                "%s has specular color 0x%08lx.\n", tests[i].message, dst_data[0].specular);
 
         hr = IDirect3DVertexBuffer7_Unlock(dst_vb);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     IDirect3DVertexBuffer7_Release(src_vb1);
@@ -4715,7 +4715,7 @@ static void test_lighting(void)
     IDirectDraw7_Release(ddraw);
     IDirect3D7_Release(d3d);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -5022,7 +5022,7 @@ static void test_specular_lighting(void)
         return;
     }
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     quad = heap_alloc(vertices_side * vertices_side * sizeof(*quad));
     indices = heap_alloc(indices_count * sizeof(*indices));
@@ -5052,52 +5052,52 @@ static void test_specular_lighting(void)
     }
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_LightEnable(device, 0, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SPECULARENABLE, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = fvf;
     vb_desc.dwNumVertices = ARRAY_SIZE(vertices);
     hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &src_vb, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer7_Lock(src_vb, 0, (void **)&src_data, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(src_data, vertices, sizeof(vertices));
     hr = IDirect3DVertexBuffer7_Unlock(src_vb);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR;
     vb_desc.dwNumVertices = ARRAY_SIZE(vertices);
     hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &dst_vb, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice7_SetLight(device, 0, tests[i].light);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LOCALVIEWER, tests[i].local_viewer);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         memset(&material, 0, sizeof(material));
         U1(U2(material).specular).r = 1.0f;
@@ -5106,52 +5106,52 @@ static void test_specular_lighting(void)
         U4(U2(material).specular).a = 0.5f;
         U4(material).power = tests[i].specular_power;
         hr = IDirect3DDevice7_SetMaterial(device, &material);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DVertexBuffer7_Lock(dst_vb, 0, (void **)&dst_data, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         memset(dst_data, 0, sizeof(*dst_data) * ARRAY_SIZE(vertices));
         hr = IDirect3DVertexBuffer7_Unlock(dst_vb);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 0,
                 ARRAY_SIZE(vertices), src_vb, 0, device, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, fvf, quad,
                 vertices_side * vertices_side, indices, indices_count, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DVertexBuffer7_Lock(dst_vb, 0, (void **)&dst_data, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         ok(tests[i].expected_count == ARRAY_SIZE(vertices), "Array size mismatch.\n");
         for (j = 0; j < tests[i].expected_count; ++j)
         {
             color = get_surface_color(rt, tests[i].expected[j].x, tests[i].expected[j].y);
             ok(compare_color(color, tests[i].expected[j].color, 1),
-                    "Expected color 0x%08x at location (%u, %u), got 0x%08x, case %u.\n",
+                    "Expected color 0x%08lx at location (%u, %u), got 0x%08lx, case %u.\n",
                     tests[i].expected[j].color, tests[i].expected[j].x,
                     tests[i].expected[j].y, color, i);
-            ok(!dst_data[j].diffuse, "Expected color 0x00000000 for vertex %u, got 0x%08x, case %u.\n",
+            ok(!dst_data[j].diffuse, "Expected color 0x00000000 for vertex %u, got 0x%08lx, case %u.\n",
                     j, dst_data[j].diffuse, i);
             expected_color = tests[i].expected_process_vertices[j].color | 0x80000000;
             todo_wine_if(tests[i].todo_process_vertices && dst_data[j].specular != expected_color)
             ok(compare_color(dst_data[j].specular, expected_color, 1),
-                    "Expected color 0x%08x for vertex %u, got 0x%08x, case %u.\n",
+                    "Expected color 0x%08lx for vertex %u, got 0x%08lx, case %u.\n",
                     expected_color, j, dst_data[j].specular, i);
         }
         hr = IDirect3DVertexBuffer7_Unlock(dst_vb);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     IDirect3DVertexBuffer7_Release(dst_vb);
@@ -5160,7 +5160,7 @@ static void test_specular_lighting(void)
 
     IDirect3D7_Release(d3d);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
     heap_free(indices);
     heap_free(quad);
@@ -5184,25 +5184,25 @@ static void test_clear_rect_count(void)
     }
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ffffff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_Clear(device, 0, &rect, D3DCLEAR_TARGET, 0x00ff0000, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 320, 240);
     ok(compare_color(color, 0x00ffffff, 1) || broken(compare_color(color, 0x00ff0000, 1)),
-            "Clear with count = 0, rect != NULL has color %#08x.\n", color);
+            "Clear with count = 0, rect != NULL has color %#08lx.\n", color);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ffffff, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_Clear(device, 1, NULL, D3DCLEAR_TARGET, 0x0000ff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 320, 240);
     ok(compare_color(color, 0x0000ff00, 1),
-            "Clear with count = 1, rect = NULL has color %#08x.\n", color);
+            "Clear with count = 1, rect = NULL has color %#08lx.\n", color);
 
     IDirectDrawSurface7_Release(rt);
     IDirect3DDevice7_Release(device);
@@ -5217,21 +5217,21 @@ static BOOL test_mode_restored(IDirectDraw7 *ddraw, HWND window)
     memset(&ddsd1, 0, sizeof(ddsd1));
     ddsd1.dwSize = sizeof(ddsd1);
     hr = IDirectDraw7_GetDisplayMode(ddraw, &ddsd1);
-    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = set_display_mode(ddraw, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     memset(&ddsd2, 0, sizeof(ddsd2));
     ddsd2.dwSize = sizeof(ddsd2);
     hr = IDirectDraw7_GetDisplayMode(ddraw, &ddsd2);
-    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDraw7_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#lx.\n", hr);
 
     return ddsd1.dwWidth == ddsd2.dwWidth && ddsd1.dwHeight == ddsd2.dwHeight;
 }
@@ -5255,16 +5255,16 @@ static void test_coop_level_versions(void)
 
     /* A failing ddraw1::SetCooperativeLevel call does not have an effect */
     hr = IDirectDraw7_QueryInterface(ddraw7, &IID_IDirectDraw, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(FAILED(hr), "SetCooperativeLevel returned %#x, expected failure.\n", hr);
+    ok(FAILED(hr), "SetCooperativeLevel returned %#lx, expected failure.\n", hr);
     restored = test_mode_restored(ddraw7, window);
     ok(restored, "Display mode not restored after bad ddraw1::SetCooperativeLevel call\n");
 
     /* A successful one does */
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     restored = test_mode_restored(ddraw7, window);
     ok(!restored, "Display mode restored after good ddraw1::SetCooperativeLevel call\n");
 
@@ -5274,10 +5274,10 @@ static void test_coop_level_versions(void)
     ddraw7 = create_ddraw();
     ok(!!ddraw7, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_QueryInterface(ddraw7, &IID_IDirectDraw, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_SETFOCUSWINDOW);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     restored = test_mode_restored(ddraw7, window);
     ok(!restored, "Display mode restored after ddraw1::SetCooperativeLevel(SETFOCUSWINDOW) call\n");
 
@@ -5288,12 +5288,12 @@ static void test_coop_level_versions(void)
     ddraw7 = create_ddraw();
     ok(!!ddraw7, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_QueryInterface(ddraw7, &IID_IDirectDraw, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(FAILED(hr), "SetCooperativeLevel returned %#x, expected failure.\n", hr);
+    ok(FAILED(hr), "SetCooperativeLevel returned %#lx, expected failure.\n", hr);
     restored = test_mode_restored(ddraw7, window);
     ok(!restored, "Display mode restored after good-bad ddraw1::SetCooperativeLevel() call sequence\n");
 
@@ -5304,14 +5304,14 @@ static void test_coop_level_versions(void)
     ddraw7 = create_ddraw();
     ok(!!ddraw7, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_QueryInterface(ddraw7, &IID_IDirectDraw, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw7, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw7, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     restored = test_mode_restored(ddraw7, window);
     ok(!restored, "Display mode restored after ddraw1-ddraw7 SetCooperativeLevel() call sequence\n");
@@ -5322,10 +5322,10 @@ static void test_coop_level_versions(void)
     ddraw7 = create_ddraw();
     ok(!!ddraw7, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_QueryInterface(ddraw7, &IID_IDirectDraw, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#lx.\n", hr);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw7, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -5333,7 +5333,7 @@ static void test_coop_level_versions(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     ddsd.dwWidth = ddsd.dwHeight = 8;
     hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "CreateSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateSurface failed, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface);
     restored = test_mode_restored(ddraw7, window);
     ok(restored, "Display mode not restored after ddraw1::CreateSurface() call\n");
@@ -5388,50 +5388,50 @@ static void test_fog_special(void)
     }
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable fog, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGCOLOR, 0xffff0000);
-    ok(SUCCEEDED(hr), "Failed to set fog color, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set fog color, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
 
     conv.f = 0.5f;
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGSTART, conv.d);
-    ok(SUCCEEDED(hr), "Failed to set fog start, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set fog start, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGEND, conv.d);
-    ok(SUCCEEDED(hr), "Failed to set fog end, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set fog end, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x000000ff, 1.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGVERTEXMODE, tests[i].vertexmode);
-        ok(SUCCEEDED(hr), "Failed to set fogvertexmode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set fogvertexmode, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, tests[i].tablemode);
-        ok(SUCCEEDED(hr), "Failed to set fogtablemode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set fogtablemode, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE, quad, 4, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = get_surface_color(rt, 310, 240);
         ok(compare_color(color, tests[i].color_left, 1),
-                "Expected left color 0x%08x, got 0x%08x, case %u.\n", tests[i].color_left, color, i);
+                "Expected left color 0x%08lx, got 0x%08lx, case %u.\n", tests[i].color_left, color, i);
         color = get_surface_color(rt, 330, 240);
         ok(compare_color(color, tests[i].color_right, 1),
-                "Expected right color 0x%08x, got 0x%08x, case %u.\n", tests[i].color_right, color, i);
+                "Expected right color 0x%08lx, got 0x%08lx, case %u.\n", tests[i].color_right, color, i);
     }
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(rt);
     IDirect3DDevice7_Release(device);
@@ -5581,55 +5581,55 @@ static void test_lighting_interface_versions(void)
     }
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     memset(&material, 0, sizeof(material));
     U2(U3(material).emissive).g = 1.0f;
     hr = IDirect3DDevice7_SetMaterial(device, &material);
-    ok(SUCCEEDED(hr), "Failed set material, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed set material, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable z test, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_LIGHTING, &rs);
-    ok(SUCCEEDED(hr), "Failed to get lighting render state, hr %#x.\n", hr);
-    ok(rs == TRUE, "Initial D3DRENDERSTATE_LIGHTING is %#x, expected TRUE.\n", rs);
+    ok(SUCCEEDED(hr), "Failed to get lighting render state, hr %#lx.\n", hr);
+    ok(rs == TRUE, "Initial D3DRENDERSTATE_LIGHTING is %#lx, expected TRUE.\n", rs);
     hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_SPECULARENABLE, &rs);
-    ok(SUCCEEDED(hr), "Failed to get specularenable render state, hr %#x.\n", hr);
-    ok(rs == FALSE, "Initial D3DRENDERSTATE_SPECULARENABLE is %#x, expected FALSE.\n", rs);
+    ok(SUCCEEDED(hr), "Failed to get specularenable render state, hr %#lx.\n", hr);
+    ok(rs == FALSE, "Initial D3DRENDERSTATE_SPECULARENABLE is %#lx, expected FALSE.\n", rs);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff202020, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, tests[i].d3drs_lighting);
-        ok(SUCCEEDED(hr), "Failed to set lighting render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set lighting render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SPECULARENABLE,
                 tests[i].d3drs_specular);
-        ok(SUCCEEDED(hr), "Failed to set specularenable render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set specularenable render state, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
                 tests[i].vertextype, tests[i].data, 4, tests[i].draw_flags | D3DDP_WAIT);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_LIGHTING, &rs);
-        ok(SUCCEEDED(hr), "Failed to get lighting render state, hr %#x.\n", hr);
-        ok(rs == tests[i].d3drs_lighting, "D3DRENDERSTATE_LIGHTING is %#x, expected %#x.\n",
+        ok(SUCCEEDED(hr), "Failed to get lighting render state, hr %#lx.\n", hr);
+        ok(rs == tests[i].d3drs_lighting, "D3DRENDERSTATE_LIGHTING is %#lx, expected %#lx.\n",
                 rs, tests[i].d3drs_lighting);
 
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, tests[i].color, 1),
-                "Got unexpected color 0x%08x, expected 0x%08x, test %u.\n",
+                "Got unexpected color 0x%08lx, expected 0x%08lx, test %u.\n",
                 color, tests[i].color, i);
     }
 
     IDirectDrawSurface7_Release(rt);
     ref = IDirect3DDevice7_Release(device);
-    ok(ref == 0, "Device not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Device not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -5651,7 +5651,7 @@ static LRESULT CALLBACK activateapp_test_proc(HWND hwnd, UINT message, WPARAM wp
             activateapp_testdata.received = FALSE;
             hr = IDirectDraw7_SetCooperativeLevel(activateapp_testdata.ddraw,
                     activateapp_testdata.window, activateapp_testdata.coop_level);
-            ok(SUCCEEDED(hr), "Recursive SetCooperativeLevel call failed, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Recursive SetCooperativeLevel call failed, hr %#lx.\n", hr);
             ok(!activateapp_testdata.received, "Received WM_ACTIVATEAPP during recursive SetCooperativeLevel call.\n");
         }
         activateapp_testdata.received = TRUE;
@@ -5683,31 +5683,31 @@ static void test_coop_level_activateapp(void)
     SetForegroundWindow(window);
     activateapp_testdata.received = FALSE;
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(!activateapp_testdata.received, "Received WM_ACTIVATEAPP although window was already active.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Exclusive with window not active. */
     SetForegroundWindow(GetDesktopWindow());
     activateapp_testdata.received = FALSE;
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(activateapp_testdata.received, "Expected WM_ACTIVATEAPP, but did not receive it.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Normal with window not active, then exclusive with the same window. */
     SetForegroundWindow(GetDesktopWindow());
     activateapp_testdata.received = FALSE;
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(!activateapp_testdata.received, "Received WM_ACTIVATEAPP when setting DDSCL_NORMAL.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(activateapp_testdata.received, "Expected WM_ACTIVATEAPP, but did not receive it.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Recursive set of DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN. */
     SetForegroundWindow(GetDesktopWindow());
@@ -5716,10 +5716,10 @@ static void test_coop_level_activateapp(void)
     activateapp_testdata.window = window;
     activateapp_testdata.coop_level = DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN;
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(activateapp_testdata.received, "Expected WM_ACTIVATEAPP, but did not receive it.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* The recursive call seems to have some bad effect on native ddraw, despite (apparently)
      * succeeding. Another switch to exclusive and back to normal is needed to release the
@@ -5727,9 +5727,9 @@ static void test_coop_level_activateapp(void)
      * WM_ACTIVATEAPP messages. */
     activateapp_testdata.ddraw = NULL;
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Setting DDSCL_NORMAL with recursive invocation. */
     SetForegroundWindow(GetDesktopWindow());
@@ -5738,7 +5738,7 @@ static void test_coop_level_activateapp(void)
     activateapp_testdata.window = window;
     activateapp_testdata.coop_level = DDSCL_NORMAL;
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     ok(activateapp_testdata.received, "Expected WM_ACTIVATEAPP, but did not receive it.\n");
 
     /* DDraw is in exclusive mode now. */
@@ -5748,15 +5748,15 @@ static void test_coop_level_activateapp(void)
     U5(ddsd).dwBackBufferCount = 1;
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     IDirectDrawSurface7_Release(surface);
 
     /* Recover again, just to be sure. */
     activateapp_testdata.ddraw = NULL;
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     DestroyWindow(window);
     UnregisterClassA("ddraw_test_wndproc_wc", GetModuleHandleA(NULL));
@@ -5818,14 +5818,14 @@ static void test_texturemanage(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     memset(&hel_caps, 0, sizeof(hel_caps));
     hel_caps.dwSize = sizeof(hel_caps);
     hr = IDirectDraw7_GetCaps(ddraw, &hal_caps, &hel_caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & needed_caps) != needed_caps)
     {
         skip("Managed textures not supported, skipping managed texture test.\n");
@@ -5845,22 +5845,22 @@ static void test_texturemanage(void)
 
         hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
         if (tests[i].hr == DD_OK && is_ddraw64 && (tests[i].caps_in & DDSCAPS_TEXTURE))
-            todo_wine ok(hr == E_NOINTERFACE, "Test %u: Got unexpected hr %#x.\n", i, hr);
+            todo_wine ok(hr == E_NOINTERFACE, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         else
-            ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, tests[i].hr);
+            ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, tests[i].hr);
         if (FAILED(hr))
             continue;
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd);
-        ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
 
         ok(ddsd.ddsCaps.dwCaps == tests[i].caps_out,
-                "Input caps %#x, %#x, expected output caps %#x, got %#x, case %u.\n",
+                "Input caps %#lx, %#lx, expected output caps %#lx, got %#lx, case %u.\n",
                 tests[i].caps_in, tests[i].caps2_in, tests[i].caps_out, ddsd.ddsCaps.dwCaps, i);
         ok(ddsd.ddsCaps.dwCaps2 == tests[i].caps2_out,
-                "Input caps %#x, %#x, expected output caps %#x, got %#x, case %u.\n",
+                "Input caps %#lx, %#lx, expected output caps %#lx, got %#lx, case %u.\n",
                 tests[i].caps_in, tests[i].caps2_in, tests[i].caps2_out, ddsd.ddsCaps.dwCaps2, i);
 
         IDirectDrawSurface7_Release(surface);
@@ -6020,23 +6020,23 @@ static void test_block_formats_creation(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **) &ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
 
     hr = IDirect3DDevice7_EnumTextureFormats(device, test_block_formats_creation_cb,
             &supported_fmts);
-    ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#lx.\n", hr);
 
     hr = IDirectDraw7_GetFourCCCodes(ddraw, &num_fourcc_codes, NULL);
-    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#lx.\n", hr);
     fourcc_codes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
             num_fourcc_codes * sizeof(*fourcc_codes));
     if (!fourcc_codes)
         goto cleanup;
     hr = IDirectDraw7_GetFourCCCodes(ddraw, &num_fourcc_codes, fourcc_codes);
-    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#lx.\n", hr);
     for (i = 0; i < num_fourcc_codes; i++)
     {
         for (j = 0; j < ARRAY_SIZE(formats); ++j)
@@ -6050,7 +6050,7 @@ static void test_block_formats_creation(void)
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw7_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
 
     mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 2 * 2 * 16 + 1);
 
@@ -6108,7 +6108,7 @@ static void test_block_formats_creation(void)
                     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
                     todo_wine_if (todo)
                         ok(hr == expect_hr,
-                                "Got unexpected hr %#x for format %s, resource type %s, size %ux%u, expected %#x.\n",
+                                "Got unexpected hr %#lx for format %s, resource type %s, size %ux%u, expected %#lx.\n",
                                 hr, formats[i].name, types[j].name, w, h, expect_hr);
 
                     if (SUCCEEDED(hr))
@@ -6151,7 +6151,7 @@ static void test_block_formats_creation(void)
             ddsd.dwHeight = 8;
 
             hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
-            ok(hr == user_mem_tests[j].hr, "Test %u: Got unexpected hr %#x, format %s.\n", j, hr, formats[i].name);
+            ok(hr == user_mem_tests[j].hr, "Test %u: Got unexpected hr %#lx, format %s.\n", j, hr, formats[i].name);
 
             if (FAILED(hr))
                 continue;
@@ -6159,15 +6159,15 @@ static void test_block_formats_creation(void)
             memset(&ddsd, 0, sizeof(ddsd));
             ddsd.dwSize = sizeof(ddsd);
             hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd);
-            ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", j, hr);
+            ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#lx.\n", j, hr);
             ok(ddsd.dwFlags == (DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_LINEARSIZE),
-                    "Test %u: Got unexpected flags %#x.\n", j, ddsd.dwFlags);
+                    "Test %u: Got unexpected flags %#lx.\n", j, ddsd.dwFlags);
             if (user_mem_tests[j].flags & DDSD_LPSURFACE)
-                ok(U1(ddsd).dwLinearSize == ~0u, "Test %u: Got unexpected linear size %#x.\n",
+                ok(U1(ddsd).dwLinearSize == ~0u, "Test %u: Got unexpected linear size %#lx.\n",
                         j, U1(ddsd).dwLinearSize);
             else
                 ok(U1(ddsd).dwLinearSize == 2 * 2 * formats[i].block_size,
-                        "Test %u: Got unexpected linear size %#x, expected %#x.\n",
+                        "Test %u: Got unexpected linear size %#lx, expected %#x.\n",
                         j, U1(ddsd).dwLinearSize, 2 * 2 * formats[i].block_size);
             IDirectDrawSurface7_Release(surface);
         }
@@ -6244,16 +6244,16 @@ static void test_unsupported_formats(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **) &ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
 
     for (i = 0; i < ARRAY_SIZE(formats); ++i)
     {
         struct format_support_check check = {&formats[i].fmt, FALSE};
         hr = IDirect3DDevice7_EnumTextureFormats(device, test_unsupported_formats_cb, &check);
-        ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to enumerate texture formats %#lx.\n", hr);
 
         for (j = 0; j < ARRAY_SIZE(caps); ++j)
         {
@@ -6272,7 +6272,7 @@ static void test_unsupported_formats(void)
 
             hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
             ok(SUCCEEDED(hr) == expect_success,
-                    "Got unexpected hr %#x for format %s, caps %#x, expected %s.\n",
+                    "Got unexpected hr %#lx for format %s, caps %#lx, expected %s.\n",
                     hr, formats[i].name, caps[j], expect_success ? "success" : "failure");
             if (FAILED(hr))
                 continue;
@@ -6280,7 +6280,7 @@ static void test_unsupported_formats(void)
             memset(&ddsd, 0, sizeof(ddsd));
             ddsd.dwSize = sizeof(ddsd);
             hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd);
-            ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
 
             if (caps[j] & DDSCAPS_VIDEOMEMORY)
                 expected_caps = DDSCAPS_VIDEOMEMORY;
@@ -6292,7 +6292,7 @@ static void test_unsupported_formats(void)
                 expected_caps = DDSCAPS_SYSTEMMEMORY;
 
             ok(ddsd.ddsCaps.dwCaps & expected_caps,
-                    "Expected capability %#x, format %s, input cap %#x.\n",
+                    "Expected capability %#lx, format %s, input cap %#lx.\n",
                     expected_caps, formats[i].name, caps[j]);
 
             IDirectDrawSurface7_Release(surface);
@@ -6518,7 +6518,7 @@ static void test_rt_caps(const GUID *device_guid)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     if (FAILED(IDirectDraw7_QueryInterface(ddraw, &IID_IDirect3D7, (void **)&d3d)))
     {
@@ -6537,12 +6537,12 @@ static void test_rt_caps(const GUID *device_guid)
 
     memset(palette_entries, 0, sizeof(palette_entries));
     hr = IDirectDraw7_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, palette_entries, &palette, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw7_GetCaps(ddraw, &hal_caps, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
@@ -6574,14 +6574,14 @@ static void test_rt_caps(const GUID *device_guid)
         ok(hr == expected_hr || (software_device && (surface_desc.ddsCaps.dwCaps & (DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER))
                 == (DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER) && hr == DDERR_UNSUPPORTED)
                 || broken(software_device && test_data[i].pf == &p8_fmt && hr == DDERR_INVALIDPIXELFORMAT),
-                "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+                "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
         if (FAILED(hr))
             continue;
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
-        ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+        ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
 
         if ((caps_in & DDSCAPS_SYSTEMMEMORY) || (test_data[i].caps2_in & (DDSCAPS2_D3DTEXTUREMANAGE
                 | DDSCAPS2_TEXTUREMANAGE)) || !(hal_caps.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
@@ -6593,34 +6593,34 @@ static void test_rt_caps(const GUID *device_guid)
                 && surface_desc.ddsCaps.dwCaps == (caps_in | DDSCAPS_SYSTEMMEMORY))
                 || (software_device && test_data[i].pf == &z_fmt
                 && surface_desc.ddsCaps.dwCaps == (caps_in | DDSCAPS_SYSTEMMEMORY)),
-                "Got unexpected caps %#x, expected %#x, test %u, software_device %u.\n",
+                "Got unexpected caps %#lx, expected %#lx, test %u, software_device %u.\n",
                 surface_desc.ddsCaps.dwCaps, expected_caps, i, software_device);
 
         ok(surface_desc.ddsCaps.dwCaps2 == test_data[i].caps2_in,
-                "Got unexpected caps2 %#x, expected %#x, test %u, software_device %u.\n",
+                "Got unexpected caps2 %#lx, expected %#lx, test %u, software_device %u.\n",
                 surface_desc.ddsCaps.dwCaps2, test_data[i].caps2_in, i, software_device);
 
         hr = IDirect3D7_CreateDevice(d3d, device_guid, surface, &device);
         ok((!software_device && hr == test_data[i].create_device_hr)
                 || (software_device && (hr == (test_data[i].create_device_hr == D3DERR_SURFACENOTINVIDMEM
                 ? DD_OK : test_data[i].create_device_hr))),
-                "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+                "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
         if (FAILED(hr))
         {
             if (hr == DDERR_NOPALETTEATTACHED)
             {
                 hr = IDirectDrawSurface7_SetPalette(surface, palette);
-                ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+                ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
                 hr = IDirect3D7_CreateDevice(d3d, device_guid, surface, &device);
                 if (surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)
-                    ok(hr == DDERR_INVALIDPIXELFORMAT, "Got unexpected hr %#x, test %u, software_device %u.\n",
+                    ok(hr == DDERR_INVALIDPIXELFORMAT, "Got unexpected hr %#lx, test %u, software_device %u.\n",
                             hr, i, software_device);
                 else if (software_device)
                     todo_wine
-                    ok(hr == E_FAIL, "Got unexpected hr %#x, test %u, software_device %u.\n",
+                    ok(hr == E_FAIL, "Got unexpected hr %#lx, test %u, software_device %u.\n",
                             hr, i, software_device);
                 else
-                    ok(hr == D3DERR_SURFACENOTINVIDMEM, "Got unexpected hr %#x, test %u, software_device %u.\n",
+                    ok(hr == D3DERR_SURFACENOTINVIDMEM, "Got unexpected hr %#lx, test %u, software_device %u.\n",
                             hr, i, software_device);
             }
             IDirectDrawSurface7_Release(surface);
@@ -6632,10 +6632,10 @@ static void test_rt_caps(const GUID *device_guid)
             surface_desc.dwWidth = 640;
             surface_desc.dwHeight = 480;
             hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+            ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
 
             hr = IDirect3D7_CreateDevice(d3d, device_guid, surface, &device);
-            ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+            ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
         }
 
         memset(&surface_desc, 0, sizeof(surface_desc));
@@ -6651,12 +6651,12 @@ static void test_rt_caps(const GUID *device_guid)
         surface_desc.dwWidth = 640;
         surface_desc.dwHeight = 480;
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &rt, NULL);
-        ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+        ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
 
         hr = IDirect3DDevice7_SetRenderTarget(device, rt, 0);
         ok(hr == test_data[i].set_rt_hr || (software_device && hr == DDERR_NOPALETTEATTACHED)
                 || hr == test_data[i].alternative_set_rt_hr,
-                "Got unexpected hr %#x, test %u, software_device %u.\n",
+                "Got unexpected hr %#lx, test %u, software_device %u.\n",
                 hr, i, software_device);
         if (SUCCEEDED(hr) || hr == DDERR_INVALIDPIXELFORMAT)
             expected_rt = rt;
@@ -6664,24 +6664,24 @@ static void test_rt_caps(const GUID *device_guid)
             expected_rt = surface;
 
         hr = IDirect3DDevice7_GetRenderTarget(device, &tmp);
-        ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+        ok(hr == DD_OK, "Got unexpected hr %#lx, test %u, software_device %u.\n", hr, i, software_device);
         ok(tmp == expected_rt, "Got unexpected rt %p, test %u, software_device %u.\n", tmp, i, software_device);
 
         IDirectDrawSurface7_Release(tmp);
         IDirectDrawSurface7_Release(rt);
         refcount = IDirect3DDevice7_Release(device);
-        ok(refcount == 0, "Test %u: The device was not properly freed, refcount %u.\n", i, refcount);
+        ok(refcount == 0, "Test %u: The device was not properly freed, refcount %lu.\n", i, refcount);
         refcount = IDirectDrawSurface7_Release(surface);
-        ok(refcount == 0, "Test %u: The surface was not properly freed, refcount %u.\n", i, refcount);
+        ok(refcount == 0, "Test %u: The surface was not properly freed, refcount %lu.\n", i, refcount);
     }
 
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     IDirect3D7_Release(d3d);
 
 done:
     refcount = IDirectDraw7_Release(ddraw);
-    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -6806,7 +6806,7 @@ static void test_primary_caps(void)
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, test_data[i].coop_level);
-        ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
@@ -6816,23 +6816,23 @@ static void test_primary_caps(void)
         surface_desc.ddsCaps.dwCaps = test_data[i].caps_in;
         U5(surface_desc).dwBackBufferCount = test_data[i].back_buffer_count;
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
         if (FAILED(hr))
             continue;
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
-        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#lx.\n", i, hr);
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == test_data[i].caps_out,
-                "Test %u: Got unexpected caps %#x, expected %#x.\n",
+                "Test %u: Got unexpected caps %#lx, expected %#lx.\n",
                 i, surface_desc.ddsCaps.dwCaps, test_data[i].caps_out);
 
         IDirectDrawSurface7_Release(surface);
     }
 
     refcount = IDirectDraw7_Release(ddraw);
-    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -6961,7 +6961,7 @@ static void test_surface_lock(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     if (FAILED(IDirectDraw7_QueryInterface(ddraw, &IID_IDirect3D7, (void **)&d3d)))
     {
@@ -6970,7 +6970,7 @@ static void test_surface_lock(void)
     }
 
     hr = IDirect3D7_EnumDevices(d3d, enum_devtype_cb, &hal_ok);
-    ok(SUCCEEDED(hr), "Failed to enumerate devices, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enumerate devices, hr %#lx.\n", hr);
     if (hal_ok)
         devtype = &IID_IDirect3DTnLHalDevice;
 
@@ -6989,12 +6989,12 @@ static void test_surface_lock(void)
     ddsd.dwHeight = 64;
     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirect3D7_CreateDevice(d3d, devtype, surface, &device);
-    ok(SUCCEEDED(hr), "Failed to create device, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create device, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_GetCaps(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     cubemap_supported = !!(device_desc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_CUBEMAP);
     IDirect3DDevice7_Release(device);
 
@@ -7023,30 +7023,30 @@ static void test_surface_lock(void)
         ddsd.ddsCaps.dwCaps2 = tests[i].caps2;
 
         hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, type %s, hr %#x.\n", tests[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to create surface, type %s, hr %#lx.\n", tests[i].name, hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface7_Lock(surface, NULL, &ddsd, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, type %s, hr %#x.\n", tests[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, type %s, hr %#lx.\n", tests[i].name, hr);
         if (SUCCEEDED(hr))
         {
-            ok(ddsd.dwSize == sizeof(ddsd), "Got unexpected dwSize %u, type %s.\n", ddsd.dwSize, tests[i].name);
+            ok(ddsd.dwSize == sizeof(ddsd), "Got unexpected dwSize %lu, type %s.\n", ddsd.dwSize, tests[i].name);
             hr = IDirectDrawSurface7_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, type %s, hr %#x.\n", tests[i].name, hr);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, type %s, hr %#lx.\n", tests[i].name, hr);
         }
 
         memset(&ddsd, 0, sizeof(ddsd));
         expected_hr = tests[i].caps & DDSCAPS_TEXTURE && !(tests[i].caps & DDSCAPS_VIDEOMEMORY)
                 ? DD_OK : DDERR_INVALIDPARAMS;
         hr = IDirectDrawSurface7_Lock(surface, NULL, &ddsd, DDLOCK_WAIT, NULL);
-        ok(hr == expected_hr, "Got hr %#x, expected %#x, type %s.\n", hr, expected_hr, tests[i].name);
+        ok(hr == expected_hr, "Got hr %#lx, expected %#lx, type %s.\n", hr, expected_hr, tests[i].name);
         if (SUCCEEDED(hr))
         {
-            ok(!ddsd.dwSize, "Got unexpected dwSize %u, type %s.\n", ddsd.dwSize, tests[i].name);
+            ok(!ddsd.dwSize, "Got unexpected dwSize %lu, type %s.\n", ddsd.dwSize, tests[i].name);
             ok(!!ddsd.lpSurface, "Got NULL lpSurface, type %s.\n", tests[i].name);
             hr = IDirectDrawSurface7_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, type %s, hr %#x.\n", tests[i].name, hr);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, type %s, hr %#lx.\n", tests[i].name, hr);
         }
 
         IDirectDrawSurface7_Release(surface);
@@ -7056,7 +7056,7 @@ done:
     if (d3d)
         IDirect3D7_Release(d3d);
     refcount = IDirectDraw7_Release(ddraw);
-    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -7108,11 +7108,11 @@ static void test_surface_discard(void)
             return;
         }
         hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-        ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
         hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-        ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_GetRenderTarget(device, &target);
-        ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
@@ -7122,34 +7122,34 @@ static void test_surface_discard(void)
         ddsd.dwWidth = 64;
         ddsd.dwHeight = 64;
         hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create offscreen surface, hr %#x, case %u.\n", hr, i);
+        ok(SUCCEEDED(hr), "Failed to create offscreen surface, hr %#lx, case %u.\n", hr, i);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface7_Lock(surface, NULL, &ddsd, 0, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         addr = ddsd.lpSurface;
         hr = IDirectDrawSurface7_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface7_Lock(surface, NULL, &ddsd, DDLOCK_DISCARDCONTENTS, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         discarded = ddsd.lpSurface != addr;
         hr = IDirectDrawSurface7_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         hr = IDirectDrawSurface7_Blt(target, NULL, surface, NULL, DDBLT_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
         hr = IDirectDrawSurface7_Lock(surface, NULL, &ddsd, DDLOCK_DISCARDCONTENTS, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         discarded |= ddsd.lpSurface != addr;
         hr = IDirectDrawSurface7_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         IDirectDrawSurface7_Release(surface);
 
@@ -7200,7 +7200,7 @@ static void test_flip(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
@@ -7223,95 +7223,95 @@ static void test_flip(void)
         surface_desc.dwHeight = 512;
         U5(surface_desc).dwBackBufferCount = 3;
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
 
         surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_FLIP;
         surface_desc.dwFlags |= DDSD_BACKBUFFERCOUNT;
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
 
         surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_COMPLEX;
         surface_desc.ddsCaps.dwCaps |= DDSCAPS_FLIP;
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_INVALIDCAPS, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
 
         surface_desc.ddsCaps.dwCaps |= DDSCAPS_COMPLEX;
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
         if (is_ddraw64 && test_data[i].caps & DDSCAPS_TEXTURE)
-            todo_wine ok(hr == E_NOINTERFACE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+            todo_wine ok(hr == E_NOINTERFACE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         else todo_wine_if(test_data[i].caps & DDSCAPS_TEXTURE)
-            ok(SUCCEEDED(hr), "%s: Failed to create surface, hr %#x.\n", test_data[i].name, hr);
+            ok(SUCCEEDED(hr), "%s: Failed to create surface, hr %#lx.\n", test_data[i].name, hr);
         if (FAILED(hr))
             continue;
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface7_GetSurfaceDesc(frontbuffer, &surface_desc);
-        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#lx.\n", test_data[i].name, hr);
         expected_caps = DDSCAPS_FRONTBUFFER | DDSCAPS_COMPLEX | DDSCAPS_FLIP | test_data[i].caps;
         if (test_data[i].caps & DDSCAPS_PRIMARYSURFACE)
             expected_caps |= DDSCAPS_VISIBLE;
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == expected_caps,
-                "%s: Got unexpected caps %#x.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
+                "%s: Got unexpected caps %#lx.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
         sysmem_primary = surface_desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY;
 
         hr = IDirectDrawSurface7_GetAttachedSurface(frontbuffer, &caps, &backbuffer1);
-        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#lx.\n", test_data[i].name, hr);
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface7_GetSurfaceDesc(backbuffer1, &surface_desc);
-        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#x.\n", test_data[i].name, hr);
-        ok(!U5(surface_desc).dwBackBufferCount, "%s: Got unexpected back buffer count %u.\n",
+        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#lx.\n", test_data[i].name, hr);
+        ok(!U5(surface_desc).dwBackBufferCount, "%s: Got unexpected back buffer count %lu.\n",
                 test_data[i].name, U5(surface_desc).dwBackBufferCount);
         expected_caps &= ~(DDSCAPS_VISIBLE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER);
         expected_caps |= DDSCAPS_BACKBUFFER;
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == expected_caps,
-                "%s: Got unexpected caps %#x.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
+                "%s: Got unexpected caps %#lx.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
 
         hr = IDirectDrawSurface7_GetAttachedSurface(backbuffer1, &caps, &backbuffer2);
-        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#lx.\n", test_data[i].name, hr);
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface7_GetSurfaceDesc(backbuffer2, &surface_desc);
-        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#x.\n", test_data[i].name, hr);
-        ok(!U5(surface_desc).dwBackBufferCount, "%s: Got unexpected back buffer count %u.\n",
+        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#lx.\n", test_data[i].name, hr);
+        ok(!U5(surface_desc).dwBackBufferCount, "%s: Got unexpected back buffer count %lu.\n",
                 test_data[i].name, U5(surface_desc).dwBackBufferCount);
         expected_caps &= ~DDSCAPS_BACKBUFFER;
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == expected_caps,
-                "%s: Got unexpected caps %#x.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
+                "%s: Got unexpected caps %#lx.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
 
         hr = IDirectDrawSurface7_GetAttachedSurface(backbuffer2, &caps, &backbuffer3);
-        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#lx.\n", test_data[i].name, hr);
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface7_GetSurfaceDesc(backbuffer3, &surface_desc);
-        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#x.\n", test_data[i].name, hr);
-        ok(!U5(surface_desc).dwBackBufferCount, "%s: Got unexpected back buffer count %u.\n",
+        ok(SUCCEEDED(hr), "%s: Failed to get surface desc, hr %#lx.\n", test_data[i].name, hr);
+        ok(!U5(surface_desc).dwBackBufferCount, "%s: Got unexpected back buffer count %lu.\n",
                 test_data[i].name, U5(surface_desc).dwBackBufferCount);
         ok((surface_desc.ddsCaps.dwCaps & ~placement) == expected_caps,
-                "%s: Got unexpected caps %#x.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
+                "%s: Got unexpected caps %#lx.\n", test_data[i].name, surface_desc.ddsCaps.dwCaps);
 
         hr = IDirectDrawSurface7_GetAttachedSurface(backbuffer3, &caps, &surface);
-        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to get attached surface, hr %#lx.\n", test_data[i].name, hr);
         ok(surface == frontbuffer, "%s: Got unexpected surface %p, expected %p.\n",
                 test_data[i].name, surface, frontbuffer);
         IDirectDrawSurface7_Release(surface);
 
         hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-        ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_IsLost(frontbuffer);
-        ok(hr == DD_OK, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DD_OK, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Flip(frontbuffer, NULL, DDFLIP_WAIT);
         if (test_data[i].caps & DDSCAPS_PRIMARYSURFACE)
-            ok(hr == DDERR_NOEXCLUSIVEMODE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+            ok(hr == DDERR_NOEXCLUSIVEMODE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         else
-            ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+            ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-        ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to set cooperative level, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_IsLost(frontbuffer);
-        todo_wine ok(hr == DDERR_SURFACELOST, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        todo_wine ok(hr == DDERR_SURFACELOST, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDraw7_RestoreAllSurfaces(ddraw);
-        ok(SUCCEEDED(hr), "%s: Failed to restore surfaces, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to restore surfaces, hr %#lx.\n", test_data[i].name, hr);
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
@@ -7320,19 +7320,19 @@ static void test_flip(void)
         surface_desc.dwWidth = 640;
         surface_desc.dwHeight = 480;
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(SUCCEEDED(hr), "%s: Failed to create surface, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to create surface, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Flip(frontbuffer, surface, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         IDirectDrawSurface7_Release(surface);
 
         hr = IDirectDrawSurface7_Flip(frontbuffer, frontbuffer, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Flip(backbuffer1, NULL, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Flip(backbuffer2, NULL, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Flip(backbuffer3, NULL, DDFLIP_WAIT);
-        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+        ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
 
         /* The Nvidia Geforce 7 driver cannot do a color fill on a texture backbuffer after
          * the backbuffer has been locked. Do it ourselves as a workaround. Unlike ddraw1
@@ -7342,59 +7342,59 @@ static void test_flip(void)
         fill_surface(backbuffer3, 0xff0000ff);
 
         hr = IDirectDrawSurface7_Flip(frontbuffer, NULL, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
         /* The testbot seems to just copy the contents of one surface to all the
          * others, instead of properly flipping. */
         ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
-        ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer3, 0xffff0000);
 
         hr = IDirectDrawSurface7_Flip(frontbuffer, NULL, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
         ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
-        ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer3, 0xff00ff00);
 
         hr = IDirectDrawSurface7_Flip(frontbuffer, NULL, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
         ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
-        ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer3, 0xff0000ff);
 
         hr = IDirectDrawSurface7_Flip(frontbuffer, backbuffer1, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer2, 320, 240);
         ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer3, 320, 240);
-        ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer1, 0xffff0000);
 
         hr = IDirectDrawSurface7_Flip(frontbuffer, backbuffer2, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
-        ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer3, 320, 240);
         ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         fill_surface(backbuffer2, 0xff00ff00);
 
         hr = IDirectDrawSurface7_Flip(frontbuffer, backbuffer3, DDFLIP_WAIT);
-        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#lx.\n", test_data[i].name, hr);
         color = get_surface_color(backbuffer1, 320, 240);
         ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
-                "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+                "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
-        ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
+        ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08lx.\n", test_data[i].name, color);
 
         IDirectDrawSurface7_Release(backbuffer3);
         IDirectDrawSurface7_Release(backbuffer2);
@@ -7408,7 +7408,7 @@ static void test_flip(void)
         goto done;
     }
     hr = IDirect3DDevice7_GetCaps(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     IDirect3DDevice7_Release(device);
     if (!(device_desc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_CUBEMAP))
     {
@@ -7425,33 +7425,33 @@ static void test_flip(void)
     surface_desc.dwHeight = 128;
     U5(surface_desc).dwBackBufferCount = 3;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-    ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#lx.\n", hr);
 
     surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_FLIP;
     surface_desc.dwFlags |= DDSD_BACKBUFFERCOUNT;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_COMPLEX;
     surface_desc.ddsCaps.dwCaps |= DDSCAPS_FLIP;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-    ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#lx.\n", hr);
 
     surface_desc.ddsCaps.dwCaps |= DDSCAPS_COMPLEX;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     U5(surface_desc).dwBackBufferCount = 1;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     U5(surface_desc).dwBackBufferCount = 0;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
-    ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#lx.\n", hr);
 
 done:
     refcount = IDirectDraw7_Release(ddraw);
-    ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
+    ok(refcount == 0, "The ddraw object was not properly freed, refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -7490,7 +7490,7 @@ static void test_set_surface_desc(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
@@ -7505,74 +7505,74 @@ static void test_set_surface_desc(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     /* Redundantly setting the same lpSurface is not an error. */
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!(ddsd.dwFlags & DDSD_LPSURFACE), "DDSD_LPSURFACE is set.\n");
     ok(ddsd.lpSurface == NULL, "lpSurface is %p, expected NULL.\n", ddsd.lpSurface);
 
     hr = IDirectDrawSurface7_Lock(surface, NULL, &ddsd, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ok(!(ddsd.dwFlags & DDSD_LPSURFACE), "DDSD_LPSURFACE is set.\n");
     ok(ddsd.lpSurface == data, "lpSurface is %p, expected %p.\n", data, data);
     hr = IDirectDrawSurface7_Unlock(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 1);
-    ok(hr == DDERR_INVALIDPARAMS, "SetSurfaceDesc with flags=1 returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "SetSurfaceDesc with flags=1 returned %#lx.\n", hr);
 
     ddsd.lpSurface = NULL;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting lpSurface=NULL returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting lpSurface=NULL returned %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, NULL, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "SetSurfaceDesc with NULL desc returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "SetSurfaceDesc with NULL desc returned %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(ddsd.ddsCaps.dwCaps == (DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN),
-            "Got unexpected caps %#x.\n", ddsd.ddsCaps.dwCaps);
+            "Got unexpected caps %#lx.\n", ddsd.ddsCaps.dwCaps);
     ok(ddsd.ddsCaps.dwCaps2 == 0, "Got unexpected caps2 %#x.\n", 0);
 
     /* Setting the caps is an error. This also means the original description cannot be reapplied. */
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting the original desc returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting the original desc returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_CAPS;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting DDSD_CAPS returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting DDSD_CAPS returned %#lx.\n", hr);
 
     /* dwCaps = 0 is allowed, but ignored. Caps2 can be anything and is ignored too. */
     ddsd.dwFlags = DDSD_CAPS | DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDCAPS, "Setting DDSD_CAPS returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDCAPS, "Setting DDSD_CAPS returned %#lx.\n", hr);
     ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDCAPS, "Setting DDSD_CAPS returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDCAPS, "Setting DDSD_CAPS returned %#lx.\n", hr);
     ddsd.ddsCaps.dwCaps = 0;
     ddsd.ddsCaps.dwCaps2 = 0xdeadbeef;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(ddsd.ddsCaps.dwCaps == (DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN),
-            "Got unexpected caps %#x.\n", ddsd.ddsCaps.dwCaps);
+            "Got unexpected caps %#lx.\n", ddsd.ddsCaps.dwCaps);
     ok(ddsd.ddsCaps.dwCaps2 == 0, "Got unexpected caps2 %#x.\n", 0);
 
     /* Setting the height is allowed, but it cannot be set to 0, and only if LPSURFACE is set too. */
@@ -7580,56 +7580,56 @@ static void test_set_surface_desc(void)
     ddsd.dwFlags = DDSD_HEIGHT;
     ddsd.dwHeight = 16;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting height without lpSurface returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting height without lpSurface returned %#lx.\n", hr);
 
     ddsd.lpSurface = data;
     ddsd.dwFlags = DDSD_HEIGHT | DDSD_LPSURFACE;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     ddsd.dwHeight = 0;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting height=0 returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting height=0 returned %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd);
-    ok(SUCCEEDED(hr), "GetSurfaceDesc failed, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == 8, "SetSurfaceDesc: Expected width 8, got %u.\n", ddsd.dwWidth);
-    ok(ddsd.dwHeight == 16, "SetSurfaceDesc: Expected height 16, got %u.\n", ddsd.dwHeight);
+    ok(SUCCEEDED(hr), "GetSurfaceDesc failed, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == 8, "SetSurfaceDesc: Expected width 8, got %lu.\n", ddsd.dwWidth);
+    ok(ddsd.dwHeight == 16, "SetSurfaceDesc: Expected height 16, got %lu.\n", ddsd.dwHeight);
 
     /* Pitch and width can be set, but only together, and only with LPSURFACE. They must not be 0. */
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_PITCH;
     U1(ddsd).lPitch = 8 * 4;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting pitch without lpSurface or width returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting pitch without lpSurface or width returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_WIDTH;
     ddsd.dwWidth = 16;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting width without lpSurface or pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting width without lpSurface or pitch returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_PITCH | DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting pitch and lpSurface without width returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting pitch and lpSurface without width returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_WIDTH | DDSD_LPSURFACE;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting width and lpSurface without pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting width and lpSurface without pitch returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_WIDTH | DDSD_PITCH | DDSD_LPSURFACE;
     U1(ddsd).lPitch = 16 * 4;
     ddsd.dwWidth = 16;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(ddsd.dwWidth == 16, "SetSurfaceDesc: Expected width 8, got %u.\n", ddsd.dwWidth);
-    ok(ddsd.dwHeight == 16, "SetSurfaceDesc: Expected height 16, got %u.\n", ddsd.dwHeight);
-    ok(U1(ddsd).lPitch == 16 * 4, "SetSurfaceDesc: Expected pitch 64, got %u.\n", U1(ddsd).lPitch);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(ddsd.dwWidth == 16, "SetSurfaceDesc: Expected width 8, got %lu.\n", ddsd.dwWidth);
+    ok(ddsd.dwHeight == 16, "SetSurfaceDesc: Expected height 16, got %lu.\n", ddsd.dwHeight);
+    ok(U1(ddsd).lPitch == 16 * 4, "SetSurfaceDesc: Expected pitch 64, got %lu.\n", U1(ddsd).lPitch);
 
     /* The pitch must be 32 bit aligned and > 0, but is not verified for sanity otherwise.
      *
@@ -7638,27 +7638,27 @@ static void test_set_surface_desc(void)
     U1(ddsd).lPitch = 4 * 4;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDPARAMS), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDPARAMS), "Failed to set surface desc, hr %#lx.\n", hr);
 
     U1(ddsd).lPitch = 4;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDPARAMS), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == DDERR_INVALIDPARAMS), "Failed to set surface desc, hr %#lx.\n", hr);
 
     U1(ddsd).lPitch = 16 * 4 + 1;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting misaligned pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting misaligned pitch returned %#lx.\n", hr);
 
     U1(ddsd).lPitch = 16 * 4 + 3;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting misaligned pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting misaligned pitch returned %#lx.\n", hr);
 
     U1(ddsd).lPitch = -4;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting negative pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting negative pitch returned %#lx.\n", hr);
 
     U1(ddsd).lPitch = 16 * 4;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_WIDTH | DDSD_PITCH | DDSD_LPSURFACE;
@@ -7666,13 +7666,13 @@ static void test_set_surface_desc(void)
     ddsd.dwWidth = 16;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting zero pitch returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting zero pitch returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_WIDTH | DDSD_PITCH | DDSD_LPSURFACE;
     U1(ddsd).lPitch = 16 * 4;
     ddsd.dwWidth = 0;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting zero width returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting zero width returned %#lx.\n", hr);
 
     /* Setting the pixelformat without LPSURFACE is an error, but with LPSURFACE it works. */
     ddsd.dwFlags = DDSD_PIXELFORMAT;
@@ -7683,11 +7683,11 @@ static void test_set_surface_desc(void)
     U3(U4(ddsd).ddpfPixelFormat).dwGBitMask = 0x0000ff00;
     U4(U4(ddsd).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting the pixel format returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting the pixel format returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_LPSURFACE;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     /* Can't set color keys. */
     reset_ddsd(&ddsd);
@@ -7695,12 +7695,12 @@ static void test_set_surface_desc(void)
     ddsd.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00ff0000;
     ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00ff0000;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting ddckCKSrcBlt returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting ddckCKSrcBlt returned %#lx.\n", hr);
 
     ddsd.dwFlags = DDSD_CKSRCBLT | DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Setting ddckCKSrcBlt returned %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Setting ddckCKSrcBlt returned %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(surface);
 
@@ -7713,7 +7713,7 @@ static void test_set_surface_desc(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW || hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW || hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
 
     if (FAILED(hr))
     {
@@ -7724,13 +7724,13 @@ static void test_set_surface_desc(void)
         /* Changing surface desc for mipmap fails even without changing any
          * parameters. */
         hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-        ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#lx.\n", hr);
 
         reset_ddsd(&ddsd);
         ddsd.dwFlags = DDSD_LPSURFACE;
         ddsd.lpSurface = data;
         hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-        ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#lx.\n", hr);
         IDirectDrawSurface7_Release(surface);
     }
 
@@ -7743,7 +7743,7 @@ static void test_set_surface_desc(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW || hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW || hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
 
     if (hr == DD_OK)
     {
@@ -7752,14 +7752,14 @@ static void test_set_surface_desc(void)
         IDirectDrawSurface7 *surface2;
 
         hr = IDirectDrawSurface7_GetAttachedSurface(surface, &caps, &surface2);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         reset_ddsd(&ddsd);
         hr = IDirectDrawSurface7_GetSurfaceDesc(surface2, &ddsd);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-        ok(ddsd.dwWidth == 4, "Got unexpected dwWidth %u.\n", ddsd.dwWidth);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+        ok(ddsd.dwWidth == 4, "Got unexpected dwWidth %lu.\n", ddsd.dwWidth);
 
         hr = IDirectDrawSurface7_Lock(surface2, NULL, &ddsd, 0, NULL);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         surface2_system_mem = ddsd.lpSurface;
         IDirectDrawSurface7_Unlock(surface2, NULL);
 
@@ -7770,7 +7770,7 @@ static void test_set_surface_desc(void)
         U1(ddsd).lPitch = 16 * 4;
         ddsd.lpSurface = data;
         hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-        todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        todo_wine ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         reset_ddsd(&ddsd);
         ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH | DDSD_LPSURFACE;
@@ -7779,11 +7779,11 @@ static void test_set_surface_desc(void)
         U1(ddsd).lPitch = 8 * 4;
         ddsd.lpSurface = data;
         hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         reset_ddsd(&ddsd);
         hr = IDirectDrawSurface7_Lock(surface2, NULL, &ddsd, 0, NULL);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         ok(ddsd.lpSurface == surface2_system_mem, "Got unexpected lpSurface %p.\n", ddsd.lpSurface);
         IDirectDrawSurface7_Unlock(surface2, NULL);
 
@@ -7794,11 +7794,11 @@ static void test_set_surface_desc(void)
         U1(ddsd).lPitch = 4 * 4;
         ddsd.lpSurface = data;
         hr = IDirectDrawSurface7_SetSurfaceDesc(surface2, &ddsd, 0);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         reset_ddsd(&ddsd);
         hr = IDirectDrawSurface7_Lock(surface2, NULL, &ddsd, 0, NULL);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         ok(ddsd.lpSurface == data, "Got unexpected lpSurface %p.\n", ddsd.lpSurface);
         IDirectDrawSurface7_Unlock(surface2, NULL);
 
@@ -7809,7 +7809,7 @@ static void test_set_surface_desc(void)
         U1(ddsd).lPitch = 16 * 4;
         ddsd.lpSurface = data;
         hr = IDirectDrawSurface7_SetSurfaceDesc(surface2, &ddsd, 0);
-        todo_wine ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        todo_wine ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         IDirectDrawSurface7_Release(surface2);
         IDirectDrawSurface7_Release(surface);
@@ -7824,10 +7824,10 @@ static void test_set_surface_desc(void)
     U1(ddsd).lPitch = 8 * 4;
     ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
@@ -7835,7 +7835,7 @@ static void test_set_surface_desc(void)
     ddsd.dwHeight = 8;
     /* Cannot reset lpSurface. */
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_LPSURFACE | DDSD_PITCH;
@@ -7845,7 +7845,7 @@ static void test_set_surface_desc(void)
     U1(ddsd).lPitch = 8 * 4;
     /* Can change the parameters of surface created with DDSD_LPSURFACE. */
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(surface);
 
@@ -7874,9 +7874,9 @@ static void test_set_surface_desc(void)
 
         hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
         if (is_ddraw64 && (invalid_caps_tests[i].caps & DDSCAPS_TEXTURE))
-            todo_wine ok(hr == E_NOINTERFACE, "Test %u: Got unexpected hr %#x.\n", i, hr);
+            todo_wine ok(hr == E_NOINTERFACE, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         else
-            ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW, "Test %u: Got unexpected hr %#x.\n", i, hr);
+            ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         if (FAILED(hr))
             continue;
 
@@ -7886,17 +7886,17 @@ static void test_set_surface_desc(void)
         hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
         if (invalid_caps_tests[i].supported)
         {
-            ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
         }
         else
         {
-            ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n",
+            ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#lx.\n",
                     invalid_caps_tests[i].name, hr);
 
             /* Check priority of error conditions. */
             ddsd.dwFlags = DDSD_WIDTH;
             hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-            ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n",
+            ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#lx.\n",
                     invalid_caps_tests[i].name, hr);
         }
 
@@ -7904,7 +7904,7 @@ static void test_set_surface_desc(void)
     }
 
     ref = IDirectDraw7_Release(ddraw);
-    ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Ddraw object not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -7927,7 +7927,7 @@ static void test_user_memory_getdc(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
@@ -7941,17 +7941,17 @@ static void test_user_memory_getdc(void)
     U4(U4(ddsd).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(data, 0xaa, sizeof(data));
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_LPSURFACE;
     ddsd.lpSurface = data;
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     bitmap = GetCurrentObject(dc, OBJ_BITMAP);
     ok(!!bitmap, "Failed to get bitmap.\n");
     size = GetObjectA(bitmap, sizeof(dib), &dib);
@@ -7960,10 +7960,10 @@ static void test_user_memory_getdc(void)
     BitBlt(dc, 0, 0, 16, 8, NULL, 0, 0, WHITENESS);
     BitBlt(dc, 0, 8, 16, 8, NULL, 0, 0, BLACKNESS);
     hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
-    ok(data[0][0] == 0xffffffff, "Expected color 0xffffffff, got %#x.\n", data[0][0]);
-    ok(data[15][15] == 0x00000000, "Expected color 0x00000000, got %#x.\n", data[15][15]);
+    ok(data[0][0] == 0xffffffff, "Expected color 0xffffffff, got %#lx.\n", data[0][0]);
+    ok(data[15][15] == 0x00000000, "Expected color 0x00000000, got %#lx.\n", data[15][15]);
 
     ddsd.dwFlags = DDSD_LPSURFACE | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PITCH;
     ddsd.lpSurface = data;
@@ -7971,40 +7971,40 @@ static void test_user_memory_getdc(void)
     ddsd.dwHeight = 8;
     U1(ddsd).lPitch = sizeof(*data);
     hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0);
-    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#lx.\n", hr);
 
     memset(data, 0xaa, sizeof(data));
     hr = IDirectDrawSurface7_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     BitBlt(dc, 0, 0, 4, 8, NULL, 0, 0, BLACKNESS);
     BitBlt(dc, 1, 1, 2, 2, NULL, 0, 0, WHITENESS);
     hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     for (y = 0; y < 4; y++)
     {
         for (x = 0; x < 4; x++)
         {
             if ((x == 1 || x == 2) && (y == 1 || y == 2))
-                ok(data[y][x] == 0xffffffff, "Expected color 0xffffffff on position %ux%u, got %#x.\n",
+                ok(data[y][x] == 0xffffffff, "Expected color 0xffffffff on position %ux%u, got %#lx.\n",
                         x, y, data[y][x]);
             else
-                ok(data[y][x] == 0x00000000, "Expected color 0x00000000 on position %ux%u, got %#x.\n",
+                ok(data[y][x] == 0x00000000, "Expected color 0x00000000 on position %ux%u, got %#lx.\n",
                         x, y, data[y][x]);
         }
     }
-    ok(data[0][5] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 5x0, got %#x.\n",
+    ok(data[0][5] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 5x0, got %#lx.\n",
             data[0][5]);
-    ok(data[7][3] == 0x00000000, "Expected color 0x00000000 on position 3x7, got %#x.\n",
+    ok(data[7][3] == 0x00000000, "Expected color 0x00000000 on position 3x7, got %#lx.\n",
             data[7][3]);
-    ok(data[7][4] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 4x7, got %#x.\n",
+    ok(data[7][4] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 4x7, got %#lx.\n",
             data[7][4]);
-    ok(data[8][0] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 0x8, got %#x.\n",
+    ok(data[8][0] == 0xaaaaaaaa, "Expected color 0xaaaaaaaa on position 0x8, got %#lx.\n",
             data[8][0]);
 
     IDirectDrawSurface7_Release(surface);
     ref = IDirectDraw7_Release(ddraw);
-    ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Ddraw object not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -8021,7 +8021,7 @@ static void test_sysmem_overlay(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     reset_ddsd(&ddsd);
     ddsd.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
@@ -8035,10 +8035,10 @@ static void test_sysmem_overlay(void)
     U3(U4(ddsd).ddpfPixelFormat).dwGBitMask = 0x0000ff00;
     U4(U4(ddsd).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DDERR_NOOVERLAYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOOVERLAYHW, "Got unexpected hr %#lx.\n", hr);
 
     ref = IDirectDraw7_Release(ddraw);
-    ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);
+    ok(ref == 0, "Ddraw object not properly released, refcount %lu.\n", ref);
     DestroyWindow(window);
 }
 
@@ -8066,7 +8066,7 @@ static void test_primary_palette(void)
         return;
     }
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -8074,22 +8074,22 @@ static void test_primary_palette(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     U5(surface_desc).dwBackBufferCount = 1;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetAttachedSurface(primary, &surface_caps, &backbuffer);
-    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#lx.\n", hr);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     hr = IDirectDraw7_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256, palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)palette);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
-    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
-    ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#x.\n", palette_caps);
+    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#lx.\n", hr);
+    ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#lx.\n", palette_caps);
 
     hr = IDirectDrawSurface7_SetPalette(primary, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     /* The Windows 8 testbot attaches the palette to the backbuffer as well,
      * and is generally somewhat broken with respect to 8 bpp / palette
@@ -8102,99 +8102,99 @@ static void test_primary_palette(void)
         /* The Windows 8 testbot keeps extra references to the primary and
          * backbuffer while in 8 bpp mode. */
         hr = IDirectDraw7_RestoreDisplayMode(ddraw);
-        ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#lx.\n", hr);
         goto done;
     }
 
     refcount = get_refcount((IUnknown *)palette);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
-    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#lx.\n", hr);
     ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_PRIMARYSURFACE | DDPCAPS_ALLOW256),
-            "Got unexpected palette caps %#x.\n", palette_caps);
+            "Got unexpected palette caps %#lx.\n", palette_caps);
 
     hr = IDirectDrawSurface7_SetPalette(primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)palette);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawPalette_GetCaps(palette, &palette_caps);
-    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#x.\n", hr);
-    ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#x.\n", palette_caps);
+    ok(SUCCEEDED(hr), "Failed to get palette caps, hr %#lx.\n", hr);
+    ok(palette_caps == (DDPCAPS_8BIT | DDPCAPS_ALLOW256), "Got unexpected palette caps %#lx.\n", palette_caps);
 
     hr = IDirectDrawSurface7_SetPalette(primary, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)palette);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface7_GetPalette(primary, &tmp);
-    ok(SUCCEEDED(hr), "Failed to get palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette, hr %#lx.\n", hr);
     ok(tmp == palette, "Got unexpected palette %p, expected %p.\n", tmp, palette);
     IDirectDrawPalette_Release(tmp);
     hr = IDirectDrawSurface7_GetPalette(backbuffer, &tmp);
-    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx.\n", hr);
 
     refcount = IDirectDrawPalette_Release(palette);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     /* Note that this only seems to work when the palette is attached to the
      * primary surface. When attached to a regular surface, attempting to get
      * the palette here will cause an access violation. */
     hr = IDirectDrawSurface7_GetPalette(primary, &tmp);
-    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
-    ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 8, "Got unexpected bit count %u.\n",
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %lu.\n", surface_desc.dwWidth);
+    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %lu.\n", surface_desc.dwHeight);
+    ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 8, "Got unexpected bit count %lu.\n",
             U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount);
 
     hr = set_display_mode(ddraw, 640, 480);
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %lu.\n", surface_desc.dwWidth);
+    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %lu.\n", surface_desc.dwHeight);
     ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 32
             || U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 24,
-            "Got unexpected bit count %u.\n", U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount);
+            "Got unexpected bit count %lu.\n", U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount);
 
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Restore(primary);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(primary);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface7_GetSurfaceDesc(primary, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %u.\n", surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %u.\n", surface_desc.dwHeight);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == 640, "Got unexpected surface width %lu.\n", surface_desc.dwWidth);
+    ok(surface_desc.dwHeight == 480, "Got unexpected surface height %lu.\n", surface_desc.dwHeight);
     ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 32
             || U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == 24,
-            "Got unexpected bit count %u.\n", U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount);
+            "Got unexpected bit count %lu.\n", U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount);
 
 done:
     refcount = IDirectDrawSurface7_Release(backbuffer);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawSurface7_Release(primary);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -8224,7 +8224,7 @@ static void test_surface_attachment(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -8242,11 +8242,11 @@ static void test_surface_attachment(void)
     }
 
     hr = IDirectDrawSurface7_GetAttachedSurface(surface1, &caps, &surface2);
-    ok(SUCCEEDED(hr), "Failed to get mip level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get mip level, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetAttachedSurface(surface2, &caps, &surface3);
-    ok(SUCCEEDED(hr), "Failed to get mip level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get mip level, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetAttachedSurface(surface3, &caps, &surface4);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
 
     surface_count = 0;
     IDirectDrawSurface7_EnumAttachedSurfaces(surface1, &surface_count, surface_counter);
@@ -8265,20 +8265,20 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 16;
     surface_desc.dwHeight = 16;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_AddAttachedSurface(surface1, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_AddAttachedSurface(surface4, surface1);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_AddAttachedSurface(surface3, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_AddAttachedSurface(surface4, surface3);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_AddAttachedSurface(surface2, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_AddAttachedSurface(surface4, surface2);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(surface4);
 
@@ -8289,20 +8289,20 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 16;
     surface_desc.dwHeight = 16;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_AddAttachedSurface(surface1, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_AddAttachedSurface(surface4, surface1);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_AddAttachedSurface(surface3, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_AddAttachedSurface(surface4, surface3);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_AddAttachedSurface(surface2, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_AddAttachedSurface(surface4, surface2);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(surface4);
     IDirectDrawSurface7_Release(surface3);
@@ -8310,7 +8310,7 @@ static void test_surface_attachment(void)
     IDirectDrawSurface7_Release(surface1);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     /* Try a single primary and two offscreen plain surfaces. */
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -8318,7 +8318,7 @@ static void test_surface_attachment(void)
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -8327,7 +8327,7 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = registry_mode.dmPelsWidth;
     surface_desc.dwHeight = registry_mode.dmPelsHeight;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -8336,7 +8336,7 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = registry_mode.dmPelsWidth;
     surface_desc.dwHeight = registry_mode.dmPelsHeight;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* This one has a different size. */
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -8346,18 +8346,18 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 128;
     surface_desc.dwHeight = 128;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_AddAttachedSurface(surface1, surface2);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_AddAttachedSurface(surface2, surface1);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_AddAttachedSurface(surface2, surface3);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_AddAttachedSurface(surface1, surface4);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_AddAttachedSurface(surface4, surface1);
-    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(surface4);
     IDirectDrawSurface7_Release(surface3);
@@ -8372,7 +8372,7 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 64;
     surface_desc.dwHeight = 64;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -8385,26 +8385,26 @@ static void test_surface_attachment(void)
     surface_desc.dwWidth = 32;
     surface_desc.dwHeight = 32;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
     surface_desc.dwWidth = 64;
     surface_desc.dwHeight = 64;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
     surface_desc.dwWidth = 128;
     surface_desc.dwHeight = 128;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
-    ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
-    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     if (SUCCEEDED(hr))
         IDirectDrawSurface7_DeleteAttachedSurface(surface1, 0, surface2);
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface3);
-    ok(hr == D3D_OK, "Failed to attach depth buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to attach depth buffer, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_DeleteAttachedSurface(surface1, 0, surface3);
-    ok(hr == D3D_OK, "Failed to detach depth buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to detach depth buffer, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4);
-    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(surface4);
     IDirectDrawSurface7_Release(surface3);
@@ -8425,72 +8425,72 @@ static void test_surface_attachment(void)
     U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x07e0;
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x001f;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
     U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_ZBUFFER;
     U1(U4(surface_desc).ddpfPixelFormat).dwZBufferBitDepth = 16;
     U3(U4(surface_desc).ddpfPixelFormat).dwZBitMask = 0x0000ffff;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_QueryInterface(surface1, &IID_IDirectDrawSurface, (void **)&surface1v1);
-    ok(SUCCEEDED(hr), "Failed to get interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get interface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_QueryInterface(surface2, &IID_IDirectDrawSurface, (void **)&surface2v1);
-    ok(SUCCEEDED(hr), "Failed to get interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get interface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_AddAttachedSurface(surface1, surface2);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)surface2);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
     refcount = get_refcount((IUnknown *)surface2v1);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     hr = IDirectDrawSurface7_AddAttachedSurface(surface1, surface2);
-    ok(hr == DDERR_SURFACEALREADYATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACEALREADYATTACHED, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_AddAttachedSurface(surface1v1, surface2v1);
-    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface1v1, 0, surface2v1);
-    ok(hr == DDERR_SURFACENOTATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACENOTATTACHED, "Got unexpected hr %#lx.\n", hr);
 
     /* Attaching while already attached to other surface. */
     hr = IDirectDrawSurface7_AddAttachedSurface(surface3, surface2);
-    todo_wine ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    todo_wine ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_DeleteAttachedSurface(surface3, 0, surface2);
-    todo_wine ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    todo_wine ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
     IDirectDrawSurface7_Release(surface3);
 
     hr = IDirectDrawSurface7_DeleteAttachedSurface(surface1, 0, surface2);
-    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)surface2);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     refcount = get_refcount((IUnknown *)surface2v1);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     /* DeleteAttachedSurface() when attaching via IDirectDrawSurface. */
     hr = IDirectDrawSurface_AddAttachedSurface(surface1v1, surface2v1);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_DeleteAttachedSurface(surface1, 0, surface2);
-    ok(hr == DDERR_SURFACENOTATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACENOTATTACHED, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface_DeleteAttachedSurface(surface1v1, 0, surface2v1);
-    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach surface, hr %#lx.\n", hr);
     refcount = IDirectDrawSurface7_Release(surface2);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawSurface7_Release(surface1);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     /* Automatic detachment on release. */
     hr = IDirectDrawSurface_AddAttachedSurface(surface1v1, surface2v1);
-    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to attach surface, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)surface2v1);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawSurface_Release(surface1v1);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawSurface_Release(surface2v1);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -8526,7 +8526,7 @@ static void test_private_data(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     reset_ddsd(&surface_desc);
     surface_desc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
@@ -8534,27 +8534,27 @@ static void test_private_data(void)
     surface_desc.dwHeight = 4;
     surface_desc.dwWidth = 4;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* NULL pointers are not valid, but don't cause a crash. */
     hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL,
             sizeof(IUnknown *), DDSPD_IUNKNOWNPOINTER);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, 0, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, 1, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* DDSPD_IUNKNOWNPOINTER needs sizeof(IUnknown *) bytes of data. */
     hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
             0, DDSPD_IUNKNOWNPOINTER);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
             5, DDSPD_IUNKNOWNPOINTER);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
             sizeof(ddraw) * 2, DDSPD_IUNKNOWNPOINTER);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Note that with a size != 0 and size != sizeof(IUnknown *) and
      * DDSPD_IUNKNOWNPOINTER set SetPrivateData in ddraw4 and ddraw7
@@ -8563,85 +8563,85 @@ static void test_private_data(void)
      * that depends on this we don't care about this behavior. */
     hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
             sizeof(ddraw), DDSPD_IUNKNOWNPOINTER);
-    ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
             0, DDSPD_IUNKNOWNPOINTER);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     size = sizeof(ptr);
     hr = IDirectDrawSurface7_GetPrivateData(surface, &ddraw_private_data_test_guid, &ptr, &size);
-    ok(SUCCEEDED(hr), "Failed to get private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get private data, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_FreePrivateData(surface, &ddraw_private_data_test_guid);
-    ok(SUCCEEDED(hr), "Failed to free private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to free private data, hr %#lx.\n", hr);
 
     refcount = get_refcount((IUnknown *)ddraw);
     hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
             sizeof(ddraw), DDSPD_IUNKNOWNPOINTER);
-    ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
     refcount2 = get_refcount((IUnknown *)ddraw);
-    ok(refcount2 == refcount + 1, "Got unexpected refcount %u.\n", refcount2);
+    ok(refcount2 == refcount + 1, "Got unexpected refcount %lu.\n", refcount2);
 
     hr = IDirectDrawSurface7_FreePrivateData(surface, &ddraw_private_data_test_guid);
-    ok(SUCCEEDED(hr), "Failed to free private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to free private data, hr %#lx.\n", hr);
     refcount2 = get_refcount((IUnknown *)ddraw);
-    ok(refcount2 == refcount, "Got unexpected refcount %u.\n", refcount2);
+    ok(refcount2 == refcount, "Got unexpected refcount %lu.\n", refcount2);
 
     hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
             sizeof(ddraw), DDSPD_IUNKNOWNPOINTER);
-    ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, surface,
             sizeof(surface), DDSPD_IUNKNOWNPOINTER);
-    ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
     refcount2 = get_refcount((IUnknown *)ddraw);
-    ok(refcount2 == refcount, "Got unexpected refcount %u.\n", refcount2);
+    ok(refcount2 == refcount, "Got unexpected refcount %lu.\n", refcount2);
 
     hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
             sizeof(ddraw), DDSPD_IUNKNOWNPOINTER);
-    ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
     size = 2 * sizeof(ptr);
     hr = IDirectDrawSurface7_GetPrivateData(surface, &ddraw_private_data_test_guid, &ptr, &size);
-    ok(SUCCEEDED(hr), "Failed to get private data, hr %#x.\n", hr);
-    ok(size == sizeof(ddraw), "Got unexpected size %u.\n", size);
+    ok(SUCCEEDED(hr), "Failed to get private data, hr %#lx.\n", hr);
+    ok(size == sizeof(ddraw), "Got unexpected size %lu.\n", size);
     refcount2 = get_refcount(ptr);
     /* Object is NOT addref'ed by the getter. */
     ok(ptr == (IUnknown *)ddraw, "Returned interface pointer is %p, expected %p.\n", ptr, ddraw);
-    ok(refcount2 == refcount + 1, "Got unexpected refcount %u.\n", refcount2);
+    ok(refcount2 == refcount + 1, "Got unexpected refcount %lu.\n", refcount2);
 
     ptr = (IUnknown *)0xdeadbeef;
     size = 1;
     hr = IDirectDrawSurface7_GetPrivateData(surface, &ddraw_private_data_test_guid, NULL, &size);
-    ok(hr == DDERR_MOREDATA, "Got unexpected hr %#x.\n", hr);
-    ok(size == sizeof(ddraw), "Got unexpected size %u.\n", size);
+    ok(hr == DDERR_MOREDATA, "Got unexpected hr %#lx.\n", hr);
+    ok(size == sizeof(ddraw), "Got unexpected size %lu.\n", size);
     size = 2 * sizeof(ptr);
     hr = IDirectDrawSurface7_GetPrivateData(surface, &ddraw_private_data_test_guid, NULL, &size);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
-    ok(size == 2 * sizeof(ptr), "Got unexpected size %u.\n", size);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
+    ok(size == 2 * sizeof(ptr), "Got unexpected size %lu.\n", size);
     size = 1;
     hr = IDirectDrawSurface7_GetPrivateData(surface, &ddraw_private_data_test_guid, &ptr, &size);
-    ok(hr == DDERR_MOREDATA, "Got unexpected hr %#x.\n", hr);
-    ok(size == sizeof(ddraw), "Got unexpected size %u.\n", size);
+    ok(hr == DDERR_MOREDATA, "Got unexpected hr %#lx.\n", hr);
+    ok(size == sizeof(ddraw), "Got unexpected size %lu.\n", size);
     ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
     hr = IDirectDrawSurface7_GetPrivateData(surface, &ddraw_private_data_test_guid2, NULL, NULL);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     size = 0xdeadbabe;
     hr = IDirectDrawSurface7_GetPrivateData(surface, &ddraw_private_data_test_guid2, &ptr, &size);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
-    ok(size == 0xdeadbabe, "Got unexpected size %u.\n", size);
+    ok(size == 0xdeadbabe, "Got unexpected size %lu.\n", size);
     hr = IDirectDrawSurface7_GetPrivateData(surface, &ddraw_private_data_test_guid, NULL, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     refcount3 = IDirectDrawSurface7_Release(surface);
-    ok(!refcount3, "Got unexpected refcount %u.\n", refcount3);
+    ok(!refcount3, "Got unexpected refcount %lu.\n", refcount3);
 
     /* Destroying the surface frees the reference held on the private data. It also frees
      * the reference the surface is holding on its creating object. */
     refcount2 = get_refcount((IUnknown *)ddraw);
-    ok(refcount2 == refcount - 1, "Got unexpected refcount %u.\n", refcount2);
+    ok(refcount2 == refcount - 1, "Got unexpected refcount %lu.\n", refcount2);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw7_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) == (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)
             && !is_ddraw64)
     {
@@ -8652,14 +8652,14 @@ static void test_private_data(void)
         surface_desc.dwWidth = 4;
         U2(surface_desc).dwMipMapCount = 2;
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
         hr = IDirectDrawSurface7_GetAttachedSurface(surface, &caps, &surface2);
-        ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#lx.\n", hr);
 
         hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, data, sizeof(data), 0);
-        ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set private data, hr %#lx.\n", hr);
         hr = IDirectDrawSurface7_GetPrivateData(surface2, &ddraw_private_data_test_guid, NULL, NULL);
-        ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
 
         IDirectDrawSurface7_Release(surface2);
         IDirectDrawSurface7_Release(surface);
@@ -8668,7 +8668,7 @@ static void test_private_data(void)
         skip("Mipmapped textures not supported, skipping mipmap private data test.\n");
 
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -8751,7 +8751,7 @@ static void test_pixel_format(void)
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
     if (FAILED(hr))
     {
-        skip("Failed to set cooperative level, hr %#x.\n", hr);
+        skip("Failed to set cooperative level, hr %#lx.\n", hr);
         goto cleanup;
     }
 
@@ -8761,9 +8761,9 @@ static void test_pixel_format(void)
     if (hdc2)
     {
         hr = IDirectDraw7_CreateClipper(ddraw, 0, &clipper, NULL);
-        ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
         hr = IDirectDrawClipper_SetHWnd(clipper, 0, window2);
-        ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#lx.\n", hr);
 
         test_format = GetPixelFormat(hdc);
         ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -8778,7 +8778,7 @@ static void test_pixel_format(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -8792,7 +8792,7 @@ static void test_pixel_format(void)
     if (clipper)
     {
         hr = IDirectDrawSurface7_SetClipper(primary, clipper);
-        ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
 
         test_format = GetPixelFormat(hdc);
         ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -8807,18 +8807,18 @@ static void test_pixel_format(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     ddsd.dwWidth = ddsd.dwHeight = 64;
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &offscreen, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     hr = IDirectDrawSurface7_Blt(offscreen, NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear source surface, hr %#lx.\n", hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
 
     hr = IDirectDrawSurface7_Blt(primary, NULL, offscreen, NULL, DDBLT_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to blit to primary surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit to primary surface, hr %#lx.\n", hr);
 
     test_format = GetPixelFormat(hdc);
     ok(test_format == format, "window has pixel format %d, expected %d\n", test_format, format);
@@ -8943,7 +8943,7 @@ static void test_create_surface_pitch(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ((63 * 4) + 8) * 63);
 
@@ -8966,36 +8966,36 @@ static void test_create_surface_pitch(void)
         if (test_data[i].flags_in & DDSD_LPSURFACE)
         {
             HRESULT expected_hr = SUCCEEDED(test_data[i].hr) ? DDERR_INVALIDPARAMS : test_data[i].hr;
-            ok(hr == expected_hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, expected_hr);
+            ok(hr == expected_hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, expected_hr);
             surface_desc.lpSurface = mem;
             hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
         }
         if ((test_data[i].caps & DDSCAPS_VIDEOMEMORY) && hr == DDERR_NODIRECTDRAWHW)
             continue;
         if (is_ddraw64 && (test_data[i].caps & DDSCAPS_TEXTURE) && SUCCEEDED(test_data[i].hr))
-            todo_wine ok(hr == E_NOINTERFACE, "Test %u: Got unexpected hr %#x.\n", i, hr);
+            todo_wine ok(hr == E_NOINTERFACE, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         else
-            ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+            ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
         if (FAILED(hr))
             continue;
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
-        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#lx.\n", i, hr);
         ok((surface_desc.dwFlags & flags_mask) == test_data[i].flags_out,
-                "Test %u: Got unexpected flags %#x, expected %#x.\n",
+                "Test %u: Got unexpected flags %#lx, expected %#lx.\n",
                 i, surface_desc.dwFlags & flags_mask, test_data[i].flags_out);
         /* The pitch for textures seems to be implementation specific. */
         if (!(test_data[i].caps & DDSCAPS_TEXTURE))
         {
             if (is_ddraw64 && test_data[i].pitch_out32 != test_data[i].pitch_out64)
                 todo_wine ok(U1(surface_desc).lPitch == test_data[i].pitch_out64,
-                        "Test %u: Got unexpected pitch %u, expected %u.\n",
+                        "Test %u: Got unexpected pitch %lu, expected %lu.\n",
                         i, U1(surface_desc).lPitch, test_data[i].pitch_out64);
             else
                 ok(U1(surface_desc).lPitch == test_data[i].pitch_out32,
-                        "Test %u: Got unexpected pitch %u, expected %u.\n",
+                        "Test %u: Got unexpected pitch %lu, expected %lu.\n",
                         i, U1(surface_desc).lPitch, test_data[i].pitch_out32);
         }
         ok(!surface_desc.lpSurface, "Test %u: Got unexpected lpSurface %p.\n", i, surface_desc.lpSurface);
@@ -9005,7 +9005,7 @@ static void test_create_surface_pitch(void)
 
     HeapFree(GetProcessHeap(), 0, mem);
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -9045,12 +9045,12 @@ static void test_mipmap(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw7_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) != (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)
             || is_ddraw64)
     {
@@ -9071,18 +9071,18 @@ static void test_mipmap(void)
         if (tests[i].flags & DDSD_MIPMAPCOUNT)
             U2(surface_desc).dwMipMapCount = tests[i].mipmap_count_in;
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         if (FAILED(hr))
             continue;
 
         memset(&surface_desc, 0, sizeof(surface_desc));
         surface_desc.dwSize = sizeof(surface_desc);
         hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
-        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#lx.\n", i, hr);
         ok(surface_desc.dwFlags & DDSD_MIPMAPCOUNT,
-                "Test %u: Got unexpected flags %#x.\n", i, surface_desc.dwFlags);
+                "Test %u: Got unexpected flags %#lx.\n", i, surface_desc.dwFlags);
         ok(U2(surface_desc).dwMipMapCount == tests[i].mipmap_count_out,
-                "Test %u: Got unexpected mipmap count %u.\n", i, U2(surface_desc).dwMipMapCount);
+                "Test %u: Got unexpected mipmap count %lu.\n", i, U2(surface_desc).dwMipMapCount);
 
         surface_base = surface;
         IDirectDrawSurface7_AddRef(surface_base);
@@ -9090,31 +9090,31 @@ static void test_mipmap(void)
         while (mipmap_count > 1)
         {
             hr = IDirectDrawSurface7_GetAttachedSurface(surface_base, &caps, &surface_mip);
-            ok(SUCCEEDED(hr), "Test %u, %u: Failed to get attached surface, hr %#x.\n", i, mipmap_count, hr);
+            ok(SUCCEEDED(hr), "Test %u, %u: Failed to get attached surface, hr %#lx.\n", i, mipmap_count, hr);
 
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface7_GetSurfaceDesc(surface_base, &surface_desc);
-            ok(SUCCEEDED(hr), "Test %u, %u: Failed to get surface desc, hr %#x.\n", i, mipmap_count, hr);
+            ok(SUCCEEDED(hr), "Test %u, %u: Failed to get surface desc, hr %#lx.\n", i, mipmap_count, hr);
             ok(surface_desc.dwFlags & DDSD_MIPMAPCOUNT,
-                    "Test %u, %u: Got unexpected flags %#x.\n", i, mipmap_count, surface_desc.dwFlags);
+                    "Test %u, %u: Got unexpected flags %#lx.\n", i, mipmap_count, surface_desc.dwFlags);
             ok(U2(surface_desc).dwMipMapCount == mipmap_count,
-                    "Test %u, %u: Got unexpected mipmap count %u.\n",
+                    "Test %u, %u: Got unexpected mipmap count %lu.\n",
                     i, mipmap_count, U2(surface_desc).dwMipMapCount);
 
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface7_Lock(surface_base, NULL, &surface_desc, 0, NULL);
-            ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#x.\n", i, mipmap_count, hr);
+            ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#lx.\n", i, mipmap_count, hr);
             ok(surface_desc.dwMipMapCount == mipmap_count,
-                    "Test %u, %u: unexpected change of mipmap count %u.\n",
+                    "Test %u, %u: unexpected change of mipmap count %lu.\n",
                     i, mipmap_count, surface_desc.dwMipMapCount);
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface7_Lock(surface_mip, NULL, &surface_desc, 0, NULL);
-            ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#x.\n", i, mipmap_count, hr);
+            ok(SUCCEEDED(hr), "Test %u, %u: Failed to lock surface, hr %#lx.\n", i, mipmap_count, hr);
             ok(surface_desc.dwMipMapCount == mipmap_count - 1,
-                    "Test %u, %u: Child mipmap count unexpected %u\n", i, mipmap_count, surface_desc.dwMipMapCount);
+                    "Test %u, %u: Child mipmap count unexpected %lu\n", i, mipmap_count, surface_desc.dwMipMapCount);
             IDirectDrawSurface7_Unlock(surface_mip, NULL);
             IDirectDrawSurface7_Unlock(surface_base, NULL);
 
@@ -9128,7 +9128,7 @@ static void test_mipmap(void)
     }
 
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -9150,12 +9150,12 @@ static void test_palette_complex(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw7_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) != (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)
             || is_ddraw64)
     {
@@ -9175,21 +9175,21 @@ static void test_palette_complex(void)
     U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
     U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount = 8;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     hr = IDirectDraw7_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     palette2 = (void *)0xdeadbeef;
     hr = IDirectDrawSurface7_GetPalette(surface, &palette2);
-    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx.\n", hr);
     ok(!palette2, "Got unexpected palette %p.\n", palette2);
     hr = IDirectDrawSurface7_SetPalette(surface, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetPalette(surface, &palette2);
-    ok(SUCCEEDED(hr), "Failed to get palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette, hr %#lx.\n", hr);
     ok(palette == palette2, "Got unexpected palette %p.\n", palette2);
     IDirectDrawPalette_Release(palette2);
 
@@ -9198,17 +9198,17 @@ static void test_palette_complex(void)
     for (i = 0; i < 7; ++i)
     {
         hr = IDirectDrawSurface7_GetAttachedSurface(mipmap, &caps, &tmp);
-        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#lx.\n", i, hr);
         palette2 = (void *)0xdeadbeef;
         hr = IDirectDrawSurface7_GetPalette(tmp, &palette2);
-        ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x, i %u.\n", hr, i);
+        ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx, i %u.\n", hr, i);
         ok(!palette2, "Got unexpected palette %p, i %u.\n", palette2, i);
 
         hr = IDirectDrawSurface7_SetPalette(tmp, palette);
-        ok(hr == DDERR_NOTONMIPMAPSUBLEVEL, "Got unexpected hr %#x, i %u.\n", hr, i);
+        ok(hr == DDERR_NOTONMIPMAPSUBLEVEL, "Got unexpected hr %#lx, i %u.\n", hr, i);
 
         hr = IDirectDrawSurface7_GetPalette(tmp, &palette2);
-        ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x, i %u.\n", hr, i);
+        ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx, i %u.\n", hr, i);
         ok(!palette2, "Got unexpected palette %p, i %u.\n", palette2, i);
 
         /* Ddraw7 uses the palette of the mipmap for GetDC, just like previous
@@ -9221,10 +9221,10 @@ static void test_palette_complex(void)
     }
 
     hr = IDirectDrawSurface7_GetAttachedSurface(mipmap, &caps, &tmp);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface7_Release(mipmap);
     refcount = IDirectDrawSurface7_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     /* Test DDERR_INVALIDPIXELFORMAT vs DDERR_NOTONMIPMAPSUBLEVEL. */
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -9240,21 +9240,21 @@ static void test_palette_complex(void)
     U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x0000ff00;
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_GetAttachedSurface(surface, &caps, &mipmap);
-    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_SetPalette(mipmap, palette);
-    ok(hr == DDERR_NOTONMIPMAPSUBLEVEL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTONMIPMAPSUBLEVEL, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(mipmap);
     refcount = IDirectDrawSurface7_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -9285,7 +9285,7 @@ static void test_p8_blit(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     is_warp = ddraw_is_warp(ddraw);
 
     memset(palette_entries, 0, sizeof(palette_entries));
@@ -9295,14 +9295,14 @@ static void test_p8_blit(void)
     palette_entries[4].peRed = 0xff;
     hr = IDirectDraw7_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
     palette_entries[1].peBlue = 0xff;
     palette_entries[2].peGreen = 0xff;
     palette_entries[3].peRed = 0xff;
     palette_entries[4].peFlags = 0x0;
     hr = IDirectDraw7_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -9314,11 +9314,11 @@ static void test_p8_blit(void)
     U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
     U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount = 8;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &src, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &dst_p8, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_SetPalette(dst_p8, palette2);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -9334,34 +9334,34 @@ static void test_p8_blit(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(U4(surface_desc).ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface7_Lock(src, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock source surface, hr %#lx.\n", hr);
     memcpy(surface_desc.lpSurface, src_data, sizeof(src_data));
     hr = IDirectDrawSurface7_Unlock(src, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock source surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Lock(dst_p8, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#lx.\n", hr);
     memcpy(surface_desc.lpSurface, src_data2, sizeof(src_data2));
     hr = IDirectDrawSurface7_Unlock(dst_p8, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#lx.\n", hr);
 
     fx.dwSize = sizeof(fx);
     fx.dwFillColor = 0xdeadbeef;
     hr = IDirectDrawSurface7_Blt(dst, NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
-    ok(SUCCEEDED(hr), "Failed to color fill %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to color fill %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_SetPalette(src, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(dst, NULL, src, NULL, DDBLT_WAIT, NULL);
     /* The r500 Windows 7 driver returns E_NOTIMPL. r200 on Windows XP works.
      * The Geforce 7 driver on Windows Vista returns E_FAIL. Newer Nvidia GPUs work. */
     ok(SUCCEEDED(hr) || broken(hr == E_NOTIMPL) || broken(hr == E_FAIL),
-            "Failed to blit, hr %#x.\n", hr);
+            "Failed to blit, hr %#lx.\n", hr);
 
     if (SUCCEEDED(hr))
     {
@@ -9372,7 +9372,7 @@ static void test_p8_blit(void)
              * blits see below. */
             todo_wine ok(compare_color(color, expected[x], 0)
                     || broken(is_warp && compare_color(color, 0x00000000, 0)),
-                    "Pixel %u: Got color %#x, expected %#x.\n",
+                    "Pixel %u: Got color %#lx, expected %#lx.\n",
                     x, color, expected[x]);
         }
     }
@@ -9380,10 +9380,10 @@ static void test_p8_blit(void)
     fx.ddckSrcColorkey.dwColorSpaceHighValue = 0x2;
     fx.ddckSrcColorkey.dwColorSpaceLowValue = 0x2;
     hr = IDirectDrawSurface7_Blt(dst_p8, NULL, src, NULL, DDBLT_WAIT | DDBLT_KEYSRCOVERRIDE, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Lock(dst_p8, NULL, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#lx.\n", hr);
     /* A color keyed P8 blit doesn't do anything on WARP - it just leaves the data in the destination
      * surface untouched. Error checking (DDBLT_KEYSRC without a key
      * for example) also works as expected.
@@ -9394,7 +9394,7 @@ static void test_p8_blit(void)
             || broken(is_warp && !memcmp(surface_desc.lpSurface, src_data2, sizeof(src_data2))),
             "Got unexpected P8 color key blit result.\n");
     hr = IDirectDrawSurface7_Unlock(dst_p8, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(src);
     IDirectDrawSurface7_Release(dst);
@@ -9403,7 +9403,7 @@ static void test_p8_blit(void)
     IDirectDrawPalette_Release(palette2);
 
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -9425,7 +9425,7 @@ static void test_material(void)
     }
 
     hr = IDirect3DDevice7_GetMaterial(device, &material);
-    ok(SUCCEEDED(hr), "Failed to get material, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get material, hr %#lx.\n", hr);
     ok(!memcmp(&U(material).diffuse, &null_color, sizeof(null_color)),
             "Got unexpected diffuse color {%.8e, %.8e, %.8e, %.8e}.\n",
             U1(U(material).diffuse).r, U2(U(material).diffuse).g,
@@ -9445,7 +9445,7 @@ static void test_material(void)
     ok(U4(material).power == 0.0f, "Got unexpected power %.8e.\n", U4(material).power);
 
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -9491,7 +9491,7 @@ static void test_palette_gdi(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -9503,7 +9503,7 @@ static void test_palette_gdi(void)
     U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
     U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount = 8;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* Avoid colors from the Windows default palette. */
     memset(palette_entries, 0, sizeof(palette_entries));
@@ -9515,7 +9515,7 @@ static void test_palette_gdi(void)
     palette_entries[4].peBlue = 0x15;
     hr = IDirectDraw7_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     /* If there is no palette assigned and the display mode is not 8 bpp, some
      * drivers refuse to create a DC while others allow it. If a DC is created,
@@ -9528,9 +9528,9 @@ static void test_palette_gdi(void)
      * contains uninitialized garbage. See comments below for the P8 case. */
 
     hr = IDirectDrawSurface7_SetPalette(surface, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     ddraw_palette_handle = SelectPalette(dc, GetStockObject(DEFAULT_PALETTE), FALSE);
     ok(ddraw_palette_handle == GetStockObject(DEFAULT_PALETTE),
             "Got unexpected palette %p, expected %p.\n",
@@ -9557,7 +9557,7 @@ static void test_palette_gdi(void)
     palette_entries[4].peGreen = 0x24;
     palette_entries[4].peBlue = 0x25;
     hr = IDirectDrawPalette_SetEntries(palette, 0, 4, 1, &palette_entries[4]);
-    ok(SUCCEEDED(hr), "Failed to set palette entries, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette entries, hr %#lx.\n", hr);
 
     i = GetDIBColorTable(dc, 4, 1, &rgbquad[4]);
     ok(i == 1, "Expected count 1, got %u.\n", i);
@@ -9568,9 +9568,9 @@ static void test_palette_gdi(void)
 
     /* Neither does re-setting the palette. */
     hr = IDirectDrawSurface7_SetPalette(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_SetPalette(surface, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     i = GetDIBColorTable(dc, 4, 1, &rgbquad[4]);
     ok(i == 1, "Expected count 1, got %u.\n", i);
@@ -9580,11 +9580,11 @@ static void test_palette_gdi(void)
             expected1[4].rgbRed, expected1[4].rgbGreen, expected1[4].rgbBlue);
 
     hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     /* Refresh the DC. This updates the palette. */
     hr = IDirectDrawSurface7_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad);
     ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i);
     for (i = 0; i < ARRAY_SIZE(expected2); ++i)
@@ -9601,13 +9601,13 @@ static void test_palette_gdi(void)
                 i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue);
     }
     hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     refcount = IDirectDrawSurface7_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     if (FAILED(IDirectDraw7_SetDisplayMode(ddraw, 640, 480, 8, 0, 0)))
     {
         win_skip("Failed to set 8 bpp display mode, skipping test.\n");
@@ -9616,35 +9616,35 @@ static void test_palette_gdi(void)
         DestroyWindow(window);
         return;
     }
-    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set display mode, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 3;
     SetRect(&r, 0, 0, 319, 479);
     hr = IDirectDrawSurface7_Blt(primary, &r, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear surface, hr %#lx.\n", hr);
     SetRect(&r, 320, 0, 639, 479);
     U5(fx).dwFillColor = 4;
     hr = IDirectDrawSurface7_Blt(primary, &r, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to clear surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_SetPalette(primary, palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetDC(primary, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
 
     color = GetPixel(dc, 160, 240);
-    ok(color == 0x00030000, "Clear index 3: Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00030000, "Clear index 3: Got unexpected color 0x%08lx.\n", color);
     color = GetPixel(dc, 480, 240);
-    ok(color == 0x00252423, "Clear index 4: Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00252423, "Clear index 4: Got unexpected color 0x%08lx.\n", color);
 
     ddraw_palette_handle = SelectPalette(dc, GetStockObject(DEFAULT_PALETTE), FALSE);
     ok(ddraw_palette_handle == GetStockObject(DEFAULT_PALETTE),
@@ -9674,7 +9674,7 @@ static void test_palette_gdi(void)
                 i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue);
     }
     hr = IDirectDrawSurface7_ReleaseDC(primary, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -9683,12 +9683,12 @@ static void test_palette_gdi(void)
     surface_desc.dwHeight = 16;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* Here the offscreen surface appears to use the primary's palette,
      * but in all likelihood it is actually the system palette. */
     hr = IDirectDrawSurface7_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad);
     ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i);
     for (i = 0; i < ARRAY_SIZE(expected2); ++i)
@@ -9705,7 +9705,7 @@ static void test_palette_gdi(void)
                 i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue);
     }
     hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     /* On real hardware a change to the primary surface's palette applies immediately,
      * even on device contexts from offscreen surfaces that do not have their own
@@ -9721,14 +9721,14 @@ static void test_palette_gdi(void)
     palette_entries[4].peBlue = 0x56;
     hr = IDirectDraw7_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
             palette_entries, &palette2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_SetPalette(surface, palette2);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     /* A palette assigned to the offscreen surface overrides the primary / system
      * palette. */
     hr = IDirectDrawSurface7_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     i = GetDIBColorTable(dc, 0, ARRAY_SIZE(rgbquad), rgbquad);
     ok(i == ARRAY_SIZE(rgbquad), "Expected count 255, got %u.\n", i);
     for (i = 0; i < ARRAY_SIZE(expected3); ++i)
@@ -9745,24 +9745,24 @@ static void test_palette_gdi(void)
                 i, rgbquad[i].rgbRed, rgbquad[i].rgbGreen, rgbquad[i].rgbBlue);
     }
     hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     refcount = IDirectDrawSurface7_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     /* The Windows 8 testbot keeps extra references to the primary and
      * backbuffer while in 8 bpp mode. */
     hr = IDirectDraw7_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#lx.\n", hr);
 
     refcount = IDirectDrawSurface7_Release(primary);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette2);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -9801,18 +9801,18 @@ static void test_palette_alpha(void)
         return;
     }
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     palette_entries[1].peFlags = 0x42;
     palette_entries[2].peFlags = 0xff;
     palette_entries[3].peFlags = 0x80;
     hr = IDirectDraw7_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     memset(palette_entries, 0x66, sizeof(palette_entries));
     hr = IDirectDrawPalette_GetEntries(palette, 0, 1, 4, palette_entries);
-    ok(SUCCEEDED(hr), "Failed to get palette entries, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette entries, hr %#lx.\n", hr);
     ok(palette_entries[0].peFlags == 0x42, "Got unexpected peFlags 0x%02x, expected 0xff.\n",
             palette_entries[0].peFlags);
     ok(palette_entries[1].peFlags == 0xff, "Got unexpected peFlags 0x%02x, expected 0xff.\n",
@@ -9831,11 +9831,11 @@ static void test_palette_alpha(void)
     palette_entries[3].peFlags = 0x80;
     hr = IDirectDraw7_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT | DDPCAPS_ALPHA,
             palette_entries, &palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create palette, hr %#lx.\n", hr);
 
     memset(palette_entries, 0x66, sizeof(palette_entries));
     hr = IDirectDrawPalette_GetEntries(palette, 0, 1, 4, palette_entries);
-    ok(SUCCEEDED(hr), "Failed to get palette entries, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette entries, hr %#lx.\n", hr);
     ok(palette_entries[0].peFlags == 0x42, "Got unexpected peFlags 0x%02x, expected 0xff.\n",
             palette_entries[0].peFlags);
     ok(palette_entries[1].peFlags == 0xff, "Got unexpected peFlags 0x%02x, expected 0xff.\n",
@@ -9855,17 +9855,17 @@ static void test_palette_alpha(void)
         surface_desc.ddsCaps.dwCaps = test_data[i].caps;
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
         if (is_ddraw64 && test_data[i].caps & DDSCAPS_TEXTURE)
-            todo_wine ok(hr == E_NOINTERFACE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+            todo_wine ok(hr == E_NOINTERFACE, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         else
-            ok(hr == DD_OK, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
+            ok(hr == DD_OK, "%s: Got unexpected hr %#lx.\n", test_data[i].name, hr);
         if (FAILED(hr))
             continue;
 
         hr = IDirectDrawSurface7_SetPalette(surface, palette);
         if (test_data[i].attach_allowed)
-            ok(SUCCEEDED(hr), "Failed to attach palette to %s surface, hr %#x.\n", test_data[i].name, hr);
+            ok(SUCCEEDED(hr), "Failed to attach palette to %s surface, hr %#lx.\n", test_data[i].name, hr);
         else
-            ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#x, %s surface.\n", hr, test_data[i].name);
+            ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#lx, %s surface.\n", hr, test_data[i].name);
 
         if (SUCCEEDED(hr))
         {
@@ -9874,7 +9874,7 @@ static void test_palette_alpha(void)
             UINT retval;
 
             hr = IDirectDrawSurface7_GetDC(surface, &dc);
-            ok(SUCCEEDED(hr), "Failed to get DC, hr %#x, %s surface.\n", hr, test_data[i].name);
+            ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx, %s surface.\n", hr, test_data[i].name);
             retval = GetDIBColorTable(dc, 1, 1, &rgbquad);
             ok(retval == 1, "GetDIBColorTable returned unexpected result %u.\n", retval);
             ok(rgbquad.rgbRed == 0xff, "Expected rgbRed = 0xff, got %#x, %s surface.\n",
@@ -9886,7 +9886,7 @@ static void test_palette_alpha(void)
             ok(rgbquad.rgbReserved == 0, "Expected rgbReserved = 0, got %u, %s surface.\n",
                     rgbquad.rgbReserved, test_data[i].name);
             hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-            ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
         }
         IDirectDrawSurface7_Release(surface);
     }
@@ -9905,20 +9905,20 @@ static void test_palette_alpha(void)
     U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x0000ff00;
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_SetPalette(surface, palette);
-    ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDSURFACETYPE, "Got unexpected hr %#lx.\n", hr);
     IDirectDrawSurface7_Release(surface);
 
     /* The Windows 8 testbot keeps extra references to the primary
      * while in 8 bpp mode. */
     hr = IDirectDraw7_RestoreDisplayMode(ddraw);
-    ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to restore display mode, hr %#lx.\n", hr);
 
     refcount = IDirectDrawPalette_Release(palette);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -9948,7 +9948,7 @@ static void test_vb_writeonly(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
 
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
@@ -9956,32 +9956,32 @@ static void test_vb_writeonly(void)
     desc.dwFVF = D3DFVF_XYZRHW;
     desc.dwNumVertices = ARRAY_SIZE(quad);
     hr = IDirect3D7_CreateVertexBuffer(d3d, &desc, &buffer, 0);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(buffer, DDLOCK_DISCARDCONTENTS, &ptr, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     memcpy(ptr, quad, sizeof(quad));
     hr = IDirect3DVertexBuffer7_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, buffer, 0, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(buffer, 0, &ptr, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     ok (!memcmp(ptr, quad, sizeof(quad)), "Got unexpected vertex buffer data.\n");
     hr = IDirect3DVertexBuffer7_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(buffer, DDLOCK_READONLY, &ptr, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     ok (!memcmp(ptr, quad, sizeof(quad)), "Got unexpected vertex buffer data.\n");
     hr = IDirect3DVertexBuffer7_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     IDirect3DVertexBuffer7_Release(buffer);
     IDirect3D7_Release(d3d);
@@ -10008,7 +10008,7 @@ static void test_lost_device(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -10016,7 +10016,7 @@ static void test_lost_device(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     U5(surface_desc).dwBackBufferCount = 1;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -10025,7 +10025,7 @@ static void test_lost_device(void)
     surface_desc.dwWidth = 100;
     surface_desc.dwHeight = 100;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -10046,93 +10046,93 @@ static void test_lost_device(void)
     }
 
     hr = IDirectDraw7_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDraw7_TestCooperativeLevel(ddraw);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Restore(surface);
-    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Restore(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface7_Restore(vidmem_surface);
-        ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_WRONGMODE, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     ret = SetForegroundWindow(window1);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDraw7_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw7_RestoreAllSurfaces(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT);
-    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        todo_wine ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     /* Trying to restore the primary will crash, probably because flippable
@@ -10143,78 +10143,78 @@ static void test_lost_device(void)
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_RestoreAllSurfaces(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw7_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDraw7_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     ret = SetForegroundWindow(window1);
     ok(ret, "Failed to set foreground window.\n");
     hr = IDirectDraw7_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw7_RestoreAllSurfaces(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     IDirectDrawSurface7_Release(surface);
@@ -10224,115 +10224,115 @@ static void test_lost_device(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     U5(surface_desc).dwBackBufferCount = 1;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window1, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window2, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOEXCLUSIVEMODE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window2, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_TestCooperativeLevel(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(surface);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (vidmem_surface)
     {
         hr = IDirectDrawSurface7_IsLost(vidmem_surface);
-        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     }
 
     memset(&caps, 0, sizeof(caps));
     caps.dwCaps = DDSCAPS_FLIP;
 
     hr = IDirectDrawSurface7_GetAttachedSurface(surface, &caps, &back_buffer);
-    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_SURFACELOST, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Restore(surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetAttachedSurface(surface, &caps, &back_buffer);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(back_buffer);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(back_buffer);
 
@@ -10341,7 +10341,7 @@ static void test_lost_device(void)
     IDirectDrawSurface7_Release(sysmem_surface);
     IDirectDrawSurface7_Release(surface);
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window2);
     DestroyWindow(window1);
 }
@@ -10384,12 +10384,12 @@ static void test_resource_priority(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw7_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & needed_caps) != needed_caps
             || !(hal_caps.ddsCaps.dwCaps & DDSCAPS2_TEXTUREMANAGE))
     {
@@ -10409,48 +10409,48 @@ static void test_resource_priority(void)
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
         if (is_ddraw64 && (test_data[i].caps & DDSCAPS_TEXTURE))
         {
-            todo_wine ok(hr == E_NOINTERFACE, "Got unexpected hr %#x, type %s.\n", hr, test_data[i].name);
+            todo_wine ok(hr == E_NOINTERFACE, "Got unexpected hr %#lx, type %s.\n", hr, test_data[i].name);
             if (SUCCEEDED(hr))
                 IDirectDrawSurface7_Release(surface);
             continue;
         }
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x, type %s.\n", hr, test_data[i].name);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx, type %s.\n", hr, test_data[i].name);
 
         /* Priority == NULL segfaults. */
         priority = 0xdeadbeef;
         hr = IDirectDrawSurface7_GetPriority(surface, &priority);
-        ok(hr == test_data[i].hr, "Got unexpected hr %#x, type %s.\n", hr, test_data[i].name);
+        ok(hr == test_data[i].hr, "Got unexpected hr %#lx, type %s.\n", hr, test_data[i].name);
         if (SUCCEEDED(test_data[i].hr))
-            ok(priority == 0, "Got unexpected priority %u, type %s.\n", priority, test_data[i].name);
+            ok(priority == 0, "Got unexpected priority %lu, type %s.\n", priority, test_data[i].name);
         else
-            ok(priority == 0xdeadbeef, "Got unexpected priority %u, type %s.\n", priority, test_data[i].name);
+            ok(priority == 0xdeadbeef, "Got unexpected priority %lu, type %s.\n", priority, test_data[i].name);
 
         if (!test_data[i].crash)
         {
             hr = IDirectDrawSurface7_SetPriority(surface, 1);
-            ok(hr == test_data[i].hr, "Got unexpected hr %#x, type %s.\n", hr, test_data[i].name);
+            ok(hr == test_data[i].hr, "Got unexpected hr %#lx, type %s.\n", hr, test_data[i].name);
             hr = IDirectDrawSurface7_GetPriority(surface, &priority);
-            ok(hr == test_data[i].hr, "Got unexpected hr %#x, type %s.\n", hr, test_data[i].name);
+            ok(hr == test_data[i].hr, "Got unexpected hr %#lx, type %s.\n", hr, test_data[i].name);
             if (SUCCEEDED(test_data[i].hr))
             {
-                ok(priority == 1, "Got unexpected priority %u, type %s.\n", priority, test_data[i].name);
+                ok(priority == 1, "Got unexpected priority %lu, type %s.\n", priority, test_data[i].name);
                 hr = IDirectDrawSurface7_SetPriority(surface, 2);
-                ok(hr == test_data[i].hr, "Got unexpected hr %#x, type %s.\n", hr, test_data[i].name);
+                ok(hr == test_data[i].hr, "Got unexpected hr %#lx, type %s.\n", hr, test_data[i].name);
             }
             else
-                ok(priority == 0xdeadbeef, "Got unexpected priority %u, type %s.\n", priority, test_data[i].name);
+                ok(priority == 0xdeadbeef, "Got unexpected priority %lu, type %s.\n", priority, test_data[i].name);
         }
 
         if (test_data[i].caps2 & DDSCAPS2_CUBEMAP)
         {
             caps.dwCaps2 = DDSCAPS2_CUBEMAP_NEGATIVEZ;
             hr = IDirectDrawSurface7_GetAttachedSurface(surface, &caps, &mipmap);
-            ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#x.\n", i, hr);
+            ok(SUCCEEDED(hr), "Failed to get attached surface, i %u, hr %#lx.\n", i, hr);
             /* IDirectDrawSurface7_SetPriority crashes when called on non-positive X surfaces on Windows */
             priority = 0xdeadbeef;
             hr = IDirectDrawSurface7_GetPriority(mipmap, &priority);
-            ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x, type %s.\n", hr, test_data[i].name);
-            ok(priority == 0xdeadbeef, "Got unexpected priority %u, type %s.\n", priority, test_data[i].name);
+            ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx, type %s.\n", hr, test_data[i].name);
+            ok(priority == 0xdeadbeef, "Got unexpected priority %lu, type %s.\n", priority, test_data[i].name);
 
             IDirectDrawSurface7_Release(mipmap);
         }
@@ -10470,27 +10470,27 @@ static void test_resource_priority(void)
     surface_desc.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE;
     U2(surface_desc).dwMipMapCount = 2;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     caps.dwCaps2 = 0;
     hr = IDirectDrawSurface7_GetAttachedSurface(surface, &caps, &mipmap);
-    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#lx.\n", hr);
 
     priority = 0xdeadbeef;
     hr = IDirectDrawSurface7_GetPriority(mipmap, &priority);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x, type managed mipmap.\n", hr);
-    ok(priority == 0xdeadbeef, "Got unexpected priority %u, type managed mipmap.\n", priority);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx, type managed mipmap.\n", hr);
+    ok(priority == 0xdeadbeef, "Got unexpected priority %lu, type managed mipmap.\n", priority);
     /* SetPriority on the mipmap surface crashes. */
     hr = IDirectDrawSurface7_GetPriority(surface, &priority);
-    ok(SUCCEEDED(hr), "Failed to get priority, hr %#x.\n", hr);
-    ok(priority == 0, "Got unexpected priority %u, type managed mipmap.\n", priority);
+    ok(SUCCEEDED(hr), "Failed to get priority, hr %#lx.\n", hr);
+    ok(priority == 0, "Got unexpected priority %lu, type managed mipmap.\n", priority);
 
     IDirectDrawSurface7_Release(mipmap);
     refcount = IDirectDrawSurface7_Release(surface);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
 done:
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -10507,7 +10507,7 @@ static void test_surface_desc_lock(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -10516,36 +10516,36 @@ static void test_surface_desc_lock(void)
     surface_desc.dwHeight = 16;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0xaa, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!surface_desc.lpSurface, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
 
     memset(&surface_desc, 0xaa, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface7_Lock(surface, NULL, &surface_desc, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ok(surface_desc.lpSurface != NULL, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
     memset(&surface_desc, 0xaa, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!surface_desc.lpSurface, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
     hr = IDirectDrawSurface7_Unlock(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0xaa, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(!surface_desc.lpSurface, "Got unexpected lpSurface %p.\n", surface_desc.lpSurface);
 
     IDirectDrawSurface7_Release(surface);
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -10605,30 +10605,30 @@ static void test_fog_interpolation(void)
     }
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_GetCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGTABLE))
         skip("D3DPRASTERCAPS_FOGTABLE not supported, skipping some fog tests\n");
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGCOLOR, 0x0000ff00);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     conv.f = 5.0;
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGDENSITY, conv.d);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_TEXTUREFACTOR, 0x000000ff);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -10636,35 +10636,35 @@ static void test_fog_interpolation(void)
             continue;
 
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00808080, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SHADEMODE, tests[i].shade);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGVERTEXMODE, tests[i].vfog);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, tests[i].tfog);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
                 D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, quad, 4, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = get_surface_color(rt, 0, 240);
-        ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x, case %u.\n", color, i);
+        ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx, case %u.\n", color, i);
         color = get_surface_color(rt, 320, 240);
         todo_wine_if (tests[i].todo)
             ok(compare_color(color, tests[i].middle_color, 2),
-                    "Got unexpected color 0x%08x, case %u.\n", color, i);
+                    "Got unexpected color 0x%08lx, case %u.\n", color, i);
         color = get_surface_color(rt, 639, 240);
-        ok(compare_color(color, 0x0000fd02, 2), "Got unexpected color 0x%08x, case %u.\n", color, i);
+        ok(compare_color(color, 0x0000fd02, 2), "Got unexpected color 0x%08lx, case %u.\n", color, i);
     }
 
     IDirectDrawSurface7_Release(rt);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -10759,42 +10759,42 @@ static void test_fog_process_vertices(void)
         return;
     }
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &model_matrix);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &view_matrix);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &identity_matrix);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = D3DFVF_XYZ | D3DFVF_NORMAL;
     vb_desc.dwNumVertices = 1;
     hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &src_vb, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR;
     vb_desc.dwNumVertices = 1;
     hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &dst_vb, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_LightEnable(device, 0, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SPECULARENABLE, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetLight(device, 0, &directional_light);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&material, 0, sizeof(material));
     U1(U2(material).specular).r = 0.0f;
@@ -10803,7 +10803,7 @@ static void test_fog_process_vertices(void)
     U4(U2(material).specular).a = 0.5f;
     U4(material).power = 5.0f;
     hr = IDirect3DDevice7_SetMaterial(device, &material);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -10811,43 +10811,43 @@ static void test_fog_process_vertices(void)
                 tests[i].fog_vertex_mode);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE,
                 tests[i].fog_table_mode);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_RANGEFOGENABLE, tests[i].range_fog);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DVertexBuffer7_Lock(src_vb, 0, (void **)&src_data, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         *src_data = tests[i].vertex;
         hr = IDirect3DVertexBuffer7_Unlock(src_vb);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DVertexBuffer7_Lock(dst_vb, 0, (void **)&dst_data, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         memset(dst_data, 0, sizeof(*dst_data));
         hr = IDirect3DVertexBuffer7_Unlock(dst_vb);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DVertexBuffer7_ProcessVertices(dst_vb, D3DVOP_TRANSFORM | D3DVOP_LIGHT, 0,
                 1, src_vb, 0, device, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DVertexBuffer7_Lock(dst_vb, 0, (void **)&dst_data, NULL);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         ok(compare_color(dst_data->specular, tests[i].expected_color, 1)
                 || broken(tests[i].expected_broken
                 && compare_color(dst_data->specular, tests[i].expected_broken, 1)),
-                "Expected color 0x%08x, got 0x%08x, test %u.\n",
+                "Expected color 0x%08lx, got 0x%08lx, test %u.\n",
                 tests[i].expected_color, dst_data->specular, i);
 
         hr = IDirect3DVertexBuffer7_Unlock(dst_vb);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     }
 
     IDirect3DVertexBuffer7_Release(dst_vb);
     IDirect3DVertexBuffer7_Release(src_vb);
     IDirect3D7_Release(d3d);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -10945,22 +10945,22 @@ static void test_negative_fixedfunction_fog(void)
     }
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_GetCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGTABLE))
         skip("D3DPRASTERCAPS_FOGTABLE not supported, skipping some fog tests.\n");
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGCOLOR, 0x0000ff00);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -10968,36 +10968,36 @@ static void test_negative_fixedfunction_fog(void)
             continue;
 
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x000000ff, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, tests[i].matrix);
-        ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGSTART, tests[i].start.d);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGEND, tests[i].end.d);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGVERTEXMODE, tests[i].vfog);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, tests[i].tfog);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
                 tests[i].pos_type | D3DFVF_DIFFUSE, tests[i].quad, 4, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = get_surface_color(rt, 0, 240);
         ok(compare_color(color, tests[i].color, 2) || broken(compare_color(color, tests[i].color_broken, 2))
                 || broken(compare_color(color, tests[i].color_broken2, 2)),
-                "Got unexpected color 0x%08x, case %u.\n", color, i);
+                "Got unexpected color 0x%08lx, case %u.\n", color, i);
     }
 
     IDirectDrawSurface7_Release(rt);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -11057,33 +11057,33 @@ static void test_table_fog_zw(void)
     }
 
     hr = IDirect3DDevice7_GetCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGTABLE))
     {
         skip("D3DPRASTERCAPS_FOGTABLE not supported, skipping POSITIONT table fog test.\n");
         goto done;
     }
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGCOLOR, 0x0000ff00);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     /* Work around an AMD Windows driver bug. Needs a proj matrix applied redundantly. */
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &identity);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_LINEAR);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x000000ff, 1.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
         quad[0].position.z = tests[i].z;
         quad[1].position.z = tests[i].z;
@@ -11094,25 +11094,25 @@ static void test_table_fog_zw(void)
         quad[2].position.w = tests[i].w;
         quad[3].position.w = tests[i].w;
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, tests[i].z_test);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
                 D3DFVF_XYZRHW | D3DFVF_DIFFUSE, quad, 4, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color = get_surface_color(rt, 0, 240);
         ok(compare_color(color, tests[i].color, 2),
-                "Got unexpected color 0x%08x, expected 0x%8x, case %u.\n", color, tests[i].color, i);
+                "Got unexpected color 0x%08lx, expected 0x%8lx, case %u.\n", color, tests[i].color, i);
     }
 
     IDirectDrawSurface7_Release(rt);
 done:
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -11216,7 +11216,7 @@ static void test_signed_formats(void)
     }
 
     hr = IDirect3DDevice7_GetCaps(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
     if (!(device_desc.dwTextureOpCaps & D3DTEXOPCAPS_BLENDFACTORALPHA))
     {
         skip("D3DTOP_BLENDFACTORALPHA not supported, skipping bumpmap format tests.\n");
@@ -11224,31 +11224,31 @@ static void test_signed_formats(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     /* dst = tex * 0.5 + 1.0 * (1.0 - 0.5) = tex * 0.5 + 0.5 */
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_TEXTUREFACTOR, 0x80ffffff);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_BLENDFACTORALPHA);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
-    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture stage state, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(formats); ++i)
     {
         for (width = 1; width < 5; width += 3)
         {
             hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00000000, 0.0f, 0);
-            ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to clear render target, hr %#lx.\n", hr);
 
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
@@ -11263,14 +11263,14 @@ static void test_signed_formats(void)
                 skip("%s textures not supported, skipping.\n", formats[i].name);
                 continue;
             }
-            ok(SUCCEEDED(hr), "Failed to create surface, hr %#x, format %s.\n", hr, formats[i].name);
+            ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx, format %s.\n", hr, formats[i].name);
             hr = IDirect3DDevice7_SetTexture(device, 0, surface);
-            ok(SUCCEEDED(hr), "Failed to set texture, hr %#x, format %s.\n", hr, formats[i].name);
+            ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx, format %s.\n", hr, formats[i].name);
 
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface7_Lock(surface, NULL, &surface_desc, 0, NULL);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, format %s.\n", hr, formats[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, format %s.\n", hr, formats[i].name);
             for (y = 0; y < 4; y++)
             {
                 memcpy((char *)surface_desc.lpSurface + y * U1(surface_desc).lPitch,
@@ -11278,15 +11278,15 @@ static void test_signed_formats(void)
                         width * formats[i].pixel_size);
             }
             hr = IDirectDrawSurface7_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, format %s.\n", hr, formats[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, format %s.\n", hr, formats[i].name);
 
             hr = IDirect3DDevice7_BeginScene(device);
-            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
             hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
                     D3DFVF_XYZ | D3DFVF_TEX1, quad, 4, 0);
-            ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
             hr = IDirect3DDevice7_EndScene(device);
-            ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
             for (y = 0; y < 4; y++)
             {
@@ -11299,7 +11299,7 @@ static void test_signed_formats(void)
                     color = get_surface_color(rt, 80 + 160 * x, 60 + 120 * y);
                     ok(compare_color(color, expected_color, formats[i].slop)
                             || broken(compare_color(color, expected_color, formats[i].slop_broken)),
-                            "Expected color 0x%08x, got 0x%08x, format %s, location %ux%u.\n",
+                            "Expected color 0x%08lx, got 0x%08lx, format %s, location %ux%u.\n",
                             expected_color, color, formats[i].name, x, y);
                 }
             }
@@ -11315,7 +11315,7 @@ static void test_signed_formats(void)
 
 done:
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -11506,9 +11506,9 @@ static void test_color_fill(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
 
     memset(&z_fmt, 0, sizeof(z_fmt));
     IDirect3D7_EnumZBufferFormats(d3d, &IID_IDirect3DHALDevice, enum_z_fmt, &z_fmt);
@@ -11522,13 +11522,13 @@ static void test_color_fill(void)
     IDirect3D7_Release(d3d);
 
     hr = IDirectDraw7_GetFourCCCodes(ddraw, &num_fourcc_codes, NULL);
-    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#lx.\n", hr);
     fourcc_codes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
             num_fourcc_codes * sizeof(*fourcc_codes));
     if (!fourcc_codes)
         goto done;
     hr = IDirectDraw7_GetFourCCCodes(ddraw, &num_fourcc_codes, fourcc_codes);
-    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get fourcc codes %#lx.\n", hr);
     for (i = 0; i < num_fourcc_codes; i++)
     {
         if (fourcc_codes[i] == MAKEFOURCC('Y', 'U', 'Y', '2'))
@@ -11541,7 +11541,7 @@ static void test_color_fill(void)
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw7_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
 
     if (!(supported_fmts & (SUPPORT_YUY2 | SUPPORT_UYVY)) || !(hal_caps.dwCaps & DDCAPS_OVERLAY))
         skip("Overlays or some YUV formats not supported, skipping YUV colorfill tests.\n");
@@ -11596,16 +11596,16 @@ static void test_color_fill(void)
         }
 
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x, surface %s.\n", hr, tests[i].name);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx, surface %s.\n", hr, tests[i].name);
 
         hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
         todo_wine_if (tests[i].format.dwFourCC)
-            ok(hr == tests[i].colorfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
+            ok(hr == tests[i].colorfill_hr, "Blt returned %#lx, expected %#lx, surface %s.\n",
                     hr, tests[i].colorfill_hr, tests[i].name);
 
         hr = IDirectDrawSurface7_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
         todo_wine_if (tests[i].format.dwFourCC)
-            ok(hr == tests[i].colorfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
+            ok(hr == tests[i].colorfill_hr, "Blt returned %#lx, expected %#lx, surface %s.\n",
                     hr, tests[i].colorfill_hr, tests[i].name);
 
         if (SUCCEEDED(hr) && tests[i].check_result)
@@ -11613,19 +11613,19 @@ static void test_color_fill(void)
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface7_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
             color = surface_desc.lpSurface;
-            ok(*color == tests[i].result, "Got clear result 0x%08x, expected 0x%08x, surface %s.\n",
+            ok(*color == tests[i].result, "Got clear result 0x%08lx, expected 0x%08lx, surface %s.\n",
                     *color, tests[i].result, tests[i].name);
             hr = IDirectDrawSurface7_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
         }
 
         hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-        ok(hr == tests[i].depthfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
+        ok(hr == tests[i].depthfill_hr, "Blt returned %#lx, expected %#lx, surface %s.\n",
                 hr, tests[i].depthfill_hr, tests[i].name);
         hr = IDirectDrawSurface7_Blt(surface, &rect, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-        ok(hr == tests[i].depthfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
+        ok(hr == tests[i].depthfill_hr, "Blt returned %#lx, expected %#lx, surface %s.\n",
                 hr, tests[i].depthfill_hr, tests[i].name);
 
         if (SUCCEEDED(hr) && tests[i].check_result)
@@ -11633,22 +11633,22 @@ static void test_color_fill(void)
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface7_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
             color = surface_desc.lpSurface;
             ok((*color & U3(z_fmt).dwZBitMask) == (tests[i].result & U3(z_fmt).dwZBitMask)
                     || broken((*color & U3(z_fmt).dwZBitMask) == (expected_broken & U3(z_fmt).dwZBitMask)),
-                    "Got clear result 0x%08x, expected 0x%08x, surface %s.\n",
+                    "Got clear result 0x%08lx, expected 0x%08lx, surface %s.\n",
                     *color & U3(z_fmt).dwZBitMask, tests[i].result & U3(z_fmt).dwZBitMask, tests[i].name);
             hr = IDirectDrawSurface7_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
         }
 
         U5(fx).dwFillColor = 0xdeadbeef;
         fx.dwROP = BLACKNESS;
         hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
-        ok(FAILED(hr) == !tests[i].rop_success, "Blt returned %#x, expected %s, surface %s.\n",
+        ok(FAILED(hr) == !tests[i].rop_success, "Blt returned %#lx, expected %s, surface %s.\n",
                 hr, tests[i].rop_success ? "success" : "failure", tests[i].name);
-        ok(U5(fx).dwFillColor == 0xdeadbeef, "dwFillColor was set to 0x%08x, surface %s\n",
+        ok(U5(fx).dwFillColor == 0xdeadbeef, "dwFillColor was set to 0x%08lx, surface %s\n",
                 U5(fx).dwFillColor, tests[i].name);
 
         if (SUCCEEDED(hr) && tests[i].check_result)
@@ -11656,19 +11656,19 @@ static void test_color_fill(void)
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface7_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
             color = surface_desc.lpSurface;
-            ok(*color == 0, "Got clear result 0x%08x, expected 0x00000000, surface %s.\n",
+            ok(*color == 0, "Got clear result 0x%08lx, expected 0x00000000, surface %s.\n",
                     *color, tests[i].name);
             hr = IDirectDrawSurface7_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
         }
 
         fx.dwROP = WHITENESS;
         hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
-        ok(FAILED(hr) == !tests[i].rop_success, "Blt returned %#x, expected %s, surface %s.\n",
+        ok(FAILED(hr) == !tests[i].rop_success, "Blt returned %#lx, expected %s, surface %s.\n",
                 hr, tests[i].rop_success ? "success" : "failure", tests[i].name);
-        ok(U5(fx).dwFillColor == 0xdeadbeef, "dwFillColor was set to 0x%08x, surface %s\n",
+        ok(U5(fx).dwFillColor == 0xdeadbeef, "dwFillColor was set to 0x%08lx, surface %s\n",
                 U5(fx).dwFillColor, tests[i].name);
 
         if (SUCCEEDED(hr) && tests[i].check_result)
@@ -11676,13 +11676,13 @@ static void test_color_fill(void)
             memset(&surface_desc, 0, sizeof(surface_desc));
             surface_desc.dwSize = sizeof(surface_desc);
             hr = IDirectDrawSurface7_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
-            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
             color = surface_desc.lpSurface;
             /* WHITENESS sets the alpha channel to 0x00. Ignore this for now. */
-            ok((*color & 0x00ffffff) == 0x00ffffff, "Got clear result 0x%08x, expected 0xffffffff, surface %s.\n",
+            ok((*color & 0x00ffffff) == 0x00ffffff, "Got clear result 0x%08lx, expected 0xffffffff, surface %s.\n",
                     *color, tests[i].name);
             hr = IDirectDrawSurface7_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, surface %s.\n", hr, tests[i].name);
         }
 
         IDirectDrawSurface7_Release(surface);
@@ -11706,78 +11706,78 @@ static void test_color_fill(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* No DDBLTFX. */
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, &rect, DDBLT_COLORFILL | DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, &rect, DDBLT_ROP | DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Unused source rectangle. */
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     /* Unused source surface. */
     hr = IDirectDrawSurface7_Blt(surface, NULL, surface2, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, surface2, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, surface2, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, surface2, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     /* Inverted destination or source rectangle. */
     SetRect(&rect, 5, 7, 7, 5);
     hr = IDirectDrawSurface7_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, &rect, surface2, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, surface2, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, surface2, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
 
     /* Negative rectangle. */
     SetRect(&rect, -1, -1, 5, 5);
     hr = IDirectDrawSurface7_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, &rect, surface2, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, &rect, surface2, &rect, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, surface2, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
 
     /* Out of bounds rectangle. */
     SetRect(&rect, 0, 0, 65, 65);
     hr = IDirectDrawSurface7_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, surface2, &rect, DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
 
     /* Combine multiple flags. */
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_ROP | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(rops); ++i)
     {
         fx.dwROP = rops[i].rop;
         hr = IDirectDrawSurface7_Blt(surface, NULL, surface2, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
-        ok(hr == rops[i].hr, "Got unexpected hr %#x for rop %s.\n", hr, rops[i].name);
+        ok(hr == rops[i].hr, "Got unexpected hr %#lx for rop %s.\n", hr, rops[i].name);
     }
 
     IDirectDrawSurface7_Release(surface2);
@@ -11794,54 +11794,54 @@ static void test_color_fill(void)
     U4(surface_desc).ddpfPixelFormat = z_fmt;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* No DDBLTFX. */
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Unused source rectangle. */
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
 
     /* Unused source surface. */
     hr = IDirectDrawSurface7_Blt(surface, NULL, surface2, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, surface2, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Inverted destination or source rectangle. */
     SetRect(&rect, 5, 7, 7, 5);
     hr = IDirectDrawSurface7_Blt(surface, &rect, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, &rect, surface2, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, surface2, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Negative rectangle. */
     SetRect(&rect, -1, -1, 5, 5);
     hr = IDirectDrawSurface7_Blt(surface, &rect, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, &rect, surface2, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, &rect, surface2, &rect, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Out of bounds rectangle. */
     SetRect(&rect, 0, 0, 65, 65);
     hr = IDirectDrawSurface7_Blt(surface, &rect, NULL, NULL, DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "Got unexpected hr %#lx.\n", hr);
 
     /* Combine multiple flags. */
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_DEPTHFILL | DDBLT_WAIT, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(surface2);
     IDirectDrawSurface7_Release(surface);
@@ -11849,7 +11849,7 @@ static void test_color_fill(void)
 done:
     IDirectDraw7_Release(ddraw);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -11898,13 +11898,13 @@ static void test_texcoordindex(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get DirectDraw7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DirectDraw7 interface, hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -11920,14 +11920,14 @@ static void test_texcoordindex(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(U4(surface_desc).ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &texture1, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &texture2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface7_Lock(texture1, 0, &surface_desc, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ptr = surface_desc.lpSurface;
     ptr[0] = 0xff000000;
     ptr[1] = 0xff00ff00;
@@ -11935,12 +11935,12 @@ static void test_texcoordindex(void)
     ptr[0] = 0xff0000ff;
     ptr[1] = 0xff00ffff;
     hr = IDirectDrawSurface7_Unlock(texture1, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface7_Lock(texture2, 0, &surface_desc, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ptr = surface_desc.lpSurface;
     ptr[0] = 0xff000000;
     ptr[1] = 0xff0000ff;
@@ -11948,101 +11948,101 @@ static void test_texcoordindex(void)
     ptr[0] = 0xffff0000;
     ptr[1] = 0xffff00ff;
     hr = IDirectDrawSurface7_Unlock(texture2, 0);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetTexture(device, 0, texture1);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTexture(device, 1, texture2);
-    ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_ADD);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 1, D3DTSS_COLORARG2, D3DTA_CURRENT);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 2, D3DTSS_COLOROP, D3DTOP_DISABLE);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_TEXCOORDINDEX, 1);
-    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 1, D3DTSS_TEXCOORDINDEX, 0);
-    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable z-buffering, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, fvf, quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 120);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 120);
-    ok(compare_color(color, 0x0000ffff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ffff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 160, 360);
-    ok(compare_color(color, 0x00ff0000, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 360);
-    ok(compare_color(color, 0x00ffffff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 2), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice7_SetTextureStageState(device, 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
-    ok(SUCCEEDED(hr), "Failed to set texture transform flags, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture transform flags, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_TEXTURE1, &mat);
-    ok(SUCCEEDED(hr), "Failed to set transformation matrix, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set transformation matrix, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, fvf, quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 120);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 120);
-    ok(compare_color(color, 0x0000ffff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ffff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 160, 360);
-    ok(compare_color(color, 0x00000000, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00000000, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 360);
-    ok(compare_color(color, 0x0000ffff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ffff, 2), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice7_SetTextureStageState(device, 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
-    ok(SUCCEEDED(hr), "Failed to set texture transform flags, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture transform flags, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 1, D3DTSS_TEXCOORDINDEX, 2);
-    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texcoord index, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffff00, 1.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, fvf, quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 120);
-    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 120);
-    ok(compare_color(color, 0x0000ffff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ffff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 160, 360);
-    ok(compare_color(color, 0x00ff00ff, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff00ff, 2), "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 360);
-    ok(compare_color(color, 0x00ffff00, 2), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffff00, 2), "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface7_Release(texture1);
     IDirectDrawSurface7_Release(texture2);
@@ -12050,7 +12050,7 @@ static void test_texcoordindex(void)
     IDirectDrawSurface7_Release(rt);
     IDirectDraw7_Release(ddraw);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -12136,12 +12136,12 @@ static void test_colorkey_precision(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     is_nvidia = ddraw_is_nvidia(ddraw);
     /* The Windows 8 WARP driver has plenty of false negatives in X8R8G8B8
@@ -12156,23 +12156,23 @@ static void test_colorkey_precision(void)
     }
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_COLORKEYENABLE, TRUE);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     /* Multiply the texture read result with 0, that way the result color if the key doesn't
      * match is constant. In theory color keying works without reading the texture result
      * (meaning we could just op=arg1, arg1=tfactor), but the Geforce7 Windows driver begs
      * to differ. */
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_MODULATE);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_TEXTUREFACTOR, 0x00000000);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
@@ -12197,9 +12197,9 @@ static void test_colorkey_precision(void)
         /* Windows XP (at least with the r200 driver, other drivers untested) produces
          * garbage when doing color keyed texture->texture blits. */
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &src, NULL);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &dst, NULL);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         U5(fx).dwFillColor = tests[t].clear;
         /* On the w8 testbot (WARP driver) the blit result has different values in the
@@ -12217,15 +12217,15 @@ static void test_colorkey_precision(void)
             surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = c << tests[t].shift;
             surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = c << tests[t].shift;
             hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &texture, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice7_SetTexture(device, 0, texture);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirectDrawSurface7_Blt(dst, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirectDrawSurface7_Lock(src, NULL, &lock_desc, DDLOCK_WAIT, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             switch (tests[t].bpp)
             {
                 case 4:
@@ -12243,21 +12243,21 @@ static void test_colorkey_precision(void)
                     break;
             }
             hr = IDirectDrawSurface7_Unlock(src, 0);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirectDrawSurface7_Blt(texture, NULL, src, NULL, DDBLT_WAIT, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             ckey.dwColorSpaceLowValue = c << tests[t].shift;
             ckey.dwColorSpaceHighValue = c << tests[t].shift;
             hr = IDirectDrawSurface7_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirectDrawSurface7_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC | DDBLT_WAIT, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             /* Don't make this read only, it somehow breaks the detection of the Nvidia bug below. */
             hr = IDirectDrawSurface7_Lock(dst, NULL, &lock_desc, DDLOCK_WAIT, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             switch (tests[t].bpp)
             {
                 case 4:
@@ -12275,11 +12275,11 @@ static void test_colorkey_precision(void)
                     break;
             }
             hr = IDirectDrawSurface7_Unlock(dst, 0);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             if (!c)
             {
-                ok(data[0] == tests[t].clear, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+                ok(data[0] == tests[t].clear, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                         tests[t].clear, data[0], tests[t].name, c);
 
                 if (data[3] == tests[t].clear)
@@ -12303,48 +12303,48 @@ static void test_colorkey_precision(void)
                 }
             }
             else
-                ok(data[0] == (c - 1) << tests[t].shift, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+                ok(data[0] == (c - 1) << tests[t].shift, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                         (c - 1) << tests[t].shift, data[0], tests[t].name, c);
 
-            ok(data[1] == tests[t].clear, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+            ok(data[1] == tests[t].clear, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                     tests[t].clear, data[1], tests[t].name, c);
 
             if (c == tests[t].max)
-                ok(data[2] == tests[t].clear, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+                ok(data[2] == tests[t].clear, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                         tests[t].clear, data[2], tests[t].name, c);
             else
-                ok(data[2] == (c + 1) << tests[t].shift, "Expected surface content %#x, got %#x, format %s, c=%u.\n",
+                ok(data[2] == (c + 1) << tests[t].shift, "Expected surface content %#x, got %#lx, format %s, c=%u.\n",
                         (c + 1) << tests[t].shift, data[2], tests[t].name, c);
 
             hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x0000ff00, 1.0f, 0);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice7_BeginScene(device);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_TEX1, quad, 4, 0);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice7_EndScene(device);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             color = get_surface_color(rt, 80, 240);
 
             if (!c)
-                ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                         color, tests[t].name, c);
             else
-                ok(compare_color(color, 0x00000000, 1), "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                ok(compare_color(color, 0x00000000, 1), "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                         color, tests[t].name, c);
 
             color = get_surface_color(rt, 240, 240);
-            ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x, format %s, c=%u.\n",
+            ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                     color, tests[t].name, c);
 
             color = get_surface_color(rt, 400, 240);
             if (c == tests[t].max)
-                ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                         color, tests[t].name, c);
             else
-                ok(compare_color(color, 0x00000000, 1), "Got unexpected color 0x%08x, format %s, c=%u.\n",
+                ok(compare_color(color, 0x00000000, 1), "Got unexpected color 0x%08lx, format %s, c=%u.\n",
                         color, tests[t].name, c);
 
             IDirectDrawSurface7_Release(texture);
@@ -12357,7 +12357,7 @@ done:
     IDirectDrawSurface7_Release(rt);
     IDirectDraw7_Release(ddraw);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -12375,7 +12375,7 @@ static void test_range_colorkey(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -12394,85 +12394,85 @@ static void test_range_colorkey(void)
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000000;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000001;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     /* Same for DDSCAPS_OFFSCREENPLAIN. */
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000000;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000001;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00000000;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     /* Setting a range color key without DDCKEY_COLORSPACE collapses the key. */
     ckey.dwColorSpaceLowValue = 0x00000000;
     ckey.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDrawSurface7_SetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_GetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(!ckey.dwColorSpaceLowValue, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceLowValue);
-    ok(!ckey.dwColorSpaceHighValue, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(!ckey.dwColorSpaceLowValue, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceLowValue);
+    ok(!ckey.dwColorSpaceHighValue, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceHighValue);
 
     ckey.dwColorSpaceLowValue = 0x00000001;
     ckey.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDrawSurface7_SetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_GetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(ckey.dwColorSpaceLowValue == 0x00000001, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceLowValue);
-    ok(ckey.dwColorSpaceHighValue == 0x00000001, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(ckey.dwColorSpaceLowValue == 0x00000001, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceLowValue);
+    ok(ckey.dwColorSpaceHighValue == 0x00000001, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceHighValue);
 
     /* DDCKEY_COLORSPACE is ignored if the key is a single value. */
     ckey.dwColorSpaceLowValue = 0x00000000;
     ckey.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDrawSurface7_SetColorKey(surface, DDCKEY_SRCBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     /* Using it with a range key results in DDERR_NOCOLORKEYHW. */
     ckey.dwColorSpaceLowValue = 0x00000001;
     ckey.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDrawSurface7_SetColorKey(surface, DDCKEY_SRCBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
     ckey.dwColorSpaceLowValue = 0x00000000;
     ckey.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDrawSurface7_SetColorKey(surface, DDCKEY_SRCBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
     /* Range destination keys don't work either. */
     hr = IDirectDrawSurface7_SetColorKey(surface, DDCKEY_DESTBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     /* Just to show it's not because of A, R, and G having equal values. */
     ckey.dwColorSpaceLowValue = 0x00000000;
     ckey.dwColorSpaceHighValue = 0x01010101;
     hr = IDirectDrawSurface7_SetColorKey(surface, DDCKEY_SRCBLT | DDCKEY_COLORSPACE, &ckey);
-    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEYHW, "Got unexpected hr %#lx.\n", hr);
 
     /* None of these operations modified the key. */
     hr = IDirectDrawSurface7_GetColorKey(surface, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
-    ok(!ckey.dwColorSpaceLowValue, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceLowValue);
-    ok(!ckey.dwColorSpaceHighValue, "Got unexpected value 0x%08x.\n", ckey.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
+    ok(!ckey.dwColorSpaceLowValue, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceLowValue);
+    ok(!ckey.dwColorSpaceHighValue, "Got unexpected value 0x%08lx.\n", ckey.dwColorSpaceHighValue);
 
     IDirectDrawSurface7_Release(surface);
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -12536,14 +12536,14 @@ static void test_shademode(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Failed to disable lighting, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to disable lighting, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#lx.\n", hr);
 
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
@@ -12551,21 +12551,21 @@ static void test_shademode(void)
     desc.dwFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE;
     desc.dwNumVertices = ARRAY_SIZE(quad_strip);
     hr = IDirect3D7_CreateVertexBuffer(d3d, &desc, &vb_strip, 0);
-    ok(hr == D3D_OK, "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create vertex buffer, hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer7_Lock(vb_strip, 0, &data, NULL);
-    ok(hr == D3D_OK, "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to lock vertex buffer, hr %#lx.\n", hr);
     memcpy(data, quad_strip, sizeof(quad_strip));
     hr = IDirect3DVertexBuffer7_Unlock(vb_strip);
-    ok(hr == D3D_OK, "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     desc.dwNumVertices = ARRAY_SIZE(quad_list);
     hr = IDirect3D7_CreateVertexBuffer(d3d, &desc, &vb_list, 0);
-    ok(hr == D3D_OK, "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to create vertex buffer, hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer7_Lock(vb_list, 0, &data, NULL);
-    ok(hr == D3D_OK, "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to lock vertex buffer, hr %#lx.\n", hr);
     memcpy(data, quad_list, sizeof(quad_list));
     hr = IDirect3DVertexBuffer7_Unlock(vb_list);
-    ok(hr == D3D_OK, "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     /* Try it first with a TRIANGLESTRIP.  Do it with different geometry because
      * the color fixups we have to do for FLAT shading will be dependent on that. */
@@ -12573,19 +12573,19 @@ static void test_shademode(void)
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-        ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to clear, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SHADEMODE, tests[i].shademode);
-        ok(hr == D3D_OK, "Failed to set shade mode, hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Failed to set shade mode, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         buffer = tests[i].primtype == D3DPT_TRIANGLESTRIP ? vb_strip : vb_list;
         count = tests[i].primtype == D3DPT_TRIANGLESTRIP ? 4 : 6;
         hr = IDirect3DDevice7_DrawPrimitiveVB(device, tests[i].primtype, buffer, 0, count, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         color0 = get_surface_color(rt, 100, 100); /* Inside first triangle */
         color1 = get_surface_color(rt, 500, 350); /* Inside second triangle */
@@ -12595,9 +12595,9 @@ static void test_shademode(void)
          * functionality being available. */
         /* PHONG should be the same as GOURAUD, since no hardware implements
          * this. */
-        ok(compare_color(color0, tests[i].color0, 1), "Test %u shading has color0 %08x, expected %08x.\n",
+        ok(compare_color(color0, tests[i].color0, 1), "Test %u shading has color0 %08lx, expected %08lx.\n",
                 i, color0, tests[i].color0);
-        ok(compare_color(color1, tests[i].color1, 1), "Test %u shading has color1 %08x, expected %08x.\n",
+        ok(compare_color(color1, tests[i].color1, 1), "Test %u shading has color1 %08lx, expected %08lx.\n",
                 i, color1, tests[i].color1);
     }
 
@@ -12606,7 +12606,7 @@ static void test_shademode(void)
     IDirectDrawSurface7_Release(rt);
     IDirect3D7_Release(d3d);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -12670,12 +12670,12 @@ static void test_lockrect_invalid(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hr = IDirectDraw7_GetCaps(ddraw, &hal_caps, NULL);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     if ((hal_caps.ddsCaps.dwCaps & needed_caps) != needed_caps
             || !(hal_caps.ddsCaps.dwCaps & DDSCAPS2_TEXTUREMANAGE))
     {
@@ -12702,17 +12702,17 @@ static void test_lockrect_invalid(void)
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
         if (!resources[r].allowed)
         {
-            ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name);
+            ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#lx, type %s.\n", hr, resources[r].name);
             continue;
         }
         if (is_ddraw64 && (resources[r].caps & DDSCAPS_TEXTURE))
         {
-            todo_wine ok(hr == E_NOINTERFACE, "Got unexpected hr %#x, type %s.\n", hr, resources[r].name);
+            todo_wine ok(hr == E_NOINTERFACE, "Got unexpected hr %#lx, type %s.\n", hr, resources[r].name);
             if (SUCCEEDED(hr))
                 IDirectDrawSurface7_Release(surface);
             continue;
         }
-        ok(SUCCEEDED(hr), "Failed to create surface, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx, type %s.\n", hr, resources[r].name);
 
         /* Crashes in ddraw7
         hr = IDirectDrawSurface7_Lock(surface, NULL, NULL, DDLOCK_WAIT, NULL);
@@ -12727,11 +12727,11 @@ static void test_lockrect_invalid(void)
             locked_desc.dwSize = sizeof(locked_desc);
 
             hr = IDirectDrawSurface7_Lock(surface, rect, &locked_desc, DDLOCK_WAIT, NULL);
-            ok(SUCCEEDED(hr), "Lock failed (%#x) for rect %s, type %s.\n",
+            ok(SUCCEEDED(hr), "Lock failed (%#lx) for rect %s, type %s.\n",
                     hr, wine_dbgstr_rect(rect), resources[r].name);
 
             hr = IDirectDrawSurface7_Unlock(surface, NULL);
-            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+            ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
         }
 
         for (i = 0; i < ARRAY_SIZE(invalid); ++i)
@@ -12743,37 +12743,37 @@ static void test_lockrect_invalid(void)
 
             hr = IDirectDrawSurface7_Lock(surface, rect, &locked_desc, DDLOCK_WAIT, NULL);
             todo_wine_if (SUCCEEDED(resources[r].hr))
-                ok(hr == resources[r].hr, "Lock returned %#x for rect %s, type %s.\n",
+                ok(hr == resources[r].hr, "Lock returned %#lx for rect %s, type %s.\n",
                         hr, wine_dbgstr_rect(rect), resources[r].name);
             if (SUCCEEDED(hr))
             {
                 hr = IDirectDrawSurface7_Unlock(surface, NULL);
-                ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+                ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
             }
             else
                 ok(!locked_desc.lpSurface, "Got unexpected lpSurface %p.\n", locked_desc.lpSurface);
         }
 
         hr = IDirectDrawSurface7_Lock(surface, NULL, &locked_desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Lock(rect = NULL) failed, hr %#x, type %s.\n",
+        ok(SUCCEEDED(hr), "Lock(rect = NULL) failed, hr %#lx, type %s.\n",
                 hr, resources[r].name);
         hr = IDirectDrawSurface7_Lock(surface, NULL, &locked_desc, DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_SURFACEBUSY, "Double lock(rect = NULL) returned %#x, type %s.\n",
+        ok(hr == DDERR_SURFACEBUSY, "Double lock(rect = NULL) returned %#lx, type %s.\n",
                 hr, resources[r].name);
         hr = IDirectDrawSurface7_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
 
         hr = IDirectDrawSurface7_Lock(surface, &valid[0], &locked_desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Lock(rect = %s) failed (%#x).\n", wine_dbgstr_rect(&valid[0]), hr);
+        ok(SUCCEEDED(hr), "Lock(rect = %s) failed (%#lx).\n", wine_dbgstr_rect(&valid[0]), hr);
         hr = IDirectDrawSurface7_Lock(surface, &valid[0], &locked_desc, DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_SURFACEBUSY, "Double lock(rect = %s) failed (%#x).\n",
+        ok(hr == DDERR_SURFACEBUSY, "Double lock(rect = %s) failed (%#lx).\n",
                 wine_dbgstr_rect(&valid[0]), hr);
 
         /* Locking a different rectangle returns DD_OK, but it seems to break the surface.
          * Afterwards unlocking the surface fails(NULL rectangle or both locked rectangles) */
 
         hr = IDirectDrawSurface7_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, type %s.\n", hr, resources[r].name);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx, type %s.\n", hr, resources[r].name);
 
         IDirectDrawSurface7_Release(surface);
     }
@@ -12798,7 +12798,7 @@ static void test_yv12_overlay(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     if (!(src_surface = create_overlay(ddraw, 256, 256, MAKEFOURCC('Y','V','1','2'))))
     {
@@ -12809,17 +12809,17 @@ static void test_yv12_overlay(void)
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
     hr = IDirectDrawSurface7_Lock(src_surface, NULL, &desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
 
     ok(desc.dwFlags == (DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS | DDSD_PITCH),
-            "Got unexpected flags %#x.\n", desc.dwFlags);
+            "Got unexpected flags %#lx.\n", desc.dwFlags);
     ok(desc.ddsCaps.dwCaps == (DDSCAPS_OVERLAY | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM | DDSCAPS_HWCODEC)
             || desc.ddsCaps.dwCaps == (DDSCAPS_OVERLAY | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM),
-            "Got unexpected caps %#x.\n", desc.ddsCaps.dwCaps);
-    ok(desc.dwWidth == 256, "Got unexpected width %u.\n", desc.dwWidth);
-    ok(desc.dwHeight == 256, "Got unexpected height %u.\n", desc.dwHeight);
+            "Got unexpected caps %#lx.\n", desc.ddsCaps.dwCaps);
+    ok(desc.dwWidth == 256, "Got unexpected width %lu.\n", desc.dwWidth);
+    ok(desc.dwHeight == 256, "Got unexpected height %lu.\n", desc.dwHeight);
     /* The overlay pitch seems to have 256 byte alignment. */
-    ok(!(U1(desc).lPitch & 0xff), "Got unexpected pitch %u.\n", U1(desc).lPitch);
+    ok(!(U1(desc).lPitch & 0xff), "Got unexpected pitch %lu.\n", U1(desc).lPitch);
 
     /* Fill the surface with some data for the blit test. */
     base = desc.lpSurface;
@@ -12840,7 +12840,7 @@ static void test_yv12_overlay(void)
     }
 
     hr = IDirectDrawSurface7_Unlock(src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* YV12 uses 2x2 blocks with 6 bytes per block (4*Y, 1*U, 1*V). Unlike
      * other block-based formats like DXT the entire Y channel is stored in
@@ -12848,12 +12848,12 @@ static void test_yv12_overlay(void)
      * locks do not really make sense. Show that they are allowed nevertheless
      * and the offset points into the luminance data. */
     hr = IDirectDrawSurface7_Lock(src_surface, &rect, &desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     offset = ((const unsigned char *)desc.lpSurface - base);
-    ok(offset == rect.top * U1(desc).lPitch + rect.left, "Got unexpected offset %u, expected %u.\n",
+    ok(offset == rect.top * U1(desc).lPitch + rect.left, "Got unexpected offset %u, expected %lu.\n",
             offset, rect.top * U1(desc).lPitch + rect.left);
     hr = IDirectDrawSurface7_Unlock(src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     if (!(dst_surface = create_overlay(ddraw, 256, 256, MAKEFOURCC('Y','V','1','2'))))
     {
@@ -12867,14 +12867,14 @@ static void test_yv12_overlay(void)
     hr = IDirectDrawSurface7_Blt(dst_surface, NULL, src_surface, NULL, DDBLT_WAIT, NULL);
     /* VMware rejects YV12 blits. This behavior has not been seen on real
      * hardware yet, so mark it broken. */
-    ok(SUCCEEDED(hr) || broken(hr == E_NOTIMPL), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(hr == E_NOTIMPL), "Failed to blit, hr %#lx.\n", hr);
 
     if (SUCCEEDED(hr))
     {
         memset(&desc, 0, sizeof(desc));
         desc.dwSize = sizeof(desc);
         hr = IDirectDrawSurface7_Lock(dst_surface, NULL, &desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
 
         base = desc.lpSurface;
         ok(base[0] == 0x10, "Got unexpected Y data 0x%02x.\n", base[0]);
@@ -12884,7 +12884,7 @@ static void test_yv12_overlay(void)
         ok(base[0] == 0x30, "Got unexpected U data 0x%02x.\n", base[0]);
 
         hr = IDirectDrawSurface7_Unlock(dst_surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
     }
 
     IDirectDrawSurface7_Release(dst_surface);
@@ -12920,7 +12920,7 @@ static void test_offscreen_overlay(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     if (!(overlay = create_overlay(ddraw, 64, 64, MAKEFOURCC('U','Y','V','Y'))))
     {
@@ -12933,21 +12933,21 @@ static void test_offscreen_overlay(void)
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     /* On Windows 7, and probably Vista, UpdateOverlay() will return
      * DDERR_OUTOFCAPS if the dwm is active. Calling GetDC() on the primary
      * surface prevents this by disabling the dwm. */
     hr = IDirectDrawSurface7_GetDC(primary, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_ReleaseDC(primary, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     /* Try to overlay a NULL surface. */
     hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_SHOW, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, NULL, NULL, DDOVER_HIDE, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Try to overlay an offscreen surface. */
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -12964,18 +12964,18 @@ static void test_offscreen_overlay(void)
     U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x07e0;
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x001f;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &offscreen, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, offscreen, NULL, DDOVER_SHOW, NULL);
     ok(SUCCEEDED(hr) || broken(hr == DDERR_OUTOFCAPS && dwm_enabled())
             || broken(hr == E_NOTIMPL && ddraw_is_vmware(ddraw)),
-            "Failed to update overlay, hr %#x.\n", hr);
+            "Failed to update overlay, hr %#lx.\n", hr);
 
     /* Try to overlay the primary with a non-overlay surface. */
     hr = IDirectDrawSurface7_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_SHOW, NULL);
-    ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_UpdateOverlay(offscreen, NULL, primary, NULL, DDOVER_HIDE, NULL);
-    ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTAOVERLAYSURFACE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(offscreen);
     IDirectDrawSurface7_Release(primary);
@@ -13000,7 +13000,7 @@ static void test_overlay_rect(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     if (!(overlay = create_overlay(ddraw, 64, 64, MAKEFOURCC('U','Y','V','Y'))))
     {
@@ -13013,15 +13013,15 @@ static void test_overlay_rect(void)
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n",hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n",hr);
 
     /* On Windows 7, and probably Vista, UpdateOverlay() will return
      * DDERR_OUTOFCAPS if the dwm is active. Calling GetDC() on the primary
      * surface prevents this by disabling the dwm. */
     hr = IDirectDrawSurface7_GetDC(primary, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_ReleaseDC(primary, dc);
-    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#lx.\n", hr);
 
     /* On Windows 8 and newer DWM can't be turned off, making overlays unusable. */
     if (dwm_enabled())
@@ -13034,48 +13034,48 @@ static void test_overlay_rect(void)
      * used. This is not true in Windows Vista and earlier, but changed in
      * Windows 7. */
     hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, primary, &rect, DDOVER_SHOW, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, primary, NULL, DDOVER_HIDE, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, primary, NULL, DDOVER_SHOW, NULL);
-    ok(hr == DD_OK || hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Show that the overlay position is the (top, left) coordinate of the
      * destination rectangle. */
     OffsetRect(&rect, 32, 16);
     hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, primary, &rect, DDOVER_SHOW, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#lx.\n", hr);
     pos_x = -1; pos_y = -1;
     hr = IDirectDrawSurface7_GetOverlayPosition(overlay, &pos_x, &pos_y);
-    ok(SUCCEEDED(hr), "Failed to get overlay position, hr %#x.\n", hr);
-    ok(pos_x == rect.left, "Got unexpected pos_x %d, expected %d.\n", pos_x, rect.left);
-    ok(pos_y == rect.top, "Got unexpected pos_y %d, expected %d.\n", pos_y, rect.top);
+    ok(SUCCEEDED(hr), "Failed to get overlay position, hr %#lx.\n", hr);
+    ok(pos_x == rect.left, "Got unexpected pos_x %ld, expected %ld.\n", pos_x, rect.left);
+    ok(pos_y == rect.top, "Got unexpected pos_y %ld, expected %ld.\n", pos_y, rect.top);
 
     /* Passing a NULL dest rect sets the position to 0/0. Visually it can be
      * seen that the overlay overlays the whole primary(==screen). */
     hr2 = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, primary, NULL, 0, NULL);
-    ok(hr2 == DD_OK || hr2 == DDERR_INVALIDPARAMS || hr2 == DDERR_OUTOFCAPS, "Got unexpected hr %#x.\n", hr2);
+    ok(hr2 == DD_OK || hr2 == DDERR_INVALIDPARAMS || hr2 == DDERR_OUTOFCAPS, "Got unexpected hr %#lx.\n", hr2);
     hr = IDirectDrawSurface7_GetOverlayPosition(overlay, &pos_x, &pos_y);
-    ok(SUCCEEDED(hr), "Failed to get overlay position, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get overlay position, hr %#lx.\n", hr);
     if (SUCCEEDED(hr2))
     {
-        ok(!pos_x, "Got unexpected pos_x %d.\n", pos_x);
-        ok(!pos_y, "Got unexpected pos_y %d.\n", pos_y);
+        ok(!pos_x, "Got unexpected pos_x %ld.\n", pos_x);
+        ok(!pos_y, "Got unexpected pos_y %ld.\n", pos_y);
     }
     else
     {
-        ok(pos_x == 32, "Got unexpected pos_x %d.\n", pos_x);
-        ok(pos_y == 16, "Got unexpected pos_y %d.\n", pos_y);
+        ok(pos_x == 32, "Got unexpected pos_x %ld.\n", pos_x);
+        ok(pos_y == 16, "Got unexpected pos_y %ld.\n", pos_y);
     }
 
     /* The position cannot be retrieved when the overlay is not shown. */
     hr = IDirectDrawSurface7_UpdateOverlay(overlay, NULL, primary, &rect, DDOVER_HIDE, NULL);
-    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to update overlay, hr %#lx.\n", hr);
     pos_x = -1; pos_y = -1;
     hr = IDirectDrawSurface7_GetOverlayPosition(overlay, &pos_x, &pos_y);
-    ok(hr == DDERR_OVERLAYNOTVISIBLE, "Got unexpected hr %#x.\n", hr);
-    ok(!pos_x, "Got unexpected pos_x %d.\n", pos_x);
-    ok(!pos_y, "Got unexpected pos_y %d.\n", pos_y);
+    ok(hr == DDERR_OVERLAYNOTVISIBLE, "Got unexpected hr %#lx.\n", hr);
+    ok(!pos_x, "Got unexpected pos_x %ld.\n", pos_x);
+    ok(!pos_y, "Got unexpected pos_y %ld.\n", pos_y);
 
 done:
     if (primary)
@@ -13127,12 +13127,12 @@ static void test_blt(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get DirectDraw7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DirectDraw7 interface, hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -13141,37 +13141,37 @@ static void test_blt(void)
     surface_desc.dwHeight = 480;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Blt(surface, NULL, surface, NULL, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Blt(surface, NULL, rt, NULL, 0, NULL);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirectDrawSurface7_Blt(surface, &test_data[i].dst_rect,
                 surface, &test_data[i].src_rect, DDBLT_WAIT, NULL);
-        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
 
         hr = IDirectDrawSurface7_Blt(surface, &test_data[i].dst_rect,
                 rt, &test_data[i].src_rect, DDBLT_WAIT, NULL);
-        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
+        ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#lx, expected %#lx.\n", i, hr, test_data[i].hr);
 
         hr = IDirectDrawSurface7_Blt(surface, &test_data[i].dst_rect,
                 NULL, &test_data[i].src_rect, DDBLT_WAIT, NULL);
-        ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirectDrawSurface7_Blt(surface, &test_data[i].dst_rect, NULL, NULL, DDBLT_WAIT, NULL);
-        ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#lx.\n", i, hr);
     }
 
     IDirectDrawSurface7_Release(surface);
     IDirectDrawSurface7_Release(rt);
     IDirectDraw7_Release(ddraw);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -13212,7 +13212,7 @@ static void test_blt_z_alpha(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&pf, 0, sizeof(pf));
     pf.dwSize = sizeof(pf);
@@ -13232,9 +13232,9 @@ static void test_blt_z_alpha(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#lx.\n", hr);
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &dst_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
@@ -13254,23 +13254,23 @@ static void test_blt_z_alpha(void)
     {
         U5(fx).dwFillColor = 0x3300ff00;
         hr = IDirectDrawSurface7_Blt(src_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         U5(fx).dwFillColor = 0xccff0000;
         hr = IDirectDrawSurface7_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirectDrawSurface7_Blt(dst_surface, NULL, src_surface, NULL, blt_flags[i] | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         color = get_surface_color(dst_surface, 32, 32);
-        ok(compare_color(color, 0x0000ff00, 0), "Test %u: Got unexpected color 0x%08x.\n", i, color);
+        ok(compare_color(color, 0x0000ff00, 0), "Test %u: Got unexpected color 0x%08lx.\n", i, color);
     }
 
     IDirectDrawSurface7_Release(dst_surface);
     IDirectDrawSurface7_Release(src_surface);
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -13306,15 +13306,15 @@ static void test_cross_device_blt(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get DirectDraw7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DirectDraw7 interface, hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
 
     hr = IDirect3DDevice7_GetDirect3D(device2, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw2);
-    ok(SUCCEEDED(hr), "Failed to get DirectDraw7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DirectDraw7 interface, hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -13324,7 +13324,7 @@ static void test_cross_device_blt(void)
     surface_desc.dwHeight = 480;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &sysmem_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -13332,7 +13332,7 @@ static void test_cross_device_blt(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_VIDEOMEMORY;
     U5(surface_desc).dwBackBufferCount = 2;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -13347,37 +13347,37 @@ static void test_cross_device_blt(void)
     U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x000003e0;
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x0000001f;
     hr = IDirectDraw7_CreateSurface(ddraw2, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
     U5(fx).dwFillColor = 0xff0000ff;
     hr = IDirectDrawSurface7_Blt(surface2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Blt(surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Flip(surface, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(surface, 320, 240);
-    ok(color == 0x00000000, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00000000, "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirectDrawSurface7_Blt(sysmem_surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(sysmem_surface, 320, 240);
-    ok(color == 0x00000000, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00000000, "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_IsLost(sysmem_surface);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Blt(sysmem_surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    ok(hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     color = get_surface_color(sysmem_surface, 320, 240);
-    ok(color == 0x00000000, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0x00000000, "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface7_Release(surface2);
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -13387,14 +13387,14 @@ static void test_cross_device_blt(void)
     surface_desc.dwHeight = 480;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw7_CreateSurface(ddraw2, &surface_desc, &surface2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(surface2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to fill surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Blt(sysmem_surface, NULL, surface2, NULL, DDBLT_WAIT, NULL);
-    todo_wine ok(hr == D3D_OK, "Failed to blit, hr %#x.\n", hr);
+    todo_wine ok(hr == D3D_OK, "Failed to blit, hr %#lx.\n", hr);
     color = get_surface_color(sysmem_surface, 320, 240);
-    todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
+    todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface7_Release(surface);
     IDirectDrawSurface7_Release(surface2);
@@ -13402,9 +13402,9 @@ static void test_cross_device_blt(void)
     IDirectDraw7_Release(ddraw);
     IDirectDraw7_Release(ddraw2);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     refcount = IDirect3DDevice7_Release(device2);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
     DestroyWindow(window2);
 }
@@ -13441,60 +13441,60 @@ static void test_color_clamping(void)
     }
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat);
-    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_STENCILENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
-    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_TEXTUREFACTOR, 0xff404040);
-    ok(SUCCEEDED(hr), "Failed to set texture factor, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set texture factor, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_ADD);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_SPECULAR);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 1, D3DTSS_COLOROP, D3DTOP_MODULATE);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 1, D3DTSS_COLORARG1, D3DTA_TFACTOR);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 1, D3DTSS_COLORARG2, D3DTA_CURRENT);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 320, 240);
-    ok(compare_color(color, 0x00404040, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00404040, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface7_Release(rt);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -13566,11 +13566,11 @@ static void test_getdc(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw7_GetDisplayMode(ddraw, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get display mode, hr %#lx.\n", hr);
     screen_bpp = U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount;
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
@@ -13589,7 +13589,7 @@ static void test_getdc(void)
             surface_desc.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE;
             if (FAILED(hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL)))
             {
-                skip("Failed to create surface for format %s (hr %#x), skipping tests.\n", test_data[i].name, hr);
+                skip("Failed to create surface for format %s (hr %#lx), skipping tests.\n", test_data[i].name, hr);
                 continue;
             }
         }
@@ -13598,9 +13598,9 @@ static void test_getdc(void)
         hr = IDirectDrawSurface7_GetDC(surface, &dc);
         if (test_data[i].getdc_supported)
             ok(SUCCEEDED(hr) || broken(hr == test_data[i].alt_result),
-                    "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+                    "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         else
-            ok(FAILED(hr), "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+            ok(FAILED(hr), "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         if (SUCCEEDED(hr))
         {
@@ -13611,10 +13611,10 @@ static void test_getdc(void)
             int size;
 
             type = GetObjectType(dc);
-            ok(type == OBJ_MEMDC, "Got unexpected object type %#x for format %s.\n", type, test_data[i].name);
+            ok(type == OBJ_MEMDC, "Got unexpected object type %#lx for format %s.\n", type, test_data[i].name);
             bitmap = GetCurrentObject(dc, OBJ_BITMAP);
             type = GetObjectType(bitmap);
-            ok(type == OBJ_BITMAP, "Got unexpected object type %#x for format %s.\n", type, test_data[i].name);
+            ok(type == OBJ_BITMAP, "Got unexpected object type %#lx for format %s.\n", type, test_data[i].name);
 
             size = GetObjectA(bitmap, sizeof(dib), &dib);
             ok(size == sizeof(dib), "Got unexpected size %d for format %s.\n", size, test_data[i].name);
@@ -13638,11 +13638,11 @@ static void test_getdc(void)
             ok(!!dib.dsBm.bmBits || broken(!pDwmIsCompositionEnabled && dib.dsBm.bmBitsPixel == screen_bpp),
                     "Got unexpected bits %p for format %s.\n", dib.dsBm.bmBits, test_data[i].name);
 
-            ok(dib.dsBmih.biSize == sizeof(dib.dsBmih), "Got unexpected size %u for format %s.\n",
+            ok(dib.dsBmih.biSize == sizeof(dib.dsBmih), "Got unexpected size %lu for format %s.\n",
                     dib.dsBmih.biSize, test_data[i].name);
-            ok(dib.dsBmih.biWidth == surface_desc.dwWidth, "Got unexpected width %d for format %s.\n",
+            ok(dib.dsBmih.biWidth == surface_desc.dwWidth, "Got unexpected width %ld for format %s.\n",
                     dib.dsBmih.biHeight, test_data[i].name);
-            ok(dib.dsBmih.biHeight == surface_desc.dwHeight, "Got unexpected height %d for format %s.\n",
+            ok(dib.dsBmih.biHeight == surface_desc.dwHeight, "Got unexpected height %ld for format %s.\n",
                     dib.dsBmih.biHeight, test_data[i].name);
             ok(dib.dsBmih.biPlanes == 1, "Got unexpected plane count %u for format %s.\n",
                     dib.dsBmih.biPlanes, test_data[i].name);
@@ -13651,17 +13651,17 @@ static void test_getdc(void)
                     dib.dsBmih.biBitCount, test_data[i].name);
             ok(dib.dsBmih.biCompression == (U1(test_data[i].format).dwRGBBitCount == 16 ? BI_BITFIELDS : BI_RGB)
                     || broken(U1(test_data[i].format).dwRGBBitCount == 32 && dib.dsBmih.biCompression == BI_BITFIELDS),
-                    "Got unexpected compression %#x for format %s.\n",
+                    "Got unexpected compression %#lx for format %s.\n",
                     dib.dsBmih.biCompression, test_data[i].name);
-            ok(!dib.dsBmih.biSizeImage, "Got unexpected image size %u for format %s.\n",
+            ok(!dib.dsBmih.biSizeImage, "Got unexpected image size %lu for format %s.\n",
                     dib.dsBmih.biSizeImage, test_data[i].name);
-            ok(!dib.dsBmih.biXPelsPerMeter, "Got unexpected horizontal resolution %d for format %s.\n",
+            ok(!dib.dsBmih.biXPelsPerMeter, "Got unexpected horizontal resolution %ld for format %s.\n",
                     dib.dsBmih.biXPelsPerMeter, test_data[i].name);
-            ok(!dib.dsBmih.biYPelsPerMeter, "Got unexpected vertical resolution %d for format %s.\n",
+            ok(!dib.dsBmih.biYPelsPerMeter, "Got unexpected vertical resolution %ld for format %s.\n",
                     dib.dsBmih.biYPelsPerMeter, test_data[i].name);
-            ok(!dib.dsBmih.biClrUsed, "Got unexpected used colour count %u for format %s.\n",
+            ok(!dib.dsBmih.biClrUsed, "Got unexpected used colour count %lu for format %s.\n",
                     dib.dsBmih.biClrUsed, test_data[i].name);
-            ok(!dib.dsBmih.biClrImportant, "Got unexpected important colour count %u for format %s.\n",
+            ok(!dib.dsBmih.biClrImportant, "Got unexpected important colour count %lu for format %s.\n",
                     dib.dsBmih.biClrImportant, test_data[i].name);
 
             if (dib.dsBmih.biCompression == BI_BITFIELDS)
@@ -13670,20 +13670,20 @@ static void test_getdc(void)
                         && dib.dsBitfields[1] == U3(test_data[i].format).dwGBitMask
                         && dib.dsBitfields[2] == U4(test_data[i].format).dwBBitMask)
                         || broken(!dib.dsBitfields[0] && !dib.dsBitfields[1] && !dib.dsBitfields[2]),
-                        "Got unexpected colour masks 0x%08x 0x%08x 0x%08x for format %s.\n",
+                        "Got unexpected colour masks 0x%08lx 0x%08lx 0x%08lx for format %s.\n",
                         dib.dsBitfields[0], dib.dsBitfields[1], dib.dsBitfields[2], test_data[i].name);
             }
             else
             {
                 ok(!dib.dsBitfields[0] && !dib.dsBitfields[1] && !dib.dsBitfields[2],
-                        "Got unexpected colour masks 0x%08x 0x%08x 0x%08x for format %s.\n",
+                        "Got unexpected colour masks 0x%08lx 0x%08lx 0x%08lx for format %s.\n",
                         dib.dsBitfields[0], dib.dsBitfields[1], dib.dsBitfields[2], test_data[i].name);
             }
             ok(!dib.dshSection, "Got unexpected section %p for format %s.\n", dib.dshSection, test_data[i].name);
-            ok(!dib.dsOffset, "Got unexpected offset %u for format %s.\n", dib.dsOffset, test_data[i].name);
+            ok(!dib.dsOffset, "Got unexpected offset %lu for format %s.\n", dib.dsOffset, test_data[i].name);
 
             hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-            ok(hr == DD_OK, "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+            ok(hr == DD_OK, "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         }
         else
         {
@@ -13699,149 +13699,149 @@ static void test_getdc(void)
         surface_desc.ddsCaps.dwCaps2 = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_ALLFACES | DDSCAPS2_TEXTUREMANAGE;
         if (FAILED(hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL)))
         {
-            skip("Failed to create cube texture for format %s (hr %#x), skipping tests.\n", test_data[i].name, hr);
+            skip("Failed to create cube texture for format %s (hr %#lx), skipping tests.\n", test_data[i].name, hr);
             continue;
         }
 
         hr = IDirectDrawSurface7_GetAttachedSurface(surface, &caps, &surface2);
-        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_GetAttachedSurface(surface2, &caps, &tmp);
-        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         IDirectDrawSurface7_Release(surface2);
         hr = IDirectDrawSurface7_GetAttachedSurface(tmp, &caps, &surface2);
-        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get attached surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         IDirectDrawSurface7_Release(tmp);
 
         hr = IDirectDrawSurface7_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface7_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         dc2 = (void *)0x1234;
         hr = IDirectDrawSurface7_GetDC(surface, &dc2);
-        ok(hr == DDERR_DCALREADYCREATED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_DCALREADYCREATED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         ok(dc2 == (void *)0x1234, "Got unexpected dc %p for format %s.\n", dc, test_data[i].name);
         hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-        ok(hr == DDERR_NODC, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NODC, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         map_desc.dwSize = sizeof(map_desc);
         hr = IDirectDrawSurface7_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_SURFACEBUSY, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_SURFACEBUSY, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface7_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Unlock(surface, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         hr = IDirectDrawSurface7_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(hr == DDERR_SURFACEBUSY, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_SURFACEBUSY, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface7_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface7_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_GetDC(surface2, &dc2);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_ReleaseDC(surface2, dc2);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface7_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_GetDC(surface, &dc2);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_ReleaseDC(surface, dc2);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface7_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Lock(surface2, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Unlock(surface2, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface7_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface7_Lock(surface2, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Unlock(surface2, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface7_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Lock(surface2, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Unlock(surface2, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface7_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Lock(surface, NULL, &map_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to map surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to unmap surface for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
 
         hr = IDirectDrawSurface7_Unlock(surface, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface7_GetDC(surface2, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Unlock(surface, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface7_ReleaseDC(surface2, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Unlock(surface, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         hr = IDirectDrawSurface7_Unlock(surface2, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface7_GetDC(surface, &dc);
-        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to get DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Unlock(surface2, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
         hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#x.\n", test_data[i].name, hr);
+        ok(SUCCEEDED(hr), "Failed to release DC for format %s, hr %#lx.\n", test_data[i].name, hr);
         hr = IDirectDrawSurface7_Unlock(surface2, NULL);
-        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#x for format %s.\n", hr, test_data[i].name);
+        ok(hr == DDERR_NOTLOCKED, "Got unexpected hr %#lx for format %s.\n", hr, test_data[i].name);
 
         IDirectDrawSurface7_Release(surface2);
         IDirectDrawSurface7_Release(surface);
@@ -13881,84 +13881,84 @@ static void test_draw_primitive(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get D3D interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get D3D interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get DirectDraw7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DirectDraw7 interface, hr %#lx.\n", hr);
 
     memset(&vb_desc, 0, sizeof(vb_desc));
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwFVF = D3DFVF_XYZ;
     vb_desc.dwNumVertices = 4;
     hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &vb, 0);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
 
     IDirect3D7_Release(d3d);
 
     memset(&strided, 0, sizeof(strided));
 
     hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, NULL, 0, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawIndexedPrimitiveStrided(device,
             D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, &strided, 0, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawIndexedPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, 0, 0, NULL, 0, 0);
-    todo_wine ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawIndexedPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, 0, 0, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, NULL, 0, 0);
     /* r200 rejects 0 vertices */
-    ok(SUCCEEDED(hr) || broken(ddraw_is_amd(ddraw) && hr == E_FAIL), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(ddraw_is_amd(ddraw) && hr == E_FAIL), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitiveStrided(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, &strided, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, 0, 0, 0);
-    ok(SUCCEEDED(hr) || broken(ddraw_is_amd(ddraw) && hr == E_FAIL), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(ddraw_is_amd(ddraw) && hr == E_FAIL), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, NULL, 0, indices, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawIndexedPrimitiveStrided(device,
             D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, &strided, 0, indices, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     /* Interestingly r200 rejects this, but not the call with a NULL index buffer and 0 indices. */
     hr = IDirect3DDevice7_DrawIndexedPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, 0, 0, indices, 4, 0);
-    ok(SUCCEEDED(hr) || broken(ddraw_is_amd(ddraw) && hr == E_FAIL), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(ddraw_is_amd(ddraw) && hr == E_FAIL), "Failed to draw, hr %#lx.\n", hr);
 
     strided.position.lpvData = quad;
     strided.position.dwStride = sizeof(*quad);
     hr = IDirect3DVertexBuffer7_Lock(vb, 0, &data, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     memcpy(data, quad, sizeof(quad));
     hr = IDirect3DVertexBuffer7_Unlock(vb);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawIndexedPrimitiveStrided(device,
             D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, &strided, 4, NULL, 0, 0);
     /* r200 again fails this, this time with E_OUTOFMEMORY. */
-    ok(SUCCEEDED(hr) || broken(ddraw_is_amd(ddraw) && hr == E_OUTOFMEMORY), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(ddraw_is_amd(ddraw) && hr == E_OUTOFMEMORY), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawIndexedPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, 0, 4, NULL, 0, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     /* Now this draw should work, but r200 rejects it too - presumably earlier tests broke
      * driver internal state. */
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, 0);
-    ok(SUCCEEDED(hr) || broken(ddraw_is_amd(ddraw) && hr == E_FAIL), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || broken(ddraw_is_amd(ddraw) && hr == E_FAIL), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitiveStrided(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, &strided, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, 0, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, indices, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawIndexedPrimitiveStrided(device,
             D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, &strided, 4, indices, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawIndexedPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, 0, 4, indices, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
 
     IDirect3DVertexBuffer7_Release(vb);
     IDirectDraw7_Release(ddraw);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -14016,16 +14016,16 @@ static void test_edge_antialiasing_blending(void)
     }
 
     hr = IDirect3DDevice7_GetCaps(device, &device_desc);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
-    trace("Line edge antialiasing support: %#x.\n",
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
+    trace("Line edge antialiasing support: %#lx.\n",
             device_desc.dpcLineCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES);
-    trace("Triangle edge antialiasing support: %#x.\n",
+    trace("Triangle edge antialiasing support: %#lx.\n",
             device_desc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES);
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get D3D interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get D3D interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get DirectDraw7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DirectDraw7 interface, hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -14041,128 +14041,128 @@ static void test_edge_antialiasing_blending(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(U4(surface_desc).ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &offscreen, NULL);
-    ok(hr == D3D_OK, "Creating the offscreen render target failed, hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Creating the offscreen render target failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderTarget(device, offscreen, 0);
-    ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &mat);
-    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set world transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_VIEW, &mat);
-    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set view transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &mat);
-    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable fog, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_STENCILENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
-    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable blending, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable blending, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
-    ok(SUCCEEDED(hr), "Failed to set src blend, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set src blend, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_DESTALPHA);
-    ok(SUCCEEDED(hr), "Failed to set dest blend, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set dest blend, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color op, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color arg, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
-    ok(SUCCEEDED(hr), "Failed to set alpha op, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set alpha op, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
-    ok(SUCCEEDED(hr), "Failed to set alpha arg, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set alpha arg, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xccff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             green_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x00cc7f00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00cc7f00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             red_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x00cc7f00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00cc7f00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable blending, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable blending, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xccff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             green_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             red_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_EDGEANTIALIAS, TRUE);
-    ok(SUCCEEDED(hr), "Failed to enable edge antialiasing, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enable edge antialiasing, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xccff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             green_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE,
             red_quad, 4, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     color = get_surface_color(offscreen, 320, 240);
-    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface7_Release(offscreen);
     IDirectDraw7_Release(ddraw);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -14184,14 +14184,14 @@ static void test_display_mode_surface_pixel_format(void)
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw7_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     width = surface_desc.dwWidth;
     height = surface_desc.dwHeight;
 
     window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
             0, 0, width, height, NULL, NULL, NULL, NULL);
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     bpp = 0;
     if (SUCCEEDED(IDirectDraw7_SetDisplayMode(ddraw, width, height, 16, 0, 0)))
@@ -14204,10 +14204,10 @@ static void test_display_mode_surface_pixel_format(void)
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw7_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == width, "Got width %u, expected %u.\n", surface_desc.dwWidth, width);
-    ok(surface_desc.dwHeight == height, "Got height %u, expected %u.\n", surface_desc.dwHeight, height);
-    ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == width, "Got width %lu, expected %u.\n", surface_desc.dwWidth, width);
+    ok(surface_desc.dwHeight == height, "Got height %lu, expected %u.\n", surface_desc.dwHeight, height);
+    ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %lu, expected %u.\n",
             U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount, bpp);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -14216,14 +14216,14 @@ static void test_display_mode_surface_pixel_format(void)
     U5(surface_desc).dwBackBufferCount = 1;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == width, "Got width %u, expected %u.\n", surface_desc.dwWidth, width);
-    ok(surface_desc.dwHeight == height, "Got height %u, expected %u.\n", surface_desc.dwHeight, height);
-    ok(U4(surface_desc).ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#x.\n",
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == width, "Got width %lu, expected %u.\n", surface_desc.dwWidth, width);
+    ok(surface_desc.dwHeight == height, "Got height %lu, expected %u.\n", surface_desc.dwHeight, height);
+    ok(U4(surface_desc).ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#lx.\n",
             U4(surface_desc).ddpfPixelFormat.dwFlags);
-    ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
+    ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %lu, expected %u.\n",
             U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount, bpp);
     IDirectDrawSurface7_Release(surface);
 
@@ -14234,18 +14234,18 @@ static void test_display_mode_surface_pixel_format(void)
     surface_desc.dwHeight = height;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok(U4(surface_desc).ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#x.\n",
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(U4(surface_desc).ddpfPixelFormat.dwFlags == DDPF_RGB, "Got unexpected pixel format flags %#lx.\n",
             U4(surface_desc).ddpfPixelFormat.dwFlags);
-    ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %u, expected %u.\n",
+    ok(U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount == bpp, "Got bpp %lu, expected %u.\n",
             U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount, bpp);
     IDirectDrawSurface7_Release(surface);
 
     /* Test compatibility mode mipmap texture creation. */
     hr = IDirectDraw7_SetDisplayMode(ddraw, width, height, 16, 0, 0);
-    ok(hr == DD_OK || hr == E_NOTIMPL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == E_NOTIMPL, "Got unexpected hr %#lx.\n", hr);
     if (FAILED(hr))
     {
         win_skip("SetDisplayMode failed, skipping test.");
@@ -14262,13 +14262,13 @@ static void test_display_mode_surface_pixel_format(void)
     U1(surface_desc).lPitch = surface_desc.dwWidth * bpp / 8;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP | DDSCAPS_VIDEOMEMORY;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_NODIRECTDRAWHW, "Got unexpected hr %#lx.\n", hr);
     if (surface)
         IDirectDrawSurface7_Release(surface);
 
 done:
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -14326,7 +14326,7 @@ static void test_surface_desc_size(void)
         return;
     }
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(surface_caps); ++i)
     {
@@ -14342,9 +14342,9 @@ static void test_surface_desc_size(void)
             continue;
         }
         hr = IDirectDrawSurface_QueryInterface(surface7, &IID_IDirectDrawSurface, (void **)&surface);
-        ok(hr == DD_OK, "Failed to query IDirectDrawSurface, hr %#x, type %s.\n", hr, surface_caps[i].name);
+        ok(hr == DD_OK, "Failed to query IDirectDrawSurface, hr %#lx, type %s.\n", hr, surface_caps[i].name);
         hr = IDirectDrawSurface_QueryInterface(surface7, &IID_IDirectDrawSurface3, (void **)&surface3);
-        ok(hr == DD_OK, "Failed to query IDirectDrawSurface3, hr %#x, type %s.\n", hr, surface_caps[i].name);
+        ok(hr == DD_OK, "Failed to query IDirectDrawSurface3, hr %#lx, type %s.\n", hr, surface_caps[i].name);
 
         /* GetSurfaceDesc() */
         for (j = 0; j < ARRAY_SIZE(desc_sizes); ++j)
@@ -14353,21 +14353,21 @@ static void test_surface_desc_size(void)
             desc.dwSize = desc_sizes[j];
             expected_hr = desc.dwSize == sizeof(DDSURFACEDESC) ? DD_OK : DDERR_INVALIDPARAMS;
             hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc.desc1);
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
 
             memset(&desc, 0, sizeof(desc));
             desc.dwSize = desc_sizes[j];
             expected_hr = desc.dwSize == sizeof(DDSURFACEDESC) ? DD_OK : DDERR_INVALIDPARAMS;
             hr = IDirectDrawSurface3_GetSurfaceDesc(surface3, &desc.desc1);
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
 
             memset(&desc, 0, sizeof(desc));
             desc.dwSize = desc_sizes[j];
             expected_hr = desc.dwSize == sizeof(DDSURFACEDESC2) ? DD_OK : DDERR_INVALIDPARAMS;
             hr = IDirectDrawSurface7_GetSurfaceDesc(surface7, &desc.desc2);
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
         }
 
@@ -14386,22 +14386,22 @@ static void test_surface_desc_size(void)
             desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
             hr = IDirectDrawSurface_Lock(surface, NULL, &desc.desc1, 0, 0);
             expected_hr = ignore_size || valid_size ? DD_OK : DDERR_INVALIDPARAMS;
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
-            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
+            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %lu, type %s.\n",
                     desc_sizes[j], desc.dwSize, surface_caps[i].name);
             ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
                     desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
             if (SUCCEEDED(hr))
             {
-                ok(desc.desc1.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
+                ok(desc.desc1.dwWidth == 128, "Got unexpected width %lu, dwSize %u, type %s.\n",
                         desc.desc1.dwWidth, desc_sizes[j], surface_caps[i].name);
-                ok(desc.desc1.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
+                ok(desc.desc1.dwHeight == 128, "Got unexpected height %lu, dwSize %u, type %s.\n",
                         desc.desc1.dwHeight, desc_sizes[j], surface_caps[i].name);
                 expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
                 todo_wine_if(!expected_texture_stage)
                 ok(desc.desc2.dwTextureStage == expected_texture_stage,
-                        "Got unexpected texture stage %#x, dwSize %u, type %s.\n",
+                        "Got unexpected texture stage %#lx, dwSize %u, type %s.\n",
                         desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
                 IDirectDrawSurface_Unlock(surface, NULL);
             }
@@ -14412,22 +14412,22 @@ static void test_surface_desc_size(void)
             desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
             hr = IDirectDrawSurface3_Lock(surface3, NULL, &desc.desc1, 0, 0);
             expected_hr = ignore_size || valid_size ? DD_OK : DDERR_INVALIDPARAMS;
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
-            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
+            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %lu, type %s.\n",
                     desc_sizes[j], desc.dwSize, surface_caps[i].name);
             ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
                     desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
             if (SUCCEEDED(hr))
             {
-                ok(desc.desc1.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
+                ok(desc.desc1.dwWidth == 128, "Got unexpected width %lu, dwSize %u, type %s.\n",
                         desc.desc1.dwWidth, desc_sizes[j], surface_caps[i].name);
-                ok(desc.desc1.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
+                ok(desc.desc1.dwHeight == 128, "Got unexpected height %lu, dwSize %u, type %s.\n",
                         desc.desc1.dwHeight, desc_sizes[j], surface_caps[i].name);
                 expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
                 todo_wine_if(!expected_texture_stage)
                 ok(desc.desc2.dwTextureStage == expected_texture_stage,
-                        "Got unexpected texture stage %#x, dwSize %u, type %s.\n",
+                        "Got unexpected texture stage %#lx, dwSize %u, type %s.\n",
                         desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
                 IDirectDrawSurface3_Unlock(surface3, NULL);
             }
@@ -14438,21 +14438,21 @@ static void test_surface_desc_size(void)
             desc.blob[sizeof(DDSURFACEDESC2)] = 0xef;
             hr = IDirectDrawSurface7_Lock(surface7, NULL, &desc.desc2, 0, 0);
             expected_hr = ignore_size || valid_size ? DD_OK : DDERR_INVALIDPARAMS;
-            ok(hr == expected_hr, "Got hr %#x, expected %#x, dwSize %u, type %s.\n",
+            ok(hr == expected_hr, "Got hr %#lx, expected %#lx, dwSize %u, type %s.\n",
                     hr, expected_hr, desc_sizes[j], surface_caps[i].name);
-            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %u, type %s.\n",
+            ok(desc.dwSize == desc_sizes[j], "dwSize was changed from %u to %lu, type %s.\n",
                     desc_sizes[j], desc.dwSize, surface_caps[i].name);
             ok(desc.blob[sizeof(DDSURFACEDESC2)] == 0xef, "Got unexpected byte %02x, dwSize %u, type %s.\n",
                     desc.blob[sizeof(DDSURFACEDESC2)], desc_sizes[j], surface_caps[i].name);
             if (SUCCEEDED(hr))
             {
-                ok(desc.desc2.dwWidth == 128, "Got unexpected width %u, dwSize %u, type %s.\n",
+                ok(desc.desc2.dwWidth == 128, "Got unexpected width %lu, dwSize %u, type %s.\n",
                         desc.desc2.dwWidth, desc_sizes[j], surface_caps[i].name);
-                ok(desc.desc2.dwHeight == 128, "Got unexpected height %u, dwSize %u, type %s.\n",
+                ok(desc.desc2.dwHeight == 128, "Got unexpected height %lu, dwSize %u, type %s.\n",
                         desc.desc2.dwHeight, desc_sizes[j], surface_caps[i].name);
                 expected_texture_stage = desc_sizes[j] >= sizeof(DDSURFACEDESC2) ? 0 : 0xdeadbeef;
                 ok(desc.desc2.dwTextureStage == expected_texture_stage,
-                        "Got unexpected texture stage %#x, dwSize %u, type %s.\n",
+                        "Got unexpected texture stage %#lx, dwSize %u, type %s.\n",
                         desc.desc2.dwTextureStage, desc_sizes[j], surface_caps[i].name);
                 IDirectDrawSurface7_Unlock(surface7, NULL);
             }
@@ -14471,17 +14471,17 @@ static void test_surface_desc_size(void)
         expected_hr = (desc.dwSize == sizeof(DDSURFACEDESC) || desc.dwSize == sizeof(DDSURFACEDESC2))
                 ? DD_OK : DDERR_INVALIDPARAMS;
         hr = IDirectDraw7_GetDisplayMode(ddraw, &desc.desc2);
-        ok(hr == expected_hr, "Got hr %#x, expected %#x, size %u.\n", hr, expected_hr, desc_sizes[j]);
+        ok(hr == expected_hr, "Got hr %#lx, expected %#lx, size %u.\n", hr, expected_hr, desc_sizes[j]);
         if (SUCCEEDED(hr))
         {
-            ok(desc.dwSize == sizeof(DDSURFACEDESC2), "Wrong size %u for %u.\n", desc.dwSize, desc_sizes[j]);
+            ok(desc.dwSize == sizeof(DDSURFACEDESC2), "Wrong size %lu for %u.\n", desc.dwSize, desc_sizes[j]);
             ok(desc.blob[desc_sizes[j]] == 0xcc, "Overflow for size %u.\n", desc_sizes[j]);
             ok(desc.blob[desc_sizes[j] - 1] != 0xcc, "Struct not cleared for size %u.\n", desc_sizes[j]);
         }
     }
 
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
 }
 
 static void test_get_surface_from_dc(void)
@@ -14500,7 +14500,7 @@ static void test_get_surface_from_dc(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -14510,59 +14510,59 @@ static void test_get_surface_from_dc(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_QueryInterface(surface, &IID_IDirectDrawSurface, (void **)&surface1);
-    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#lx.\n", hr);
 
     refcount = get_refcount((IUnknown *)surface1);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     refcount = get_refcount((IUnknown *)surface);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface7_GetDC(surface, &dc);
-    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#lx.\n", hr);
 
     tmp1 = (void *)0xdeadbeef;
     device_dc = (void *)0xdeadbeef;
     hr = GetSurfaceFromDC(NULL, &tmp1, &device_dc);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!tmp1, "Got unexpected surface %p.\n", tmp1);
     ok(!device_dc, "Got unexpected device_dc %p.\n", device_dc);
 
     device_dc = (void *)0xdeadbeef;
     hr = GetSurfaceFromDC(dc, NULL, &device_dc);
-    ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
     ok(device_dc == (void *)0xdeadbeef, "Got unexpected device_dc %p.\n", device_dc);
 
     tmp1 = (void *)0xdeadbeef;
     hr = GetSurfaceFromDC(dc, &tmp1, NULL);
-    ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
     ok(!tmp1, "Got unexpected surface %p.\n", tmp1);
 
     hr = GetSurfaceFromDC(dc, &tmp1, &device_dc);
-    ok(SUCCEEDED(hr), "GetSurfaceFromDC failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetSurfaceFromDC failed, hr %#lx.\n", hr);
     ok(tmp1 == surface1, "Got unexpected surface %p, expected %p.\n", tmp1, surface1);
     IDirectDrawSurface_Release(tmp1);
 
     ret = GetObjectType(device_dc);
-    todo_wine ok(ret == OBJ_DC, "Got unexpected object type %#x.\n", ret);
+    todo_wine ok(ret == OBJ_DC, "Got unexpected object type %#lx.\n", ret);
     ret = GetDeviceCaps(device_dc, TECHNOLOGY);
-    todo_wine ok(ret == DT_RASDISPLAY, "Got unexpected technology %#x.\n", ret);
+    todo_wine ok(ret == DT_RASDISPLAY, "Got unexpected technology %#lx.\n", ret);
 
     hr = IDirectDraw7_GetSurfaceFromDC(ddraw, dc, NULL);
-    ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw7_GetSurfaceFromDC(ddraw, dc, &tmp);
-    ok(SUCCEEDED(hr), "GetSurfaceFromDC failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "GetSurfaceFromDC failed, hr %#lx.\n", hr);
     ok(tmp == surface, "Got unexpected surface %p, expected %p.\n", tmp, surface);
 
     refcount = get_refcount((IUnknown *)surface1);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
     refcount = get_refcount((IUnknown *)surface);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface7_ReleaseDC(surface, dc);
-    ok(SUCCEEDED(hr), "ReleaseDC failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "ReleaseDC failed, hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(tmp);
 
@@ -14572,20 +14572,20 @@ static void test_get_surface_from_dc(void)
     tmp1 = (void *)0xdeadbeef;
     device_dc = (void *)0xdeadbeef;
     hr = GetSurfaceFromDC(dc, &tmp1, &device_dc);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!tmp1, "Got unexpected surface %p.\n", tmp1);
     ok(!device_dc, "Got unexpected device_dc %p.\n", device_dc);
 
     tmp = (void *)0xdeadbeef;
     hr = IDirectDraw7_GetSurfaceFromDC(ddraw, dc, &tmp);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!tmp, "Got unexpected surface %p.\n", tmp);
 
     ok(DeleteDC(dc), "DeleteDC failed.\n");
 
     tmp = (void *)0xdeadbeef;
     hr = IDirectDraw7_GetSurfaceFromDC(ddraw, NULL, &tmp);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!tmp, "Got unexpected surface %p.\n", tmp);
 
     IDirectDrawSurface7_Release(surface);
@@ -14612,7 +14612,7 @@ static void test_ck_operation(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -14626,16 +14626,16 @@ static void test_ck_operation(void)
     U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x0000ff00;
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     surface_desc.dwFlags |= DDSD_CKSRCBLT;
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0x00ff00ff;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0x00ff00ff;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &src, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Lock(src, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     ok(!(surface_desc.dwFlags & DDSD_LPSURFACE), "Surface desc has LPSURFACE Flags set.\n");
     color = surface_desc.lpSurface;
     color[0] = 0x77010203;
@@ -14643,33 +14643,33 @@ static void test_ck_operation(void)
     color[2] = 0x77ff00ff;
     color[3] = 0x00ff00ff;
     hr = IDirectDrawSurface7_Unlock(src, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     for (i = 0; i < 2; ++i)
     {
         hr = IDirectDrawSurface7_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         color = surface_desc.lpSurface;
         color[0] = 0xcccccccc;
         color[1] = 0xcccccccc;
         color[2] = 0xcccccccc;
         color[3] = 0xcccccccc;
         hr = IDirectDrawSurface7_Unlock(dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
         if (i)
         {
             hr = IDirectDrawSurface7_BltFast(dst, 0, 0, src, NULL, DDBLTFAST_SRCCOLORKEY);
-            ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
         }
         else
         {
             hr = IDirectDrawSurface7_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC, NULL);
-            ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
         }
 
         hr = IDirectDrawSurface7_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT | DDLOCK_READONLY, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         ok(!(surface_desc.dwFlags & DDSD_LPSURFACE), "Surface desc has LPSURFACE Flags set.\n");
         color = surface_desc.lpSurface;
         /* Different behavior on some drivers / windows versions. Some versions ignore the X channel when
@@ -14684,69 +14684,69 @@ static void test_ck_operation(void)
                 && color[2] == 0xcccccccc && color[3] == 0xcccccccc) /* Nvidia */
                 || broken(color[0] == 0xff010203 && color[1] == 0xff010203
                 && color[2] == 0xcccccccc && color[3] == 0xcccccccc) /* Testbot */,
-                "Destination data after blitting is %08x %08x %08x %08x, i=%u.\n",
+                "Destination data after blitting is %08lx %08lx %08lx %08lx, i=%u.\n",
                 color[0], color[1], color[2], color[3], i);
         hr = IDirectDrawSurface7_Unlock(dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
     }
 
     hr = IDirectDrawSurface7_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x00ff00ff && ckey.dwColorSpaceHighValue == 0x00ff00ff,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface7_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface7_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x0000ff00 && ckey.dwColorSpaceHighValue == 0x0000ff00,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue = 0;
     surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface7_GetSurfaceDesc(src, &surface_desc);
-    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface desc, hr %#lx.\n", hr);
     ok(surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue == 0x0000ff00
             && surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue == 0x0000ff00,
-            "Got unexpected color key low=%08x high=%08x.\n", surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue,
+            "Got unexpected color key low=%08lx high=%08lx.\n", surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue,
             surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue);
 
     /* Test SetColorKey with dwColorSpaceHighValue < dwColorSpaceLowValue */
     ckey.dwColorSpaceLowValue = 0x000000ff;
     ckey.dwColorSpaceHighValue = 0x00000000;
     hr = IDirectDrawSurface7_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface7_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x000000ff && ckey.dwColorSpaceHighValue == 0x000000ff,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     ckey.dwColorSpaceLowValue = 0x000000ff;
     ckey.dwColorSpaceHighValue = 0x00000001;
     hr = IDirectDrawSurface7_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface7_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x000000ff && ckey.dwColorSpaceHighValue == 0x000000ff,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     ckey.dwColorSpaceLowValue = 0x000000fe;
     ckey.dwColorSpaceHighValue = 0x000000fd;
     hr = IDirectDrawSurface7_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = ckey.dwColorSpaceHighValue = 0;
     hr = IDirectDrawSurface7_GetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to get color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get color key, hr %#lx.\n", hr);
     ok(ckey.dwColorSpaceLowValue == 0x000000fe && ckey.dwColorSpaceHighValue == 0x000000fe,
-            "Got unexpected color key low=%08x high=%08x.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
+            "Got unexpected color key low=%08lx high=%08lx.\n", ckey.dwColorSpaceLowValue, ckey.dwColorSpaceHighValue);
 
     IDirectDrawSurface7_Release(src);
     IDirectDrawSurface7_Release(dst);
@@ -14766,18 +14766,18 @@ static void test_ck_operation(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(U4(surface_desc).ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &src, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     ckey.dwColorSpaceLowValue = 0x0000ff00;
     ckey.dwColorSpaceHighValue = 0x0000ff00;
     hr = IDirectDrawSurface7_SetColorKey(dst, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     ckey.dwColorSpaceLowValue = 0x00ff0000;
     ckey.dwColorSpaceHighValue = 0x00ff0000;
     hr = IDirectDrawSurface7_SetColorKey(dst, DDCKEY_DESTBLT, &ckey);
-    ok(SUCCEEDED(hr) || hr == DDERR_NOCOLORKEYHW, "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr) || hr == DDERR_NOCOLORKEYHW, "Failed to set color key, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
         /* Nvidia reject dest keys, AMD allows them. This applies to vidmem and sysmem surfaces. */
@@ -14788,11 +14788,11 @@ static void test_ck_operation(void)
     ckey.dwColorSpaceLowValue = 0x000000ff;
     ckey.dwColorSpaceHighValue = 0x000000ff;
     hr = IDirectDrawSurface7_SetColorKey(src, DDCKEY_SRCBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     ckey.dwColorSpaceLowValue = 0x000000aa;
     ckey.dwColorSpaceHighValue = 0x000000aa;
     hr = IDirectDrawSurface7_SetColorKey(src, DDCKEY_DESTBLT, &ckey);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     memset(&fx, 0, sizeof(fx));
     fx.dwSize = sizeof(fx);
@@ -14802,7 +14802,7 @@ static void test_ck_operation(void)
     fx.ddckDestColorkey.dwColorSpaceLowValue = 0x00001100;
 
     hr = IDirectDrawSurface7_Lock(src, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     color[0] = 0x000000ff; /* Applies to src blt key in src surface. */
     color[1] = 0x000000aa; /* Applies to dst blt key in src surface. */
@@ -14811,77 +14811,77 @@ static void test_ck_operation(void)
     color[4] = 0x00001100; /* Src color key in ddbltfx. */
     color[5] = 0x00110000; /* Dst color key in ddbltfx. */
     hr = IDirectDrawSurface7_Unlock(src, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0x55555555;
     hr = IDirectDrawSurface7_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Test a blit without keying. */
     hr = IDirectDrawSurface7_Blt(dst, NULL, src, NULL, 0, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Should have copied src data unmodified to dst. */
     ok(color[0] == 0x000000ff && color[1] == 0x000000aa && color[2] == 0x00ff0000 &&
             color[3] == 0x0000ff00 && color[4] == 0x00001100 && color[5] == 0x00110000,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0x55555555;
     hr = IDirectDrawSurface7_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Src key. */
     hr = IDirectDrawSurface7_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Src key applied to color[0]. It is unmodified, the others are copied. */
     ok(color[0] == 0x55555555 && color[1] == 0x000000aa && color[2] == 0x00ff0000 &&
             color[3] == 0x0000ff00 && color[4] == 0x00001100 && color[5] == 0x00110000,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0x55555555;
     hr = IDirectDrawSurface7_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Src override. */
     hr = IDirectDrawSurface7_Blt(dst, NULL, src, NULL, DDBLT_KEYSRCOVERRIDE, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Override key applied to color[5]. It is unmodified, the others are copied. */
     ok(color[0] == 0x000000ff && color[1] == 0x000000aa && color[2] == 0x00ff0000 &&
             color[3] == 0x0000ff00 && color[4] == 0x00001100 && color[5] == 0x55555555,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = color[1] = color[2] = color[3] = color[4] = color[5] = 0x55555555;
     hr = IDirectDrawSurface7_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Src override AND src key. That is not supposed to work. */
     hr = IDirectDrawSurface7_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC | DDBLT_KEYSRCOVERRIDE, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Ensure the destination was not changed. */
     ok(color[0] == 0x55555555 && color[1] == 0x55555555 && color[2] == 0x55555555 &&
             color[3] == 0x55555555 && color[4] == 0x55555555 && color[5] == 0x55555555,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     /* Use different dst colors for the dst key test. */
@@ -14892,19 +14892,19 @@ static void test_ck_operation(void)
     color[4] = 0x000000aa; /* Dest key in src surface. */
     color[5] = 0x000000aa; /* Dest key in src surface. */
     hr = IDirectDrawSurface7_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Dest key blit. The key is taken from the DESTINATION surface in v7! */
     hr = IDirectDrawSurface7_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Dst key applied to color[0,1], they are the only changed pixels. */
     todo_wine ok(color[0] == 0x000000ff && color[1] == 0x000000aa && color[2] == 0x00001100 &&
             color[3] == 0x00001100 && color[4] == 0x000000aa && color[5] == 0x000000aa,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = 0x00ff0000; /* Dest key in dst surface. */
@@ -14914,28 +14914,28 @@ static void test_ck_operation(void)
     color[4] = 0x000000aa; /* Dest key in src surface. */
     color[5] = 0x000000aa; /* Dest key in src surface. */
     hr = IDirectDrawSurface7_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* What happens with a QI'd older version of the interface? It takes the key
      * from the source surface. */
     hr = IDirectDrawSurface7_QueryInterface(src, &IID_IDirectDrawSurface, (void **)&src1);
-    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_QueryInterface(dst, &IID_IDirectDrawSurface, (void **)&dst1);
-    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to query IDirectDrawSurface interface, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface_Blt(dst1, NULL, src1, NULL, DDBLT_KEYDEST, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     IDirectDrawSurface_Release(dst1);
     IDirectDrawSurface_Release(src1);
 
     hr = IDirectDrawSurface7_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Dst key applied to color[4,5], they are the only changed pixels. */
     ok(color[0] == 0x00ff0000 && color[1] == 0x00ff0000 && color[2] == 0x00001100 &&
             color[3] == 0x00001100 && color[4] == 0x00001100 && color[5] == 0x00110000,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = 0x00ff0000; /* Dest key in dst surface. */
@@ -14945,19 +14945,19 @@ static void test_ck_operation(void)
     color[4] = 0x000000aa; /* Dest key in src surface. */
     color[5] = 0x000000aa; /* Dest key in src surface. */
     hr = IDirectDrawSurface7_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Dest override key blit. */
     hr = IDirectDrawSurface7_Blt(dst, NULL, src, NULL, DDBLT_KEYDESTOVERRIDE, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Dst key applied to color[2,3], they are the only changed pixels. */
     ok(color[0] == 0x00ff0000 && color[1] == 0x00ff0000 && color[2] == 0x00ff0000 &&
             color[3] == 0x0000ff00 && color[4] == 0x000000aa && color[5] == 0x000000aa,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
 
     color[0] = 0x00ff0000; /* Dest key in dst surface. */
@@ -14967,38 +14967,38 @@ static void test_ck_operation(void)
     color[4] = 0x000000aa; /* Dest key in src surface. */
     color[5] = 0x000000aa; /* Dest key in src surface. */
     hr = IDirectDrawSurface7_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Dest override together with surface key. Supposed to fail. */
     hr = IDirectDrawSurface7_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST | DDBLT_KEYDESTOVERRIDE, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Destination is unchanged. */
     ok(color[0] == 0x00ff0000 && color[1] == 0x00ff0000 && color[2] == 0x00001100 &&
             color[3] == 0x00001100 && color[4] == 0x000000aa && color[5] == 0x000000aa,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
     hr = IDirectDrawSurface7_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Source and destination key. This is driver dependent. New HW treats it like
      * DDBLT_KEYSRC. Older HW and some software renderers apply both keys. */
     if (0)
     {
         hr = IDirectDrawSurface7_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST | DDBLT_KEYSRC, &fx);
-        ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
         hr = IDirectDrawSurface7_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
         color = surface_desc.lpSurface;
         /* Color[0] is filtered by the src key, 2-5 are filtered by the dst key, if
          * the driver applies it. */
         ok(color[0] == 0x00ff0000 && color[1] == 0x000000aa && color[2] == 0x00ff0000 &&
                 color[3] == 0x0000ff00 && color[4] == 0x00001100 && color[5] == 0x00110000,
-                "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+                "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
                 color[0], color[1], color[2], color[3], color[4], color[5]);
 
         color[0] = 0x00ff0000; /* Dest key in dst surface. */
@@ -15008,55 +15008,55 @@ static void test_ck_operation(void)
         color[4] = 0x000000aa; /* Dest key in src surface. */
         color[5] = 0x000000aa; /* Dest key in src surface. */
         hr = IDirectDrawSurface7_Unlock(dst, NULL);
-        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
     }
 
     /* Override keys without ddbltfx parameter fail */
     hr = IDirectDrawSurface7_Blt(dst, NULL, src, NULL, DDBLT_KEYDESTOVERRIDE, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_Blt(dst, NULL, src, NULL, DDBLT_KEYSRCOVERRIDE, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Try blitting without keys in the source surface. */
     hr = IDirectDrawSurface7_SetColorKey(src, DDCKEY_SRCBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_SetColorKey(src, DDCKEY_DESTBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     /* That fails now. Do not bother to check that the data is unmodified. */
     hr = IDirectDrawSurface7_Blt(dst, NULL, src, NULL, DDBLT_KEYSRC, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     /* Dest key blit still works, the destination surface key is used in v7. */
     hr = IDirectDrawSurface7_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST, &fx);
-    ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to blit, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_Lock(dst, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
     color = surface_desc.lpSurface;
     /* Dst key applied to color[0,1], they are the only changed pixels. */
     todo_wine ok(color[0] == 0x000000ff && color[1] == 0x000000aa && color[2] == 0x00001100 &&
             color[3] == 0x00001100 && color[4] == 0x000000aa && color[5] == 0x000000aa,
-            "Got unexpected content %08x %08x %08x %08x %08x %08x.\n",
+            "Got unexpected content %08lx %08lx %08lx %08lx %08lx %08lx.\n",
             color[0], color[1], color[2], color[3], color[4], color[5]);
     hr = IDirectDrawSurface7_Unlock(dst, NULL);
-    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
 
     /* Try blitting without keys in the destination surface. */
     hr = IDirectDrawSurface7_SetColorKey(dst, DDCKEY_SRCBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_SetColorKey(dst, DDCKEY_DESTBLT, NULL);
-    ok(SUCCEEDED(hr), "Failed to set color key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set color key, hr %#lx.\n", hr);
 
     /* This fails, as sanity would dictate. */
     hr = IDirectDrawSurface7_Blt(dst, NULL, src, NULL, DDBLT_KEYDEST, &fx);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
 done:
     IDirectDrawSurface7_Release(src);
     IDirectDrawSurface7_Release(dst);
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "DirectDraw has %u references left.\n", refcount);
+    ok(!refcount, "DirectDraw has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -15083,7 +15083,7 @@ static void test_vb_refcount(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#lx.\n", hr);
 
     prev_d3d_refcount = get_refcount((IUnknown *)d3d);
     prev_device_refcount = get_refcount((IUnknown *)device);
@@ -15093,37 +15093,37 @@ static void test_vb_refcount(void)
     vb_desc.dwFVF = D3DFVF_XYZ;
     vb_desc.dwNumVertices = 4;
     hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &vb, 0);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
 
     cur_d3d_refcount = get_refcount((IUnknown *)d3d);
     cur_device_refcount = get_refcount((IUnknown *)device);
-    ok(cur_d3d_refcount > prev_d3d_refcount, "D3D object refcount didn't change from %u.\n", prev_d3d_refcount);
-    ok(cur_device_refcount == prev_device_refcount, "Device refcount changed from %u to %u.\n",
+    ok(cur_d3d_refcount > prev_d3d_refcount, "D3D object refcount didn't change from %lu.\n", prev_d3d_refcount);
+    ok(cur_device_refcount == prev_device_refcount, "Device refcount changed from %lu to %lu.\n",
             prev_device_refcount, cur_device_refcount);
 
     prev_d3d_refcount = cur_d3d_refcount;
     hr = IDirect3DVertexBuffer7_QueryInterface(vb, &IID_IDirect3DVertexBuffer7, (void **)&vb7);
-    ok(hr == DD_OK, "Failed to query IDirect3DVertexBuffer7, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to query IDirect3DVertexBuffer7, hr %#lx.\n", hr);
     cur_d3d_refcount = get_refcount((IUnknown *)d3d);
-    ok(cur_d3d_refcount == prev_d3d_refcount, "D3D object refcount changed from %u to %u.\n",
+    ok(cur_d3d_refcount == prev_d3d_refcount, "D3D object refcount changed from %lu to %lu.\n",
             prev_d3d_refcount, cur_d3d_refcount);
     IDirect3DVertexBuffer7_Release(vb7);
 
     hr = IDirect3DVertexBuffer7_QueryInterface(vb, &IID_IDirect3DVertexBuffer, (void **)&vb1);
-    ok(hr == E_NOINTERFACE, "Querying IDirect3DVertexBuffer returned unexpected hr %#x.\n", hr);
+    ok(hr == E_NOINTERFACE, "Querying IDirect3DVertexBuffer returned unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer_QueryInterface(vb, &IID_IUnknown, (void **)&unk);
-    ok(hr == DD_OK, "Failed to query IUnknown, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to query IUnknown, hr %#lx.\n", hr);
     ok((IUnknown *)vb == unk,
             "IDirect3DVertexBuffer7 and IUnknown interface pointers don't match, %p != %p.\n", vb, unk);
     IUnknown_Release(unk);
 
     refcount = IDirect3DVertexBuffer7_Release(vb);
-    ok(!refcount, "Vertex buffer has %u references left.\n", refcount);
+    ok(!refcount, "Vertex buffer has %lu references left.\n", refcount);
 
     IDirect3D7_Release(d3d);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -15205,7 +15205,7 @@ static void test_compute_sphere_visibility(void)
     }
 
     hr = IDirect3DDevice7_SetClipPlane(device, 0, clip_plane);
-    ok(SUCCEEDED(hr), "Failed to set user clip plane, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set user clip plane, hr %#lx.\n", hr);
 
     IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &identity);
 
@@ -15216,19 +15216,19 @@ static void test_compute_sphere_visibility(void)
 
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPLANEENABLE,
                 tests[i].enable_planes);
-        ok(SUCCEEDED(hr), "Failed to enable / disable user clip planes, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to enable / disable user clip planes, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_ComputeSphereVisibility(device, tests[i].center, tests[i].radius,
                 tests[i].sphere_count, 0, result);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         for (j = 0; j < tests[i].sphere_count; ++j)
-            ok(result[j] == tests[i].expected[j], "Test %u sphere %u: expected %#x, got %#x.\n",
+            ok(result[j] == tests[i].expected[j], "Test %u sphere %u: expected %#lx, got %#lx.\n",
                     i, j, tests[i].expected[j], result[j]);
     }
 
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -15253,7 +15253,7 @@ static void test_clip_planes_limits(void)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice7_GetCaps(device, &caps);
-    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#lx.\n", hr);
 
     trace("Max user clip planes: %u.\n", caps.wMaxUserClipPlanes);
 
@@ -15261,7 +15261,7 @@ static void test_clip_planes_limits(void)
     {
         memset(plane, 0xff, sizeof(plane));
         hr = IDirect3DDevice7_GetClipPlane(device, i, plane);
-        ok(hr == D3D_OK, "Failed to get clip plane %u, hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Failed to get clip plane %u, hr %#lx.\n", i, hr);
         ok(!plane[0] && !plane[1] && !plane[2] && !plane[3],
                 "Got unexpected plane %u: %.8e, %.8e, %.8e, %.8e.\n",
                 i, plane[0], plane[1], plane[2], plane[3]);
@@ -15274,31 +15274,31 @@ static void test_clip_planes_limits(void)
     {
         plane[3] = i;
         hr = IDirect3DDevice7_SetClipPlane(device, i, plane);
-        ok(hr == D3D_OK, "Failed to set clip plane %u, hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Failed to set clip plane %u, hr %#lx.\n", i, hr);
     }
     for (i = 0; i < caps.wMaxUserClipPlanes; ++i)
     {
         memset(plane, 0xff, sizeof(plane));
         hr = IDirect3DDevice7_GetClipPlane(device, i, plane);
-        ok(hr == D3D_OK, "Failed to get clip plane %u, hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Failed to get clip plane %u, hr %#lx.\n", i, hr);
         ok(plane[0] == 2.0f && plane[1] == 8.0f && plane[2] == 5.0f && plane[3] == i,
                 "Got unexpected plane %u: %.8e, %.8e, %.8e, %.8e.\n",
                 i, plane[0], plane[1], plane[2], plane[3]);
     }
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPLANEENABLE, 0xffffffff);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_CLIPPLANEENABLE, &state);
-    ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
-    ok(state == 0xffffffff, "Got unexpected state %#x.\n", state);
+    ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
+    ok(state == 0xffffffff, "Got unexpected state %#lx.\n", state);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPLANEENABLE, 0x80000000);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_CLIPPLANEENABLE, &state);
-    ok(SUCCEEDED(hr), "Failed to get render state, hr %#x.\n", hr);
-    ok(state == 0x80000000, "Got unexpected state %#x.\n", state);
+    ok(SUCCEEDED(hr), "Failed to get render state, hr %#lx.\n", hr);
+    ok(state == 0x80000000, "Got unexpected state %#lx.\n", state);
 
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -15322,9 +15322,9 @@ static void test_texture_stages_limits(void)
         return;
     }
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get DirectDraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DirectDraw interface, hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -15334,22 +15334,22 @@ static void test_texture_stages_limits(void)
     surface_desc.dwWidth = 16;
     surface_desc.dwHeight = 16;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &texture, NULL);
-    ok(hr == DD_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to create surface, hr %#lx.\n", hr);
 
     for (i = 0; i < 8; ++i)
     {
         hr = IDirect3DDevice7_SetTexture(device, i, texture);
-        ok(hr == D3D_OK, "Failed to set texture %u, hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Failed to set texture %u, hr %#lx.\n", i, hr);
         hr = IDirect3DDevice7_SetTexture(device, i, NULL);
-        ok(hr == D3D_OK, "Failed to set texture %u, hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Failed to set texture %u, hr %#lx.\n", i, hr);
         hr = IDirect3DDevice7_SetTextureStageState(device, i, D3DTSS_COLOROP, D3DTOP_ADD);
-        ok(hr == D3D_OK, "Failed to set texture stage state %u, hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Failed to set texture stage state %u, hr %#lx.\n", i, hr);
     }
 
     IDirectDrawSurface7_Release(texture);
     IDirectDraw7_Release(ddraw);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -15370,26 +15370,26 @@ static void test_set_render_state(void)
     }
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZVISIBLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* States deprecated in D3D7 */
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, 0);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     state = 0xdeadbeef;
     hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_TEXTUREHANDLE, &state);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
-    ok(state == 0xdeadbeef, "Got unexpected render state %#x.\n", state);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
+    ok(state == 0xdeadbeef, "Got unexpected render state %#lx.\n", state);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     state = 0xdeadbeef;
     hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, &state);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
-    ok(state == 0xdeadbeef, "Got unexpected render state %#x.\n", state);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
+    ok(state == 0xdeadbeef, "Got unexpected render state %#lx.\n", state);
 
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -15461,9 +15461,9 @@ static void test_map_synchronisation(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
     /* Maps are always synchronised on WARP. */
     if (ddraw_is_warp(ddraw))
     {
@@ -15472,7 +15472,7 @@ static void test_map_synchronisation(void)
     }
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     tri_count = 0x1000;
 
@@ -15484,28 +15484,28 @@ static void test_map_synchronisation(void)
     vb_desc.dwFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE;
     vb_desc.dwNumVertices = tri_count + 2;
     hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &buffer, 0);
-    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
     hr = IDirect3DVertexBuffer7_Lock(buffer, DDLOCK_DISCARDCONTENTS, (void **)&quads, NULL);
-    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
     for (j = 0; j < vb_desc.dwNumVertices / 4; ++j)
     {
         quads[j] = quad1;
     }
     hr = IDirect3DVertexBuffer7_Unlock(buffer);
-    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     /* Initial draw to initialise states, compile shaders, etc. */
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, buffer, 0, vb_desc.dwNumVertices, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     /* Read the result to ensure the GPU has finished drawing. */
     colour = get_surface_color(rt, 320, 240);
 
@@ -15513,25 +15513,25 @@ static void test_map_synchronisation(void)
     ret = QueryPerformanceCounter(&ts[0]);
     ok(ret, "Failed to read performance counter.\n");
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, buffer, 0, vb_desc.dwNumVertices, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     colour = get_surface_color(rt, 320, 240);
     /* Time drawing a single triangle. */
     ret = QueryPerformanceCounter(&ts[1]);
     ok(ret, "Failed to read performance counter.\n");
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, buffer, 0, 3, 0);
-    ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
     colour = get_surface_color(rt, 320, 240);
     ret = QueryPerformanceCounter(&ts[2]);
     ok(ret, "Failed to read performance counter.\n");
@@ -15547,32 +15547,32 @@ static void test_map_synchronisation(void)
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &buffer, 0);
-        ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#lx.\n", hr);
         hr = IDirect3DVertexBuffer7_Lock(buffer, DDLOCK_DISCARDCONTENTS, (void **)&quads, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
         for (j = 0; j < vb_desc.dwNumVertices / 4; ++j)
         {
             quads[j] = quad1;
         }
         hr = IDirect3DVertexBuffer7_Unlock(buffer);
-        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
         /* Start a draw operation. */
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, buffer, 0, vb_desc.dwNumVertices, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         /* Map the last quad while the draw is in progress. */
         hr = IDirect3DVertexBuffer7_Lock(buffer, DDLOCK_WAIT | tests[i].flags, (void **)&quads, NULL);
-        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#lx.\n", hr);
         quads[(vb_desc.dwNumVertices / 4) - 1] = quad2;
         hr = IDirect3DVertexBuffer7_Unlock(buffer);
-        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#lx.\n", hr);
 
         colour = get_surface_color(rt, 320, 240);
         unsynchronised = compare_color(colour, 0x00ffff00, 1);
@@ -15587,7 +15587,7 @@ done:
     IDirectDraw7_Release(ddraw);
     IDirect3D7_Release(d3d);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -15644,19 +15644,19 @@ static void test_depth_readback(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     ds = get_depth_stencil(device);
     hr = IDirectDrawSurface7_DeleteAttachedSurface(rt, 0, ds);
-    ok(SUCCEEDED(hr), "Failed to detach depth buffer, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to detach depth buffer, hr %#lx.\n", hr);
     IDirectDrawSurface7_Release(ds);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
@@ -15683,18 +15683,18 @@ static void test_depth_readback(void)
         }
 
         hr = IDirectDrawSurface_AddAttachedSurface(rt, ds);
-        ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_SetRenderTarget(device, rt, 0);
-        ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE, quad, 4, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         all_zero = all_one = all_pass = TRUE;
         for (y = 60; y < 480; y += 120)
@@ -15705,7 +15705,7 @@ static void test_depth_readback(void)
                 memset(&surface_desc, 0, sizeof(surface_desc));
                 surface_desc.dwSize = sizeof(surface_desc);
                 hr = IDirectDrawSurface7_Lock(ds, &r, &surface_desc, DDLOCK_READONLY, NULL);
-                ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to lock surface, hr %#lx.\n", hr);
 
                 raw_value = *((DWORD *)surface_desc.lpSurface);
                 if (raw_value)
@@ -15738,20 +15738,20 @@ static void test_depth_readback(void)
                     ok(compare_uint(expected_depth, depth, max_diff)
                             || (ddraw_is_nvidia(ddraw) && (all_zero || all_one || !tests[i].s_depth))
                             || (ddraw_is_amd(ddraw) && !tests[i].s_depth && tests[i].z_mask == 0x00ffffff),
-                            "Test %u: Got depth 0x%08x (diff %d), expected 0x%08x+/-%u, at %u, %u.\n",
+                            "Test %u: Got depth 0x%08lx (diff %ld), expected 0x%08lx+/-%lu, at %u, %u.\n",
                             i, depth, expected_depth - depth, expected_depth, max_diff, x, y);
                 if (!compare_uint(expected_depth, depth, max_diff))
                     all_pass = FALSE;
 
                 hr = IDirectDrawSurface7_Unlock(ds, &r);
-                ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#lx.\n", hr);
             }
         }
         if (all_pass)
             passed_fmts++;
 
         hr = IDirectDrawSurface7_DeleteAttachedSurface(rt, 0, ds);
-        ok(SUCCEEDED(hr), "Failed to detach depth buffer, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to detach depth buffer, hr %#lx.\n", hr);
         IDirectDrawSurface7_Release(ds);
     }
 
@@ -15761,7 +15761,7 @@ static void test_depth_readback(void)
     IDirectDraw7_Release(ddraw);
     IDirect3D7_Release(d3d);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -15788,15 +15788,15 @@ static void test_clear(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     /* Positive x, negative y. */
     U1(rect[0]).x1 = 0;
@@ -15813,19 +15813,19 @@ static void test_clear(void)
     /* Clear 2 rectangles with one call. Unlike d3d8/9, the refrast does not
      * refuse negative rectangles, but it will not clear them either. */
     hr = IDirect3DDevice7_Clear(device, 2, rect, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 360);
-    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3 (pos, neg) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3 (pos, neg) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 160, 120);
-    ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1 (pos, pos) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1 (pos, pos) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 360);
-    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4 (NULL) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4 (NULL) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 120);
-    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4 (neg, neg) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4 (neg, neg) has color 0x%08lx.\n", color);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     /* negative x, negative y.
      * Also ignored, except on WARP, which clears the entire screen. */
     U1(rect_negneg).x1 = 640;
@@ -15833,30 +15833,30 @@ static void test_clear(void)
     U3(rect_negneg).x2 = 320;
     U4(rect_negneg).y2 = 0;
     hr = IDirect3DDevice7_Clear(device, 1, &rect_negneg, D3DCLEAR_TARGET, 0xff00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 160, 360);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 160, 120);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 360);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
     color = get_surface_color(rt, 480, 120);
     ok(compare_color(color, 0x00ffffff, 0)
             || broken(ddraw_is_warp(ddraw) && compare_color(color, 0x0000ff00, 0)),
-            "Got unexpected color 0x%08x.\n", color);
+            "Got unexpected color 0x%08lx.\n", color);
 
     /* Test how the viewport affects clears. */
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_GetViewport(device, &old_vp);
-    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get viewport, hr %#lx.\n", hr);
 
     vp.dwX = 160;
     vp.dwY = 120;
@@ -15865,9 +15865,9 @@ static void test_clear(void)
     vp.dvMinZ = 0.0f;
     vp.dvMaxZ = 1.0f;
     hr = IDirect3DDevice7_SetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     vp.dwX = 320;
     vp.dwY = 240;
@@ -15876,44 +15876,44 @@ static void test_clear(void)
     vp.dvMinZ = 0.0f;
     vp.dvMaxZ = 1.0f;
     hr = IDirect3DDevice7_SetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
 
     U1(rect[0]).x1 = 160;
     U2(rect[0]).y1 = 120;
     U3(rect[0]).x2 = 480;
     U4(rect[0]).y2 = 360;
     hr = IDirect3DDevice7_Clear(device, 1, &rect[0], D3DCLEAR_TARGET, 0xff00ff00, 0.0f, 0);
-    ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to clear, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetViewport(device, &old_vp);
-    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set viewport, hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 158, 118);
-    ok(compare_color(color, 0x00ffffff, 0), "(158, 118) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(158, 118) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 162, 118);
-    ok(compare_color(color, 0x00ffffff, 0), "(162, 118) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(162, 118) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 158, 122);
-    ok(compare_color(color, 0x00ffffff, 0), "(158, 122) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(158, 122) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 162, 122);
-    ok(compare_color(color, 0x000000ff, 0), "(162, 122) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 0), "(162, 122) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 318, 238);
-    ok(compare_color(color, 0x000000ff, 0), "(318, 238) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x000000ff, 0), "(318, 238) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 322, 238);
-    ok(compare_color(color, 0x00ffffff, 0), "(322, 328) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(322, 328) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 318, 242);
-    ok(compare_color(color, 0x00ffffff, 0), "(318, 242) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(318, 242) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 322, 242);
-    ok(compare_color(color, 0x0000ff00, 0), "(322, 242) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(322, 242) has color 0x%08lx.\n", color);
 
     color = get_surface_color(rt, 478, 358);
-    ok(compare_color(color, 0x0000ff00, 0), "(478, 358) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x0000ff00, 0), "(478, 358) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 482, 358);
-    ok(compare_color(color, 0x00ffffff, 0), "(482, 358) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(482, 358) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 478, 362);
-    ok(compare_color(color, 0x00ffffff, 0), "(478, 362) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(478, 362) has color 0x%08lx.\n", color);
     color = get_surface_color(rt, 482, 362);
-    ok(compare_color(color, 0x00ffffff, 0), "(482, 362) has color 0x%08x.\n", color);
+    ok(compare_color(color, 0x00ffffff, 0), "(482, 362) has color 0x%08lx.\n", color);
 
     /* COLORWRITEENABLE, SRGBWRITEENABLE and scissor rectangles do not exist
      * in d3d7. */
@@ -15922,7 +15922,7 @@ static void test_clear(void)
     IDirectDraw7_Release(ddraw);
     IDirect3D7_Release(d3d);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -15980,12 +15980,12 @@ static HRESULT WINAPI enum_surfaces_create_cb(IDirectDrawSurface7 *surface, DDSU
     struct enum_surfaces_param *param = context;
 
     ok(!surface, "Unexpected surface %p.\n", surface);
-    ok((desc->dwFlags & expect_flags) == expect_flags, "Got unexpected flags %#x.\n", desc->dwFlags);
+    ok((desc->dwFlags & expect_flags) == expect_flags, "Got unexpected flags %#lx.\n", desc->dwFlags);
     if (param->count < ARRAY_SIZE(param->modes))
     {
         const DDSURFACEDESC2 *expect = &param->modes[param->count];
-        ok(desc->dwWidth == expect->dwWidth, "Expected width %u, got %u.\n", expect->dwWidth, desc->dwWidth);
-        ok(desc->dwHeight == expect->dwHeight, "Expected height %u, got %u.\n", expect->dwHeight, desc->dwHeight);
+        ok(desc->dwWidth == expect->dwWidth, "Expected width %lu, got %lu.\n", expect->dwWidth, desc->dwWidth);
+        ok(desc->dwHeight == expect->dwHeight, "Expected height %lu, got %lu.\n", expect->dwHeight, desc->dwHeight);
         ok(!memcmp(&U4(*desc).ddpfPixelFormat, &U4(*expect).ddpfPixelFormat, sizeof(U4(*desc).ddpfPixelFormat)),
                 "Pixel formats didn't match.\n");
     }
@@ -16010,21 +16010,21 @@ static void test_enum_surfaces(void)
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
     hr = IDirectDraw7_GetDisplayMode(ddraw, &desc);
-    ok(hr == DD_OK, "Failed to get display mode, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to get display mode, hr %#lx.\n", hr);
     current_format = U4(desc).ddpfPixelFormat;
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to set cooperative level, hr %#lx.\n", hr);
 
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, NULL, NULL, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_ALL, NULL, NULL, enum_surfaces_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL,
             NULL, NULL, enum_surfaces_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
@@ -16041,49 +16041,49 @@ static void test_enum_surfaces(void)
     }
 
     hr = IDirectDrawSurface7_GetAttachedSurface(param.surfaces[0], &desc.ddsCaps, &param.surfaces[1]);
-    ok(hr == DD_OK, "Failed to get attached surface, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to get attached surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetAttachedSurface(param.surfaces[1], &desc.ddsCaps, &param.surfaces[2]);
-    ok(hr == DD_OK, "Failed to get attached surface, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to get attached surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetAttachedSurface(param.surfaces[2], &desc.ddsCaps, &param.surfaces[3]);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!param.surfaces[3], "Got unexpected pointer %p.\n", param.surfaces[3]);
 
     param.count = 0;
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
             &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     param.count = 0;
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
             NULL, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
     param.count = 0;
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     param.count = 0;
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_NOMATCH,
             &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 2, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     desc.dwFlags = 0;
     param.count = 0;
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     desc.dwFlags = 0;
     param.count = 0;
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST, &desc, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 3, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     IDirectDrawSurface7_Release(param.surfaces[2]);
@@ -16093,7 +16093,7 @@ static void test_enum_surfaces(void)
     param.count = 0;
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL,
             NULL, &param, enum_surfaces_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(!param.count, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     memset(&desc, 0, sizeof(desc));
@@ -16103,15 +16103,15 @@ static void test_enum_surfaces(void)
 
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_ALL,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#lx.\n", hr);
 
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_NOMATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#lx.\n", hr);
 
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Failed to enumerate surfaces, hr %#lx.\n", hr);
 
     /* When not passed width and height, the callback is called with every
      * available display resolution. */
@@ -16120,13 +16120,13 @@ static void test_enum_surfaces(void)
     desc.dwFlags |= DDSD_PIXELFORMAT;
     U4(desc).ddpfPixelFormat = current_format;
     hr = IDirectDraw7_EnumDisplayModes(ddraw, 0, &desc, &param, build_mode_list_cb);
-    ok(hr == DD_OK, "Failed to build mode list, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to build mode list, hr %#lx.\n", hr);
 
     param.count = 0;
     desc.dwFlags &= ~DDSD_PIXELFORMAT;
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == param.mode_count, "Expected %u surfaces, got %u.\n", param.mode_count, param.count);
 
     desc.dwFlags |= DDSD_WIDTH | DDSD_HEIGHT;
@@ -16137,15 +16137,15 @@ static void test_enum_surfaces(void)
     param.count = 0;
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     hr = IDirectDraw7_CreateSurface(ddraw, &desc, &param.surfaces[0], NULL);
-    ok(hr == DD_OK, "Failed to create surface, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to create surface, hr %#lx.\n", hr);
     param.count = 0;
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(param.count == 1, "Got unexpected number of enumerated surfaces %u.\n", param.count);
     IDirectDrawSurface7_Release(param.surfaces[0]);
 
@@ -16157,7 +16157,7 @@ static void test_enum_surfaces(void)
     param.count = 0;
     hr = IDirectDraw7_EnumSurfaces(ddraw, DDENUMSURFACES_CANBECREATED | DDENUMSURFACES_MATCH,
             &desc, &param, enum_surfaces_create_cb);
-    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#x.\n", hr);
+    ok(hr == DD_OK, "Failed to enumerate surfaces, hr %#lx.\n", hr);
     ok(!param.count, "Got unexpected number of enumerated surfaces %u.\n", param.count);
 
     IDirectDraw7_Release(ddraw);
@@ -16221,26 +16221,26 @@ static void test_viewport(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Well, by default the vertices without color info should be white, and without any texture
      * ops this should just show up in the output, but the r200 driver begs to differ and draws a
      * random color. */
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_TEXTUREFACTOR, 0x00ffffff);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetViewport(device, NULL);
-    ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
 
     ds = get_depth_stencil(device);
     memset(&surface_desc, 0, sizeof(surface_desc));
@@ -16261,23 +16261,23 @@ static void test_viewport(void)
             surface_desc.dwHeight = rt_sizes[i].y;
             surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
             hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &rt, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             surface_desc.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
             surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
             U4(surface_desc).ddpfPixelFormat = z_fmt;
             hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &ds, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirectDrawSurface7_AddAttachedSurface(rt, ds);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice7_SetRenderTarget(device, rt, 0);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         }
         else
         {
             hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         }
 
         for (j = 0; j < ARRAY_SIZE(tests); ++j)
@@ -16286,32 +16286,32 @@ static void test_viewport(void)
 
             hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000,
                     tests[j].expected_z - z_eps, 0);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZFUNC, D3DCMP_GREATER);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, !i);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice7_SetViewport(device, &tests[j].vp);
             if (tests[j].vp.dwX + tests[j].vp.dwWidth > rt_sizes[i].x
                     || tests[j].vp.dwY + tests[j].vp.dwHeight > rt_sizes[i].y)
             {
-                ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+                ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
                 winetest_pop_context();
                 continue;
             }
             else
             {
-                ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+                ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             }
 
             hr = IDirect3DDevice7_BeginScene(device);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, 0);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice7_EndScene(device);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             check_rect(rt, tests[j].expected_rect);
 
@@ -16319,16 +16319,16 @@ static void test_viewport(void)
             {
                 hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000,
                         tests[j].expected_z + z_eps, 0);
-                ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+                ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
                 hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZFUNC, D3DCMP_LESS);
-                ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+                ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
                 hr = IDirect3DDevice7_BeginScene(device);
-                ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+                ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
                 hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, 0);
-                ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+                ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
                 hr = IDirect3DDevice7_EndScene(device);
-                ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+                ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
                 check_rect(rt, tests[j].expected_rect);
             }
@@ -16337,7 +16337,7 @@ static void test_viewport(void)
         }
 
         hr = IDirectDrawSurface7_DeleteAttachedSurface(rt, 0, ds);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         IDirectDrawSurface7_Release(ds);
         IDirectDrawSurface7_Release(rt);
 
@@ -16345,7 +16345,7 @@ static void test_viewport(void)
     }
 
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     IDirectDraw7_Release(ddraw);
     DestroyWindow(window);
 }
@@ -16360,7 +16360,7 @@ static unsigned int validate_loaded_surface(IDirectDrawSurface7 *surface, unsign
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface7_Lock(surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-    ok(SUCCEEDED(hr), "Failed to map surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to map surface, hr %#lx.\n", hr);
 
     for (y = 0, diff = 0; y < surface_desc.dwHeight; ++y)
     {
@@ -16390,7 +16390,7 @@ static unsigned int validate_loaded_surface(IDirectDrawSurface7 *surface, unsign
     }
 
     hr = IDirectDrawSurface7_Unlock(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to unmap surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to unmap surface, hr %#lx.\n", hr);
 
     return diff;
 }
@@ -16459,14 +16459,14 @@ static void test_device_load(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get Direct3D7 interface, hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#lx.\n", hr);
     IDirect3D7_Release(d3d);
 
     memset(&d3d_caps, 0, sizeof(d3d_caps));
     hr = IDirect3DDevice7_GetCaps(device, &d3d_caps);
-    ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get caps, hr %#lx.\n", hr);
     cube_support = d3d_caps.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_CUBEMAP;
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
@@ -16503,7 +16503,7 @@ static void test_device_load(void)
         U3(U4(surface_desc).ddpfPixelFormat).dwGBitMask = 0x0000ff00;
         U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &src_surface, NULL);
-        ok(SUCCEEDED(hr), "Test %u: Failed to create source surface, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to create source surface, hr %#lx.\n", i, hr);
 
         surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
         if (tests[i].dst_mip_count)
@@ -16520,7 +16520,7 @@ static void test_device_load(void)
         surface_desc.dwHeight = tests[i].dst_h;
         U2(surface_desc).dwMipMapCount = tests[i].dst_mip_count;
         hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &dst_surface, NULL);
-        ok(SUCCEEDED(hr), "Test %u: Failed to create destination surface, hr %#x.\n", i, hr);
+        ok(SUCCEEDED(hr), "Test %u: Failed to create destination surface, hr %#lx.\n", i, hr);
 
         src_count = dst_count = 1;
         if (tests[i].src_flags & TEX_MIP)
@@ -16540,9 +16540,9 @@ static void test_device_load(void)
                 memset(&surface_desc, 0, sizeof(surface_desc));
                 surface_desc.dwSize = sizeof(surface_desc);
                 hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
-                ok(SUCCEEDED(hr), "Test %u: Failed to get surface description, hr %#x.\n", i, hr);
+                ok(SUCCEEDED(hr), "Test %u: Failed to get surface description, hr %#lx.\n", i, hr);
                 ok(U2(surface_desc).dwMipMapCount == src_count,
-                        "Test %u: Got unexpected mip count %u, expected %u.\n",
+                        "Test %u: Got unexpected mip count %lu, expected %u.\n",
                         i, U2(surface_desc).dwMipMapCount, src_count);
             }
 
@@ -16551,7 +16551,7 @@ static void test_device_load(void)
                 memset(&surface_desc, 0, sizeof(surface_desc));
                 surface_desc.dwSize = sizeof(surface_desc);
                 hr = IDirectDrawSurface7_Lock(surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
-                ok(SUCCEEDED(hr), "Test %u: Failed to map surface, hr %#x.\n", i, hr);
+                ok(SUCCEEDED(hr), "Test %u: Failed to map surface, hr %#lx.\n", i, hr);
 
                 for (y = 0; y < surface_desc.dwHeight; ++y)
                 {
@@ -16568,7 +16568,7 @@ static void test_device_load(void)
                 }
 
                 hr = IDirectDrawSurface7_Unlock(surface, NULL);
-                ok(SUCCEEDED(hr), "Test %u: Failed to unmap surface, hr %#x.\n", i, hr);
+                ok(SUCCEEDED(hr), "Test %u: Failed to unmap surface, hr %#lx.\n", i, hr);
 
                 hr = IDirectDrawSurface7_GetAttachedSurface(surface, &mip_caps, &tmp);
                 IDirectDrawSurface7_Release(surface);
@@ -16597,9 +16597,9 @@ static void test_device_load(void)
                 memset(&surface_desc, 0, sizeof(surface_desc));
                 surface_desc.dwSize = sizeof(surface_desc);
                 hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
-                ok(SUCCEEDED(hr), "Test %u: Failed to get surface description, hr %#x.\n", i, hr);
+                ok(SUCCEEDED(hr), "Test %u: Failed to get surface description, hr %#lx.\n", i, hr);
                 ok(U2(surface_desc).dwMipMapCount == dst_count,
-                        "Test %u: Got unexpected mip count %u, expected %u.\n",
+                        "Test %u: Got unexpected mip count %lu, expected %u.\n",
                         i, U2(surface_desc).dwMipMapCount, dst_count);
             }
 
@@ -16609,7 +16609,7 @@ static void test_device_load(void)
                 fx.dwSize = sizeof(fx);
                 U5(fx).dwFillColor = 0x00000000;
                 hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-                ok(SUCCEEDED(hr), "Test %u: Failed to clear surface, hr %#x.\n", i, hr);
+                ok(SUCCEEDED(hr), "Test %u: Failed to clear surface, hr %#lx.\n", i, hr);
 
                 hr = IDirectDrawSurface7_GetAttachedSurface(surface, &mip_caps, &tmp);
                 IDirectDrawSurface7_Release(surface);
@@ -16632,7 +16632,7 @@ static void test_device_load(void)
                 dst_surface, tests[i].dst_flags & NULL_COORDS ? NULL : &dst_point,
                 src_surface, tests[i].src_flags & NULL_COORDS ? NULL : &src_rect,
                 tests[i].dst_flags & TEX_CUBE ? DDSCAPS2_CUBEMAP_ALLFACES : 0);
-        ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         if (SUCCEEDED(hr))
         {
@@ -16756,46 +16756,46 @@ static void test_device_load(void)
     U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8;
     U1(U4(surface_desc).ddpfPixelFormat).dwRGBBitCount = 8;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &src_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create source surface, hr %#lx.\n", hr);
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &dst_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create destination surface, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetAttachedSurface(src_surface, &mip_caps, &surface);
-    ok(SUCCEEDED(hr), "Failed to get surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get surface, hr %#lx.\n", hr);
 
     /* Test palette copying. */
     memset(table1, 0, sizeof(table1));
     table1[0].peBlue = 1;
     hr = IDirectDraw7_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, table1, &src_palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create source palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create source palette, hr %#lx.\n", hr);
     table1[0].peBlue = 3;
     hr = IDirectDraw7_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, table1, &dst_palette, NULL);
-    ok(SUCCEEDED(hr), "Failed to create destination palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create destination palette, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_SetPalette(src_surface, src_palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Load(device, dst_surface, NULL, src_surface, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to load texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to load texture, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_GetPalette(surface, &palette);
-    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetPalette(dst_surface, &palette);
-    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_SetPalette(surface, src_palette);
-    ok(hr == DDERR_NOTONMIPMAPSUBLEVEL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTONMIPMAPSUBLEVEL, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_SetPalette(dst_surface, dst_palette);
-    ok(SUCCEEDED(hr), "Failed to set palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set palette, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Load(device, dst_surface, NULL, src_surface, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to load texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to load texture, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_GetPalette(dst_surface, &palette);
-    ok(SUCCEEDED(hr), "Failed to get palette, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get palette, hr %#lx.\n", hr);
     ok(palette == dst_palette, "Got unexpected palette %p, expected %p.\n", palette, dst_palette);
     memset(table1, 0, sizeof(table1));
     hr = IDirectDrawPalette_GetEntries(palette, 0, 0, 256, table1);
-    ok(SUCCEEDED(hr), "Failed to retrieve palette entries, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to retrieve palette entries, hr %#lx.\n", hr);
     ok(table1[0].peBlue == 1, "Got unexpected palette colour %#x.\n", (unsigned int)table1[0].peBlue);
     IDirectDrawPalette_Release(palette);
 
@@ -16806,20 +16806,20 @@ static void test_device_load(void)
     colour_key.dwColorSpaceLowValue = 32;
     colour_key.dwColorSpaceHighValue = 64;
     hr = IDirectDrawSurface7_SetColorKey(src_surface, DDCKEY_SRCBLT, &colour_key);
-    ok(SUCCEEDED(hr), "Failed to set colour-key, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set colour-key, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_SetColorKey(surface, DDCKEY_SRCBLT, &colour_key);
-    ok(hr == DDERR_NOTONMIPMAPSUBLEVEL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTONMIPMAPSUBLEVEL, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_GetColorKey(dst_surface, DDCKEY_SRCBLT, &colour_key);
-    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOCOLORKEY, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Load(device, dst_surface, NULL, src_surface, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to load texture, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to load texture, hr %#lx.\n", hr);
 
     hr = IDirectDrawSurface7_GetColorKey(dst_surface, DDCKEY_SRCBLT, &colour_key);
-    ok(SUCCEEDED(hr), "Failed to get colour-key, hr %#x.\n", hr);
-    ok(colour_key.dwColorSpaceLowValue == 32, "Got unexpected value %u.\n", colour_key.dwColorSpaceLowValue);
-    ok(colour_key.dwColorSpaceHighValue == 32, "Got unexpected value %u.\n", colour_key.dwColorSpaceHighValue);
+    ok(SUCCEEDED(hr), "Failed to get colour-key, hr %#lx.\n", hr);
+    ok(colour_key.dwColorSpaceLowValue == 32, "Got unexpected value %lu.\n", colour_key.dwColorSpaceLowValue);
+    ok(colour_key.dwColorSpaceHighValue == 32, "Got unexpected value %lu.\n", colour_key.dwColorSpaceHighValue);
 
     IDirectDrawSurface7_Release(surface);
     IDirectDrawSurface7_Release(dst_surface);
@@ -16827,7 +16827,7 @@ static void test_device_load(void)
 
     IDirectDraw7_Release(ddraw);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -16917,50 +16917,50 @@ static void test_color_vertex(void)
         return;
     }
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get render target, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, TRUE);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_AMBIENT, 0xffffffff);
-    ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
     memset(&material, 0, sizeof(material));
     U3(U1(material).ambient).b = 0.5f;
     U3(U3(material).emissive).b = 0.25f;
     hr = IDirect3DDevice7_SetMaterial(device, &material);
-    ok(SUCCEEDED(hr), "Failed to set material, hr %#x\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set material, hr %#lx\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_COLORVERTEX, tests[i].color_vertex);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_AMBIENTMATERIALSOURCE, tests[i].ambient);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_EMISSIVEMATERIALSOURCE, tests[i].emissive);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-        ok(SUCCEEDED(hr), "Failed to set render state, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to set render state, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0);
-        ok(SUCCEEDED(hr), "Failed to clear depth/stencil, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to clear depth/stencil, hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
                 D3DFVF_XYZ | tests[i].fvf, tests[i].vtx, 4, 0);
-        ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to draw, hr %#lx.\n", hr);
         hr = IDirect3DDevice7_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr);
 
         colour = get_surface_color(rt, 320, 240);
         ok(compare_color(colour, tests[i].result, 1),
-                "Expected colour 0x%08x for test %u, got 0x%08x.\n",
+                "Expected colour 0x%08lx for test %u, got 0x%08lx.\n",
                 tests[i].result, i, colour);
     }
 
     IDirectDrawSurface7_Release(rt);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -16974,9 +16974,9 @@ static LRESULT CALLBACK killfocus_proc(HWND window, UINT message, WPARAM wparam,
     if (message == WM_KILLFOCUS)
     {
         ref = IDirectDrawSurface7_Release(killfocus_surface);
-        ok(!ref, "Unexpected surface refcount %u.\n", ref);
+        ok(!ref, "Unexpected surface refcount %lu.\n", ref);
         ref = IDirectDraw7_Release(killfocus_ddraw);
-        ok(!ref, "Unexpected ddraw refcount %u.\n", ref);
+        ok(!ref, "Unexpected ddraw refcount %lu.\n", ref);
         killfocus_ddraw = NULL;
     }
 
@@ -17001,14 +17001,14 @@ static void test_killfocus(void)
     ok(!!killfocus_ddraw, "Failed to create a ddraw object.\n");
 
     hr = IDirectDraw7_SetCooperativeLevel(killfocus_ddraw, window, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw7_CreateSurface(killfocus_ddraw, &surface_desc, &killfocus_surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create surface, hr %#lx.\n", hr);
 
     SetForegroundWindow(GetDesktopWindow());
     ok(!killfocus_ddraw, "WM_KILLFOCUS was not received.\n");
@@ -17057,53 +17057,53 @@ static void test_sysmem_draw(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     vb_desc.dwSize = sizeof(vb_desc);
     vb_desc.dwCaps = D3DVBCAPS_SYSTEMMEMORY;
     vb_desc.dwFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE;
     vb_desc.dwNumVertices = 4;
     hr = IDirect3D7_CreateVertexBuffer(d3d, &vb_desc, &vb, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DVertexBuffer7_Lock(vb, 0, (void **)&data, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     memcpy(data, quad, sizeof(quad));
     hr = IDirect3DVertexBuffer7_Unlock(vb);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, 0, 4, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     colour = get_surface_color(rt, 320, 240);
-    ok(compare_color(colour, 0x00007f7f, 1), "Got unexpected colour 0x%08x.\n", colour);
+    ok(compare_color(colour, 0x00007f7f, 1), "Got unexpected colour 0x%08lx.\n", colour);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawIndexedPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, 0, 4, indices, 4, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     colour = get_surface_color(rt, 320, 240);
-    ok(compare_color(colour, 0x00007f7f, 1), "Got unexpected colour 0x%08x.\n", colour);
+    ok(compare_color(colour, 0x00007f7f, 1), "Got unexpected colour 0x%08lx.\n", colour);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -17119,19 +17119,19 @@ static void test_sysmem_draw(void)
     U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
     U5(U4(surface_desc).ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &texture, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTexture(device, 0, texture);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x77777777, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, vb, 0, 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(hr == D3D_OK || hr == D3DERR_SCENE_END_FAILED, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK || hr == D3DERR_SCENE_END_FAILED, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(texture);
     IDirect3DVertexBuffer7_Release(vb);
@@ -17139,7 +17139,7 @@ static void test_sysmem_draw(void)
     IDirectDraw7_Release(ddraw);
     IDirect3D7_Release(d3d);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -17157,38 +17157,38 @@ static void test_gdi_surface(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     /* Retrieving the GDI surface requires a primary surface to exist. */
     gdi_surface = (void *)0xc0dec0de;
     hr = IDirectDraw7_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
     ok(!gdi_surface, "Got unexpected surface %p.\n", gdi_surface);
 
     hr = IDirectDraw7_FlipToGDISurface(ddraw);
-    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw7_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(gdi_surface == primary, "Got unexpected surface %p, expected %p.\n", gdi_surface, primary);
     IDirectDrawSurface7_Release(gdi_surface);
 
     /* Flipping to the GDI surface requires the primary surface to be
      * flippable. */
     hr = IDirectDraw7_FlipToGDISurface(ddraw);
-    ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_NOTFLIPPABLE, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(primary);
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -17196,40 +17196,40 @@ static void test_gdi_surface(void)
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
     U5(surface_desc).dwBackBufferCount = 1;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &primary, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_GetAttachedSurface(primary, &caps, &backbuffer);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(backbuffer != primary, "Got unexpected backbuffer %p.\n", backbuffer);
 
     hr = IDirectDraw7_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(gdi_surface == primary, "Got unexpected surface %p, expected %p.\n", gdi_surface, primary);
     IDirectDrawSurface7_Release(gdi_surface);
 
     hr = IDirectDrawSurface7_Flip(primary, NULL, DDFLIP_WAIT);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(gdi_surface == backbuffer || broken(gdi_surface == primary),
             "Got unexpected surface %p, expected %p.\n", gdi_surface, backbuffer);
     IDirectDrawSurface7_Release(gdi_surface);
 
     hr = IDirectDraw7_FlipToGDISurface(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw7_GetGDISurface(ddraw, &gdi_surface);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(gdi_surface == primary, "Got unexpected surface %p, expected %p.\n", gdi_surface, primary);
     IDirectDrawSurface7_Release(gdi_surface);
 
     hr = IDirectDraw7_FlipToGDISurface(ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDrawSurface7_Release(backbuffer);
     IDirectDrawSurface7_Release(primary);
 
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -17287,52 +17287,52 @@ static void test_multiply_transform(void)
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
         hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         ok(!memcmp(&ret_mat, &mat1, sizeof(mat1)), "Test %u: Got unexpected transform matrix.\n", i);
 
         hr = IDirect3DDevice7_MultiplyTransform(device, tests[i], &mat2);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         ok(!memcmp(&ret_mat, &mat2, sizeof(mat2)), "Test %u: Got unexpected transform matrix.\n", i);
 
         /* MultiplyTransform() goes directly into the primary stateblock. */
 
         hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat1);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice7_BeginStateBlock(device);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice7_MultiplyTransform(device, tests[i], &mat2);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice7_EndStateBlock(device, &stateblock);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         ok(!memcmp(&ret_mat, &mat2, sizeof(mat2)), "Test %u: Got unexpected transform matrix.\n", i);
 
         hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice7_SetTransform(device, tests[i], &mat1);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
 
         hr = IDirect3DDevice7_GetTransform(device, tests[i], &ret_mat);
-        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+        ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
         ok(!memcmp(&ret_mat, &mat1, sizeof(mat1)), "Test %u: Got unexpected transform matrix.\n", i);
 
         IDirect3DDevice7_DeleteStateBlock(device, stateblock);
     }
 
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -17388,61 +17388,61 @@ static void test_alphatest(void)
         return;
     }
     hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHATESTENABLE, TRUE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(test_data); ++i)
     {
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHAFUNC, test_data[i].func);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, ALPHATEST_FAILED, 0.0f, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHAREF, 0x70);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice7_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
                 D3DFVF_XYZ | D3DFVF_DIFFUSE, quad, ARRAY_SIZE(quad), 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice7_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, test_data[i].color_greater, 0),
-                "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n",
+                "Alphatest failed, color 0x%08lx, expected 0x%08lx, alpha > ref, func %u.\n",
                 color, test_data[i].color_greater, test_data[i].func);
 
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, ALPHATEST_FAILED, 0.0f, 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHAREF, 0xff70);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_ALPHAREF, &value);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-        ok(value == 0xff70, "Got unexpected value %#x.\n", value);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+        ok(value == 0xff70, "Got unexpected value %#lx.\n", value);
         hr = IDirect3DDevice7_BeginScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
                 D3DFVF_XYZ | D3DFVF_DIFFUSE, quad, ARRAY_SIZE(quad), 0);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         hr = IDirect3DDevice7_EndScene(device);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
         color = get_surface_color(rt, 320, 240);
         ok(compare_color(color, test_data[i].color_greater, 0),
-                "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n",
+                "Alphatest failed, color 0x%08lx, expected 0x%08lx, alpha > ref, func %u.\n",
                 color, test_data[i].color_greater, test_data[i].func);
     }
 
     IDirectDrawSurface7_Release(rt);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -17463,24 +17463,24 @@ static void test_clipper_refcount(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     surface_desc.dwFlags = DDSD_CAPS;
     surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirectDraw7_CreateClipper(ddraw, 0, &clipper, NULL);
-    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     /* Show that clipper validation doesn't somehow happen through per-clipper vtable
      * pointers. */
     hr = IDirectDraw7_CreateClipper(ddraw, 0, &clipper2, NULL);
-    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
     ok(clipper->lpVtbl == clipper2->lpVtbl, "Got different clipper vtables %p and %p.\n",
             clipper->lpVtbl, clipper2->lpVtbl);
     orig_vtbl = clipper->lpVtbl;
@@ -17488,50 +17488,50 @@ static void test_clipper_refcount(void)
 
     /* Surfaces hold a reference to clippers. No surprises there. */
     hr = IDirectDrawSurface7_SetClipper(surface, clipper);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface7_GetClipper(surface, &clipper2);
-    ok(SUCCEEDED(hr), "Failed to get clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get clipper, hr %#lx.\n", hr);
     ok(clipper == clipper2, "Got clipper %p, expected %p.\n", clipper2, clipper);
     refcount = IDirectDrawClipper_Release(clipper2);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface7_SetClipper(surface, NULL);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     hr = IDirectDrawSurface7_SetClipper(surface, clipper);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
 
     refcount = IDirectDrawSurface7_Release(surface);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     refcount = get_refcount((IUnknown *)clipper);
-    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     /* SetClipper with an invalid pointer crashes. */
 
     /* Clipper methods work with a broken vtable, with the exception of Release. */
     clipper->lpVtbl = (void *)0xdeadbeef;
     refcount = orig_vtbl->AddRef(clipper);
-    todo_wine ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+    todo_wine ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount);
     refcount = orig_vtbl->Release(clipper);
-    ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+    ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
 
     clipper->lpVtbl = orig_vtbl;
     refcount = orig_vtbl->Release(clipper);
-    todo_wine ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
+    todo_wine ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount);
 
     /* Fix the refcount difference because Wine did not increase the ref in the
      * AddRef call above. */
     if (refcount)
     {
         refcount = IDirectDrawClipper_Release(clipper);
-        ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+        ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
     }
 
     /* Steal the reference and see what happens - releasing the surface works fine.
@@ -17539,11 +17539,11 @@ static void test_clipper_refcount(void)
      * release it after the GetClipper call is likely to crash, and certain to crash
      * if we allocate and zero as much heap memory as we can get. */
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirectDraw7_CreateClipper(ddraw, 0, &clipper, NULL);
-    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to create clipper, hr %#lx.\n", hr);
     hr = IDirectDrawSurface7_SetClipper(surface, clipper);
-    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to set clipper, hr %#lx.\n", hr);
 
     IDirectDrawClipper_Release(clipper);
     IDirectDrawClipper_Release(clipper);
@@ -17559,7 +17559,7 @@ static void test_clipper_refcount(void)
          * The same Windows and driver versions run the test without heap corruption on
          * a Geforce 1060 GTX card. I have not seen the problem on AMD GPUs either. */
         hr = IDirectDrawSurface7_GetClipper(surface, &clipper2);
-        ok(SUCCEEDED(hr), "Failed to get clipper, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "Failed to get clipper, hr %#lx.\n", hr);
         ok(clipper == clipper2, "Got clipper %p, expected %p.\n", clipper2, clipper);
     }
 
@@ -17567,10 +17567,10 @@ static void test_clipper_refcount(void)
      * vtable through the clipper pointer because it is no longer pointing to
      * valid memory. */
     refcount = orig_vtbl->Release(clipper);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
 
     refcount = IDirectDrawSurface7_Release(surface);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
 
     /* It looks like the protection against invalid thispointers is part of
      * the IDirectDrawClipper method implementation, not IDirectDrawSurface. */
@@ -17583,33 +17583,33 @@ static void test_clipper_refcount(void)
     clipper->lpVtbl = orig_vtbl;
 
     refcount = orig_vtbl->AddRef(clipper);
-    todo_wine ok(!refcount, "Got refcount %u.\n", refcount);
+    todo_wine ok(!refcount, "Got refcount %lu.\n", refcount);
     refcount = orig_vtbl->AddRef((IDirectDrawClipper *)(ULONG_PTR)0xdeadbeef);
-    ok(!refcount, "Got refcount %u.\n", refcount);
+    ok(!refcount, "Got refcount %lu.\n", refcount);
 
     changed = 0x1234;
     hr = orig_vtbl->IsClipListChanged(clipper, &changed);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     todo_wine ok(changed == 0x1234, "'changed' changed: %x.\n", changed);
 
     changed = 0x1234;
     hr = orig_vtbl->IsClipListChanged((IDirectDrawClipper *)(ULONG_PTR)0xdeadbeef, &changed);
-    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
     ok(changed == 0x1234, "'changed' changed: %x.\n", changed);
 
     /* Nope, we can't initialize our fake clipper. */
     hr = IDirectDraw7_QueryInterface(ddraw, &IID_IDirectDraw, (void **)&ddraw1);
-    ok(SUCCEEDED(hr), "Failed to get ddraw1 interface, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get ddraw1 interface, hr %#lx.\n", hr);
 
     hr = orig_vtbl->Initialize(clipper, ddraw1, 0);
-    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+    todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#lx.\n", hr);
 
     IDirectDraw_Release(ddraw1);
 
     HeapFree(GetProcessHeap(), 0, clipper);
 
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -17631,56 +17631,56 @@ static void test_begin_end_state_block(void)
     }
 
     hr = IDirect3DDevice7_BeginStateBlock(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     stateblock = 0xdeadbeef;
     hr = IDirect3DDevice7_EndStateBlock(device, &stateblock);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(!!stateblock && stateblock != 0xdeadbeef, "Got unexpected stateblock %#x.\n", stateblock);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(!!stateblock && stateblock != 0xdeadbeef, "Got unexpected stateblock %#lx.\n", stateblock);
 
     stateblock2 = 0xdeadbeef;
     hr = IDirect3DDevice7_EndStateBlock(device, &stateblock2);
-    ok(hr == D3DERR_NOTINBEGINSTATEBLOCK, "Got unexpected hr %#x.\n", hr);
-    ok(stateblock2 == 0xdeadbeef, "Got unexpected stateblock %#x.\n", stateblock2);
+    ok(hr == D3DERR_NOTINBEGINSTATEBLOCK, "Got unexpected hr %#lx.\n", hr);
+    ok(stateblock2 == 0xdeadbeef, "Got unexpected stateblock %#lx.\n", stateblock2);
 
     hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_LIGHTING, &value);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(value == TRUE, "Got unexpected value %#x.\n", value);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(value == TRUE, "Got unexpected value %#lx.\n", value);
 
     hr = IDirect3DDevice7_BeginStateBlock(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_BeginStateBlock(device);
-    ok(hr == D3DERR_INBEGINSTATEBLOCK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INBEGINSTATEBLOCK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock);
-    ok(hr == D3DERR_INBEGINSTATEBLOCK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INBEGINSTATEBLOCK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_CaptureStateBlock(device, stateblock);
-    ok(hr == D3DERR_INBEGINSTATEBLOCK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INBEGINSTATEBLOCK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_CreateStateBlock(device, D3DSBT_ALL, &stateblock2);
-    ok(hr == D3DERR_INBEGINSTATEBLOCK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INBEGINSTATEBLOCK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_LIGHTING, &value);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(value == TRUE, "Got unexpected value %#x.\n", value);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(value == TRUE, "Got unexpected value %#lx.\n", value);
 
     hr = IDirect3DDevice7_EndStateBlock(device, &stateblock2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_ApplyStateBlock(device, stateblock2);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_LIGHTING, &value);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-    ok(value == TRUE, "Got unexpected value %#x.\n", value);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+    ok(value == TRUE, "Got unexpected value %#lx.\n", value);
 
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -17732,77 +17732,77 @@ static void test_caps(void)
     hal_caps.dwSize = sizeof(hal_caps);
     hel_caps.dwSize = sizeof(hel_caps);
     hr = IDirectDraw7_GetCaps(ddraw, &hal_caps, &hel_caps);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(hal_caps.ddsOldCaps.dwCaps == hal_caps.ddsCaps.dwCaps,
-            "Got unexpected caps %#x, expected %#x.\n",
+            "Got unexpected caps %#lx, expected %#lx.\n",
             hal_caps.ddsOldCaps.dwCaps, hal_caps.ddsCaps.dwCaps);
     ok(hel_caps.ddsOldCaps.dwCaps == hel_caps.ddsCaps.dwCaps,
-            "Got unexpected caps %#x, expected %#x.\n",
+            "Got unexpected caps %#lx, expected %#lx.\n",
             hel_caps.ddsOldCaps.dwCaps, hel_caps.ddsCaps.dwCaps);
 
     no3d = !(hal_caps.ddsCaps.dwCaps & DDSCAPS_3DDEVICE);
     if (hal_caps.ddsCaps.dwCaps)
     {
-        ok(!(hal_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
-        ok(!(~hal_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(hal_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(~hal_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
         todo_wine_if(no3d) ok(!(~hal_caps.ddsCaps.dwCaps & caps_hal),
-                "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
+                "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
     }
-    ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
-    ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+    ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
+    ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
     todo_wine_if(!no3d) ok(!(hel_caps.ddsCaps.dwCaps & caps_hal),
-            "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+            "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
 
     IDirectDraw7_Release(ddraw);
 
     if (hal_caps.ddsCaps.dwCaps)
     {
         hr = pDirectDrawCreateEx((GUID *)DDCREATE_HARDWAREONLY, (void **)&ddraw, &IID_IDirectDraw7, NULL);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
         memset(&hal_caps, 0, sizeof(hal_caps));
         memset(&hel_caps, 0, sizeof(hel_caps));
         hal_caps.dwSize = sizeof(hal_caps);
         hel_caps.dwSize = sizeof(hel_caps);
         hr = IDirectDraw7_GetCaps(ddraw, &hal_caps, &hel_caps);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         ok(hal_caps.ddsOldCaps.dwCaps == hal_caps.ddsCaps.dwCaps,
-                "Got unexpected caps %#x, expected %#x.\n",
+                "Got unexpected caps %#lx, expected %#lx.\n",
                 hal_caps.ddsOldCaps.dwCaps, hal_caps.ddsCaps.dwCaps);
         ok(hel_caps.ddsOldCaps.dwCaps == hel_caps.ddsCaps.dwCaps,
-                "Got unexpected caps %#x, expected %#x.\n",
+                "Got unexpected caps %#lx, expected %#lx.\n",
                 hel_caps.ddsOldCaps.dwCaps, hel_caps.ddsCaps.dwCaps);
 
-        ok(!(hal_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
-        ok(!(~hal_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(hal_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
+        ok(!(~hal_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
         todo_wine_if(no3d) ok(!(~hal_caps.ddsCaps.dwCaps & caps_hal),
-                "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
-        todo_wine ok(!hel_caps.ddsCaps.dwCaps, "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+                "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
+        todo_wine ok(!hel_caps.ddsCaps.dwCaps, "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
 
         IDirectDraw7_Release(ddraw);
     }
 
     hr = pDirectDrawCreateEx((GUID *)DDCREATE_EMULATIONONLY, (void **)&ddraw, &IID_IDirectDraw7, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&hal_caps, 0, sizeof(hal_caps));
     memset(&hel_caps, 0, sizeof(hel_caps));
     hal_caps.dwSize = sizeof(hal_caps);
     hel_caps.dwSize = sizeof(hel_caps);
     hr = IDirectDraw7_GetCaps(ddraw, &hal_caps, &hel_caps);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     ok(hal_caps.ddsOldCaps.dwCaps == hal_caps.ddsCaps.dwCaps,
-            "Got unexpected caps %#x, expected %#x.\n",
+            "Got unexpected caps %#lx, expected %#lx.\n",
             hal_caps.ddsOldCaps.dwCaps, hal_caps.ddsCaps.dwCaps);
     ok(hel_caps.ddsOldCaps.dwCaps == hel_caps.ddsCaps.dwCaps,
-            "Got unexpected caps %#x, expected %#x.\n",
+            "Got unexpected caps %#lx, expected %#lx.\n",
             hel_caps.ddsOldCaps.dwCaps, hel_caps.ddsCaps.dwCaps);
 
-    todo_wine ok(!hal_caps.ddsCaps.dwCaps, "Got unexpected caps %#x.\n", hal_caps.ddsCaps.dwCaps);
-    ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
-    ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+    todo_wine ok(!hal_caps.ddsCaps.dwCaps, "Got unexpected caps %#lx.\n", hal_caps.ddsCaps.dwCaps);
+    ok(!(hel_caps.ddsCaps.dwCaps & caps_never), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
+    ok(!(~hel_caps.ddsCaps.dwCaps & caps_always), "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
     todo_wine_if(!no3d) ok(!(hel_caps.ddsCaps.dwCaps & caps_hal),
-            "Got unexpected caps %#x.\n", hel_caps.ddsCaps.dwCaps);
+            "Got unexpected caps %#lx.\n", hel_caps.ddsCaps.dwCaps);
 
     IDirectDraw7_Release(ddraw);
 }
@@ -17820,7 +17820,7 @@ static void test_d32_support(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
@@ -17833,25 +17833,25 @@ static void test_d32_support(void)
     surface_desc.dwWidth = 64;
     surface_desc.dwHeight = 64;
     hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
-    ok((surface_desc.dwFlags & DDSD_PIXELFORMAT), "Got unexpected flags %#x.\n", surface_desc.dwFlags);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
+    ok((surface_desc.dwFlags & DDSD_PIXELFORMAT), "Got unexpected flags %#lx.\n", surface_desc.dwFlags);
     ok(U4(surface_desc).ddpfPixelFormat.dwFlags & DDPF_ZBUFFER,
-            "Got unexpected format flags %#x.\n", U4(surface_desc).ddpfPixelFormat.dwFlags);
+            "Got unexpected format flags %#lx.\n", U4(surface_desc).ddpfPixelFormat.dwFlags);
     ok(U1(U4(surface_desc).ddpfPixelFormat).dwZBufferBitDepth == 32,
-            "Got unexpected dwZBufferBitDepth %u.\n", U1(U4(surface_desc).ddpfPixelFormat).dwZBufferBitDepth);
+            "Got unexpected dwZBufferBitDepth %lu.\n", U1(U4(surface_desc).ddpfPixelFormat).dwZBufferBitDepth);
     ok(U3(U4(surface_desc).ddpfPixelFormat).dwZBitMask == 0xffffffff,
-            "Got unexpected Z mask 0x%08x.\n", U3(U4(surface_desc).ddpfPixelFormat).dwZBitMask);
+            "Got unexpected Z mask 0x%08lx.\n", U3(U4(surface_desc).ddpfPixelFormat).dwZBitMask);
     ok(!(surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY),
-            "Got unexpected surface caps %#x.\n", surface_desc.ddsCaps.dwCaps);
+            "Got unexpected surface caps %#lx.\n", surface_desc.ddsCaps.dwCaps);
     IDirectDrawSurface7_Release(surface);
 
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -18053,11 +18053,11 @@ static void test_surface_format_conversion_alpha(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_EnumTextureFormats(device, test_block_formats_creation_cb,
             &supported_fmts);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     is_wine = !strcmp(winetest_platform, "wine");
 
@@ -18095,17 +18095,17 @@ static void test_surface_format_conversion_alpha(void)
             U4(surface_desc).ddpfPixelFormat = src_format->fmt;
             surface_desc.ddsCaps.dwCaps = test_caps[j].src_caps;
             hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &src_surf, NULL);
-            ok(hr == DD_OK, "Test (%u, %u), got unexpected hr %#x.\n", j, i, hr);
+            ok(hr == DD_OK, "Test (%u, %u), got unexpected hr %#lx.\n", j, i, hr);
 
             U4(surface_desc).ddpfPixelFormat = dst_format->fmt;
             surface_desc.ddsCaps.dwCaps = test_caps[j].dst_caps;
             hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &dst_surf, NULL);
-            ok(hr == DD_OK, "Test (%u, %u), got unexpected hr %#x.\n", j, i, hr);
+            ok(hr == DD_OK, "Test (%u, %u), got unexpected hr %#lx.\n", j, i, hr);
 
             memset(&lock, 0, sizeof(lock));
             lock.dwSize = sizeof(lock);
             hr = IDirectDrawSurface7_Lock(src_surf, NULL, &lock, 0, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             pitch = U1(lock).lPitch;
             for (y = 0; y < src_format->y_blocks; ++y)
             {
@@ -18114,7 +18114,7 @@ static void test_surface_format_conversion_alpha(void)
                         src_format->block_size * src_format->x_blocks);
             }
             hr = IDirectDrawSurface7_Unlock(src_surf, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirectDrawSurface7_Blt(dst_surf, NULL, src_surf, NULL, DDBLT_WAIT, NULL);
             if (!is_wine && FAILED(hr))
@@ -18122,17 +18122,17 @@ static void test_surface_format_conversion_alpha(void)
                 /* Some software blits are rejected on Windows. */
                 IDirectDrawSurface7_Release(dst_surf);
                 IDirectDrawSurface7_Release(src_surf);
-                skip("Skipping test (%u, %u), cannot blit %s -> %s, hr %#x.\n", j, i,
+                skip("Skipping test (%u, %u), cannot blit %s -> %s, hr %#lx.\n", j, i,
                         src_format->name, dst_format->name, hr);
                 continue;
             }
-            ok(hr == DD_OK, "Test (%u, %s -> %s), got unexpected hr %#x.\n", j,
+            ok(hr == DD_OK, "Test (%u, %s -> %s), got unexpected hr %#lx.\n", j,
                     src_format->name, dst_format->name, hr);
 
             memset(&lock, 0, sizeof(lock));
             lock.dwSize = sizeof(lock);
             hr = IDirectDrawSurface7_Lock(dst_surf, NULL, &lock, 0, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
             pitch = U1(lock).lPitch;
 
             for (y = 0; y < dst_format->y_blocks; ++y)
@@ -18160,7 +18160,7 @@ static void test_surface_format_conversion_alpha(void)
                     break;
             }
             hr = IDirectDrawSurface7_Unlock(dst_surf, NULL);
-            ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
             IDirectDrawSurface7_Release(dst_surf);
             IDirectDrawSurface7_Release(src_surf);
@@ -18169,7 +18169,7 @@ static void test_surface_format_conversion_alpha(void)
 
     IDirect3DDevice7_Release(device);
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -18263,11 +18263,11 @@ static void test_compressed_surface_stretch(void)
     ddraw = create_ddraw();
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_EnumTextureFormats(device, test_block_formats_creation_cb,
             &supported_fmts);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&src_surface_desc, 0, sizeof(src_surface_desc));
     src_surface_desc.dwSize = sizeof(src_surface_desc);
@@ -18314,22 +18314,22 @@ static void test_compressed_surface_stretch(void)
             rb_surface_desc.dwHeight = max(src_surface_desc.dwHeight, dst_surface_desc.dwHeight);
 
             hr = IDirectDraw7_CreateSurface(ddraw, &rb_surface_desc, &rb_surf, NULL);
-            ok(hr == DD_OK, "Test (%u, %u), got unexpected hr %#x.\n", i, j, hr);
+            ok(hr == DD_OK, "Test (%u, %u), got unexpected hr %#lx.\n", i, j, hr);
 
             for (k = 0; k < ARRAY_SIZE(test_formats); ++k)
             {
                 U4(src_surface_desc).ddpfPixelFormat = test_formats[k].fmt;
                 hr = IDirectDraw7_CreateSurface(ddraw, &src_surface_desc, &src_surf, NULL);
-                ok(hr == DD_OK, "Test (%u, %u, %u), got unexpected hr %#x.\n", i, j, k, hr);
+                ok(hr == DD_OK, "Test (%u, %u, %u), got unexpected hr %#lx.\n", i, j, k, hr);
 
                 U5(fx).dwFillColor = 0x801f;
                 hr = IDirectDrawSurface7_Blt(rb_surf, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-                ok(hr == DD_OK, "Test (%u, %u, %u), got unexpected hr %#x.\n", i, j, k, hr);
+                ok(hr == DD_OK, "Test (%u, %u, %u), got unexpected hr %#lx.\n", i, j, k, hr);
 
                 hr = IDirectDrawSurface7_Blt(src_surf, &src_rect, rb_surf, &src_rect, DDBLT_WAIT, NULL);
 
                 todo_wine_if(test_formats[k].fmt.dwFlags == DDPF_FOURCC && test_sizes[j].todo_src)
-                ok(hr == DD_OK, "Test (%u, %u, %u), got unexpected hr %#x.\n", i, j, k, hr);
+                ok(hr == DD_OK, "Test (%u, %u, %u), got unexpected hr %#lx.\n", i, j, k, hr);
                 if (FAILED(hr))
                 {
                     IDirectDrawSurface7_Release(src_surf);
@@ -18347,7 +18347,7 @@ static void test_compressed_surface_stretch(void)
                     U4(dst_surface_desc).ddpfPixelFormat = test_formats[l].fmt;
 
                     hr = IDirectDraw7_CreateSurface(ddraw, &dst_surface_desc, &dst_surf, NULL);
-                    ok(hr == DD_OK, "Test (%u, %u, %u, %u), got unexpected hr %#x.\n", i, j, k, l, hr);
+                    ok(hr == DD_OK, "Test (%u, %u, %u, %u), got unexpected hr %#lx.\n", i, j, k, l, hr);
 
                     memset(&lock, 0, sizeof(lock));
                     lock.dwSize = sizeof(lock);
@@ -18360,15 +18360,15 @@ static void test_compressed_surface_stretch(void)
                     if (test_formats[l].fmt.dwFourCC == MAKEFOURCC('D', 'X', 'T', '3'))
                     {
                         hr = IDirectDrawSurface7_Lock(dst_surf, NULL, &lock, 0, NULL);
-                        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+                        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
                         memset(lock.lpSurface, 0, U1(lock).dwLinearSize);
                         hr = IDirectDrawSurface7_Unlock(dst_surf, NULL);
-                        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+                        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
                     }
 
                     hr = IDirectDrawSurface7_Blt(dst_surf, &dst_rect, src_surf, &src_rect, DDBLT_WAIT, NULL);
                     todo_wine_if(test_formats[l].fmt.dwFlags == DDPF_FOURCC && test_sizes[j].todo_dst)
-                    ok(hr == DD_OK, "Test (%u, %u, %u, %u), got unexpected hr %#x.\n", i, j, k, l, hr);
+                    ok(hr == DD_OK, "Test (%u, %u, %u, %u), got unexpected hr %#lx.\n", i, j, k, l, hr);
                     if (FAILED(hr))
                     {
                         IDirectDrawSurface7_Release(dst_surf);
@@ -18377,12 +18377,12 @@ static void test_compressed_surface_stretch(void)
 
                     U5(fx).dwFillColor = 0xffffffff;
                     hr = IDirectDrawSurface7_Blt(rb_surf, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-                    ok(hr == DD_OK, "Test (%u, %u, %u, %u), got unexpected hr %#x.\n", i, j, k, l, hr);
+                    ok(hr == DD_OK, "Test (%u, %u, %u, %u), got unexpected hr %#lx.\n", i, j, k, l, hr);
 
                     hr = IDirectDrawSurface7_Blt(rb_surf, &dst_rect, dst_surf, &dst_rect, DDBLT_WAIT, NULL);
-                    ok(hr == DD_OK, "Test (%u, %u, %u, %u), got unexpected hr %#x.\n", i, j, k, l, hr);
+                    ok(hr == DD_OK, "Test (%u, %u, %u, %u), got unexpected hr %#lx.\n", i, j, k, l, hr);
                     hr = IDirectDrawSurface7_Lock(rb_surf, NULL, &lock, 0, NULL);
-                    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+                    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
                     pitch = U1(lock).lPitch;
 
                     passed = TRUE;
@@ -18408,7 +18408,7 @@ static void test_compressed_surface_stretch(void)
 
     IDirect3DDevice7_Release(device);
     refcount = IDirectDraw7_Release(ddraw);
-    ok(!refcount, "%u references left.\n", refcount);
+    ok(!refcount, "%lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -18470,13 +18470,13 @@ static void test_cursor_clipping(void)
     memset(&surface_desc, 0, sizeof(surface_desc));
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw7_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "GetDisplayMode failed, hr %#lx.\n", hr);
 
     memset(&param, 0, sizeof(param));
     param.old_width = surface_desc.dwWidth;
     param.old_height = surface_desc.dwHeight;
     hr = IDirectDraw7_EnumDisplayModes(ddraw, 0, NULL, &param, find_different_mode_callback);
-    ok(hr == DD_OK, "EnumDisplayModes failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "EnumDisplayModes failed, hr %#lx.\n", hr);
     if (!(param.new_width && param.new_height))
     {
         skip("Failed to find a different mode than %ux%u.\n", param.old_width, param.old_height);
@@ -18484,87 +18484,87 @@ static void test_cursor_clipping(void)
     }
 
     ret = ClipCursor(NULL);
-    ok(ret, "ClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "ClipCursor failed, error %#lx.\n", GetLastError());
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     /* Set cooperative level to normal */
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     flush_events();
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     hr = set_display_mode(ddraw, param.new_width, param.new_height);
-    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode failed, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
-        win_skip("SetDisplayMode failed, hr %#x.\n", hr);
+        win_skip("SetDisplayMode failed, hr %#lx.\n", hr);
         goto done;
     }
     flush_events();
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     hr = IDirectDraw7_RestoreDisplayMode(ddraw);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
     flush_events();
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     /* Switch to full screen cooperative level */
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     flush_events();
     SetRect(&rect, 0, 0, param.old_width, param.old_height);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     hr = set_display_mode(ddraw, param.new_width, param.new_height);
-    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode failed, hr %#lx.\n", hr);
     if (FAILED(hr))
     {
-        win_skip("SetDisplayMode failed, hr %#x.\n", hr);
+        win_skip("SetDisplayMode failed, hr %#lx.\n", hr);
         goto done;
     }
     flush_events();
     SetRect(&rect, 0, 0, param.new_width, param.new_height);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     /* Restore display mode */
     hr = IDirectDraw7_RestoreDisplayMode(ddraw);
-    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "RestoreDisplayMode failed, hr %#lx.\n", hr);
     flush_events();
     SetRect(&rect, 0, 0, param.old_width, param.old_height);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
     /* Switch to normal cooperative level */
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     flush_events();
     get_virtual_rect(&rect);
     ret = GetClipCursor(&clip_rect);
-    ok(ret, "GetClipCursor failed, error %#x.\n", GetLastError());
+    ok(ret, "GetClipCursor failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&clip_rect, &rect), "Expect clip rect %s, got %s.\n", wine_dbgstr_rect(&rect),
             wine_dbgstr_rect(&clip_rect));
 
@@ -18591,10 +18591,10 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
     flush_events();
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     flush_events();
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "GetWindowRect failed, error %#x.\n", GetLastError());
+    ok(ret, "GetWindowRect failed, error %#lx.\n", GetLastError());
     SetRect(&primary_rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
     ok(EqualRect(&window_rect, &primary_rect), "Expect window rect %s, got %s.\n",
             wine_dbgstr_rect(&primary_rect), wine_dbgstr_rect(&window_rect));
@@ -18605,9 +18605,9 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
 
     ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left,
             new_rect.bottom - new_rect.top, TRUE);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ok(EqualRect(&window_rect, &new_rect),
             "Expected window rect %s, got %s.\n",
             wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect));
@@ -18615,7 +18615,7 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
      * on the second resize remains. */
     flush_events();
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     /* Both Windows and Wine change the size of the window. On Windows it is exactly the new size but in Wine
      * it may get adjusted depending on window manager. */
     ok(window_rect.right != monitor_rect->right && window_rect.bottom != monitor_rect->bottom,
@@ -18624,15 +18624,15 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
 
     ret = MoveWindow(window, new_rect.left, new_rect.top, new_rect.right - new_rect.left,
             new_rect.bottom - new_rect.top, TRUE);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ok(EqualRect(&window_rect, &new_rect),
             "Expected window rect %s, got %s.\n",
             wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect));
     flush_events();
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "Got unexpected ret %#x, error %#x.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, error %#lx.\n", ret, GetLastError());
     ok(window_rect.right != monitor_rect->right && window_rect.bottom != monitor_rect->bottom,
             "Expected window rect %s, got %s.\n",
             wine_dbgstr_rect(monitor_rect), wine_dbgstr_rect(&window_rect));
@@ -18640,25 +18640,25 @@ static BOOL CALLBACK test_window_position_cb(HMONITOR monitor, HDC hdc, RECT *mo
     /* Window activation should restore the window to fit the whole primary monitor */
     ret = SetWindowPos(window, 0, monitor_rect->left, monitor_rect->top, 0, 0,
             SWP_NOZORDER | SWP_NOSIZE);
-    ok(ret, "SetWindowPos failed, error %#x.\n", GetLastError());
+    ok(ret, "SetWindowPos failed, error %#lx.\n", GetLastError());
     ret = SetForegroundWindow(GetDesktopWindow());
     ok(ret, "Failed to set foreground window.\n");
     flush_events();
     ret = ShowWindow(window, SW_RESTORE);
-    ok(ret, "Failed to restore window, error %#x.\n", GetLastError());
+    ok(ret, "Failed to restore window, error %#lx.\n", GetLastError());
     flush_events();
     ret = SetForegroundWindow(window);
-    ok(ret, "SetForegroundWindow failed, error %#x.\n", GetLastError());
+    ok(ret, "SetForegroundWindow failed, error %#lx.\n", GetLastError());
     flush_events();
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "GetWindowRect failed, error %#x.\n", GetLastError());
+    ok(ret, "GetWindowRect failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&window_rect, &primary_rect), "Expect window rect %s, got %s.\n",
             wine_dbgstr_rect(&primary_rect), wine_dbgstr_rect(&window_rect));
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
     ret = GetWindowRect(window, &window_rect);
-    ok(ret, "GetWindowRect failed, error %#x.\n", GetLastError());
+    ok(ret, "GetWindowRect failed, error %#lx.\n", GetLastError());
     ok(EqualRect(&window_rect, &primary_rect), "Expect window rect %s, got %s.\n",
             wine_dbgstr_rect(&primary_rect), wine_dbgstr_rect(&window_rect));
 
@@ -18689,14 +18689,14 @@ static BOOL CALLBACK test_get_display_mode_cb(HMONITOR monitor, HDC hdc, RECT *m
     /* Test that DirectDraw doesn't use the device window to determine which monitor to use */
     ret = SetWindowPos(window, 0, monitor_rect->left, monitor_rect->top, 0, 0,
             SWP_NOZORDER | SWP_NOSIZE);
-    ok(ret, "SetWindowPos failed, error %#x.\n", GetLastError());
+    ok(ret, "SetWindowPos failed, error %#lx.\n", GetLastError());
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw7_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == GetSystemMetrics(SM_CXSCREEN), "Expect width %d, got %d.\n",
+    ok(hr == DD_OK, "GetDisplayMode failed, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == GetSystemMetrics(SM_CXSCREEN), "Expect width %d, got %ld.\n",
             GetSystemMetrics(SM_CXSCREEN), surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == GetSystemMetrics(SM_CYSCREEN), "Expect height %d, got %d.\n",
+    ok(surface_desc.dwHeight == GetSystemMetrics(SM_CYSCREEN), "Expect height %d, got %ld.\n",
             GetSystemMetrics(SM_CYSCREEN), surface_desc.dwHeight);
 
     DestroyWindow(window);
@@ -18723,41 +18723,41 @@ static void test_get_display_mode(void)
     ok(!!window, "Failed to create a window.\n");
 
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr);
 
     memset(&devmode, 0, sizeof(devmode));
     devmode.dmSize = sizeof(devmode);
     ret = EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &devmode);
-    ok(ret, "EnumDisplaySettingsW failed, error %#x.\n", GetLastError());
+    ok(ret, "EnumDisplaySettingsW failed, error %#lx.\n", GetLastError());
 
     surface_desc.dwSize = sizeof(surface_desc);
     hr = IDirectDraw7_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
-    ok(surface_desc.dwSize == sizeof(surface_desc), "Expected dwSize %u, got %u.\n",
+    ok(hr == DD_OK, "GetDisplayMode failed, hr %#lx.\n", hr);
+    ok(surface_desc.dwSize == sizeof(surface_desc), "Expected dwSize %Iu, got %lu.\n",
             sizeof(surface_desc), surface_desc.dwSize);
-    ok(surface_desc.dwFlags == flags, "Expected dwFlags %#x, got %#x.\n", flags,
+    ok(surface_desc.dwFlags == flags, "Expected dwFlags %#lx, got %#lx.\n", flags,
             surface_desc.dwFlags);
-    ok(surface_desc.dwWidth == devmode.dmPelsWidth, "Expected width %u, got %u.\n",
+    ok(surface_desc.dwWidth == devmode.dmPelsWidth, "Expected width %lu, got %lu.\n",
             devmode.dmPelsWidth, surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == devmode.dmPelsHeight, "Expected height %u, got %u.\n",
+    ok(surface_desc.dwHeight == devmode.dmPelsHeight, "Expected height %lu, got %lu.\n",
             devmode.dmPelsHeight, surface_desc.dwHeight);
-    ok(surface_desc.dwRefreshRate == devmode.dmDisplayFrequency, "Expected frequency %u, got %u.\n",
+    ok(surface_desc.dwRefreshRate == devmode.dmDisplayFrequency, "Expected frequency %lu, got %lu.\n",
             devmode.dmDisplayFrequency, surface_desc.dwRefreshRate);
     ok(surface_desc.ddpfPixelFormat.dwSize == sizeof(surface_desc.ddpfPixelFormat),
-            "Expected ddpfPixelFormat.dwSize %u, got %u.\n", sizeof(surface_desc.ddpfPixelFormat),
+            "Expected ddpfPixelFormat.dwSize %Iu, got %lu.\n", sizeof(surface_desc.ddpfPixelFormat),
             surface_desc.ddpfPixelFormat.dwSize);
     ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == devmode.dmBitsPerPel,
-            "Expected ddpfPixelFormat.dwRGBBitCount %u, got %u.\n", devmode.dmBitsPerPel,
+            "Expected ddpfPixelFormat.dwRGBBitCount %lu, got %lu.\n", devmode.dmBitsPerPel,
             surface_desc.ddpfPixelFormat.dwRGBBitCount);
     ok(surface_desc.lPitch == devmode.dmPelsWidth * devmode.dmBitsPerPel / 8,
-            "Expected pitch %u, got %u.\n", devmode.dmPelsWidth * devmode.dmBitsPerPel / 8,
+            "Expected pitch %lu, got %lu.\n", devmode.dmPelsWidth * devmode.dmBitsPerPel / 8,
             surface_desc.lPitch);
 
     memset(&param, 0, sizeof(param));
     param.old_frequency = surface_desc.dwRefreshRate;
     hr = IDirectDraw7_EnumDisplayModes(ddraw, DDEDM_REFRESHRATES, NULL, &param,
             find_different_mode_callback);
-    ok(hr == DD_OK, "EnumDisplayModes failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "EnumDisplayModes failed, hr %#lx.\n", hr);
     if (!param.new_frequency)
     {
         skip("Failed to find a display mode with a different frequency.\n");
@@ -18766,17 +18766,17 @@ static void test_get_display_mode(void)
 
     hr = IDirectDraw7_SetDisplayMode(ddraw, param.new_width, param.new_height, param.new_bpp,
             param.new_frequency, 0);
-    ok(hr == DD_OK, "SetDisplayMode failed, hr %#x.\n", hr);
+    ok(hr == DD_OK, "SetDisplayMode failed, hr %#lx.\n", hr);
     hr = IDirectDraw7_GetDisplayMode(ddraw, &surface_desc);
-    ok(hr == DD_OK, "GetDisplayMode failed, hr %#x.\n", hr);
-    ok(surface_desc.dwWidth == param.new_width, "Expected width %u, got %u.\n", param.new_width,
+    ok(hr == DD_OK, "GetDisplayMode failed, hr %#lx.\n", hr);
+    ok(surface_desc.dwWidth == param.new_width, "Expected width %u, got %lu.\n", param.new_width,
             surface_desc.dwWidth);
-    ok(surface_desc.dwHeight == param.new_height, "Expected height %u, got %u.\n", param.new_height,
+    ok(surface_desc.dwHeight == param.new_height, "Expected height %u, got %lu.\n", param.new_height,
             surface_desc.dwHeight);
-    ok(surface_desc.dwRefreshRate == param.new_frequency, "Expected frequency %u, got %u.\n",
+    ok(surface_desc.dwRefreshRate == param.new_frequency, "Expected frequency %u, got %lu.\n",
             param.new_frequency, surface_desc.dwRefreshRate);
     ok(surface_desc.ddpfPixelFormat.dwRGBBitCount == param.new_bpp,
-            "Expected ddpfPixelFormat.dwRGBBitCount %u, got %u.\n", devmode.dmBitsPerPel,
+            "Expected ddpfPixelFormat.dwRGBBitCount %lu, got %lu.\n", devmode.dmBitsPerPel,
             surface_desc.ddpfPixelFormat.dwRGBBitCount);
 
 done:
@@ -18821,11 +18821,11 @@ static void test_texture_wrong_caps(const GUID *device_guid)
         return;
     }
     hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -18835,47 +18835,47 @@ static void test_texture_wrong_caps(const GUID *device_guid)
     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     U4(ddsd).ddpfPixelFormat = fmt;
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     fill_surface(surface, 0xff00ff00);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetTexture(device, 0, surface);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x000000ff, 0.0f, 0);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     if (is_software_device_type(device_guid))
         fill_surface(rt, 0x000000ff);
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
             D3DFVF_XYZ | D3DFVF_TEX1, quad, 4, 0);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_EndScene(device);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     color = get_surface_color(rt, 320, 240);
-    ok(color == 0, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0, "Got unexpected color 0x%08lx.\n", color);
 
     IDirectDrawSurface7_Release(surface);
     IDirectDrawSurface7_Release(rt);
     IDirectDraw7_Release(ddraw);
     IDirect3D7_Release(d3d);
     refcount = IDirect3DDevice3_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -19225,11 +19225,11 @@ static void test_filling_convention(void)
     }
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **)&ddraw);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_GetRenderTarget(device, &backbuffer);
-    ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
 
     memset(&desc, 0, sizeof(desc));
     desc.dwSize = sizeof(desc);
@@ -19244,12 +19244,12 @@ static void test_filling_convention(void)
     desc.ddpfPixelFormat.dwGBitMask = 0x0000ff00;
     desc.ddpfPixelFormat.dwBBitMask = 0x000000ff;
     hr = IDirectDraw7_CreateSurface(ddraw, &desc, &rt, NULL);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
-    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
@@ -19258,19 +19258,19 @@ static void test_filling_convention(void)
             cur = j ? rt : backbuffer;
 
             hr = IDirect3DDevice7_SetRenderTarget(device, cur, 0);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, colour_clear, 0.0f, 0);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice7_SetViewport(device, &vp);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
             hr = IDirect3DDevice7_BeginScene(device);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLELIST,
                     tests[i].fvf, tests[i].geometry, 12, 0);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
             hr = IDirect3DDevice7_EndScene(device);
-            ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+            ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
 
             for (y = 0; y < 8; y++)
             {
@@ -19308,7 +19308,7 @@ static void test_filling_convention(void)
                      * convention, but because wined3d will nudge geometry to the left to
                      * keep diagonals (the 'R' in test case 'edge_tris') intact. */
                     todo_wine_if(todo && !compare_color(colour, expected, 1))
-                        ok(compare_color(colour, expected, 1), "Got unexpected colour %08x, %ux%u, case %u, j %u.\n",
+                        ok(compare_color(colour, expected, 1), "Got unexpected colour %08lx, %ux%u, case %u, j %u.\n",
                                 colour, x, y, i, j);
                 }
             }
@@ -19320,7 +19320,7 @@ static void test_filling_convention(void)
     IDirectDraw7_Release(ddraw);
     IDirect3D7_Release(d3d);
     refcount = IDirect3DDevice7_Release(device);
-    ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %lu references left.\n", refcount);
     DestroyWindow(window);
 }
 
@@ -19365,7 +19365,7 @@ START_TEST(ddraw7)
     if (IDirectDraw7_QueryInterface(ddraw, &IID_IDirect3D7, (void **)&d3d) == DD_OK)
     {
         hr = IDirect3D7_EnumDevices(d3d, enum_devtype_cb, &hal_ok);
-        ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+        ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr);
         if (hal_ok)
             hw_device_guid = &IID_IDirect3DTnLHalDevice;
         IDirectDraw7_Release(d3d);
diff --git a/dlls/ddraw/tests/ddrawmodes.c b/dlls/ddraw/tests/ddrawmodes.c
index 638ff3740129..22d297dc03d7 100644
--- a/dlls/ddraw/tests/ddrawmodes.c
+++ b/dlls/ddraw/tests/ddrawmodes.c
@@ -81,9 +81,9 @@ static BOOL createdirectdraw(void)
     SetRect(&rect_before_create, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
 
     rc = DirectDrawCreate(NULL, &lpDD, NULL);
-    ok(rc==DD_OK || rc==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", rc);
+    ok(rc==DD_OK || rc==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %lx\n", rc);
     if (!lpDD) {
-        trace("DirectDrawCreateEx() failed with an error %x\n", rc);
+        trace("DirectDrawCreateEx() failed with an error %lx\n", rc);
         return FALSE;
     }
     return TRUE;
@@ -138,17 +138,17 @@ static void test_DirectDrawEnumerateA(void)
 
     /* Test with NULL callback parameter. */
     ret = pDirectDrawEnumerateA(NULL, NULL);
-    ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
+    ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %ld\n", ret);
 
     /* Test with valid callback parameter and NULL context parameter. */
     trace("Calling DirectDrawEnumerateA with test_nullcontext_callbackA callback and NULL context.\n");
     ret = pDirectDrawEnumerateA(test_nullcontext_callbackA, NULL);
-    ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
+    ok(ret == DD_OK, "Expected DD_OK, got %ld\n", ret);
 
     /* Test with valid callback parameter and valid context parameter. */
     trace("Calling DirectDrawEnumerateA with test_context_callbackA callback and non-NULL context.\n");
     ret = pDirectDrawEnumerateA(test_context_callbackA, (void *)0xdeadbeef);
-    ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
+    ok(ret == DD_OK, "Expected DD_OK, got %ld\n", ret);
 }
 
 static BOOL WINAPI test_callbackW(GUID *lpGUID, WCHAR *lpDriverDescription,
@@ -174,17 +174,17 @@ static void test_DirectDrawEnumerateW(void)
     ret = pDirectDrawEnumerateW(NULL, NULL);
     ok(ret == DDERR_INVALIDPARAMS ||
        ret == DDERR_UNSUPPORTED, /* Older ddraw */
-       "Expected DDERR_INVALIDPARAMS or DDERR_UNSUPPORTED, got %d\n", ret);
+       "Expected DDERR_INVALIDPARAMS or DDERR_UNSUPPORTED, got %ld\n", ret);
 
     /* Test with invalid callback parameter. */
     ret = pDirectDrawEnumerateW((LPDDENUMCALLBACKW)0xdeadbeef, NULL);
     ok(ret == DDERR_INVALIDPARAMS /* XP */ ||
        ret == DDERR_UNSUPPORTED /* Win7 */,
-       "Expected DDERR_INVALIDPARAMS or DDERR_UNSUPPORTED, got %d\n", ret);
+       "Expected DDERR_INVALIDPARAMS or DDERR_UNSUPPORTED, got %ld\n", ret);
 
     /* Test with valid callback parameter and NULL context parameter. */
     ret = pDirectDrawEnumerateW(test_callbackW, NULL);
-    ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
+    ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %ld\n", ret);
 }
 
 static BOOL WINAPI test_nullcontext_callbackExA(GUID *lpGUID, char *lpDriverDescription,
@@ -235,36 +235,36 @@ static void test_DirectDrawEnumerateExA(void)
 
     /* Test with NULL callback parameter. */
     ret = pDirectDrawEnumerateExA(NULL, NULL, 0);
-    ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
+    ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %ld\n", ret);
 
     /* Test with valid callback parameter and invalid flags */
     ret = pDirectDrawEnumerateExA(test_nullcontext_callbackExA, NULL, ~0);
-    ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %d\n", ret);
+    ok(ret == DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, got %ld\n", ret);
 
     /* Test with valid callback parameter and NULL context parameter. */
     trace("Calling DirectDrawEnumerateExA with empty flags and NULL context.\n");
     ret = pDirectDrawEnumerateExA(test_nullcontext_callbackExA, NULL, 0);
-    ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
+    ok(ret == DD_OK, "Expected DD_OK, got %ld\n", ret);
 
     /* Test with valid callback parameter and non-NULL context parameter. */
     trace("Calling DirectDrawEnumerateExA with empty flags and non-NULL context.\n");
     ret = pDirectDrawEnumerateExA(test_context_callbackExA, (void *)0xdeadbeef, 0);
-    ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
+    ok(ret == DD_OK, "Expected DD_OK, got %ld\n", ret);
 
     /* Test with valid callback parameter and count the number of primary devices */
     callbackCount = 0;
     ret = pDirectDrawEnumerateExA(test_count_callbackExA, &callbackCount, 0);
-    ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
-    ok(callbackCount == 1, "Expected 1 primary device, got %d\n", callbackCount);
+    ok(ret == DD_OK, "Expected DD_OK, got %ld\n", ret);
+    ok(callbackCount == 1, "Expected 1 primary device, got %ld\n", callbackCount);
 
     /* Test with valid callback parameter and count the number of secondary devices */
     callbackCount = 0;
     ret = pDirectDrawEnumerateExA(test_count_callbackExA, &callbackCount,
                                   DDENUM_ATTACHEDSECONDARYDEVICES);
-    ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
+    ok(ret == DD_OK, "Expected DD_OK, got %ld\n", ret);
     /* Note: this list includes the primary devices as well and some systems (such as the TestBot)
        do not include any secondary devices */
-    ok(callbackCount >= 1, "Expected at least one device, got %d\n", callbackCount);
+    ok(callbackCount >= 1, "Expected at least one device, got %ld\n", callbackCount);
 
     /* Test with valid callback parameter, NULL context parameter, and all flags set. */
     trace("Calling DirectDrawEnumerateExA with all flags set and NULL context.\n");
@@ -272,7 +272,7 @@ static void test_DirectDrawEnumerateExA(void)
                                   DDENUM_ATTACHEDSECONDARYDEVICES |
                                   DDENUM_DETACHEDSECONDARYDEVICES |
                                   DDENUM_NONDISPLAYDEVICES);
-    ok(ret == DD_OK, "Expected DD_OK, got %d\n", ret);
+    ok(ret == DD_OK, "Expected DD_OK, got %ld\n", ret);
 }
 
 static BOOL WINAPI test_callbackExW(GUID *lpGUID, WCHAR *lpDriverDescription,
@@ -296,26 +296,26 @@ static void test_DirectDrawEnumerateExW(void)
 
     /* Test with NULL callback parameter. */
     ret = pDirectDrawEnumerateExW(NULL, NULL, 0);
-    ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
+    ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %ld\n", ret);
 
     /* Test with invalid callback parameter. */
     ret = pDirectDrawEnumerateExW((LPDDENUMCALLBACKEXW)0xdeadbeef, NULL, 0);
-    ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
+    ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %ld\n", ret);
 
     /* Test with valid callback parameter and invalid flags */
     ret = pDirectDrawEnumerateExW(test_callbackExW, NULL, ~0);
-    ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
+    ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %ld\n", ret);
 
     /* Test with valid callback parameter and NULL context parameter. */
     ret = pDirectDrawEnumerateExW(test_callbackExW, NULL, 0);
-    ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
+    ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %ld\n", ret);
 
     /* Test with valid callback parameter, NULL context parameter, and all flags set. */
     ret = pDirectDrawEnumerateExW(test_callbackExW, NULL,
                                   DDENUM_ATTACHEDSECONDARYDEVICES |
                                   DDENUM_DETACHEDSECONDARYDEVICES |
                                   DDENUM_NONDISPLAYDEVICES);
-    ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %d\n", ret);
+    ok(ret == DDERR_UNSUPPORTED, "Expected DDERR_UNSUPPORTED, got %ld\n", ret);
 }
 
 static void adddisplaymode(DDSURFACEDESC *lpddsd)
@@ -338,7 +338,7 @@ static void flushdisplaymodes(void)
 static HRESULT WINAPI enummodescallback(DDSURFACEDESC *lpddsd, void *lpContext)
 {
     if (winetest_debug > 1)
-        trace("Width = %i, Height = %i, bpp = %i, Refresh Rate = %i, Pitch = %i, flags =%02X\n",
+        trace("Width = %li, Height = %li, bpp = %li, Refresh Rate = %li, Pitch = %li, flags =%02lX\n",
               lpddsd->dwWidth, lpddsd->dwHeight, U1(lpddsd->ddpfPixelFormat).dwRGBBitCount,
               U2(*lpddsd).dwRefreshRate, U1(*lpddsd).lPitch, lpddsd->dwFlags);
 
@@ -368,15 +368,15 @@ static HRESULT WINAPI enummodescallback(DDSURFACEDESC *lpddsd, void *lpContext)
 static HRESULT WINAPI enummodescallback_16bit(DDSURFACEDESC *lpddsd, void *lpContext)
 {
     if (winetest_debug > 1)
-        trace("Width = %i, Height = %i, bpp = %i, Refresh Rate = %i, Pitch = %i, flags =%02X\n",
+        trace("Width = %li, Height = %li, bpp = %li, Refresh Rate = %li, Pitch = %li, flags =%02lX\n",
               lpddsd->dwWidth, lpddsd->dwHeight, U1(lpddsd->ddpfPixelFormat).dwRGBBitCount,
               U2(*lpddsd).dwRefreshRate, U1(*lpddsd).lPitch, lpddsd->dwFlags);
 
     ok(lpddsd->dwFlags == (DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH|DDSD_REFRESHRATE),
-            "Wrong surface description flags %02X\n", lpddsd->dwFlags);
-    ok(lpddsd->ddpfPixelFormat.dwFlags == DDPF_RGB, "Wrong pixel format flag %02X\n",
+            "Wrong surface description flags %02lX\n", lpddsd->dwFlags);
+    ok(lpddsd->ddpfPixelFormat.dwFlags == DDPF_RGB, "Wrong pixel format flag %02lX\n",
             lpddsd->ddpfPixelFormat.dwFlags);
-    ok(U1(lpddsd->ddpfPixelFormat).dwRGBBitCount == 16, "Expected 16 bpp got %i\n",
+    ok(U1(lpddsd->ddpfPixelFormat).dwRGBBitCount == 16, "Expected 16 bpp got %li\n",
             U1(lpddsd->ddpfPixelFormat).dwRGBBitCount);
 
     /* Check that the pitch is valid if applicable */
@@ -407,7 +407,7 @@ static HRESULT WINAPI enummodescallback_16bit(DDSURFACEDESC *lpddsd, void *lpCon
 static HRESULT WINAPI enummodescallback_count(DDSURFACEDESC *lpddsd, void *lpContext)
 {
     ok(lpddsd->dwFlags == (DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH|DDSD_REFRESHRATE),
-            "Wrong surface description flags %02X\n", lpddsd->dwFlags);
+            "Wrong surface description flags %02lX\n", lpddsd->dwFlags);
 
     modes16bpp_cnt++;
 
@@ -427,7 +427,7 @@ static void enumdisplaymodes(void)
 
     /* Flags parameter is reserved in very old ddraw versions (3 and older?) and must be 0 */
     rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback);
-    ok(rc==DD_OK, "EnumDisplayModes returned: %x\n",rc);
+    ok(rc==DD_OK, "EnumDisplayModes returned: %lx\n",rc);
 
     count = modes16bpp_cnt;
 
@@ -440,7 +440,7 @@ static void enumdisplaymodes(void)
     U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x001F;
 
     rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
-    ok(rc==DD_OK, "EnumDisplayModes returned: %x\n",rc);
+    ok(rc==DD_OK, "EnumDisplayModes returned: %lx\n",rc);
     ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
 
     modes16bpp_cnt = 0;
@@ -449,7 +449,7 @@ static void enumdisplaymodes(void)
     U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x0000;
 
     rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
-    ok(rc==DD_OK, "EnumDisplayModes returned: %x\n",rc);
+    ok(rc==DD_OK, "EnumDisplayModes returned: %lx\n",rc);
     ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
 
     modes16bpp_cnt = 0;
@@ -458,7 +458,7 @@ static void enumdisplaymodes(void)
     U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000F;
 
     rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
-    ok(rc==DD_OK, "EnumDisplayModes returned: %x\n",rc);
+    ok(rc==DD_OK, "EnumDisplayModes returned: %lx\n",rc);
     ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
 
 
@@ -466,14 +466,14 @@ static void enumdisplaymodes(void)
     ddsd.ddpfPixelFormat.dwFlags = DDPF_YUV;
 
     rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
-    ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
+    ok(rc==DD_OK,"EnumDisplayModes returned: %lx\n",rc);
     ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
 
     modes16bpp_cnt = 0;
     ddsd.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8;
 
     rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
-    ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
+    ok(rc==DD_OK,"EnumDisplayModes returned: %lx\n",rc);
     ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
 
     modes16bpp_cnt = 0;
@@ -481,14 +481,14 @@ static void enumdisplaymodes(void)
     ddsd.ddpfPixelFormat.dwFlags = 0;
 
     rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
-    ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
+    ok(rc==DD_OK,"EnumDisplayModes returned: %lx\n",rc);
     ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
 
     modes16bpp_cnt = 0;
     ddsd.dwFlags = 0;
 
     rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_count);
-    ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
+    ok(rc==DD_OK,"EnumDisplayModes returned: %lx\n",rc);
     ok(modes16bpp_cnt == modes_cnt, "Expected %d modes got %d\n", modes_cnt, modes16bpp_cnt);
 
     modes16bpp_cnt = 0;
@@ -496,7 +496,7 @@ static void enumdisplaymodes(void)
     U1(ddsd).lPitch = 123;
 
     rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
-    ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
+    ok(rc==DD_OK,"EnumDisplayModes returned: %lx\n",rc);
     ok(modes16bpp_cnt == count, "Expected %d modes got %d\n", count, modes16bpp_cnt);
 
     modes16bpp_cnt = 0;
@@ -507,7 +507,7 @@ static void enumdisplaymodes(void)
     U2(ddsd).dwRefreshRate = 2;
 
     rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
-    ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
+    ok(rc==DD_OK,"EnumDisplayModes returned: %lx\n",rc);
     ok(modes16bpp_cnt == 0, "Expected 0 modes got %d\n", modes16bpp_cnt);
 
     modes16bpp_cnt = 0;
@@ -519,7 +519,7 @@ static void enumdisplaymodes(void)
         skip("Ddraw version too old. Skipping.\n");
         return;
     }
-    ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
+    ok(rc==DD_OK,"EnumDisplayModes returned: %lx\n",rc);
     refresh_count = refresh_rate_cnt;
 
     if(refresh_rate)
@@ -529,12 +529,12 @@ static void enumdisplaymodes(void)
         U2(ddsd).dwRefreshRate = refresh_rate;
 
         rc = IDirectDraw_EnumDisplayModes(lpDD, 0, &ddsd, 0, enummodescallback_16bit);
-        ok(rc==DD_OK,"EnumDisplayModes returned: %x\n",rc);
+        ok(rc==DD_OK,"EnumDisplayModes returned: %lx\n",rc);
         ok(modes16bpp_cnt == refresh_count, "Expected %d modes got %d\n", refresh_count, modes16bpp_cnt);
     }
 
     rc = IDirectDraw_EnumDisplayModes(lpDD, 0, NULL, 0, enummodescallback);
-    ok(rc==DD_OK, "EnumDisplayModes returned: %x\n",rc);
+    ok(rc==DD_OK, "EnumDisplayModes returned: %lx\n",rc);
 }
 
 
@@ -547,7 +547,7 @@ static void setdisplaymode(int i)
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(rc==DD_OK,"SetCooperativeLevel returned: %x\n",rc);
+    ok(rc==DD_OK,"SetCooperativeLevel returned: %lx\n",rc);
     if (modes[i].dwFlags & DDSD_PIXELFORMAT)
     {
         if (modes[i].ddpfPixelFormat.dwFlags & DDPF_RGB)
@@ -555,7 +555,7 @@ static void setdisplaymode(int i)
             rc = IDirectDraw_SetDisplayMode(lpDD,
                 modes[i].dwWidth, modes[i].dwHeight,
                 U1(modes[i].ddpfPixelFormat).dwRGBBitCount);
-            ok(DD_OK==rc || DDERR_UNSUPPORTED==rc,"SetDisplayMode returned: %x\n",rc);
+            ok(DD_OK==rc || DDERR_UNSUPPORTED==rc,"SetDisplayMode returned: %lx\n",rc);
             if (rc == DD_OK)
             {
                 RECT scrn, test, virt;
@@ -563,7 +563,7 @@ static void setdisplaymode(int i)
                 SetRect(&virt, 0, 0, GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN));
                 OffsetRect(&virt, GetSystemMetrics(SM_XVIRTUALSCREEN), GetSystemMetrics(SM_YVIRTUALSCREEN));
                 SetRect(&scrn, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
-                trace("Mode (%dx%d) [%dx%d] (%d %d)x(%d %d)\n", modes[i].dwWidth, modes[i].dwHeight,
+                trace("Mode (%ldx%ld) [%ldx%ld] (%ld %ld)x(%ld %ld)\n", modes[i].dwWidth, modes[i].dwHeight,
                       scrn.right, scrn.bottom, virt.left, virt.top, virt.right, virt.bottom);
                 if (!EqualRect(&scrn, &orig_rect))
                 {
@@ -578,7 +578,7 @@ static void setdisplaymode(int i)
                     /* Check that switching to normal cooperative level
                        does not restore the display mode */
                     rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_NORMAL);
-                    ok(rc==DD_OK, "SetCooperativeLevel returned %x\n", rc);
+                    ok(rc==DD_OK, "SetCooperativeLevel returned %lx\n", rc);
                     SetRect(&test, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
                     rect_result = EqualRect(&scrn, &test);
                     ok(rect_result!=0, "Setting cooperative level to DDSCL_NORMAL changed the display mode\n");
@@ -586,7 +586,7 @@ static void setdisplaymode(int i)
                     /* Go back to fullscreen */
                     rc = IDirectDraw_SetCooperativeLevel(lpDD,
                         hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-                    ok(rc==DD_OK, "SetCooperativeLevel returned: %x\n",rc);
+                    ok(rc==DD_OK, "SetCooperativeLevel returned: %lx\n",rc);
 
                     /* If the display mode was changed, set the correct mode
                        to avoid irrelevant failures */
@@ -595,11 +595,11 @@ static void setdisplaymode(int i)
                         rc = IDirectDraw_SetDisplayMode(lpDD,
                             modes[i].dwWidth, modes[i].dwHeight,
                             U1(modes[i].ddpfPixelFormat).dwRGBBitCount);
-                        ok(DD_OK==rc, "SetDisplayMode returned: %x\n",rc);
+                        ok(DD_OK==rc, "SetDisplayMode returned: %lx\n",rc);
                     }
                 }
                 rc = IDirectDraw_RestoreDisplayMode(lpDD);
-                ok(DD_OK==rc,"RestoreDisplayMode returned: %x\n",rc);
+                ok(DD_OK==rc,"RestoreDisplayMode returned: %lx\n",rc);
             }
         }
     }
@@ -618,10 +618,10 @@ static void createsurface(void)
         DDSCAPS_COMPLEX;
     ddsd.dwBackBufferCount = 1;
     rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSPrimary, NULL );
-    ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
+    ok(rc==DD_OK,"CreateSurface returned: %lx\n",rc);
     ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
     rc = IDirectDrawSurface_GetAttachedSurface(lpDDSPrimary, &ddscaps, &lpDDSBack);
-    ok(rc==DD_OK,"GetAttachedSurface returned: %x\n",rc);
+    ok(rc==DD_OK,"GetAttachedSurface returned: %lx\n",rc);
 }
 
 static void destroysurface(void)
@@ -640,17 +640,17 @@ static void testsurface(void)
     HRESULT rc;
 
     rc = IDirectDrawSurface_GetDC(lpDDSBack, &hdc);
-    ok(rc==DD_OK, "IDirectDrawSurface_GetDC returned: %x\n",rc);
+    ok(rc==DD_OK, "IDirectDrawSurface_GetDC returned: %lx\n",rc);
     SetBkColor(hdc, RGB(0, 0, 255));
     SetTextColor(hdc, RGB(255, 255, 0));
     TextOutA(hdc, 0, 0, testMsg, strlen(testMsg));
     rc = IDirectDrawSurface_ReleaseDC(lpDDSBack, hdc);
-    ok(rc==DD_OK, "IDirectDrawSurface_ReleaseDC returned: %x\n",rc);
+    ok(rc==DD_OK, "IDirectDrawSurface_ReleaseDC returned: %lx\n",rc);
 
     while (1)
     {
         rc = IDirectDrawSurface_Flip(lpDDSPrimary, NULL, DDFLIP_WAIT);
-        ok(rc==DD_OK || rc==DDERR_SURFACELOST, "IDirectDrawSurface_BltFast returned: %x\n",rc);
+        ok(rc==DD_OK || rc==DDERR_SURFACELOST, "IDirectDrawSurface_BltFast returned: %lx\n",rc);
 
         if (rc == DD_OK)
         {
@@ -659,7 +659,7 @@ static void testsurface(void)
         else if (rc == DDERR_SURFACELOST)
         {
             rc = IDirectDrawSurface_Restore(lpDDSPrimary);
-            ok(rc==DD_OK, "IDirectDrawSurface_Restore returned: %x\n",rc);
+            ok(rc==DD_OK, "IDirectDrawSurface_Restore returned: %lx\n",rc);
         }
     }
 }
@@ -692,14 +692,14 @@ static void testcooperativelevels_normal(void)
     surfacedesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW);
-    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %x\n",rc);
+    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %lx\n",rc);
 
     /* Do some tests with DDSCL_NORMAL mode */
 
     /* Fullscreen mode + normal mode + exclusive mode */
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL);
-    ok(rc==DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, received: %x\n", rc);
+    ok(rc==DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, received: %lx\n", rc);
 
     sfw=FALSE;
     if(hwnd2)
@@ -708,7 +708,7 @@ static void testcooperativelevels_normal(void)
         skip("Failed to create the second window\n");
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL);
-    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc);
+    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %lx\n",rc);
 
     if(sfw)
         ok(GetForegroundWindow()==hwnd,"Expected the main windows (%p) for foreground, received the second one (%p)\n",hwnd, hwnd2);
@@ -720,14 +720,14 @@ static void testcooperativelevels_normal(void)
         skip("Unsupported mode\n");
     else
     {
-        ok(rc == DD_OK, "IDirectDraw_CreateSurface returned %08x\n", rc);
+        ok(rc == DD_OK, "IDirectDraw_CreateSurface returned %08lx\n", rc);
         ok(surface!=NULL, "Returned NULL surface pointer\n");
     }
     if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
 
     /* Exclusive mode + normal mode */
     rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_EXCLUSIVE | DDSCL_NORMAL);
-    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %x\n",rc);
+    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_NORMAL) returned: %lx\n",rc);
 
     /* Fullscreen mode + normal mode */
 
@@ -735,13 +735,13 @@ static void testcooperativelevels_normal(void)
     if(hwnd2) sfw=SetForegroundWindow(hwnd2);
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_FULLSCREEN | DDSCL_NORMAL);
-    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_NORMAL) returned: %x\n",rc);
+    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_FULLSCREEN | DDSCL_NORMAL) returned: %lx\n",rc);
 
     if(sfw)
         ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_NORMAL);
-    ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);
+    ok(rc==DD_OK, "Expected DD_OK, received %lx\n", rc);
 
     /* Try creating a double buffered primary in fullscreen + normal mode */
     rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
@@ -749,7 +749,7 @@ static void testcooperativelevels_normal(void)
         skip("Unsupported mode\n");
     else
     {
-        ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08x\n", rc);
+        ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08lx\n", rc);
         ok(surface == NULL, "Returned surface pointer is %p\n", surface);
     }
 
@@ -762,13 +762,13 @@ static void testcooperativelevels_normal(void)
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_NORMAL);
-    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL) returned: %x\n",rc);
+    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL) returned: %lx\n",rc);
 
     if(sfw)
         ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL);
-    ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);
+    ok(rc==DD_OK, "Expected DD_OK, received %lx\n", rc);
 
     /* Try creating a double buffered primary in normal mode */
     rc = IDirectDraw_CreateSurface(lpDD, &surfacedesc, &surface, NULL);
@@ -776,7 +776,7 @@ static void testcooperativelevels_normal(void)
         skip("Unsupported mode\n");
     else
     {
-        ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08x\n", rc);
+        ok(rc == DDERR_NOEXCLUSIVEMODE, "IDirectDraw_CreateSurface returned %08lx\n", rc);
         ok(surface == NULL, "Returned surface pointer is %p\n", surface);
     }
     if(surface && surface != (IDirectDrawSurface *)0xdeadbeef) IDirectDrawSurface_Release(surface);
@@ -788,18 +788,18 @@ static void testcooperativelevels_normal(void)
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | FULLSCREEN) returned: %x\n",rc);
+    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | FULLSCREEN) returned: %lx\n",rc);
 
     if(sfw)
         ok(GetForegroundWindow()==hwnd2,"Expected the second windows (%p) for foreground, received the main one (%p)\n",hwnd2, hwnd);
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL | DDSCL_FULLSCREEN);
-    ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);
+    ok(rc==DD_OK, "Expected DD_OK, received %lx\n", rc);
 
     /* Set the focus window */
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW);
-    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %x\n",rc);
+    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW | DDSCL_CREATEDEVICEWINDOW) returned: %lx\n",rc);
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_SETFOCUSWINDOW);
 
@@ -809,7 +809,7 @@ static void testcooperativelevels_normal(void)
         return;
     }
 
-    ok(rc==DD_OK, "Expected DD_OK, received %x\n", rc);
+    ok(rc==DD_OK, "Expected DD_OK, received %lx\n", rc);
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_SETFOCUSWINDOW);
@@ -820,61 +820,61 @@ static void testcooperativelevels_normal(void)
         return;
     }
 
-    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
+    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
 
     /* Set the focus window a second time*/
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_SETFOCUSWINDOW);
-    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) the second time returned: %x\n",rc);
+    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) the second time returned: %lx\n",rc);
 
     /* Test DDSCL_SETFOCUSWINDOW with the other flags. They should all fail, except of DDSCL_NOWINDOWCHANGES */
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW);
-    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
+    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW);
-    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
+    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
 
     /* This one succeeds */
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW);
-    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
+    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NOWINDOWCHANGES | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW);
-    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
+    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_MULTITHREADED | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW);
-    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
+    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUSETUP | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW);
-    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
+    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FPUPRESERVE | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW);
-    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
+    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWREBOOT | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW);
-    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
+    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_ALLOWMODEX | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
 
     /* Set the device window without any other flags. Should give an error */
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_SETDEVICEWINDOW);
-    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETDEVICEWINDOW) returned: %x\n",rc);
+    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_SETDEVICEWINDOW) returned: %lx\n",rc);
 
     /* Set device window with DDSCL_NORMAL */
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW);
-    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW) returned: %x\n",rc);
+    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW) returned: %lx\n",rc);
 
     /* Also set the focus window. Should give an error */
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW);
-    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
+    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_NORMAL | DDSCL_SETDEVICEWINDOW | DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
 
     /* All done */
 }
@@ -894,17 +894,17 @@ static void testcooperativelevels_exclusive(void)
     /* Try to set exclusive mode only */
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_EXCLUSIVE);
-    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE) returned: %x\n",rc);
+    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_EXCLUSIVE) returned: %lx\n",rc);
 
     /* Full screen mode only */
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_FULLSCREEN);
-    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FULLSCREEN) returned: %x\n",rc);
+    ok(rc==DDERR_INVALIDPARAMS,"SetCooperativeLevel(DDSCL_FULLSCREEN) returned: %lx\n",rc);
 
     /* Full screen mode + exclusive mode */
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(rc==DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, received %x\n", rc);
+    ok(rc==DDERR_INVALIDPARAMS, "Expected DDERR_INVALIDPARAMS, received %lx\n", rc);
 
     sfw=FALSE;
     if(hwnd2)
@@ -914,7 +914,7 @@ static void testcooperativelevels_exclusive(void)
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
-    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) returned: %x\n",rc);
+    ok(rc==DD_OK,"SetCooperativeLevel(DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) returned: %lx\n",rc);
 
     if(sfw)
         ok(GetForegroundWindow()==hwnd,"Expected the main windows (%p) for foreground, received the second one (%p)\n",hwnd, hwnd2);
@@ -928,7 +928,7 @@ static void testcooperativelevels_exclusive(void)
     rc = IDirectDraw_SetCooperativeLevel(lpDD,
         hwnd, DDSCL_SETFOCUSWINDOW);
     ok(rc==DDERR_HWNDALREADYSET ||
-       broken(rc==DDERR_INVALIDPARAMS) /* NT4/Win95 */,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %x\n",rc);
+       broken(rc==DDERR_INVALIDPARAMS) /* NT4/Win95 */,"SetCooperativeLevel(DDSCL_SETFOCUSWINDOW) returned: %lx\n",rc);
 
 
     /* All done */
@@ -945,7 +945,7 @@ static void testddraw3(void)
     IDirectDraw3 *dd3;
     HRESULT hr;
     hr = IDirectDraw_QueryInterface(lpDD, &My_IID_IDirectDraw3, (void **) &dd3);
-    ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectDraw3 returned 0x%08x, expected E_NOINTERFACE\n", hr);
+    ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectDraw3 returned 0x%08lx, expected E_NOINTERFACE\n", hr);
     if(SUCCEEDED(hr) && dd3) IDirectDraw3_Release(dd3);
 }
 
@@ -963,7 +963,7 @@ static void testddraw7(void)
         win_skip("DirectDraw7 is not supported\n");
         return;
     }
-    ok(hr==DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
+    ok(hr==DD_OK, "IDirectDraw7_QueryInterface returned %08lx\n", hr);
 
     if (hr==DD_OK)
     {
@@ -975,7 +975,7 @@ static void testddraw7(void)
          pend[1] = 0xdeadbeef;
 
          hr = IDirectDraw7_GetDeviceIdentifier(dd7, pdddi2, 0);
-         ok(hr==DD_OK, "get device identifier failed with %08x\n", hr);
+         ok(hr==DD_OK, "get device identifier failed with %08lx\n", hr);
 
          if (hr==DD_OK)
          {
@@ -994,7 +994,7 @@ static void testddraw7(void)
          pend[0] = 0xdeadbeef;
          pend[1] = 0xdeadbeef;
          hr = IDirectDraw7_GetDeviceIdentifier(dd7, pdddi2, DDGDI_GETHOSTIDENTIFIER);
-         ok(hr==DD_OK, "get device identifier failed with %08x\n", hr);
+         ok(hr==DD_OK, "get device identifier failed with %08lx\n", hr);
          if (hr==DD_OK)
          {
              /* szDriver contains the name of the driver DLL */
diff --git a/dlls/ddraw/tests/dsurface.c b/dlls/ddraw/tests/dsurface.c
index 59902b43761e..5a3ad28452bd 100644
--- a/dlls/ddraw/tests/dsurface.c
+++ b/dlls/ddraw/tests/dsurface.c
@@ -38,14 +38,14 @@ static BOOL CreateDirectDraw(void)
     HRESULT rc;
 
     rc = DirectDrawCreate(NULL, &lpDD, NULL);
-    ok(rc==DD_OK || rc==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", rc);
+    ok(rc==DD_OK || rc==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %lx\n", rc);
     if (!lpDD) {
-        trace("DirectDrawCreateEx() failed with an error %x\n", rc);
+        trace("DirectDrawCreateEx() failed with an error %lx\n", rc);
         return FALSE;
     }
 
     rc = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL);
-    ok(rc==DD_OK,"SetCooperativeLevel returned: %x\n",rc);
+    ok(rc==DD_OK,"SetCooperativeLevel returned: %lx\n",rc);
 
     return TRUE;
 }
@@ -92,41 +92,41 @@ static void GetDDInterface_1(void)
     ret = IDirectDraw_CreateSurface(lpDD, &surface, &dsurface, NULL);
     if(ret != DD_OK)
     {
-        ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
+        ok(FALSE, "IDirectDraw::CreateSurface failed with error %lx\n", ret);
         return;
     }
     ret = IDirectDrawSurface_QueryInterface(dsurface, &IID_IDirectDrawSurface2, (void **) &dsurface2);
-    ok(ret == DD_OK, "IDirectDrawSurface_QueryInterface returned %08x\n", ret);
+    ok(ret == DD_OK, "IDirectDrawSurface_QueryInterface returned %08lx\n", ret);
     ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw2, (void **) &dd2);
-    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", ret);
+    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", ret);
     ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw4, (void **) &dd4);
-    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", ret);
+    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", ret);
     ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
-    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", ret);
+    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", ret);
 
     ref1 = getref((IUnknown *) lpDD);
-    ok(ref1 == 1, "IDirectDraw refcount is %d\n", ref1);
+    ok(ref1 == 1, "IDirectDraw refcount is %ld\n", ref1);
     ref2 = getref((IUnknown *) dd2);
-    ok(ref2 == 1, "IDirectDraw2 refcount is %d\n", ref2);
+    ok(ref2 == 1, "IDirectDraw2 refcount is %ld\n", ref2);
     ref4 = getref((IUnknown *) dd4);
-    ok(ref4 == 1, "IDirectDraw4 refcount is %d\n", ref4);
+    ok(ref4 == 1, "IDirectDraw4 refcount is %ld\n", ref4);
     ref7 = getref((IUnknown *) dd7);
-    ok(ref7 == 1, "IDirectDraw7 refcount is %d\n", ref7);
+    ok(ref7 == 1, "IDirectDraw7 refcount is %ld\n", ref7);
 
 
     ret = IDirectDrawSurface2_GetDDInterface(dsurface2, &dd);
-    ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08x\n", ret);
-    ok(getref((IUnknown *) lpDD) == ref1 + 1, "IDirectDraw refcount was increased by %d\n", getref((IUnknown *) lpDD) - ref1);
-    ok(getref((IUnknown *) dd2) == ref2 + 0, "IDirectDraw2 refcount was increased by %d\n", getref((IUnknown *) dd2) - ref2);
-    ok(getref((IUnknown *) dd4) == ref4 + 0, "IDirectDraw4 refcount was increased by %d\n", getref((IUnknown *) dd4) - ref4);
-    ok(getref((IUnknown *) dd7) == ref7 + 0, "IDirectDraw7 refcount was increased by %d\n", getref((IUnknown *) dd7) - ref7);
+    ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08lx\n", ret);
+    ok(getref((IUnknown *) lpDD) == ref1 + 1, "IDirectDraw refcount was increased by %ld\n", getref((IUnknown *) lpDD) - ref1);
+    ok(getref((IUnknown *) dd2) == ref2 + 0, "IDirectDraw2 refcount was increased by %ld\n", getref((IUnknown *) dd2) - ref2);
+    ok(getref((IUnknown *) dd4) == ref4 + 0, "IDirectDraw4 refcount was increased by %ld\n", getref((IUnknown *) dd4) - ref4);
+    ok(getref((IUnknown *) dd7) == ref7 + 0, "IDirectDraw7 refcount was increased by %ld\n", getref((IUnknown *) dd7) - ref7);
 
     ok(dd == lpDD, "Returned interface pointer is not equal to the creation interface\n");
     IUnknown_Release((IUnknown *) dd);
 
     /* try a NULL pointer */
     ret = IDirectDrawSurface2_GetDDInterface(dsurface2, NULL);
-    ok(ret == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_GetDDInterface returned %08x\n", ret);
+    ok(ret == DDERR_INVALIDPARAMS, "IDirectDrawSurface7_GetDDInterface returned %08lx\n", ret);
 
     IDirectDraw2_Release(dd2);
     IDirectDraw4_Release(dd4);
@@ -148,11 +148,11 @@ static void GetDDInterface_2(void)
     void *dd;
 
     ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw2, (void **) &dd2);
-    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", ret);
+    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", ret);
     ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw4, (void **) &dd4);
-    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", ret);
+    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", ret);
     ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
-    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", ret);
+    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", ret);
 
     /* Create a surface */
     ZeroMemory(&surface, sizeof(surface));
@@ -163,31 +163,31 @@ static void GetDDInterface_2(void)
     ret = IDirectDraw2_CreateSurface(dd2, &surface, &dsurface, NULL);
     if(ret != DD_OK)
     {
-        ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
+        ok(FALSE, "IDirectDraw::CreateSurface failed with error %lx\n", ret);
         IDirectDraw2_Release(dd2);
         IDirectDraw4_Release(dd4);
         IDirectDraw7_Release(dd7);
         return;
     }
     ret = IDirectDrawSurface_QueryInterface(dsurface, &IID_IDirectDrawSurface2, (void **) &dsurface2);
-    ok(ret == DD_OK, "IDirectDrawSurface_QueryInterface returned %08x\n", ret);
+    ok(ret == DD_OK, "IDirectDrawSurface_QueryInterface returned %08lx\n", ret);
 
     ref1 = getref((IUnknown *) lpDD);
-    ok(ref1 == 1, "IDirectDraw refcount is %d\n", ref1);
+    ok(ref1 == 1, "IDirectDraw refcount is %ld\n", ref1);
     ref2 = getref((IUnknown *) dd2);
-    ok(ref2 == 1, "IDirectDraw2 refcount is %d\n", ref2);
+    ok(ref2 == 1, "IDirectDraw2 refcount is %ld\n", ref2);
     ref4 = getref((IUnknown *) dd4);
-    ok(ref4 == 1, "IDirectDraw4 refcount is %d\n", ref4);
+    ok(ref4 == 1, "IDirectDraw4 refcount is %ld\n", ref4);
     ref7 = getref((IUnknown *) dd7);
-    ok(ref7 == 1, "IDirectDraw7 refcount is %d\n", ref7);
+    ok(ref7 == 1, "IDirectDraw7 refcount is %ld\n", ref7);
 
 
     ret = IDirectDrawSurface2_GetDDInterface(dsurface2, &dd);
-    ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08x\n", ret);
-    ok(getref((IUnknown *) lpDD) == ref1 + 0, "IDirectDraw refcount was increased by %d\n", getref((IUnknown *) lpDD) - ref1);
-    ok(getref((IUnknown *) dd2) == ref2 + 1, "IDirectDraw2 refcount was increased by %d\n", getref((IUnknown *) dd2) - ref2);
-    ok(getref((IUnknown *) dd4) == ref4 + 0, "IDirectDraw4 refcount was increased by %d\n", getref((IUnknown *) dd4) - ref4);
-    ok(getref((IUnknown *) dd7) == ref7 + 0, "IDirectDraw7 refcount was increased by %d\n", getref((IUnknown *) dd7) - ref7);
+    ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08lx\n", ret);
+    ok(getref((IUnknown *) lpDD) == ref1 + 0, "IDirectDraw refcount was increased by %ld\n", getref((IUnknown *) lpDD) - ref1);
+    ok(getref((IUnknown *) dd2) == ref2 + 1, "IDirectDraw2 refcount was increased by %ld\n", getref((IUnknown *) dd2) - ref2);
+    ok(getref((IUnknown *) dd4) == ref4 + 0, "IDirectDraw4 refcount was increased by %ld\n", getref((IUnknown *) dd4) - ref4);
+    ok(getref((IUnknown *) dd7) == ref7 + 0, "IDirectDraw7 refcount was increased by %ld\n", getref((IUnknown *) dd7) - ref7);
 
     ok(dd == dd2, "Returned interface pointer is not equal to the creation interface\n");
     IUnknown_Release((IUnknown *) dd);
@@ -212,11 +212,11 @@ static void GetDDInterface_4(void)
     void *dd;
 
     ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw2, (void **) &dd2);
-    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", ret);
+    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", ret);
     ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw4, (void **) &dd4);
-    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", ret);
+    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", ret);
     ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
-    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", ret);
+    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", ret);
 
     /* Create a surface */
     ZeroMemory(&surface, sizeof(surface));
@@ -227,41 +227,41 @@ static void GetDDInterface_4(void)
     ret = IDirectDraw4_CreateSurface(dd4, &surface, &dsurface4, NULL);
     if(ret != DD_OK)
     {
-        ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
+        ok(FALSE, "IDirectDraw::CreateSurface failed with error %lx\n", ret);
         IDirectDraw2_Release(dd2);
         IDirectDraw4_Release(dd4);
         IDirectDraw7_Release(dd7);
         return;
     }
     ret = IDirectDrawSurface4_QueryInterface(dsurface4, &IID_IDirectDrawSurface2, (void **) &dsurface2);
-    ok(ret == DD_OK, "IDirectDrawSurface_QueryInterface returned %08x\n", ret);
+    ok(ret == DD_OK, "IDirectDrawSurface_QueryInterface returned %08lx\n", ret);
 
     ref1 = getref((IUnknown *) lpDD);
-    ok(ref1 == 1, "IDirectDraw refcount is %d\n", ref1);
+    ok(ref1 == 1, "IDirectDraw refcount is %ld\n", ref1);
     ref2 = getref((IUnknown *) dd2);
-    ok(ref2 == 1, "IDirectDraw2 refcount is %d\n", ref2);
+    ok(ref2 == 1, "IDirectDraw2 refcount is %ld\n", ref2);
     ref4 = getref((IUnknown *) dd4);
-    ok(ref4 == 2, "IDirectDraw4 refcount is %d\n", ref4);
+    ok(ref4 == 2, "IDirectDraw4 refcount is %ld\n", ref4);
     ref7 = getref((IUnknown *) dd7);
-    ok(ref7 == 1, "IDirectDraw7 refcount is %d\n", ref7);
+    ok(ref7 == 1, "IDirectDraw7 refcount is %ld\n", ref7);
 
     ret = IDirectDrawSurface4_GetDDInterface(dsurface4, &dd);
-    ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08x\n", ret);
-    ok(getref((IUnknown *) lpDD) == ref1 + 0, "IDirectDraw refcount was increased by %d\n", getref((IUnknown *) lpDD) - ref1);
-    ok(getref((IUnknown *) dd2) == ref2 + 0, "IDirectDraw2 refcount was increased by %d\n", getref((IUnknown *) dd2) - ref2);
-    ok(getref((IUnknown *) dd4) == ref4 + 1, "IDirectDraw4 refcount was increased by %d\n", getref((IUnknown *) dd4) - ref4);
-    ok(getref((IUnknown *) dd7) == ref7 + 0, "IDirectDraw7 refcount was increased by %d\n", getref((IUnknown *) dd7) - ref7);
+    ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08lx\n", ret);
+    ok(getref((IUnknown *) lpDD) == ref1 + 0, "IDirectDraw refcount was increased by %ld\n", getref((IUnknown *) lpDD) - ref1);
+    ok(getref((IUnknown *) dd2) == ref2 + 0, "IDirectDraw2 refcount was increased by %ld\n", getref((IUnknown *) dd2) - ref2);
+    ok(getref((IUnknown *) dd4) == ref4 + 1, "IDirectDraw4 refcount was increased by %ld\n", getref((IUnknown *) dd4) - ref4);
+    ok(getref((IUnknown *) dd7) == ref7 + 0, "IDirectDraw7 refcount was increased by %ld\n", getref((IUnknown *) dd7) - ref7);
 
     ok(dd == dd4, "Returned interface pointer is not equal to the creation interface\n");
     IUnknown_Release((IUnknown *) dd);
 
     /* Now test what happens if we QI the surface for some other version - It should still return the creation interface */
     ret = IDirectDrawSurface2_GetDDInterface(dsurface2, &dd);
-    ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08x\n", ret);
-    ok(getref((IUnknown *) lpDD) == ref1 + 0, "IDirectDraw refcount was increased by %d\n", getref((IUnknown *) lpDD) - ref1);
-    ok(getref((IUnknown *) dd2) == ref2 + 0, "IDirectDraw2 refcount was increased by %d\n", getref((IUnknown *) dd2) - ref2);
-    ok(getref((IUnknown *) dd4) == ref4 + 1, "IDirectDraw4 refcount was increased by %d\n", getref((IUnknown *) dd4) - ref4);
-    ok(getref((IUnknown *) dd7) == ref7 + 0, "IDirectDraw7 refcount was increased by %d\n", getref((IUnknown *) dd7) - ref7);
+    ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08lx\n", ret);
+    ok(getref((IUnknown *) lpDD) == ref1 + 0, "IDirectDraw refcount was increased by %ld\n", getref((IUnknown *) lpDD) - ref1);
+    ok(getref((IUnknown *) dd2) == ref2 + 0, "IDirectDraw2 refcount was increased by %ld\n", getref((IUnknown *) dd2) - ref2);
+    ok(getref((IUnknown *) dd4) == ref4 + 1, "IDirectDraw4 refcount was increased by %ld\n", getref((IUnknown *) dd4) - ref4);
+    ok(getref((IUnknown *) dd7) == ref7 + 0, "IDirectDraw7 refcount was increased by %ld\n", getref((IUnknown *) dd7) - ref7);
 
     ok(dd == dd4, "Returned interface pointer is not equal to the creation interface\n");
     IUnknown_Release((IUnknown *) dd);
@@ -286,11 +286,11 @@ static void GetDDInterface_7(void)
     void *dd;
 
     ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw2, (void **) &dd2);
-    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", ret);
+    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", ret);
     ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw4, (void **) &dd4);
-    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", ret);
+    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", ret);
     ret = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
-    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", ret);
+    ok(ret == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", ret);
 
     /* Create a surface */
     ZeroMemory(&surface, sizeof(surface));
@@ -301,41 +301,41 @@ static void GetDDInterface_7(void)
     ret = IDirectDraw7_CreateSurface(dd7, &surface, &dsurface7, NULL);
     if(ret != DD_OK)
     {
-        ok(FALSE, "IDirectDraw::CreateSurface failed with error %x\n", ret);
+        ok(FALSE, "IDirectDraw::CreateSurface failed with error %lx\n", ret);
         IDirectDraw2_Release(dd2);
         IDirectDraw4_Release(dd4);
         IDirectDraw7_Release(dd7);
         return;
     }
     ret = IDirectDrawSurface7_QueryInterface(dsurface7, &IID_IDirectDrawSurface4, (void **) &dsurface4);
-    ok(ret == DD_OK, "IDirectDrawSurface_QueryInterface returned %08x\n", ret);
+    ok(ret == DD_OK, "IDirectDrawSurface_QueryInterface returned %08lx\n", ret);
 
     ref1 = getref((IUnknown *) lpDD);
-    ok(ref1 == 1, "IDirectDraw refcount is %d\n", ref1);
+    ok(ref1 == 1, "IDirectDraw refcount is %ld\n", ref1);
     ref2 = getref((IUnknown *) dd2);
-    ok(ref2 == 1, "IDirectDraw2 refcount is %d\n", ref2);
+    ok(ref2 == 1, "IDirectDraw2 refcount is %ld\n", ref2);
     ref4 = getref((IUnknown *) dd4);
-    ok(ref4 == 1, "IDirectDraw4 refcount is %d\n", ref4);
+    ok(ref4 == 1, "IDirectDraw4 refcount is %ld\n", ref4);
     ref7 = getref((IUnknown *) dd7);
-    ok(ref7 == 2, "IDirectDraw7 refcount is %d\n", ref7);
+    ok(ref7 == 2, "IDirectDraw7 refcount is %ld\n", ref7);
 
     ret = IDirectDrawSurface7_GetDDInterface(dsurface7, &dd);
-    ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08x\n", ret);
-    ok(getref((IUnknown *) lpDD) == ref1 + 0, "IDirectDraw refcount was increased by %d\n", getref((IUnknown *) lpDD) - ref1);
-    ok(getref((IUnknown *) dd2) == ref2 + 0, "IDirectDraw2 refcount was increased by %d\n", getref((IUnknown *) dd2) - ref2);
-    ok(getref((IUnknown *) dd4) == ref4 + 0, "IDirectDraw4 refcount was increased by %d\n", getref((IUnknown *) dd4) - ref4);
-    ok(getref((IUnknown *) dd7) == ref7 + 1, "IDirectDraw7 refcount was increased by %d\n", getref((IUnknown *) dd7) - ref7);
+    ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08lx\n", ret);
+    ok(getref((IUnknown *) lpDD) == ref1 + 0, "IDirectDraw refcount was increased by %ld\n", getref((IUnknown *) lpDD) - ref1);
+    ok(getref((IUnknown *) dd2) == ref2 + 0, "IDirectDraw2 refcount was increased by %ld\n", getref((IUnknown *) dd2) - ref2);
+    ok(getref((IUnknown *) dd4) == ref4 + 0, "IDirectDraw4 refcount was increased by %ld\n", getref((IUnknown *) dd4) - ref4);
+    ok(getref((IUnknown *) dd7) == ref7 + 1, "IDirectDraw7 refcount was increased by %ld\n", getref((IUnknown *) dd7) - ref7);
 
     ok(dd == dd7, "Returned interface pointer is not equal to the creation interface\n");
     IUnknown_Release((IUnknown *) dd);
 
     /* Now test what happens if we QI the surface for some other version - It should still return the creation interface */
     ret = IDirectDrawSurface4_GetDDInterface(dsurface4, &dd);
-    ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08x\n", ret);
-    ok(getref((IUnknown *) lpDD) == ref1 + 0, "IDirectDraw refcount was increased by %d\n", getref((IUnknown *) lpDD) - ref1);
-    ok(getref((IUnknown *) dd2) == ref2 + 0, "IDirectDraw2 refcount was increased by %d\n", getref((IUnknown *) dd2) - ref2);
-    ok(getref((IUnknown *) dd4) == ref4 + 0, "IDirectDraw4 refcount was increased by %d\n", getref((IUnknown *) dd4) - ref4);
-    ok(getref((IUnknown *) dd7) == ref7 + 1, "IDirectDraw7 refcount was increased by %d\n", getref((IUnknown *) dd7) - ref7);
+    ok(ret == DD_OK, "IDirectDrawSurface7_GetDDInterface returned %08lx\n", ret);
+    ok(getref((IUnknown *) lpDD) == ref1 + 0, "IDirectDraw refcount was increased by %ld\n", getref((IUnknown *) lpDD) - ref1);
+    ok(getref((IUnknown *) dd2) == ref2 + 0, "IDirectDraw2 refcount was increased by %ld\n", getref((IUnknown *) dd2) - ref2);
+    ok(getref((IUnknown *) dd4) == ref4 + 0, "IDirectDraw4 refcount was increased by %ld\n", getref((IUnknown *) dd4) - ref4);
+    ok(getref((IUnknown *) dd7) == ref7 + 1, "IDirectDraw7 refcount was increased by %ld\n", getref((IUnknown *) dd7) - ref7);
 
     ok(dd == dd7, "Returned interface pointer is not equal to the creation interface\n");
     IUnknown_Release((IUnknown *) dd);
@@ -389,9 +389,9 @@ static HRESULT WINAPI CubeTestPaletteEnum(IDirectDrawSurface7 *surface, DDSURFAC
 
     hr = IDirectDrawSurface7_SetPalette(surface, context);
     if (desc->dwWidth == 64) /* This is for first mimpmap */
-        ok(hr == DDERR_NOTONMIPMAPSUBLEVEL, "SetPalette returned: %x\n",hr);
+        ok(hr == DDERR_NOTONMIPMAPSUBLEVEL, "SetPalette returned: %lx\n",hr);
     else
-        ok(hr == DD_OK, "SetPalette returned: %x\n",hr);
+        ok(hr == DD_OK, "SetPalette returned: %lx\n",hr);
 
     IDirectDrawSurface7_Release(surface);
 
@@ -459,10 +459,10 @@ static HRESULT WINAPI CubeTestLvl1Enum(IDirectDrawSurface7 *surface, DDSURFACEDE
                                              &mipmaps,
                                              CubeTestLvl2Enum);
 
-    ok(desc->dwWidth == expected[*num].width, "Surface width is %d expected %d\n", desc->dwWidth, expected[*num].width);
-    ok(desc->dwHeight == expected[*num].height, "Surface height is %d expected %d\n", desc->dwHeight, expected[*num].height);
-    ok(desc->ddsCaps.dwCaps == expected[*num].caps, "Surface caps are %08x expected %08x\n", desc->ddsCaps.dwCaps, expected[*num].caps);
-    ok(desc->ddsCaps.dwCaps2 == expected[*num].caps2, "Surface caps2 are %08x expected %08x\n", desc->ddsCaps.dwCaps2, expected[*num].caps2);
+    ok(desc->dwWidth == expected[*num].width, "Surface width is %ld expected %ld\n", desc->dwWidth, expected[*num].width);
+    ok(desc->dwHeight == expected[*num].height, "Surface height is %ld expected %ld\n", desc->dwHeight, expected[*num].height);
+    ok(desc->ddsCaps.dwCaps == expected[*num].caps, "Surface caps are %08lx expected %08lx\n", desc->ddsCaps.dwCaps, expected[*num].caps);
+    ok(desc->ddsCaps.dwCaps2 == expected[*num].caps2, "Surface caps2 are %08lx expected %08lx\n", desc->ddsCaps.dwCaps2, expected[*num].caps2);
     ok(mipmaps == expected[*num].mipmaps, "Surface has %d mipmaps, expected %d\n", mipmaps, expected[*num].mipmaps);
 
     (*num)++;
@@ -494,7 +494,7 @@ static void CubeMapTest(void)
     }
 
     hr = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
-    ok(hr == DD_OK, "IDirectDraw::QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw::QueryInterface returned %08lx\n", hr);
     if (FAILED(hr)) goto err;
 
     memset(&ddsd, 0, sizeof(ddsd));
@@ -521,11 +521,11 @@ static void CubeMapTest(void)
     }
 
     hr = IDirectDrawSurface7_GetSurfaceDesc(cubemap, &ddsd);
-    ok(hr == DD_OK, "IDirectDrawSurface7_GetSurfaceDesc returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface7_GetSurfaceDesc returned %08lx\n", hr);
     ok(ddsd.ddsCaps.dwCaps == (DDSCAPS_MIPMAP | DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY | DDSCAPS_COMPLEX),
-       "Root Caps are %08x\n", ddsd.ddsCaps.dwCaps);
+       "Root Caps are %08lx\n", ddsd.ddsCaps.dwCaps);
     ok(ddsd.ddsCaps.dwCaps2 == (DDSCAPS2_CUBEMAP_POSITIVEX | DDSCAPS2_CUBEMAP),
-       "Root Caps2 are %08x\n", ddsd.ddsCaps.dwCaps2);
+       "Root Caps2 are %08lx\n", ddsd.ddsCaps.dwCaps2);
 
     IDirectDrawSurface7_EnumAttachedSurfaces(cubemap,
                                              &num,
@@ -551,7 +551,7 @@ static void CubeMapTest(void)
     U4(U4(ddsd).ddpfPixelFormat).dwBBitMask = 0x001F;
 
     hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &cubemap, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw7::CreateSurface asking for a cube map without faces returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw7::CreateSurface asking for a cube map without faces returned %08lx\n", hr);
 
     /* Cube map faces without a cube map? */
     memset(&ddsd, 0, sizeof(ddsd));
@@ -571,7 +571,7 @@ static void CubeMapTest(void)
     U4(U4(ddsd).ddpfPixelFormat).dwBBitMask = 0x001F;
 
     hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &cubemap, NULL);
-    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw7::CreateSurface returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw7::CreateSurface returned %08lx\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -590,7 +590,7 @@ static void CubeMapTest(void)
     U4(U4(ddsd).ddpfPixelFormat).dwBBitMask = 0x001F;
 
     hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &cubemap, NULL);
-    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw7::CreateSurface returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw7::CreateSurface returned %08lx\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -612,7 +612,7 @@ static void CubeMapTest(void)
     }
 
     hr = IDirectDraw7_CreatePalette(dd7, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
-    ok(hr == DD_OK, "CreatePalette failed with %08x\n", hr);
+    ok(hr == DD_OK, "CreatePalette failed with %08lx\n", hr);
 
     hr = IDirectDrawSurface7_EnumAttachedSurfaces(cubemap, palette, CubeTestPaletteEnum);
     ok(hr == DD_OK, "EnumAttachedSurfaces failed\n");
@@ -632,7 +632,7 @@ static void CubeMapTest(void)
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(DDSURFACEDESC);
     hr = IDirectDraw_EnumSurfaces(lpDD, DDENUMSURFACES_DOESEXIST | DDENUMSURFACES_ALL, (DDSURFACEDESC *) &ddsd, (void *) &ctx, enumCB);
-    ok(hr == DD_OK, "IDirectDraw_EnumSurfaces returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw_EnumSurfaces returned %08lx\n", hr);
     ok(ctx.count == 0, "%d surfaces enumerated, expected 0\n", ctx.count);
 
     err:
@@ -649,7 +649,7 @@ static void CompressedTest(void)
     RECT r2 = { 32, 32, 64, 64 };
 
     hr = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
-    ok(hr == DD_OK, "IDirectDraw::QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw::QueryInterface returned %08lx\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -662,7 +662,7 @@ static void CompressedTest(void)
     U4(ddsd).ddpfPixelFormat.dwFourCC = MAKEFOURCC('D','X','T','1');
 
     hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface, NULL);
-    ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
+    ok(hr == DD_OK, "CreateSurface returned %08lx\n", hr);
     if (FAILED(hr))
     {
         skip("failed to create surface\n");
@@ -673,21 +673,21 @@ static void CompressedTest(void)
     ddsd2.dwSize = sizeof(ddsd2);
     U4(ddsd2).ddpfPixelFormat.dwSize = sizeof(U4(ddsd2).ddpfPixelFormat);
     hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd2);
-    ok(hr == DD_OK, "GetSurfaceDesc returned %08x\n", hr);
+    ok(hr == DD_OK, "GetSurfaceDesc returned %08lx\n", hr);
 
     ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-       "Surface desc flags: %08x\n", ddsd2.dwFlags);
-    ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-    ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+       "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+    ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+    ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
     ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY),
-       "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
-    ok(U1(ddsd2).dwLinearSize == 8192, "Linear size is %d\n", U1(ddsd2).dwLinearSize);
-    ok(ddsd2.ddsCaps.dwCaps2 == 0, "Caps2: %08x\n", ddsd2.ddsCaps.dwCaps2);
+       "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
+    ok(U1(ddsd2).dwLinearSize == 8192, "Linear size is %ld\n", U1(ddsd2).dwLinearSize);
+    ok(ddsd2.ddsCaps.dwCaps2 == 0, "Caps2: %08lx\n", ddsd2.ddsCaps.dwCaps2);
     IDirectDrawSurface7_Release(surface);
 
     U4(ddsd).ddpfPixelFormat.dwFourCC = MAKEFOURCC('D','X','T','3');
     hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface, NULL);
-    ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
+    ok(hr == DD_OK, "CreateSurface returned %08lx\n", hr);
     if (FAILED(hr))
     {
         skip("failed to create surface\n");
@@ -698,20 +698,20 @@ static void CompressedTest(void)
     ddsd2.dwSize = sizeof(ddsd2);
     U4(ddsd2).ddpfPixelFormat.dwSize = sizeof(U4(ddsd2).ddpfPixelFormat);
     hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd2);
-    ok(hr == DD_OK, "GetSurfaceDesc returned %08x\n", hr);
+    ok(hr == DD_OK, "GetSurfaceDesc returned %08lx\n", hr);
 
     ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-       "Surface desc flags: %08x\n", ddsd2.dwFlags);
-    ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-    ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+       "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+    ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+    ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
     ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY),
-       "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
-    ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %d\n", U1(ddsd2).dwLinearSize);
+       "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
+    ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %ld\n", U1(ddsd2).dwLinearSize);
     IDirectDrawSurface7_Release(surface);
 
     U4(ddsd).ddpfPixelFormat.dwFourCC = MAKEFOURCC('D','X','T','5');
     hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface, NULL);
-    ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
+    ok(hr == DD_OK, "CreateSurface returned %08lx\n", hr);
     if (FAILED(hr))
     {
         skip("failed to create surface\n");
@@ -722,15 +722,15 @@ static void CompressedTest(void)
     ddsd2.dwSize = sizeof(ddsd2);
     U4(ddsd2).ddpfPixelFormat.dwSize = sizeof(U4(ddsd2).ddpfPixelFormat);
     hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd2);
-    ok(hr == DD_OK, "GetSurfaceDesc returned %08x\n", hr);
+    ok(hr == DD_OK, "GetSurfaceDesc returned %08lx\n", hr);
 
     ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-       "Surface desc flags: %08x\n", ddsd2.dwFlags);
-    ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-    ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+       "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+    ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+    ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
     ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY),
-       "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
-    ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %d\n", U1(ddsd2).dwLinearSize);
+       "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
+    ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %ld\n", U1(ddsd2).dwLinearSize);
     ok(ddsd2.lpSurface == 0, "Surface memory is at %p, expected NULL\n", ddsd2.lpSurface);
 
     memset(&ddsd2, 0, sizeof(ddsd2));
@@ -741,51 +741,51 @@ static void CompressedTest(void)
      * about this is that DDSD_LPSURFACE isn't set.
      */
     hr = IDirectDrawSurface7_Lock(surface, NULL, &ddsd2, DDLOCK_READONLY, 0);
-    ok(hr == DD_OK, "Lock returned %08x\n", hr);
+    ok(hr == DD_OK, "Lock returned %08lx\n", hr);
 
     ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-       "Surface desc flags: %08x\n", ddsd2.dwFlags);
-    ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-    ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+       "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+    ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+    ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
     ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY),
-       "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
-    ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %d\n", U1(ddsd2).dwLinearSize);
+       "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
+    ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %ld\n", U1(ddsd2).dwLinearSize);
     ok(ddsd2.lpSurface != 0, "Surface memory is at NULL\n");
 
     hr = IDirectDrawSurface7_Unlock(surface, NULL);
-    ok(hr == DD_OK, "Unlock returned %08x\n", hr);
+    ok(hr == DD_OK, "Unlock returned %08lx\n", hr);
 
     /* Now what about a locking rect?  */
     hr = IDirectDrawSurface7_Lock(surface, &r, &ddsd2, DDLOCK_READONLY, 0);
-    ok(hr == DD_OK, "Lock returned %08x\n", hr);
+    ok(hr == DD_OK, "Lock returned %08lx\n", hr);
 
     ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-       "Surface desc flags: %08x\n", ddsd2.dwFlags);
-    ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-    ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+       "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+    ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+    ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
     ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY),
-       "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
-    ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %d\n", U1(ddsd2).dwLinearSize);
+       "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
+    ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %ld\n", U1(ddsd2).dwLinearSize);
     ok(ddsd2.lpSurface != 0, "Surface memory is at NULL\n");
 
     hr = IDirectDrawSurface7_Unlock(surface, &r);
-    ok(hr == DD_OK, "Unlock returned %08x\n", hr);
+    ok(hr == DD_OK, "Unlock returned %08lx\n", hr);
 
     /* Now what about a different locking offset? */
     hr = IDirectDrawSurface7_Lock(surface, &r2, &ddsd2, DDLOCK_READONLY, 0);
-    ok(hr == DD_OK, "Lock returned %08x\n", hr);
+    ok(hr == DD_OK, "Lock returned %08lx\n", hr);
 
     ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-       "Surface desc flags: %08x\n", ddsd2.dwFlags);
-    ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-    ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+       "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+    ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+    ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
     ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY),
-       "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
-    ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %d\n", U1(ddsd2).dwLinearSize);
+       "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
+    ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %ld\n", U1(ddsd2).dwLinearSize);
     ok(ddsd2.lpSurface != 0, "Surface memory is at NULL\n");
 
     hr = IDirectDrawSurface7_Unlock(surface, &r2);
-    ok(hr == DD_OK, "Unlock returned %08x\n", hr);
+    ok(hr == DD_OK, "Unlock returned %08lx\n", hr);
     IDirectDrawSurface7_Release(surface);
 
     /* Try this with video memory. A kind of surprise. It still has the LINEARSIZE flag set,
@@ -796,7 +796,7 @@ static void CompressedTest(void)
 
     hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface, NULL);
     ok(hr == DD_OK || hr == DDERR_NOTEXTUREHW || hr == DDERR_INVALIDPARAMS ||
-       broken(hr == DDERR_NODIRECTDRAWHW), "CreateSurface returned %08x\n", hr);
+       broken(hr == DDERR_NODIRECTDRAWHW), "CreateSurface returned %08lx\n", hr);
 
     /* Not supported everywhere */
     if(SUCCEEDED(hr))
@@ -805,53 +805,53 @@ static void CompressedTest(void)
         ddsd2.dwSize = sizeof(ddsd2);
         U4(ddsd2).ddpfPixelFormat.dwSize = sizeof(U4(ddsd2).ddpfPixelFormat);
         hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd2);
-        ok(hr == DD_OK, "GetSurfaceDesc returned %08x\n", hr);
+        ok(hr == DD_OK, "GetSurfaceDesc returned %08lx\n", hr);
 
         ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-        "Surface desc flags: %08x\n", ddsd2.dwFlags);
-        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+        "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
         ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM),
-        "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
+        "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
         /* ATI drivers report a broken linear size, thus no need to clone the exact behaviour. nvidia reports the correct size */
-        ok(ddsd2.ddsCaps.dwCaps2 == 0, "Caps2: %08x\n", ddsd2.ddsCaps.dwCaps2);
+        ok(ddsd2.ddsCaps.dwCaps2 == 0, "Caps2: %08lx\n", ddsd2.ddsCaps.dwCaps2);
         IDirectDrawSurface7_Release(surface);
 
         U4(ddsd).ddpfPixelFormat.dwFourCC = MAKEFOURCC('D','X','T','3');
         hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface, NULL);
-        ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
+        ok(hr == DD_OK, "CreateSurface returned %08lx\n", hr);
 
         memset(&ddsd2, 0, sizeof(ddsd2));
         ddsd2.dwSize = sizeof(ddsd2);
         U4(ddsd2).ddpfPixelFormat.dwSize = sizeof(U4(ddsd2).ddpfPixelFormat);
         hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd2);
-        ok(hr == DD_OK, "GetSurfaceDesc returned %08x\n", hr);
+        ok(hr == DD_OK, "GetSurfaceDesc returned %08lx\n", hr);
 
         ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-        "Surface desc flags: %08x\n", ddsd2.dwFlags);
-        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+        "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
         ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM),
-        "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
+        "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
         /* ATI drivers report a broken linear size, thus no need to clone the exact behaviour. nvidia reports the correct size */
         IDirectDrawSurface7_Release(surface);
 
         U4(ddsd).ddpfPixelFormat.dwFourCC = MAKEFOURCC('D','X','T','5');
         hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface, NULL);
-        ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
+        ok(hr == DD_OK, "CreateSurface returned %08lx\n", hr);
 
         memset(&ddsd2, 0, sizeof(ddsd2));
         ddsd2.dwSize = sizeof(ddsd2);
         U4(ddsd2).ddpfPixelFormat.dwSize = sizeof(U4(ddsd2).ddpfPixelFormat);
         hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd2);
-        ok(hr == DD_OK, "GetSurfaceDesc returned %08x\n", hr);
+        ok(hr == DD_OK, "GetSurfaceDesc returned %08lx\n", hr);
 
         ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-        "Surface desc flags: %08x\n", ddsd2.dwFlags);
-        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+        "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
         ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM),
-        "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
+        "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
         /* ATI drivers report a broken linear size, thus no need to clone the exact behaviour. nvidia reports the correct size */
         ok(ddsd2.lpSurface == 0, "Surface memory is at %p, expected NULL\n", ddsd2.lpSurface);
 
@@ -863,51 +863,51 @@ static void CompressedTest(void)
         * about this is that DDSD_LPSURFACE isn't set.
         */
         hr = IDirectDrawSurface7_Lock(surface, NULL, &ddsd2, DDLOCK_READONLY, 0);
-        ok(hr == DD_OK, "Lock returned %08x\n", hr);
+        ok(hr == DD_OK, "Lock returned %08lx\n", hr);
 
         ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-        "Surface desc flags: %08x\n", ddsd2.dwFlags);
-        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+        "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
         ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM),
-        "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
+        "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
         /* ATI drivers report a broken linear size, thus no need to clone the exact behaviour. nvidia reports the correct size */
         ok(ddsd2.lpSurface != 0, "Surface memory is at NULL\n");
 
         hr = IDirectDrawSurface7_Unlock(surface, NULL);
-        ok(hr == DD_OK, "Unlock returned %08x\n", hr);
+        ok(hr == DD_OK, "Unlock returned %08lx\n", hr);
 
         /* Now what about a locking rect?  */
         hr = IDirectDrawSurface7_Lock(surface, &r, &ddsd2, DDLOCK_READONLY, 0);
-        ok(hr == DD_OK, "Lock returned %08x\n", hr);
+        ok(hr == DD_OK, "Lock returned %08lx\n", hr);
 
         ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-        "Surface desc flags: %08x\n", ddsd2.dwFlags);
-        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+        "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
         ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM),
-        "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
+        "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
         /* ATI drivers report a broken linear size, thus no need to clone the exact behaviour. nvidia reports the correct size */
         ok(ddsd2.lpSurface != 0, "Surface memory is at NULL\n");
 
         hr = IDirectDrawSurface7_Unlock(surface, &r);
-        ok(hr == DD_OK, "Unlock returned %08x\n", hr);
+        ok(hr == DD_OK, "Unlock returned %08lx\n", hr);
 
         /* Now what about a different locking offset? */
         hr = IDirectDrawSurface7_Lock(surface, &r2, &ddsd2, DDLOCK_READONLY, 0);
-        ok(hr == DD_OK, "Lock returned %08x\n", hr);
+        ok(hr == DD_OK, "Lock returned %08lx\n", hr);
 
         ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-        "Surface desc flags: %08x\n", ddsd2.dwFlags);
-        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+        "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
         ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM),
-        "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
+        "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
         /* ATI drivers report a broken linear size, thus no need to clone the exact behaviour. nvidia reports the correct size */
         ok(ddsd2.lpSurface != 0, "Surface memory is at NULL\n");
 
         hr = IDirectDrawSurface7_Unlock(surface, &r2);
-        ok(hr == DD_OK, "Unlock returned %08x\n", hr);
+        ok(hr == DD_OK, "Unlock returned %08lx\n", hr);
 
         IDirectDrawSurface7_Release(surface);
     }
@@ -924,7 +924,7 @@ static void CompressedTest(void)
     U4(ddsd).ddpfPixelFormat.dwFourCC = MAKEFOURCC('D','X','T','1');
 
     hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface, NULL);
-    ok(hr == DD_OK || hr == DDERR_NOTEXTUREHW, "CreateSurface returned %08x\n", hr);
+    ok(hr == DD_OK || hr == DDERR_NOTEXTUREHW, "CreateSurface returned %08lx\n", hr);
 
     /* Not supported everywhere */
     if(SUCCEEDED(hr))
@@ -933,54 +933,54 @@ static void CompressedTest(void)
         ddsd2.dwSize = sizeof(ddsd2);
         U4(ddsd2).ddpfPixelFormat.dwSize = sizeof(U4(ddsd2).ddpfPixelFormat);
         hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd2);
-        ok(hr == DD_OK, "GetSurfaceDesc returned %08x\n", hr);
+        ok(hr == DD_OK, "GetSurfaceDesc returned %08lx\n", hr);
 
         ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-        "Surface desc flags: %08x\n", ddsd2.dwFlags);
-        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+        "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
         ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY),
-        "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
-        ok(U1(ddsd2).dwLinearSize == 8192, "Linear size is %d\n", U1(ddsd2).dwLinearSize);
-        ok(ddsd2.ddsCaps.dwCaps2 == DDSCAPS2_TEXTUREMANAGE, "Caps2: %08x\n", ddsd2.ddsCaps.dwCaps2);
+        "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
+        ok(U1(ddsd2).dwLinearSize == 8192, "Linear size is %ld\n", U1(ddsd2).dwLinearSize);
+        ok(ddsd2.ddsCaps.dwCaps2 == DDSCAPS2_TEXTUREMANAGE, "Caps2: %08lx\n", ddsd2.ddsCaps.dwCaps2);
         IDirectDrawSurface7_Release(surface);
 
         U4(ddsd).ddpfPixelFormat.dwFourCC = MAKEFOURCC('D','X','T','3');
         hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface, NULL);
-        ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
+        ok(hr == DD_OK, "CreateSurface returned %08lx\n", hr);
 
         memset(&ddsd2, 0, sizeof(ddsd2));
         ddsd2.dwSize = sizeof(ddsd2);
         U4(ddsd2).ddpfPixelFormat.dwSize = sizeof(U4(ddsd2).ddpfPixelFormat);
         hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd2);
-        ok(hr == DD_OK, "GetSurfaceDesc returned %08x\n", hr);
+        ok(hr == DD_OK, "GetSurfaceDesc returned %08lx\n", hr);
 
         ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-        "Surface desc flags: %08x\n", ddsd2.dwFlags);
-        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+        "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
         ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY),
-        "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
-        ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %d\n", U1(ddsd2).dwLinearSize);
+        "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
+        ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %ld\n", U1(ddsd2).dwLinearSize);
         IDirectDrawSurface7_Release(surface);
 
         U4(ddsd).ddpfPixelFormat.dwFourCC = MAKEFOURCC('D','X','T','5');
         hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface, NULL);
-        ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
+        ok(hr == DD_OK, "CreateSurface returned %08lx\n", hr);
 
         memset(&ddsd2, 0, sizeof(ddsd2));
         ddsd2.dwSize = sizeof(ddsd2);
         U4(ddsd2).ddpfPixelFormat.dwSize = sizeof(U4(ddsd2).ddpfPixelFormat);
         hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &ddsd2);
-        ok(hr == DD_OK, "GetSurfaceDesc returned %08x\n", hr);
+        ok(hr == DD_OK, "GetSurfaceDesc returned %08lx\n", hr);
 
         ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-        "Surface desc flags: %08x\n", ddsd2.dwFlags);
-        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+        "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
         ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY),
-        "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
-        ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %d\n", U1(ddsd2).dwLinearSize);
+        "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
+        ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %ld\n", U1(ddsd2).dwLinearSize);
         ok(ddsd2.lpSurface == 0, "Surface memory is at %p, expected NULL\n", ddsd2.lpSurface);
 
         memset(&ddsd2, 0, sizeof(ddsd2));
@@ -991,51 +991,51 @@ static void CompressedTest(void)
         * about this is that DDSD_LPSURFACE isn't set.
         */
         hr = IDirectDrawSurface7_Lock(surface, NULL, &ddsd2, DDLOCK_READONLY, 0);
-        ok(hr == DD_OK, "Lock returned %08x\n", hr);
+        ok(hr == DD_OK, "Lock returned %08lx\n", hr);
 
         ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-        "Surface desc flags: %08x\n", ddsd2.dwFlags);
-        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+        "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
         ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY),
-        "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
-        ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %d\n", U1(ddsd2).dwLinearSize);
+        "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
+        ok(U1(ddsd2).dwLinearSize == 16384, "Linear size is %ld\n", U1(ddsd2).dwLinearSize);
         ok(ddsd2.lpSurface != 0, "Surface memory is at NULL\n");
 
         hr = IDirectDrawSurface7_Unlock(surface, NULL);
-        ok(hr == DD_OK, "Unlock returned %08x\n", hr);
+        ok(hr == DD_OK, "Unlock returned %08lx\n", hr);
 
         /* Now what about a locking rect?  */
         hr = IDirectDrawSurface7_Lock(surface, &r, &ddsd2, DDLOCK_READONLY, 0);
-        ok(hr == DD_OK, "Lock returned %08x\n", hr);
+        ok(hr == DD_OK, "Lock returned %08lx\n", hr);
 
         ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-        "Surface desc flags: %08x\n", ddsd2.dwFlags);
-        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+        "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
         ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY),
-        "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
-        ok(U1(ddsd2).dwLinearSize == 16384, "\"Linear\" size is %d\n", U1(ddsd2).dwLinearSize);
+        "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
+        ok(U1(ddsd2).dwLinearSize == 16384, "\"Linear\" size is %ld\n", U1(ddsd2).dwLinearSize);
         ok(ddsd2.lpSurface != 0, "Surface memory is at NULL\n");
 
         hr = IDirectDrawSurface7_Unlock(surface, &r);
-        ok(hr == DD_OK, "Unlock returned %08x\n", hr);
+        ok(hr == DD_OK, "Unlock returned %08lx\n", hr);
 
         /* Now what about a different locking offset? */
         hr = IDirectDrawSurface7_Lock(surface, &r2, &ddsd2, DDLOCK_READONLY, 0);
-        ok(hr == DD_OK, "Lock returned %08x\n", hr);
+        ok(hr == DD_OK, "Lock returned %08lx\n", hr);
 
         ok(ddsd2.dwFlags == (DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_LINEARSIZE),
-        "Surface desc flags: %08x\n", ddsd2.dwFlags);
-        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08x\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
-        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08x\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
+        "Surface desc flags: %08lx\n", ddsd2.dwFlags);
+        ok(U4(ddsd2).ddpfPixelFormat.dwFlags == DDPF_FOURCC, "Pixel format flags: %08lx\n", U4(ddsd2).ddpfPixelFormat.dwFlags);
+        ok(U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount == 0, "RGB bitcount: %08lx\n", U1(U4(ddsd2).ddpfPixelFormat).dwRGBBitCount);
         ok(ddsd2.ddsCaps.dwCaps == (DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY),
-        "Surface caps flags: %08x\n", ddsd2.ddsCaps.dwCaps);
-        ok(U1(ddsd2).dwLinearSize == 16384, "\"Linear\" size is %d\n", U1(ddsd2).dwLinearSize);
+        "Surface caps flags: %08lx\n", ddsd2.ddsCaps.dwCaps);
+        ok(U1(ddsd2).dwLinearSize == 16384, "\"Linear\" size is %ld\n", U1(ddsd2).dwLinearSize);
         ok(ddsd2.lpSurface != 0, "Surface memory is at NULL\n");
 
         hr = IDirectDrawSurface7_Unlock(surface, &r2);
-        ok(hr == DD_OK, "Unlock returned %08x\n", hr);
+        ok(hr == DD_OK, "Unlock returned %08lx\n", hr);
 
         IDirectDrawSurface7_Release(surface);
     }
@@ -1061,7 +1061,7 @@ static void SizeTest(void)
     desc.dwFlags = DDSD_CAPS;
     desc.ddsCaps.dwCaps |= DDSCAPS_OFFSCREENPLAIN;
     ret = IDirectDraw_CreateSurface(lpDD, &desc, &dsurface, NULL);
-    ok(ret == DDERR_INVALIDPARAMS, "Creating an offscreen plain surface without a size info returned %08x (dsurface=%p)\n", ret, dsurface);
+    ok(ret == DDERR_INVALIDPARAMS, "Creating an offscreen plain surface without a size info returned %08lx (dsurface=%p)\n", ret, dsurface);
     if(dsurface)
     {
         trace("Surface at %p\n", dsurface);
@@ -1076,7 +1076,7 @@ static void SizeTest(void)
     desc.ddsCaps.dwCaps |= DDSCAPS_OFFSCREENPLAIN;
     desc.dwWidth = 128;
     ret = IDirectDraw_CreateSurface(lpDD, &desc, &dsurface, NULL);
-    ok(ret == DDERR_INVALIDPARAMS, "Creating an offscreen plain surface without height info returned %08x\n", ret);
+    ok(ret == DDERR_INVALIDPARAMS, "Creating an offscreen plain surface without height info returned %08lx\n", ret);
     if(dsurface)
     {
         IDirectDrawSurface_Release(dsurface);
@@ -1090,7 +1090,7 @@ static void SizeTest(void)
     desc.ddsCaps.dwCaps |= DDSCAPS_OFFSCREENPLAIN;
     desc.dwHeight = 128;
     ret = IDirectDraw_CreateSurface(lpDD, &desc, &dsurface, NULL);
-    ok(ret == DDERR_INVALIDPARAMS, "Creating an offscreen plain surface without width info returned %08x\n", ret);
+    ok(ret == DDERR_INVALIDPARAMS, "Creating an offscreen plain surface without width info returned %08lx\n", ret);
     if(dsurface)
     {
         IDirectDrawSurface_Release(dsurface);
@@ -1105,7 +1105,7 @@ static void SizeTest(void)
     desc.dwWidth = 1;
     desc.dwHeight = 0;
     ret = IDirectDraw_CreateSurface(lpDD, &desc, &dsurface, NULL);
-    ok(ret == DDERR_INVALIDPARAMS, "Creating a 0 height surface returned %#x, expected DDERR_INVALIDPARAMS.\n", ret);
+    ok(ret == DDERR_INVALIDPARAMS, "Creating a 0 height surface returned %#lx, expected DDERR_INVALIDPARAMS.\n", ret);
     if (SUCCEEDED(ret)) IDirectDrawSurface_Release(dsurface);
     dsurface = NULL;
 
@@ -1117,7 +1117,7 @@ static void SizeTest(void)
     desc.dwWidth = 0;
     desc.dwHeight = 1;
     ret = IDirectDraw_CreateSurface(lpDD, &desc, &dsurface, NULL);
-    ok(ret == DDERR_INVALIDPARAMS, "Creating a 0 width surface returned %#x, expected DDERR_INVALIDPARAMS.\n", ret);
+    ok(ret == DDERR_INVALIDPARAMS, "Creating a 0 width surface returned %#lx, expected DDERR_INVALIDPARAMS.\n", ret);
     if (SUCCEEDED(ret)) IDirectDrawSurface_Release(dsurface);
     dsurface = NULL;
 
@@ -1129,7 +1129,7 @@ static void SizeTest(void)
     desc.dwHeight = 128;
     desc.dwWidth = 128;
     ret = IDirectDraw_CreateSurface(lpDD, &desc, &dsurface, NULL);
-    ok(ret == DD_OK, "Creating an offscreen plain surface with width and height info returned %08x\n", ret);
+    ok(ret == DD_OK, "Creating an offscreen plain surface with width and height info returned %08lx\n", ret);
     if(dsurface)
     {
         IDirectDrawSurface_Release(dsurface);
@@ -1138,7 +1138,7 @@ static void SizeTest(void)
 
     /* Test a primary surface size */
     ret = IDirectDraw_SetCooperativeLevel(lpDD, window, DDSCL_NORMAL);
-    ok(ret == DD_OK, "SetCooperativeLevel failed with %08x\n", ret);
+    ok(ret == DD_OK, "SetCooperativeLevel failed with %08lx\n", ret);
 
     ZeroMemory(&desc, sizeof(desc));
     desc.dwSize = sizeof(desc);
@@ -1147,11 +1147,11 @@ static void SizeTest(void)
     desc.dwHeight = 128; /* Keep them set to  check what happens */
     desc.dwWidth = 128; /* Keep them set to  check what happens */
     ret = IDirectDraw_CreateSurface(lpDD, &desc, &dsurface, NULL);
-    ok(ret == DD_OK, "Creating a primary surface without width and height info returned %08x\n", ret);
+    ok(ret == DD_OK, "Creating a primary surface without width and height info returned %08lx\n", ret);
     if(dsurface)
     {
         ret = IDirectDrawSurface_GetSurfaceDesc(dsurface, &desc);
-        ok(ret == DD_OK, "GetSurfaceDesc returned %x\n", ret);
+        ok(ret == DD_OK, "GetSurfaceDesc returned %lx\n", ret);
 
         IDirectDrawSurface_Release(dsurface);
         dsurface = NULL;
@@ -1162,7 +1162,7 @@ static void SizeTest(void)
         ok(desc.dwHeight == GetSystemMetrics(SM_CYSCREEN), "Surface height differs from screen height\n");
     }
     ret = IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL);
-    ok(ret == DD_OK, "SetCooperativeLevel failed with %08x\n", ret);
+    ok(ret == DD_OK, "SetCooperativeLevel failed with %08lx\n", ret);
 }
 
 static void BltParamTest(void)
@@ -1184,47 +1184,47 @@ static void BltParamTest(void)
     desc.dwHeight = 128;
     desc.dwWidth = 128;
     hr = IDirectDraw_CreateSurface(lpDD, &desc, &surface1, NULL);
-    ok(hr == DD_OK, "Creating an offscreen plain surface failed with %08x\n", hr);
+    ok(hr == DD_OK, "Creating an offscreen plain surface failed with %08lx\n", hr);
 
     desc.dwHeight = 64;
     desc.dwWidth = 64;
     hr = IDirectDraw_CreateSurface(lpDD, &desc, &surface2, NULL);
-    ok(hr == DD_OK, "Creating an offscreen plain surface failed with %08x\n", hr);
+    ok(hr == DD_OK, "Creating an offscreen plain surface failed with %08lx\n", hr);
 
     if(0)
     {
         /* This crashes */
         hr = IDirectDrawSurface_BltFast(surface1, 0, 0, NULL, NULL, 0);
-        ok(hr == DD_OK, "BltFast from NULL surface returned %08x\n", hr);
+        ok(hr == DD_OK, "BltFast from NULL surface returned %08lx\n", hr);
     }
     hr = IDirectDrawSurface_BltFast(surface1, 0, 0, surface2, NULL, 0);
-    ok(hr == DD_OK, "BltFast from smaller to bigger surface returned %08x\n", hr);
+    ok(hr == DD_OK, "BltFast from smaller to bigger surface returned %08lx\n", hr);
     hr = IDirectDrawSurface_BltFast(surface2, 0, 0, surface1, NULL, 0);
-    ok(hr == DDERR_INVALIDRECT, "BltFast from bigger to smaller surface returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "BltFast from bigger to smaller surface returned %08lx\n", hr);
     hr = IDirectDrawSurface_BltFast(surface2, 0, 0, surface1, &valid, 0);
-    ok(hr == DD_OK, "BltFast from bigger to smaller surface using a valid rectangle returned %08x\n", hr);
+    ok(hr == DD_OK, "BltFast from bigger to smaller surface using a valid rectangle returned %08lx\n", hr);
     hr = IDirectDrawSurface_BltFast(surface2, 60, 60, surface1, &valid, 0);
-    ok(hr == DDERR_INVALIDRECT, "BltFast with a rectangle resulting in an off-surface write returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "BltFast with a rectangle resulting in an off-surface write returned %08lx\n", hr);
     hr = IDirectDrawSurface_BltFast(surface1, 90, 90, surface2, NULL, 0);
-    ok(hr == DDERR_INVALIDRECT, "BltFast with a rectangle resulting in an off-surface write returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "BltFast with a rectangle resulting in an off-surface write returned %08lx\n", hr);
 
     hr = IDirectDrawSurface_BltFast(surface1, -10, 0, surface2, NULL, 0);
-    ok(hr == DDERR_INVALIDRECT, "BltFast with an offset resulting in an off-surface write returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "BltFast with an offset resulting in an off-surface write returned %08lx\n", hr);
     hr = IDirectDrawSurface_BltFast(surface1, 0, -10, surface2, NULL, 0);
-    ok(hr == DDERR_INVALIDRECT, "BltFast with an offset resulting in an off-surface write returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "BltFast with an offset resulting in an off-surface write returned %08lx\n", hr);
     hr = IDirectDrawSurface_BltFast(surface2, 20, 20, surface1, &valid, 0);
-    ok(hr == DD_OK, "BltFast from bigger to smaller surface using a valid rectangle and offset returned %08x\n", hr);
+    ok(hr == DD_OK, "BltFast from bigger to smaller surface using a valid rectangle and offset returned %08lx\n", hr);
 
     hr = IDirectDrawSurface_BltFast(surface2, 0, 0, surface1, &invalid1, 0);
-    ok(hr == DDERR_INVALIDRECT, "BltFast with invalid rectangle 1 returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "BltFast with invalid rectangle 1 returned %08lx\n", hr);
     hr = IDirectDrawSurface_BltFast(surface2, 0, 0, surface1, &invalid2, 0);
-    ok(hr == DDERR_INVALIDRECT, "BltFast with invalid rectangle 2 returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "BltFast with invalid rectangle 2 returned %08lx\n", hr);
     hr = IDirectDrawSurface_BltFast(surface2, 0, 0, surface1, &invalid3, 0);
-    ok(hr == DDERR_INVALIDRECT, "BltFast with invalid rectangle 3 returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "BltFast with invalid rectangle 3 returned %08lx\n", hr);
     hr = IDirectDrawSurface_BltFast(surface1, 0, 0, surface2, &invalid4, 0);
-    ok(hr == DDERR_INVALIDRECT, "BltFast with invalid rectangle 3 returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "BltFast with invalid rectangle 3 returned %08lx\n", hr);
     hr = IDirectDrawSurface_BltFast(surface1, 0, 0, surface1, NULL, 0);
-    ok(hr == DD_OK, "BltFast blitting a surface onto itself returned %08x\n", hr);
+    ok(hr == DD_OK, "BltFast blitting a surface onto itself returned %08lx\n", hr);
 
     /* Blt(non-fast) tests */
     memset(&BltFx, 0, sizeof(BltFx));
@@ -1232,47 +1232,47 @@ static void BltParamTest(void)
     U5(BltFx).dwFillColor = 0xaabbccdd;
 
     hr = IDirectDrawSurface_Blt(surface1, &valid, NULL, NULL, DDBLT_COLORFILL, &BltFx);
-    ok(hr == DD_OK, "IDirectDrawSurface_Blt with a valid rectangle for color fill returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface_Blt with a valid rectangle for color fill returned %08lx\n", hr);
     hr = IDirectDrawSurface_Blt(surface1, &valid, NULL, &invalid3, DDBLT_COLORFILL, &BltFx);
-    ok(hr == DD_OK, "IDirectDrawSurface_Blt with an invalid, unused rectangle returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface_Blt with an invalid, unused rectangle returned %08lx\n", hr);
     hr = IDirectDrawSurface_Blt(surface2, &invalid1, NULL, NULL, DDBLT_COLORFILL, &BltFx);
-    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 1 returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 1 returned %08lx\n", hr);
     hr = IDirectDrawSurface_Blt(surface2, &invalid2, NULL, NULL, DDBLT_COLORFILL, &BltFx);
-    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 2 returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 2 returned %08lx\n", hr);
     hr = IDirectDrawSurface_Blt(surface2, &invalid3, NULL, NULL, DDBLT_COLORFILL, &BltFx);
-    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 3 returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 3 returned %08lx\n", hr);
     hr = IDirectDrawSurface_Blt(surface2, &invalid4, NULL, NULL, DDBLT_COLORFILL, &BltFx);
-    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 4 returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 4 returned %08lx\n", hr);
 
     /* Valid on surface 1 */
     hr = IDirectDrawSurface_Blt(surface1, &invalid4, NULL, NULL, DDBLT_COLORFILL, &BltFx);
-    ok(hr == DD_OK, "IDirectDrawSurface_Blt with a subrectangle fill returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface_Blt with a subrectangle fill returned %08lx\n", hr);
 
     /* Works - stretched blit */
     hr = IDirectDrawSurface_Blt(surface1, NULL, surface2, NULL, 0, NULL);
-    ok(hr == DD_OK, "IDirectDrawSurface_Blt from a smaller to a bigger surface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface_Blt from a smaller to a bigger surface returned %08lx\n", hr);
     hr = IDirectDrawSurface_Blt(surface2, NULL, surface1, NULL, 0, NULL);
-    ok(hr == DD_OK, "IDirectDrawSurface_Blt from a bigger to a smaller surface %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface_Blt from a bigger to a smaller surface %08lx\n", hr);
 
     /* Invalid dest rects in sourced blits */
     hr = IDirectDrawSurface_Blt(surface2, &invalid1, surface1, NULL, 0, NULL);
-    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 1 returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 1 returned %08lx\n", hr);
     hr = IDirectDrawSurface_Blt(surface2, &invalid2, surface1, NULL, 0, NULL);
-    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 2 returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 2 returned %08lx\n", hr);
     hr = IDirectDrawSurface_Blt(surface2, &invalid3, surface1, NULL, 0, NULL);
-    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 3 returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 3 returned %08lx\n", hr);
     hr = IDirectDrawSurface_Blt(surface2, &invalid4, surface1, NULL, 0, NULL);
-    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 4 returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 4 returned %08lx\n", hr);
 
     /* Invalid src rects */
     hr = IDirectDrawSurface_Blt(surface2, NULL, surface1, &invalid1, 0, NULL);
-    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 1 returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 1 returned %08lx\n", hr);
     hr = IDirectDrawSurface_Blt(surface2, NULL, surface1, &invalid2, 0, NULL);
-    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 2 returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 2 returned %08lx\n", hr);
     hr = IDirectDrawSurface_Blt(surface2, NULL, surface1, &invalid3, 0, NULL);
-    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 3 returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 3 returned %08lx\n", hr);
     hr = IDirectDrawSurface_Blt(surface1, NULL, surface2, &invalid4, 0, NULL);
-    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 4 returned %08x\n", hr);
+    ok(hr == DDERR_INVALIDRECT, "IDirectDrawSurface_Blt with a with invalid rectangle 4 returned %08lx\n", hr);
 
     IDirectDrawSurface_Release(surface1);
     IDirectDrawSurface_Release(surface2);
@@ -1300,12 +1300,12 @@ static void PaletteTest(void)
 
     /* Create a 8bit palette without DDPCAPS_ALLOW256 set */
     hr = IDirectDraw_CreatePalette(lpDD, DDPCAPS_8BIT, Table, &palette, NULL);
-    ok(hr == DD_OK, "CreatePalette failed with %08x\n", hr);
+    ok(hr == DD_OK, "CreatePalette failed with %08lx\n", hr);
     if (FAILED(hr)) goto err;
     /* Read back the palette and verify the entries. Without DDPCAPS_ALLOW256 set
     /  entry 0 and 255 should have been overwritten with black and white */
     hr = IDirectDrawPalette_GetEntries(palette , 0, 0, 256, &palEntries[0]);
-    ok(hr == DD_OK, "GetEntries failed with %08x\n", hr);
+    ok(hr == DD_OK, "GetEntries failed with %08lx\n", hr);
     if(hr == DD_OK)
     {
         ok((palEntries[0].peRed == 0) && (palEntries[0].peGreen == 0) && (palEntries[0].peBlue == 0),
@@ -1325,9 +1325,9 @@ static void PaletteTest(void)
     /* CreatePalette without DDPCAPS_ALLOW256 ignores entry 0 and 255,
     /  now check we are able to update the entries afterwards. */
     hr = IDirectDrawPalette_SetEntries(palette , 0, 0, 256, &Table[0]);
-    ok(hr == DD_OK, "SetEntries failed with %08x\n", hr);
+    ok(hr == DD_OK, "SetEntries failed with %08lx\n", hr);
     hr = IDirectDrawPalette_GetEntries(palette , 0, 0, 256, &palEntries[0]);
-    ok(hr == DD_OK, "GetEntries failed with %08x\n", hr);
+    ok(hr == DD_OK, "GetEntries failed with %08lx\n", hr);
     if(hr == DD_OK)
     {
         ok((palEntries[0].peRed == 0) && (palEntries[0].peGreen == 0) && (palEntries[0].peBlue == 0),
@@ -1341,11 +1341,11 @@ static void PaletteTest(void)
 
     /* Create a 8bit palette with DDPCAPS_ALLOW256 set */
     hr = IDirectDraw_CreatePalette(lpDD, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
-    ok(hr == DD_OK, "CreatePalette failed with %08x\n", hr);
+    ok(hr == DD_OK, "CreatePalette failed with %08lx\n", hr);
     if (FAILED(hr)) goto err;
 
     hr = IDirectDrawPalette_GetEntries(palette , 0, 0, 256, &palEntries[0]);
-    ok(hr == DD_OK, "GetEntries failed with %08x\n", hr);
+    ok(hr == DD_OK, "GetEntries failed with %08lx\n", hr);
     if(hr == DD_OK)
     {
         /* All entries should contain red */
@@ -1368,7 +1368,7 @@ static void PaletteTest(void)
     U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x00FF00;
     U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x0000FF;
     hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpSurf, NULL);
-    ok(hr==DD_OK, "CreateSurface returned: %x\n",hr);
+    ok(hr==DD_OK, "CreateSurface returned: %lx\n",hr);
     if (FAILED(hr))
     {
         skip("failed to create surface\n");
@@ -1376,13 +1376,13 @@ static void PaletteTest(void)
     }
 
     hr = IDirectDrawSurface_SetPalette(lpSurf, palette);
-    ok(hr == DDERR_INVALIDPIXELFORMAT, "CreateSurface returned: %x\n",hr);
+    ok(hr == DDERR_INVALIDPIXELFORMAT, "CreateSurface returned: %lx\n",hr);
 
     IDirectDrawPalette_Release(palette);
     palette = NULL;
 
     hr = IDirectDrawSurface_GetPalette(lpSurf, &palette);
-    ok(hr == DDERR_NOPALETTEATTACHED, "CreateSurface returned: %x\n",hr);
+    ok(hr == DDERR_NOPALETTEATTACHED, "CreateSurface returned: %lx\n",hr);
 
     err:
 
@@ -1390,7 +1390,7 @@ static void PaletteTest(void)
     if (palette) IDirectDrawPalette_Release(palette);
 
     hr = IDirectDraw_CreatePalette(lpDD, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
-    ok(hr == DD_OK, "CreatePalette failed with %08x\n", hr);
+    ok(hr == DD_OK, "CreatePalette failed with %08lx\n", hr);
 
     ddsd.dwSize = sizeof(ddsd);
     ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
@@ -1403,7 +1403,7 @@ static void PaletteTest(void)
     U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 8;
 
     hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpSurf, NULL);
-    ok(hr==DD_OK, "CreateSurface returned: %x\n",hr);
+    ok(hr==DD_OK, "CreateSurface returned: %lx\n",hr);
     if (FAILED(hr))
     {
         skip("failed to create surface\n");
@@ -1412,16 +1412,16 @@ static void PaletteTest(void)
 
     ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
     hr = IDirectDrawSurface_GetAttachedSurface(lpSurf, &ddscaps, &backbuffer);
-    ok(hr == DD_OK, "GetAttachedSurface returned: %x\n",hr);
+    ok(hr == DD_OK, "GetAttachedSurface returned: %lx\n",hr);
 
     hr = IDirectDrawSurface_SetPalette(backbuffer, palette);
-    ok(hr == DD_OK, "SetPalette returned: %x\n",hr);
+    ok(hr == DD_OK, "SetPalette returned: %lx\n",hr);
 
     IDirectDrawPalette_Release(palette);
     palette = NULL;
 
     hr = IDirectDrawSurface_GetPalette(backbuffer, &palette);
-    ok(hr == DD_OK, "CreateSurface returned: %x\n",hr);
+    ok(hr == DD_OK, "CreateSurface returned: %lx\n",hr);
     IDirectDrawPalette_Release(palette);
 
     IDirectDrawSurface_Release(backbuffer);
@@ -1497,17 +1497,17 @@ static void SurfaceCapsTest(void)
         }
 
         hr = IDirectDraw_CreateSurface(lpDD, &create, &surface1, NULL);
-        ok(hr == DD_OK, "IDirectDraw_CreateSurface failed with %08x\n", hr);
+        ok(hr == DD_OK, "IDirectDraw_CreateSurface failed with %08lx\n", hr);
 
         if (SUCCEEDED(hr))
         {
             memset(&desc, 0, sizeof(desc));
             desc.dwSize = sizeof(DDSURFACEDESC);
             hr = IDirectDrawSurface_GetSurfaceDesc(surface1, &desc);
-            ok(hr == DD_OK, "IDirectDrawSurface_GetSurfaceDesc failed with %08x\n", hr);
+            ok(hr == DD_OK, "IDirectDrawSurface_GetSurfaceDesc failed with %08lx\n", hr);
 
             ok(desc.ddsCaps.dwCaps == expected_caps[i],
-                    "GetSurfaceDesc test %d returned caps %x, expected %x\n",
+                    "GetSurfaceDesc test %d returned caps %lx, expected %lx\n",
                     i, desc.ddsCaps.dwCaps, expected_caps[i]);
 
             IDirectDrawSurface_Release(surface1);
@@ -1516,7 +1516,7 @@ static void SurfaceCapsTest(void)
 
     /* Test for differences in ddraw 7 */
     hr = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
-    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", hr);
     if (FAILED(hr))
     {
         skip("Failed to get IDirectDraw7 interface, skipping tests\n");
@@ -1547,17 +1547,17 @@ static void SurfaceCapsTest(void)
             }
 
             hr = IDirectDraw7_CreateSurface(dd7, &create2, &surface7, NULL);
-            ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
+            ok(hr==DD_OK,"CreateSurface returned: %lx\n",hr);
 
             if (SUCCEEDED(hr))
             {
                 memset(&desc2, 0, sizeof(desc2));
                 desc2.dwSize = sizeof(DDSURFACEDESC2);
                 hr = IDirectDrawSurface7_GetSurfaceDesc(surface7, &desc2);
-                ok(hr == DD_OK, "IDirectDrawSurface_GetSurfaceDesc failed with %08x\n", hr);
+                ok(hr == DD_OK, "IDirectDrawSurface_GetSurfaceDesc failed with %08lx\n", hr);
 
                 ok(desc2.ddsCaps.dwCaps == expected_caps[i],
-                        "GetSurfaceDesc test %d returned caps %x, expected %x\n",
+                        "GetSurfaceDesc test %d returned caps %lx, expected %lx\n",
                         i, desc2.ddsCaps.dwCaps, expected_caps[i]);
 
                 IDirectDrawSurface7_Release(surface7);
@@ -1574,7 +1574,7 @@ static void SurfaceCapsTest(void)
     create.dwWidth = 64;
     create.dwHeight = 64;
     hr = IDirectDraw_CreateSurface(lpDD, &create, &surface1, NULL);
-    ok(hr == DDERR_INVALIDCAPS, "Creating a SYSMEM | VIDMEM surface returned 0x%08x, expected DDERR_INVALIDCAPS\n", hr);
+    ok(hr == DDERR_INVALIDCAPS, "Creating a SYSMEM | VIDMEM surface returned 0x%08lx, expected DDERR_INVALIDCAPS\n", hr);
     if(surface1) IDirectDrawSurface_Release(surface1);
 }
 
@@ -1632,40 +1632,40 @@ static void BackBufferCreateSurfaceTest(void)
     created_ddsd.dwSize = sizeof(DDSURFACEDESC);
 
     hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surf, NULL);
-    ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed: 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed: 0x%08lx\n", hr);
     if (surf != NULL)
     {
         hr = IDirectDrawSurface_GetSurfaceDesc(surf, &created_ddsd);
-        ok(SUCCEEDED(hr), "IDirectDraw_GetSurfaceDesc failed: 0x%08x\n", hr);
+        ok(SUCCEEDED(hr), "IDirectDraw_GetSurfaceDesc failed: 0x%08lx\n", hr);
         ok(created_ddsd.ddsCaps.dwCaps == expected_caps,
-           "GetSurfaceDesc returned caps %x, expected %x\n", created_ddsd.ddsCaps.dwCaps,
+           "GetSurfaceDesc returned caps %lx, expected %lx\n", created_ddsd.ddsCaps.dwCaps,
            expected_caps);
         IDirectDrawSurface_Release(surf);
     }
 
     hr = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw2, (void **) &dd2);
-    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08lx\n", hr);
 
     hr = IDirectDraw2_CreateSurface(dd2, &ddsd, &surf, NULL);
-    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw2_CreateSurface didn't return %x08x, but %x08x\n",
+    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw2_CreateSurface didn't return %lx08x, but %lx08x\n",
        DDERR_INVALIDCAPS, hr);
 
     IDirectDraw2_Release(dd2);
 
     hr = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw4, (void **) &dd4);
-    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08lx\n", hr);
 
     hr = IDirectDraw4_CreateSurface(dd4, &ddsd2, &surf4, NULL);
-    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw4_CreateSurface didn't return %x08x, but %x08x\n",
+    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw4_CreateSurface didn't return %lx08x, but %lx08x\n",
        DDERR_INVALIDCAPS, hr);
 
     IDirectDraw4_Release(dd4);
 
     hr = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
-    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08lx\n", hr);
 
     hr = IDirectDraw7_CreateSurface(dd7, &ddsd2, &surf7, NULL);
-    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw7_CreateSurface didn't return %x08x, but %x08x\n",
+    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw7_CreateSurface didn't return %lx08x, but %lx08x\n",
        DDERR_INVALIDCAPS, hr);
 
     IDirectDraw7_Release(dd7);
@@ -1680,7 +1680,7 @@ static void BackBufferAttachmentFlipTest(void)
             100, 100, 160, 160, NULL, NULL, NULL, NULL);
 
     hr = IDirectDraw_SetCooperativeLevel(lpDD, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "SetCooperativeLevel returned %08x\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel returned %08lx\n", hr);
 
     /* Perform attachment tests on a back-buffer */
     memset(&ddsd, 0, sizeof(ddsd));
@@ -1690,7 +1690,7 @@ static void BackBufferAttachmentFlipTest(void)
     ddsd.dwWidth = GetSystemMetrics(SM_CXSCREEN);
     ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN);
     hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface2, NULL);
-    ok(SUCCEEDED(hr), "CreateSurface returned: %x\n",hr);
+    ok(SUCCEEDED(hr), "CreateSurface returned: %lx\n",hr);
 
     if (surface2 != NULL)
     {
@@ -1700,7 +1700,7 @@ static void BackBufferAttachmentFlipTest(void)
         ddsd.dwFlags = DDSD_CAPS;
         ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
         hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface1, NULL);
-        ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
+        ok(hr==DD_OK,"CreateSurface returned: %lx\n",hr);
 
         memset(&ddsd, 0, sizeof(ddsd));
         ddsd.dwSize = sizeof(ddsd);
@@ -1709,7 +1709,7 @@ static void BackBufferAttachmentFlipTest(void)
         ddsd.dwWidth = GetSystemMetrics(SM_CXSCREEN);
         ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN);
         hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface3, NULL);
-        ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
+        ok(hr==DD_OK,"CreateSurface returned: %lx\n",hr);
 
         /* This one has a different size */
         memset(&ddsd, 0, sizeof(ddsd));
@@ -1719,63 +1719,63 @@ static void BackBufferAttachmentFlipTest(void)
         ddsd.dwWidth = 128;
         ddsd.dwHeight = 128;
         hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface4, NULL);
-        ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
+        ok(hr==DD_OK,"CreateSurface returned: %lx\n",hr);
 
         hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
         todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
-           "Attaching a back buffer to a front buffer returned %08x\n", hr);
+           "Attaching a back buffer to a front buffer returned %08lx\n", hr);
         if(SUCCEEDED(hr))
         {
             /* Try flipping the surfaces */
             hr = IDirectDrawSurface_Flip(surface1, NULL, DDFLIP_WAIT);
-            todo_wine ok(hr == DD_OK, "IDirectDrawSurface_Flip returned 0x%08x\n", hr);
+            todo_wine ok(hr == DD_OK, "IDirectDrawSurface_Flip returned 0x%08lx\n", hr);
             hr = IDirectDrawSurface_Flip(surface2, NULL, DDFLIP_WAIT);
-            todo_wine ok(hr == DDERR_NOTFLIPPABLE, "IDirectDrawSurface_Flip returned 0x%08x\n", hr);
+            todo_wine ok(hr == DDERR_NOTFLIPPABLE, "IDirectDrawSurface_Flip returned 0x%08lx\n", hr);
 
             /* Try the reverse without detaching first */
             hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface1);
-            ok(hr == DDERR_SURFACEALREADYATTACHED, "Attaching an attached surface to its attachee returned %08x\n", hr);
+            ok(hr == DDERR_SURFACEALREADYATTACHED, "Attaching an attached surface to its attachee returned %08lx\n", hr);
             hr = IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface2);
-            ok(hr == DD_OK, "DeleteAttachedSurface failed with %08x\n", hr);
+            ok(hr == DD_OK, "DeleteAttachedSurface failed with %08lx\n", hr);
         }
         hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface1);
         todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
-           "Attaching a front buffer to a back buffer returned %08x\n", hr);
+           "Attaching a front buffer to a back buffer returned %08lx\n", hr);
         if(SUCCEEDED(hr))
         {
             /* Try flipping the surfaces */
             hr = IDirectDrawSurface_Flip(surface1, NULL, DDFLIP_WAIT);
-            todo_wine ok(hr == DD_OK, "IDirectDrawSurface_Flip returned 0x%08x\n", hr);
+            todo_wine ok(hr == DD_OK, "IDirectDrawSurface_Flip returned 0x%08lx\n", hr);
             hr = IDirectDrawSurface_Flip(surface2, NULL, DDFLIP_WAIT);
-            todo_wine ok(hr == DDERR_NOTFLIPPABLE, "IDirectDrawSurface_Flip returned 0x%08x\n", hr);
+            todo_wine ok(hr == DDERR_NOTFLIPPABLE, "IDirectDrawSurface_Flip returned 0x%08lx\n", hr);
 
             /* Try to detach reversed */
             hr = IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface2);
-            ok(hr == DDERR_CANNOTDETACHSURFACE, "DeleteAttachedSurface returned %08x\n", hr);
+            ok(hr == DDERR_CANNOTDETACHSURFACE, "DeleteAttachedSurface returned %08lx\n", hr);
             /* Now the proper detach */
             hr = IDirectDrawSurface_DeleteAttachedSurface(surface2, 0, surface1);
-            ok(hr == DD_OK, "DeleteAttachedSurface failed with %08x\n", hr);
+            ok(hr == DD_OK, "DeleteAttachedSurface failed with %08lx\n", hr);
         }
         hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface3);
         todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
-           "Attaching a back buffer to another back buffer returned %08x\n", hr);
+           "Attaching a back buffer to another back buffer returned %08lx\n", hr);
         if(SUCCEEDED(hr))
         {
             /* Try flipping the surfaces */
             hr = IDirectDrawSurface_Flip(surface3, NULL, DDFLIP_WAIT);
-            todo_wine ok(hr == DD_OK, "IDirectDrawSurface_Flip returned 0x%08x\n", hr);
+            todo_wine ok(hr == DD_OK, "IDirectDrawSurface_Flip returned 0x%08lx\n", hr);
             hr = IDirectDrawSurface_Flip(surface2, NULL, DDFLIP_WAIT);
-            todo_wine ok(hr == DDERR_NOTFLIPPABLE, "IDirectDrawSurface_Flip returned 0x%08x\n", hr);
+            todo_wine ok(hr == DDERR_NOTFLIPPABLE, "IDirectDrawSurface_Flip returned 0x%08lx\n", hr);
             hr = IDirectDrawSurface_Flip(surface1, NULL, DDFLIP_WAIT);
-            ok(hr == DDERR_NOTFLIPPABLE, "IDirectDrawSurface_Flip returned 0x%08x\n", hr);
+            ok(hr == DDERR_NOTFLIPPABLE, "IDirectDrawSurface_Flip returned 0x%08lx\n", hr);
 
             hr = IDirectDrawSurface_DeleteAttachedSurface(surface2, 0, surface3);
-            ok(hr == DD_OK, "DeleteAttachedSurface failed with %08x\n", hr);
+            ok(hr == DD_OK, "DeleteAttachedSurface failed with %08lx\n", hr);
         }
         hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a back buffer to a front buffer of different size returned %08x\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a back buffer to a front buffer of different size returned %08lx\n", hr);
         hr = IDirectDrawSurface_AddAttachedSurface(surface4, surface1);
-        ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a front buffer to a back buffer of different size returned %08x\n", hr);
+        ok(hr == DDERR_CANNOTATTACHSURFACE, "Attaching a front buffer to a back buffer of different size returned %08lx\n", hr);
 
         IDirectDrawSurface_Release(surface4);
         IDirectDrawSurface_Release(surface3);
@@ -1784,7 +1784,7 @@ static void BackBufferAttachmentFlipTest(void)
     }
 
     hr =IDirectDraw_SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel returned %08x\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel returned %08lx\n", hr);
 
     DestroyWindow(window);
 }
@@ -1842,96 +1842,96 @@ static void CreateSurfaceBadCapsSizeTest(void)
     ddsd2_bad4.dwSize = sizeof(DDSURFACEDESC);
 
     hr = IDirectDraw_CreateSurface(lpDD, &ddsd_ok, &surf, NULL);
-    ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed: 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed: 0x%08lx\n", hr);
     IDirectDrawSurface_Release(surf);
 
     hr = IDirectDraw_CreateSurface(lpDD, &ddsd_bad1, &surf, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
     hr = IDirectDraw_CreateSurface(lpDD, &ddsd_bad2, &surf, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
     hr = IDirectDraw_CreateSurface(lpDD, &ddsd_bad3, &surf, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
     hr = IDirectDraw_CreateSurface(lpDD, &ddsd_bad4, &surf, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
     hr = IDirectDraw_CreateSurface(lpDD, NULL, &surf, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
 
     hr = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw2, (void **) &dd2);
-    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08lx\n", hr);
 
     hr = IDirectDraw2_CreateSurface(dd2, &ddsd_ok, &surf, NULL);
-    ok(SUCCEEDED(hr), "IDirectDraw2_CreateSurface failed: 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw2_CreateSurface failed: 0x%08lx\n", hr);
     IDirectDrawSurface_Release(surf);
 
     hr = IDirectDraw2_CreateSurface(dd2, &ddsd_bad1, &surf, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw2_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw2_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
     hr = IDirectDraw2_CreateSurface(dd2, &ddsd_bad2, &surf, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw2_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw2_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
     hr = IDirectDraw2_CreateSurface(dd2, &ddsd_bad3, &surf, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw2_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw2_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
     hr = IDirectDraw2_CreateSurface(dd2, &ddsd_bad4, &surf, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw2_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw2_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
     hr = IDirectDraw2_CreateSurface(dd2, NULL, &surf, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw2_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw2_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
 
     IDirectDraw2_Release(dd2);
 
     hr = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw4, (void **) &dd4);
-    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08lx\n", hr);
 
     hr = IDirectDraw4_CreateSurface(dd4, &ddsd2_ok, &surf4, NULL);
-    ok(SUCCEEDED(hr), "IDirectDraw4_CreateSurface failed: 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw4_CreateSurface failed: 0x%08lx\n", hr);
     IDirectDrawSurface4_Release(surf4);
 
     hr = IDirectDraw4_CreateSurface(dd4, &ddsd2_bad1, &surf4, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw4_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw4_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
     hr = IDirectDraw4_CreateSurface(dd4, &ddsd2_bad2, &surf4, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw4_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw4_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
     hr = IDirectDraw4_CreateSurface(dd4, &ddsd2_bad3, &surf4, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw4_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw4_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
     hr = IDirectDraw4_CreateSurface(dd4, &ddsd2_bad4, &surf4, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw4_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw4_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
     hr = IDirectDraw4_CreateSurface(dd4, NULL, &surf4, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw4_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw4_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
 
     IDirectDraw4_Release(dd4);
 
     hr = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
-    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08lx\n", hr);
 
     hr = IDirectDraw7_CreateSurface(dd7, &ddsd2_ok, &surf7, NULL);
-    ok(SUCCEEDED(hr), "IDirectDraw7_CreateSurface failed: 0x%08x\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw7_CreateSurface failed: 0x%08lx\n", hr);
     IDirectDrawSurface7_Release(surf7);
 
     hr = IDirectDraw7_CreateSurface(dd7, &ddsd2_bad1, &surf7, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw7_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw7_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
     hr = IDirectDraw7_CreateSurface(dd7, &ddsd2_bad2, &surf7, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw7_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw7_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
     hr = IDirectDraw7_CreateSurface(dd7, &ddsd2_bad3, &surf7, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw7_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw7_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
     hr = IDirectDraw7_CreateSurface(dd7, &ddsd2_bad4, &surf7, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw7_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw7_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
     hr = IDirectDraw7_CreateSurface(dd7, NULL, &surf7, NULL);
-    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw7_CreateSurface didn't return 0x%08x, but 0x%08x\n",
+    ok(hr == DDERR_INVALIDPARAMS, "IDirectDraw7_CreateSurface didn't return 0x%08lx, but 0x%08lx\n",
        DDERR_INVALIDPARAMS, hr);
 
     IDirectDraw7_Release(dd7);
@@ -1955,7 +1955,7 @@ static void no_ddsd_caps_test(void)
     ddsd.dwHeight = 128;
     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
     hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed, hr %#lx.\n", hr);
     reset_ddsd(&ddsd);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &ddsd);
     IDirectDrawSurface_Release(surface);
@@ -1965,7 +1965,7 @@ static void no_ddsd_caps_test(void)
     reset_ddsd(&ddsd);
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
     hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed, hr %#lx.\n", hr);
     reset_ddsd(&ddsd);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &ddsd);
     IDirectDrawSurface_Release(surface);
@@ -1978,14 +1978,14 @@ static void no_ddsd_caps_test(void)
     ddsd.dwHeight = 128;
     ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface, NULL);
-    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw_CreateSurface returned %#x, expected DDERR_INVALIDCAPS.\n", hr);
+    ok(hr == DDERR_INVALIDCAPS, "IDirectDraw_CreateSurface returned %#lx, expected DDERR_INVALIDCAPS.\n", hr);
 }
 
 static void dump_format(const DDPIXELFORMAT *fmt)
 {
-    trace("dwFlags %08x, FourCC %08x, dwZBufferBitDepth %u, stencil %u\n", fmt->dwFlags, fmt->dwFourCC,
+    trace("dwFlags %08lx, FourCC %08lx, dwZBufferBitDepth %lu, stencil %lu\n", fmt->dwFlags, fmt->dwFourCC,
           U1(*fmt).dwZBufferBitDepth, U2(*fmt).dwStencilBitDepth);
-    trace("dwZBitMask %08x, dwStencilBitMask %08x, dwRGBZBitMask %08x\n", U3(*fmt).dwZBitMask,
+    trace("dwZBitMask %08lx, dwStencilBitMask %08lx, dwRGBZBitMask %08lx\n", U3(*fmt).dwZBitMask,
           U4(*fmt).dwStencilBitMask, U5(*fmt).dwRGBZBitMask);
 }
 
@@ -2052,7 +2052,7 @@ static void zbufferbitdepth_test(void)
     memset(&caps, 0, sizeof(caps));
     caps.dwSize = sizeof(caps);
     hr = IDirectDraw_GetCaps(lpDD, &caps, NULL);
-    ok(SUCCEEDED(hr), "IDirectDraw_GetCaps failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_GetCaps failed, hr %#lx.\n", hr);
     if (!(caps.ddsCaps.dwCaps & DDSCAPS_ZBUFFER))
     {
         skip("Z buffers not supported, skipping DDSD_ZBUFFERBITDEPTH test\n");
@@ -2071,18 +2071,18 @@ static void zbufferbitdepth_test(void)
         hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface, NULL);
         if (test_data[i].supported == ZFMT_SUPPORTED_ALWAYS)
         {
-            ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed, hr %#x.\n", hr);
+            ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed, hr %#lx.\n", hr);
         }
         else if (test_data[i].supported == ZFMT_SUPPORTED_NEVER)
         {
-            ok(hr == DDERR_INVALIDPIXELFORMAT, "IDirectDraw_CreateSurface returned %#x, expected %x.\n",
+            ok(hr == DDERR_INVALIDPIXELFORMAT, "IDirectDraw_CreateSurface returned %#lx, expected %lx.\n",
                hr, DDERR_INVALIDPIXELFORMAT);
         }
         if (!surface) continue;
 
         reset_ddsd(&ddsd);
         hr = IDirectDrawSurface_GetSurfaceDesc(surface, &ddsd);
-        ok(SUCCEEDED(hr), "IDirectDrawSurface_GetSurfaceDesc failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "IDirectDrawSurface_GetSurfaceDesc failed, hr %#lx.\n", hr);
         IDirectDrawSurface_Release(surface);
 
         ok(ddsd.dwFlags & DDSD_ZBUFFERBITDEPTH, "DDSD_ZBUFFERBITDEPTH is not set\n");
@@ -2090,7 +2090,7 @@ static void zbufferbitdepth_test(void)
         /* Yet the ddpfPixelFormat member contains valid data */
         if (memcmp(&ddsd.ddpfPixelFormat, &test_data[i].pf, ddsd.ddpfPixelFormat.dwSize))
         {
-            ok(0, "Unexpected format for depth %u\n", test_data[i].depth);
+            ok(0, "Unexpected format for depth %lu\n", test_data[i].depth);
             dump_format(&ddsd.ddpfPixelFormat);
         }
     }
@@ -2109,17 +2109,17 @@ static void zbufferbitdepth_test(void)
 
     surface = NULL;
     hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed, hr %#lx.\n", hr);
     if (!surface) return;
     reset_ddsd(&ddsd);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &ddsd);
-    ok(SUCCEEDED(hr), "IDirectDrawSurface_GetSurfaceDesc failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDrawSurface_GetSurfaceDesc failed, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface);
-    ok(U1(ddsd.ddpfPixelFormat).dwZBufferBitDepth == 16, "Expected a 16bpp depth buffer, got %ubpp\n",
+    ok(U1(ddsd.ddpfPixelFormat).dwZBufferBitDepth == 16, "Expected a 16bpp depth buffer, got %lubpp\n",
        U1(ddsd.ddpfPixelFormat).dwZBufferBitDepth);
     ok(ddsd.dwFlags & DDSD_ZBUFFERBITDEPTH, "DDSD_ZBUFFERBITDEPTH is not set\n");
     ok(!(ddsd.dwFlags & DDSD_PIXELFORMAT), "DDSD_PIXELFORMAT is set\n");
-    ok(U2(ddsd).dwZBufferBitDepth == 16, "Expected dwZBufferBitDepth=16, got %u\n",
+    ok(U2(ddsd).dwZBufferBitDepth == 16, "Expected dwZBufferBitDepth=16, got %lu\n",
        U2(ddsd).dwZBufferBitDepth);
 
     /* DDSD_PIXELFORMAT vs invalid ZBUFFERBITDEPTH */
@@ -2135,7 +2135,7 @@ static void zbufferbitdepth_test(void)
     U3(ddsd.ddpfPixelFormat).dwZBitMask = 0x0000ffff;
     surface = NULL;
     hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed, hr %#lx.\n", hr);
     if (surface) IDirectDrawSurface_Release(surface);
 
     /* Create a PIXELFORMAT-only surface, see if ZBUFFERBITDEPTH is set */
@@ -2150,16 +2150,16 @@ static void zbufferbitdepth_test(void)
     U3(ddsd.ddpfPixelFormat).dwZBitMask = 0x0000ffff;
     surface = NULL;
     hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface, NULL);
-    ok(SUCCEEDED(hr), "IDirectDrawSurface_GetSurfaceDesc failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDrawSurface_GetSurfaceDesc failed, hr %#lx.\n", hr);
     reset_ddsd(&ddsd);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &ddsd);
-    ok(SUCCEEDED(hr), "IDirectDrawSurface_GetSurfaceDesc failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDrawSurface_GetSurfaceDesc failed, hr %#lx.\n", hr);
     IDirectDrawSurface_Release(surface);
-    ok(U1(ddsd.ddpfPixelFormat).dwZBufferBitDepth == 16, "Expected a 16bpp depth buffer, got %ubpp\n",
+    ok(U1(ddsd.ddpfPixelFormat).dwZBufferBitDepth == 16, "Expected a 16bpp depth buffer, got %lubpp\n",
        U1(ddsd.ddpfPixelFormat).dwZBufferBitDepth);
     ok(ddsd.dwFlags & DDSD_ZBUFFERBITDEPTH, "DDSD_ZBUFFERBITDEPTH is not set\n");
     ok(!(ddsd.dwFlags & DDSD_PIXELFORMAT), "DDSD_PIXELFORMAT is set\n");
-    ok(U2(ddsd).dwZBufferBitDepth == 16, "Expected dwZBufferBitDepth=16, got %u\n",
+    ok(U2(ddsd).dwZBufferBitDepth == 16, "Expected dwZBufferBitDepth=16, got %lu\n",
        U2(ddsd).dwZBufferBitDepth);
 }
 
@@ -2177,17 +2177,17 @@ static void test_ddsd(DDSURFACEDESC *ddsd, BOOL expect_pf, BOOL expect_zd, const
         skip("Z buffers not supported, skipping Z flag test\n");
         return;
     }
-    ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed, hr %#lx.\n", hr);
     hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void **) &surface7);
-    ok(SUCCEEDED(hr), "IDirectDrawSurface_QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDrawSurface_QueryInterface failed, hr %#lx.\n", hr);
 
     reset_ddsd(&out);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &out);
-    ok(SUCCEEDED(hr), "IDirectDrawSurface_GetSurfaceDesc failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDrawSurface_GetSurfaceDesc failed, hr %#lx.\n", hr);
     memset(&out2, 0, sizeof(out2));
     out2.dwSize = sizeof(out2);
     hr = IDirectDrawSurface7_GetSurfaceDesc(surface7, &out2);
-    ok(SUCCEEDED(hr), "IDirectDrawSurface_GetSurfaceDesc failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDrawSurface_GetSurfaceDesc failed, hr %#lx.\n", hr);
 
     if (expect_pf)
     {
@@ -2204,20 +2204,20 @@ static void test_ddsd(DDSURFACEDESC *ddsd, BOOL expect_pf, BOOL expect_zd, const
     if (expect_zd)
     {
         ok(out.dwFlags & DDSD_ZBUFFERBITDEPTH, "%s surface: Expected DDSD_ZBUFFERBITDEPTH to be set\n", name);
-        ok(U2(out).dwZBufferBitDepth == z_bit_depth, "ZBufferBitDepth is %u, expected %u\n",
+        ok(U2(out).dwZBufferBitDepth == z_bit_depth, "ZBufferBitDepth is %lu, expected %lu\n",
                 U2(out).dwZBufferBitDepth, z_bit_depth);
         ok(!(out2.dwFlags & DDSD_ZBUFFERBITDEPTH),
                 "%s surface: Did not expect DDSD_ZBUFFERBITDEPTH to be set in DDSURFACEDESC2\n", name);
         /* dwMipMapCount and dwZBufferBitDepth share the same union */
-        ok(U2(out2).dwMipMapCount == 0, "dwMipMapCount is %u, expected 0\n", U2(out2).dwMipMapCount);
+        ok(U2(out2).dwMipMapCount == 0, "dwMipMapCount is %lu, expected 0\n", U2(out2).dwMipMapCount);
     }
     else
     {
         ok(!(out.dwFlags & DDSD_ZBUFFERBITDEPTH), "%s surface: Expected DDSD_ZBUFFERBITDEPTH not to be set\n", name);
-        ok(U2(out).dwZBufferBitDepth == 0, "ZBufferBitDepth is %u, expected 0\n", U2(out).dwZBufferBitDepth);
+        ok(U2(out).dwZBufferBitDepth == 0, "ZBufferBitDepth is %lu, expected 0\n", U2(out).dwZBufferBitDepth);
         ok(!(out2.dwFlags & DDSD_ZBUFFERBITDEPTH),
                 "%s surface: Did not expect DDSD_ZBUFFERBITDEPTH to be set in DDSURFACEDESC2\n", name);
-        ok(U2(out2).dwMipMapCount == 0, "dwMipMapCount is %u, expected 0\n", U2(out2).dwMipMapCount);
+        ok(U2(out2).dwMipMapCount == 0, "dwMipMapCount is %lu, expected 0\n", U2(out2).dwMipMapCount);
     }
 
     reset_ddsd(&out);
@@ -2225,7 +2225,7 @@ static void test_ddsd(DDSURFACEDESC *ddsd, BOOL expect_pf, BOOL expect_zd, const
     if (SUCCEEDED(hr))
     {
         hr = IDirectDrawSurface_Unlock(surface, NULL);
-        ok(SUCCEEDED(hr), "IDirectDrawSurface_GetSurfaceDesc failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "IDirectDrawSurface_GetSurfaceDesc failed, hr %#lx.\n", hr);
 
         /* DDSD_ZBUFFERBITDEPTH is never set on Nvidia, but follows GetSurfaceDesc rules on AMD */
         if (!expect_zd)
@@ -2245,24 +2245,24 @@ static void test_ddsd(DDSURFACEDESC *ddsd, BOOL expect_pf, BOOL expect_zd, const
                 "Lock %s surface: Expected DDSD_PIXELFORMAT not to be set\n", name);
         }
         if (out.dwFlags & DDSD_ZBUFFERBITDEPTH)
-            ok(U2(out).dwZBufferBitDepth == z_bit_depth, "ZBufferBitDepth is %u, expected %u\n",
+            ok(U2(out).dwZBufferBitDepth == z_bit_depth, "ZBufferBitDepth is %lu, expected %lu\n",
                     U2(out).dwZBufferBitDepth, z_bit_depth);
         else
-            ok(U2(out).dwZBufferBitDepth == 0, "ZBufferBitDepth is %u, expected 0\n", U2(out).dwZBufferBitDepth);
+            ok(U2(out).dwZBufferBitDepth == 0, "ZBufferBitDepth is %lu, expected 0\n", U2(out).dwZBufferBitDepth);
     }
 
     hr = IDirectDrawSurface7_Lock(surface7, NULL, &out2, 0, NULL);
-    ok(SUCCEEDED(hr), "IDirectDrawSurface7_Lock failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDrawSurface7_Lock failed, hr %#lx.\n", hr);
     if (SUCCEEDED(hr))
     {
         hr = IDirectDrawSurface7_Unlock(surface7, NULL);
-        ok(SUCCEEDED(hr), "IDirectDrawSurface7_Unlock failed, hr %#x.\n", hr);
+        ok(SUCCEEDED(hr), "IDirectDrawSurface7_Unlock failed, hr %#lx.\n", hr);
         /* DDSD_PIXELFORMAT is always set, DDSD_ZBUFFERBITDEPTH never */
         ok(out2.dwFlags & DDSD_PIXELFORMAT,
                 "Lock %s surface: Expected DDSD_PIXELFORMAT to be set in DDSURFACEDESC2\n", name);
         ok(!(out2.dwFlags & DDSD_ZBUFFERBITDEPTH),
                 "Lock %s surface: Did not expect DDSD_ZBUFFERBITDEPTH to be set in DDSURFACEDESC2\n", name);
-        ok(U2(out2).dwMipMapCount == 0, "dwMipMapCount is %u, expected 0\n", U2(out2).dwMipMapCount);
+        ok(U2(out2).dwMipMapCount == 0, "dwMipMapCount is %lu, expected 0\n", U2(out2).dwMipMapCount);
     }
 
     IDirectDrawSurface7_Release(surface7);
@@ -2278,7 +2278,7 @@ static void pixelformat_flag_test(void)
     memset(&caps, 0, sizeof(caps));
     caps.dwSize = sizeof(caps);
     hr = IDirectDraw_GetCaps(lpDD, &caps, NULL);
-    ok(SUCCEEDED(hr), "IDirectDraw_GetCaps failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirectDraw_GetCaps failed, hr %#lx.\n", hr);
     if (!(caps.ddsCaps.dwCaps & DDSCAPS_ZBUFFER))
     {
         skip("Z buffers not supported, skipping DDSD_PIXELFORMAT test\n");
@@ -2379,7 +2379,7 @@ static void partial_block_lock_test(void)
     RECT rect;
 
     hr = IDirectDraw_QueryInterface(lpDD, &IID_IDirectDraw7, (void **) &dd7);
-    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "QueryInterface failed, hr %#lx.\n", hr);
 
     for (i = 0; i < sizeof(formats) / sizeof(formats[0]); i++)
     {
@@ -2404,7 +2404,7 @@ static void partial_block_lock_test(void)
             U4(ddsd).ddpfPixelFormat.dwFlags = DDPF_FOURCC;
             U4(ddsd).ddpfPixelFormat.dwFourCC = formats[i].fourcc;
             hr = IDirectDraw7_CreateSurface(dd7, &ddsd, &surface, NULL);
-            ok(SUCCEEDED(hr), "CreateSurface failed, hr %#x, format %s, pool %s\n",
+            ok(SUCCEEDED(hr), "CreateSurface failed, hr %#lx, format %s, pool %s\n",
                 hr, formats[i].name, pools[j].name);
 
             /* All Windows versions allow partial block locks with DDSCAPS_SYSTEMMEMORY and
@@ -2424,7 +2424,7 @@ static void partial_block_lock_test(void)
                 if (SUCCEEDED(hr))
                 {
                     hr = IDirectDrawSurface7_Unlock(surface, NULL);
-                    ok(SUCCEEDED(hr), "Unlock failed, hr %#x.\n", hr);
+                    ok(SUCCEEDED(hr), "Unlock failed, hr %#lx.\n", hr);
                 }
 
                 SetRect(&rect, 0, 0, formats[i].block_width >> 1, formats[i].block_height);
@@ -2436,7 +2436,7 @@ static void partial_block_lock_test(void)
                 if (SUCCEEDED(hr))
                 {
                     hr = IDirectDrawSurface7_Unlock(surface, NULL);
-                    ok(SUCCEEDED(hr), "Unlock failed, hr %#x.\n", hr);
+                    ok(SUCCEEDED(hr), "Unlock failed, hr %#lx.\n", hr);
                 }
             }
 
@@ -2451,7 +2451,7 @@ static void partial_block_lock_test(void)
                 if (SUCCEEDED(hr))
                 {
                     hr = IDirectDrawSurface7_Unlock(surface, NULL);
-                    ok(SUCCEEDED(hr), "Unlock failed, hr %#x.\n", hr);
+                    ok(SUCCEEDED(hr), "Unlock failed, hr %#lx.\n", hr);
                 }
 
                 SetRect(&rect, 0, 0, formats[i].block_width, formats[i].block_height >> 1);
@@ -2463,18 +2463,18 @@ static void partial_block_lock_test(void)
                 if (SUCCEEDED(hr))
                 {
                     hr = IDirectDrawSurface7_Unlock(surface, NULL);
-                    ok(SUCCEEDED(hr), "Unlock failed, hr %#x.\n", hr);
+                    ok(SUCCEEDED(hr), "Unlock failed, hr %#lx.\n", hr);
                 }
             }
 
             SetRect(&rect, 0, 0, formats[i].block_width, formats[i].block_height);
             hr = IDirectDrawSurface7_Lock(surface, &rect, &ddsd, 0, NULL);
-            ok(SUCCEEDED(hr), "Full block lock returned %08x, expected %08x, format %s, pool %s\n",
+            ok(SUCCEEDED(hr), "Full block lock returned %08lx, expected %08lx, format %s, pool %s\n",
                     hr, DD_OK, formats[i].name, pools[j].name);
             if (SUCCEEDED(hr))
             {
                 hr = IDirectDrawSurface7_Unlock(surface, NULL);
-                ok(SUCCEEDED(hr), "Unlock failed, hr %#x.\n", hr);
+                ok(SUCCEEDED(hr), "Unlock failed, hr %#lx.\n", hr);
             }
 
             IDirectDrawSurface7_Release(surface);
@@ -2514,7 +2514,7 @@ START_TEST(dsurface)
     ret = IDirectDraw_GetCaps(lpDD, &ddcaps, NULL);
     if (ret != DD_OK)
     {
-        skip("IDirectDraw_GetCaps failed with %08x\n", ret);
+        skip("IDirectDraw_GetCaps failed with %08lx\n", ret);
         return;
     }
 
diff --git a/dlls/ddraw/tests/refcount.c b/dlls/ddraw/tests/refcount.c
index 07673ab66e9b..ce04f406bf13 100644
--- a/dlls/ddraw/tests/refcount.c
+++ b/dlls/ddraw/tests/refcount.c
@@ -55,7 +55,7 @@ static void test_ddraw_objects(void)
     DDSURFACEDESC2 ddsd;
 
     hr = pDirectDrawCreateEx(NULL, (void **) &DDraw7, &IID_IDirectDraw7, NULL);
-    ok(hr == DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", hr);
+    ok(hr == DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %lx\n", hr);
     if(!DDraw7)
     {
         trace("Couldn't create DDraw interface, skipping tests\n");
@@ -63,25 +63,25 @@ static void test_ddraw_objects(void)
     }
 
     hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw4, (void **) &DDraw4);
-    ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08lx\n", hr);
     hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw2, (void **) &DDraw2);
-    ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08lx\n", hr);
     hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw, (void **) &DDraw1);
-    ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08lx\n", hr);
 
     ref = getRefcount( (IUnknown *) DDraw7);
-    ok(ref == 1, "Got refcount %d, expected 1\n", ref);
+    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
 
     /* Fails without a cooplevel */
     hr = IDirectDraw7_CreatePalette(DDraw7, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
-    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "CreatePalette returned %08x\n", hr);
+    ok(hr == DDERR_NOCOOPERATIVELEVELSET, "CreatePalette returned %08lx\n", hr);
 
     /* This check is before the cooplevel check */
     hr = IDirectDraw7_CreatePalette(DDraw7, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, (void *) 0xdeadbeef);
-    ok(hr == CLASS_E_NOAGGREGATION, "CreatePalette returned %08x\n", hr);
+    ok(hr == CLASS_E_NOAGGREGATION, "CreatePalette returned %08lx\n", hr);
 
     hr = IDirectDraw7_SetCooperativeLevel(DDraw7, 0, DDSCL_NORMAL);
-    ok(hr == DD_OK, "SetCooperativeLevel failed with %08x\n", hr);
+    ok(hr == DD_OK, "SetCooperativeLevel failed with %08lx\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -96,98 +96,98 @@ static void test_ddraw_objects(void)
     hr = IDirectDraw7_CreateSurface(DDraw7, &ddsd, &surface, NULL);
     if (!surface)
     {
-        win_skip("Could not create surface : %08x\n", hr);
+        win_skip("Could not create surface : %08lx\n", hr);
         IDirectDraw_Release(DDraw1);
         IDirectDraw2_Release(DDraw2);
         IDirectDraw4_Release(DDraw4);
         IDirectDraw7_Release(DDraw7);
         return;
     }
-    ok(hr == DD_OK, "CreateSurface failed with %08x\n", hr);
+    ok(hr == DD_OK, "CreateSurface failed with %08lx\n", hr);
 
     /* DDraw refcount increased by 1 */
     ref = getRefcount( (IUnknown *) DDraw7);
-    ok(ref == 2, "Got refcount %d, expected 2\n", ref);
+    ok(ref == 2, "Got refcount %ld, expected 2\n", ref);
 
     /* Surface refcount starts with 1 */
     ref = getRefcount( (IUnknown *) surface);
-    ok(ref == 1, "Got refcount %d, expected 1\n", ref);
+    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
 
     hr = IDirectDraw7_CreatePalette(DDraw7, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
-    ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
+    ok(hr == DD_OK, "CreatePalette returned %08lx\n", hr);
 
     /* DDraw refcount increased by 1 */
     ref = getRefcount( (IUnknown *) DDraw7);
-    ok(ref == 3, "Got refcount %d, expected 3\n", ref);
+    ok(ref == 3, "Got refcount %ld, expected 3\n", ref);
 
     /* Palette starts with 1 */
     ref = getRefcount( (IUnknown *) palette);
-    ok(ref == 1, "Got refcount %d, expected 1\n", ref);
+    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
 
     /* Test attaching a palette to a surface */
     hr = IDirectDrawSurface7_SetPalette(surface, palette);
-    ok(hr == DD_OK, "IDirectDrawSurface_SetPalette failed with %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface_SetPalette failed with %08lx\n", hr);
 
     /* Palette refcount increased, surface stays the same */
     ref = getRefcount( (IUnknown *) palette);
-    ok(ref == 2, "Got refcount %d, expected 2\n", ref);
+    ok(ref == 2, "Got refcount %ld, expected 2\n", ref);
     ref = getRefcount( (IUnknown *) surface);
-    ok(ref == 1, "Got refcount %d, expected 1\n", ref);
+    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
 
     IDirectDrawSurface7_Release(surface);
     /* Increased before - decrease now */
     ref = getRefcount( (IUnknown *) DDraw7);
-    ok(ref == 2, "Got refcount %d, expected 2\n", ref);
+    ok(ref == 2, "Got refcount %ld, expected 2\n", ref);
 
     /* Releasing the surface detaches the palette */
     ref = getRefcount( (IUnknown *) palette);
-    ok(ref == 1, "Got refcount %d, expected 1\n", ref);
+    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
 
     IDirectDrawPalette_Release(palette);
 
     /* Increased before - decrease now */
     ref = getRefcount( (IUnknown *) DDraw7);
-    ok(ref == 1, "Got refcount %d, expected 1\n", ref);
+    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
 
     /* Not all interfaces are AddRefed when a palette is created */
     hr = IDirectDraw4_CreatePalette(DDraw4, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
-    ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
+    ok(hr == DD_OK, "CreatePalette returned %08lx\n", hr);
     ref = getRefcount( (IUnknown *) DDraw4);
-    ok(ref == 2, "Got refcount %d, expected 2\n", ref);
+    ok(ref == 2, "Got refcount %ld, expected 2\n", ref);
     IDirectDrawPalette_Release(palette);
 
     /* No addref here */
     hr = IDirectDraw2_CreatePalette(DDraw2, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
-    ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
+    ok(hr == DD_OK, "CreatePalette returned %08lx\n", hr);
     ref = getRefcount( (IUnknown *) DDraw2);
-    ok(ref == 1, "Got refcount %d, expected 1\n", ref);
+    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
     IDirectDrawPalette_Release(palette);
 
     /* No addref here */
     hr = IDirectDraw_CreatePalette(DDraw1, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, Table, &palette, NULL);
-    ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
+    ok(hr == DD_OK, "CreatePalette returned %08lx\n", hr);
     ref = getRefcount( (IUnknown *) DDraw1);
-    ok(ref == 1, "Got refcount %d, expected 1\n", ref);
+    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
     IDirectDrawPalette_Release(palette);
 
     /* Similar for surfaces */
     hr = IDirectDraw4_CreateSurface(DDraw4, &ddsd, &surface4, NULL);
-    ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
+    ok(hr == DD_OK, "CreateSurface returned %08lx\n", hr);
     ref = getRefcount( (IUnknown *) DDraw4);
-    ok(ref == 2, "Got refcount %d, expected 2\n", ref);
+    ok(ref == 2, "Got refcount %ld, expected 2\n", ref);
     IDirectDrawSurface4_Release(surface4);
 
     ddsd.dwSize = sizeof(DDSURFACEDESC);
     hr = IDirectDraw2_CreateSurface(DDraw2, (DDSURFACEDESC *) &ddsd, &surface1, NULL);
-    ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
+    ok(hr == DD_OK, "CreateSurface returned %08lx\n", hr);
     ref = getRefcount( (IUnknown *) DDraw2);
-    ok(ref == 1, "Got refcount %d, expected 1\n", ref);
+    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
     IDirectDrawSurface_Release(surface1);
 
     hr = IDirectDraw_CreateSurface(DDraw1, (DDSURFACEDESC *) &ddsd, &surface1, NULL);
-    ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
+    ok(hr == DD_OK, "CreateSurface returned %08lx\n", hr);
     ref = getRefcount( (IUnknown *) DDraw1);
-    ok(ref == 1, "Got refcount %d, expected 1\n", ref);
+    ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
     IDirectDrawSurface_Release(surface1);
 
     IDirectDraw7_Release(DDraw7);
@@ -210,7 +210,7 @@ static void test_iface_refcnt(void)
     long ref;
 
     hr = pDirectDrawCreateEx(NULL, (void **) &DDraw7, &IID_IDirectDraw7, NULL);
-    ok(hr == DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", hr);
+    ok(hr == DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %lx\n", hr);
     if(!DDraw7)
     {
         trace("Couldn't create DDraw interface, skipping tests\n");
@@ -221,11 +221,11 @@ static void test_iface_refcnt(void)
     ok(ref == 1, "Initial IDirectDraw7 reference count is %ld\n", ref);
 
     hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw4, (void **) &DDraw4);
-    ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08lx\n", hr);
     hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw2, (void **) &DDraw2);
-    ok(hr == DD_OK, "IDirectDraw7_QueryInterf&ace returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw7_QueryInterf&ace returned %08lx\n", hr);
     hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirectDraw, (void **) &DDraw1);
-    ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw7_QueryInterface returned %08lx\n", hr);
 
     /* All interfaces now have refcount 1! */
     ref = getRefcount( (IUnknown *) DDraw7);
@@ -241,7 +241,7 @@ static void test_iface_refcnt(void)
 
     hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirect3D7, (void **) &D3D7);
     ok(hr == DD_OK || hr == E_NOINTERFACE, /* win64 */
-       "IDirectDraw7_QueryInterface returned %08x\n", hr);
+       "IDirectDraw7_QueryInterface returned %08lx\n", hr);
     if (FAILED(hr))
     {
         IDirectDraw7_Release(DDraw7);
@@ -272,31 +272,31 @@ static void test_iface_refcnt(void)
 
     /* Can't get older d3d interfaces. WHY????? */
     hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirect3D3, (void **) &D3D3);
-    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw7_QueryInterface returned %08x\n", hr);
+    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw7_QueryInterface returned %08lx\n", hr);
     if(hr == DD_OK && D3D3) IDirect3D3_Release(D3D3);
 
     hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D3, (void **) &D3D3);
-    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw4_QueryInterface returned %08x\n", hr);
+    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw4_QueryInterface returned %08lx\n", hr);
     if(hr == DD_OK && D3D3) IDirect3D3_Release(D3D3);
 
     hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirect3D2, (void **) &D3D2);
-    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw7_QueryInterface returned %08x\n", hr);
+    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw7_QueryInterface returned %08lx\n", hr);
     if(hr == DD_OK && D3D2) IDirect3D2_Release(D3D2);
 
     hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D2, (void **) &D3D2);
-    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw2_QueryInterface returned %08x\n", hr);
+    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw2_QueryInterface returned %08lx\n", hr);
     if(hr == DD_OK && D3D2) IDirect3D2_Release(D3D2);
 
     hr = IDirectDraw7_QueryInterface(DDraw7, &IID_IDirect3D, (void **) &D3D1);
-    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw7_QueryInterface returned %08x\n", hr);
+    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw7_QueryInterface returned %08lx\n", hr);
     if(hr == DD_OK && D3D1) IDirect3D_Release(D3D1);
 
     hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D, (void **) &D3D1);
-    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw_QueryInterface returned %08x\n", hr);
+    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw_QueryInterface returned %08lx\n", hr);
     if(hr == DD_OK && D3D1) IDirect3D_Release(D3D1);
 
     hr = IDirect3D7_QueryInterface(D3D7, &IID_IDirect3D, (void **) &D3D1);
-    todo_wine ok(hr == E_NOINTERFACE, "IDirect3D7_QueryInterface returned %08x\n", hr);
+    todo_wine ok(hr == E_NOINTERFACE, "IDirect3D7_QueryInterface returned %08lx\n", hr);
     if(hr == DD_OK && D3D1) IDirect3D_Release(D3D1);
 
     /* Try an AddRef, it only affects the AddRefed interface */
@@ -315,10 +315,10 @@ static void test_iface_refcnt(void)
 
     /* Make sure that they are one object, not different ones */
     hr = IDirectDraw4_SetCooperativeLevel(DDraw4, GetDesktopWindow(), DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "IDirectDraw4::SetCooperativeLevel returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw4::SetCooperativeLevel returned %08lx\n", hr);
     /* After an window has been set, DDSCL_SETFOCUSWINDOW should return DDERR_HWNDALREADYSET, see the mode test */
     hr = IDirectDraw7_SetCooperativeLevel(DDraw7, NULL, DDSCL_SETFOCUSWINDOW);
-    ok(hr == DDERR_HWNDALREADYSET, "IDirectDraw7::SetCooperativeLevel returned %08x\n", hr);
+    ok(hr == DDERR_HWNDALREADYSET, "IDirectDraw7::SetCooperativeLevel returned %08lx\n", hr);
 
     /* All done, release all interfaces */
     IDirectDraw7_Release(DDraw7);
@@ -341,17 +341,17 @@ static void test_d3d_ifaces(void)
     long ref;
 
     hr = DirectDrawCreate(NULL, &DDraw1, NULL);
-    ok(hr == DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", hr);
+    ok(hr == DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %lx\n", hr);
     if(!DDraw1)
     {
-        trace("DirectDrawCreate failed with %08x\n", hr);
+        trace("DirectDrawCreate failed with %08lx\n", hr);
         return;
     }
 
     hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirectDraw2, (void **) &DDraw2);
-    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", hr);
     hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirectDraw4, (void **) &DDraw4);
-    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", hr);
 
     ref = getRefcount( (IUnknown *) DDraw4);
     ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
@@ -372,7 +372,7 @@ static void test_d3d_ifaces(void)
         skip( "no IDirect3D support\n" );
         return;
     }
-    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", hr);
     ref = getRefcount( (IUnknown *) DDraw4);
     ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
     ref = getRefcount( (IUnknown *) DDraw2);
@@ -382,7 +382,7 @@ static void test_d3d_ifaces(void)
     IDirect3D_Release(D3D1);
 
     hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D2, (void **) &D3D2);
-    ok(hr == DD_OK, "IDirectDraw2_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw2_QueryInterface returned %08lx\n", hr);
     ref = getRefcount( (IUnknown *) DDraw4);
     ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
     ref = getRefcount( (IUnknown *) DDraw2);
@@ -392,7 +392,7 @@ static void test_d3d_ifaces(void)
     IDirect3D2_Release(D3D2);
 
     hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D3, (void **) &D3D3);
-    ok(hr == DD_OK, "IDirectDraw4_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw4_QueryInterface returned %08lx\n", hr);
     ref = getRefcount( (IUnknown *) DDraw4);
     ok(ref == 1, "IDirectDraw4 reference count is %ld\n", ref);
     ref = getRefcount( (IUnknown *) DDraw2);
@@ -422,35 +422,35 @@ static void test_d3d_ifaces(void)
      * Except IDirect3D7, it can only be returned by IDirectDraw7(which can't return older ifaces)
      */
     hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D, (void **) &D3D1);
-    ok(hr == DD_OK, "IDirectDraw2_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw2_QueryInterface returned %08lx\n", hr);
     IDirect3D_Release(D3D1);
     hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D, (void **) &D3D1);
-    ok(hr == DD_OK, "IDirectDraw4_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw4_QueryInterface returned %08lx\n", hr);
     IDirect3D_Release(D3D1);
 
     hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D2, (void **) &D3D2);
-    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", hr);
     IDirect3D_Release(D3D2);
     hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D2, (void **) &D3D2);
-    ok(hr == DD_OK, "IDirectDraw4_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw4_QueryInterface returned %08lx\n", hr);
     IDirect3D_Release(D3D2);
 
     hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D3, (void **) &D3D3);
-    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw_QueryInterface returned %08lx\n", hr);
     IDirect3D_Release(D3D3);
     hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D3, (void **) &D3D3);
-    ok(hr == DD_OK, "IDirectDraw2_QueryInterface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw2_QueryInterface returned %08lx\n", hr);
     IDirect3D_Release(D3D3);
 
     /* This does NOT work */
     hr = IDirectDraw_QueryInterface(DDraw1, &IID_IDirect3D7, (void **) &D3D7);
-    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw_QueryInterface returned %08x\n", hr);
+    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw_QueryInterface returned %08lx\n", hr);
     if(D3D7) IDirect3D_Release(D3D7);
     hr = IDirectDraw2_QueryInterface(DDraw2, &IID_IDirect3D7, (void **) &D3D7);
-    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw2_QueryInterface returned %08x\n", hr);
+    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw2_QueryInterface returned %08lx\n", hr);
     if(D3D7) IDirect3D_Release(D3D7);
     hr = IDirectDraw4_QueryInterface(DDraw4, &IID_IDirect3D7, (void **) &D3D7);
-    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw4_QueryInterface returned %08x\n", hr);
+    todo_wine ok(hr == E_NOINTERFACE, "IDirectDraw4_QueryInterface returned %08lx\n", hr);
     if(D3D7) IDirect3D_Release(D3D7);
 
     /* Release the interfaces */
diff --git a/dlls/ddraw/tests/visual.c b/dlls/ddraw/tests/visual.c
index 4d6b198e3238..9572cd453597 100644
--- a/dlls/ddraw/tests/visual.c
+++ b/dlls/ddraw/tests/visual.c
@@ -97,7 +97,7 @@ static BOOL createObjects(void)
     if(!pDirectDrawCreateEx) return FALSE;
 
     hr = pDirectDrawCreateEx(NULL, (void **) &DirectDraw, &IID_IDirectDraw7, NULL);
-    ok(hr==DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %x\n", hr);
+    ok(hr==DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreateEx returned: %lx\n", hr);
     if(!DirectDraw) goto err;
 
     wc.lpfnWndProc = DefWindowProcA;
@@ -107,7 +107,7 @@ static BOOL createObjects(void)
             0, 0, 640, 480, 0, 0, 0, 0);
 
     hr = IDirectDraw7_SetCooperativeLevel(DirectDraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr == DD_OK, "IDirectDraw7_SetCooperativeLevel failed with %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw7_SetCooperativeLevel failed with %08lx\n", hr);
     if(FAILED(hr)) goto err;
     hr = IDirectDraw7_SetDisplayMode(DirectDraw, 640, 480, 32, 0, 0);
     if(FAILED(hr)) {
@@ -115,7 +115,7 @@ static BOOL createObjects(void)
         hr = IDirectDraw7_SetDisplayMode(DirectDraw, 640, 480, 24, 0, 0);
 
     }
-    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "IDirectDraw7_SetDisplayMode failed with %08x\n", hr);
+    ok(hr == DD_OK || hr == DDERR_UNSUPPORTED, "IDirectDraw7_SetDisplayMode failed with %08lx\n", hr);
     if(FAILED(hr)) {
         /* use trace, the caller calls skip() */
         trace("SetDisplayMode failed\n");
@@ -124,7 +124,7 @@ static BOOL createObjects(void)
 
     hr = IDirectDraw7_QueryInterface(DirectDraw, &IID_IDirect3D7, (void**) &Direct3D);
     if (hr == E_NOINTERFACE) goto err;
-    ok(hr==DD_OK, "QueryInterface returned: %08x\n", hr);
+    ok(hr==DD_OK, "QueryInterface returned: %08lx\n", hr);
 
     /* DirectDraw Flipping behavior doesn't seem that well-defined. The reference rasterizer behaves differently
      * than hardware implementations. Request single buffering, that seems to work everywhere
@@ -138,7 +138,7 @@ static BOOL createObjects(void)
     if(FAILED(hr)) goto err;
 
     hr = IDirect3D7_EnumDevices(Direct3D, enum_devtype_cb, &hal_ok);
-    ok(SUCCEEDED(hr), "Failed to enumerate devices, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to enumerate devices, hr %#lx.\n", hr);
     if (hal_ok) devtype = &IID_IDirect3DTnLHalDevice;
 
     memset(&zfmt, 0, sizeof(zfmt));
@@ -154,11 +154,11 @@ static BOOL createObjects(void)
     ddsd.dwWidth = 640;
     ddsd.dwHeight = 480;
     hr = IDirectDraw7_CreateSurface(DirectDraw, &ddsd, &depth_buffer, NULL);
-    ok(SUCCEEDED(hr), "CreateSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "CreateSurface failed, hr %#lx.\n", hr);
     if (FAILED(hr)) goto err;
 
     hr = IDirectDrawSurface_AddAttachedSurface(Surface, depth_buffer);
-    ok(SUCCEEDED(hr), "AddAttachedSurface failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "AddAttachedSurface failed, hr %#lx.\n", hr);
     if (FAILED(hr)) goto err;
 
     hr = IDirect3D7_CreateDevice(Direct3D, devtype, Surface, &Direct3DDevice);
@@ -204,7 +204,7 @@ static DWORD getPixelColor(IDirect3DDevice7 *device, UINT x, UINT y)
     ddsd.dwHeight = 480;
     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw7_CreateSurface(DirectDraw, &ddsd, &surf, NULL);
-    ok(hr == DD_OK, "IDirectDraw7_CreateSurface failed with %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw7_CreateSurface failed with %08lx\n", hr);
     if(!surf)
     {
         trace("cannot create helper surface\n");
@@ -216,7 +216,7 @@ static DWORD getPixelColor(IDirect3DDevice7 *device, UINT x, UINT y)
     U4(ddsd).ddpfPixelFormat.dwSize = sizeof(U4(ddsd).ddpfPixelFormat);
 
     hr = IDirectDrawSurface_BltFast(surf, 0, 0, Surface, NULL, 0);
-    ok(hr == DD_OK, "IDirectDrawSurface7_BltFast returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface7_BltFast returned %08lx\n", hr);
     if(FAILED(hr))
     {
         trace("Cannot blit\n");
@@ -227,7 +227,7 @@ static DWORD getPixelColor(IDirect3DDevice7 *device, UINT x, UINT y)
     hr = IDirectDrawSurface7_Lock(surf, &rectToLock, &ddsd, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
     if(FAILED(hr))
     {
-        trace("Can't lock the offscreen surface, hr=%08x\n", hr);
+        trace("Can't lock the offscreen surface, hr=%08lx\n", hr);
         ret = 0xdeadbeec;
         goto out;
     }
@@ -239,7 +239,7 @@ static DWORD getPixelColor(IDirect3DDevice7 *device, UINT x, UINT y)
     hr = IDirectDrawSurface7_Unlock(surf, NULL);
     if(FAILED(hr))
     {
-        trace("Can't unlock the offscreen surface, hr=%08x\n", hr);
+        trace("Can't unlock the offscreen surface, hr=%08lx\n", hr);
     }
 
 out:
@@ -255,18 +255,18 @@ static void set_viewport_size(IDirect3DDevice7 *device)
     IDirectDrawSurface7 *target;
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &target);
-    ok(hr == D3D_OK, "IDirect3DDevice7_GetRenderTarget returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_GetRenderTarget returned %08lx\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
     hr = IDirectDrawSurface7_GetSurfaceDesc(target, &ddsd);
-    ok(hr == D3D_OK, "IDirectDrawSurface7_GetSurfaceDesc returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirectDrawSurface7_GetSurfaceDesc returned %08lx\n", hr);
     IDirectDrawSurface7_Release(target);
 
     vp.dwWidth = ddsd.dwWidth;
     vp.dwHeight = ddsd.dwHeight;
     hr = IDirect3DDevice7_SetViewport(device, &vp);
-    ok(hr == D3D_OK, "IDirect3DDevice7_SetViewport returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_SetViewport returned %08lx\n", hr);
     return;
 }
 
@@ -368,66 +368,66 @@ static void fog_test(IDirect3DDevice7 *device)
 
     memset(&caps, 0, sizeof(caps));
     hr = IDirect3DDevice7_GetCaps(device, &caps);
-    ok(hr == D3D_OK, "IDirect3DDevice7_GetCaps returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_GetCaps returned %08lx\n", hr);
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice7_Clear returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_Clear returned %08lx\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(SUCCEEDED(hr), "Failed to disable z test, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable z test, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
-    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to disable culling, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "Turning off lighting returned %08x\n", hr);
+    ok(hr == D3D_OK, "Turning off lighting returned %08lx\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, TRUE);
-    ok(hr == D3D_OK, "Turning on fog calculations returned %08x\n", hr);
+    ok(hr == D3D_OK, "Turning on fog calculations returned %08lx\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGCOLOR, 0xFF00FF00 /* A nice green */);
-    ok(hr == D3D_OK, "Setting fog color returned %08x\n", hr);
+    ok(hr == D3D_OK, "Setting fog color returned %08lx\n", hr);
 
     /* First test: Both table fog and vertex fog off */
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_NONE);
-    ok(hr == D3D_OK, "Turning off table fog returned %08x\n", hr);
+    ok(hr == D3D_OK, "Turning off table fog returned %08lx\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGVERTEXMODE, D3DFOG_NONE);
-    ok(hr == D3D_OK, "Turning off vertex fog returned %08x\n", hr);
+    ok(hr == D3D_OK, "Turning off vertex fog returned %08lx\n", hr);
 
     /* Start = 0, end = 1. Should be default, but set them */
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGSTART, *((DWORD *) &start));
-    ok(hr == D3D_OK, "Setting fog start returned %08x\n", hr);
+    ok(hr == D3D_OK, "Setting fog start returned %08lx\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGEND, *((DWORD *) &end));
-    ok(hr == D3D_OK, "Setting fog end returned %08x\n", hr);
+    ok(hr == D3D_OK, "Setting fog end returned %08lx\n", hr);
 
     if(IDirect3DDevice7_BeginScene(device) == D3D_OK)
     {
         /* Untransformed, vertex fog = NONE, table fog = NONE: Read the fog weighting from the specular color */
         hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
                                                    untransformed_1, 4, Indices, 6, 0);
-        ok(hr == D3D_OK, "DrawIndexedPrimitive returned %08x\n", hr);
+        ok(hr == D3D_OK, "DrawIndexedPrimitive returned %08lx\n", hr);
 
         /* That makes it use the Z value */
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGVERTEXMODE, D3DFOG_LINEAR);
-        ok(hr == D3D_OK, "Setting fog vertex mode to D3DFOG_LINEAR returned %08x\n", hr);
+        ok(hr == D3D_OK, "Setting fog vertex mode to D3DFOG_LINEAR returned %08lx\n", hr);
         /* Untransformed, vertex fog != none (or table fog != none):
          * Use the Z value as input into the equation
          */
         hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
                                                    untransformed_2, 4, Indices, 6, 0);
-        ok(hr == D3D_OK, "DrawIndexedPrimitive returned %08x\n", hr);
+        ok(hr == D3D_OK, "DrawIndexedPrimitive returned %08lx\n", hr);
 
         /* Transformed, vertex fog != NONE, pixel fog == NONE: Use specular color alpha component */
         hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
                                                    transformed_1, 4, Indices, 6, 0);
-        ok(hr == D3D_OK, "DrawIndexedPrimitive returned %08x\n", hr);
+        ok(hr == D3D_OK, "DrawIndexedPrimitive returned %08lx\n", hr);
 
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_LINEAR);
-        ok( hr == D3D_OK, "Setting fog table mode to D3DFOG_LINEAR returned %08x\n", hr);
+        ok( hr == D3D_OK, "Setting fog table mode to D3DFOG_LINEAR returned %08lx\n", hr);
         /* Transformed, table fog != none, vertex anything: Use Z value as input to the fog
          * equation
          */
         hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
                                                    transformed_2, 4, Indices, 6, 0);
-        ok(hr == D3D_OK, "DrawIndexedPrimitive returned %08x\n", hr);
+        ok(hr == D3D_OK, "DrawIndexedPrimitive returned %08lx\n", hr);
 
         hr = IDirect3DDevice7_EndScene(device);
-        ok(hr == D3D_OK, "EndScene returned %08x\n", hr);
+        ok(hr == D3D_OK, "EndScene returned %08lx\n", hr);
     }
     else
     {
@@ -435,15 +435,15 @@ static void fog_test(IDirect3DDevice7 *device)
     }
 
     color = getPixelColor(device, 160, 360);
-    ok(color_match(color, 0x00FF0000, 1), "Untransformed vertex with no table or vertex fog has color %08x\n", color);
+    ok(color_match(color, 0x00FF0000, 1), "Untransformed vertex with no table or vertex fog has color %08lx\n", color);
     color = getPixelColor(device, 160, 120);
-    ok(color_match(color, 0x0000FF00, 1), "Untransformed vertex with linear vertex fog has color %08x\n", color);
+    ok(color_match(color, 0x0000FF00, 1), "Untransformed vertex with linear vertex fog has color %08lx\n", color);
     color = getPixelColor(device, 480, 120);
-    ok(color_match(color, 0x00FFFF00, 1), "Transformed vertex with linear vertex fog has color %08x\n", color);
+    ok(color_match(color, 0x00FFFF00, 1), "Transformed vertex with linear vertex fog has color %08lx\n", color);
     if(caps.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_FOGTABLE)
     {
         color = getPixelColor(device, 480, 360);
-        ok(color_match(color, 0x0000FF00, 1), "Transformed vertex with linear table fog has color %08x\n", color);
+        ok(color_match(color, 0x0000FF00, 1), "Transformed vertex with linear table fog has color %08lx\n", color);
     }
     else
     {
@@ -451,7 +451,7 @@ static void fog_test(IDirect3DDevice7 *device)
          * The settings above result in no fogging with vertex fog
          */
         color = getPixelColor(device, 480, 120);
-        ok(color == 0x00FFFF00, "Transformed vertex with linear vertex fog has color %08x\n", color);
+        ok(color == 0x00FFFF00, "Transformed vertex with linear vertex fog has color %08lx\n", color);
         trace("Info: Table fog not supported by this device\n");
     }
 
@@ -459,28 +459,28 @@ static void fog_test(IDirect3DDevice7 *device)
     {
         /* A simple fog + non-identity world matrix test */
         hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &world_mat1);
-        ok(hr == D3D_OK, "IDirect3DDevice7_SetTransform returned %#08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_SetTransform returned %#08lx\n", hr);
 
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_LINEAR);
-        ok(hr == D3D_OK, "Setting fog table mode to D3DFOG_LINEAR returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Setting fog table mode to D3DFOG_LINEAR returned %#08lx\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGVERTEXMODE, D3DFOG_NONE);
-        ok(hr == D3D_OK, "Turning off vertex fog returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Turning off vertex fog returned %#08lx\n", hr);
 
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 0.0, 0);
-        ok(hr == D3D_OK, "IDirect3DDevice7_Clear returned %#08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_Clear returned %#08lx\n", hr);
 
         if (IDirect3DDevice7_BeginScene(device) == D3D_OK)
         {
             hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST,
                     D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, far_quad1, 4, Indices, 6, 0);
-            ok(hr == D3D_OK, "DrawIndexedPrimitive returned %#08x\n", hr);
+            ok(hr == D3D_OK, "DrawIndexedPrimitive returned %#08lx\n", hr);
 
             hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST,
                     D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, far_quad2, 4, Indices, 6, 0);
-            ok(hr == D3D_OK, "DrawIndexedPrimitive returned %#08x\n", hr);
+            ok(hr == D3D_OK, "DrawIndexedPrimitive returned %#08lx\n", hr);
 
             hr = IDirect3DDevice7_EndScene(device);
-            ok(hr == D3D_OK, "EndScene returned %#08x\n", hr);
+            ok(hr == D3D_OK, "EndScene returned %#08lx\n", hr);
         }
         else
         {
@@ -488,31 +488,31 @@ static void fog_test(IDirect3DDevice7 *device)
         }
 
         color = getPixelColor(device, 160, 360);
-        ok(color_match(color, 0x00ff0000, 4), "Unfogged quad has color %08x\n", color);
+        ok(color_match(color, 0x00ff0000, 4), "Unfogged quad has color %08lx\n", color);
         color = getPixelColor(device, 160, 120);
-        ok(color_match(color, 0x0000ff00, 1), "Fogged out quad has color %08x\n", color);
+        ok(color_match(color, 0x0000ff00, 1), "Fogged out quad has color %08lx\n", color);
 
         /* Test fog behavior with an orthogonal (but not identity) projection matrix */
         hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &world_mat2);
-        ok(hr == D3D_OK, "SetTransform returned %#08x\n", hr);
+        ok(hr == D3D_OK, "SetTransform returned %#08lx\n", hr);
         hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &proj_mat);
-        ok(hr == D3D_OK, "SetTransform returned %#08x\n", hr);
+        ok(hr == D3D_OK, "SetTransform returned %#08lx\n", hr);
 
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 0.0, 0);
-        ok(hr == D3D_OK, "Clear returned %#08x\n", hr);
+        ok(hr == D3D_OK, "Clear returned %#08lx\n", hr);
 
         if (IDirect3DDevice7_BeginScene(device) == D3D_OK)
         {
             hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST,
                     D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, untransformed_1, 4, Indices, 6, 0);
-            ok(hr == D3D_OK, "DrawIndexedPrimitiveUP returned %#08x\n", hr);
+            ok(hr == D3D_OK, "DrawIndexedPrimitiveUP returned %#08lx\n", hr);
 
             hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST,
                     D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_SPECULAR, untransformed_2, 4, Indices, 6, 0);
-            ok(hr == D3D_OK, "DrawIndexedPrimitiveUP returned %#08x\n", hr);
+            ok(hr == D3D_OK, "DrawIndexedPrimitiveUP returned %#08lx\n", hr);
 
             hr = IDirect3DDevice7_EndScene(device);
-            ok(hr == D3D_OK, "EndScene returned %#08x\n", hr);
+            ok(hr == D3D_OK, "EndScene returned %#08lx\n", hr);
         }
         else
         {
@@ -520,14 +520,14 @@ static void fog_test(IDirect3DDevice7 *device)
         }
 
         color = getPixelColor(device, 160, 360);
-        ok(color_match(color, 0x00e51900, 4), "Partially fogged quad has color %08x\n", color);
+        ok(color_match(color, 0x00e51900, 4), "Partially fogged quad has color %08lx\n", color);
         color = getPixelColor(device, 160, 120);
-        ok(color_match(color, 0x0000ff00, 1), "Fogged out quad has color %08x\n", color);
+        ok(color_match(color, 0x0000ff00, 1), "Fogged out quad has color %08lx\n", color);
 
         hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, &ident_mat);
-        ok(hr == D3D_OK, "SetTransform returned %#08x\n", hr);
+        ok(hr == D3D_OK, "SetTransform returned %#08lx\n", hr);
         hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, &ident_mat);
-        ok(hr == D3D_OK, "SetTransform returned %#08x\n", hr);
+        ok(hr == D3D_OK, "SetTransform returned %#08lx\n", hr);
     }
     else
     {
@@ -536,7 +536,7 @@ static void fog_test(IDirect3DDevice7 *device)
 
     /* Turn off the fog master switch to avoid confusing other tests */
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(hr == D3D_OK, "Turning off fog calculations returned %08x\n", hr);
+    ok(hr == D3D_OK, "Turning off fog calculations returned %08lx\n", hr);
 }
 
 static void offscreen_test(IDirect3DDevice7 *device)
@@ -554,7 +554,7 @@ static void offscreen_test(IDirect3DDevice7 *device)
     };
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0);
-    ok(hr == D3D_OK, "Clear failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Clear failed, hr = %08lx\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -564,27 +564,27 @@ static void offscreen_test(IDirect3DDevice7 *device)
     ddsd.dwHeight = 128;
     ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_3DDEVICE;
     hr = IDirectDraw7_CreateSurface(DirectDraw, &ddsd, &offscreen, NULL);
-    ok(hr == D3D_OK, "Creating the offscreen render target failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Creating the offscreen render target failed, hr = %08lx\n", hr);
     if(!offscreen) {
         goto out;
     }
 
     hr = IDirect3DDevice7_GetRenderTarget(device, &backbuffer);
-    ok(hr == D3D_OK, "Can't get back buffer, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Can't get back buffer, hr = %08lx\n", hr);
     if(!backbuffer) {
         goto out;
     }
 
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08lx\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08lx\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_MINFILTER, D3DFILTER_NEAREST);
-    ok(SUCCEEDED(hr), "SetTextureStageState D3DSAMP_MINFILTER failed (0x%08x)\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState D3DSAMP_MINFILTER failed (0x%08lx)\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_MAGFILTER, D3DFILTER_NEAREST);
-    ok(SUCCEEDED(hr), "SetTextureStageState D3DSAMP_MAGFILTER failed (0x%08x)\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState D3DSAMP_MAGFILTER failed (0x%08lx)\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned hr = %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned hr = %08lx\n", hr);
 
     if (refdevice) {
         win_skip("Tests would crash on W2K with a refdevice\n");
@@ -593,55 +593,55 @@ static void offscreen_test(IDirect3DDevice7 *device)
 
     if(IDirect3DDevice7_BeginScene(device) == D3D_OK) {
         hr = IDirect3DDevice7_SetRenderTarget(device, offscreen, 0);
-        ok(hr == D3D_OK, "SetRenderTarget failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "SetRenderTarget failed, hr = %08lx\n", hr);
         set_viewport_size(device);
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff00ff, 0.0, 0);
-        ok(hr == D3D_OK, "Clear failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "Clear failed, hr = %08lx\n", hr);
 
         /* Draw without textures - Should result in a white quad */
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_TEX1, quad, 4, 0);
-        ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08lx\n", hr);
 
         hr = IDirect3DDevice7_SetRenderTarget(device, backbuffer, 0);
-        ok(hr == D3D_OK, "SetRenderTarget failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "SetRenderTarget failed, hr = %08lx\n", hr);
         set_viewport_size(device);
 
         hr = IDirect3DDevice7_SetTexture(device, 0, offscreen);
-        ok(hr == D3D_OK, "SetTexture failed, %08x\n", hr);
+        ok(hr == D3D_OK, "SetTexture failed, %08lx\n", hr);
 
         /* This time with the texture */
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_TEX1, quad, 4, 0);
-        ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08lx\n", hr);
 
         IDirect3DDevice7_EndScene(device);
     }
 
     /* Center quad - should be white */
     color = getPixelColor(device, 320, 240);
-    ok(color == 0x00ffffff, "Offscreen failed: Got color 0x%08x, expected 0x00ffffff.\n", color);
+    ok(color == 0x00ffffff, "Offscreen failed: Got color 0x%08lx, expected 0x00ffffff.\n", color);
     /* Some quad in the cleared part of the texture */
     color = getPixelColor(device, 170, 240);
-    ok(color == 0x00ff00ff, "Offscreen failed: Got color 0x%08x, expected 0x00ff00ff.\n", color);
+    ok(color == 0x00ff00ff, "Offscreen failed: Got color 0x%08lx, expected 0x00ff00ff.\n", color);
     /* Part of the originally cleared back buffer */
     color = getPixelColor(device, 10, 10);
-    ok(color == 0x00ff0000, "Offscreen failed: Got color 0x%08x, expected 0x00ff0000.\n", color);
+    ok(color == 0x00ff0000, "Offscreen failed: Got color 0x%08lx, expected 0x00ff0000.\n", color);
     if(0) {
         /* Lower left corner of the screen, where back buffer offscreen rendering draws the offscreen texture.
          * It should be red, but the offscreen texture may leave some junk there. Not tested yet. Depending on
          * the offscreen rendering mode this test would succeed or fail
          */
         color = getPixelColor(device, 10, 470);
-        ok(color == 0x00ff0000, "Offscreen failed: Got color 0x%08x, expected 0x00ff0000.\n", color);
+        ok(color == 0x00ff0000, "Offscreen failed: Got color 0x%08lx, expected 0x00ff0000.\n", color);
     }
 
 out:
     hr = IDirect3DDevice7_SetTexture(device, 0, NULL);
-    ok(SUCCEEDED(hr), "IDirect3DDevice7_SetTexture returned %#x.\n", hr);
+    ok(SUCCEEDED(hr), "IDirect3DDevice7_SetTexture returned %#lx.\n", hr);
 
     /* restore things */
     if(backbuffer) {
         hr = IDirect3DDevice7_SetRenderTarget(device, backbuffer, 0);
-        ok(SUCCEEDED(hr), "IDirect3DDevice7_SetRenderTarget returned %#x.\n", hr);
+        ok(SUCCEEDED(hr), "IDirect3DDevice7_SetRenderTarget returned %#lx.\n", hr);
         IDirectDrawSurface7_Release(backbuffer);
     }
     if(offscreen) {
@@ -684,7 +684,7 @@ static void test_blend(IDirect3DDevice7 *device)
 
     /* Clear the render target with alpha = 0.5 */
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x80ff0000, 0.0, 0);
-    ok(hr == D3D_OK, "Clear failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Clear failed, hr = %08lx\n", hr);
 
     memset(&ddsd, 0, sizeof(ddsd));
     ddsd.dwSize = sizeof(ddsd);
@@ -699,27 +699,27 @@ static void test_blend(IDirect3DDevice7 *device)
     U4(U4(ddsd).ddpfPixelFormat).dwBBitMask         = 0x000000ff;
     U5(U4(ddsd).ddpfPixelFormat).dwRGBAlphaBitMask  = 0xff000000;
     hr = IDirectDraw7_CreateSurface(DirectDraw, &ddsd, &offscreen, NULL);
-    ok(hr == D3D_OK, "Creating the offscreen render target failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Creating the offscreen render target failed, hr = %08lx\n", hr);
     if(!offscreen) {
         goto out;
     }
     hr = IDirect3DDevice7_GetRenderTarget(device, &backbuffer);
-    ok(hr == D3D_OK, "Can't get back buffer, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Can't get back buffer, hr = %08lx\n", hr);
     if(!backbuffer) {
         goto out;
     }
 
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08lx\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "SetTextureStageState failed, hr = %08lx\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_MINFILTER, D3DFILTER_NEAREST);
-    ok(SUCCEEDED(hr), "SetTextureStageState D3DSAMP_MINFILTER failed (0x%08x)\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState D3DSAMP_MINFILTER failed (0x%08lx)\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_MAGFILTER, D3DFILTER_NEAREST);
-    ok(SUCCEEDED(hr), "SetTextureStageState D3DSAMP_MAGFILTER failed (0x%08x)\n", hr);
+    ok(SUCCEEDED(hr), "SetTextureStageState D3DSAMP_MAGFILTER failed (0x%08lx)\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
-    ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08lx\n", hr);
 
     if (refdevice) {
         win_skip("Tests would crash on W2K with a refdevice\n");
@@ -736,18 +736,18 @@ static void test_blend(IDirect3DDevice7 *device)
          * They give essentially ZERO and ONE blend factors
          */
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
-        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08lx\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
-        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08lx\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE, quad1, 4, 0);
-        ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08lx\n", hr);
 
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_DESTALPHA);
-        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08lx\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVDESTALPHA);
-        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08lx\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE, quad2, 4, 0);
-        ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08lx\n", hr);
 
         /* Switch to the offscreen buffer, and redo the testing. SRCALPHA and DESTALPHA. The offscreen buffer
          * has an alpha channel on its own. Clear the offscreen buffer with alpha = 0.5 again, then draw the
@@ -756,44 +756,44 @@ static void test_blend(IDirect3DDevice7 *device)
          * vertices
          */
         hr = IDirect3DDevice7_SetRenderTarget(device, offscreen, 0);
-        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderTarget failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderTarget failed, hr = %08lx\n", hr);
         set_viewport_size(device);
         hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x80ff0000, 0.0, 0);
-        ok(hr == D3D_OK, "Clear failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "Clear failed, hr = %08lx\n", hr);
 
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
-        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08lx\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
-        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08lx\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE, quad1, 4, 0);
-        ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08lx\n", hr);
 
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_SRCBLEND, D3DBLEND_DESTALPHA);
-        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08lx\n", hr);
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVDESTALPHA);
-        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08lx\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE, quad2, 4, 0);
-        ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08lx\n", hr);
 
         hr = IDirect3DDevice7_SetRenderTarget(device, backbuffer, 0);
-        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderTarget failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderTarget failed, hr = %08lx\n", hr);
         set_viewport_size(device);
 
         /* Render the offscreen texture onto the frame buffer to be able to compare it regularly.
          * Disable alpha blending for the final composition
          */
         hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
-        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr = %08lx\n", hr);
 
         hr = IDirect3DDevice7_SetTexture(device, 0, offscreen);
-        ok(hr == D3D_OK, "IDirect3DDevice7_SetTexture failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_SetTexture failed, hr = %08lx\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_TEX1, composite_quad, 4, 0);
-        ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08lx\n", hr);
         hr = IDirect3DDevice7_SetTexture(device, 0, NULL);
-        ok(hr == D3D_OK, "IDirect3DDevice7_SetTexture failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_SetTexture failed, hr = %08lx\n", hr);
 
         hr = IDirect3DDevice7_EndScene(device);
-        ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed, hr = %08lx\n", hr);
     }
 
     color = getPixelColor(device, 160, 360);
@@ -801,28 +801,28 @@ static void test_blend(IDirect3DDevice7 *device)
     green = (color & 0x0000ff00) >>  8;
     blue =  (color & 0x000000ff);
     ok(red >= 0xbe && red <= 0xc0 && green >= 0x39 && green <= 0x41 && blue == 0x00,
-       "SRCALPHA on frame buffer returned color 0x%08x, expected 0x00bf4000\n", color);
+       "SRCALPHA on frame buffer returned color 0x%08lx, expected 0x00bf4000\n", color);
 
     color = getPixelColor(device, 160, 120);
     red =   (color & 0x00ff0000) >> 16;
     green = (color & 0x0000ff00) >>  8;
     blue =  (color & 0x000000ff);
     ok(red == 0x00 && green == 0x00 && blue >= 0xfe && blue <= 0xff ,
-       "DSTALPHA on frame buffer returned color 0x%08x, expected 0x000000ff\n", color);
+       "DSTALPHA on frame buffer returned color 0x%08lx, expected 0x000000ff\n", color);
 
     color = getPixelColor(device, 480, 360);
     red =   (color & 0x00ff0000) >> 16;
     green = (color & 0x0000ff00) >>  8;
     blue =  (color & 0x000000ff);
     ok(red >= 0xbe && red <= 0xc0 && green >= 0x39 && green <= 0x41 && blue == 0x00,
-       "SRCALPHA on texture returned color 0x%08x, expected 0x00bf4000\n", color);
+       "SRCALPHA on texture returned color 0x%08lx, expected 0x00bf4000\n", color);
 
     color = getPixelColor(device, 480, 120);
     red =   (color & 0x00ff0000) >> 16;
     green = (color & 0x0000ff00) >>  8;
     blue =  (color & 0x000000ff);
     ok(red >= 0x7e && red <= 0x81 && green == 0x00 && blue >= 0x7e && blue <= 0x81,
-       "DSTALPHA on texture returned color 0x%08x, expected 0x00800080\n", color);
+       "DSTALPHA on texture returned color 0x%08lx, expected 0x00800080\n", color);
 
     out:
     if(offscreen) IDirectDrawSurface7_Release(offscreen);
@@ -849,26 +849,26 @@ static void rhw_zero_test(IDirect3DDevice7 *device)
 
     /* Clear to black */
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0, 0.0, 0);
-    ok(hr == D3D_OK, "Clear failed, hr = %08x\n", hr);
+    ok(hr == D3D_OK, "Clear failed, hr = %08lx\n", hr);
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(hr == D3D_OK, "IDirect3DDevice7_BeginScene failed with %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_BeginScene failed with %08lx\n", hr);
 
     if (SUCCEEDED(hr)) {
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_DIFFUSE, quad1, 4, 0);
-        ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "DrawPrimitive failed, hr = %08lx\n", hr);
 
         hr = IDirect3DDevice7_EndScene(device);
-        ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed, hr = %08lx\n", hr);
     }
 
     color = getPixelColor(device, 5, 5);
     ok(color == 0xffffff ||
        broken(color == 0), /* VMware */
-       "Got color %08x, expected 00ffffff\n", color);
+       "Got color %08lx, expected 00ffffff\n", color);
 
     color = getPixelColor(device, 105, 105);
-    ok(color == 0, "Got color %08x, expected 00000000\n", color);
+    ok(color == 0, "Got color %08lx, expected 00000000\n", color);
 }
 
 static DWORD D3D3_getPixelColor(IDirectDraw4 *DirectDraw, IDirectDrawSurface4 *Surface, UINT x, UINT y)
@@ -890,7 +890,7 @@ static DWORD D3D3_getPixelColor(IDirectDraw4 *DirectDraw, IDirectDrawSurface4 *S
     ddsd.dwHeight = 480;
     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
     hr = IDirectDraw4_CreateSurface(DirectDraw, &ddsd, &surf, NULL);
-    ok(hr == DD_OK, "IDirectDraw4_CreateSurface failed with %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw4_CreateSurface failed with %08lx\n", hr);
     if(!surf)
     {
         trace("cannot create helper surface\n");
@@ -902,7 +902,7 @@ static DWORD D3D3_getPixelColor(IDirectDraw4 *DirectDraw, IDirectDrawSurface4 *S
     U4(ddsd).ddpfPixelFormat.dwSize = sizeof(U4(ddsd).ddpfPixelFormat);
 
     hr = IDirectDrawSurface4_BltFast(surf, 0, 0, Surface, NULL, 0);
-    ok(hr == DD_OK, "IDirectDrawSurface_BltFast returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface_BltFast returned %08lx\n", hr);
     if(FAILED(hr))
     {
         trace("Cannot blit\n");
@@ -913,7 +913,7 @@ static DWORD D3D3_getPixelColor(IDirectDraw4 *DirectDraw, IDirectDrawSurface4 *S
     hr = IDirectDrawSurface4_Lock(surf, &rectToLock, &ddsd, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
     if(FAILED(hr))
     {
-        trace("Can't lock the offscreen surface, hr=%08x\n", hr);
+        trace("Can't lock the offscreen surface, hr=%08lx\n", hr);
         ret = 0xdeadbeec;
         goto out;
     }
@@ -925,7 +925,7 @@ static DWORD D3D3_getPixelColor(IDirectDraw4 *DirectDraw, IDirectDrawSurface4 *S
     hr = IDirectDrawSurface4_Unlock(surf, NULL);
     if(FAILED(hr))
     {
-        trace("Can't unlock the offscreen surface, hr=%08x\n", hr);
+        trace("Can't unlock the offscreen surface, hr=%08lx\n", hr);
     }
 
 out:
@@ -978,11 +978,11 @@ static void D3D3_ViewportClearTest(void)
             WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, 640, 480, 0, 0, 0, 0);
 
     hr = DirectDrawCreate( NULL, &DirectDraw1, NULL );
-    ok(hr==DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreate returned: %x\n", hr);
+    ok(hr==DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreate returned: %lx\n", hr);
     if(FAILED(hr)) goto out;
 
     hr = IDirectDraw_SetCooperativeLevel(DirectDraw1, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr==DD_OK, "SetCooperativeLevel returned: %x\n", hr);
+    ok(hr==DD_OK, "SetCooperativeLevel returned: %lx\n", hr);
     if(FAILED(hr)) goto out;
 
     hr = IDirectDraw_SetDisplayMode(DirectDraw1, 640, 480, 32);
@@ -990,11 +990,11 @@ static void D3D3_ViewportClearTest(void)
         /* 24 bit is fine too */
         hr = IDirectDraw_SetDisplayMode(DirectDraw1, 640, 480, 24);
     }
-    ok(hr==DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode returned: %x\n", hr);
+    ok(hr==DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode returned: %lx\n", hr);
     if (FAILED(hr)) goto out;
 
     hr = IDirectDraw_QueryInterface(DirectDraw1, &IID_IDirectDraw4, (void**)&DirectDraw4);
-    ok(hr==DD_OK, "QueryInterface returned: %08x\n", hr);
+    ok(hr==DD_OK, "QueryInterface returned: %08lx\n", hr);
     if(FAILED(hr)) goto out;
 
     memset(&ddsd, 0, sizeof(DDSURFACEDESC2));
@@ -1003,11 +1003,11 @@ static void D3D3_ViewportClearTest(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE;
 
     hr = IDirectDraw4_CreateSurface(DirectDraw4, &ddsd, &Primary, NULL);
-    ok(hr==DD_OK, "IDirectDraw4_CreateSurface returned: %08x\n", hr);
+    ok(hr==DD_OK, "IDirectDraw4_CreateSurface returned: %08lx\n", hr);
     if(FAILED(hr)) goto out;
 
     hr = IDirectDraw4_QueryInterface(DirectDraw4, &IID_IDirect3D3, (void**)&Direct3D3);
-    ok(hr==DD_OK, "IDirectDraw4_QueryInterface returned: %08x\n", hr);
+    ok(hr==DD_OK, "IDirectDraw4_QueryInterface returned: %08lx\n", hr);
     if(FAILED(hr)) goto out;
 
     hr = IDirect3D3_CreateDevice(Direct3D3, &IID_IDirect3DHALDevice, Primary, &Direct3DDevice3, NULL);
@@ -1015,15 +1015,15 @@ static void D3D3_ViewportClearTest(void)
         trace("Creating a HAL device failed, trying Ref\n");
         hr = IDirect3D3_CreateDevice(Direct3D3, &IID_IDirect3DRefDevice, Primary, &Direct3DDevice3, NULL);
     }
-    ok(hr==D3D_OK, "Creating 3D device returned: %x\n", hr);
+    ok(hr==D3D_OK, "Creating 3D device returned: %lx\n", hr);
     if(FAILED(hr)) goto out;
 
     hr = IDirect3D3_CreateViewport(Direct3D3, &Viewport3, NULL);
-    ok(hr==DD_OK, "IDirect3D3_CreateViewport returned: %08x\n", hr);
+    ok(hr==DD_OK, "IDirect3D3_CreateViewport returned: %08lx\n", hr);
     if(FAILED(hr)) goto out;
 
     hr = IDirect3DDevice3_AddViewport(Direct3DDevice3, Viewport3);
-    ok(hr==DD_OK, "IDirect3DDevice3_AddViewport returned: %08x\n", hr);
+    ok(hr==DD_OK, "IDirect3DDevice3_AddViewport returned: %08lx\n", hr);
 
     memset(&vp_data, 0, sizeof(D3DVIEWPORT2));
     vp_data.dwSize = sizeof(D3DVIEWPORT2);
@@ -1035,14 +1035,14 @@ static void D3D3_ViewportClearTest(void)
     vp_data.dvClipHeight = 2.0f;
     vp_data.dvMaxZ = 1.0f;
     hr = IDirect3DViewport3_SetViewport2(Viewport3, &vp_data);
-    ok(hr==DD_OK, "IDirect3DViewport3_SetViewport2 returned: %08x\n", hr);
+    ok(hr==DD_OK, "IDirect3DViewport3_SetViewport2 returned: %08lx\n", hr);
 
     hr = IDirect3D3_CreateViewport(Direct3D3, &SmallViewport3, NULL);
-    ok(hr==DD_OK, "IDirect3D3_CreateViewport returned: %08x\n", hr);
+    ok(hr==DD_OK, "IDirect3D3_CreateViewport returned: %08lx\n", hr);
     if(FAILED(hr)) goto out;
 
     hr = IDirect3DDevice3_AddViewport(Direct3DDevice3, SmallViewport3);
-    ok(hr==DD_OK, "IDirect3DDevice3_AddViewport returned: %08x\n", hr);
+    ok(hr==DD_OK, "IDirect3DDevice3_AddViewport returned: %08lx\n", hr);
 
     memset(&vp_data, 0, sizeof(D3DVIEWPORT2));
     vp_data.dwSize = sizeof(D3DVIEWPORT2);
@@ -1056,33 +1056,33 @@ static void D3D3_ViewportClearTest(void)
     vp_data.dvClipHeight = 2.0f;
     vp_data.dvMaxZ = 1.0f;
     hr = IDirect3DViewport3_SetViewport2(SmallViewport3, &vp_data);
-    ok(hr==DD_OK, "IDirect3DViewport3_SetViewport2 returned: %08x\n", hr);
+    ok(hr==DD_OK, "IDirect3DViewport3_SetViewport2 returned: %08lx\n", hr);
 
     hr = IDirect3DDevice3_BeginScene(Direct3DDevice3);
-    ok(hr == D3D_OK, "IDirect3DDevice3_BeginScene failed with %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice3_BeginScene failed with %08lx\n", hr);
 
     hr = IDirect3DDevice3_SetTransform(Direct3DDevice3, D3DTRANSFORMSTATE_WORLD, &mat);
-    ok(hr == D3D_OK, "IDirect3DDevice3_SetTransform returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice3_SetTransform returned %08lx\n", hr);
     hr = IDirect3DDevice3_SetTransform(Direct3DDevice3, D3DTRANSFORMSTATE_VIEW, &mat);
-    ok(hr == D3D_OK, "IDirect3DDevice3_SetTransform returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice3_SetTransform returned %08lx\n", hr);
     hr = IDirect3DDevice3_SetTransform(Direct3DDevice3, D3DTRANSFORMSTATE_PROJECTION, &mat);
-    ok(hr == D3D_OK, "IDirect3DDevice3_SetTransform returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice3_SetTransform returned %08lx\n", hr);
     hr = IDirect3DDevice3_SetRenderState(Direct3DDevice3, D3DRENDERSTATE_CLIPPING, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice3_SetRenderState returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice3_SetRenderState returned %08lx\n", hr);
     hr = IDirect3DDevice3_SetRenderState(Direct3DDevice3, D3DRENDERSTATE_ZENABLE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice3_SetRenderState returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice3_SetRenderState returned %08lx\n", hr);
     hr = IDirect3DDevice3_SetRenderState(Direct3DDevice3, D3DRENDERSTATE_FOGENABLE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice3_SetRenderState returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice3_SetRenderState returned %08lx\n", hr);
     hr = IDirect3DDevice3_SetRenderState(Direct3DDevice3, D3DRENDERSTATE_STENCILENABLE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice3_SetRenderState returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice3_SetRenderState returned %08lx\n", hr);
     hr = IDirect3DDevice3_SetRenderState(Direct3DDevice3, D3DRENDERSTATE_ALPHATESTENABLE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice3_SetRenderState returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice3_SetRenderState returned %08lx\n", hr);
     hr = IDirect3DDevice3_SetRenderState(Direct3DDevice3, D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice3_SetRenderState returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice3_SetRenderState returned %08lx\n", hr);
     hr = IDirect3DDevice3_SetRenderState(Direct3DDevice3, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
-    ok(hr == D3D_OK, "IDirect3DDevice3_SetRenderState failed with %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice3_SetRenderState failed with %08lx\n", hr);
     hr = IDirect3DDevice3_SetRenderState(Direct3DDevice3, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(hr == D3D_OK, "IDirect3DDevice3_SetRenderState returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice3_SetRenderState returned %08lx\n", hr);
 
     if (SUCCEEDED(hr)) {
         U1(rect).x1 = U2(rect).y1 = 0;
@@ -1090,57 +1090,57 @@ static void D3D3_ViewportClearTest(void)
         U4(rect).y2 = 480;
 
         hr = IDirect3DViewport3_Clear2(Viewport3, 1, &rect, D3DCLEAR_TARGET, 0x00ff00, 0.0f, 0);
-        ok(hr == D3D_OK, "IDirect3DViewport3_Clear2 failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DViewport3_Clear2 failed, hr = %08lx\n", hr);
 
         hr = IDirect3DViewport3_Clear2(SmallViewport3, 1, &rect, D3DCLEAR_TARGET, 0xff0000, 0.0f, 0);
-        ok(hr == D3D_OK, "IDirect3DViewport3_Clear2 failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DViewport3_Clear2 failed, hr = %08lx\n", hr);
 
         hr = IDirect3DDevice3_EndScene(Direct3DDevice3);
-        ok(hr == D3D_OK, "IDirect3DDevice3_EndScene failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice3_EndScene failed, hr = %08lx\n", hr);
         }
 
     color = D3D3_getPixelColor(DirectDraw4, Primary, 5, 5);
     red =   (color & 0x00ff0000) >> 16;
     green = (color & 0x0000ff00) >>  8;
     blue =  (color & 0x000000ff);
-    ok(red == 0 && green == 0xff && blue == 0, "Got color %08x, expected 0000ff00\n", color);
+    ok(red == 0 && green == 0xff && blue == 0, "Got color %08lx, expected 0000ff00\n", color);
 
     color = D3D3_getPixelColor(DirectDraw4, Primary, 405, 105);
     red =   (color & 0x00ff0000) >> 16;
     green = (color & 0x0000ff00) >>  8;
     blue =  (color & 0x000000ff);
-    ok(red == 0xff && green == 0 && blue == 0, "Got color %08x, expected 00ff0000\n", color);
+    ok(red == 0xff && green == 0 && blue == 0, "Got color %08lx, expected 00ff0000\n", color);
 
     /* Test that clearing viewport doesn't interfere with rendering to previously active viewport. */
     hr = IDirect3DDevice3_BeginScene(Direct3DDevice3);
-    ok(hr == D3D_OK, "IDirect3DDevice3_BeginScene failed with %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice3_BeginScene failed with %08lx\n", hr);
 
     if (SUCCEEDED(hr)) {
         hr = IDirect3DDevice3_SetCurrentViewport(Direct3DDevice3, SmallViewport3);
-        ok(hr == D3D_OK, "IDirect3DDevice3_SetCurrentViewport failed with %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice3_SetCurrentViewport failed with %08lx\n", hr);
 
         hr = IDirect3DViewport3_Clear2(Viewport3, 1, &rect, D3DCLEAR_TARGET, 0x000000, 0.0f, 0);
-        ok(hr == D3D_OK, "IDirect3DViewport3_Clear2 failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DViewport3_Clear2 failed, hr = %08lx\n", hr);
 
         hr = IDirect3DDevice3_DrawIndexedPrimitive(Direct3DDevice3, D3DPT_TRIANGLELIST, fvf, quad, 4 /* NumVerts */,
                                                     Indices, 6 /* Indexcount */, 0 /* flags */);
-        ok(hr == D3D_OK, "IDirect3DDevice3_DrawIndexedPrimitive failed with %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice3_DrawIndexedPrimitive failed with %08lx\n", hr);
 
         hr = IDirect3DDevice3_EndScene(Direct3DDevice3);
-        ok(hr == D3D_OK, "IDirect3DDevice3_EndScene failed, hr = %08x\n", hr);
+        ok(hr == D3D_OK, "IDirect3DDevice3_EndScene failed, hr = %08lx\n", hr);
         }
 
     color = D3D3_getPixelColor(DirectDraw4, Primary, 5, 5);
     red =   (color & 0x00ff0000) >> 16;
     green = (color & 0x0000ff00) >>  8;
     blue =  (color & 0x000000ff);
-    ok(red == 0 && green == 0 && blue == 0, "Got color %08x, expected 00000000\n", color);
+    ok(red == 0 && green == 0 && blue == 0, "Got color %08lx, expected 00000000\n", color);
 
     color = D3D3_getPixelColor(DirectDraw4, Primary, 405, 105);
     red =   (color & 0x00ff0000) >> 16;
     green = (color & 0x0000ff00) >>  8;
     blue =  (color & 0x000000ff);
-    ok(red == 0xff && green == 0xff && blue == 0xff, "Got color %08x, expected 00ffffff\n", color);
+    ok(red == 0xff && green == 0xff && blue == 0xff, "Got color %08lx, expected 00ffffff\n", color);
 
     out:
 
@@ -1161,13 +1161,13 @@ static COLORREF getPixelColor_GDI(IDirectDrawSurface *Surface, UINT x, UINT y)
     HRESULT hr;
 
     hr = IDirectDrawSurface_GetDC(Surface, &hdc);
-    ok(hr==DD_OK, "IDirectDrawSurface_GetDC returned: %x\n", hr);
+    ok(hr==DD_OK, "IDirectDrawSurface_GetDC returned: %lx\n", hr);
 
     if (SUCCEEDED(hr)) {
         clr = GetPixel(hdc, x, y);
 
         hr = IDirectDrawSurface_ReleaseDC(Surface, hdc);
-        ok(hr==DD_OK, "IDirectDrawSurface_ReleaseDC returned: %x\n", hr);
+        ok(hr==DD_OK, "IDirectDrawSurface_ReleaseDC returned: %lx\n", hr);
     }
 
     return clr;
@@ -1211,7 +1211,7 @@ static void cubemap_test(IDirect3DDevice7 *device)
 
     memset(&d3dcaps, 0, sizeof(d3dcaps));
     hr = IDirect3DDevice7_GetCaps(device, &d3dcaps);
-    ok(hr == D3D_OK, "IDirect3DDevice7_GetCaps returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_GetCaps returned %08lx\n", hr);
     if(!(d3dcaps.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_CUBEMAP))
     {
         skip("No cubemap support\n");
@@ -1219,12 +1219,12 @@ static void cubemap_test(IDirect3DDevice7 *device)
     }
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 0.0, 0);
-    ok(hr == D3D_OK, "IDirect3DDevice7_Clear failed with %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_Clear failed with %08lx\n", hr);
 
     hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
-    ok(hr == D3D_OK, "IDirect3DDevice7_GetDirect3D returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3DDevice7_GetDirect3D returned %08lx\n", hr);
     hr = IDirect3D7_QueryInterface(d3d, &IID_IDirectDraw7, (void **) &ddraw);
-    ok(hr == D3D_OK, "IDirect3D7_QueryInterface returned %08x\n", hr);
+    ok(hr == D3D_OK, "IDirect3D7_QueryInterface returned %08lx\n", hr);
     IDirect3D7_Release(d3d);
 
 
@@ -1243,60 +1243,60 @@ static void cubemap_test(IDirect3DDevice7 *device)
     U4(U4(ddsd).ddpfPixelFormat).dwBBitMask = 0x000000FF;
 
     hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &cubemap, NULL);
-    ok(hr == DD_OK, "IDirectDraw7_CreateSurface returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDraw7_CreateSurface returned %08lx\n", hr);
     IDirectDraw7_Release(ddraw);
 
     /* Positive X */
     U5(DDBltFx).dwFillColor = 0x00ff0000;
     hr = IDirectDrawSurface7_Blt(cubemap, NULL, NULL, NULL, DDBLT_COLORFILL, &DDBltFx);
-    ok(hr == DD_OK, "IDirectDrawSurface7_Blt returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface7_Blt returned %08lx\n", hr);
 
     memset(&caps, 0, sizeof(caps));
     caps.dwCaps = DDSCAPS_TEXTURE;
     caps.dwCaps2 = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX;
     hr = IDirectDrawSurface_GetAttachedSurface(cubemap, &caps, &surface);
-    ok(hr == DD_OK, "IDirectDrawSurface7_Lock returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface7_Lock returned %08lx\n", hr);
     U5(DDBltFx).dwFillColor = 0x0000ffff;
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL, &DDBltFx);
-    ok(hr == DD_OK, "IDirectDrawSurface7_Blt returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface7_Blt returned %08lx\n", hr);
 
     caps.dwCaps2 = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ;
     hr = IDirectDrawSurface_GetAttachedSurface(cubemap, &caps, &surface);
-    ok(hr == DD_OK, "IDirectDrawSurface7_Lock returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface7_Lock returned %08lx\n", hr);
     U5(DDBltFx).dwFillColor = 0x0000ff00;
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL, &DDBltFx);
-    ok(hr == DD_OK, "IDirectDrawSurface7_Blt returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface7_Blt returned %08lx\n", hr);
 
     caps.dwCaps2 = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEZ;
     hr = IDirectDrawSurface_GetAttachedSurface(cubemap, &caps, &surface);
-    ok(hr == DD_OK, "IDirectDrawSurface7_Lock returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface7_Lock returned %08lx\n", hr);
     U5(DDBltFx).dwFillColor = 0x000000ff;
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL, &DDBltFx);
-    ok(hr == DD_OK, "IDirectDrawSurface7_Blt returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface7_Blt returned %08lx\n", hr);
 
     caps.dwCaps2 = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEY;
     hr = IDirectDrawSurface_GetAttachedSurface(cubemap, &caps, &surface);
-    ok(hr == DD_OK, "IDirectDrawSurface7_Lock returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface7_Lock returned %08lx\n", hr);
     U5(DDBltFx).dwFillColor = 0x00ffff00;
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL, &DDBltFx);
-    ok(hr == DD_OK, "IDirectDrawSurface7_Blt returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface7_Blt returned %08lx\n", hr);
 
     caps.dwCaps2 = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEY;
     hr = IDirectDrawSurface_GetAttachedSurface(cubemap, &caps, &surface);
-    ok(hr == DD_OK, "IDirectDrawSurface7_Lock returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface7_Lock returned %08lx\n", hr);
     U5(DDBltFx).dwFillColor = 0x00ff00ff;
     hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL, &DDBltFx);
-    ok(hr == DD_OK, "IDirectDrawSurface7_Blt returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface7_Blt returned %08lx\n", hr);
 
     hr = IDirect3DDevice7_SetTexture(device, 0, cubemap);
-    ok(hr == DD_OK, "IDirect3DDevice7_SetTexture returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirect3DDevice7_SetTexture returned %08lx\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-    ok(hr == DD_OK, "IDirect3DDevice7_SetTextureStageState returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirect3DDevice7_SetTextureStageState returned %08lx\n", hr);
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-    ok(hr == DD_OK, "IDirect3DDevice7_SetTextureStageState returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirect3DDevice7_SetTextureStageState returned %08lx\n", hr);
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(hr == DD_OK, "IDirect3DDevice7_BeginScene returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirect3DDevice7_BeginScene returned %08lx\n", hr);
     if(SUCCEEDED(hr))
     {
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEX1, quad + 0 * 6, 4, 0);
@@ -1305,35 +1305,35 @@ static void cubemap_test(IDirect3DDevice7 *device)
             /* VMware */
             win_skip("IDirect3DDevice7_DrawPrimitive is not completely implemented, colors won't be tested\n");
             hr = IDirect3DDevice7_EndScene(device);
-            ok(hr == DD_OK, "IDirect3DDevice7_EndScene returned %08x\n", hr);
+            ok(hr == DD_OK, "IDirect3DDevice7_EndScene returned %08lx\n", hr);
             goto out;
         }
-        ok(hr == DD_OK, "IDirect3DDevice7_DrawPrimitive returned %08x\n", hr);
+        ok(hr == DD_OK, "IDirect3DDevice7_DrawPrimitive returned %08lx\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEX1, quad + 4 * 6, 4, 0);
-        ok(hr == DD_OK, "IDirect3DDevice7_DrawPrimitive returned %08x\n", hr);
+        ok(hr == DD_OK, "IDirect3DDevice7_DrawPrimitive returned %08lx\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEX1, quad + 8 * 6, 4, 0);
-        ok(hr == DD_OK, "IDirect3DDevice7_DrawPrimitive returned %08x\n", hr);
+        ok(hr == DD_OK, "IDirect3DDevice7_DrawPrimitive returned %08lx\n", hr);
         hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEX1, quad + 12* 6, 4, 0);
-        ok(hr == DD_OK, "IDirect3DDevice7_DrawPrimitive returned %08x\n", hr);
+        ok(hr == DD_OK, "IDirect3DDevice7_DrawPrimitive returned %08lx\n", hr);
 
         hr = IDirect3DDevice7_EndScene(device);
-        ok(hr == DD_OK, "IDirect3DDevice7_EndScene returned %08x\n", hr);
+        ok(hr == DD_OK, "IDirect3DDevice7_EndScene returned %08lx\n", hr);
     }
     hr = IDirect3DDevice7_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_DISABLE);
-    ok(hr == DD_OK, "IDirect3DDevice7_SetTextureStageState returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirect3DDevice7_SetTextureStageState returned %08lx\n", hr);
 
     color = getPixelColor(device, 160, 360); /* lower left quad - positivex */
-    ok(color == 0x00ff0000, "DDSCAPS2_CUBEMAP_POSITIVEX has color 0x%08x, expected 0x00ff0000\n", color);
+    ok(color == 0x00ff0000, "DDSCAPS2_CUBEMAP_POSITIVEX has color 0x%08lx, expected 0x00ff0000\n", color);
     color = getPixelColor(device, 160, 120); /* upper left quad - negativex */
-    ok(color == 0x0000ffff, "DDSCAPS2_CUBEMAP_NEGATIVEX has color 0x%08x, expected 0x0000ffff\n", color);
+    ok(color == 0x0000ffff, "DDSCAPS2_CUBEMAP_NEGATIVEX has color 0x%08lx, expected 0x0000ffff\n", color);
     color = getPixelColor(device, 480, 360); /* lower right quad - positivey */
-    ok(color == 0x00ff00ff, "DDSCAPS2_CUBEMAP_POSITIVEY has color 0x%08x, expected 0x00ff00ff\n", color);
+    ok(color == 0x00ff00ff, "DDSCAPS2_CUBEMAP_POSITIVEY has color 0x%08lx, expected 0x00ff00ff\n", color);
     color = getPixelColor(device, 480, 120); /* upper right quad - positivez */
-    ok(color == 0x000000ff, "DDSCAPS2_CUBEMAP_POSITIVEZ has color 0x%08x, expected 0x000000ff\n", color);
+    ok(color == 0x000000ff, "DDSCAPS2_CUBEMAP_POSITIVEZ has color 0x%08lx, expected 0x000000ff\n", color);
 
 out:
     hr = IDirect3DDevice7_SetTexture(device, 0, NULL);
-    ok(hr == DD_OK, "IDirect3DDevice7_SetTexture returned %08x\n", hr);
+    ok(hr == DD_OK, "IDirect3DDevice7_SetTexture returned %08lx\n", hr);
     IDirectDrawSurface7_Release(cubemap);
 }
 
@@ -1414,66 +1414,66 @@ static void depth_clamp_test(IDirect3DDevice7 *device)
     vp.dvMaxZ = 7.5;
 
     hr = IDirect3DDevice7_SetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "SetViewport failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetViewport failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff00ff00, 1.0, 0);
-    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZWRITEENABLE, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZFUNC, D3DCMP_LESSEQUAL);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_BeginScene(device);
-    ok(SUCCEEDED(hr), "BeginScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "BeginScene failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_DIFFUSE, quad1, 4, 0);
-    ok(SUCCEEDED(hr), "DrawPrimitive failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitive failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_DIFFUSE, quad2, 4, 0);
-    ok(SUCCEEDED(hr), "DrawPrimitive failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitive failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_DIFFUSE, quad3, 4, 0);
-    ok(SUCCEEDED(hr), "DrawPrimitive failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitive failed, hr %#lx.\n", hr);
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_DIFFUSE, quad4, 4, 0);
-    ok(SUCCEEDED(hr), "DrawPrimitive failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitive failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, FALSE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE, quad5, 4, 0);
-    ok(SUCCEEDED(hr), "DrawPrimitive failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitive failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, TRUE);
-    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetRenderState failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ | D3DFVF_DIFFUSE, quad6, 4, 0);
-    ok(SUCCEEDED(hr), "DrawPrimitive failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "DrawPrimitive failed, hr %#lx.\n", hr);
 
     hr = IDirect3DDevice7_EndScene(device);
-    ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "EndScene failed, hr %#lx.\n", hr);
 
     color = getPixelColor(device, 75, 75);
-    ok(color_match(color, 0x00ffffff, 1) || color_match(color, 0x0000ff00, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00ffffff, 1) || color_match(color, 0x0000ff00, 1), "color 0x%08lx.\n", color);
     color = getPixelColor(device, 150, 150);
-    ok(color_match(color, 0x00ffffff, 1) || color_match(color, 0x0000ff00, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00ffffff, 1) || color_match(color, 0x0000ff00, 1), "color 0x%08lx.\n", color);
     color = getPixelColor(device, 320, 240);
-    ok(color_match(color, 0x00002b7f, 1) || color_match(color, 0x0000ff00, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00002b7f, 1) || color_match(color, 0x0000ff00, 1), "color 0x%08lx.\n", color);
     color = getPixelColor(device, 320, 330);
-    ok(color_match(color, 0x00f9e814, 1) || color_match(color, 0x0000ff00, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00f9e814, 1) || color_match(color, 0x0000ff00, 1), "color 0x%08lx.\n", color);
     color = getPixelColor(device, 320, 330);
-    ok(color_match(color, 0x00f9e814, 1) || color_match(color, 0x0000ff00, 1), "color 0x%08x.\n", color);
+    ok(color_match(color, 0x00f9e814, 1) || color_match(color, 0x0000ff00, 1), "color 0x%08lx.\n", color);
 
     vp.dvMinZ = 0.0;
     vp.dvMaxZ = 1.0;
     hr = IDirect3DDevice7_SetViewport(device, &vp);
-    ok(SUCCEEDED(hr), "SetViewport failed, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "SetViewport failed, hr %#lx.\n", hr);
 }
 
 static void DX1_BackBufferFlipTest(void)
@@ -1497,11 +1497,11 @@ static void DX1_BackBufferFlipTest(void)
             WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, 640, 480, 0, 0, 0, 0);
 
     hr = DirectDrawCreate( NULL, &DirectDraw1, NULL );
-    ok(hr==DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreate returned: %x\n", hr);
+    ok(hr==DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreate returned: %lx\n", hr);
     if(FAILED(hr)) goto out;
 
     hr = IDirectDraw_SetCooperativeLevel(DirectDraw1, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-    ok(hr==DD_OK, "SetCooperativeLevel returned: %x\n", hr);
+    ok(hr==DD_OK, "SetCooperativeLevel returned: %lx\n", hr);
     if(FAILED(hr)) goto out;
 
     hr = IDirectDraw_SetDisplayMode(DirectDraw1, 640, 480, 32);
@@ -1509,7 +1509,7 @@ static void DX1_BackBufferFlipTest(void)
         /* 24 bit is fine too */
         hr = IDirectDraw_SetDisplayMode(DirectDraw1, 640, 480, 24);
     }
-    ok(hr==DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode returned: %x\n", hr);
+    ok(hr==DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode returned: %lx\n", hr);
     if (FAILED(hr)) {
         goto out;
     }
@@ -1520,7 +1520,7 @@ static void DX1_BackBufferFlipTest(void)
     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
 
     hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &Primary, NULL);
-    ok(hr==DD_OK, "IDirectDraw_CreateSurface returned: %08x\n", hr);
+    ok(hr==DD_OK, "IDirectDraw_CreateSurface returned: %08lx\n", hr);
 
     memset(&ddsd, 0, sizeof(DDSURFACEDESC));
     ddsd.dwSize = sizeof(DDSURFACEDESC);
@@ -1536,12 +1536,12 @@ static void DX1_BackBufferFlipTest(void)
     U4(ddsd.ddpfPixelFormat).dwBBitMask         = 0x000000ff;
 
     hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &Backbuffer, NULL);
-    ok(hr==DD_OK, "IDirectDraw_CreateSurface returned: %08x\n", hr);
+    ok(hr==DD_OK, "IDirectDraw_CreateSurface returned: %08lx\n", hr);
     if(FAILED(hr)) goto out;
 
     hr = IDirectDrawSurface_AddAttachedSurface(Primary, Backbuffer);
     todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
-       "Attaching a back buffer to a front buffer returned %08x\n", hr);
+       "Attaching a back buffer to a front buffer returned %08lx\n", hr);
     if (FAILED(hr)) goto out;
 
     attached = TRUE;
@@ -1550,11 +1550,11 @@ static void DX1_BackBufferFlipTest(void)
     ddbltfx.dwSize = sizeof(ddbltfx);
     U5(ddbltfx).dwFillColor = red;
     hr = IDirectDrawSurface_Blt(Backbuffer, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
-    ok(hr == DD_OK, "IDirectDrawSurface_Blt returned: %x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface_Blt returned: %lx\n", hr);
 
     U5(ddbltfx).dwFillColor = white;
     hr = IDirectDrawSurface_Blt(Primary, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
-    ok(hr == DD_OK, "IDirectDrawSurface_Blt returned: %x\n", hr);
+    ok(hr == DD_OK, "IDirectDrawSurface_Blt returned: %lx\n", hr);
 
     /* Check it out */
     color = getPixelColor_GDI(Primary, 5, 5);
@@ -1568,7 +1568,7 @@ static void DX1_BackBufferFlipTest(void)
             GetRValue(color), GetGValue(color), GetBValue(color));
 
     hr = IDirectDrawSurface_Flip(Primary, NULL, DDFLIP_WAIT);
-    todo_wine ok(hr == DD_OK, "IDirectDrawSurface_Flip returned 0x%08x\n", hr);
+    todo_wine ok(hr == DD_OK, "IDirectDrawSurface_Flip returned 0x%08lx\n", hr);
 
     if (hr == DD_OK)
     {
@@ -1618,7 +1618,7 @@ START_TEST(visual)
     color = getPixelColor(Direct3DDevice, 1, 1);
     if(color !=0x00ff0000)
     {
-        skip("Sanity check returned an incorrect color(%08x), can't assure the correctness of the tests, skipping\n", color);
+        skip("Sanity check returned an incorrect color(%08lx), can't assure the correctness of the tests, skipping\n", color);
         goto cleanup;
     }
 
@@ -1632,7 +1632,7 @@ START_TEST(visual)
     color = getPixelColor(Direct3DDevice, 639, 479);
     if(color != 0x0000ddee)
     {
-        skip("Sanity check returned an incorrect color(%08x), can't assure the correctness of the tests, skipping\n", color);
+        skip("Sanity check returned an incorrect color(%08lx), can't assure the correctness of the tests, skipping\n", color);
         goto cleanup;
     }
 




More information about the wine-devel mailing list