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

Eric Pouech eric.pouech at gmail.com
Thu Feb 24 04:27:30 CST 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     | 4704 +++++++++++++++++-----------------
 dlls/ddraw/tests/ddraw4.c     | 5648 +++++++++++++++++++++--------------------
 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, 10961 insertions(+), 10962 deletions(-)

diff --git a/dlls/ddraw/tests/Makefile.in b/dlls/ddraw/tests/Makefile.in
index 6316bf91892..a3d0ce5cf12 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 d8f3618200b..e894e0fed23 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 458b3f48fdb..764b5e38704 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, const char *message)
@@ -417,7 +417,7 @@ static void check_rect(IDirectDrawSurface *surface, RECT r, const char *message)
                     if (x < 0 || x >= 640 || y < 0 || y >= 480)
                         continue;
                     color = get_surface_color(surface, x, y);
-                    ok(color == expected, "%s: Pixel (%d, %d) has color %08x, expected %08x\n",
+                    ok(color == expected, "%s: Pixel (%ld, %ld) has color %08lx, expected %08lx\n",
                             message, x, y, color, expected);
                 }
             }
@@ -596,7 +596,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)
@@ -647,7 +647,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);
@@ -659,18 +659,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);
     }
 
@@ -692,7 +692,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;
@@ -720,11 +720,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;
@@ -738,7 +738,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;
@@ -751,9 +751,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)
@@ -761,7 +761,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);
 }
 
@@ -772,11 +772,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;
@@ -866,7 +866,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;
@@ -888,9 +888,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);
 }
@@ -898,7 +898,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;
@@ -921,23 +921,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");
 
@@ -951,48 +951,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");
 
@@ -1066,22 +1066,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));
@@ -1101,11 +1101,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);
 
@@ -1123,33 +1123,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)
@@ -1159,13 +1159,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)
@@ -1174,35 +1174,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);
 }
 
@@ -1236,31 +1236,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);
@@ -1269,16 +1269,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);
@@ -1328,7 +1328,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))
@@ -1345,15 +1345,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;
 
@@ -1368,9 +1368,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)
@@ -1395,7 +1395,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);
@@ -1448,79 +1448,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;
@@ -1534,11 +1534,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;
@@ -1552,12 +1552,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",
@@ -1571,12 +1571,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",
@@ -1586,12 +1586,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",
@@ -1605,12 +1605,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",
@@ -1619,16 +1619,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);
@@ -1684,9 +1684,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);
@@ -1696,20 +1696,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)
@@ -1718,7 +1718,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);
@@ -1832,11 +1832,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));
@@ -1845,10 +1845,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)
     {
@@ -1856,7 +1856,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);
@@ -1883,45 +1883,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. */
@@ -1929,7 +1929,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);
@@ -1984,7 +1984,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);
@@ -2005,18 +2005,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);
@@ -2024,10 +2024,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);
@@ -2055,59 +2055,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);
@@ -2151,20 +2151,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;
@@ -2172,20 +2172,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);
@@ -2194,17 +2194,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);
@@ -2212,45 +2212,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);
 }
 
@@ -2272,13 +2272,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;
@@ -2287,7 +2287,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);
                 }
             }
@@ -2296,7 +2296,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);
         }
     }
@@ -2379,9 +2379,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));
 
@@ -2493,36 +2493,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
@@ -2530,53 +2530,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);
@@ -2607,12 +2607,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",
@@ -2624,9 +2624,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");
@@ -2635,77 +2635,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());
@@ -2713,20 +2713,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);
@@ -2736,13 +2736,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",
@@ -2751,46 +2751,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);
@@ -2811,15 +2811,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;
@@ -2831,14 +2831,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);
 }
@@ -2977,10 +2977,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);
@@ -2991,9 +2991,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)
     {
@@ -3012,7 +3012,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");
@@ -3025,7 +3025,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),
@@ -3037,12 +3037,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);
@@ -3055,16 +3055,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);
@@ -3072,10 +3072,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);
 
@@ -3085,12 +3085,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);
@@ -3103,16 +3103,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);
@@ -3128,7 +3128,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;
@@ -3141,11 +3141,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
@@ -3167,7 +3167,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;
@@ -3175,17 +3175,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);
@@ -3193,16 +3193,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);
@@ -3210,12 +3210,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);
@@ -3223,17 +3223,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);
 
@@ -3243,12 +3243,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);
@@ -3261,18 +3261,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),
@@ -3284,7 +3284,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 */)
     {
@@ -3293,25 +3293,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);
 
@@ -3321,12 +3321,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);
@@ -3339,25 +3339,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);
 
@@ -3365,11 +3365,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);
@@ -3377,12 +3377,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);
@@ -3393,17 +3393,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);
 
@@ -3413,12 +3413,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);
@@ -3431,18 +3431,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),
@@ -3454,27 +3454,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);
 
@@ -3484,12 +3484,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);
@@ -3502,25 +3502,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);
 
@@ -3528,11 +3528,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);
@@ -3540,12 +3540,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);
 
@@ -3555,12 +3555,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);
@@ -3568,19 +3568,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),
@@ -3594,36 +3594,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");
@@ -3633,19 +3633,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");
@@ -3654,23 +3654,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;
@@ -3697,10 +3697,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);
@@ -3721,14 +3721,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);
@@ -3738,7 +3738,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);
@@ -3746,21 +3746,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);
@@ -3769,7 +3769,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);
@@ -3777,21 +3777,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);
@@ -3801,21 +3801,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);
@@ -3825,7 +3825,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);
@@ -3833,24 +3833,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);
@@ -3859,28 +3859,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);
@@ -3908,7 +3908,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))
@@ -3925,32 +3925,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");
@@ -3960,19 +3960,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");
@@ -3981,23 +3981,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");
 
@@ -4005,24 +4005,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");
@@ -4034,27 +4034,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");
 
@@ -4065,25 +4065,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);
@@ -4102,26 +4102,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();
 
@@ -4129,7 +4129,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();
     }
 }
@@ -4150,20 +4150,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);
@@ -4181,9 +4181,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");
 
@@ -4216,7 +4216,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);
@@ -4226,20 +4226,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);
@@ -4270,7 +4270,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;
@@ -4302,31 +4302,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());
@@ -4335,10 +4335,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
@@ -4346,9 +4346,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());
@@ -4357,7 +4357,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. */
@@ -4367,15 +4367,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));
@@ -4451,7 +4451,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++)
         {
@@ -4470,7 +4470,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;
@@ -4478,7 +4478,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;
@@ -4490,7 +4490,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);
@@ -4671,12 +4671,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)
     {
@@ -4711,14 +4711,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;
@@ -4729,43 +4729,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);
 }
 
@@ -4890,7 +4890,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);
@@ -4900,23 +4900,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);
 }
 
@@ -5001,27 +5001,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);
 }
 
@@ -5072,7 +5072,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);
@@ -5090,29 +5090,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);
 
@@ -5160,7 +5160,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)
     {
@@ -5183,90 +5183,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);
@@ -5278,19 +5278,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
@@ -5300,59 +5300,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);
@@ -5361,7 +5361,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);
 }
 
@@ -5379,7 +5379,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);
@@ -5394,10 +5394,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);
 }
 
@@ -5425,7 +5425,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);
@@ -5433,22 +5433,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
@@ -5461,99 +5461,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);
 }
 
@@ -5582,7 +5582,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);
@@ -5592,14 +5592,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);
@@ -5618,20 +5618,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);
 
@@ -5642,27 +5642,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);
@@ -5671,7 +5671,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));
@@ -5679,7 +5679,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);
@@ -5688,7 +5688,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);
@@ -5697,7 +5697,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));
@@ -5707,33 +5707,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);
@@ -5748,7 +5748,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);
@@ -5761,26 +5761,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);
@@ -5801,47 +5801,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);
 }
 
@@ -5924,7 +5924,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;
     }
 
@@ -5934,9 +5934,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);
@@ -5951,7 +5951,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);
@@ -5965,7 +5965,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);
@@ -5980,18 +5980,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);
@@ -6097,7 +6097,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);
 
@@ -6120,32 +6120,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);
@@ -6155,7 +6155,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);
 }
 
@@ -6195,12 +6195,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");
@@ -6220,18 +6220,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);
@@ -6239,31 +6239,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);
 
@@ -6277,7 +6277,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);
 }
 
@@ -6302,12 +6302,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");
@@ -6326,28 +6326,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);
 
@@ -6356,46 +6356,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);
 }
 
@@ -6426,7 +6426,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));
@@ -6436,14 +6436,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);
@@ -6455,11 +6455,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);
@@ -6475,34 +6475,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))
     {
@@ -6513,7 +6513,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]);
         }
     }
@@ -6521,10 +6521,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.
@@ -6535,7 +6535,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);
@@ -6544,7 +6544,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);
 }
 
@@ -6597,7 +6597,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);
@@ -6605,7 +6605,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);
@@ -6614,12 +6614,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);
@@ -6631,67 +6631,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);
@@ -6699,9 +6699,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);
 }
 
@@ -6832,30 +6832,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);
@@ -6864,10 +6864,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);
@@ -6884,17 +6884,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);
@@ -6905,14 +6905,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);
@@ -6923,14 +6923,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);
@@ -6941,29 +6941,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;
@@ -6973,35 +6973,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);
@@ -7014,17 +7014,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);
@@ -7032,16 +7032,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);
 }
 
@@ -7286,36 +7286,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);
@@ -7324,26 +7324,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;
@@ -7363,21 +7363,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);
         }
@@ -7390,16 +7390,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);
@@ -7447,7 +7447,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);
@@ -7459,7 +7459,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));
@@ -7471,7 +7471,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,
@@ -7484,9 +7484,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",
@@ -7513,7 +7513,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);
@@ -7524,9 +7524,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);
@@ -7536,11 +7536,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++)
@@ -7557,13 +7557,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");
@@ -7572,35 +7572,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),
@@ -7630,7 +7630,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);
@@ -7639,12 +7639,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++)
@@ -7661,7 +7661,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
@@ -7677,14 +7677,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++)
@@ -7701,24 +7701,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);
 }
 
@@ -7757,18 +7757,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",
@@ -7787,11 +7787,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",
@@ -7810,13 +7810,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))
         {
@@ -7826,7 +7826,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);
@@ -7840,7 +7840,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);
@@ -7860,20 +7860,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);
 }
 
@@ -7896,7 +7896,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);
@@ -7904,7 +7904,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);
@@ -7913,7 +7913,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);
@@ -7934,84 +7934,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
@@ -8022,59 +8022,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);
@@ -8084,103 +8084,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)
@@ -8188,7 +8188,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);
 }
@@ -8206,7 +8206,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);
@@ -8215,36 +8215,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);
 }
 
@@ -8306,7 +8306,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);
@@ -8318,7 +8318,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.
      *
@@ -8338,27 +8338,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));
 
@@ -8411,29 +8411,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));
@@ -8450,25 +8450,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);
@@ -8481,15 +8481,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-
@@ -8497,23 +8497,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));
@@ -8530,25 +8530,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));
 
@@ -8564,15 +8564,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
@@ -8582,20 +8582,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));
@@ -8612,30 +8612,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));
 
@@ -8658,41 +8658,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);
 }
 
@@ -8722,32 +8722,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);
@@ -8756,7 +8756,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);
 }
 
@@ -8938,13 +8938,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'))
@@ -8957,7 +8957,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");
@@ -8984,7 +8984,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;
         }
@@ -9019,16 +9019,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)
@@ -9036,19 +9036,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)
@@ -9056,23 +9056,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)
@@ -9080,19 +9080,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)
@@ -9100,13 +9100,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);
@@ -9130,78 +9130,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);
@@ -9215,54 +9215,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);
@@ -9270,7 +9270,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);
 }
 
@@ -9359,7 +9359,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
@@ -9380,7 +9380,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);
@@ -9405,9 +9405,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
@@ -9425,16 +9425,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));
 
@@ -9459,14 +9459,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:
@@ -9484,21 +9484,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:
@@ -9516,11 +9516,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)
@@ -9544,52 +9544,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);
@@ -9605,7 +9605,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);
 }
 
@@ -9623,7 +9623,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);
@@ -9642,85 +9642,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);
 }
 
@@ -9783,7 +9783,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);
@@ -9796,7 +9796,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. */
@@ -9804,10 +9804,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));
@@ -9827,14 +9827,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 */
@@ -9844,9 +9844,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);
     }
 
@@ -9855,7 +9855,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);
 }
@@ -9909,12 +9909,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");
@@ -9937,10 +9937,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)
         {
@@ -9950,11 +9950,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)
@@ -9965,37 +9965,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);
     }
@@ -10020,7 +10020,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'))))
     {
@@ -10031,17 +10031,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;
@@ -10062,7 +10062,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
@@ -10070,12 +10070,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'))))
     {
@@ -10089,14 +10089,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]);
@@ -10106,7 +10106,7 @@ static void test_yv12_overlay(void)
         todo_wine 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);
@@ -10142,7 +10142,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'))))
     {
@@ -10155,21 +10155,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));
@@ -10186,18 +10186,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);
@@ -10222,7 +10222,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'))))
     {
@@ -10235,15 +10235,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())
@@ -10256,48 +10256,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)
@@ -10351,7 +10351,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);
@@ -10360,36 +10360,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);
 }
@@ -10431,7 +10431,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);
@@ -10451,9 +10451,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);
@@ -10473,23 +10473,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);
 }
 
@@ -10535,7 +10535,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);
@@ -10543,7 +10543,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);
@@ -10558,37 +10558,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));
@@ -10598,22 +10598,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);
@@ -10688,11 +10688,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)
@@ -10710,7 +10710,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;
             }
         }
@@ -10719,9 +10719,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))
         {
@@ -10732,10 +10732,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);
@@ -10759,11 +10759,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);
@@ -10772,17 +10772,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)
@@ -10791,20 +10791,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
         {
@@ -10819,152 +10819,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);
@@ -11089,11 +11089,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);
@@ -11105,8 +11105,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)
     {
@@ -11121,19 +11121,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)
     {
@@ -11150,12 +11150,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[] =
@@ -11172,8 +11172,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[] =
@@ -11186,7 +11186,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
@@ -11211,8 +11211,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[] =
@@ -11222,19 +11222,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[] =
@@ -11244,7 +11244,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;
@@ -11253,11 +11253,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[] =
@@ -11267,7 +11267,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.
@@ -11278,51 +11278,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]);
@@ -11332,21 +11332,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.
      *
@@ -11362,22 +11362,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);
@@ -11385,10 +11385,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);
@@ -11396,21 +11396,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)
     {
@@ -11429,48 +11429,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);
@@ -11479,8 +11479,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;
@@ -11492,15 +11492,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);
@@ -11508,33 +11508,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);
@@ -11545,7 +11545,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);
 }
@@ -11568,14 +11568,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)))
@@ -11588,10 +11588,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));
@@ -11600,14 +11600,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);
 
@@ -11618,17 +11618,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);
 }
 
@@ -11685,7 +11685,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)
     {
@@ -11701,7 +11701,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)
@@ -11710,14 +11710,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);
         }
 
@@ -11734,22 +11734,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);
             }
@@ -11760,21 +11760,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);
             }
@@ -11792,17 +11792,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)
@@ -11846,7 +11846,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);
@@ -11858,7 +11858,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);
@@ -11874,29 +11874,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);
@@ -11908,41 +11908,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);
@@ -11952,7 +11952,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);
 }
 
@@ -11974,7 +11974,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);
@@ -11988,16 +11988,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;
@@ -12005,33 +12005,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
@@ -12046,69 +12046,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);
@@ -12128,18 +12128,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. */
@@ -12150,11 +12150,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);
@@ -12164,7 +12164,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. */
@@ -12173,77 +12173,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. */
@@ -12254,18 +12254,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. */
@@ -12275,28 +12275,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. */
@@ -12306,19 +12306,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. */
@@ -12328,38 +12328,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. */
@@ -12369,70 +12369,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);
 }
 
@@ -12488,7 +12488,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);
@@ -12506,10 +12506,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);
@@ -12520,22 +12520,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)
     {
@@ -12548,13 +12548,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);
@@ -12562,7 +12562,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);
 }
@@ -12592,7 +12592,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);
 
@@ -12603,7 +12603,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;
@@ -12621,20 +12621,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. */
@@ -12644,34 +12644,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);
@@ -12681,7 +12681,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
@@ -12689,96 +12689,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. */
@@ -12792,9 +12792,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);
 }
 
@@ -12852,12 +12852,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");
     }
@@ -12882,18 +12882,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);
@@ -12903,52 +12903,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]);
@@ -12958,7 +12958,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));
@@ -12968,15 +12968,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. */
@@ -12985,13 +12985,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;
@@ -13002,15 +13002,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]);
 
@@ -13022,7 +13022,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);
@@ -13056,7 +13056,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));
 
@@ -13066,87 +13066,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);
@@ -13216,25 +13216,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);
@@ -13243,10 +13243,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);
@@ -13263,7 +13263,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);
@@ -13275,10 +13275,10 @@ static void test_viewport(void)
     for (j = 0; j < ARRAY_SIZE(tests); ++j)
     {
         hr = IDirect3DViewport_Clear(full_viewport, 1, &clear_rect, D3DCLEAR_TARGET);
-        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x (j %u).\n", hr, j);
+        ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx (j %u).\n", hr, j);
 
         hr = IDirect3D_CreateViewport(d3d, &viewport, NULL);
-        ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x (j %u).\n", hr, j);
+        ok(SUCCEEDED(hr), "Failed to create viewport, hr %#lx (j %u).\n", hr, j);
         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.dvMaxZ = 1.0f;
         hr = IDirect3DViewport_SetViewport(viewport, &vp);
         ok(hr == D3DERR_VIEWPORTHASNODEVICE,
-                "Setting viewport data returned unexpected hr %#x (j %u).\n", hr, j);
+                "Setting viewport data returned unexpected hr %#lx (j %u).\n", hr, j);
         hr = IDirect3DDevice_AddViewport(device, viewport);
-        ok(SUCCEEDED(hr), "Failed to add viewport, hr %#x (j %u).\n", hr, j);
+        ok(SUCCEEDED(hr), "Failed to add viewport, hr %#lx (j %u).\n", hr, j);
         hr = IDirect3DViewport_SetViewport(viewport, &vp);
-        ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x (j %u).\n", hr, j);
+        ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#lx (j %u).\n", hr, j);
 
         hr = IDirect3DDevice_BeginScene(device);
-        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x (j %u).\n", hr, j);
+        ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx (j %u).\n", hr, j);
 
         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 (j %u).\n", hr, j);
+        ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#lx (j %u).\n", hr, j);
 
         hr = IDirect3DDevice_EndScene(device);
-        ok(SUCCEEDED(hr), "Failed to end scene, hr %#x (j %u).\n", hr, j);
+        ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx (j %u).\n", hr, j);
 
         check_rect(rt, tests[j].expected_rect, tests[j].message);
 
@@ -13323,7 +13323,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);
@@ -13385,48 +13385,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)
     {
@@ -13439,21 +13439,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);
         }
     }
 
@@ -13480,7 +13480,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);
@@ -13496,9 +13496,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;
     }
 
@@ -13523,14 +13523,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");
@@ -13553,38 +13553,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);
@@ -13592,40 +13592,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);
 }
 
@@ -13686,7 +13686,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);
@@ -13695,7 +13695,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);
@@ -13704,10 +13704,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);
@@ -13717,17 +13717,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);
@@ -13740,24 +13740,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);
@@ -13769,20 +13769,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);
     }
 
@@ -13792,9 +13792,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);
 }
 
@@ -13814,24 +13814,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;
@@ -13839,50 +13839,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.
@@ -13890,11 +13890,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);
@@ -13910,7 +13910,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);
     }
 
@@ -13918,10 +13918,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. */
@@ -13934,28 +13934,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);
 }
 
@@ -14007,68 +14007,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));
@@ -14076,19 +14076,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);
     }
@@ -14107,7 +14107,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);
@@ -14117,21 +14117,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);
 }
 
@@ -14178,13 +14178,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);
@@ -14192,87 +14192,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));
 
@@ -14286,7 +14286,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)
 
@@ -14309,27 +14309,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);
@@ -14346,7 +14346,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);
 }
 
@@ -14368,10 +14368,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));
@@ -14382,9 +14382,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));
@@ -14392,7 +14392,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,
@@ -14401,15 +14401,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));
@@ -14417,25 +14417,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));
 
@@ -14466,14 +14466,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);
@@ -14498,29 +14498,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);
@@ -14574,7 +14574,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);
 
@@ -14586,11 +14586,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);
 
@@ -14598,7 +14598,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);
 
@@ -14608,10 +14608,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);
@@ -14620,20 +14620,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);
@@ -14644,7 +14644,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);
 }
 
@@ -14991,7 +14991,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);
@@ -15004,15 +15004,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));
@@ -15028,16 +15028,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++)
         {
@@ -15075,7 +15075,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);
             }
         }
@@ -15085,7 +15085,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 1285fa1b682..1298d1bc605 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, const char *message)
@@ -419,7 +419,7 @@ static void check_rect(IDirectDrawSurface *surface, RECT r, const char *message)
                     if (x < 0 || x >= 640 || y < 0 || y >= 480)
                         continue;
                     color = get_surface_color(surface, x, y);
-                    ok(color == expected, "%s: Pixel (%d, %d) has color %08x, expected %08x\n",
+                    ok(color == expected, "%s: Pixel (%ld, %ld) has color %08lx, expected %08lx\n",
                             message, x, y, color, expected);
                 }
             }
@@ -483,7 +483,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);
@@ -495,18 +495,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);
     }
 
@@ -535,7 +535,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;
@@ -564,11 +564,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;
@@ -582,7 +582,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;
@@ -595,9 +595,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)
@@ -605,7 +605,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);
 }
 
@@ -616,11 +616,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;
@@ -710,7 +710,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;
@@ -732,9 +732,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);
 }
@@ -742,7 +742,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;
@@ -765,23 +765,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");
 
@@ -795,48 +795,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");
 
@@ -910,22 +910,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));
@@ -945,11 +945,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);
 
@@ -967,33 +967,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)
@@ -1003,13 +1003,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)
@@ -1018,35 +1018,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);
 }
 
@@ -1100,44 +1100,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);
@@ -1146,33 +1146,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);
@@ -1223,7 +1223,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))
@@ -1246,15 +1246,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;
 
@@ -1269,9 +1269,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)
@@ -1297,7 +1297,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);
@@ -1353,7 +1353,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))
@@ -1362,71 +1362,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
@@ -1437,42 +1437,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)
     {
@@ -1482,7 +1482,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);
@@ -1508,7 +1508,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);
@@ -1517,13 +1517,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 */
@@ -1531,11 +1531,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 */
@@ -1545,43 +1545,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);
@@ -1639,7 +1639,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");
@@ -1649,106 +1649,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);
 
@@ -1756,43 +1756,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));
@@ -1811,29 +1811,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);
@@ -1878,35 +1878,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)
     {
@@ -1916,7 +1916,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);
@@ -1994,7 +1994,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);
@@ -2014,76 +2014,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);
@@ -2128,13 +2128,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);
@@ -2151,52 +2151,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);
@@ -2239,20 +2239,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;
@@ -2260,20 +2260,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);
@@ -2282,17 +2282,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);
@@ -2300,45 +2300,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);
 }
 
@@ -2360,13 +2360,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;
@@ -2375,7 +2375,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);
                 }
             }
@@ -2384,7 +2384,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);
         }
     }
@@ -2467,9 +2467,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));
 
@@ -2580,36 +2580,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
@@ -2617,53 +2617,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);
@@ -2694,12 +2694,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",
@@ -2711,9 +2711,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");
@@ -2722,77 +2722,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());
@@ -2800,20 +2800,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);
@@ -2823,13 +2823,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",
@@ -2838,46 +2838,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);
@@ -2898,15 +2898,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;
@@ -2918,14 +2918,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);
 }
@@ -3075,10 +3075,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);
@@ -3089,9 +3089,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)
     {
@@ -3110,7 +3110,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");
@@ -3128,7 +3128,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),
@@ -3140,12 +3140,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);
@@ -3158,16 +3158,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);
@@ -3175,10 +3175,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);
 
@@ -3188,12 +3188,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);
@@ -3206,16 +3206,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);
@@ -3231,7 +3231,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;
@@ -3244,11 +3244,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
@@ -3270,7 +3270,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;
@@ -3278,17 +3278,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);
@@ -3296,16 +3296,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);
@@ -3313,12 +3313,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);
@@ -3326,17 +3326,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);
 
@@ -3346,12 +3346,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);
@@ -3364,18 +3364,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),
@@ -3387,7 +3387,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 */)
     {
@@ -3396,25 +3396,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);
 
@@ -3424,12 +3424,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);
@@ -3442,25 +3442,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);
 
@@ -3468,11 +3468,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);
@@ -3480,12 +3480,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);
@@ -3496,17 +3496,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);
 
@@ -3516,12 +3516,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);
@@ -3534,18 +3534,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),
@@ -3557,27 +3557,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);
 
@@ -3587,12 +3587,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);
@@ -3605,25 +3605,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);
 
@@ -3631,11 +3631,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);
@@ -3643,12 +3643,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);
 
@@ -3658,9 +3658,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;
@@ -3668,13 +3668,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);
 
@@ -3688,23 +3688,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);
@@ -3712,23 +3712,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;
@@ -3738,14 +3738,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);
@@ -3761,17 +3761,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),
@@ -3785,36 +3785,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");
@@ -3824,19 +3824,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");
@@ -3845,23 +3845,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;
@@ -3890,10 +3890,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);
@@ -3914,14 +3914,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);
@@ -3931,7 +3931,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);
@@ -3939,21 +3939,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);
@@ -3962,7 +3962,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);
@@ -3970,21 +3970,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);
@@ -3994,21 +3994,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);
@@ -4018,7 +4018,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);
@@ -4026,24 +4026,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);
@@ -4052,28 +4052,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);
@@ -4101,7 +4101,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))
@@ -4118,32 +4118,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");
@@ -4153,19 +4153,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");
@@ -4174,23 +4174,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");
 
@@ -4198,24 +4198,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");
@@ -4227,27 +4227,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");
 
@@ -4258,25 +4258,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);
@@ -4294,16 +4294,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();
 }
@@ -4324,20 +4324,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);
@@ -4355,9 +4355,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");
 
@@ -4390,7 +4390,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);
@@ -4399,24 +4399,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);
@@ -4437,21 +4437,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;
 }
@@ -4475,16 +4475,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");
 
@@ -4494,10 +4494,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");
 
@@ -4508,12 +4508,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");
 
@@ -4524,14 +4524,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");
@@ -4542,10 +4542,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);
@@ -4553,7 +4553,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");
@@ -4652,49 +4652,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);
     }
 
@@ -4704,7 +4704,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);
 }
 
@@ -4726,7 +4726,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;
@@ -4758,31 +4758,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());
@@ -4791,10 +4791,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
@@ -4802,9 +4802,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());
@@ -4813,7 +4813,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. */
@@ -4823,15 +4823,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));
@@ -4907,7 +4907,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++)
         {
@@ -4926,7 +4926,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;
@@ -4934,7 +4934,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;
@@ -4946,7 +4946,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);
@@ -5176,12 +5176,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)
     {
@@ -5216,7 +5216,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;
 
@@ -5233,7 +5233,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);
@@ -5241,30 +5241,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);
@@ -5276,10 +5276,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));
@@ -5299,12 +5299,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)
@@ -5317,19 +5317,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);
@@ -5337,7 +5337,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);
 }
 
@@ -5462,7 +5462,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);
@@ -5472,23 +5472,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);
 }
 
@@ -5573,27 +5573,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);
 }
 
@@ -5644,7 +5644,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);
@@ -5662,29 +5662,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);
 
@@ -5732,7 +5732,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)
     {
@@ -5755,90 +5755,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);
@@ -5850,19 +5850,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
@@ -5872,59 +5872,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);
@@ -5933,7 +5933,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);
 }
 
@@ -5971,7 +5971,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;
@@ -5986,131 +5986,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.
      *
@@ -6119,27 +6119,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;
@@ -6147,13 +6147,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;
@@ -6164,11 +6164,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);
@@ -6176,12 +6176,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);
 
@@ -6193,7 +6193,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))
     {
@@ -6202,19 +6202,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);
     }
 
@@ -6227,7 +6227,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)
     {
@@ -6235,15 +6235,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;
@@ -6252,7 +6252,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;
@@ -6261,13 +6261,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);
         }
 
@@ -6281,7 +6281,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);
@@ -6296,7 +6296,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.
      *
@@ -6320,7 +6320,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",
@@ -6328,7 +6328,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);
@@ -6337,17 +6337,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);
         }
 
@@ -6356,7 +6356,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);
 }
 
@@ -6381,7 +6381,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;
@@ -6395,10 +6395,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));
@@ -6406,10 +6406,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);
@@ -6418,10 +6418,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;
@@ -6429,40 +6429,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);
 }
 
@@ -6480,7 +6480,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;
@@ -6494,10 +6494,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);
 }
 
@@ -6525,7 +6525,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);
@@ -6533,22 +6533,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
@@ -6561,99 +6561,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);
 }
 
@@ -6682,7 +6682,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);
@@ -6692,14 +6692,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);
@@ -6718,20 +6718,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);
 
@@ -6742,27 +6742,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);
@@ -6771,7 +6771,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));
@@ -6779,7 +6779,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);
@@ -6788,7 +6788,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);
@@ -6797,7 +6797,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));
@@ -6807,33 +6807,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);
@@ -6848,7 +6848,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);
@@ -6861,26 +6861,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);
@@ -6901,47 +6901,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);
 }
 
@@ -7024,7 +7024,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;
     }
 
@@ -7034,9 +7034,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);
@@ -7051,7 +7051,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);
@@ -7065,7 +7065,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);
@@ -7080,18 +7080,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);
@@ -7197,7 +7197,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);
 
@@ -7220,33 +7220,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);
@@ -7256,7 +7256,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);
 }
 
@@ -7297,12 +7297,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");
@@ -7322,22 +7322,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);
@@ -7345,31 +7345,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);
 
@@ -7383,7 +7383,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);
 }
 
@@ -7409,12 +7409,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");
@@ -7433,31 +7433,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);
 
@@ -7466,46 +7466,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);
 }
 
@@ -7536,7 +7536,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));
@@ -7546,14 +7546,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);
@@ -7565,11 +7565,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);
@@ -7585,34 +7585,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))
     {
@@ -7623,7 +7623,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]);
         }
     }
@@ -7631,10 +7631,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.
@@ -7645,7 +7645,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);
@@ -7654,7 +7654,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);
 }
 
@@ -7703,98 +7703,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);
 }
 
@@ -7920,83 +7920,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;
@@ -8006,78 +8006,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);
 }
 
@@ -8308,67 +8308,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);
         }
@@ -8377,16 +8377,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);
@@ -8434,7 +8434,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);
@@ -8446,7 +8446,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));
@@ -8458,7 +8458,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,
@@ -8471,9 +8471,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",
@@ -8500,7 +8500,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);
@@ -8511,9 +8511,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);
@@ -8523,11 +8523,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++)
@@ -8544,13 +8544,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");
@@ -8559,35 +8559,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),
@@ -8617,7 +8617,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);
@@ -8626,12 +8626,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++)
@@ -8648,7 +8648,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
@@ -8664,14 +8664,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++)
@@ -8688,24 +8688,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);
 }
 
@@ -8745,18 +8745,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",
@@ -8775,11 +8775,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",
@@ -8798,16 +8798,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))
         {
@@ -8817,7 +8817,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);
@@ -8831,7 +8831,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);
@@ -8851,24 +8851,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);
 }
 
@@ -8891,7 +8891,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);
@@ -8899,7 +8899,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);
@@ -8908,7 +8908,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);
@@ -8929,83 +8929,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
@@ -9016,59 +9016,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);
@@ -9078,103 +9078,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)
@@ -9182,7 +9182,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);
 }
@@ -9200,7 +9200,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);
@@ -9209,36 +9209,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);
 }
 
@@ -9296,13 +9296,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.
      *
@@ -9322,64 +9322,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));
@@ -9396,46 +9396,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));
@@ -9452,49 +9452,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));
@@ -9511,64 +9511,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);
 }
 
@@ -9598,32 +9598,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);
@@ -9632,7 +9632,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);
 }
 
@@ -9814,13 +9814,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'))
@@ -9833,7 +9833,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");
@@ -9860,7 +9860,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;
         }
@@ -9895,16 +9895,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)
@@ -9912,19 +9912,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)
@@ -9932,23 +9932,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)
@@ -9956,19 +9956,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)
@@ -9976,13 +9976,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);
@@ -10006,78 +10006,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);
@@ -10091,54 +10091,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);
@@ -10146,7 +10146,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);
 }
 
@@ -10231,7 +10231,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
@@ -10246,16 +10246,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);
@@ -10280,9 +10280,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
@@ -10300,21 +10300,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:
@@ -10332,21 +10332,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:
@@ -10364,11 +10364,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)
@@ -10392,56 +10392,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);
@@ -10454,7 +10454,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);
 }
 
@@ -10472,7 +10472,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);
@@ -10491,85 +10491,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);
 }
 
@@ -10632,16 +10632,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. */
@@ -10649,19 +10649,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 */
@@ -10671,9 +10671,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);
     }
 
@@ -10681,7 +10681,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);
 }
@@ -10736,12 +10736,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");
@@ -10764,13 +10764,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)
         {
@@ -10780,11 +10780,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)
@@ -10795,37 +10795,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);
     }
@@ -10850,7 +10850,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'))))
     {
@@ -10861,17 +10861,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;
@@ -10892,7 +10892,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
@@ -10900,12 +10900,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'))))
     {
@@ -10919,14 +10919,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]);
@@ -10936,7 +10936,7 @@ static void test_yv12_overlay(void)
         todo_wine 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);
@@ -10972,7 +10972,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'))))
     {
@@ -10985,21 +10985,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));
@@ -11016,18 +11016,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);
@@ -11052,7 +11052,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'))))
     {
@@ -11065,15 +11065,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())
@@ -11086,48 +11086,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)
@@ -11181,7 +11181,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);
@@ -11190,36 +11190,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);
 }
@@ -11261,7 +11261,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);
@@ -11281,9 +11281,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);
@@ -11303,23 +11303,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);
 }
 
@@ -11365,7 +11365,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);
@@ -11373,7 +11373,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);
@@ -11388,37 +11388,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));
@@ -11428,22 +11428,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);
@@ -11518,11 +11518,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)
@@ -11540,7 +11540,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;
             }
         }
@@ -11549,9 +11549,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))
         {
@@ -11562,10 +11562,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);
@@ -11589,11 +11589,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);
@@ -11602,17 +11602,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)
@@ -11621,20 +11621,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
         {
@@ -11649,152 +11649,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);
@@ -11835,31 +11835,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);
 }
@@ -11917,14 +11917,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));
@@ -11941,127 +11941,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);
 }
@@ -12191,11 +12191,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);
@@ -12207,8 +12207,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)
     {
@@ -12223,19 +12223,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)
     {
@@ -12252,12 +12252,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[] =
@@ -12274,8 +12274,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[] =
@@ -12288,7 +12288,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
@@ -12313,8 +12313,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[] =
@@ -12324,19 +12324,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[] =
@@ -12346,7 +12346,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;
@@ -12355,11 +12355,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[] =
@@ -12369,7 +12369,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.
@@ -12380,51 +12380,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]);
@@ -12434,21 +12434,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.
      *
@@ -12464,20 +12464,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)
     {
@@ -12496,48 +12496,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);
@@ -12546,8 +12546,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;
@@ -12559,40 +12559,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);
@@ -12607,12 +12607,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[] =
@@ -12633,41 +12633,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;
@@ -12680,14 +12680,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[] =
@@ -12701,7 +12701,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);
     }
 
@@ -12709,7 +12709,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);
 }
@@ -12732,14 +12732,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)))
@@ -12752,10 +12752,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));
@@ -12764,14 +12764,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);
 
@@ -12782,17 +12782,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);
 }
 
@@ -12850,7 +12850,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)
     {
@@ -12866,9 +12866,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)
@@ -12877,21 +12877,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);
         }
 
@@ -12908,22 +12908,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);
             }
@@ -12934,22 +12934,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);
             }
@@ -12960,21 +12960,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);
             }
@@ -12993,17 +12993,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)
@@ -13025,7 +13025,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);
@@ -13039,22 +13039,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;
@@ -13062,33 +13062,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
@@ -13103,69 +13103,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);
@@ -13185,25 +13185,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. */
@@ -13214,11 +13214,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);
@@ -13228,7 +13228,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. */
@@ -13237,77 +13237,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. */
@@ -13318,19 +13318,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. */
@@ -13340,28 +13340,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. */
@@ -13371,19 +13371,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. */
@@ -13393,38 +13393,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. */
@@ -13434,69 +13434,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);
 }
 
@@ -13520,26 +13520,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);
 }
 
@@ -13592,16 +13592,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)
@@ -13621,23 +13621,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)
@@ -13655,7 +13655,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;
@@ -13663,13 +13663,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);
     }
 
@@ -13679,7 +13679,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);
 }
@@ -13709,11 +13709,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);
@@ -13722,7 +13722,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;
@@ -13740,20 +13740,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. */
@@ -13763,41 +13763,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;
@@ -13805,84 +13805,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. */
@@ -13896,9 +13896,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);
 }
 
@@ -13956,12 +13956,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");
     }
@@ -13986,18 +13986,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);
@@ -14007,52 +14007,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]);
@@ -14062,7 +14062,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));
@@ -14072,15 +14072,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. */
@@ -14089,13 +14089,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;
@@ -14106,15 +14106,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]);
 
@@ -14126,7 +14126,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);
@@ -14196,19 +14196,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);
 
@@ -14229,23 +14229,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(SUCCEEDED(hr), "Failed to create render target, hr %#x (i %u).\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx (i %u).\n", hr, i);
 
             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(SUCCEEDED(hr), "Failed to create depth buffer, hr %#x (i %u).\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#lx (i %u).\n", hr, i);
             hr = IDirectDrawSurface_AddAttachedSurface(rt, ds);
-            ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x (i %u).\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx (i %u).\n", hr, i);
 
             hr = IDirect3DDevice2_SetRenderTarget(device, rt, 0);
-            ok(SUCCEEDED(hr), "Failed to set render target, hr %#x (i %u).\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to set render target, hr %#lx (i %u).\n", hr, i);
         }
         else
         {
             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);
         }
 
         full_viewport = create_viewport(device, 0, 0, rt_sizes[i].x, rt_sizes[i].y);
@@ -14261,12 +14261,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(SUCCEEDED(hr), "Failed to clear viewport, hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx (i %u, j %u).\n", hr, i, j);
 
             hr = IDirect3D2_CreateViewport(d3d, &viewport, NULL);
-            ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Failed to create viewport, hr %#lx (i %u, j %u).\n", hr, i, j);
             hr = IDirect3DViewport2_SetViewport2(viewport, NULL);
-            ok(hr == E_INVALIDARG, "Setting NULL viewport data returned unexpected hr %#x (i %u, j %u).\n",
+            ok(hr == E_INVALIDARG, "Setting NULL viewport data returned unexpected hr %#lx (i %u, j %u).\n",
                     hr, i, j);
             memset(&vp, 0, sizeof(vp));
             vp.dwSize = sizeof(vp);
@@ -14280,18 +14280,18 @@ static void test_viewport(void)
             vp.dvMaxZ = 1.0f;
             hr = IDirect3DViewport2_SetViewport(viewport, &vp);
             ok(hr == D3DERR_VIEWPORTHASNODEVICE,
-                    "Setting viewport data returned unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+                    "Setting viewport data returned unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
             hr = IDirect3DDevice2_AddViewport(device, viewport);
-            ok(SUCCEEDED(hr), "Failed to add viewport, hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Failed to add viewport, hr %#lx (i %u, j %u).\n", hr, i, j);
             hr = IDirect3DViewport2_SetViewport(viewport, &vp);
             if (expected_failure)
-                ok(hr == E_INVALIDARG, "Setting viewport data returned unexpected hr %#x (i %u, j %u).\n",
+                ok(hr == E_INVALIDARG, "Setting viewport data returned unexpected hr %#lx (i %u, j %u).\n",
                         hr, i, j);
             else
-                ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x (i %u, j %u).\n", hr, i, j);
+                ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#lx (i %u, j %u).\n", hr, i, j);
 
             hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
-            ok(SUCCEEDED(hr), "Failed to set the viewport, hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Failed to set the viewport, hr %#lx (i %u, j %u).\n", hr, i, j);
             if (expected_failure)
             {
                 destroy_viewport(device, viewport);
@@ -14299,11 +14299,11 @@ static void test_viewport(void)
             }
 
             hr = IDirect3DDevice2_BeginScene(device);
-            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx (i %u, j %u).\n", hr, i, j);
             hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, quad, 4, 0);
-            ok(SUCCEEDED(hr), "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Got unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
             hr = IDirect3DDevice2_EndScene(device);
-            ok(SUCCEEDED(hr), "Failed to end scene, hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx (i %u, j %u).\n", hr, i, j);
 
             check_rect(rt, tests[j].expected_rect, tests[j].message);
 
@@ -14313,7 +14313,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);
@@ -14321,7 +14321,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);
@@ -14383,48 +14383,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)
     {
@@ -14437,21 +14437,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);
         }
     }
 
@@ -14478,7 +14478,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);
@@ -14494,9 +14494,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;
     }
 
@@ -14521,14 +14521,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");
@@ -14551,38 +14551,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);
@@ -14590,40 +14590,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);
 }
 
@@ -14681,64 +14681,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);
     }
 
@@ -14747,9 +14747,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);
 }
 
@@ -14770,24 +14770,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;
@@ -14795,50 +14795,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.
@@ -14846,11 +14846,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);
@@ -14866,7 +14866,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);
     }
 
@@ -14874,10 +14874,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. */
@@ -14890,33 +14890,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);
 }
 
@@ -14969,35 +14969,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));
@@ -15005,39 +15005,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));
@@ -15045,19 +15045,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);
     }
@@ -15076,7 +15076,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);
@@ -15086,21 +15086,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);
 }
 
@@ -15154,13 +15154,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);
@@ -15168,87 +15168,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));
 
@@ -15275,10 +15275,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));
@@ -15289,9 +15289,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));
@@ -15299,7 +15299,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,
@@ -15308,15 +15308,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));
@@ -15324,25 +15324,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));
 
@@ -15373,14 +15373,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);
@@ -15407,41 +15407,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");
@@ -15450,17 +15450,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:
@@ -15506,11 +15506,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);
@@ -15520,37 +15520,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);
@@ -15559,7 +15559,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);
 }
 
@@ -15903,15 +15903,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);
@@ -15926,7 +15926,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. */
@@ -15935,7 +15935,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;
@@ -15943,14 +15943,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)
     {
@@ -15959,17 +15959,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++)
             {
@@ -16007,7 +16007,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);
                 }
             }
@@ -16020,9 +16020,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 399ef157497..d56476c2864 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, const char *message)
@@ -420,7 +420,7 @@ static void check_rect(IDirectDrawSurface4 *surface, RECT r, const char *message
                     if (x < 0 || x >= 640 || y < 0 || y >= 480)
                         continue;
                     color = get_surface_color(surface, x, y);
-                    ok(color == expected, "%s: Pixel (%d, %d) has color %08x, expected %08x\n",
+                    ok(color == expected, "%s: Pixel (%ld, %ld) has color %08lx, expected %08lx\n",
                             message, x, y, color, expected);
                 }
             }
@@ -469,7 +469,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);
@@ -481,18 +481,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);
     }
 
@@ -524,7 +524,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);
@@ -533,7 +533,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))
     {
@@ -564,11 +564,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;
@@ -582,7 +582,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;
@@ -593,7 +593,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);
 }
 
@@ -604,11 +604,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;
@@ -702,13 +702,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);
         }
 
@@ -731,9 +731,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);
 }
@@ -776,17 +776,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;
@@ -797,19 +797,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;
@@ -822,22 +822,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);
@@ -848,16 +848,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);
@@ -868,7 +868,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;
@@ -882,13 +882,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);
@@ -899,7 +899,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;
@@ -913,13 +913,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);
@@ -930,10 +930,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);
@@ -954,23 +954,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");
 
@@ -984,48 +984,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");
 
@@ -1099,22 +1099,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));
@@ -1134,11 +1134,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);
 
@@ -1156,33 +1156,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)
@@ -1192,13 +1192,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)
@@ -1207,35 +1207,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);
 }
 
@@ -1277,29 +1277,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))
@@ -1310,53 +1310,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);
@@ -1386,7 +1386,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);
@@ -1396,10 +1396,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)))
     {
@@ -1423,15 +1423,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;
 
@@ -1444,9 +1444,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)
@@ -1470,7 +1470,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);
@@ -1521,9 +1521,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);
@@ -1533,7 +1533,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))
@@ -1542,70 +1542,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
@@ -1614,40 +1614,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)
     {
@@ -1657,7 +1657,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);
@@ -1681,7 +1681,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);
@@ -1690,13 +1690,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 */
@@ -1707,50 +1707,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);
@@ -1803,109 +1803,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);
 
@@ -1913,42 +1913,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));
@@ -1968,16 +1968,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;
@@ -1991,12 +1991,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",
@@ -2010,12 +2010,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",
@@ -2025,12 +2025,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",
@@ -2044,12 +2044,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",
@@ -2058,12 +2058,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",
@@ -2071,15 +2071,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);
@@ -2119,35 +2119,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)
     {
@@ -2157,7 +2157,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);
@@ -2232,12 +2232,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));
@@ -2258,66 +2258,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);
     }
 
@@ -2367,17 +2367,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);
@@ -2394,47 +2394,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);
@@ -2467,9 +2467,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));
@@ -2479,20 +2479,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;
@@ -2500,20 +2500,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);
@@ -2522,17 +2522,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);
@@ -2540,46 +2540,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);
 }
 
@@ -2601,13 +2601,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;
@@ -2616,7 +2616,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);
                 }
             }
@@ -2625,7 +2625,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);
         }
     }
@@ -2700,7 +2700,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);
@@ -2709,9 +2709,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));
 
@@ -2817,36 +2817,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
@@ -2854,53 +2854,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);
@@ -2931,12 +2931,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",
@@ -2948,9 +2948,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");
@@ -2959,77 +2959,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());
@@ -3037,20 +3037,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);
@@ -3060,13 +3060,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",
@@ -3075,46 +3075,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);
@@ -3135,15 +3135,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;
@@ -3155,14 +3155,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);
 }
@@ -3312,10 +3312,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);
@@ -3326,9 +3326,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)
     {
@@ -3347,7 +3347,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");
@@ -3365,7 +3365,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),
@@ -3377,12 +3377,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);
@@ -3395,16 +3395,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);
@@ -3412,10 +3412,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);
 
@@ -3425,12 +3425,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);
@@ -3443,16 +3443,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);
@@ -3471,7 +3471,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;
@@ -3484,11 +3484,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
@@ -3510,7 +3510,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;
@@ -3518,17 +3518,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);
@@ -3536,16 +3536,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);
@@ -3553,12 +3553,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);
@@ -3566,17 +3566,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);
 
@@ -3586,12 +3586,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);
@@ -3604,18 +3604,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),
@@ -3627,27 +3627,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);
 
@@ -3657,12 +3657,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);
@@ -3675,25 +3675,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);
 
@@ -3701,11 +3701,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);
@@ -3713,12 +3713,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);
@@ -3729,17 +3729,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);
 
@@ -3749,12 +3749,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);
@@ -3767,18 +3767,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),
@@ -3790,27 +3790,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);
 
@@ -3820,12 +3820,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);
@@ -3838,25 +3838,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);
 
@@ -3864,11 +3864,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);
@@ -3876,12 +3876,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);
 
@@ -3891,9 +3891,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;
@@ -3901,13 +3901,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);
 
@@ -3921,23 +3921,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);
@@ -3945,23 +3945,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;
@@ -3971,14 +3971,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);
@@ -3994,17 +3994,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),
@@ -4018,36 +4018,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");
@@ -4057,19 +4057,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");
@@ -4078,23 +4078,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);
@@ -4122,10 +4122,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);
@@ -4139,14 +4139,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);
@@ -4156,7 +4156,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);
@@ -4164,21 +4164,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);
@@ -4187,7 +4187,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);
@@ -4195,21 +4195,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);
@@ -4219,21 +4219,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);
@@ -4243,7 +4243,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);
@@ -4251,24 +4251,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);
@@ -4277,28 +4277,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);
@@ -4326,7 +4326,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))
@@ -4343,32 +4343,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");
@@ -4378,19 +4378,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");
@@ -4399,23 +4399,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");
 
@@ -4423,24 +4423,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");
@@ -4452,27 +4452,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");
 
@@ -4483,25 +4483,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);
@@ -4519,16 +4519,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();
 }
@@ -4549,20 +4549,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);
@@ -4597,7 +4597,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);
@@ -4605,29 +4605,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)
@@ -4637,7 +4637,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);
@@ -4657,9 +4657,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");
 
@@ -4704,15 +4704,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;
@@ -4721,13 +4721,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);
@@ -4877,153 +4877,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;
@@ -5033,85 +5033,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);
@@ -5119,13 +5119,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);
 }
@@ -5386,25 +5386,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);
@@ -5415,95 +5415,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);
     }
@@ -5515,12 +5515,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);
@@ -5546,23 +5546,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);
@@ -5578,21 +5578,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;
 }
@@ -5616,16 +5616,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");
 
@@ -5635,10 +5635,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");
 
@@ -5649,12 +5649,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");
 
@@ -5665,14 +5665,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");
@@ -5683,10 +5683,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);
@@ -5694,7 +5694,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");
@@ -5852,46 +5852,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);
     }
 
@@ -5899,7 +5899,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);
 }
 
@@ -5921,7 +5921,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;
@@ -5953,31 +5953,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());
@@ -5986,10 +5986,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
@@ -5997,9 +5997,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());
@@ -6008,7 +6008,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. */
@@ -6018,15 +6018,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));
@@ -6088,14 +6088,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");
@@ -6114,20 +6114,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);
@@ -6287,23 +6287,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++)
@@ -6317,7 +6317,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);
 
@@ -6375,7 +6375,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))
@@ -6418,7 +6418,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;
@@ -6426,15 +6426,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);
         }
@@ -6511,16 +6511,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++)
         {
@@ -6539,7 +6539,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;
@@ -6547,7 +6547,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;
@@ -6559,7 +6559,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);
@@ -6785,7 +6785,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)))
     {
@@ -6804,12 +6804,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)
     {
@@ -6841,14 +6841,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))
@@ -6860,11 +6860,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);
@@ -6872,13 +6872,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
@@ -6889,10 +6889,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);
@@ -6904,10 +6904,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));
@@ -6923,12 +6923,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;
@@ -6936,24 +6936,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);
 }
 
@@ -7078,7 +7078,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);
@@ -7088,23 +7088,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);
 }
 
@@ -7193,7 +7193,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)))
     {
@@ -7229,21 +7229,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);
     }
@@ -7252,7 +7252,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);
 }
 
@@ -7304,11 +7304,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);
@@ -7318,34 +7318,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);
 
@@ -7394,7 +7394,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)
     {
@@ -7417,93 +7417,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);
@@ -7512,19 +7512,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
@@ -7534,59 +7534,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);
@@ -7595,7 +7595,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);
 }
 
@@ -7634,7 +7634,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;
@@ -7649,73 +7649,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. */
@@ -7723,56 +7723,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.
      *
@@ -7781,27 +7781,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;
@@ -7809,13 +7809,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;
@@ -7826,11 +7826,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);
@@ -7838,12 +7838,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);
 
@@ -7856,7 +7856,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))
     {
@@ -7867,13 +7867,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);
     }
 
@@ -7886,7 +7886,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)
     {
@@ -7894,11 +7894,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;
@@ -7907,7 +7907,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;
@@ -7916,13 +7916,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);
         }
 
@@ -7933,12 +7933,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);
 
@@ -7949,7 +7949,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);
@@ -7964,10 +7964,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;
@@ -7975,7 +7975,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;
@@ -7985,7 +7985,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);
 
@@ -8012,7 +8012,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",
@@ -8026,17 +8026,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);
         }
 
@@ -8045,7 +8045,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);
 }
 
@@ -8069,7 +8069,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;
@@ -8083,17 +8083,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);
@@ -8102,10 +8102,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;
@@ -8113,40 +8113,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);
 }
 
@@ -8164,7 +8164,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;
@@ -8178,10 +8178,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);
 }
 
@@ -8209,7 +8209,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);
@@ -8217,22 +8217,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
@@ -8245,99 +8245,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);
 }
 
@@ -8367,7 +8367,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);
@@ -8377,14 +8377,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);
@@ -8403,20 +8403,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);
 
@@ -8427,27 +8427,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);
@@ -8456,7 +8456,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));
@@ -8464,7 +8464,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);
@@ -8473,7 +8473,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);
@@ -8482,7 +8482,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));
@@ -8492,33 +8492,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);
@@ -8533,7 +8533,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);
@@ -8546,26 +8546,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);
@@ -8586,72 +8586,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);
 }
 
@@ -8687,7 +8687,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;
@@ -8695,27 +8695,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
@@ -8724,85 +8724,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);
@@ -8812,14 +8812,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);
@@ -8828,7 +8828,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);
 }
 
@@ -8911,7 +8911,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;
     }
 
@@ -8921,9 +8921,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);
@@ -8938,7 +8938,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);
@@ -8952,7 +8952,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);
@@ -8967,18 +8967,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);
@@ -9103,7 +9103,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);
 
@@ -9126,33 +9126,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);
@@ -9162,7 +9162,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);
 }
 
@@ -9202,12 +9202,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");
@@ -9227,18 +9227,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);
@@ -9246,31 +9246,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);
 
@@ -9284,7 +9284,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);
 }
 
@@ -9309,12 +9309,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");
@@ -9333,28 +9333,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);
 
@@ -9363,46 +9363,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);
 }
 
@@ -9433,7 +9433,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));
@@ -9443,14 +9443,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);
@@ -9462,11 +9462,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);
@@ -9482,34 +9482,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))
     {
@@ -9520,7 +9520,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]);
         }
     }
@@ -9528,10 +9528,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.
@@ -9542,7 +9542,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);
@@ -9551,7 +9551,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);
 }
 
@@ -9613,95 +9613,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);
 }
 
@@ -9747,7 +9747,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);
@@ -9759,7 +9759,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));
@@ -9771,7 +9771,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,
@@ -9784,9 +9784,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",
@@ -9813,7 +9813,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);
@@ -9824,9 +9824,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);
@@ -9836,11 +9836,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++)
@@ -9857,13 +9857,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");
@@ -9872,35 +9872,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),
@@ -9930,7 +9930,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);
@@ -9939,12 +9939,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++)
@@ -9961,7 +9961,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
@@ -9977,14 +9977,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++)
@@ -10001,24 +10001,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);
 }
 
@@ -10057,18 +10057,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",
@@ -10087,11 +10087,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",
@@ -10110,13 +10110,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))
         {
@@ -10125,7 +10125,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",
@@ -10137,7 +10137,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);
     }
@@ -10156,20 +10156,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);
 }
 
@@ -10199,7 +10199,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);
@@ -10207,32 +10207,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);
@@ -10259,7 +10259,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);
@@ -10267,7 +10267,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);
@@ -10276,7 +10276,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);
@@ -10297,93 +10297,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
@@ -10394,76 +10394,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);
@@ -10473,116 +10473,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)
@@ -10590,7 +10590,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);
 }
@@ -10608,7 +10608,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);
@@ -10617,36 +10617,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);
 }
 
@@ -10708,23 +10708,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.
@@ -10746,53 +10746,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. */
@@ -10802,117 +10802,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. */
@@ -10930,52 +10930,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. */
@@ -10993,51 +10993,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). */
@@ -11055,65 +11055,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);
 }
 
@@ -11224,7 +11224,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");
@@ -11232,43 +11232,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);
@@ -11283,19 +11283,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,
@@ -11303,15 +11303,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++)
             {
@@ -11324,7 +11324,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);
                 }
             }
@@ -11340,7 +11340,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);
 }
 
@@ -11531,9 +11531,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);
@@ -11547,13 +11547,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'))
@@ -11566,7 +11566,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");
@@ -11621,16 +11621,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)
@@ -11638,19 +11638,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)
@@ -11658,22 +11658,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)
@@ -11681,19 +11681,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)
@@ -11701,13 +11701,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);
@@ -11731,78 +11731,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);
@@ -11819,54 +11819,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);
@@ -11874,7 +11874,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);
 }
 
@@ -11919,13 +11919,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);
@@ -11941,14 +11941,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;
@@ -11956,12 +11956,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;
@@ -11969,83 +11969,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);
@@ -12057,7 +12057,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);
 }
 
@@ -12144,12 +12144,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
@@ -12162,24 +12162,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);
@@ -12204,9 +12204,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
@@ -12224,17 +12224,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:
@@ -12252,21 +12252,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:
@@ -12284,11 +12284,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)
@@ -12313,52 +12313,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);
@@ -12373,7 +12373,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);
 }
 
@@ -12391,7 +12391,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);
@@ -12410,85 +12410,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);
 }
 
@@ -12554,16 +12554,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);
@@ -12571,21 +12571,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. */
@@ -12593,19 +12593,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 */
@@ -12615,9 +12615,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);
     }
 
@@ -12627,7 +12627,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);
 }
 
@@ -12688,12 +12688,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))
     {
@@ -12720,13 +12720,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)
         {
@@ -12736,11 +12736,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)
@@ -12751,37 +12751,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);
     }
@@ -12806,7 +12806,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'))))
     {
@@ -12817,17 +12817,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;
@@ -12848,7 +12848,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
@@ -12856,12 +12856,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'))))
     {
@@ -12875,14 +12875,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]);
@@ -12892,7 +12892,7 @@ static void test_yv12_overlay(void)
         todo_wine 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);
@@ -12928,7 +12928,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'))))
     {
@@ -12941,21 +12941,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));
@@ -12972,18 +12972,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);
@@ -13008,7 +13008,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'))))
     {
@@ -13021,15 +13021,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())
@@ -13042,48 +13042,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)
@@ -13135,12 +13135,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);
@@ -13149,37 +13149,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);
 }
 
@@ -13220,7 +13220,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);
@@ -13240,9 +13240,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);
@@ -13262,23 +13262,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);
 }
 
@@ -13314,15 +13314,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));
@@ -13332,7 +13332,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);
@@ -13340,7 +13340,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);
@@ -13355,37 +13355,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));
@@ -13395,14 +13395,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);
@@ -13410,9 +13410,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);
 }
@@ -13451,61 +13451,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);
 }
 
@@ -13577,11 +13577,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)
@@ -13600,7 +13600,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;
             }
         }
@@ -13609,9 +13609,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))
         {
@@ -13622,10 +13622,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);
@@ -13649,11 +13649,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);
@@ -13662,17 +13662,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)
@@ -13681,20 +13681,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
         {
@@ -13710,147 +13710,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);
@@ -13891,77 +13891,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);
 }
 
@@ -14025,20 +14025,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));
@@ -14054,134 +14054,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);
 }
 
@@ -14308,11 +14308,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);
@@ -14324,8 +14324,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)
     {
@@ -14340,19 +14340,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)
     {
@@ -14369,12 +14369,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[] =
@@ -14391,8 +14391,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[] =
@@ -14405,7 +14405,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
@@ -14430,8 +14430,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[] =
@@ -14441,19 +14441,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[] =
@@ -14463,7 +14463,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;
@@ -14472,11 +14472,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[] =
@@ -14486,7 +14486,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.
@@ -14497,51 +14497,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]);
@@ -14551,21 +14551,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.
      *
@@ -14581,20 +14581,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)
     {
@@ -14613,48 +14613,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);
@@ -14663,8 +14663,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;
@@ -14676,38 +14676,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);
@@ -14722,12 +14722,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[] =
@@ -14742,40 +14742,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;
@@ -14788,14 +14788,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[] =
@@ -14809,14 +14809,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);
 }
 
@@ -14838,14 +14838,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)))
@@ -14858,10 +14858,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));
@@ -14870,14 +14870,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);
 
@@ -14888,17 +14888,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);
 }
 
@@ -14956,7 +14956,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)
     {
@@ -14972,9 +14972,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)
@@ -14983,21 +14983,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);
         }
 
@@ -15014,22 +15014,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);
             }
@@ -15040,22 +15040,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);
             }
@@ -15066,21 +15066,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);
             }
@@ -15099,17 +15099,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)
@@ -15128,7 +15128,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);
@@ -15138,59 +15138,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);
 
@@ -15200,20 +15200,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);
@@ -15240,7 +15240,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);
@@ -15254,16 +15254,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;
@@ -15271,33 +15271,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
@@ -15312,69 +15312,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);
@@ -15394,18 +15394,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. */
@@ -15416,11 +15416,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);
@@ -15430,7 +15430,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. */
@@ -15439,77 +15439,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. */
@@ -15520,19 +15520,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. */
@@ -15542,28 +15542,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. */
@@ -15573,19 +15573,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. */
@@ -15595,38 +15595,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. */
@@ -15636,55 +15636,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);
 }
 
@@ -15711,7 +15711,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);
@@ -15721,33 +15721,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);
 }
 
@@ -15826,7 +15826,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);
 
@@ -15837,17 +15837,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);
 }
 
@@ -15872,9 +15872,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));
@@ -15884,25 +15884,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);
 }
 
@@ -15923,24 +15923,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);
 }
 
@@ -16016,13 +16016,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;
 
@@ -16034,25 +16034,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);
 
@@ -16060,25 +16060,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");
@@ -16094,32 +16094,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);
@@ -16133,7 +16133,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);
 }
 
@@ -16192,19 +16192,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)
@@ -16231,19 +16231,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)
@@ -16254,7 +16254,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;
@@ -16268,13 +16268,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);
             }
         }
 
@@ -16282,7 +16282,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);
     }
 
@@ -16293,7 +16293,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);
 }
 
@@ -16320,19 +16320,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;
@@ -16349,19 +16349,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;
@@ -16369,123 +16369,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. */
@@ -16497,7 +16497,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);
 }
 
@@ -16555,12 +16555,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");
     }
@@ -16585,18 +16585,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);
@@ -16606,52 +16606,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]);
@@ -16661,7 +16661,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));
@@ -16671,15 +16671,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. */
@@ -16688,13 +16688,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;
@@ -16705,15 +16705,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]);
 
@@ -16725,7 +16725,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);
@@ -16791,21 +16791,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));
@@ -16824,23 +16824,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(SUCCEEDED(hr), "Failed to create render target, hr %#x (i %u).\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to create render target, hr %#lx (i %u).\n", hr, i);
 
             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(SUCCEEDED(hr), "Failed to create depth buffer, hr %#x (i %u).\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#lx (i %u).\n", hr, i);
             hr = IDirectDrawSurface4_AddAttachedSurface(rt, ds);
-            ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x (i %u).\n", hr, i);
+            ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#lx (i %u).\n", hr, i);
 
             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);
         }
         else
         {
             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);
         }
 
         full_viewport = create_viewport(device, 0, 0, rt_sizes[i].x, rt_sizes[i].y);
@@ -16855,12 +16855,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(SUCCEEDED(hr), "Failed to clear viewport, hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#lx (i %u, j %u).\n", hr, i, j);
 
             hr = IDirect3D3_CreateViewport(d3d, &viewport, NULL);
-            ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Failed to create viewport, hr %#lx (i %u, j %u).\n", hr, i, j);
             hr = IDirect3DViewport3_SetViewport2(viewport, NULL);
-            ok(hr == E_INVALIDARG, "Setting NULL viewport data returned unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(hr == E_INVALIDARG, "Setting NULL viewport data returned unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
             memset(&vp, 0, sizeof(vp));
             vp.dwSize = sizeof(vp);
             vp.dwX = tests[j].vp.dwX;
@@ -16875,18 +16875,18 @@ static void test_viewport(void)
             vp.dvMaxZ = 1.0f;
             hr = IDirect3DViewport3_SetViewport2(viewport, &vp);
             ok(hr == D3DERR_VIEWPORTHASNODEVICE,
-                    "Setting viewport data returned unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+                    "Setting viewport data returned unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
             hr = IDirect3DDevice3_AddViewport(device, viewport);
-            ok(SUCCEEDED(hr), "Failed to add viewport, hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Failed to add viewport, hr %#lx (i %u, j %u).\n", hr, i, j);
             hr = IDirect3DViewport3_SetViewport2(viewport, &vp);
             if (expected_failure)
                 ok(hr == E_INVALIDARG,
-                        "Setting viewport data returned unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+                        "Setting viewport data returned unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
             else
-                ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x (i %u, j %u).\n", hr, i, j);
+                ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#lx (i %u, j %u).\n", hr, i, j);
 
             hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
-            ok(SUCCEEDED(hr), "Failed to set the viewport, hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Failed to set the viewport, hr %#lx (i %u, j %u).\n", hr, i, j);
             if (expected_failure)
             {
                 destroy_viewport(device, viewport);
@@ -16894,11 +16894,11 @@ static void test_viewport(void)
             }
 
             hr = IDirect3DDevice3_BeginScene(device);
-            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Failed to begin scene, hr %#lx (i %u, j %u).\n", hr, i, j);
             hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, 0);
-            ok(SUCCEEDED(hr), "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Got unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
             hr = IDirect3DDevice3_EndScene(device);
-            ok(SUCCEEDED(hr), "Failed to end scene, hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx (i %u, j %u).\n", hr, i, j);
 
             check_rect(rt, tests[j].expected_rect, tests[j].message);
 
@@ -16908,14 +16908,14 @@ 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);
     }
 
     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);
@@ -16977,48 +16977,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)
     {
@@ -17031,21 +17031,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);
         }
     }
 
@@ -17072,7 +17072,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);
@@ -17088,9 +17088,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;
     }
 
@@ -17115,14 +17115,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");
@@ -17178,57 +17178,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);
@@ -17244,22 +17244,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);
@@ -17268,7 +17268,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);
 }
 
@@ -17286,38 +17286,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);
@@ -17325,40 +17325,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);
 }
 
@@ -17416,66 +17416,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);
 }
 
@@ -17496,24 +17496,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;
@@ -17521,50 +17521,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.
@@ -17572,11 +17572,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);
@@ -17592,7 +17592,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);
     }
 
@@ -17600,10 +17600,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. */
@@ -17616,33 +17616,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);
 }
 
@@ -17695,35 +17695,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));
@@ -17731,27 +17731,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));
@@ -17759,19 +17759,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);
 }
@@ -17789,7 +17789,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);
@@ -17802,25 +17802,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);
 }
 
@@ -18022,11 +18022,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");
 
@@ -18064,17 +18064,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)
             {
@@ -18083,7 +18083,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))
@@ -18091,17 +18091,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)
@@ -18129,7 +18129,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);
@@ -18138,7 +18138,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);
 }
 
@@ -18192,13 +18192,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);
@@ -18206,87 +18206,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));
 
@@ -18313,10 +18313,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));
@@ -18327,9 +18327,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));
@@ -18337,7 +18337,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,
@@ -18346,15 +18346,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));
@@ -18362,25 +18362,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));
 
@@ -18411,14 +18411,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);
@@ -18445,41 +18445,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");
@@ -18488,17 +18488,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:
@@ -18552,15 +18552,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);
@@ -18570,39 +18570,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);
@@ -18611,7 +18611,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);
 }
 
@@ -18962,14 +18962,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);
@@ -18984,7 +18984,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. */
@@ -18993,7 +18993,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;
@@ -19001,14 +19001,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)
     {
@@ -19017,17 +19017,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++)
             {
@@ -19065,7 +19065,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);
                 }
             }
@@ -19079,7 +19079,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 84789e8f177..17d20892b3c 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, c) check_rect_(__LINE__, a, b, c)
@@ -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, "%s: Pixel (%d, %d) has color %08x, expected %08x.\n",
+                    ok_(__FILE__, line)(color == expected, "%s: Pixel (%ld, %ld) has color %08lx, expected %08lx.\n",
                             message, 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)
         todo_wine 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);
@@ -16217,26 +16217,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));
@@ -16255,54 +16255,54 @@ 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 (i %u).\n", hr, i);
+            ok(hr == DD_OK, "Got unexpected hr %#lx (i %u).\n", hr, i);
 
             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 (i %u).\n", hr, i);
+            ok(hr == DD_OK, "Got unexpected hr %#lx (i %u).\n", hr, i);
             hr = IDirectDrawSurface7_AddAttachedSurface(rt, ds);
-            ok(hr == DD_OK, "Got unexpected hr %#x (i %u).\n", hr, i);
+            ok(hr == DD_OK, "Got unexpected hr %#lx (i %u).\n", hr, i);
 
             hr = IDirect3DDevice7_SetRenderTarget(device, rt, 0);
-            ok(hr == DD_OK, "Got unexpected hr %#x (i %u).\n", hr, i);
+            ok(hr == DD_OK, "Got unexpected hr %#lx (i %u).\n", hr, i);
         }
         else
         {
             hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
-            ok(hr == DD_OK, "Got unexpected hr %#x (i %u).\n", hr, i);
+            ok(hr == DD_OK, "Got unexpected hr %#lx (i %u).\n", hr, i);
         }
 
         for (j = 0; j < ARRAY_SIZE(tests); ++j)
         {
             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 (i %u, j %u).\n", hr, i, j);
+            ok(hr == DD_OK, "Got unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
             hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZFUNC, D3DCMP_GREATER);
-            ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(hr == DD_OK, "Got unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
 
             hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, !i);
-            ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(hr == DD_OK, "Got unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
 
             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 (i %u, j %u).\n", hr, i, j);
+                ok(hr == E_INVALIDARG, "Got unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
                 continue;
             }
             else
             {
-                ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+                ok(hr == DD_OK, "Got unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
             }
 
             hr = IDirect3DDevice7_BeginScene(device);
-            ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(hr == DD_OK, "Got unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
             hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, 0);
-            ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(hr == DD_OK, "Got unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
             hr = IDirect3DDevice7_EndScene(device);
-            ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+            ok(hr == DD_OK, "Got unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
 
             check_rect(rt, tests[j].expected_rect, tests[j].message);
 
@@ -16310,29 +16310,29 @@ 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 (i %u, j %u).\n", hr, i, j);
+                ok(hr == DD_OK, "Got unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
                 hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZFUNC, D3DCMP_LESS);
-                ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+                ok(hr == DD_OK, "Got unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
 
                 hr = IDirect3DDevice7_BeginScene(device);
-                ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+                ok(hr == DD_OK, "Got unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
                 hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, 0);
-                ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+                ok(hr == DD_OK, "Got unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
                 hr = IDirect3DDevice7_EndScene(device);
-                ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
+                ok(hr == DD_OK, "Got unexpected hr %#lx (i %u, j %u).\n", hr, i, j);
 
                 check_rect(rt, tests[j].expected_rect, tests[j].message);
             }
         }
 
         hr = IDirectDrawSurface7_DeleteAttachedSurface(rt, 0, ds);
-        ok(hr == DD_OK, "Got unexpected hr %#x (i %u).\n", hr, i);
+        ok(hr == DD_OK, "Got unexpected hr %#lx (i %u).\n", hr, i);
         IDirectDrawSurface7_Release(ds);
         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);
     IDirectDraw7_Release(ddraw);
     DestroyWindow(window);
 }
@@ -16347,7 +16347,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)
     {
@@ -16377,7 +16377,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;
 }
@@ -16446,14 +16446,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)
@@ -16490,7 +16490,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)
@@ -16507,7 +16507,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)
@@ -16527,9 +16527,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);
             }
 
@@ -16538,7 +16538,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)
                 {
@@ -16555,7 +16555,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);
@@ -16584,9 +16584,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);
             }
 
@@ -16596,7 +16596,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);
@@ -16619,7 +16619,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))
         {
@@ -16743,46 +16743,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);
 
@@ -16793,20 +16793,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);
@@ -16814,7 +16814,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);
 }
 
@@ -16904,50 +16904,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);
 }
 
@@ -16961,9 +16961,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;
     }
 
@@ -16988,14 +16988,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");
@@ -17044,53 +17044,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);
@@ -17106,19 +17106,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);
@@ -17126,7 +17126,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);
 }
 
@@ -17144,38 +17144,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);
@@ -17183,40 +17183,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);
 }
 
@@ -17274,52 +17274,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);
 }
 
@@ -17375,61 +17375,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);
 }
 
@@ -17450,24 +17450,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;
@@ -17475,50 +17475,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.
@@ -17526,11 +17526,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);
@@ -17546,7 +17546,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);
     }
 
@@ -17554,10 +17554,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. */
@@ -17570,33 +17570,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);
 }
 
@@ -17618,56 +17618,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);
 }
 
@@ -17719,77 +17719,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);
 }
@@ -17807,7 +17807,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);
@@ -17820,25 +17820,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);
 }
 
@@ -18040,11 +18040,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");
 
@@ -18082,17 +18082,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)
             {
@@ -18101,7 +18101,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))
@@ -18109,17 +18109,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)
@@ -18147,7 +18147,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);
@@ -18156,7 +18156,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);
 }
 
@@ -18250,11 +18250,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);
@@ -18301,22 +18301,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);
@@ -18334,7 +18334,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);
@@ -18347,15 +18347,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);
@@ -18364,12 +18364,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;
@@ -18395,7 +18395,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);
 }
 
@@ -18457,13 +18457,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);
@@ -18471,87 +18471,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));
 
@@ -18578,10 +18578,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));
@@ -18592,9 +18592,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));
@@ -18602,7 +18602,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,
@@ -18611,15 +18611,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));
@@ -18627,25 +18627,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));
 
@@ -18676,14 +18676,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);
@@ -18710,41 +18710,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");
@@ -18753,17 +18753,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:
@@ -18808,11 +18808,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);
@@ -18822,47 +18822,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);
 }
 
@@ -19212,11 +19212,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);
@@ -19231,12 +19231,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)
     {
@@ -19245,19 +19245,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++)
             {
@@ -19295,7 +19295,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);
                 }
             }
@@ -19307,7 +19307,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);
 }
 
@@ -19352,7 +19352,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 638ff374012..22d297dc03d 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 59902b43761..5a3ad28452b 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 07673ab66e9..ce04f406bf1 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 4d6b198e323..9572cd45359 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