[PATCH 22/27] dlls/kernel32/tests: enable compilation with long types

Eric Pouech eric.pouech at gmail.com
Mon Feb 28 01:27:27 CST 2022


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

---
 dlls/kernel32/tests/Makefile.in  |    1 
 dlls/kernel32/tests/actctx.c     |  604 ++++++------
 dlls/kernel32/tests/atom.c       |   32 -
 dlls/kernel32/tests/change.c     |  158 ++-
 dlls/kernel32/tests/codepage.c   |  186 ++--
 dlls/kernel32/tests/comm.c       |  352 ++++---
 dlls/kernel32/tests/console.c    |  880 +++++++++---------
 dlls/kernel32/tests/debugger.c   |  510 +++++------
 dlls/kernel32/tests/directory.c  |  104 +-
 dlls/kernel32/tests/drive.c      |   36 -
 dlls/kernel32/tests/environ.c    |  212 ++--
 dlls/kernel32/tests/fiber.c      |  137 +--
 dlls/kernel32/tests/file.c       | 1548 ++++++++++++++++----------------
 dlls/kernel32/tests/format_msg.c |  546 ++++++-----
 dlls/kernel32/tests/heap.c       |  178 ++--
 dlls/kernel32/tests/loader.c     |  968 ++++++++++----------
 dlls/kernel32/tests/locale.c     |  858 +++++++++---------
 dlls/kernel32/tests/mailslot.c   |   52 +
 dlls/kernel32/tests/module.c     |  284 +++---
 dlls/kernel32/tests/path.c       |  400 ++++----
 dlls/kernel32/tests/pipe.c       |  948 ++++++++++----------
 dlls/kernel32/tests/power.c      |   10 
 dlls/kernel32/tests/process.c    |  938 ++++++++++---------
 dlls/kernel32/tests/profile.c    |  346 ++++---
 dlls/kernel32/tests/resource.c   |   46 -
 dlls/kernel32/tests/sync.c       |  462 +++++-----
 dlls/kernel32/tests/thread.c     |  384 ++++----
 dlls/kernel32/tests/time.c       |  138 +--
 dlls/kernel32/tests/timer.c      |   28 -
 dlls/kernel32/tests/toolhelp.c   |   16 
 dlls/kernel32/tests/version.c    |   80 +-
 dlls/kernel32/tests/virtual.c    | 1838 +++++++++++++++++++-------------------
 dlls/kernel32/tests/volume.c     |  422 ++++-----
 33 files changed, 6851 insertions(+), 6851 deletions(-)

diff --git a/dlls/kernel32/tests/Makefile.in b/dlls/kernel32/tests/Makefile.in
index db106ab9fc9..e9516603ce9 100644
--- a/dlls/kernel32/tests/Makefile.in
+++ b/dlls/kernel32/tests/Makefile.in
@@ -1,4 +1,3 @@
-EXTRADEFS = -DWINE_NO_LONG_TYPES
 TESTDLL   = kernel32.dll
 IMPORTS   = user32 advapi32
 
diff --git a/dlls/kernel32/tests/actctx.c b/dlls/kernel32/tests/actctx.c
index c26eb08f306..8f925b0500f 100644
--- a/dlls/kernel32/tests/actctx.c
+++ b/dlls/kernel32/tests/actctx.c
@@ -562,7 +562,7 @@ static BOOL create_manifest_file(const char *filename, const char *manifest, int
 
     file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
                        FILE_ATTRIBUTE_NORMAL, NULL);
-    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %lu\n", GetLastError());
     if(file == INVALID_HANDLE_VALUE)
         return FALSE;
     WriteFile(file, manifest, manifest_len, &size, NULL);
@@ -574,7 +574,7 @@ static BOOL create_manifest_file(const char *filename, const char *manifest, int
         GetFullPathNameW(path, ARRAY_SIZE(depmanifest_path), depmanifest_path, NULL);
         file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
                            FILE_ATTRIBUTE_NORMAL, NULL);
-        ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
+        ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %lu\n", GetLastError());
         if(file == INVALID_HANDLE_VALUE)
             return FALSE;
         WriteFile(file, depmanifest, strlen(depmanifest), &size, NULL);
@@ -651,8 +651,8 @@ static void test_detailed_info(HANDLE handle, const detailed_info_t *exinfo, int
         b = QueryActCtxW(0, handle, NULL, ActivationContextDetailedInformation, &detailed_info_tmp,
                 sizeof(detailed_info_tmp), &size);
         ok_(__FILE__, line)(!b, "QueryActCtx succeeded\n");
-        ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError());
-        ok_(__FILE__, line)(size == exsize, "size=%ld, expected %ld\n", size, exsize);
+        ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %lu\n", GetLastError());
+        ok_(__FILE__, line)(size == exsize, "size=%Id, expected %Id\n", size, exsize);
     }else {
         size = sizeof(ACTIVATION_CONTEXT_DETAILED_INFORMATION);
     }
@@ -660,35 +660,35 @@ static void test_detailed_info(HANDLE handle, const detailed_info_t *exinfo, int
     detailed_info = HeapAlloc(GetProcessHeap(), 0, size);
     memset(detailed_info, 0xfe, size);
     b = QueryActCtxW(0, handle, NULL, ActivationContextDetailedInformation, detailed_info, size, &retsize);
-    ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError());
-    ok_(__FILE__, line)(retsize == exsize, "size=%ld, expected %ld\n", retsize, exsize);
+    ok_(__FILE__, line)(b, "QueryActCtx failed: %lu\n", GetLastError());
+    ok_(__FILE__, line)(retsize == exsize, "size=%Id, expected %Id\n", retsize, exsize);
 
-    ok_(__FILE__, line)(detailed_info->dwFlags == 0, "detailed_info->dwFlags=%x\n", detailed_info->dwFlags);
+    ok_(__FILE__, line)(detailed_info->dwFlags == 0, "detailed_info->dwFlags=%lx\n", detailed_info->dwFlags);
     ok_(__FILE__, line)(detailed_info->ulFormatVersion == exinfo->format_version,
-       "detailed_info->ulFormatVersion=%u, expected %u\n", detailed_info->ulFormatVersion,
+       "detailed_info->ulFormatVersion=%lu, expected %lu\n", detailed_info->ulFormatVersion,
        exinfo->format_version);
     ok_(__FILE__, line)(exinfo->assembly_cnt_min <= detailed_info->ulAssemblyCount &&
        detailed_info->ulAssemblyCount <= exinfo->assembly_cnt_max,
-       "detailed_info->ulAssemblyCount=%u, expected between %u and %u\n", detailed_info->ulAssemblyCount,
+       "detailed_info->ulAssemblyCount=%lu, expected between %lu and %lu\n", detailed_info->ulAssemblyCount,
        exinfo->assembly_cnt_min, exinfo->assembly_cnt_max);
     ok_(__FILE__, line)(detailed_info->ulRootManifestPathType == exinfo->root_manifest_type,
-       "detailed_info->ulRootManifestPathType=%u, expected %u\n",
+       "detailed_info->ulRootManifestPathType=%lu, expected %lu\n",
        detailed_info->ulRootManifestPathType, exinfo->root_manifest_type);
     ok_(__FILE__, line)(detailed_info->ulRootManifestPathChars ==
        (exinfo->root_manifest_path ? lstrlenW(exinfo->root_manifest_path) : 0),
-       "detailed_info->ulRootManifestPathChars=%u, expected %u\n",
+       "detailed_info->ulRootManifestPathChars=%lu, expected %u\n",
        detailed_info->ulRootManifestPathChars,
        exinfo->root_manifest_path ?lstrlenW(exinfo->root_manifest_path) : 0);
     ok_(__FILE__, line)(detailed_info->ulRootConfigurationPathType == exinfo->root_config_type,
-       "detailed_info->ulRootConfigurationPathType=%u, expected %u\n",
+       "detailed_info->ulRootConfigurationPathType=%lu, expected %lu\n",
        detailed_info->ulRootConfigurationPathType, exinfo->root_config_type);
     ok_(__FILE__, line)(detailed_info->ulRootConfigurationPathChars == 0,
-       "detailed_info->ulRootConfigurationPathChars=%d\n", detailed_info->ulRootConfigurationPathChars);
+       "detailed_info->ulRootConfigurationPathChars=%ld\n", detailed_info->ulRootConfigurationPathChars);
     ok_(__FILE__, line)(detailed_info->ulAppDirPathType == exinfo->app_dir_type,
-       "detailed_info->ulAppDirPathType=%u, expected %u\n", detailed_info->ulAppDirPathType,
+       "detailed_info->ulAppDirPathType=%lu, expected %lu\n", detailed_info->ulAppDirPathType,
        exinfo->app_dir_type);
     ok_(__FILE__, line)(detailed_info->ulAppDirPathChars == (exinfo->app_dir ? lstrlenW(exinfo->app_dir) : 0),
-       "detailed_info->ulAppDirPathChars=%u, expected %u\n",
+       "detailed_info->ulAppDirPathChars=%lu, expected %u\n",
        detailed_info->ulAppDirPathChars, exinfo->app_dir ? lstrlenW(exinfo->app_dir) : 0);
     if(exinfo->root_manifest_path) {
         ok_(__FILE__, line)(detailed_info->lpRootManifestPath != NULL, "detailed_info->lpRootManifestPath == NULL\n");
@@ -789,9 +789,9 @@ static void test_info_in_assembly(HANDLE handle, DWORD id, const info_in_assembl
     size = 0xdeadbeef;
     b = QueryActCtxW(0, handle, &id, AssemblyDetailedInformationInActivationContext, &info_tmp, sizeof(info_tmp), &size);
     ok_(__FILE__, line)(!b, "QueryActCtx succeeded\n");
-    ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError());
+    ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %lu\n", GetLastError());
 
-    ok_(__FILE__, line)(size >= exsize, "size=%lu, expected %lu\n", size, exsize);
+    ok_(__FILE__, line)(size >= exsize, "size=%Iu, expected %Iu\n", size, exsize);
 
     if (size == 0xdeadbeef)
     {
@@ -804,52 +804,52 @@ static void test_info_in_assembly(HANDLE handle, DWORD id, const info_in_assembl
 
     size = 0xdeadbeef;
     b = QueryActCtxW(0, handle, &id, AssemblyDetailedInformationInActivationContext, info, size, &size);
-    ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError());
+    ok_(__FILE__, line)(b, "QueryActCtx failed: %lu\n", GetLastError());
     if (!exinfo->manifest_path)
         exsize += info->ulManifestPathLength + sizeof(WCHAR);
     if (!exinfo->encoded_assembly_id)
         exsize += info->ulEncodedAssemblyIdentityLength + sizeof(WCHAR);
     if (exinfo->has_assembly_dir)
         exsize += info->ulAssemblyDirectoryNameLength + sizeof(WCHAR);
-    ok_(__FILE__, line)(size == exsize, "size=%lu, expected %lu\n", size, exsize);
+    ok_(__FILE__, line)(size == exsize, "size=%Iu, expected %Iu\n", size, exsize);
 
     if (0)  /* FIXME: flags meaning unknown */
     {
-        ok_(__FILE__, line)((info->ulFlags) == exinfo->flags, "info->ulFlags = %x, expected %x\n",
+        ok_(__FILE__, line)((info->ulFlags) == exinfo->flags, "info->ulFlags = %lx, expected %lx\n",
            info->ulFlags, exinfo->flags);
     }
     if(exinfo->encoded_assembly_id) {
         len = lstrlenW(exinfo->encoded_assembly_id)*sizeof(WCHAR);
         ok_(__FILE__, line)(info->ulEncodedAssemblyIdentityLength == len,
-           "info->ulEncodedAssemblyIdentityLength = %u, expected %u\n",
+           "info->ulEncodedAssemblyIdentityLength = %lu, expected %lu\n",
            info->ulEncodedAssemblyIdentityLength, len);
     } else {
         ok_(__FILE__, line)(info->ulEncodedAssemblyIdentityLength != 0,
            "info->ulEncodedAssemblyIdentityLength == 0\n");
     }
     ok_(__FILE__, line)(info->ulManifestPathType == ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE,
-       "info->ulManifestPathType = %x\n", info->ulManifestPathType);
+       "info->ulManifestPathType = %lx\n", info->ulManifestPathType);
     if(exinfo->manifest_path) {
         len = lstrlenW(exinfo->manifest_path)*sizeof(WCHAR);
-        ok_(__FILE__, line)(info->ulManifestPathLength == len, "info->ulManifestPathLength = %u, expected %u\n",
+        ok_(__FILE__, line)(info->ulManifestPathLength == len, "info->ulManifestPathLength = %lu, expected %lu\n",
            info->ulManifestPathLength, len);
     } else {
         ok_(__FILE__, line)(info->ulManifestPathLength != 0, "info->ulManifestPathLength == 0\n");
     }
 
     ok_(__FILE__, line)(info->ulPolicyPathType == ACTIVATION_CONTEXT_PATH_TYPE_NONE,
-       "info->ulPolicyPathType = %x\n", info->ulPolicyPathType);
+       "info->ulPolicyPathType = %lx\n", info->ulPolicyPathType);
     ok_(__FILE__, line)(info->ulPolicyPathLength == 0,
-       "info->ulPolicyPathLength = %u, expected 0\n", info->ulPolicyPathLength);
-    ok_(__FILE__, line)(info->ulMetadataSatelliteRosterIndex == 0, "info->ulMetadataSatelliteRosterIndex = %x\n",
+       "info->ulPolicyPathLength = %lu, expected 0\n", info->ulPolicyPathLength);
+    ok_(__FILE__, line)(info->ulMetadataSatelliteRosterIndex == 0, "info->ulMetadataSatelliteRosterIndex = %lx\n",
        info->ulMetadataSatelliteRosterIndex);
-    ok_(__FILE__, line)(info->ulManifestVersionMajor == 1,"info->ulManifestVersionMajor = %x\n",
+    ok_(__FILE__, line)(info->ulManifestVersionMajor == 1,"info->ulManifestVersionMajor = %lx\n",
        info->ulManifestVersionMajor);
-    ok_(__FILE__, line)(info->ulManifestVersionMinor == 0, "info->ulManifestVersionMinor = %x\n",
+    ok_(__FILE__, line)(info->ulManifestVersionMinor == 0, "info->ulManifestVersionMinor = %lx\n",
        info->ulManifestVersionMinor);
-    ok_(__FILE__, line)(info->ulPolicyVersionMajor == 0, "info->ulPolicyVersionMajor = %x\n",
+    ok_(__FILE__, line)(info->ulPolicyVersionMajor == 0, "info->ulPolicyVersionMajor = %lx\n",
        info->ulPolicyVersionMajor);
-    ok_(__FILE__, line)(info->ulPolicyVersionMinor == 0, "info->ulPolicyVersionMinor = %x\n",
+    ok_(__FILE__, line)(info->ulPolicyVersionMinor == 0, "info->ulPolicyVersionMinor = %lx\n",
        info->ulPolicyVersionMinor);
     if(exinfo->has_assembly_dir)
         ok_(__FILE__, line)(info->ulAssemblyDirectoryNameLength != 0,
@@ -899,8 +899,8 @@ static void test_file_info(HANDLE handle, ULONG assid, ULONG fileid, LPCWSTR fil
     b = QueryActCtxW(0, handle, &index, FileInformationInAssemblyOfAssemblyInActivationContext, &info_tmp,
                       sizeof(info_tmp), &size);
     ok_(__FILE__, line)(!b, "QueryActCtx succeeded\n");
-    ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %u\n", GetLastError());
-    ok_(__FILE__, line)(size == exsize, "size=%lu, expected %lu\n", size, exsize);
+    ok_(__FILE__, line)(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %lu\n", GetLastError());
+    ok_(__FILE__, line)(size == exsize, "size=%Iu, expected %Iu\n", size, exsize);
 
     if(size == 0xdeadbeef)
     {
@@ -912,14 +912,14 @@ static void test_file_info(HANDLE handle, ULONG assid, ULONG fileid, LPCWSTR fil
     memset(info, 0xfe, size);
 
     b = QueryActCtxW(0, handle, &index, FileInformationInAssemblyOfAssemblyInActivationContext, info, size, &size);
-    ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError());
-    ok_(__FILE__, line)(!size, "size=%lu, expected 0\n", size);
+    ok_(__FILE__, line)(b, "QueryActCtx failed: %lu\n", GetLastError());
+    ok_(__FILE__, line)(!size, "size=%Iu, expected 0\n", size);
 
-    ok_(__FILE__, line)(info->ulFlags == 2, "info->ulFlags=%x, expected 2\n", info->ulFlags);
+    ok_(__FILE__, line)(info->ulFlags == 2, "info->ulFlags=%lx, expected 2\n", info->ulFlags);
     ok_(__FILE__, line)(info->ulFilenameLength == lstrlenW(filename)*sizeof(WCHAR),
-       "info->ulFilenameLength=%u, expected %u*sizeof(WCHAR)\n",
+       "info->ulFilenameLength=%lu, expected %u*sizeof(WCHAR)\n",
        info->ulFilenameLength, lstrlenW(filename));
-    ok_(__FILE__, line)(info->ulPathLength == 0, "info->ulPathLength=%u\n", info->ulPathLength);
+    ok_(__FILE__, line)(info->ulPathLength == 0, "info->ulPathLength=%lu\n", info->ulPathLength);
     ok_(__FILE__, line)(info->lpFileName != NULL, "info->lpFileName == NULL\n");
     if(info->lpFileName)
         ok_(__FILE__, line)(!lstrcmpiW(info->lpFileName, filename), "unexpected info->lpFileName\n");
@@ -967,14 +967,14 @@ static void test_runlevel_info(HANDLE handle, const runlevel_info_t *exinfo, int
         return;
     }
 
-    ok_(__FILE__, line)(b, "QueryActCtx failed: %u\n", GetLastError());
-    ok_(__FILE__, line)(retsize == size, "size=%ld, expected %ld\n", retsize, size);
+    ok_(__FILE__, line)(b, "QueryActCtx failed: %lu\n", GetLastError());
+    ok_(__FILE__, line)(retsize == size, "size=%Id, expected %Id\n", retsize, size);
 
-    ok_(__FILE__, line)(runlevel_info.ulFlags == 0, "runlevel_info.ulFlags=%x\n", runlevel_info.ulFlags);
+    ok_(__FILE__, line)(runlevel_info.ulFlags == 0, "runlevel_info.ulFlags=%lx\n", runlevel_info.ulFlags);
     ok_(__FILE__, line)(runlevel_info.RunLevel == exinfo->run_level,
        "runlevel_info.RunLevel=%u, expected %u\n", runlevel_info.RunLevel, exinfo->run_level);
     ok_(__FILE__, line)(runlevel_info.UiAccess == exinfo->ui_access,
-       "runlevel_info.UiAccess=%u, expected %u\n", runlevel_info.UiAccess, exinfo->ui_access);
+       "runlevel_info.UiAccess=%lu, expected %lu\n", runlevel_info.UiAccess, exinfo->ui_access);
 }
 
 static HANDLE test_create(const char *file)
@@ -992,8 +992,8 @@ static HANDLE test_create(const char *file)
     /* to be tested outside of this helper, including last error */
     if (handle == INVALID_HANDLE_VALUE) return handle;
 
-    ok(actctx.cbSize == sizeof(actctx), "actctx.cbSize=%d\n", actctx.cbSize);
-    ok(actctx.dwFlags == 0, "actctx.dwFlags=%d\n", actctx.dwFlags);
+    ok(actctx.cbSize == sizeof(actctx), "actctx.cbSize=%ld\n", actctx.cbSize);
+    ok(actctx.dwFlags == 0, "actctx.dwFlags=%ld\n", actctx.dwFlags);
     ok(actctx.lpSource == path, "actctx.lpSource=%p\n", actctx.lpSource);
     ok(actctx.wProcessorArchitecture == 0,
        "actctx.wProcessorArchitecture=%d\n", actctx.wProcessorArchitecture);
@@ -1030,7 +1030,7 @@ static void test_create_and_fail(const char *manifest, const char *depmanifest,
             ok(handle == INVALID_HANDLE_VALUE, "Unexpected context handle %p.\n", handle);
 
         if (handle == INVALID_HANDLE_VALUE)
-            ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "Unexpected error %d.\n", GetLastError());
+            ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "Unexpected error %ld.\n", GetLastError());
     }
     if (handle != INVALID_HANDLE_VALUE) ReleaseActCtx( handle );
     DeleteFileA("bad.manifest");
@@ -1051,7 +1051,7 @@ static void test_create_wide_and_fail(const char *manifest, BOOL fBOM)
     create_wide_manifest("bad.manifest", manifest, fBOM, FALSE);
     handle = CreateActCtxW(&actctx);
     ok(handle == INVALID_HANDLE_VALUE, "handle != INVALID_HANDLE_VALUE\n");
-    ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "GetLastError == %u\n", GetLastError());
+    ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "GetLastError == %lu\n", GetLastError());
 
     if (handle != INVALID_HANDLE_VALUE) ReleaseActCtx( handle );
     DeleteFileA("bad.manifest");
@@ -1070,7 +1070,7 @@ static void test_create_fail(void)
 
     handle = CreateActCtxW(&actctx);
     ok(handle == INVALID_HANDLE_VALUE, "handle != INVALID_HANDLE_VALUE\n");
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError == %u\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError == %lu\n", GetLastError());
 
     trace("wrong_manifest1\n");
     test_create_and_fail(wrong_manifest1, NULL, 0, FALSE);
@@ -1203,34 +1203,34 @@ static void test_find_dll_redirection(HANDLE handle, LPCWSTR libname, ULONG exid
     data.cbSize = sizeof(data);
 
     ret = FindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, libname, &data);
-    ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError());
+    ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %lu\n", GetLastError());
     if (!ret) return;
 
-    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
-    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
+    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%lu\n", data.cbSize);
+    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%lu\n", data.ulDataFormatVersion);
     ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
-    ok_(__FILE__, line)(data.ulLength == offsetof( struct dllredirect_data, paths[0]), "data.ulLength=%u\n", data.ulLength);
+    ok_(__FILE__, line)(data.ulLength == offsetof( struct dllredirect_data, paths[0]), "data.ulLength=%lu\n", data.ulLength);
 
     if (data.lpData)
     {
         struct dllredirect_data *dlldata = (struct dllredirect_data*)data.lpData;
         ok_(__FILE__, line)(dlldata->size == offsetof( struct dllredirect_data, paths[dlldata->paths_count]),
-                            "got wrong size %d\n", dlldata->size);
+                            "got wrong size %ld\n", dlldata->size);
         ok_(__FILE__, line)(dlldata->flags == DLL_REDIRECT_PATH_OMITS_ASSEMBLY_ROOT,
-                            "got wrong flags value %x\n", dlldata->flags);
-        ok_(__FILE__, line)(dlldata->total_len == 0, "got wrong total len value %d\n", dlldata->total_len);
-        ok_(__FILE__, line)(dlldata->paths_count == 0, "got wrong paths count value %d\n", dlldata->paths_count);
-        ok_(__FILE__, line)(dlldata->paths_offset == 0, "got wrong paths offset value %d\n", dlldata->paths_offset);
+                            "got wrong flags value %lx\n", dlldata->flags);
+        ok_(__FILE__, line)(dlldata->total_len == 0, "got wrong total len value %ld\n", dlldata->total_len);
+        ok_(__FILE__, line)(dlldata->paths_count == 0, "got wrong paths count value %ld\n", dlldata->paths_count);
+        ok_(__FILE__, line)(dlldata->paths_offset == 0, "got wrong paths offset value %ld\n", dlldata->paths_offset);
     }
 
     ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
-    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
+    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%lu\n",
        data.ulSectionGlobalDataLength);
     ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
-    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
+    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%lu\n",
        data.ulSectionTotalLength);
     ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
-    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
+    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
        data.ulAssemblyRosterIndex, exid);
 
     memset(&data, 0xfe, sizeof(data));
@@ -1238,21 +1238,21 @@ static void test_find_dll_redirection(HANDLE handle, LPCWSTR libname, ULONG exid
 
     ret = FindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL,
             ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, libname, &data);
-    ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u\n", GetLastError());
+    ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %lu\n", GetLastError());
     if (!ret) return;
 
-    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
-    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
+    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%lu\n", data.cbSize);
+    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%lu\n", data.ulDataFormatVersion);
     ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
-    ok_(__FILE__, line)(data.ulLength == 20, "data.ulLength=%u\n", data.ulLength);
+    ok_(__FILE__, line)(data.ulLength == 20, "data.ulLength=%lu\n", data.ulLength);
     ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
-    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
+    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%lu\n",
        data.ulSectionGlobalDataLength);
     ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
-    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
+    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%lu\n",
        data.ulSectionTotalLength);
     ok_(__FILE__, line)(data.hActCtx == handle, "data.hActCtx=%p\n", data.hActCtx);
-    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
+    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
        data.ulAssemblyRosterIndex, exid);
 
     ReleaseActCtx(handle);
@@ -1269,19 +1269,19 @@ static void test_find_window_class(HANDLE handle, LPCWSTR clsname, ULONG exid, i
     data.cbSize = sizeof(data);
 
     ret = FindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, clsname, &data);
-    ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
+    ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %lu, class %s\n", GetLastError(),
         wine_dbgstr_w(clsname));
     if (!ret) return;
 
     header = (struct strsection_header*)data.lpSectionBase;
     wnddata = (struct wndclass_redirect_data*)data.lpData;
 
-    ok_(__FILE__, line)(header->magic == 0x64487353, "got wrong magic 0x%08x\n", header->magic);
-    ok_(__FILE__, line)(header->count > 0, "got count %d\n", header->count);
-    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
-    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
+    ok_(__FILE__, line)(header->magic == 0x64487353, "got wrong magic 0x%08lx\n", header->magic);
+    ok_(__FILE__, line)(header->count > 0, "got count %ld\n", header->count);
+    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%lu\n", data.cbSize);
+    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%lu\n", data.ulDataFormatVersion);
     ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
-    ok_(__FILE__, line)(wnddata->size == sizeof(*wnddata), "got %d for header size\n", wnddata->size);
+    ok_(__FILE__, line)(wnddata->size == sizeof(*wnddata), "got %ld for header size\n", wnddata->size);
     if (data.lpData && wnddata->size == sizeof(*wnddata))
     {
         static const WCHAR verW[] = {'6','.','5','.','4','.','3','!',0};
@@ -1289,10 +1289,10 @@ static void test_find_window_class(HANDLE handle, LPCWSTR clsname, ULONG exid, i
         WCHAR *ptr;
         ULONG len;
 
-        ok_(__FILE__, line)(wnddata->res == 0, "got reserved as %d\n", wnddata->res);
+        ok_(__FILE__, line)(wnddata->res == 0, "got reserved as %ld\n", wnddata->res);
         /* redirect class name (versioned or not) is stored just after header data */
-        ok_(__FILE__, line)(wnddata->name_offset == wnddata->size, "got name offset as %d\n", wnddata->name_offset);
-        ok_(__FILE__, line)(wnddata->module_len > 0, "got module name length as %d\n", wnddata->module_len);
+        ok_(__FILE__, line)(wnddata->name_offset == wnddata->size, "got name offset as %ld\n", wnddata->name_offset);
+        ok_(__FILE__, line)(wnddata->module_len > 0, "got module name length as %ld\n", wnddata->module_len);
 
         /* expected versioned name */
         lstrcpyW(buff, verW);
@@ -1300,11 +1300,11 @@ static void test_find_window_class(HANDLE handle, LPCWSTR clsname, ULONG exid, i
         ptr = (WCHAR*)((BYTE*)wnddata + wnddata->name_offset);
         ok_(__FILE__, line)(!lstrcmpW(ptr, buff), "got wrong class name %s, expected %s\n", wine_dbgstr_w(ptr), wine_dbgstr_w(buff));
         ok_(__FILE__, line)(lstrlenW(ptr)*sizeof(WCHAR) == wnddata->name_len,
-            "got wrong class name length %d, expected %d\n", wnddata->name_len, lstrlenW(ptr));
+            "got wrong class name length %ld, expected %d\n", wnddata->name_len, lstrlenW(ptr));
 
         /* data length is simply header length + string data length including nulls */
         len = wnddata->size + wnddata->name_len + wnddata->module_len + 2*sizeof(WCHAR);
-        ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len);
+        ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %ld, expected %ld\n", data.ulLength, len);
 
         if (data.ulSectionTotalLength > wnddata->module_offset)
         {
@@ -1318,13 +1318,13 @@ static void test_find_window_class(HANDLE handle, LPCWSTR clsname, ULONG exid, i
     }
 
     ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
-    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
+    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%lu\n",
        data.ulSectionGlobalDataLength);
     ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
-    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
+    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%lu\n",
        data.ulSectionTotalLength);
     ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
-    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
+    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
        data.ulAssemblyRosterIndex, exid);
 
     memset(&data, 0xfe, sizeof(data));
@@ -1332,21 +1332,21 @@ static void test_find_window_class(HANDLE handle, LPCWSTR clsname, ULONG exid, i
 
     ret = FindActCtxSectionStringW(FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL,
             ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, clsname, &data);
-    ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %u, class %s\n", GetLastError(),
+    ok_(__FILE__, line)(ret, "FindActCtxSectionStringW failed: %lu, class %s\n", GetLastError(),
         wine_dbgstr_w(clsname));
     if (!ret) return;
 
-    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
-    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
+    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%lu\n", data.cbSize);
+    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%lu\n", data.ulDataFormatVersion);
     ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
-    ok_(__FILE__, line)(data.ulLength > 0, "data.ulLength=%u\n", data.ulLength);
+    ok_(__FILE__, line)(data.ulLength > 0, "data.ulLength=%lu\n", data.ulLength);
     ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
-    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
+    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%lu\n",
        data.ulSectionGlobalDataLength);
     ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
-    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n", data.ulSectionTotalLength);
+    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%lu\n", data.ulSectionTotalLength);
     ok_(__FILE__, line)(data.hActCtx == handle, "data.hActCtx=%p\n", data.hActCtx);
-    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
+    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
        data.ulAssemblyRosterIndex, exid);
 
     ReleaseActCtx(handle);
@@ -1359,29 +1359,29 @@ static void test_find_string_fail(void)
 
     ret = FindActCtxSectionStringW(0, NULL, 100, testlib_dll, &data);
     ok(!ret, "FindActCtxSectionStringW succeeded\n");
-    ok(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND, "GetLastError()=%u\n", GetLastError());
+    ok(GetLastError() == ERROR_SXS_SECTION_NOT_FOUND, "GetLastError()=%lu\n", GetLastError());
 
     ret = FindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, testlib2_dll, &data);
     ok(!ret, "FindActCtxSectionStringW succeeded\n");
-    ok(GetLastError() == ERROR_SXS_KEY_NOT_FOUND, "GetLastError()=%u\n", GetLastError());
+    ok(GetLastError() == ERROR_SXS_KEY_NOT_FOUND, "GetLastError()=%lu\n", GetLastError());
 
     ret = FindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, testlib_dll, NULL);
     ok(!ret, "FindActCtxSectionStringW succeeded\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%lu\n", GetLastError());
 
     ret = FindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, NULL, &data);
     ok(!ret, "FindActCtxSectionStringW succeeded\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%lu\n", GetLastError());
 
     data.cbSize = 0;
     ret = FindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, testlib_dll, &data);
     ok(!ret, "FindActCtxSectionStringW succeeded\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%lu\n", GetLastError());
 
     data.cbSize = 35;
     ret = FindActCtxSectionStringW(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, testlib_dll, &data);
     ok(!ret, "FindActCtxSectionStringW succeeded\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%lu\n", GetLastError());
 }
 
 
@@ -1396,7 +1396,7 @@ static void test_basic_info(HANDLE handle, int line)
 
     ok_(__FILE__, line) (b,"ActivationContextBasicInformation failed\n");
     ok_(__FILE__, line) (size == sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION),"size mismatch\n");
-    ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags);
+    ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %lx\n",basic.dwFlags);
     ok_(__FILE__, line) (basic.hActCtx == handle, "unexpected handle\n");
 
     b = QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX | QUERY_ACTCTX_FLAG_NO_ADDREF, handle, NULL,
@@ -1407,14 +1407,14 @@ static void test_basic_info(HANDLE handle, int line)
         ok_(__FILE__, line) (!b,"ActivationContextBasicInformation succeeded\n");
         ok_(__FILE__, line) (size == 0,"size mismatch\n");
         ok_(__FILE__, line) (GetLastError() == ERROR_INVALID_PARAMETER, "Wrong last error\n");
-        ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags);
+        ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %lx\n",basic.dwFlags);
         ok_(__FILE__, line) (basic.hActCtx == handle, "unexpected handle\n");
     }
     else
     {
         ok_(__FILE__, line) (b,"ActivationContextBasicInformation failed\n");
         ok_(__FILE__, line) (size == sizeof(ACTIVATION_CONTEXT_BASIC_INFORMATION),"size mismatch\n");
-        ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %x\n",basic.dwFlags);
+        ok_(__FILE__, line) (basic.dwFlags == 0, "unexpected flags %lx\n",basic.dwFlags);
         ok_(__FILE__, line) (basic.hActCtx == handle, "unexpected handle\n");
     }
 }
@@ -1484,66 +1484,66 @@ static void test_find_com_redirection(HANDLE handle, const GUID *clsid, const GU
         skip("failed for guid %s\n", wine_dbgstr_guid(clsid));
         return;
     }
-    ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
+    ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %lu\n", GetLastError());
 
     comclass = (struct comclassredirect_data*)data.lpData;
 
-    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
-    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
+    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%lu\n", data.cbSize);
+    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%lu\n", data.ulDataFormatVersion);
     ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
-    ok_(__FILE__, line)(comclass->size == sizeof(*comclass), "got %d for header size\n", comclass->size);
+    ok_(__FILE__, line)(comclass->size == sizeof(*comclass), "got %ld for header size\n", comclass->size);
     if (data.lpData && comclass->size == sizeof(*comclass))
     {
         ULONG len, miscmask;
         WCHAR *ptr;
 
-        ok_(__FILE__, line)(comclass->model == ThreadingModel_Neutral, "got model %d\n", comclass->model);
+        ok_(__FILE__, line)(comclass->model == ThreadingModel_Neutral, "got model %ld\n", comclass->model);
         ok_(__FILE__, line)(IsEqualGUID(&comclass->clsid, clsid), "got wrong clsid %s\n", wine_dbgstr_guid(&comclass->clsid));
         ok_(__FILE__, line)(IsEqualGUID(&comclass->clsid2, clsid), "got wrong clsid2 %s\n", wine_dbgstr_guid(&comclass->clsid2));
         if (tlid)
             ok_(__FILE__, line)(IsEqualGUID(&comclass->tlid, tlid), "got wrong tlid %s\n", wine_dbgstr_guid(&comclass->tlid));
-        ok_(__FILE__, line)(comclass->name_len > 0, "got modulename len %d\n", comclass->name_len);
+        ok_(__FILE__, line)(comclass->name_len > 0, "got modulename len %ld\n", comclass->name_len);
 
         if (progid)
         {
             len = comclass->size + comclass->clrdata_len;
-            ok_(__FILE__, line)(comclass->progid_offset == len, "got progid offset %d, expected %d\n", comclass->progid_offset, len);
+            ok_(__FILE__, line)(comclass->progid_offset == len, "got progid offset %ld, expected %ld\n", comclass->progid_offset, len);
         }
         else
-            ok_(__FILE__, line)(comclass->progid_offset == 0, "got progid offset %d, expected 0\n", comclass->progid_offset);
+            ok_(__FILE__, line)(comclass->progid_offset == 0, "got progid offset %ld, expected 0\n", comclass->progid_offset);
 
         if (comclass->progid_offset)
         {
             ptr = (WCHAR*)((BYTE*)comclass + comclass->progid_offset);
             ok_(__FILE__, line)(!lstrcmpW(ptr, progid), "got wrong progid %s, expected %s\n", wine_dbgstr_w(ptr), wine_dbgstr_w(progid));
             ok_(__FILE__, line)(lstrlenW(progid)*sizeof(WCHAR) == comclass->progid_len,
-                "got progid name length %d\n", comclass->progid_len);
+                "got progid name length %ld\n", comclass->progid_len);
         }
 
         /* data length is simply header length + string data length including nulls */
         len = comclass->size + comclass->clrdata_len;
         if (comclass->progid_len) len += comclass->progid_len + sizeof(WCHAR);
-        ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len);
+        ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %ld, expected %ld\n", data.ulLength, len);
 
         /* keyed data structure doesn't include module name, it's available from section data */
-        ok_(__FILE__, line)(data.ulSectionTotalLength > comclass->name_offset, "got wrong offset %d\n", comclass->name_offset);
+        ok_(__FILE__, line)(data.ulSectionTotalLength > comclass->name_offset, "got wrong offset %ld\n", comclass->name_offset);
 
         /* check misc fields are set */
         miscmask = (comclass->flags >> 8) & 0xff;
         if (miscmask)
         {
             if (miscmask & MiscStatus)
-                ok_(__FILE__, line)(comclass->miscstatus != 0, "got miscstatus 0x%08x\n", comclass->miscstatus);
+                ok_(__FILE__, line)(comclass->miscstatus != 0, "got miscstatus 0x%08lx\n", comclass->miscstatus);
             if (miscmask & MiscStatusIcon)
-                ok_(__FILE__, line)(comclass->miscstatusicon != 0, "got miscstatusicon 0x%08x\n", comclass->miscstatusicon);
+                ok_(__FILE__, line)(comclass->miscstatusicon != 0, "got miscstatusicon 0x%08lx\n", comclass->miscstatusicon);
             if (miscmask & MiscStatusContent)
-                ok_(__FILE__, line)(comclass->miscstatuscontent != 0, "got miscstatuscontent 0x%08x\n", comclass->miscstatuscontent);
+                ok_(__FILE__, line)(comclass->miscstatuscontent != 0, "got miscstatuscontent 0x%08lx\n", comclass->miscstatuscontent);
             if (miscmask & MiscStatusThumbnail)
-                ok_(__FILE__, line)(comclass->miscstatusthumbnail != 0, "got miscstatusthumbnail 0x%08x\n", comclass->miscstatusthumbnail);
+                ok_(__FILE__, line)(comclass->miscstatusthumbnail != 0, "got miscstatusthumbnail 0x%08lx\n", comclass->miscstatusthumbnail);
             if (miscmask & MiscStatusDocPrint)
-                ok_(__FILE__, line)(comclass->miscstatusdocprint != 0, "got miscstatusdocprint 0x%08x\n", comclass->miscstatusdocprint);
+                ok_(__FILE__, line)(comclass->miscstatusdocprint != 0, "got miscstatusdocprint 0x%08lx\n", comclass->miscstatusdocprint);
         }
-        ok_(__FILE__, line)(!(comclass->flags & 0xffff00ff), "Unexpected flags %#x.\n", comclass->flags);
+        ok_(__FILE__, line)(!(comclass->flags & 0xffff00ff), "Unexpected flags %#lx.\n", comclass->flags);
 
         /* part used for clrClass only */
         if (comclass->clrdata_len)
@@ -1554,24 +1554,24 @@ static void test_find_com_redirection(HANDLE handle, const GUID *clsid, const GU
             WCHAR *ptrW;
 
             clrclass = (struct clrclass_data*)((BYTE*)data.lpData + comclass->clrdata_offset);
-            ok_(__FILE__, line)(clrclass->size == sizeof(*clrclass), "clrclass: got size %d\n", clrclass->size);
-            ok_(__FILE__, line)(clrclass->res[0] == 0, "clrclass: got res[0]=0x%08x\n", clrclass->res[0]);
-            ok_(__FILE__, line)(clrclass->res[1] == 2, "clrclass: got res[1]=0x%08x\n", clrclass->res[1]);
-            ok_(__FILE__, line)(clrclass->module_len == lstrlenW(mscoreeW)*sizeof(WCHAR), "clrclass: got module len %d\n", clrclass->module_len);
-            ok_(__FILE__, line)(clrclass->module_offset > 0, "clrclass: got module offset %d\n", clrclass->module_offset);
+            ok_(__FILE__, line)(clrclass->size == sizeof(*clrclass), "clrclass: got size %ld\n", clrclass->size);
+            ok_(__FILE__, line)(clrclass->res[0] == 0, "clrclass: got res[0]=0x%08lx\n", clrclass->res[0]);
+            ok_(__FILE__, line)(clrclass->res[1] == 2, "clrclass: got res[1]=0x%08lx\n", clrclass->res[1]);
+            ok_(__FILE__, line)(clrclass->module_len == lstrlenW(mscoreeW)*sizeof(WCHAR), "clrclass: got module len %ld\n", clrclass->module_len);
+            ok_(__FILE__, line)(clrclass->module_offset > 0, "clrclass: got module offset %ld\n", clrclass->module_offset);
 
-            ok_(__FILE__, line)(clrclass->name_len > 0, "clrclass: got name len %d\n", clrclass->name_len);
-            ok_(__FILE__, line)(clrclass->name_offset == clrclass->size, "clrclass: got name offset %d\n", clrclass->name_offset);
-            ok_(__FILE__, line)(clrclass->version_len > 0, "clrclass: got version len %d\n", clrclass->version_len);
-            ok_(__FILE__, line)(clrclass->version_offset > 0, "clrclass: got version offset %d\n", clrclass->version_offset);
+            ok_(__FILE__, line)(clrclass->name_len > 0, "clrclass: got name len %ld\n", clrclass->name_len);
+            ok_(__FILE__, line)(clrclass->name_offset == clrclass->size, "clrclass: got name offset %ld\n", clrclass->name_offset);
+            ok_(__FILE__, line)(clrclass->version_len > 0, "clrclass: got version len %ld\n", clrclass->version_len);
+            ok_(__FILE__, line)(clrclass->version_offset > 0, "clrclass: got version offset %ld\n", clrclass->version_offset);
 
-            ok_(__FILE__, line)(clrclass->res2[0] == 0, "clrclass: got res2[0]=0x%08x\n", clrclass->res2[0]);
-            ok_(__FILE__, line)(clrclass->res2[1] == 0, "clrclass: got res2[1]=0x%08x\n", clrclass->res2[1]);
+            ok_(__FILE__, line)(clrclass->res2[0] == 0, "clrclass: got res2[0]=0x%08lx\n", clrclass->res2[0]);
+            ok_(__FILE__, line)(clrclass->res2[1] == 0, "clrclass: got res2[1]=0x%08lx\n", clrclass->res2[1]);
 
             /* clrClass uses mscoree.dll as module name, but in two variants - comclass data points to module name
                in lower case, clsclass subsection - in upper case */
-            ok_(__FILE__, line)(comclass->name_len == lstrlenW(mscoree2W)*sizeof(WCHAR), "clrclass: got com name len %d\n", comclass->name_len);
-            ok_(__FILE__, line)(comclass->name_offset > 0, "clrclass: got name offset %d\n", clrclass->name_offset);
+            ok_(__FILE__, line)(comclass->name_len == lstrlenW(mscoree2W)*sizeof(WCHAR), "clrclass: got com name len %ld\n", comclass->name_len);
+            ok_(__FILE__, line)(comclass->name_offset > 0, "clrclass: got name offset %ld\n", clrclass->name_offset);
 
             ptrW = (WCHAR*)((BYTE*)data.lpSectionBase + comclass->name_offset);
             ok_(__FILE__, line)(!lstrcmpW(ptrW, mscoreeW), "clrclass: module name %s\n", wine_dbgstr_w(ptrW));
@@ -1583,23 +1583,23 @@ static void test_find_com_redirection(HANDLE handle, const GUID *clsid, const GU
 
     header = (struct guidsection_header*)data.lpSectionBase;
     ok_(__FILE__, line)(data.lpSectionGlobalData == ((BYTE*)header + header->names_offset), "data.lpSectionGlobalData == NULL\n");
-    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == header->names_len, "data.ulSectionGlobalDataLength=%u\n",
+    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == header->names_len, "data.ulSectionGlobalDataLength=%lu\n",
        data.ulSectionGlobalDataLength);
     ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
-    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
+    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%lu\n",
        data.ulSectionTotalLength);
     ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
-    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
+    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
        data.ulAssemblyRosterIndex, exid);
 
     /* generated guid for this class works as key guid in search */
     memset(&data2, 0xfe, sizeof(data2));
     data2.cbSize = sizeof(data2);
     ret = FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, &comclass->alias, &data2);
-    ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
+    ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %lu\n", GetLastError());
 
     comclass2 = (struct comclassredirect_data*)data2.lpData;
-    ok_(__FILE__, line)(comclass->size == comclass2->size, "got wrong data length %d, expected %d\n", comclass2->size, comclass->size);
+    ok_(__FILE__, line)(comclass->size == comclass2->size, "got wrong data length %ld, expected %ld\n", comclass2->size, comclass->size);
     ok_(__FILE__, line)(!memcmp(comclass, comclass2, comclass->size), "got wrong data\n");
 }
 
@@ -1632,14 +1632,14 @@ static void test_find_ifaceps_redirection(HANDLE handle, const GUID *iid, const
     data.cbSize = sizeof(data);
 
     ret = FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION, iid, &data);
-    ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
+    ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %lu\n", GetLastError());
 
     ifaceps = (struct ifacepsredirect_data*)data.lpData;
 
-    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
-    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
+    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%lu\n", data.cbSize);
+    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%lu\n", data.ulDataFormatVersion);
     ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
-    ok_(__FILE__, line)(ifaceps->size == sizeof(*ifaceps), "got %d for header size\n", ifaceps->size);
+    ok_(__FILE__, line)(ifaceps->size == sizeof(*ifaceps), "got %ld for header size\n", ifaceps->size);
     if (data.lpData && ifaceps->size == sizeof(*ifaceps))
     {
         ULONG len;
@@ -1653,29 +1653,29 @@ static void test_find_ifaceps_redirection(HANDLE handle, const GUID *iid, const
             ok_(__FILE__, line)(IsEqualGUID(&ifaceps->iid, iid), "got wrong iid %s\n", wine_dbgstr_guid(&ifaceps->iid));
 
         ok_(__FILE__, line)(IsEqualGUID(&ifaceps->tlbid, tlbid), "got wrong tlid %s\n", wine_dbgstr_guid(&ifaceps->tlbid));
-        ok_(__FILE__, line)(ifaceps->name_len > 0, "got modulename len %d\n", ifaceps->name_len);
-        ok_(__FILE__, line)(ifaceps->name_offset == ifaceps->size, "got progid offset %d\n", ifaceps->name_offset);
+        ok_(__FILE__, line)(ifaceps->name_len > 0, "got modulename len %ld\n", ifaceps->name_len);
+        ok_(__FILE__, line)(ifaceps->name_offset == ifaceps->size, "got progid offset %ld\n", ifaceps->name_offset);
 
         /* data length is simply header length + string data length including nulls */
         len = ifaceps->size + ifaceps->name_len + sizeof(WCHAR);
-        ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len);
+        ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %ld, expected %ld\n", data.ulLength, len);
 
         /* mask purpose is to indicate if attribute was specified, for testing purposes assume that manifest
            always has non-zero value for it */
         if (ifaceps->mask & NumMethods)
-            ok_(__FILE__, line)(ifaceps->nummethods != 0, "got nummethods %d\n", ifaceps->nummethods);
+            ok_(__FILE__, line)(ifaceps->nummethods != 0, "got nummethods %ld\n", ifaceps->nummethods);
         if (ifaceps->mask & BaseIface)
             ok_(__FILE__, line)(IsEqualGUID(&ifaceps->base, base), "got base %s\n", wine_dbgstr_guid(&ifaceps->base));
     }
 
     ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
-    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
+    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%lu\n",
        data.ulSectionGlobalDataLength);
     ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
-    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
+    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%lu\n",
        data.ulSectionTotalLength);
     ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
-    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
+    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
        data.ulAssemblyRosterIndex, exid);
 }
 
@@ -1706,30 +1706,30 @@ static void test_find_surrogate(HANDLE handle, const GUID *clsid, const WCHAR *n
         skip("surrogate sections are not supported\n");
         return;
     }
-    ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
+    ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %lu\n", GetLastError());
 
     surrogate = (struct clrsurrogate_data*)data.lpData;
 
-    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
-    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
+    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%lu\n", data.cbSize);
+    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%lu\n", data.ulDataFormatVersion);
     ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
-    ok_(__FILE__, line)(surrogate->size == sizeof(*surrogate), "got %d for header size\n", surrogate->size);
+    ok_(__FILE__, line)(surrogate->size == sizeof(*surrogate), "got %ld for header size\n", surrogate->size);
     if (data.lpData && surrogate->size == sizeof(*surrogate))
     {
         WCHAR *ptrW;
         ULONG len;
 
-        ok_(__FILE__, line)(surrogate->res == 0, "invalid res value %d\n", surrogate->res);
+        ok_(__FILE__, line)(surrogate->res == 0, "invalid res value %ld\n", surrogate->res);
         ok_(__FILE__, line)(IsEqualGUID(&surrogate->clsid, clsid), "got wrong clsid %s\n", wine_dbgstr_guid(&surrogate->clsid));
 
-        ok_(__FILE__, line)(surrogate->version_len == lstrlenW(version)*sizeof(WCHAR), "got version len %d\n", surrogate->version_len);
-        ok_(__FILE__, line)(surrogate->version_offset == surrogate->size, "got version offset %d\n", surrogate->version_offset);
+        ok_(__FILE__, line)(surrogate->version_len == lstrlenW(version)*sizeof(WCHAR), "got version len %ld\n", surrogate->version_len);
+        ok_(__FILE__, line)(surrogate->version_offset == surrogate->size, "got version offset %ld\n", surrogate->version_offset);
 
-        ok_(__FILE__, line)(surrogate->name_len == lstrlenW(name)*sizeof(WCHAR), "got name len %d\n", surrogate->name_len);
-        ok_(__FILE__, line)(surrogate->name_offset > surrogate->version_offset, "got name offset %d\n", surrogate->name_offset);
+        ok_(__FILE__, line)(surrogate->name_len == lstrlenW(name)*sizeof(WCHAR), "got name len %ld\n", surrogate->name_len);
+        ok_(__FILE__, line)(surrogate->name_offset > surrogate->version_offset, "got name offset %ld\n", surrogate->name_offset);
 
         len = surrogate->size + surrogate->name_len + surrogate->version_len + 2*sizeof(WCHAR);
-        ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %d, expected %d\n", data.ulLength, len);
+        ok_(__FILE__, line)(data.ulLength == len, "got wrong data length %ld, expected %ld\n", data.ulLength, len);
 
         ptrW = (WCHAR*)((BYTE*)surrogate + surrogate->name_offset);
         ok(!lstrcmpW(ptrW, name), "got wrong name %s\n", wine_dbgstr_w(ptrW));
@@ -1739,13 +1739,13 @@ static void test_find_surrogate(HANDLE handle, const GUID *clsid, const WCHAR *n
     }
 
     ok_(__FILE__, line)(data.lpSectionGlobalData == NULL, "data.lpSectionGlobalData != NULL\n");
-    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%u\n",
+    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == 0, "data.ulSectionGlobalDataLength=%lu\n",
        data.ulSectionGlobalDataLength);
     ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
-    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n",
+    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%lu\n",
        data.ulSectionTotalLength);
     ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
-    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
+    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
        data.ulAssemblyRosterIndex, exid);
 }
 
@@ -1761,20 +1761,20 @@ static void test_find_progid_redirection(HANDLE handle, const GUID *clsid, const
     data.cbSize = sizeof(data);
 
     ret = FindActCtxSectionStringA(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION, progid, &data);
-    ok_(__FILE__, line)(ret, "FindActCtxSectionStringA failed: %u\n", GetLastError());
+    ok_(__FILE__, line)(ret, "FindActCtxSectionStringA failed: %lu\n", GetLastError());
 
     progiddata = (struct progidredirect_data*)data.lpData;
 
-    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%u\n", data.cbSize);
-    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%u\n", data.ulDataFormatVersion);
+    ok_(__FILE__, line)(data.cbSize == sizeof(data), "data.cbSize=%lu\n", data.cbSize);
+    ok_(__FILE__, line)(data.ulDataFormatVersion == 1, "data.ulDataFormatVersion=%lu\n", data.ulDataFormatVersion);
     ok_(__FILE__, line)(data.lpData != NULL, "data.lpData == NULL\n");
-    ok_(__FILE__, line)(progiddata->size == sizeof(*progiddata), "got %d for header size\n", progiddata->size);
+    ok_(__FILE__, line)(progiddata->size == sizeof(*progiddata), "got %ld for header size\n", progiddata->size);
     if (data.lpData && progiddata->size == sizeof(*progiddata))
     {
         GUID *guid;
 
-        ok_(__FILE__, line)(progiddata->reserved == 0, "got reserved as %d\n", progiddata->reserved);
-        ok_(__FILE__, line)(progiddata->clsid_offset > 0, "got clsid_offset as %d\n", progiddata->clsid_offset);
+        ok_(__FILE__, line)(progiddata->reserved == 0, "got reserved as %ld\n", progiddata->reserved);
+        ok_(__FILE__, line)(progiddata->clsid_offset > 0, "got clsid_offset as %ld\n", progiddata->clsid_offset);
 
         /* progid data points to generated alias guid */
         guid = (GUID*)((BYTE*)data.lpSectionBase + progiddata->clsid_offset);
@@ -1782,7 +1782,7 @@ static void test_find_progid_redirection(HANDLE handle, const GUID *clsid, const
         memset(&data2, 0, sizeof(data2));
         data2.cbSize = sizeof(data2);
         ret = FindActCtxSectionGuid(0, NULL, ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION, guid, &data2);
-        ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %u\n", GetLastError());
+        ok_(__FILE__, line)(ret, "FindActCtxSectionGuid failed: %lu\n", GetLastError());
 
         comclass = (struct comclassredirect_data*)data2.lpData;
         ok_(__FILE__, line)(IsEqualGUID(guid, &comclass->alias), "got wrong alias referenced from progid %s, %s\n", progid, wine_dbgstr_guid(guid));
@@ -1791,11 +1791,11 @@ static void test_find_progid_redirection(HANDLE handle, const GUID *clsid, const
 
     header = (struct strsection_header*)data.lpSectionBase;
     ok_(__FILE__, line)(data.lpSectionGlobalData == (BYTE*)header + header->global_offset, "data.lpSectionGlobalData == NULL\n");
-    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == header->global_len, "data.ulSectionGlobalDataLength=%u\n", data.ulSectionGlobalDataLength);
+    ok_(__FILE__, line)(data.ulSectionGlobalDataLength == header->global_len, "data.ulSectionGlobalDataLength=%lu\n", data.ulSectionGlobalDataLength);
     ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n");
-    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%u\n", data.ulSectionTotalLength);
+    ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%lu\n", data.ulSectionTotalLength);
     ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx);
-    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%u, expected %u\n",
+    ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
         data.ulAssemblyRosterIndex, exid);
 }
 
@@ -1816,14 +1816,14 @@ static void test_wndclass_section(void)
     create_manifest_file("main_wndcls.manifest", manifest_wndcls_main, -1, NULL, NULL);
 
     handle = test_create("main_wndcls.manifest");
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
 
     DeleteFileA("testdep1.manifest");
     DeleteFileA("testdep2.manifest");
     DeleteFileA("main_wndcls.manifest");
 
     ret = ActivateActCtx(handle, &cookie);
-    ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
+    ok(ret, "ActivateActCtx failed: %lu\n", GetLastError());
 
     memset(&data, 0, sizeof(data));
     memset(&data2, 0, sizeof(data2));
@@ -1837,12 +1837,12 @@ static void test_wndclass_section(void)
     ok(ret, "got %d\n", ret);
 
     section = (struct strsection_header*)data.lpSectionBase;
-    ok(section->count == 4, "got %d\n", section->count);
-    ok(section->size == sizeof(*section), "got %d\n", section->size);
+    ok(section->count == 4, "got %ld\n", section->count);
+    ok(section->size == sizeof(*section), "got %ld\n", section->size);
 
     /* For both string same section is returned, meaning it's one wndclass section per context */
     ok(data.lpSectionBase == data2.lpSectionBase, "got %p, %p\n", data.lpSectionBase, data2.lpSectionBase);
-    ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %u, %u\n", data.ulSectionTotalLength,
+    ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %lu, %lu\n", data.ulSectionTotalLength,
         data2.ulSectionTotalLength);
 
     /* wndClass1 is versioned, wndClass3 is not */
@@ -1855,7 +1855,7 @@ static void test_wndclass_section(void)
     ok(!lstrcmpW(ptrW, wndClass3W), "got %s\n", wine_dbgstr_w(ptrW));
 
     ret = DeactivateActCtx(0, cookie);
-    ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
+    ok(ret, "DeactivateActCtx failed: %lu\n", GetLastError());
 
     ReleaseActCtx(handle);
 }
@@ -1876,14 +1876,14 @@ static void test_dllredirect_section(void)
     create_manifest_file("main_wndcls.manifest", manifest_wndcls_main, -1, NULL, NULL);
 
     handle = test_create("main_wndcls.manifest");
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
 
     DeleteFileA("testdep1.manifest");
     DeleteFileA("testdep2.manifest");
     DeleteFileA("main_wndcls.manifest");
 
     ret = ActivateActCtx(handle, &cookie);
-    ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
+    ok(ret, "ActivateActCtx failed: %lu\n", GetLastError());
 
     memset(&data, 0, sizeof(data));
     memset(&data2, 0, sizeof(data2));
@@ -1897,16 +1897,16 @@ static void test_dllredirect_section(void)
     ok(ret, "got %d\n", ret);
 
     section = (struct strsection_header*)data.lpSectionBase;
-    ok(section->count == 4, "got %d\n", section->count);
-    ok(section->size == sizeof(*section), "got %d\n", section->size);
+    ok(section->count == 4, "got %ld\n", section->count);
+    ok(section->size == sizeof(*section), "got %ld\n", section->size);
 
     /* For both string same section is returned, meaning it's one dll redirect section per context */
     ok(data.lpSectionBase == data2.lpSectionBase, "got %p, %p\n", data.lpSectionBase, data2.lpSectionBase);
-    ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %u, %u\n", data.ulSectionTotalLength,
+    ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %lu, %lu\n", data.ulSectionTotalLength,
         data2.ulSectionTotalLength);
 
     ret = DeactivateActCtx(0, cookie);
-    ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
+    ok(ret, "DeactivateActCtx failed: %lu\n", GetLastError());
 
     ReleaseActCtx(handle);
 }
@@ -1927,14 +1927,14 @@ static void test_typelib_section(void)
     create_manifest_file("main_wndcls.manifest", manifest_wndcls_main, -1, NULL, NULL);
 
     handle = test_create("main_wndcls.manifest");
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
 
     DeleteFileA("testdep1.manifest");
     DeleteFileA("testdep2.manifest");
     DeleteFileA("main_wndcls.manifest");
 
     ret = ActivateActCtx(handle, &cookie);
-    ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
+    ok(ret, "ActivateActCtx failed: %lu\n", GetLastError());
 
     memset(&data, 0, sizeof(data));
     memset(&data2, 0, sizeof(data2));
@@ -1950,29 +1950,29 @@ static void test_typelib_section(void)
     ok(ret, "got %d\n", ret);
 
     section = (struct guidsection_header*)data.lpSectionBase;
-    ok(section->count == 4, "got %d\n", section->count);
-    ok(section->size == sizeof(*section), "got %d\n", section->size);
+    ok(section->count == 4, "got %ld\n", section->count);
+    ok(section->size == sizeof(*section), "got %ld\n", section->size);
 
     /* For both GUIDs same section is returned */
     ok(data.lpSectionBase == data2.lpSectionBase, "got %p, %p\n", data.lpSectionBase, data2.lpSectionBase);
-    ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %u, %u\n", data.ulSectionTotalLength,
+    ok(data.ulSectionTotalLength == data2.ulSectionTotalLength, "got %lu, %lu\n", data.ulSectionTotalLength,
         data2.ulSectionTotalLength);
 
     ok(data.lpSectionGlobalData == ((BYTE*)section + section->names_offset), "data.lpSectionGlobalData == NULL\n");
-    ok(data.ulSectionGlobalDataLength == section->names_len, "data.ulSectionGlobalDataLength=%u\n",
+    ok(data.ulSectionGlobalDataLength == section->names_len, "data.ulSectionGlobalDataLength=%lu\n",
        data.ulSectionGlobalDataLength);
 
     /* test some actual data */
     tlib = (struct tlibredirect_data*)data.lpData;
-    ok(tlib->size == sizeof(*tlib), "got %d\n", tlib->size);
+    ok(tlib->size == sizeof(*tlib), "got %ld\n", tlib->size);
     ok(tlib->major_version == 1, "got %d\n", tlib->major_version);
     ok(tlib->minor_version == 0, "got %d\n", tlib->minor_version);
-    ok(tlib->help_offset > 0, "got %d\n", tlib->help_offset);
-    ok(tlib->help_len == sizeof(helpW), "got %d\n", tlib->help_len);
+    ok(tlib->help_offset > 0, "got %ld\n", tlib->help_offset);
+    ok(tlib->help_len == sizeof(helpW), "got %ld\n", tlib->help_len);
     ok(tlib->flags == (LIBFLAG_FHIDDEN|LIBFLAG_FCONTROL|LIBFLAG_FRESTRICTED), "got %x\n", tlib->flags);
 
     ret = DeactivateActCtx(0, cookie);
-    ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
+    ok(ret, "DeactivateActCtx failed: %lu\n", GetLastError());
 
     ReleaseActCtx(handle);
 }
@@ -2010,7 +2010,7 @@ static void test_actctx(void)
 
     b = GetCurrentActCtx(&handle);
     ok(handle == NULL, "handle = %p, expected NULL\n", handle);
-    ok(b, "GetCurrentActCtx failed: %u\n", GetLastError());
+    ok(b, "GetCurrentActCtx failed: %lu\n", GetLastError());
     if(b) {
         test_basic_info(handle, __LINE__);
         test_detailed_info(handle, &detailed_info0, __LINE__);
@@ -2021,7 +2021,7 @@ static void test_actctx(void)
     /* test for whitespace handling in Eq ::= S? '=' S? */
     create_manifest_file("test1_1.manifest", manifest1_1, -1, NULL, NULL);
     handle = test_create("test1_1.manifest");
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
     DeleteFileA("test1_1.manifest");
     ReleaseActCtx(handle);
 
@@ -2033,7 +2033,7 @@ static void test_actctx(void)
     trace("manifest1\n");
 
     handle = test_create("test1.manifest");
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
     DeleteFileA("test1.manifest");
     if(handle != INVALID_HANDLE_VALUE) {
         test_basic_info(handle, __LINE__);
@@ -2045,7 +2045,7 @@ static void test_actctx(void)
             /* CloseHandle will generate an exception if a debugger is present */
             b = CloseHandle(handle);
             ok(!b, "CloseHandle succeeded\n");
-            ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError() == %u\n", GetLastError());
+            ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError() == %lu\n", GetLastError());
         }
 
         ReleaseActCtx(handle);
@@ -2059,7 +2059,7 @@ static void test_actctx(void)
     trace("manifest2 depmanifest1\n");
 
     handle = test_create("test2.manifest");
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
     DeleteFileA("test2.manifest");
     DeleteFileA("testdep.manifest");
     if(handle != INVALID_HANDLE_VALUE) {
@@ -2078,7 +2078,7 @@ static void test_actctx(void)
     trace("manifest2 depmanifest2\n");
 
     handle = test_create("test2-2.manifest");
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
     DeleteFileA("test2-2.manifest");
     DeleteFileA("testdep.manifest");
     if(handle != INVALID_HANDLE_VALUE) {
@@ -2090,11 +2090,11 @@ static void test_actctx(void)
         test_file_info(handle, 1, 1, testlib2_dll, __LINE__);
 
         b = ActivateActCtx(handle, &cookie);
-        ok(b, "ActivateActCtx failed: %u\n", GetLastError());
+        ok(b, "ActivateActCtx failed: %lu\n", GetLastError());
         test_find_dll_redirection(handle, testlib_dll, 2, __LINE__);
         test_find_dll_redirection(handle, testlib2_dll, 2, __LINE__);
         b = DeactivateActCtx(0, cookie);
-        ok(b, "DeactivateActCtx failed: %u\n", GetLastError());
+        ok(b, "DeactivateActCtx failed: %lu\n", GetLastError());
 
         ReleaseActCtx(handle);
     }
@@ -2107,7 +2107,7 @@ static void test_actctx(void)
     }
 
     handle = test_create("test2-3.manifest");
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
     DeleteFileA("test2-3.manifest");
     DeleteFileA("testdep.manifest");
     if(handle != INVALID_HANDLE_VALUE) {
@@ -2119,13 +2119,13 @@ static void test_actctx(void)
         test_file_info(handle, 1, 1, testlib2_dll, __LINE__);
 
         b = ActivateActCtx(handle, &cookie);
-        ok(b, "ActivateActCtx failed: %u\n", GetLastError());
+        ok(b, "ActivateActCtx failed: %lu\n", GetLastError());
         test_find_dll_redirection(handle, testlib_dll, 2, __LINE__);
         test_find_dll_redirection(handle, testlib2_dll, 2, __LINE__);
         test_find_window_class(handle, wndClassW, 2, __LINE__);
         test_find_window_class(handle, wndClass2W, 2, __LINE__);
         b = DeactivateActCtx(0, cookie);
-        ok(b, "DeactivateActCtx failed: %u\n", GetLastError());
+        ok(b, "DeactivateActCtx failed: %lu\n", GetLastError());
 
         ReleaseActCtx(handle);
     }
@@ -2139,7 +2139,7 @@ static void test_actctx(void)
 
     handle = test_create("test3.manifest");
     ok(handle != INVALID_HANDLE_VALUE || broken(handle == INVALID_HANDLE_VALUE) /* XP pre-SP2, win2k3 w/o SP */,
-        "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+        "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
     if (handle == INVALID_HANDLE_VALUE)
         win_skip("Some activation context features not supported, skipping a test (possibly old XP/Win2k3 system\n");
     DeleteFileA("test3.manifest");
@@ -2155,7 +2155,7 @@ static void test_actctx(void)
         test_file_info(handle, 0, 0, testlib_dll, __LINE__);
 
         b = ActivateActCtx(handle, &cookie);
-        ok(b, "ActivateActCtx failed: %u\n", GetLastError());
+        ok(b, "ActivateActCtx failed: %lu\n", GetLastError());
         test_find_dll_redirection(handle, testlib_dll, 1, __LINE__);
         test_find_dll_redirection(handle, testlib_dll, 1, __LINE__);
         test_find_com_redirection(handle, &IID_CoTest, &IID_TlibTest, progidW, 1, __LINE__);
@@ -2182,7 +2182,7 @@ static void test_actctx(void)
         test_find_string_fail();
 
         b = DeactivateActCtx(0, cookie);
-        ok(b, "DeactivateActCtx failed: %u\n", GetLastError());
+        ok(b, "DeactivateActCtx failed: %lu\n", GetLastError());
         ReleaseActCtx(handle);
     }
 
@@ -2207,7 +2207,7 @@ static void test_actctx(void)
 
     if(create_manifest_file("test7.manifest", manifest7, -1, NULL, NULL)) {
         handle = test_create("test7.manifest");
-        ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+        ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
         DeleteFileA("test7.manifest");
         DeleteFileA("testdep.manifest");
         if(handle != INVALID_HANDLE_VALUE)
@@ -2223,7 +2223,7 @@ static void test_actctx(void)
 
     if(create_manifest_file("test8.manifest", manifest8, -1, NULL, NULL)) {
         handle = test_create("test8.manifest");
-        ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+        ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
         DeleteFileA("test8.manifest");
         DeleteFileA("testdep.manifest");
         if(handle != INVALID_HANDLE_VALUE)
@@ -2239,7 +2239,7 @@ static void test_actctx(void)
 
     if(create_manifest_file("test9.manifest", manifest9, -1, NULL, NULL)) {
         handle = test_create("test9.manifest");
-        ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+        ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
         DeleteFileA("test9.manifest");
         DeleteFileA("testdep.manifest");
         if(handle != INVALID_HANDLE_VALUE)
@@ -2253,7 +2253,7 @@ static void test_actctx(void)
 
     if(create_manifest_file("test10.manifest", manifest10, -1, NULL, NULL)) {
         handle = test_create("test10.manifest");
-        ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+        ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
         DeleteFileA("test10.manifest");
         DeleteFileA("testdep.manifest");
         if(handle != INVALID_HANDLE_VALUE)
@@ -2268,7 +2268,7 @@ static void test_actctx(void)
     if (create_manifest_file("test11.manifest", manifest11, -1, NULL, NULL))
     {
         handle = test_create("test11.manifest");
-        ok(handle != INVALID_HANDLE_VALUE, "Failed to create activation context for %s, error %u\n",
+        ok(handle != INVALID_HANDLE_VALUE, "Failed to create activation context for %s, error %lu\n",
                 "manifest11", GetLastError());
         DeleteFileA("test11.manifest");
         if (handle != INVALID_HANDLE_VALUE)
@@ -2285,7 +2285,7 @@ static void test_actctx(void)
     }
 
     handle = test_create("test4.manifest");
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
     DeleteFileA("test4.manifest");
     DeleteFileA("testdep.manifest");
     if(handle != INVALID_HANDLE_VALUE) {
@@ -2306,7 +2306,7 @@ static void test_actctx(void)
             return;
         }
         handle = test_create("..\\test1.manifest");
-        ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+        ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
         DeleteFileA("..\\test1.manifest");
         if(handle != INVALID_HANDLE_VALUE) {
             test_basic_info(handle, __LINE__);
@@ -2327,7 +2327,7 @@ static void test_actctx(void)
     }
 
     handle = test_create("test1.manifest");
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
     DeleteFileA("test1.manifest");
     if (handle != INVALID_HANDLE_VALUE) {
         test_basic_info(handle, __LINE__);
@@ -2343,7 +2343,7 @@ static void test_actctx(void)
     }
 
     handle = test_create("test1.manifest");
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
     DeleteFileA("test1.manifest");
     if (handle != INVALID_HANDLE_VALUE) {
         test_basic_info(handle, __LINE__);
@@ -2367,7 +2367,7 @@ static void test_app_manifest(void)
 
     b = GetCurrentActCtx(&handle);
     ok(handle == NULL, "handle != NULL\n");
-    ok(b, "GetCurrentActCtx failed: %u\n", GetLastError());
+    ok(b, "GetCurrentActCtx failed: %lu\n", GetLastError());
     if(b) {
         test_basic_info(handle, __LINE__);
         test_detailed_info(handle, &detailed_info1_child, __LINE__);
@@ -2383,7 +2383,7 @@ static HANDLE create_manifest(const char *filename, const char *data, int line)
 
     handle = test_create(filename);
     ok_(__FILE__, line)(handle != INVALID_HANDLE_VALUE,
-        "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+        "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
 
     DeleteFileA(filename);
     return handle;
@@ -2408,7 +2408,7 @@ static void kernel32_find(ULONG section, const char *string_to_find, BOOL should
         "FindActCtxSectionStringA: expected ret = %u, got %u\n", should_find, ret);
     todo_wine_if(todo)
     ok_(__FILE__, line)(err == (should_find ? ERROR_SUCCESS : ERROR_SXS_KEY_NOT_FOUND),
-        "FindActCtxSectionStringA: unexpected error %u\n", err);
+        "FindActCtxSectionStringA: unexpected error %lu\n", err);
 
     memset(&data, 0xfe, sizeof(data));
     data.cbSize = sizeof(data);
@@ -2420,7 +2420,7 @@ static void kernel32_find(ULONG section, const char *string_to_find, BOOL should
         "FindActCtxSectionStringW: expected ret = %u, got %u\n", should_find, ret);
     todo_wine_if(todo)
     ok_(__FILE__, line)(err == (should_find ? ERROR_SUCCESS : ERROR_SXS_KEY_NOT_FOUND),
-        "FindActCtxSectionStringW: unexpected error %u\n", err);
+        "FindActCtxSectionStringW: unexpected error %lu\n", err);
 
     SetLastError(0);
     ret = FindActCtxSectionStringA(0, NULL, section, string_to_find, NULL);
@@ -2428,7 +2428,7 @@ static void kernel32_find(ULONG section, const char *string_to_find, BOOL should
     ok_(__FILE__, line)(!ret,
         "FindActCtxSectionStringA: expected failure, got %u\n", ret);
     ok_(__FILE__, line)(err == ERROR_INVALID_PARAMETER,
-        "FindActCtxSectionStringA: unexpected error %u\n", err);
+        "FindActCtxSectionStringA: unexpected error %lu\n", err);
 
     SetLastError(0);
     ret = FindActCtxSectionStringW(0, NULL, section, string_to_findW.Buffer, NULL);
@@ -2436,7 +2436,7 @@ static void kernel32_find(ULONG section, const char *string_to_find, BOOL should
     ok_(__FILE__, line)(!ret,
         "FindActCtxSectionStringW: expected failure, got %u\n", ret);
     ok_(__FILE__, line)(err == ERROR_INVALID_PARAMETER,
-        "FindActCtxSectionStringW: unexpected error %u\n", err);
+        "FindActCtxSectionStringW: unexpected error %lu\n", err);
 
     pRtlFreeUnicodeString(&string_to_findW);
 }
@@ -2455,12 +2455,12 @@ static void ntdll_find(ULONG section, const char *string_to_find, BOOL should_fi
     ret = pRtlFindActivationContextSectionString(0, NULL, section, &string_to_findW, &data);
     todo_wine_if(todo)
     ok_(__FILE__, line)(ret == (should_find ? STATUS_SUCCESS : STATUS_SXS_KEY_NOT_FOUND),
-        "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret);
+        "RtlFindActivationContextSectionString: unexpected status 0x%lx\n", ret);
 
     ret = pRtlFindActivationContextSectionString(0, NULL, section, &string_to_findW, NULL);
     todo_wine_if(todo)
     ok_(__FILE__, line)(ret == (should_find ? STATUS_SUCCESS : STATUS_SXS_KEY_NOT_FOUND),
-        "RtlFindActivationContextSectionString: unexpected status 0x%x\n", ret);
+        "RtlFindActivationContextSectionString: unexpected status 0x%lx\n", ret);
 
     pRtlFreeUnicodeString(&string_to_findW);
 }
@@ -2473,7 +2473,7 @@ static void test_findsectionstring(void)
 
     handle = create_manifest("test.manifest", testdep_manifest3, __LINE__);
     ret = ActivateActCtx(handle, &cookie);
-    ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
+    ok(ret, "ActivateActCtx failed: %lu\n", GetLastError());
 
     /* first we show the parameter validation from kernel32 */
     kernel32_find(ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION, "testdep", FALSE, TRUE, __LINE__);
@@ -2494,7 +2494,7 @@ static void test_findsectionstring(void)
     ntdll_find(ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION, "wndClass3", FALSE, FALSE, __LINE__);
 
     ret = DeactivateActCtx(0, cookie);
-    ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
+    ok(ret, "DeactivateActCtx failed: %lu\n", GetLastError());
     ReleaseActCtx(handle);
 }
 
@@ -2529,7 +2529,7 @@ static void run_child_process(void)
     }
     sprintf(cmdline, "\"%s\" %s manifest1", argv[0], argv[1]);
     ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-    ok(ret, "Could not create process: %u\n", GetLastError());
+    ok(ret, "Could not create process: %lu\n", GetLastError());
     wait_child_process( pi.hProcess );
     CloseHandle(pi.hThread);
     CloseHandle(pi.hProcess);
@@ -2570,7 +2570,7 @@ static void write_manifest(const char *filename, const char *manifest)
     strcat(path, filename);
 
     file = CreateFileA(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
-    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %lu\n", GetLastError());
     WriteFile(file, manifest, strlen(manifest), &size, NULL);
     CloseHandle(file);
 }
@@ -2592,7 +2592,7 @@ static void extract_resource(const char *name, const char *type, const char *pat
     void *ptr;
 
     file = CreateFileA(path, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
-    ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %d\n", path, GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %ld\n", path, GetLastError());
 
     res = FindResourceA(NULL, name, type);
     ok( res != 0, "couldn't find resource\n" );
@@ -2621,7 +2621,7 @@ static void test_CreateActCtx(void)
 
     /* create using lpSource without specified directory */
     handle = CreateActCtxA(&actctx);
-    ok(handle != INVALID_HANDLE_VALUE, "failed to generate context, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "failed to generate context, error %lu\n", GetLastError());
     ReleaseActCtx(handle);
 
     /* with specified directory, that doesn't contain dependent assembly */
@@ -2637,7 +2637,7 @@ static void test_CreateActCtx(void)
     handle = CreateActCtxA(&actctx);
 todo_wine {
     ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle);
-    ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "got error %d\n", GetLastError());
+    ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX, "got error %ld\n", GetLastError());
 }
     if (handle != INVALID_HANDLE_VALUE) ReleaseActCtx(handle);
 
@@ -2653,7 +2653,7 @@ todo_wine {
     strcat(dll, "testdep1.dll");
     extract_resource("dummy.dll", "TESTDLL", dll);
     handle = CreateActCtxA(&actctx);
-    ok(handle != INVALID_HANDLE_VALUE || broken(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX) , "got error %d\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE || broken(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX) , "got error %ld\n", GetLastError());
     ReleaseActCtx(handle);
     DeleteFileA(dll);
 
@@ -2670,7 +2670,7 @@ todo_wine {
     ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle);
     todo_wine
     ok(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX || broken(GetLastError() == ERROR_NOT_ENOUGH_MEMORY) /* XP, win2k3 */,
-        "got error %d\n", GetLastError());
+        "got error %ld\n", GetLastError());
 
     /* create from HMODULE - resource doesn't exist, lpSource is set */
     memset(&actctx, 0, sizeof(ACTCTXA));
@@ -2683,7 +2683,7 @@ todo_wine {
     SetLastError(0xdeadbeef);
     handle = CreateActCtxA(&actctx);
     ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle);
-    ok(GetLastError() == ERROR_RESOURCE_NAME_NOT_FOUND, "got error %d\n", GetLastError());
+    ok(GetLastError() == ERROR_RESOURCE_NAME_NOT_FOUND, "got error %ld\n", GetLastError());
 
     /* load manifest from lpAssemblyDirectory directory */
     write_manifest("testdir.manifest", manifest1);
@@ -2704,7 +2704,7 @@ todo_wine {
     ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle);
     ok(GetLastError()==ERROR_PATH_NOT_FOUND ||
             broken(GetLastError()==ERROR_FILE_NOT_FOUND) /* WinXP */,
-            "got error %d\n", GetLastError());
+            "got error %ld\n", GetLastError());
 
     CreateDirectoryA(dir, NULL);
     memset(&actctx, 0, sizeof(actctx));
@@ -2716,7 +2716,7 @@ todo_wine {
     SetLastError(0xdeadbeef);
     handle = CreateActCtxA(&actctx);
     ok(handle == INVALID_HANDLE_VALUE, "got handle %p\n", handle);
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %d\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %ld\n", GetLastError());
     SetCurrentDirectoryW(work_dir);
 
     write_manifest("assembly_dir\\testdir.manifest", manifest1);
@@ -2771,33 +2771,33 @@ static void test_ZombifyActCtx(void)
     SetLastError(0xdeadbeef);
     ret = ZombifyActCtx(NULL);
     todo_wine
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %ld\n", ret, GetLastError());
 
     handle = create_manifest("test.manifest", testdep_manifest3, __LINE__);
 
     ret = GetCurrentActCtx(&current);
-    ok(ret, "got %d, error %d\n", ret, GetLastError());
+    ok(ret, "got %d, error %ld\n", ret, GetLastError());
     ok(current == NULL, "got %p\n", current);
 
     ret = ActivateActCtx(handle, &cookie);
-    ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
+    ok(ret, "ActivateActCtx failed: %lu\n", GetLastError());
 
     ret = GetCurrentActCtx(&current);
-    ok(ret, "got %d, error %d\n", ret, GetLastError());
+    ok(ret, "got %d, error %ld\n", ret, GetLastError());
     ok(handle == current, "got %p, %p\n", current, handle);
 
     memset(&basicinfo, 0xff, sizeof(basicinfo));
     ret = QueryActCtxW(0, handle, 0, ActivationContextBasicInformation, &basicinfo, sizeof(basicinfo), NULL);
-    ok(ret, "got %d, error %d\n", ret, GetLastError());
+    ok(ret, "got %d, error %ld\n", ret, GetLastError());
     ok(basicinfo.hActCtx == handle, "got %p\n", basicinfo.hActCtx);
-    ok(basicinfo.dwFlags == 0, "got %x\n", basicinfo.dwFlags);
+    ok(basicinfo.dwFlags == 0, "got %lx\n", basicinfo.dwFlags);
 
     memset(&basicinfo, 0xff, sizeof(basicinfo));
     ret = QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX, NULL, 0, ActivationContextBasicInformation,
         &basicinfo, sizeof(basicinfo), NULL);
-    ok(ret, "got %d, error %d\n", ret, GetLastError());
+    ok(ret, "got %d, error %ld\n", ret, GetLastError());
     ok(basicinfo.hActCtx == handle, "got %p\n", basicinfo.hActCtx);
-    ok(basicinfo.dwFlags == 0, "got %x\n", basicinfo.dwFlags);
+    ok(basicinfo.dwFlags == 0, "got %lx\n", basicinfo.dwFlags);
 
     ret = ZombifyActCtx(handle);
     todo_wine
@@ -2805,19 +2805,19 @@ static void test_ZombifyActCtx(void)
 
     memset(&basicinfo, 0xff, sizeof(basicinfo));
     ret = QueryActCtxW(0, handle, 0, ActivationContextBasicInformation, &basicinfo, sizeof(basicinfo), NULL);
-    ok(ret, "got %d, error %d\n", ret, GetLastError());
+    ok(ret, "got %d, error %ld\n", ret, GetLastError());
     ok(basicinfo.hActCtx == handle, "got %p\n", basicinfo.hActCtx);
-    ok(basicinfo.dwFlags == 0, "got %x\n", basicinfo.dwFlags);
+    ok(basicinfo.dwFlags == 0, "got %lx\n", basicinfo.dwFlags);
 
     memset(&basicinfo, 0xff, sizeof(basicinfo));
     ret = QueryActCtxW(QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX, NULL, 0, ActivationContextBasicInformation,
             &basicinfo, sizeof(basicinfo), NULL);
-    ok(ret, "got %d, error %d\n", ret, GetLastError());
+    ok(ret, "got %d, error %ld\n", ret, GetLastError());
     ok(basicinfo.hActCtx == handle, "got %p\n", basicinfo.hActCtx);
-    ok(basicinfo.dwFlags == 0, "got %x\n", basicinfo.dwFlags);
+    ok(basicinfo.dwFlags == 0, "got %lx\n", basicinfo.dwFlags);
 
     ret = GetCurrentActCtx(&current);
-    ok(ret, "got %d, error %d\n", ret, GetLastError());
+    ok(ret, "got %d, error %ld\n", ret, GetLastError());
     ok(current == handle, "got %p\n", current);
 
     /* one more time */
@@ -2826,7 +2826,7 @@ static void test_ZombifyActCtx(void)
     ok(ret, "got %d\n", ret);
 
     ret = DeactivateActCtx(0, cookie);
-    ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
+    ok(ret, "DeactivateActCtx failed: %lu\n", GetLastError());
     ReleaseActCtx(handle);
 }
 
@@ -2863,8 +2863,8 @@ static void test_no_compat(HANDLE handle, int line)
     ok_(__FILE__, line)(b, "CompatibilityInformationInActivationContext failed\n");
     ok_(__FILE__, line)(size == offsetof(test_act_ctx_compat_info,Elements[0]) ||
                         broken(size == offsetof(old_win10_test_act_ctx_compat_info,Elements[0])),
-                        "size mismatch got %lu\n", size);
-    ok_(__FILE__, line)(compat_info.ElementCount == 0, "unexpected ElementCount %u\n", compat_info.ElementCount);
+                        "size mismatch got %Iu\n", size);
+    ok_(__FILE__, line)(compat_info.ElementCount == 0, "unexpected ElementCount %lu\n", compat_info.ElementCount);
 }
 
 static void test_with_compat(HANDLE handle, DWORD num_compat, DWORD num_version,
@@ -2882,10 +2882,10 @@ static void test_with_compat(HANDLE handle, DWORD num_compat, DWORD num_version,
     ok_(__FILE__, line)(b, "CompatibilityInformationInActivationContext failed\n");
     ok_(__FILE__, line)(size == offsetof(test_act_ctx_compat_info,Elements[num_compat + num_version]) ||
                         broken(size == offsetof(old_win10_test_act_ctx_compat_info,Elements[num_compat])),
-                        "size mismatch got %lu\n", size);
+                        "size mismatch got %Iu\n", size);
     ok_(__FILE__, line)(compat_info.ElementCount == num_compat + num_version ||
                         broken(compat_info.ElementCount == num_compat),
-                        "unexpected ElementCount %u\n", compat_info.ElementCount);
+                        "unexpected ElementCount %lu\n", compat_info.ElementCount);
 
     if (size == offsetof(old_win10_test_act_ctx_compat_info,Elements[num_compat]))
     {
@@ -2893,12 +2893,12 @@ static void test_with_compat(HANDLE handle, DWORD num_compat, DWORD num_version,
         {
             old_win10_test_act_ctx_compat_info *info = (old_win10_test_act_ctx_compat_info *)&compat_info;
             ok_(__FILE__, line)(IsEqualGUID(&info->Elements[n].Id, expected_compat[n]),
-                                "got wrong clsid %s, expected %s for %u\n",
+                                "got wrong clsid %s, expected %s for %lu\n",
                                 wine_dbgstr_guid(&info->Elements[n].Id),
                                 wine_dbgstr_guid(expected_compat[n]),
                                 n);
             ok_(__FILE__, line)(info->Elements[n].Type == ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS,
-                                "Wrong type, got %u for %u\n", (DWORD)info->Elements[n].Type, n);
+                                "Wrong type, got %lu for %lu\n", (DWORD)info->Elements[n].Type, n);
         }
     }
     else
@@ -2906,19 +2906,19 @@ static void test_with_compat(HANDLE handle, DWORD num_compat, DWORD num_version,
         for (n = 0; n < num_compat; ++n)
         {
             ok_(__FILE__, line)(IsEqualGUID(&compat_info.Elements[n].Id, expected_compat[n]),
-                                "got wrong clsid %s, expected %s for %u\n",
+                                "got wrong clsid %s, expected %s for %lu\n",
                                 wine_dbgstr_guid(&compat_info.Elements[n].Id),
                                 wine_dbgstr_guid(expected_compat[n]),
                                 n);
             ok_(__FILE__, line)(compat_info.Elements[n].Type == ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS,
-                                "Wrong type, got %u for %u\n", (DWORD)compat_info.Elements[n].Type, n);
+                                "Wrong type, got %lu for %lu\n", (DWORD)compat_info.Elements[n].Type, n);
         }
         for (; n < num_compat + num_version; ++n)
         {
             ok_(__FILE__, line)(compat_info.Elements[n].Type == ACTCTX_COMPATIBILITY_ELEMENT_TYPE_MAXVERSIONTESTED,
-                                "Wrong type, got %u for %u\n", (DWORD)compat_info.Elements[n].Type, n);
+                                "Wrong type, got %lu for %lu\n", (DWORD)compat_info.Elements[n].Type, n);
             ok_(__FILE__, line)(compat_info.Elements[n].MaxVersionTested == expected_version[n - num_compat],
-                                "Wrong version, got %s for %u\n", wine_dbgstr_longlong(compat_info.Elements[n].MaxVersionTested), n);
+                                "Wrong version, got %s for %lu\n", wine_dbgstr_longlong(compat_info.Elements[n].MaxVersionTested), n);
         }
     }
 }
@@ -2935,7 +2935,7 @@ static void test_compatibility(void)
         return;
     }
     handle = test_create("test1.manifest");
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
     DeleteFileA("test1.manifest");
     if(handle != INVALID_HANDLE_VALUE)
     {
@@ -2967,7 +2967,7 @@ static void test_compatibility(void)
         return;
     }
     handle = test_create("no_supportedOs.manifest");
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
     DeleteFileA("no_supportedOs.manifest");
     if(handle != INVALID_HANDLE_VALUE)
     {
@@ -2984,7 +2984,7 @@ static void test_compatibility(void)
         return;
     }
     handle = test_create("manifest_vista.manifest");
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
     DeleteFileA("manifest_vista.manifest");
     if(handle != INVALID_HANDLE_VALUE)
     {
@@ -3005,7 +3005,7 @@ static void test_compatibility(void)
         return;
     }
     handle = test_create("manifest_vista_7_8_10_81.manifest");
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
     DeleteFileA("manifest_vista_7_8_10_81.manifest");
     if(handle != INVALID_HANDLE_VALUE)
     {
@@ -3035,7 +3035,7 @@ static void test_compatibility(void)
         return;
     }
     handle = test_create("manifest_other_guid.manifest");
-    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError());
     DeleteFileA("manifest_other_guid.manifest");
     if(handle != INVALID_HANDLE_VALUE)
     {
@@ -3069,100 +3069,100 @@ static void test_settings(void)
     }
     create_manifest_file( "manifest_settings.manifest", settings_manifest, -1, NULL, NULL );
     handle = test_create("manifest_settings.manifest");
-    ok( handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError() );
+    ok( handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError() );
     DeleteFileA( "manifest_settings.manifest" );
 
     SetLastError( 0xdeadbeef );
     ret = pQueryActCtxSettingsW( 1, handle, NULL, dpiAwareW, buffer, 80, &size );
-    ok( !ret, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( !ret, "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
     SetLastError( 0xdeadbeef );
     ret = pQueryActCtxSettingsW( 0, handle, dummyW, dpiAwareW, buffer, 80, &size );
-    ok( !ret, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( !ret, "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
     SetLastError( 0xdeadbeef );
     size = 0xdead;
     memset( buffer, 0xcc, sizeof(buffer) );
     ret = pQueryActCtxSettingsW( 0, handle, NULL, dpiAwareW, buffer, 80, &size );
-    ok( ret, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
+    ok( ret, "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
     ok( !lstrcmpW( buffer, trueW ), "got %s\n", wine_dbgstr_w(buffer) );
-    ok( size == lstrlenW( buffer ) + 1, "wrong len %lu\n", size );
+    ok( size == lstrlenW( buffer ) + 1, "wrong len %Iu\n", size );
     SetLastError( 0xdeadbeef );
     size = 0xdead;
     memset( buffer, 0xcc, sizeof(buffer) );
     ret = pQueryActCtxSettingsW( 0, handle, NULL, dummyW, buffer, 80, &size );
     ok( !ret, "QueryActCtxSettingsW succeeded\n" );
-    ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND, "wrong error %lu\n", GetLastError() );
     ok( buffer[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer) );
     SetLastError( 0xdeadbeef );
     size = 0xdead;
     memset( buffer, 0xcc, sizeof(buffer) );
     ret = pQueryActCtxSettingsW( 0, handle, namespace2005W, dpiAwareW, buffer, 80, &size );
-    ok( ret, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
+    ok( ret, "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
     ok( !lstrcmpW( buffer, trueW ), "got %s\n", wine_dbgstr_w(buffer) );
-    ok( size == ARRAY_SIZE(trueW), "wrong len %lu\n", size );
+    ok( size == ARRAY_SIZE(trueW), "wrong len %Iu\n", size );
     SetLastError( 0xdeadbeef );
     size = 0xdead;
     memset( buffer, 0xcc, sizeof(buffer) );
     ret = pQueryActCtxSettingsW( 0, handle, namespace2005W, dpiAwareW, buffer, lstrlenW(trueW) + 1, &size );
-    ok( ret, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
+    ok( ret, "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
     ok( !lstrcmpW( buffer, trueW ), "got %s\n", wine_dbgstr_w(buffer) );
-    ok( size == ARRAY_SIZE(trueW), "wrong len %lu\n", size );
+    ok( size == ARRAY_SIZE(trueW), "wrong len %Iu\n", size );
     SetLastError( 0xdeadbeef );
     size = 0xdead;
     memset( buffer, 0xcc, sizeof(buffer) );
     ret = pQueryActCtxSettingsW( 0, handle, namespace2016W, dpiAwareW, buffer, lstrlenW(trueW) + 1, &size );
     ok( !ret, "QueryActCtxSettingsW succeeded\n" );
     ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND || broken( GetLastError() == ERROR_INVALID_PARAMETER ),
-        "wrong error %u\n", GetLastError() );
+        "wrong error %lu\n", GetLastError() );
     ok( buffer[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer) );
     SetLastError( 0xdeadbeef );
     size = 0xdead;
     memset( buffer, 0xcc, sizeof(buffer) );
     ret = pQueryActCtxSettingsW( 0, handle, NULL, dpiAwarenessW, buffer, lstrlenW(trueW) + 1, &size );
     ok( !ret, "QueryActCtxSettingsW succeeded\n" );
-    ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND, "wrong error %lu\n", GetLastError() );
     ok( buffer[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer) );
     SetLastError( 0xdeadbeef );
     size = 0xdead;
     memset( buffer, 0xcc, sizeof(buffer) );
     ret = pQueryActCtxSettingsW( 0, handle, namespace2005W, dpiAwarenessW, buffer, lstrlenW(trueW) + 1, &size );
     ok( !ret, "QueryActCtxSettingsW succeeded\n" );
-    ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND, "wrong error %lu\n", GetLastError() );
     ok( buffer[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer) );
     SetLastError( 0xdeadbeef );
     size = 0xdead;
     memset( buffer, 0xcc, sizeof(buffer) );
     ret = pQueryActCtxSettingsW( 0, handle, namespace2016W, dpiAwarenessW, buffer, lstrlenW(trueW) + 1, &size );
     ok( ret  || broken( GetLastError() == ERROR_INVALID_PARAMETER ),
-        "QueryActCtxSettingsW failed err %u\n", GetLastError() );
+        "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
     if (ret)
     {
         ok( !lstrcmpW( buffer, trueW ), "got %s\n", wine_dbgstr_w(buffer) );
-        ok( size == ARRAY_SIZE(trueW), "wrong len %lu\n", size );
+        ok( size == ARRAY_SIZE(trueW), "wrong len %Iu\n", size );
     }
     else ok( buffer[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer) );
     SetLastError( 0xdeadbeef );
     size = 0xdead;
     memset( buffer, 0xcc, sizeof(buffer) );
     ret = pQueryActCtxSettingsW( 0, handle, NULL, dpiAwareW, buffer, lstrlenW(trueW), &size );
-    ok( ret, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
+    ok( ret, "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
     ok( !lstrcmpW( buffer, trueW ), "got %s\n", wine_dbgstr_w(buffer) );
-    ok( size == ARRAY_SIZE(trueW), "wrong len %lu\n", size );
+    ok( size == ARRAY_SIZE(trueW), "wrong len %Iu\n", size );
     SetLastError( 0xdeadbeef );
     size = 0xdead;
     memset( buffer, 0xcc, sizeof(buffer) );
     ret = pQueryActCtxSettingsW( 0, handle, NULL, dpiAwareW, buffer, lstrlenW(trueW) - 1, &size );
-    ok( !ret, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
-    ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %u\n", GetLastError() );
+    ok( !ret, "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
+    ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %lu\n", GetLastError() );
     ok( buffer[0] == 0xcccc, "got %s\n", wine_dbgstr_w(buffer) );
-    ok( size == ARRAY_SIZE(trueW), "wrong len %lu\n", size );
+    ok( size == ARRAY_SIZE(trueW), "wrong len %Iu\n", size );
     ReleaseActCtx(handle);
 
     create_manifest_file( "manifest_settings2.manifest", settings_manifest2, -1, NULL, NULL );
     handle = test_create("manifest_settings2.manifest");
     ok( handle != INVALID_HANDLE_VALUE || broken( handle == INVALID_HANDLE_VALUE ), /* <= vista */
-        "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError() );
+        "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError() );
     DeleteFileA( "manifest_settings2.manifest" );
     if (handle != INVALID_HANDLE_VALUE)
     {
@@ -3170,22 +3170,22 @@ static void test_settings(void)
         size = 0xdead;
         memset( buffer, 0xcc, sizeof(buffer) );
         ret = pQueryActCtxSettingsW( 0, handle, NULL, dpiAwareW, buffer, 80, &size );
-        ok( ret, "QueryActCtxSettingsW failed err %u\n", GetLastError() );
+        ok( ret, "QueryActCtxSettingsW failed err %lu\n", GetLastError() );
         ok( !lstrcmpW( buffer, trueW ), "got %s\n", wine_dbgstr_w(buffer) );
-        ok( size == lstrlenW( buffer ) + 1, "wrong len %lu\n", size );
+        ok( size == lstrlenW( buffer ) + 1, "wrong len %Iu\n", size );
         ReleaseActCtx(handle);
     }
 
     create_manifest_file( "manifest_settings3.manifest", settings_manifest3, -1, NULL, NULL );
     handle = test_create("manifest_settings3.manifest");
-    ok( handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError() );
+    ok( handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %lu\n", GetLastError() );
     DeleteFileA( "manifest_settings3.manifest" );
     SetLastError( 0xdeadbeef );
     size = 0xdead;
     memset( buffer, 0xcc, sizeof(buffer) );
     ret = pQueryActCtxSettingsW( 0, handle, NULL, dpiAwareW, buffer, 80, &size );
     ok( !ret, "QueryActCtxSettingsW succeeded\n" );
-    ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_SXS_KEY_NOT_FOUND, "wrong error %lu\n", GetLastError() );
     ReleaseActCtx(handle);
 }
 
@@ -3228,7 +3228,7 @@ static BOOL fill_sxs_info(sxs_info *info, const char *temp, const char *path_dll
     info->handle_context = CreateActCtxA(&info->context);
     ok((info->handle_context != NULL && info->handle_context != INVALID_HANDLE_VALUE )
             || broken(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX), /* XP doesn't support manifests outside of PE files */
-            "CreateActCtxA failed: %d\n", GetLastError());
+            "CreateActCtxA failed: %ld\n", GetLastError());
     if (GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX)
     {
         skip("Failed to create activation context.\n");
@@ -3238,7 +3238,7 @@ static BOOL fill_sxs_info(sxs_info *info, const char *temp, const char *path_dll
     if (do_load)
     {
         success = ActivateActCtx(info->handle_context, &info->cookie);
-        ok(success, "ActivateActCtx failed: %d\n", GetLastError());
+        ok(success, "ActivateActCtx failed: %ld\n", GetLastError());
 
         info->module = LoadLibraryA("sxs_dll.dll");
         ok(info->module != NULL, "LoadLibrary failed\n");
@@ -3258,22 +3258,22 @@ static void clean_sxs_info(sxs_info *info)
     if (*info->path_dll)
     {
         BOOL ret = DeleteFileA(info->path_dll);
-        ok(ret, "DeleteFileA failed for %s: %d\n", info->path_dll, GetLastError());
+        ok(ret, "DeleteFileA failed for %s: %ld\n", info->path_dll, GetLastError());
     }
     if (*info->path_manifest_exe)
     {
         BOOL ret = DeleteFileA(info->path_manifest_exe);
-        ok(ret, "DeleteFileA failed for %s: %d\n", info->path_manifest_exe, GetLastError());
+        ok(ret, "DeleteFileA failed for %s: %ld\n", info->path_manifest_exe, GetLastError());
     }
     if (*info->path_manifest_dll)
     {
         BOOL ret = DeleteFileA(info->path_manifest_dll);
-        ok(ret, "DeleteFileA failed for %s: %d\n", info->path_manifest_dll, GetLastError());
+        ok(ret, "DeleteFileA failed for %s: %ld\n", info->path_manifest_dll, GetLastError());
     }
     if (*info->path_tmp)
     {
         BOOL ret = RemoveDirectoryA(info->path_tmp);
-        ok(ret, "RemoveDirectoryA failed for %s: %d\n", info->path_tmp, GetLastError());
+        ok(ret, "RemoveDirectoryA failed for %s: %ld\n", info->path_tmp, GetLastError());
     }
 }
 
@@ -3348,7 +3348,7 @@ cleanup:
     if (*path_dll_local)
     {
         BOOL success = DeleteFileA(path_dll_local);
-        ok(success, "DeleteFileA failed for %s: %d\n", path_dll_local, GetLastError());
+        ok(success, "DeleteFileA failed for %s: %ld\n", path_dll_local, GetLastError());
     }
     clean_sxs_info(&dll);
 }
@@ -3388,7 +3388,7 @@ cleanup:
     if (*path_dll_local)
     {
         BOOL success = DeleteFileA(path_dll_local);
-        ok(success, "DeleteFileA failed for %s: %d\n", path_dll_local, GetLastError());
+        ok(success, "DeleteFileA failed for %s: %ld\n", path_dll_local, GetLastError());
     }
     clean_sxs_info(&dll);
 }
@@ -3414,7 +3414,7 @@ static void test_one_with_sxs_and_GetModuleHandleA(void)
        goto cleanup;
 
     success = ActivateActCtx(dll.handle_context, &dll.cookie);
-    ok(success, "ActivateActCtx failed: %d\n", GetLastError());
+    ok(success, "ActivateActCtx failed: %ld\n", GetLastError());
 
     module_temp = GetModuleHandleA("sxs_dll.dll");
     ok (module_temp == 0, "Expected 0, got %p\n", module_temp);
@@ -3429,7 +3429,7 @@ cleanup:
     if (*path_dll_local)
     {
         success = DeleteFileA(path_dll_local);
-        ok(success, "DeleteFileA failed for %s: %d\n", path_dll_local, GetLastError());
+        ok(success, "DeleteFileA failed for %s: %ld\n", path_dll_local, GetLastError());
     }
     clean_sxs_info(&dll);
 }
@@ -3459,7 +3459,7 @@ static void test_builtin_sxs(void)
     handle_context = CreateActCtxA(&context);
     ok((handle_context != NULL && handle_context != INVALID_HANDLE_VALUE )
         || broken(GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX), /* XP doesn't support manifests outside of PE files */
-        "CreateActCtxA failed: %d\n", GetLastError());
+        "CreateActCtxA failed: %ld\n", GetLastError());
     if (GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX)
     {
         skip("Failed to create activation context.\n");
@@ -3468,12 +3468,12 @@ static void test_builtin_sxs(void)
 
 
     success = ActivateActCtx(handle_context, &cookie);
-    ok(success, "ActivateActCtx failed: %d\n", GetLastError());
+    ok(success, "ActivateActCtx failed: %ld\n", GetLastError());
 
     module_msvcp = LoadLibraryA("msvcp90.dll");
-    ok (module_msvcp != 0 || broken(module_msvcp == 0), "LoadLibraryA failed, %d\n", GetLastError());
+    ok (module_msvcp != 0 || broken(module_msvcp == 0), "LoadLibraryA failed, %ld\n", GetLastError());
     module_msvcr = LoadLibraryA("msvcr90.dll");
-    ok (module_msvcr != 0 || broken(module_msvcr == 0), "LoadLibraryA failed, %d\n", GetLastError());
+    ok (module_msvcr != 0 || broken(module_msvcr == 0), "LoadLibraryA failed, %ld\n", GetLastError());
     if (!module_msvcp || !module_msvcr)
     {
         skip("Failed to find msvcp90 or msvcr90.\n");
@@ -3495,7 +3495,7 @@ cleanup:
     if (*path_manifest)
     {
         success = DeleteFileA(path_manifest);
-        ok(success, "DeleteFileA failed for %s: %d\n", path_manifest, GetLastError());
+        ok(success, "DeleteFileA failed for %s: %ld\n", path_manifest, GetLastError());
     }
 }
 
@@ -3540,7 +3540,7 @@ static void run_child_process_two_dll(int run)
 
     si.cb = sizeof(si);
     ret = CreateProcessA(exe, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-    ok(ret, "Could not create process: %u\n", GetLastError());
+    ok(ret, "Could not create process: %lu\n", GetLastError());
 
     wait_child_process( pi.hProcess );
 
@@ -3566,7 +3566,7 @@ static void test_manifest_in_module(void)
     ctx.lpResourceName = (LPWSTR)124;
     ctx.hModule = GetModuleHandleW(NULL);
     handle = CreateActCtxW(&ctx);
-    ok(handle != 0, "CreateActCtx error %u\n", GetLastError());
+    ok(handle != 0, "CreateActCtx error %lu\n", GetLastError());
 
     test_basic_info(handle, __LINE__);
     test_detailed_info(handle, &detailed_info3, __LINE__);
diff --git a/dlls/kernel32/tests/atom.c b/dlls/kernel32/tests/atom.c
index 4796d41d23d..6d37c97388f 100644
--- a/dlls/kernel32/tests/atom.c
+++ b/dlls/kernel32/tests/atom.c
@@ -115,20 +115,20 @@ static void test_add_atom(void)
     {
         SetLastError( 0xdeadbeef );
         ok( GlobalAddAtomA((LPCSTR)i) == i && GetLastError() == 0xdeadbeef,
-            "failed to add atom %lx\n", i );
+            "failed to add atom %Ix\n", i );
         if (unicode_OS)
         {
             SetLastError( 0xdeadbeef );
             ok( GlobalAddAtomW((LPCWSTR)i) == i && GetLastError() == 0xdeadbeef,
-                "failed to add atom %lx\n", i );
+                "failed to add atom %Ix\n", i );
         }
     }
 
     for (i = 0xc000; i <= 0xffff; i++)
     {
-        ok( !GlobalAddAtomA((LPCSTR)i), "succeeded adding %lx\n", i );
+        ok( !GlobalAddAtomA((LPCSTR)i), "succeeded adding %Ix\n", i );
         if (unicode_OS)
-            ok( !GlobalAddAtomW((LPCWSTR)i), "succeeded adding %lx\n", i );
+            ok( !GlobalAddAtomW((LPCWSTR)i), "succeeded adding %Ix\n", i );
     }
 }
 
@@ -196,7 +196,7 @@ static void test_get_atom_name(void)
         len = GlobalGetAtomNameA( (ATOM)i, buf, 2);
         ok(!len, "bad length %d\n", len);
 	ok(GetLastError() == ERROR_MORE_DATA || GetLastError() == ERROR_INVALID_PARAMETER,
-            "wrong error conditions %u for %u\n", GetLastError(), i);
+            "wrong error conditions %lu for %u\n", GetLastError(), i);
     }
 
     memset( buf, '.', sizeof(buf) );
@@ -229,7 +229,7 @@ static void test_get_atom_name(void)
     SetLastError(0xdeadbeef);
     len = GlobalGetAtomNameA(atom, out, 10);
     ok(!len, "bad length %d\n", len);
-    ok(GetLastError() == ERROR_MORE_DATA, "wrong error code (%u instead of %u)\n", GetLastError(), ERROR_MORE_DATA);
+    ok(GetLastError() == ERROR_MORE_DATA, "wrong error code (%lu instead of %u)\n", GetLastError(), ERROR_MORE_DATA);
     for (i = 0; i < 9; i++)
     {
         ok(out[i] == "abcdefghij"[i % 10], "wrong string at %i (%c instead of %c)\n", i, out[i], "abcdefghij"[i % 10]);
@@ -266,7 +266,7 @@ static void test_get_atom_name(void)
             {
                 /* len == 0 with ERROR_MORE_DATA is on NT3.51 */
                 ok(len == 1 || (len == 0 && GetLastError() == ERROR_MORE_DATA),
-                         "0x%04x: got %u with %d (expected '1' or '0' with "
+                         "0x%04x: got %u with %ld (expected '1' or '0' with "
                          "ERROR_MORE_DATA)\n", i, len, GetLastError());
                 ok(outW[1] == DOUBLE('.'), "buffer overwrite\n");
             }
@@ -373,20 +373,20 @@ static void test_local_add_atom(void)
     {
         SetLastError( 0xdeadbeef );
         ok( AddAtomA((LPCSTR)i) == i && GetLastError() == 0xdeadbeef,
-            "failed to add atom %lx\n", i );
+            "failed to add atom %Ix\n", i );
         if (unicode_OS)
         {
             SetLastError( 0xdeadbeef );
             ok( AddAtomW((LPCWSTR)i) == i && GetLastError() == 0xdeadbeef,
-                "failed to add atom %lx\n", i );
+                "failed to add atom %Ix\n", i );
         }
     }
 
     for (i = 0xc000; i <= 0xffff; i++)
     {
-        ok( !AddAtomA((LPCSTR)i), "succeeded adding %lx\n", i );
+        ok( !AddAtomA((LPCSTR)i), "succeeded adding %Ix\n", i );
         if (unicode_OS)
-            ok( !AddAtomW((LPCWSTR)i), "succeeded adding %lx\n", i );
+            ok( !AddAtomW((LPCWSTR)i), "succeeded adding %Ix\n", i );
     }
 }
 
@@ -472,11 +472,11 @@ static void test_local_get_atom_name(void)
         if (i)
             ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
                GetLastError() == ERROR_MORE_DATA,
-               "wrong error conditions %u for %u\n", GetLastError(), i);
+               "wrong error conditions %lu for %u\n", GetLastError(), i);
         else
             ok(GetLastError() == ERROR_INVALID_PARAMETER ||
                GetLastError() == ERROR_MORE_DATA,
-               "wrong error conditions %u for %u\n", GetLastError(), i);
+               "wrong error conditions %lu for %u\n", GetLastError(), i);
     }
     /* test string limits & overflow */
     do_initA(in, "abcdefghij", 255);
@@ -505,7 +505,7 @@ static void test_local_get_atom_name(void)
     /* ERROR_MORE_DATA is on nt3.51 sp5 */
     ok(GetLastError() == ERROR_INVALID_PARAMETER ||
        GetLastError() == ERROR_MORE_DATA,
-       "wrong error code (%u)\n", GetLastError());
+       "wrong error code (%lu)\n", GetLastError());
 
     if (unicode_OS)
     {
@@ -532,7 +532,7 @@ static void test_local_get_atom_name(void)
             /* ERROR_MORE_DATA is on nt3.51 sp5 */
             ok(GetLastError() == ERROR_MORE_DATA ||
                GetLastError() == (i ? ERROR_INSUFFICIENT_BUFFER : ERROR_INVALID_PARAMETER),
-               "wrong error conditions %u for %u\n", GetLastError(), i);
+               "wrong error conditions %lu for %u\n", GetLastError(), i);
         }
         do_initW(inW, "abcdefghij", 255);
         atom = AddAtomW(inW);
@@ -560,7 +560,7 @@ static void test_local_get_atom_name(void)
         /* ERROR_MORE_DATA is on nt3.51 sp5 */
         ok(GetLastError() == ERROR_INVALID_PARAMETER ||
            GetLastError() == ERROR_MORE_DATA,
-           "wrong error code (%u)\n", GetLastError());
+           "wrong error code (%lu)\n", GetLastError());
     }
 }
 
diff --git a/dlls/kernel32/tests/change.c b/dlls/kernel32/tests/change.c
index c0fcf00ba68..609cf30bcfa 100644
--- a/dlls/kernel32/tests/change.c
+++ b/dlls/kernel32/tests/change.c
@@ -51,7 +51,7 @@ static DWORD CALLBACK NotificationThread(LPVOID arg)
     }
 
     ret = FindCloseChangeNotification(change);
-    ok( ret, "FindCloseChangeNotification error: %d\n",
+    ok( ret, "FindCloseChangeNotification error: %ld\n",
        GetLastError());
 
     ExitThread((DWORD)notified);
@@ -63,10 +63,10 @@ static HANDLE StartNotificationThread(LPCSTR path, BOOL subtree, DWORD flags)
     DWORD threadId;
 
     change = FindFirstChangeNotificationA(path, subtree, flags);
-    ok(change != INVALID_HANDLE_VALUE, "FindFirstChangeNotification error: %d\n", GetLastError());
+    ok(change != INVALID_HANDLE_VALUE, "FindFirstChangeNotification error: %ld\n", GetLastError());
 
     thread = CreateThread(NULL, 0, NotificationThread, change, 0, &threadId);
-    ok(thread != NULL, "CreateThread error: %d\n", GetLastError());
+    ok(thread != NULL, "CreateThread error: %ld\n", GetLastError());
 
     return thread;
 }
@@ -76,7 +76,7 @@ static DWORD FinishNotificationThread(HANDLE thread)
     DWORD status, exitcode;
 
     status = WaitForSingleObject(thread, 5000);
-    ok(status == WAIT_OBJECT_0, "WaitForSingleObject status %d error %d\n", status, GetLastError());
+    ok(status == WAIT_OBJECT_0, "WaitForSingleObject status %ld error %ld\n", status, GetLastError());
 
     ok(GetExitCodeThread(thread, &exitcode), "Could not retrieve thread exit code\n");
     CloseHandle(thread);
@@ -100,46 +100,46 @@ static void test_FindFirstChangeNotification(void)
     change = FindFirstChangeNotificationA("not-a-file", FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
     ok(change == INVALID_HANDLE_VALUE, "Expected INVALID_HANDLE_VALUE, got %p\n", change);
     ok(GetLastError() == ERROR_FILE_NOT_FOUND,
-       "FindFirstChangeNotification error: %d\n", GetLastError());
+       "FindFirstChangeNotification error: %ld\n", GetLastError());
 
     change = FindFirstChangeNotificationA(NULL, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
     ok(change == INVALID_HANDLE_VALUE || broken(change == NULL) /* < win7 */,
        "Expected INVALID_HANDLE_VALUE, got %p\n", change);
     ok(GetLastError() == ERROR_PATH_NOT_FOUND,
-       "FindFirstChangeNotification error: %u\n", GetLastError());
+       "FindFirstChangeNotification error: %lu\n", GetLastError());
 
     ret = FindNextChangeNotification(NULL);
-    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "FindNextChangeNotification error: %d\n",
+    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "FindNextChangeNotification error: %ld\n",
        GetLastError());
 
     ret = FindCloseChangeNotification(NULL);
-    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "FindCloseChangeNotification error: %d\n",
+    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "FindCloseChangeNotification error: %ld\n",
        GetLastError());
 
     ret = GetTempPathA(MAX_PATH, dirname1);
-    ok(ret, "GetTempPathA error: %d\n", GetLastError());
+    ok(ret, "GetTempPathA error: %ld\n", GetLastError());
 
     ret = GetTempFileNameA(dirname1, "ffc", 0, workdir);
-    ok(ret, "GetTempFileNameA error: %d\n", GetLastError());
+    ok(ret, "GetTempFileNameA error: %ld\n", GetLastError());
     DeleteFileA( workdir );
 
     ret = CreateDirectoryA(workdir, NULL);
-    ok(ret, "CreateDirectoryA error: %d\n", GetLastError());
+    ok(ret, "CreateDirectoryA error: %ld\n", GetLastError());
 
     ret = GetTempFileNameA(workdir, prefix, 0, filename1);
-    ok(ret, "GetTempFileNameA error: %d\n", GetLastError());
+    ok(ret, "GetTempFileNameA error: %ld\n", GetLastError());
 
     file = CreateFileA(filename1, GENERIC_WRITE|GENERIC_READ, 0, NULL, CREATE_ALWAYS,
                        FILE_ATTRIBUTE_NORMAL, 0);
-    ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %d\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %ld\n", GetLastError());
     ret = CloseHandle(file);
-    ok( ret, "CloseHandle error: %d\n", GetLastError());
+    ok( ret, "CloseHandle error: %ld\n", GetLastError());
 
     /* Try to register notification for a file */
     change = FindFirstChangeNotificationA(filename1, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
     ok(change == INVALID_HANDLE_VALUE, "Expected INVALID_HANDLE_VALUE, got %p\n", change);
     ok(GetLastError() == ERROR_DIRECTORY,
-       "FindFirstChangeNotification error: %d\n", GetLastError());
+       "FindFirstChangeNotification error: %ld\n", GetLastError());
 
     lstrcpyA(dirname1, filename1);
     lstrcatA(dirname1, "dir");
@@ -148,18 +148,18 @@ static void test_FindFirstChangeNotification(void)
     lstrcatA(dirname2, "new");
 
     ret = CreateDirectoryA(dirname1, NULL);
-    ok(ret, "CreateDirectoryA error: %d\n", GetLastError());
+    ok(ret, "CreateDirectoryA error: %ld\n", GetLastError());
 
     /* What if we move the directory we registered notification for? */
     thread = StartNotificationThread(dirname1, FALSE, FILE_NOTIFY_CHANGE_DIR_NAME);
     ret = MoveFileA(dirname1, dirname2);
-    ok(ret, "MoveFileA error: %d\n", GetLastError());
+    ok(ret, "MoveFileA error: %ld\n", GetLastError());
     ok(!FinishNotificationThread(thread), "Got notification\n");
 
     /* What if we remove the directory we registered notification for? */
     thread = StartNotificationThread(dirname2, FALSE, FILE_NOTIFY_CHANGE_DIR_NAME);
     ret = RemoveDirectoryA(dirname2);
-    ok(ret, "RemoveDirectoryA error: %d\n", GetLastError());
+    ok(ret, "RemoveDirectoryA error: %ld\n", GetLastError());
     ret = FinishNotificationThread(thread);
     todo_wine ok(ret, "Missed notification\n");
 
@@ -168,19 +168,19 @@ static void test_FindFirstChangeNotification(void)
     /* Create a directory */
     thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_DIR_NAME);
     ret = CreateDirectoryA(dirname1, NULL);
-    ok(ret, "CreateDirectoryA error: %d\n", GetLastError());
+    ok(ret, "CreateDirectoryA error: %ld\n", GetLastError());
     ok(FinishNotificationThread(thread), "Missed notification\n");
 
     /* Rename a directory */
     thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_DIR_NAME);
     ret = MoveFileA(dirname1, dirname2);
-    ok(ret, "MoveFileA error: %d\n", GetLastError());
+    ok(ret, "MoveFileA error: %ld\n", GetLastError());
     ok(FinishNotificationThread(thread), "Missed notification\n");
 
     /* Delete a directory */
     thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_DIR_NAME);
     ret = RemoveDirectoryA(dirname2);
-    ok(ret, "RemoveDirectoryA error: %d\n", GetLastError());
+    ok(ret, "RemoveDirectoryA error: %ld\n", GetLastError());
     ok(FinishNotificationThread(thread), "Missed notification\n");
 
     lstrcpyA(filename2, filename1);
@@ -189,64 +189,64 @@ static void test_FindFirstChangeNotification(void)
     /* Rename a file */
     thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
     ret = MoveFileA(filename1, filename2);
-    ok(ret, "MoveFileA error: %d\n", GetLastError());
+    ok(ret, "MoveFileA error: %ld\n", GetLastError());
     ok(FinishNotificationThread(thread), "Missed notification\n");
 
     /* Delete a file */
     thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
     ret = DeleteFileA(filename2);
-    ok(ret, "DeleteFileA error: %d\n", GetLastError());
+    ok(ret, "DeleteFileA error: %ld\n", GetLastError());
     ok(FinishNotificationThread(thread), "Missed notification\n");
 
     /* Create a file */
     thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME);
     file = CreateFileA(filename2, GENERIC_WRITE|GENERIC_READ, 0, NULL, CREATE_ALWAYS, 
                        FILE_ATTRIBUTE_NORMAL, 0);
-    ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %d\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %ld\n", GetLastError());
     ret = CloseHandle(file);
-    ok( ret, "CloseHandle error: %d\n", GetLastError());
+    ok( ret, "CloseHandle error: %ld\n", GetLastError());
     ok(FinishNotificationThread(thread), "Missed notification\n");
 
     attributes = GetFileAttributesA(filename2);
-    ok(attributes != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA error: %d\n", GetLastError());
+    ok(attributes != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA error: %ld\n", GetLastError());
     attributes &= FILE_ATTRIBUTE_READONLY;
 
     /* Change file attributes */
     thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_ATTRIBUTES);
     ret = SetFileAttributesA(filename2, attributes);
-    ok(ret, "SetFileAttributesA error: %d\n", GetLastError());
+    ok(ret, "SetFileAttributesA error: %ld\n", GetLastError());
     ok(FinishNotificationThread(thread), "Missed notification\n");
 
     /* Change last write time by writing to a file */
     thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE);
     file = CreateFileA(filename2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 
                        FILE_ATTRIBUTE_NORMAL, 0);
-    ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %d\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %ld\n", GetLastError());
     memset(buffer, 0, sizeof(buffer));
     ret = WriteFile(file, buffer, sizeof(buffer), &count, NULL);
-    ok(ret && count == sizeof(buffer), "WriteFile error: %d\n", GetLastError());
+    ok(ret && count == sizeof(buffer), "WriteFile error: %ld\n", GetLastError());
     ret = CloseHandle(file);
-    ok( ret, "CloseHandle error: %d\n", GetLastError());
+    ok( ret, "CloseHandle error: %ld\n", GetLastError());
     ok(FinishNotificationThread(thread), "Missed notification\n");
 
     /* Change file size by truncating a file */
     thread = StartNotificationThread(workdir, FALSE, FILE_NOTIFY_CHANGE_SIZE);
     file = CreateFileA(filename2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 
                        FILE_ATTRIBUTE_NORMAL, 0);
-    ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %d\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "CreateFileA error: %ld\n", GetLastError());
     ret = WriteFile(file, buffer, sizeof(buffer) / 2, &count, NULL);
-    ok(ret && count == sizeof(buffer) / 2, "WriteFileA error: %d\n", GetLastError());
+    ok(ret && count == sizeof(buffer) / 2, "WriteFileA error: %ld\n", GetLastError());
     ret = CloseHandle(file);
-    ok( ret, "CloseHandle error: %d\n", GetLastError());
+    ok( ret, "CloseHandle error: %ld\n", GetLastError());
     ok(FinishNotificationThread(thread), "Missed notification\n");
 
     /* clean up */
     
     ret = DeleteFileA(filename2);
-    ok(ret, "DeleteFileA error: %d\n", GetLastError());
+    ok(ret, "DeleteFileA error: %ld\n", GetLastError());
 
     ret = RemoveDirectoryA(workdir);
-    ok(ret, "RemoveDirectoryA error: %d\n", GetLastError());
+    ok(ret, "RemoveDirectoryA error: %ld\n", GetLastError());
 }
 
 /* this test concentrates more on the wait behaviour of the handle */
@@ -287,7 +287,7 @@ static void test_ffcn(void)
 
     file = CreateFileW( filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                         CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0 );
-    ok( file != INVALID_HANDLE_VALUE, "CreateFile error %u\n", GetLastError() );
+    ok( file != INVALID_HANDLE_VALUE, "CreateFile error %lu\n", GetLastError() );
     CloseHandle(file);
 
     r = WaitForSingleObject( handle, 0 );
@@ -364,20 +364,20 @@ static void test_ffcnMultipleThreads(void)
     char tmp[MAX_PATH], path[MAX_PATH];
 
     r = GetTempPathA(MAX_PATH, tmp);
-    ok(r, "GetTempPathA error: %d\n", GetLastError());
+    ok(r, "GetTempPathA error: %ld\n", GetLastError());
 
     r = GetTempFileNameA(tmp, "ffc", 0, path);
-    ok(r, "GetTempFileNameA error: %d\n", GetLastError());
+    ok(r, "GetTempFileNameA error: %ld\n", GetLastError());
     DeleteFileA( path );
 
     r = CreateDirectoryA(path, NULL);
-    ok(r, "CreateDirectoryA error: %d\n", GetLastError());
+    ok(r, "CreateDirectoryA error: %ld\n", GetLastError());
 
     filter = FILE_NOTIFY_CHANGE_FILE_NAME;
     filter |= FILE_NOTIFY_CHANGE_DIR_NAME;
 
     handles[0] = FindFirstChangeNotificationA(path, FALSE, filter);
-    ok(handles[0] != INVALID_HANDLE_VALUE, "FindFirstChangeNotification error: %d\n", GetLastError());
+    ok(handles[0] != INVALID_HANDLE_VALUE, "FindFirstChangeNotification error: %ld\n", GetLastError());
 
     /* Test behavior if a waiting thread holds the last reference to a change
      * directory object with an empty wine user APC queue for this thread (bug #7286) */
@@ -385,10 +385,10 @@ static void test_ffcnMultipleThreads(void)
     /* Create our notification thread */
     handles[1] = CreateThread(NULL, 0, NotificationThread, handles[0], 0,
                               &threadId);
-    ok(handles[1] != NULL, "CreateThread error: %d\n", GetLastError());
+    ok(handles[1] != NULL, "CreateThread error: %ld\n", GetLastError());
 
     status = WaitForMultipleObjects(2, handles, FALSE, 5000);
-    ok(status == WAIT_OBJECT_0 || status == WAIT_OBJECT_0+1, "WaitForMultipleObjects status %d error %d\n", status, GetLastError());
+    ok(status == WAIT_OBJECT_0 || status == WAIT_OBJECT_0+1, "WaitForMultipleObjects status %ld error %ld\n", status, GetLastError());
     ok(GetExitCodeThread(handles[1], &exitcode), "Could not retrieve thread exit code\n");
 
     /* Clean up */
@@ -614,18 +614,18 @@ static void test_readdirectorychanges(void)
     /* we may get a notification for the parent dir too */
     if (pfni->Action == FILE_ACTION_MODIFIED && pfni->NextEntryOffset)
     {
-        ok( pfni->FileNameLength == 3*sizeof(WCHAR), "len wrong %u\n", pfni->FileNameLength );
+        ok( pfni->FileNameLength == 3*sizeof(WCHAR), "len wrong %lu\n", pfni->FileNameLength );
         ok( !memcmp(pfni->FileName,&szGa[1],3*sizeof(WCHAR)), "name wrong\n" );
         pfni = (PFILE_NOTIFY_INFORMATION)((char *)pfni + pfni->NextEntryOffset);
     }
-    ok( pfni->NextEntryOffset == 0, "offset wrong %u\n", pfni->NextEntryOffset );
-    ok( pfni->Action == FILE_ACTION_REMOVED, "action wrong %u\n", pfni->Action );
-    ok( pfni->FileNameLength == 6*sizeof(WCHAR), "len wrong %u\n", pfni->FileNameLength );
+    ok( pfni->NextEntryOffset == 0, "offset wrong %lu\n", pfni->NextEntryOffset );
+    ok( pfni->Action == FILE_ACTION_REMOVED, "action wrong %lu\n", pfni->Action );
+    ok( pfni->FileNameLength == 6*sizeof(WCHAR), "len wrong %lu\n", pfni->FileNameLength );
     ok( !memcmp(pfni->FileName,&szGa[1],6*sizeof(WCHAR)), "name wrong\n" );
 
     ok( (NTSTATUS)ov.Internal == STATUS_SUCCESS, "ov.Internal wrong\n");
     dwCount = (char *)&pfni->FileName[pfni->FileNameLength/sizeof(WCHAR)] - buffer;
-    ok( ov.InternalHigh == dwCount, "ov.InternalHigh wrong %lu/%u\n",ov.InternalHigh, dwCount );
+    ok( ov.InternalHigh == dwCount, "ov.InternalHigh wrong %Iu/%lu\n",ov.InternalHigh, dwCount );
 
     CloseHandle(hdir);
 
@@ -799,7 +799,7 @@ static void test_readdirectorychanges_filedir(void)
 
 static void CALLBACK readdirectorychanges_cr(DWORD error, DWORD len, LPOVERLAPPED ov)
 {
-    ok(error == 0, "ReadDirectoryChangesW error %d\n", error);
+    ok(error == 0, "ReadDirectoryChangesW error %ld\n", error);
     ok(ov->hEvent == (void*)0xdeadbeef, "hEvent should not have changed\n");
 }
 
@@ -853,9 +853,9 @@ static void test_readdirectorychanges_cr(void)
     r = SleepEx(1000, TRUE);
     ok(r != 0, "failed to receive file creation event\n");
     ok(fni->NextEntryOffset == 0, "there should be no more events in buffer\n");
-    ok(fni->Action == FILE_ACTION_ADDED, "Action = %d\n", fni->Action);
+    ok(fni->Action == FILE_ACTION_ADDED, "Action = %ld\n", fni->Action);
     ok(fni->FileNameLength == lstrlenW(szFile)*sizeof(WCHAR),
-            "FileNameLength = %d\n", fni->FileNameLength);
+            "FileNameLength = %ld\n", fni->FileNameLength);
     ok(!memcmp(fni->FileName, szFile, lstrlenW(szFile)*sizeof(WCHAR)),
             "FileName = %s\n", wine_dbgstr_wn(fni->FileName, fni->FileNameLength/sizeof(WCHAR)));
 
@@ -873,9 +873,9 @@ static void test_readdirectorychanges_cr(void)
     r = SleepEx(1000, TRUE);
     ok(r != 0, "failed to receive file move event\n");
     ok(fni->NextEntryOffset == 0, "there should be no more events in buffer\n");
-    ok(fni->Action == FILE_ACTION_REMOVED, "Action = %d\n", fni->Action);
+    ok(fni->Action == FILE_ACTION_REMOVED, "Action = %ld\n", fni->Action);
     ok(fni->FileNameLength == lstrlenW(szFile)*sizeof(WCHAR),
-            "FileNameLength = %d\n", fni->FileNameLength);
+            "FileNameLength = %ld\n", fni->FileNameLength);
     ok(!memcmp(fni->FileName, szFile, lstrlenW(szFile)*sizeof(WCHAR)),
             "FileName = %s\n", wine_dbgstr_wn(fni->FileName, fni->FileNameLength/sizeof(WCHAR)));
 
@@ -889,9 +889,9 @@ static void test_readdirectorychanges_cr(void)
     r = SleepEx(1000, TRUE);
     ok(r != 0, "failed to receive file move event\n");
     ok(fni->NextEntryOffset == 0, "there should be no more events in buffer\n");
-    ok(fni->Action == FILE_ACTION_ADDED, "Action = %d\n", fni->Action);
+    ok(fni->Action == FILE_ACTION_ADDED, "Action = %ld\n", fni->Action);
     ok(fni->FileNameLength == lstrlenW(szFile)*sizeof(WCHAR),
-            "FileNameLength = %d\n", fni->FileNameLength);
+            "FileNameLength = %ld\n", fni->FileNameLength);
     ok(!memcmp(fni->FileName, szFile, lstrlenW(szFile)*sizeof(WCHAR)),
             "FileName = %s\n", wine_dbgstr_wn(fni->FileName, fni->FileNameLength/sizeof(WCHAR)));
 
@@ -905,9 +905,9 @@ static void test_readdirectorychanges_cr(void)
     r = SleepEx(1000, TRUE);
     ok(r != 0, "failed to receive file removal event\n");
     ok(fni->NextEntryOffset == 0, "there should be no more events in buffer\n");
-    ok(fni->Action == FILE_ACTION_REMOVED, "Action = %d\n", fni->Action);
+    ok(fni->Action == FILE_ACTION_REMOVED, "Action = %ld\n", fni->Action);
     ok(fni->FileNameLength == lstrlenW(szFile)*sizeof(WCHAR),
-            "FileNameLength = %d\n", fni->FileNameLength);
+            "FileNameLength = %ld\n", fni->FileNameLength);
     ok(!memcmp(fni->FileName, szFile, lstrlenW(szFile)*sizeof(WCHAR)),
             "FileName = %s\n", wine_dbgstr_wn(fni->FileName, fni->FileNameLength/sizeof(WCHAR)));
 
@@ -929,17 +929,17 @@ static void test_readdirectorychanges_cr(void)
     ok(r != 0, "failed to receive directory move event\n");
     if (fni->Action == FILE_ACTION_RENAMED_OLD_NAME)
     {
-        ok(fni->Action == FILE_ACTION_RENAMED_OLD_NAME, "Action = %d\n", fni->Action);
+        ok(fni->Action == FILE_ACTION_RENAMED_OLD_NAME, "Action = %ld\n", fni->Action);
         ok(fni->FileNameLength == lstrlenW(szDir)*sizeof(WCHAR),
-                "FileNameLength = %d\n", fni->FileNameLength);
+                "FileNameLength = %ld\n", fni->FileNameLength);
         ok(!memcmp(fni->FileName, szDir, lstrlenW(szDir)*sizeof(WCHAR)),
                 "FileName = %s\n", wine_dbgstr_wn(fni->FileName, fni->FileNameLength/sizeof(WCHAR)));
         ok(fni->NextEntryOffset != 0, "no next entry in movement event\n");
         fni_next = (FILE_NOTIFY_INFORMATION*)((char*)fni+fni->NextEntryOffset);
         ok(fni_next->NextEntryOffset == 0, "there should be no more events in buffer\n");
-        ok(fni_next->Action == FILE_ACTION_RENAMED_NEW_NAME, "Action = %d\n", fni_next->Action);
+        ok(fni_next->Action == FILE_ACTION_RENAMED_NEW_NAME, "Action = %ld\n", fni_next->Action);
         ok(fni_next->FileNameLength == lstrlenW(szFile)*sizeof(WCHAR),
-                "FileNameLength = %d\n", fni_next->FileNameLength);
+                "FileNameLength = %ld\n", fni_next->FileNameLength);
         ok(!memcmp(fni_next->FileName, szFile, lstrlenW(szFile)*sizeof(WCHAR)),
                 "FileName = %s\n", wine_dbgstr_wn(fni_next->FileName, fni_next->FileNameLength/sizeof(WCHAR)));
     }
@@ -970,9 +970,9 @@ static void test_readdirectorychanges_cr(void)
 
     r = SleepEx(1000, TRUE);
     ok(r != 0, "failed to receive directory creation event\n");
-    ok(fni->Action == FILE_ACTION_ADDED, "Action = %d\n", fni->Action);
+    ok(fni->Action == FILE_ACTION_ADDED, "Action = %ld\n", fni->Action);
     ok(fni->FileNameLength == lstrlenW(szDir)*sizeof(WCHAR),
-            "FileNameLength = %d\n", fni->FileNameLength);
+            "FileNameLength = %ld\n", fni->FileNameLength);
     ok(!memcmp(fni->FileName, szDir, lstrlenW(szDir)*sizeof(WCHAR)),
             "FileName = %s\n", wine_dbgstr_wn(fni->FileName, fni->FileNameLength/sizeof(WCHAR)));
     if (fni->NextEntryOffset)
@@ -988,9 +988,9 @@ static void test_readdirectorychanges_cr(void)
         fni_next = fni;
     }
     ok(fni_next->NextEntryOffset == 0, "there should be no more events in buffer\n");
-    ok(fni_next->Action == FILE_ACTION_REMOVED, "Action = %d\n", fni_next->Action);
+    ok(fni_next->Action == FILE_ACTION_REMOVED, "Action = %ld\n", fni_next->Action);
     ok(fni_next->FileNameLength == lstrlenW(szDir)*sizeof(WCHAR),
-            "FileNameLength = %d\n", fni_next->FileNameLength);
+            "FileNameLength = %ld\n", fni_next->FileNameLength);
     ok(!memcmp(fni_next->FileName, szDir, lstrlenW(szDir)*sizeof(WCHAR)),
             "FileName = %s\n", wine_dbgstr_wn(fni_next->FileName, fni_next->FileNameLength/sizeof(WCHAR)));
 
@@ -1010,21 +1010,21 @@ static void test_ffcn_directory_overlap(void)
     /* Setup directory hierarchy */
     ret = GetTempPathA(MAX_PATH, workdir);
     ok((ret > 0) && (ret <= MAX_PATH),
-       "GetTempPathA error: %d\n", GetLastError());
+       "GetTempPathA error: %ld\n", GetLastError());
 
     ret = GetTempFileNameA(workdir, "fcn", 0, tempfile);
-    ok(ret, "GetTempFileNameA error: %d\n", GetLastError());
+    ok(ret, "GetTempFileNameA error: %ld\n", GetLastError());
     ret = DeleteFileA(tempfile);
-    ok(ret, "DeleteFileA error: %d\n", GetLastError());
+    ok(ret, "DeleteFileA error: %ld\n", GetLastError());
 
     lstrcpyA(parentdir, tempfile);
     ret = CreateDirectoryA(parentdir, NULL);
-    ok(ret, "CreateDirectoryA error: %d\n", GetLastError());
+    ok(ret, "CreateDirectoryA error: %ld\n", GetLastError());
 
     lstrcpyA(childdir, parentdir);
     lstrcatA(childdir, "\\c");
     ret = CreateDirectoryA(childdir, NULL);
-    ok(ret, "CreateDirectoryA error: %d\n", GetLastError());
+    ok(ret, "CreateDirectoryA error: %ld\n", GetLastError());
 
 
     /* When recursively watching overlapping directories, changes in child
@@ -1036,7 +1036,7 @@ static void test_ffcn_directory_overlap(void)
 
     /* Create a file in child */
     ret = GetTempFileNameA(childdir, "fcn", 0, tempfile);
-    ok(ret, "GetTempFileNameA error: %d\n", GetLastError());
+    ok(ret, "GetTempFileNameA error: %ld\n", GetLastError());
 
     /* Both watches should trigger */
     ret = FinishNotificationThread(parent_thread);
@@ -1045,7 +1045,7 @@ static void test_ffcn_directory_overlap(void)
     ok(ret, "Missed child notification\n");
 
     ret = DeleteFileA(tempfile);
-    ok(ret, "DeleteFileA error: %d\n", GetLastError());
+    ok(ret, "DeleteFileA error: %ld\n", GetLastError());
 
 
     /* Removing a recursive parent watch should not affect child watches. Doing
@@ -1053,22 +1053,22 @@ static void test_ffcn_directory_overlap(void)
     parent_watch = FindFirstChangeNotificationA(parentdir, TRUE,
                                                 FILE_NOTIFY_CHANGE_FILE_NAME);
     ok(parent_watch != INVALID_HANDLE_VALUE,
-       "FindFirstChangeNotification error: %d\n", GetLastError());
+       "FindFirstChangeNotification error: %ld\n", GetLastError());
     child_watch = FindFirstChangeNotificationA(childdir, TRUE,
                                                FILE_NOTIFY_CHANGE_FILE_NAME);
     ok(child_watch != INVALID_HANDLE_VALUE,
-       "FindFirstChangeNotification error: %d\n", GetLastError());
+       "FindFirstChangeNotification error: %ld\n", GetLastError());
 
     ret = FindCloseChangeNotification(parent_watch);
-    ok(ret, "FindCloseChangeNotification error: %d\n", GetLastError());
+    ok(ret, "FindCloseChangeNotification error: %ld\n", GetLastError());
 
     child_thread = CreateThread(NULL, 0, NotificationThread, child_watch, 0,
                                 &threadId);
-    ok(child_thread != NULL, "CreateThread error: %d\n", GetLastError());
+    ok(child_thread != NULL, "CreateThread error: %ld\n", GetLastError());
 
     /* Create a file in child */
     ret = GetTempFileNameA(childdir, "fcn", 0, tempfile);
-    ok(ret, "GetTempFileNameA error: %d\n", GetLastError());
+    ok(ret, "GetTempFileNameA error: %ld\n", GetLastError());
 
     /* Child watch should trigger */
     ret = FinishNotificationThread(child_thread);
@@ -1076,13 +1076,13 @@ static void test_ffcn_directory_overlap(void)
 
     /* clean up */
     ret = DeleteFileA(tempfile);
-    ok(ret, "DeleteFileA error: %d\n", GetLastError());
+    ok(ret, "DeleteFileA error: %ld\n", GetLastError());
 
     ret = RemoveDirectoryA(childdir);
-    ok(ret, "RemoveDirectoryA error: %d\n", GetLastError());
+    ok(ret, "RemoveDirectoryA error: %ld\n", GetLastError());
 
     ret = RemoveDirectoryA(parentdir);
-    ok(ret, "RemoveDirectoryA error: %d\n", GetLastError());
+    ok(ret, "RemoveDirectoryA error: %ld\n", GetLastError());
 }
 
 START_TEST(change)
diff --git a/dlls/kernel32/tests/codepage.c b/dlls/kernel32/tests/codepage.c
index 42e49888e05..33eeebcc617 100644
--- a/dlls/kernel32/tests/codepage.c
+++ b/dlls/kernel32/tests/codepage.c
@@ -40,7 +40,7 @@ static void test_destination_buffer(void)
 
     SetLastError(0xdeadbeef);
     needed = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, NULL, 0, NULL, NULL);
-    ok( (needed > 0), "returned %d with %u (expected '> 0')\n",
+    ok( (needed > 0), "returned %d with %lu (expected '> 0')\n",
         needed, GetLastError());
 
     maxsize = needed*2;
@@ -52,14 +52,14 @@ static void test_destination_buffer(void)
     buffer[maxsize] = '\0';
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, buffer, needed+1, NULL, NULL);
-    ok( (len > 0), "returned %d with %u and '%s' (expected '> 0')\n",
+    ok( (len > 0), "returned %d with %lu and '%s' (expected '> 0')\n",
         len, GetLastError(), buffer);
 
     memset(buffer, 'x', maxsize);
     buffer[maxsize] = '\0';
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, buffer, needed, NULL, NULL);
-    ok( (len > 0), "returned %d with %u and '%s' (expected '> 0')\n",
+    ok( (len > 0), "returned %d with %lu and '%s' (expected '> 0')\n",
         len, GetLastError(), buffer);
 
     memset(buffer, 'x', maxsize);
@@ -67,7 +67,7 @@ static void test_destination_buffer(void)
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, buffer, needed-1, NULL, NULL);
     ok( !len && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
-        "returned %d with %u and '%s' (expected '0' with "
+        "returned %d with %lu and '%s' (expected '0' with "
         "ERROR_INSUFFICIENT_BUFFER)\n", len, GetLastError(), buffer);
 
     memset(buffer, 'x', maxsize);
@@ -75,18 +75,18 @@ static void test_destination_buffer(void)
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, buffer, 1, NULL, NULL);
     ok( !len && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
-        "returned %d with %u and '%s' (expected '0' with "
+        "returned %d with %lu and '%s' (expected '0' with "
         "ERROR_INSUFFICIENT_BUFFER)\n", len, GetLastError(), buffer);
 
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, buffer, 0, NULL, NULL);
-    ok( (len > 0), "returned %d with %u (expected '> 0')\n",
+    ok( (len > 0), "returned %d with %lu (expected '> 0')\n",
         len, GetLastError());
 
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, NULL, needed, NULL, NULL);
     ok( !len && (GetLastError() == ERROR_INVALID_PARAMETER),
-        "returned %d with %u (expected '0' with "
+        "returned %d with %lu (expected '0' with "
         "ERROR_INVALID_PARAMETER)\n", len, GetLastError());
 
     HeapFree(GetProcessHeap(), 0, buffer);
@@ -102,14 +102,14 @@ static void test_null_source(void)
     len = WideCharToMultiByte(CP_ACP, 0, NULL, 0, NULL, 0, NULL, NULL);
     GLE = GetLastError();
     ok(!len && GLE == ERROR_INVALID_PARAMETER,
-        "WideCharToMultiByte returned %d with GLE=%u (expected 0 with ERROR_INVALID_PARAMETER)\n",
+        "WideCharToMultiByte returned %d with GLE=%lu (expected 0 with ERROR_INVALID_PARAMETER)\n",
         len, GLE);
 
     SetLastError(0);
     len = WideCharToMultiByte(CP_ACP, 0, NULL, -1, NULL, 0, NULL, NULL);
     GLE = GetLastError();
     ok(!len && GLE == ERROR_INVALID_PARAMETER,
-        "WideCharToMultiByte returned %d with GLE=%u (expected 0 with ERROR_INVALID_PARAMETER)\n",
+        "WideCharToMultiByte returned %d with GLE=%lu (expected 0 with ERROR_INVALID_PARAMETER)\n",
         len, GLE);
 }
 
@@ -124,7 +124,7 @@ static void test_negative_source_length(void)
     memset(buf,'x',sizeof(buf));
     len = WideCharToMultiByte(CP_ACP, 0, foobarW, -2002, buf, 10, NULL, NULL);
     ok(len == 7 && GetLastError() == 0xdeadbeef,
-       "WideCharToMultiByte(-2002): len=%d error=%u\n", len, GetLastError());
+       "WideCharToMultiByte(-2002): len=%d error=%lu\n", len, GetLastError());
     ok(!lstrcmpA(buf, "foobar"),
        "WideCharToMultiByte(-2002): expected \"foobar\" got \"%s\"\n", buf);
 
@@ -132,13 +132,13 @@ static void test_negative_source_length(void)
     memset(bufW,'x',sizeof(bufW));
     len = MultiByteToWideChar(CP_ACP, 0, "foobar", -2002, bufW, 10);
     ok(len == 7 && !lstrcmpW(bufW, foobarW) && GetLastError() == 0xdeadbeef,
-       "MultiByteToWideChar(-2002): len=%d error=%u\n", len, GetLastError());
+       "MultiByteToWideChar(-2002): len=%d error=%lu\n", len, GetLastError());
 
     SetLastError(0xdeadbeef);
     memset(bufW, 'x', sizeof(bufW));
     len = MultiByteToWideChar(CP_ACP, 0, "foobar", -1, bufW, 6);
     ok(len == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-       "MultiByteToWideChar(-1): len=%d error=%u\n", len, GetLastError());
+       "MultiByteToWideChar(-1): len=%d error=%lu\n", len, GetLastError());
 }
 
 #define LONGBUFLEN 100000
@@ -156,33 +156,33 @@ static void test_negative_dest_length(void)
     memset(bufA,'x',sizeof(bufA));
     len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, bufA, -1, NULL, NULL);
     ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER,
-       "WideCharToMultiByte(destlen -1): len=%d error=%x\n", len, GetLastError());
+       "WideCharToMultiByte(destlen -1): len=%d error=%lx\n", len, GetLastError());
 
     SetLastError( 0xdeadbeef );
     memset(bufW,'x',sizeof(bufW));
     len = MultiByteToWideChar(CP_ACP, 0, foobarA, -1, bufW, -1);
     ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER,
-       "MultiByteToWideChar(destlen -1): len=%d error=%x\n", len, GetLastError());
+       "MultiByteToWideChar(destlen -1): len=%d error=%lx\n", len, GetLastError());
 
     /* Test return on -1000 dest length */
     SetLastError( 0xdeadbeef );
     memset(bufA,'x',sizeof(bufA));
     len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, bufA, -1000, NULL, NULL);
     ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER,
-       "WideCharToMultiByte(destlen -1000): len=%d error=%x\n", len, GetLastError());
+       "WideCharToMultiByte(destlen -1000): len=%d error=%lx\n", len, GetLastError());
 
     SetLastError( 0xdeadbeef );
     memset(bufW,'x',sizeof(bufW));
     len = MultiByteToWideChar(CP_ACP, 0, foobarA, -1000, bufW, -1);
     ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER,
-       "MultiByteToWideChar(destlen -1000): len=%d error=%x\n", len, GetLastError());
+       "MultiByteToWideChar(destlen -1000): len=%d error=%lx\n", len, GetLastError());
 
     /* Test return on INT_MAX dest length */
     SetLastError( 0xdeadbeef );
     memset(bufA,'x',sizeof(bufA));
     len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, bufA, INT_MAX, NULL, NULL);
     ok(len == 7 && !lstrcmpA(bufA, "foobar") && GetLastError() == 0xdeadbeef,
-       "WideCharToMultiByte(destlen INT_MAX): len=%d error=%x\n", len, GetLastError());
+       "WideCharToMultiByte(destlen INT_MAX): len=%d error=%lx\n", len, GetLastError());
 
     /* Test return on INT_MAX dest length and very long input */
     SetLastError( 0xdeadbeef );
@@ -196,7 +196,7 @@ static void test_negative_dest_length(void)
     len = WideCharToMultiByte(CP_ACP, 0, originalW, -1, bufA, INT_MAX, NULL, NULL);
     theError = GetLastError();
     ok(len == LONGBUFLEN && !lstrcmpA(bufA, originalA) && theError == 0xdeadbeef,
-       "WideCharToMultiByte(srclen %d, destlen INT_MAX): len %d error=%x\n", LONGBUFLEN, len, theError);
+       "WideCharToMultiByte(srclen %d, destlen INT_MAX): len %d error=%lx\n", LONGBUFLEN, len, theError);
 
 }
 
@@ -212,87 +212,87 @@ static void test_other_invalid_parameters(void)
     /* Unrecognized flag => ERROR_INVALID_FLAGS */
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_ACP, 0x100, w_string, -1, c_string, c_string_len, NULL, NULL);
-    ok(len == 0 && GetLastError() == ERROR_INVALID_FLAGS, "len=%d error=%x\n", len, GetLastError());
+    ok(len == 0 && GetLastError() == ERROR_INVALID_FLAGS, "len=%d error=%lx\n", len, GetLastError());
 
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_ACP, 0x800, w_string, -1, c_string, c_string_len, NULL, NULL);
-    ok(len == 0 && GetLastError() == ERROR_INVALID_FLAGS, "len=%d error=%x\n", len, GetLastError());
+    ok(len == 0 && GetLastError() == ERROR_INVALID_FLAGS, "len=%d error=%lx\n", len, GetLastError());
 
     SetLastError(0xdeadbeef);
     len = MultiByteToWideChar(CP_ACP, 0x10, c_string, -1, w_string, w_string_len);
-    ok(len == 0 && GetLastError() == ERROR_INVALID_FLAGS, "len=%d error=%x\n", len, GetLastError());
+    ok(len == 0 && GetLastError() == ERROR_INVALID_FLAGS, "len=%d error=%lx\n", len, GetLastError());
 
 
     /* Unrecognized flag and invalid codepage => ERROR_INVALID_PARAMETER */
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(0xdeadbeef, 0x100, w_string, w_string_len, c_string, c_string_len, NULL, NULL);
-    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%x\n", len, GetLastError());
+    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%lx\n", len, GetLastError());
 
     SetLastError(0xdeadbeef);
     len = MultiByteToWideChar(0xdeadbeef, 0x10, c_string, c_string_len, w_string, w_string_len);
-    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%x\n", len, GetLastError());
+    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%lx\n", len, GetLastError());
 
 
     /* Unrecognized flag and src is NULL => ERROR_INVALID_PARAMETER */
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_ACP, 0x100, NULL, -1, c_string, c_string_len, NULL, NULL);
-    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%x\n", len, GetLastError());
+    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%lx\n", len, GetLastError());
 
     SetLastError(0xdeadbeef);
     len = MultiByteToWideChar(CP_ACP, 0x10, NULL, -1, w_string, w_string_len);
-    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%x\n", len, GetLastError());
+    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%lx\n", len, GetLastError());
 
 
     /* srclen=0 => ERROR_INVALID_PARAMETER */
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_ACP, 0, w_string, 0, c_string, c_string_len, NULL, NULL);
-    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%x\n", len, GetLastError());
+    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%lx\n", len, GetLastError());
 
     SetLastError(0xdeadbeef);
     len = MultiByteToWideChar(CP_ACP, 0, c_string, 0, w_string, w_string_len);
-    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%x\n", len, GetLastError());
+    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%lx\n", len, GetLastError());
 
 
     /* dst=NULL but dstlen not 0 => ERROR_INVALID_PARAMETER */
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_ACP, 0, w_string, w_string_len, NULL, c_string_len, NULL, NULL);
-    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%x\n", len, GetLastError());
+    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%lx\n", len, GetLastError());
 
     SetLastError(0xdeadbeef);
     len = MultiByteToWideChar(CP_ACP, 0, c_string, c_string_len, NULL, w_string_len);
-    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%x\n", len, GetLastError());
+    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%lx\n", len, GetLastError());
 
 
     /* CP_UTF7, CP_UTF8, or CP_SYMBOL and defchar not NULL => ERROR_INVALID_PARAMETER */
     /* CP_SYMBOL's behavior here is undocumented */
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_UTF7, 0, w_string, w_string_len, c_string, c_string_len, c_string, NULL);
-    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%x\n", len, GetLastError());
+    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%lx\n", len, GetLastError());
 
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_UTF8, 0, w_string, w_string_len, c_string, c_string_len, c_string, NULL);
     ok((len == 0 && GetLastError() == ERROR_INVALID_PARAMETER)
-            || broken(len == 12) /* Win10 1709+ */, "len=%d error=%x\n", len, GetLastError());
+            || broken(len == 12) /* Win10 1709+ */, "len=%d error=%lx\n", len, GetLastError());
 
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_SYMBOL, 0, w_string, w_string_len, c_string, c_string_len, c_string, NULL);
-    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%x\n", len, GetLastError());
+    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%lx\n", len, GetLastError());
 
 
     /* CP_UTF7, CP_UTF8, or CP_SYMBOL and used not NULL => ERROR_INVALID_PARAMETER */
     /* CP_SYMBOL's behavior here is undocumented */
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_UTF7, 0, w_string, w_string_len, c_string, c_string_len, NULL, &used);
-    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%x\n", len, GetLastError());
+    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%lx\n", len, GetLastError());
 
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_UTF8, 0, w_string, w_string_len, c_string, c_string_len, NULL, &used);
     ok((len == 0 && GetLastError() == ERROR_INVALID_PARAMETER)
-            || broken(len == 12) /* Win10 1709+ */, "len=%d error=%x\n", len, GetLastError());
+            || broken(len == 12) /* Win10 1709+ */, "len=%d error=%lx\n", len, GetLastError());
 
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_SYMBOL, 0, w_string, w_string_len, c_string, c_string_len, NULL, &used);
-    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%x\n", len, GetLastError());
+    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%lx\n", len, GetLastError());
 
 
     /* CP_UTF7, flags not 0 and used not NULL => ERROR_INVALID_PARAMETER */
@@ -301,14 +301,14 @@ static void test_other_invalid_parameters(void)
        instead except on Windows NT4 */
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_UTF7, 1, w_string, w_string_len, c_string, c_string_len, NULL, &used);
-    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%x\n", len, GetLastError());
+    ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "len=%d error=%lx\n", len, GetLastError());
 
     /* CP_UTF8, unrecognized flag and used not NULL => ERROR_INVALID_PARAMETER */
     SetLastError(0xdeadbeef);
     len = WideCharToMultiByte(CP_UTF8, 0x100, w_string, w_string_len, c_string, c_string_len, NULL, &used);
     ok(len == 0, "wrong ret %d\n", len);
     ok(GetLastError() == ERROR_INVALID_PARAMETER
-            || GetLastError() == ERROR_INVALID_FLAGS /* Win10 1709+ */, "wrong error %u\n", GetLastError());
+            || GetLastError() == ERROR_INVALID_FLAGS /* Win10 1709+ */, "wrong error %lu\n", GetLastError());
 }
 
 static void test_overlapped_buffers(void)
@@ -326,14 +326,14 @@ static void test_overlapped_buffers(void)
     ret = WideCharToMultiByte(CP_ACP, 0, (WCHAR *)(buf + 1), -1, buf, sizeof(buf), NULL, NULL);
     ok(ret == sizeof(strA), "unexpected ret %d\n", ret);
     ok(!memcmp(buf, strA, sizeof(strA)), "conversion failed: %s\n", buf);
-    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     memcpy(buf + overlap_limit, strA, sizeof(strA));
     ret = MultiByteToWideChar(CP_ACP, 0, buf + overlap_limit, -1, (WCHAR *)buf, sizeof(buf) / sizeof(WCHAR));
     ok(ret == ARRAY_SIZE(strW), "unexpected ret %d\n", ret);
     ok(!memcmp(buf, strW, sizeof(strW)), "conversion failed: %s\n", wine_dbgstr_wn((WCHAR *)buf, ARRAY_SIZE(strW)));
-    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %lu\n", GetLastError());
 }
 
 static void test_string_conversion(LPBOOL bUsedDefaultChar)
@@ -353,14 +353,14 @@ static void test_string_conversion(LPBOOL bUsedDefaultChar)
     ok(ret == 1, "ret is %d\n", ret);
     ok(mbc == '\xe4', "mbc is %d\n", mbc);
     if(bUsedDefaultChar) ok(*bUsedDefaultChar == FALSE, "bUsedDefaultChar is %d\n", *bUsedDefaultChar);
-    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WideCharToMultiByte(1252, 0, &wc2, 1, &mbc, 1, NULL, bUsedDefaultChar);
     ok(ret == 1, "ret is %d\n", ret);
     ok(mbc == 63, "mbc is %d\n", mbc);
     if(bUsedDefaultChar) ok(*bUsedDefaultChar == TRUE, "bUsedDefaultChar is %d\n", *bUsedDefaultChar);
-    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %lu\n", GetLastError());
 
     if (IsValidCodePage(1251))
     {
@@ -371,14 +371,14 @@ static void test_string_conversion(LPBOOL bUsedDefaultChar)
         if(bUsedDefaultChar) ok(*bUsedDefaultChar == FALSE, "bUsedDefaultChar is %d\n", *bUsedDefaultChar);
         ok(GetLastError() == 0xdeadbeef ||
            broken(GetLastError() == 0), /* win95 */
-           "GetLastError() is %u\n", GetLastError());
+           "GetLastError() is %lu\n", GetLastError());
 
         SetLastError(0xdeadbeef);
         ret = WideCharToMultiByte(1251, 0, &wc1, 1, &mbc, 1, NULL, bUsedDefaultChar);
         ok(ret == 1, "ret is %d\n", ret);
         ok(mbc == 97, "mbc is %d\n", mbc);
         if(bUsedDefaultChar) ok(*bUsedDefaultChar == FALSE, "bUsedDefaultChar is %d\n", *bUsedDefaultChar);
-        ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u\n", GetLastError());
+        ok(GetLastError() == 0xdeadbeef, "GetLastError() is %lu\n", GetLastError());
     }
     else
         skip("Codepage 1251 not available\n");
@@ -389,14 +389,14 @@ static void test_string_conversion(LPBOOL bUsedDefaultChar)
     ok(ret == 0, "ret is %d\n", ret);
     ok(mbc == 84, "mbc is %d\n", mbc);
     if(bUsedDefaultChar) ok(*bUsedDefaultChar == FALSE, "bUsedDefaultChar is %d\n", *bUsedDefaultChar);
-    ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() is %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() is %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WideCharToMultiByte(1252, 0, wcs, -1, mbs, sizeof(mbs), NULL, bUsedDefaultChar);
     ok(ret == 5, "ret is %d\n", ret);
     ok(!strcmp(mbs, "Th?i"), "mbs is %s\n", mbs);
     if(bUsedDefaultChar) ok(*bUsedDefaultChar == TRUE, "bUsedDefaultChar is %d\n", *bUsedDefaultChar);
-    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %lu\n", GetLastError());
     mbs[0] = 0;
 
     /* WideCharToMultiByte mustn't add any null character automatically.
@@ -406,7 +406,7 @@ static void test_string_conversion(LPBOOL bUsedDefaultChar)
     ok(ret == 3, "ret is %d\n", ret);
     ok(!strcmp(mbs, "Th?i"), "mbs is %s\n", mbs);
     if(bUsedDefaultChar) ok(*bUsedDefaultChar == TRUE, "bUsedDefaultChar is %d\n", *bUsedDefaultChar);
-    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %lu\n", GetLastError());
     ZeroMemory(mbs, 5);
 
     /* Now this shouldn't be the case like above as we zeroed the complete string buffer. */
@@ -415,7 +415,7 @@ static void test_string_conversion(LPBOOL bUsedDefaultChar)
     ok(ret == 3, "ret is %d\n", ret);
     ok(!strcmp(mbs, "Th?"), "mbs is %s\n", mbs);
     if(bUsedDefaultChar) ok(*bUsedDefaultChar == TRUE, "bUsedDefaultChar is %d\n", *bUsedDefaultChar);
-    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %lu\n", GetLastError());
 
     /* Double-byte tests */
     ret = WideCharToMultiByte(1252, 0, dbwcs, 3, mbs, sizeof(mbs), NULL, bUsedDefaultChar);
@@ -433,13 +433,13 @@ static void test_string_conversion(LPBOOL bUsedDefaultChar)
     ret = WideCharToMultiByte(1252, 0, &wc2, 1, NULL, 0, NULL, bUsedDefaultChar);
     ok(ret == 1, "ret is %d\n", ret);
     if(bUsedDefaultChar) ok(*bUsedDefaultChar == TRUE, "bUsedDefaultChar is %d\n", *bUsedDefaultChar);
-    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WideCharToMultiByte(1252, 0, wcs, -1, NULL, 0, NULL, bUsedDefaultChar);
     ok(ret == 5, "ret is %d\n", ret);
     if(bUsedDefaultChar) ok(*bUsedDefaultChar == TRUE, "bUsedDefaultChar is %d\n", *bUsedDefaultChar);
-    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %lu\n", GetLastError());
 
     if (!IsValidCodePage(950))
     {
@@ -453,13 +453,13 @@ static void test_string_conversion(LPBOOL bUsedDefaultChar)
     ok(ret == 5, "ret is %d\n", ret);
     ok(!strcmp(mbs, "\xb5H\xa9\xd2"), "mbs is %s\n", mbs);
     if(bUsedDefaultChar) ok(*bUsedDefaultChar == FALSE, "bUsedDefaultChar is %d\n", *bUsedDefaultChar);
-    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WideCharToMultiByte(950, 0, dbwcs, 1, &mbc, 1, NULL, bUsedDefaultChar);
     ok(ret == 0, "ret is %d\n", ret);
     if(bUsedDefaultChar) ok(*bUsedDefaultChar == FALSE, "bUsedDefaultChar is %d\n", *bUsedDefaultChar);
-    ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() is %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() is %lu\n", GetLastError());
     ZeroMemory(mbs, 5);
 
     SetLastError(0xdeadbeef);
@@ -467,20 +467,20 @@ static void test_string_conversion(LPBOOL bUsedDefaultChar)
     ok(ret == 2, "ret is %d\n", ret);
     ok(!strcmp(mbs, "\xb5H"), "mbs is %s\n", mbs);
     if(bUsedDefaultChar) ok(*bUsedDefaultChar == FALSE, "bUsedDefaultChar is %d\n", *bUsedDefaultChar);
-    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %lu\n", GetLastError());
 
     /* Length-only tests */
     SetLastError(0xdeadbeef);
     ret = WideCharToMultiByte(950, 0, dbwcs, 1, NULL, 0, NULL, bUsedDefaultChar);
     ok(ret == 2, "ret is %d\n", ret);
     if(bUsedDefaultChar) ok(*bUsedDefaultChar == FALSE, "bUsedDefaultChar is %d\n", *bUsedDefaultChar);
-    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WideCharToMultiByte(950, 0, dbwcs, -1, NULL, 0, NULL, bUsedDefaultChar);
     ok(ret == 5, "ret is %d\n", ret);
     if(bUsedDefaultChar) ok(*bUsedDefaultChar == FALSE, "bUsedDefaultChar is %d\n", *bUsedDefaultChar);
-    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %u\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "GetLastError() is %lu\n", GetLastError());
 }
 
 static void test_utf7_encoding(void)
@@ -709,7 +709,7 @@ static void test_utf7_encoding(void)
         if (!tests[i].len)
         {
             ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-               "tests[%i]: expected error=0x%x, got error=0x%x\n",
+               "tests[%i]: expected error=0x%x, got error=0x%lx\n",
                i, ERROR_INSUFFICIENT_BUFFER, GetLastError());
         }
         ok(len == tests[i].len, "tests[%i]: expected len=%i, got len=%i\n", i, tests[i].len, len);
@@ -983,7 +983,7 @@ static void test_utf7_decoding(void)
         if (!tests[i].len && tests[i].chars_written)
         {
             ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-               "tests[%i]: expected error=0x%x, got error=0x%x\n",
+               "tests[%i]: expected error=0x%x, got error=0x%lx\n",
                i, ERROR_INSUFFICIENT_BUFFER, GetLastError());
         }
         ok(len == tests[i].len, "tests[%i]: expected len=%i, got len=%i\n", i, tests[i].len, len);
@@ -1034,11 +1034,11 @@ static void test_undefined_byte_char(void)
                                   testset[i].str, -1, NULL, 0);
         err = GetLastError();
         if (testset[i].is_error) {
-            ok(err == ERROR_NO_UNICODE_TRANSLATION, "Test %u: err is %u\n", i, err);
+            ok(err == ERROR_NO_UNICODE_TRANSLATION, "Test %u: err is %lu\n", i, err);
             ok(ret == 0, "Test %u: ret is %d\n", i, ret);
         }
         else {
-            ok(err == 0xdeadbeef, "Test %u: err is %u\n", i, err);
+            ok(err == 0xdeadbeef, "Test %u: err is %lu\n", i, err);
             ok(ret == 2, "Test %u: ret is %d\n", i, ret);
         }
 
@@ -1046,7 +1046,7 @@ static void test_undefined_byte_char(void)
         ret = MultiByteToWideChar(testset[i].codepage, 0,
                                   testset[i].str, -1, NULL, 0);
         err = GetLastError();
-        ok(err == 0xdeadbeef, "Test %u: err is %u\n", i, err);
+        ok(err == 0xdeadbeef, "Test %u: err is %lu\n", i, err);
         ok(ret == 2, "Test %u: ret is %d\n", i, ret);
     }
 }
@@ -1129,42 +1129,42 @@ static void test_threadcp(void)
 
         cp = 0xdeadbeef;
         GetLocaleInfoA(lcids[i].lcid, LOCALE_IDEFAULTANSICODEPAGE|LOCALE_RETURN_NUMBER, (LPSTR)&cp, sizeof(cp));
-        ok(cp == lcids[i].threadcp, "wrong codepage %u for lcid %04x, should be %u\n", cp, lcids[i].lcid, lcids[i].threadcp);
+        ok(cp == lcids[i].threadcp, "wrong codepage %u for lcid %04lx, should be %u\n", cp, lcids[i].lcid, lcids[i].threadcp);
 
         /* GetCPInfoEx/GetCPInfo - CP_ACP */
         SetLastError(0xdeadbeef);
         memset(&cpi, 0, sizeof(cpi));
         ret = GetCPInfoExA(CP_ACP, 0, &cpi);
-        ok(ret, "GetCPInfoExA failed for lcid %04x, error %d\n", lcids[i].lcid, GetLastError());
-        ok(cpi.CodePage == acp, "wrong codepage %u for lcid %04x, should be %u\n", cpi.CodePage, lcids[i].lcid, acp);
+        ok(ret, "GetCPInfoExA failed for lcid %04lx, error %ld\n", lcids[i].lcid, GetLastError());
+        ok(cpi.CodePage == acp, "wrong codepage %u for lcid %04lx, should be %u\n", cpi.CodePage, lcids[i].lcid, acp);
 
         /* WideCharToMultiByte - CP_ACP */
         num = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, NULL, 0, NULL, NULL);
-        ok(num == 7, "ret is %d (%04x)\n", num, lcids[i].lcid);
+        ok(num == 7, "ret is %d (%04lx)\n", num, lcids[i].lcid);
 
         /* MultiByteToWideChar - CP_ACP */
         num = MultiByteToWideChar(CP_ACP, 0, "foobar", -1, NULL, 0);
-        ok(num == 7, "ret is %d (%04x)\n", num, lcids[i].lcid);
+        ok(num == 7, "ret is %d (%04lx)\n", num, lcids[i].lcid);
 
         /* GetCPInfoEx/GetCPInfo - CP_THREAD_ACP */
         SetLastError(0xdeadbeef);
         memset(&cpi, 0, sizeof(cpi));
         ret = GetCPInfoExA(CP_THREAD_ACP, 0, &cpi);
-        ok(ret, "GetCPInfoExA failed for lcid %04x, error %d\n", lcids[i].lcid, GetLastError());
+        ok(ret, "GetCPInfoExA failed for lcid %04lx, error %ld\n", lcids[i].lcid, GetLastError());
         if (lcids[i].threadcp)
-            ok(cpi.CodePage == lcids[i].threadcp, "wrong codepage %u for lcid %04x, should be %u\n",
+            ok(cpi.CodePage == lcids[i].threadcp, "wrong codepage %u for lcid %04lx, should be %u\n",
                cpi.CodePage, lcids[i].lcid, lcids[i].threadcp);
         else
             ok(cpi.CodePage == acp || cpi.CodePage == CP_UTF8 /* Win10 1809+ */,
-                "wrong codepage %u for lcid %04x, should be %u\n", cpi.CodePage, lcids[i].lcid, acp);
+                "wrong codepage %u for lcid %04lx, should be %u\n", cpi.CodePage, lcids[i].lcid, acp);
 
         /* WideCharToMultiByte - CP_THREAD_ACP */
         num = WideCharToMultiByte(CP_THREAD_ACP, 0, foobarW, -1, NULL, 0, NULL, NULL);
-        ok(num == 7, "ret is %d (%04x)\n", num, lcids[i].lcid);
+        ok(num == 7, "ret is %d (%04lx)\n", num, lcids[i].lcid);
 
         /* MultiByteToWideChar - CP_THREAD_ACP */
         num = MultiByteToWideChar(CP_THREAD_ACP, 0, "foobar", -1, NULL, 0);
-        ok(num == 7, "ret is %d (%04x)\n", num, lcids[i].lcid);
+        ok(num == 7, "ret is %d (%04lx)\n", num, lcids[i].lcid);
     }
 
     /* IsDBCSLeadByteEx - locales without codepage */
@@ -1176,7 +1176,7 @@ static void test_threadcp(void)
         islead_default = IsDBCSLeadByteEx(cpi.CodePage, isleads_nocp[i].testchar);
         islead = IsDBCSLeadByteEx(CP_THREAD_ACP, isleads_nocp[i].testchar);
 
-        ok(islead == islead_default, "wrong islead %i for test char %x in lcid %04x.  should be %i\n",
+        ok(islead == islead_default, "wrong islead %i for test char %x in lcid %04lx.  should be %i\n",
             islead, isleads_nocp[i].testchar, isleads_nocp[i].lcid, islead_default);
     }
 
@@ -1186,7 +1186,7 @@ static void test_threadcp(void)
         SetThreadLocale(isleads[i].lcid);
 
         islead = IsDBCSLeadByteEx(CP_THREAD_ACP, isleads[i].testchar);
-        ok(islead == isleads[i].islead, "wrong islead %i for test char %x in lcid %04x.  should be %i\n",
+        ok(islead == isleads[i].islead, "wrong islead %i for test char %x in lcid %04lx.  should be %i\n",
             islead, isleads[i].testchar, isleads[i].lcid, isleads[i].islead);
     }
 
@@ -1218,10 +1218,10 @@ static void test_dbcs_to_widechar(void)
         count = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 2, NULL, 0);
         count2 = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 2, wbuf, count);
 
-        ok(count == 1, "%04x: returned %d (expected 1)\n", flags[i], count);
-        ok(count2 == 1, "%04x: returned %d (expected 1)\n", flags[i], count2);
-        ok(wbuf[0] == 0x770b, "%04x: returned %04x (expected 770b)\n", flags[i], wbuf[0]);
-        ok(wbuf[1] == 0xffff, "%04x: returned %04x (expected ffff)\n", flags[i], wbuf[1]);
+        ok(count == 1, "%04lx: returned %d (expected 1)\n", flags[i], count);
+        ok(count2 == 1, "%04lx: returned %d (expected 1)\n", flags[i], count2);
+        ok(wbuf[0] == 0x770b, "%04lx: returned %04x (expected 770b)\n", flags[i], wbuf[0]);
+        ok(wbuf[1] == 0xffff, "%04lx: returned %04x (expected ffff)\n", flags[i], wbuf[1]);
     }
 
     for (i = 0; i < ARRAY_SIZE(flags); ++i)
@@ -1233,19 +1233,19 @@ static void test_dbcs_to_widechar(void)
 
         if (flags[i] & MB_ERR_INVALID_CHARS)
         {
-            ok(count == 0, "%04x: returned %d (expected 0)\n", flags[i], count);
-            ok(count2 == 0, "%04x: returned %d (expected 0)\n", flags[i], count2);
-            ok(GetLastError() == ERROR_NO_UNICODE_TRANSLATION, "%04x: returned %d (expected %d)\n",
+            ok(count == 0, "%04lx: returned %d (expected 0)\n", flags[i], count);
+            ok(count2 == 0, "%04lx: returned %d (expected 0)\n", flags[i], count2);
+            ok(GetLastError() == ERROR_NO_UNICODE_TRANSLATION, "%04lx: returned %ld (expected %d)\n",
                flags[i], GetLastError(), ERROR_NO_UNICODE_TRANSLATION);
         }
         else
         {
-            ok(count == 2, "%04x: returned %d (expected 2)\n", flags[i], count);
-            ok(count2 == 2, "%04x: returned %d (expected 2)\n", flags[i], count2);
-            ok(wbuf[0] == 0x770b, "%04x: returned %04x (expected 770b)\n", flags[i], wbuf[0]);
+            ok(count == 2, "%04lx: returned %d (expected 2)\n", flags[i], count);
+            ok(count2 == 2, "%04lx: returned %d (expected 2)\n", flags[i], count2);
+            ok(wbuf[0] == 0x770b, "%04lx: returned %04x (expected 770b)\n", flags[i], wbuf[0]);
             ok(wbuf[1] == 0x003f || broken(wbuf[1] == 0), /*windows xp*/
-               "%04x: wrong wide char: %04x\n", flags[i], wbuf[1]);
-            ok(wbuf[2] == 0xffff, "%04x: returned %04x (expected ffff)\n", flags[i], wbuf[2]);
+               "%04lx: wrong wide char: %04x\n", flags[i], wbuf[1]);
+            ok(wbuf[2] == 0xffff, "%04lx: returned %04x (expected ffff)\n", flags[i], wbuf[2]);
         }
     }
 
@@ -1256,12 +1256,12 @@ static void test_dbcs_to_widechar(void)
         count = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 4, NULL, 0);
         SetLastError( 0xdeadbeef );
         count2 = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 4, wbuf, count);
-        ok(count == count2, "%04x: returned %d (expected %d)\n", flags[i], count2, count);
+        ok(count == count2, "%04lx: returned %d (expected %d)\n", flags[i], count2, count);
 
         if (flags[i] & MB_ERR_INVALID_CHARS)
         {
-            ok(count == 0, "%04x: returned %d (expected 0)\n", flags[i], count);
-            ok(GetLastError() == ERROR_NO_UNICODE_TRANSLATION, "%04x: returned %d (expected %d)\n",
+            ok(count == 0, "%04lx: returned %d (expected 0)\n", flags[i], count);
+            ok(GetLastError() == ERROR_NO_UNICODE_TRANSLATION, "%04lx: returned %ld (expected %d)\n",
                flags[i], GetLastError(), ERROR_NO_UNICODE_TRANSLATION);
         }
         else
@@ -1269,10 +1269,10 @@ static void test_dbcs_to_widechar(void)
             WCHAR wbuf_ok[]     = { 0x770b, 0x003f, '\0', 0xffff };
             WCHAR wbuf_broken[] = { 0x770b, '\0', 0xffff, 0xffff };
             ok(count == 3 || broken(count == 2 /*windows xp*/),
-               "%04x: returned %d (expected 3)\n", flags[i], count);
+               "%04lx: returned %d (expected 3)\n", flags[i], count);
             ok(!memcmp(wbuf, wbuf_ok, sizeof(wbuf_ok))
                || broken(!memcmp(wbuf, wbuf_broken, sizeof(wbuf_broken))),
-               "%04x: returned %04x %04x %04x %04x (expected %04x %04x %04x %04x)\n",
+               "%04lx: returned %04x %04x %04x %04x (expected %04x %04x %04x %04x)\n",
                flags[i], wbuf[0], wbuf[1], wbuf[2], wbuf[3],
                wbuf_ok[0], wbuf_ok[1], wbuf_ok[2], wbuf_ok[3]);
         }
@@ -1285,12 +1285,12 @@ static void test_dbcs_to_widechar(void)
         count = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 5, NULL, 0);
         SetLastError( 0xdeadbeef );
         count2 = MultiByteToWideChar(936, flags[i], (char*)&buf[0], 5, wbuf, count);
-        ok(count == count2, "%04x: returned %d (expected %d)\n", flags[i], count2, count);
+        ok(count == count2, "%04lx: returned %d (expected %d)\n", flags[i], count2, count);
 
         if (flags[i] & MB_ERR_INVALID_CHARS)
         {
-            ok(count == 0, "%04x: returned %d (expected 0)\n", flags[i], count);
-            ok(GetLastError() == ERROR_NO_UNICODE_TRANSLATION, "%04x: returned %d (expected %d)\n",
+            ok(count == 0, "%04lx: returned %d (expected 0)\n", flags[i], count);
+            ok(GetLastError() == ERROR_NO_UNICODE_TRANSLATION, "%04lx: returned %ld (expected %d)\n",
                flags[i], GetLastError(), ERROR_NO_UNICODE_TRANSLATION);
         }
         else
@@ -1298,10 +1298,10 @@ static void test_dbcs_to_widechar(void)
             WCHAR wbuf_ok[]     = { 0x770b, 0x003f, '\0', 'x', 0xffff };
             WCHAR wbuf_broken[] = { 0x770b, '\0', 'x', 0xffff, 0xffff };
             ok(count == 4 || broken(count == 3),
-               "%04x: returned %d (expected 4)\n", flags[i], count);
+               "%04lx: returned %d (expected 4)\n", flags[i], count);
             ok(!memcmp(wbuf, wbuf_ok, sizeof(wbuf_ok))
                || broken(!memcmp(wbuf, wbuf_broken, sizeof(wbuf_broken))),
-               "%04x: returned %04x %04x %04x %04x %04x (expected %04x %04x %04x %04x %04x)\n",
+               "%04lx: returned %04x %04x %04x %04x %04x (expected %04x %04x %04x %04x %04x)\n",
                flags[i], wbuf[0], wbuf[1], wbuf[2], wbuf[3], wbuf[4],
                wbuf_ok[0], wbuf_ok[1], wbuf_ok[2], wbuf_ok[3], wbuf_ok[4]);
         }
diff --git a/dlls/kernel32/tests/comm.c b/dlls/kernel32/tests/comm.c
index f82e5e60677..a559a31a205 100644
--- a/dlls/kernel32/tests/comm.c
+++ b/dlls/kernel32/tests/comm.c
@@ -450,7 +450,7 @@ static void check_result(const char *function, const TEST *ptest, int initial_va
 	DWORD LastError = GetLastError();
 	DWORD CorrectError = (ptest->result ? 0xdeadbeef : ERROR_INVALID_PARAMETER);
 
-	ok(LastError == CorrectError, "%s(\"%s\"), 0x%02x: GetLastError() returned %d, should be %d\n", function, ptest->string, initial_value, LastError, CorrectError);
+	ok(LastError == CorrectError, "%s(\"%s\"), 0x%02x: GetLastError() returned %ld, should be %ld\n", function, ptest->string, initial_value, LastError, CorrectError);
 	ok(result == ptest->result, "%s(\"%s\"), 0x%02x: return value should be %s\n", function, ptest->string, initial_value, ptest->result ? "TRUE" : "FALSE");
 }
 
@@ -461,7 +461,7 @@ static void check_dcb(const char *function, const TEST *ptest, int initial_value
 {
 	/* DCBlength is a special case since Win 9x sets it but NT does not.
 	   We will accept either as correct. */
-	check_dcb_member2(DCBlength, (DWORD)sizeof(DCB), "%u");
+    check_dcb_member2(DCBlength, (DWORD)sizeof(DCB), "%lu");
 
 	/* For old style control strings Win 9x does not set the next five members, NT does. */
 	if(ptest->old_style && ptest->result)
@@ -505,7 +505,7 @@ static void check_dcb(const char *function, const TEST *ptest, int initial_value
 	}
 
 	/* Check the result of the DCB members. */
-	check_dcb_member(BaudRate, "%u");
+	check_dcb_member(BaudRate, "%lu");
 	check_dcb_member(fBinary, "%u");
 	check_dcb_member(fParity, "%u");
 	check_dcb_member(fTXContinueOnXoff, "%u");
@@ -527,7 +527,7 @@ static void check_dcb(const char *function, const TEST *ptest, int initial_value
 	check_dcb_member(wReserved1, "%u");
 }
 
-#define check_timeouts_member(a) ok(ptimeouts1->a == ptimeouts2->a, "%s(\"%s\"), 0x%02x: "#a" is %u, should be %u\n", function, ptest->string, initial_value, ptimeouts1->a, ptimeouts2->a);
+#define check_timeouts_member(a) ok(ptimeouts1->a == ptimeouts2->a, "%s(\"%s\"), 0x%02x: "#a" is %lu, should be %lu\n", function, ptest->string, initial_value, ptimeouts1->a, ptimeouts2->a);
 
 static void check_timeouts(const char *function, const TEST *ptest, int initial_value, const COMMTIMEOUTS *ptimeouts1, const COMMTIMEOUTS *ptimeouts2)
 {
@@ -723,10 +723,10 @@ static HANDLE test_OpenComm(BOOL doOverlap)
             return INVALID_HANDLE_VALUE;
         }
 
-        ok(ret, "Unexpected error %u on open\n", GetLastError());
-        ok(comstat.cbInQue == 0, "Unexpected %d chars in InQueue\n",comstat.cbInQue);
-        ok(comstat.cbOutQue == 0, "Still pending %d characters in OutQueue\n", comstat.cbOutQue);
-        ok(errors == 0, "Unexpected errors 0x%08x\n", errors);
+        ok(ret, "Unexpected error %lu on open\n", GetLastError());
+        ok(comstat.cbInQue == 0, "Unexpected %ld chars in InQueue\n",comstat.cbInQue);
+        ok(comstat.cbOutQue == 0, "Still pending %ld characters in OutQueue\n", comstat.cbOutQue);
+        ok(errors == 0, "Unexpected errors 0x%08lx\n", errors);
     }
     return hcom;
 }
@@ -736,7 +736,7 @@ static void test_GetModemStatus(HANDLE hcom)
     DWORD ModemStat = 0;
 
     ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
-    trace("GetCommModemStatus returned 0x%08x->%s%s%s%s\n", ModemStat,
+    trace("GetCommModemStatus returned 0x%08lx->%s%s%s%s\n", ModemStat,
 	  (ModemStat &MS_RLSD_ON)?"MS_RLSD_ON ":"",
 	  (ModemStat &MS_RING_ON)?"MS_RING_ON ":"",
 	  (ModemStat &MS_DSR_ON)?"MS_DSR_ON ":"",
@@ -777,10 +777,10 @@ static void test_ReadTimeOut(void)
     LastError = GetLastError();
     after = GetTickCount();
     ok( res == TRUE, "A timed-out read should return TRUE\n");
-    ok( LastError == 0xdeadbeef, "err=%d\n", LastError);
+    ok( LastError == 0xdeadbeef, "err=%ld\n", LastError);
     timediff = after - before;
     ok( timediff > TIMEOUT>>2 && timediff < TIMEOUT *2,
-	"Unexpected TimeOut %d, expected %d\n", timediff, TIMEOUT);
+	"Unexpected TimeOut %ld, expected %d\n", timediff, TIMEOUT);
 
     CloseHandle(hcom);
 }
@@ -802,7 +802,7 @@ static void test_waittxempty(void)
 
     /* set a low baud rate to have ample time*/
     res = GetCommState(hcom, &dcb);
-    ok(res, "GetCommState error %d\n", GetLastError());
+    ok(res, "GetCommState error %ld\n", GetLastError());
     dcb.BaudRate = baud;
     dcb.ByteSize = 8;
     dcb.Parity = NOPARITY;
@@ -810,26 +810,26 @@ static void test_waittxempty(void)
     dcb.fDtrControl=DTR_CONTROL_ENABLE;
     dcb.StopBits = ONESTOPBIT;
     res = SetCommState(hcom, &dcb);
-    ok(res, "SetCommState error %d\n", GetLastError());
+    ok(res, "SetCommState error %ld\n", GetLastError());
 
     ZeroMemory( &timeouts, sizeof(timeouts));
     timeouts.ReadTotalTimeoutConstant = TIMEOUT;
     res = SetCommTimeouts(hcom, &timeouts);
-    ok(res,"SetCommTimeouts error %d\n", GetLastError());
+    ok(res,"SetCommTimeouts error %ld\n", GetLastError());
 
     res = SetupComm(hcom, 1024, 1024);
-    ok(res, "SetUpComm error %d\n", GetLastError());
+    ok(res, "SetUpComm error %ld\n", GetLastError());
 
     /* calling SetCommMask after WriteFile leads to WaitCommEvent failures
      * due to timeout (no events) under testbot VMs and VirtualBox
      */
     res = SetCommMask(hcom, EV_TXEMPTY);
-    ok(res, "SetCommMask error %d\n", GetLastError());
+    ok(res, "SetCommMask error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     res = WriteFile(hcom, tbuf, sizeof(tbuf), &bytes, NULL);
     ok(!res, "WriteFile on an overlapped handle without ovl structure should fail\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     S(U(ovl_write)).Offset = 0;
     S(U(ovl_write)).OffsetHigh = 0;
@@ -839,9 +839,9 @@ static void test_waittxempty(void)
     res = WriteFile(hcom, tbuf, sizeof(tbuf), &bytes, &ovl_write);
     after = GetTickCount();
     ok((!res && GetLastError() == ERROR_IO_PENDING) || (res && bytes == sizeof(tbuf)),
-       "WriteFile returned %d, written %u bytes, error %d\n", res, bytes, GetLastError());
-    if (!res) ok(!bytes, "expected 0, got %u\n", bytes);
-    ok(after - before < 30, "WriteFile took %d ms to write %d Bytes at %d Baud\n",
+       "WriteFile returned %d, written %lu bytes, error %ld\n", res, bytes, GetLastError());
+    if (!res) ok(!bytes, "expected 0, got %lu\n", bytes);
+    ok(after - before < 30, "WriteFile took %ld ms to write %ld Bytes at %ld Baud\n",
        after - before, bytes, baud);
     /* don't wait for WriteFile completion */
 
@@ -852,16 +852,16 @@ static void test_waittxempty(void)
     before = GetTickCount();
     SetLastError(0xdeadbeef);
     res = WaitCommEvent(hcom, &evtmask, &ovl_wait);
-    ok(res || GetLastError() == ERROR_IO_PENDING, "WaitCommEvent error %d\n", GetLastError());
+    ok(res || GetLastError() == ERROR_IO_PENDING, "WaitCommEvent error %ld\n", GetLastError());
     after = GetTickCount();
-    ok(after - before < 30, "WaitCommEvent should have returned immediately, took %d ms\n", after - before);
+    ok(after - before < 30, "WaitCommEvent should have returned immediately, took %ld ms\n", after - before);
     res = WaitForSingleObject(ovl_wait.hEvent, 1500);
     ok(res == WAIT_OBJECT_0, "WaitCommEvent failed with a timeout\n");
     if (res == WAIT_OBJECT_0)
     {
         res = GetOverlappedResult(hcom, &ovl_wait, &bytes, FALSE);
-        ok(res, "GetOverlappedResult reported error %d\n", GetLastError());
-        ok(bytes == sizeof(evtmask), "expected %u, written %u\n", (UINT)sizeof(evtmask), bytes);
+        ok(res, "GetOverlappedResult reported error %ld\n", GetLastError());
+        ok(bytes == sizeof(evtmask), "expected %u, written %lu\n", (UINT)sizeof(evtmask), bytes);
         res = TRUE;
     }
     else
@@ -869,7 +869,7 @@ static void test_waittxempty(void)
         /* unblock pending wait */
         trace("recovering after WAIT_TIMEOUT...\n");
         res = SetCommMask(hcom, EV_TXEMPTY);
-        ok(res, "SetCommMask error %d\n", GetLastError());
+        ok(res, "SetCommMask error %ld\n", GetLastError());
 
         res = WaitForSingleObject(ovl_wait.hEvent, TIMEOUT);
         ok(res == WAIT_OBJECT_0, "WaitCommEvent failed with a timeout\n");
@@ -877,19 +877,19 @@ static void test_waittxempty(void)
         res = FALSE;
     }
     after = GetTickCount();
-    ok(res, "WaitCommEvent error %d\n", GetLastError());
-    ok(evtmask & EV_TXEMPTY, "WaitCommEvent: expected EV_TXEMPTY, got %#x\n", evtmask);
+    ok(res, "WaitCommEvent error %ld\n", GetLastError());
+    ok(evtmask & EV_TXEMPTY, "WaitCommEvent: expected EV_TXEMPTY, got %#lx\n", evtmask);
     CloseHandle(ovl_wait.hEvent);
 
     timediff = after - before;
-    trace("WaitCommEvent for EV_TXEMPTY took %d ms (timeout 1500)\n", timediff);
-    ok(timediff < 1200, "WaitCommEvent used %d ms for waiting\n", timediff);
+    trace("WaitCommEvent for EV_TXEMPTY took %ld ms (timeout 1500)\n", timediff);
+    ok(timediff < 1200, "WaitCommEvent used %ld ms for waiting\n", timediff);
 
     res = WaitForSingleObject(ovl_write.hEvent, 0);
     ok(res == WAIT_OBJECT_0, "WriteFile failed with a timeout\n");
     res = GetOverlappedResult(hcom, &ovl_write, &bytes, FALSE);
-    ok(res, "GetOverlappedResult reported error %d\n", GetLastError());
-    ok(bytes == sizeof(tbuf), "expected %u, written %u\n", (UINT)sizeof(tbuf), bytes);
+    ok(res, "GetOverlappedResult reported error %ld\n", GetLastError());
+    ok(bytes == sizeof(tbuf), "expected %u, written %lu\n", (UINT)sizeof(tbuf), bytes);
     CloseHandle(ovl_write.hEvent);
 
     CloseHandle(hcom);
@@ -900,7 +900,7 @@ static void test_waittxempty(void)
         if (hcom == INVALID_HANDLE_VALUE) return;
 
         res = SetCommMask(hcom, EV_TXEMPTY);
-        ok(res, "SetCommMask error %d\n", GetLastError());
+        ok(res, "SetCommMask error %ld\n", GetLastError());
 
         if (i == 0)
         {
@@ -910,27 +910,27 @@ static void test_waittxempty(void)
             SetLastError(0xdeadbeef);
             res = WriteFile(hcom, tbuf, sizeof(tbuf), &bytes, &ovl_write);
             ok((!res && GetLastError() == ERROR_IO_PENDING) || (res && bytes == sizeof(tbuf)),
-               "WriteFile returned %d, written %u bytes, error %d\n", res, bytes, GetLastError());
-            if (!res) ok(!bytes, "expected 0, got %u\n", bytes);
+               "WriteFile returned %d, written %lu bytes, error %ld\n", res, bytes, GetLastError());
+            if (!res) ok(!bytes, "expected 0, got %lu\n", bytes);
 
             ClearCommError(hcom, &errors, &stat);
-            ok(stat.cbInQue == 0, "InQueue should be empty, got %d bytes\n", stat.cbInQue);
+            ok(stat.cbInQue == 0, "InQueue should be empty, got %ld bytes\n", stat.cbInQue);
             ok(stat.cbOutQue != 0 || broken(stat.cbOutQue == 0) /* VM */, "OutQueue should not be empty\n");
-            ok(errors == 0, "ClearCommErrors: Unexpected error 0x%08x\n", errors);
+            ok(errors == 0, "ClearCommErrors: Unexpected error 0x%08lx\n", errors);
 
             res = GetOverlappedResult(hcom, &ovl_write, &bytes, TRUE);
-            ok(res, "GetOverlappedResult reported error %d\n", GetLastError());
-            ok(bytes == sizeof(tbuf), "expected %u, written %u\n", (UINT)sizeof(tbuf), bytes);
+            ok(res, "GetOverlappedResult reported error %ld\n", GetLastError());
+            ok(bytes == sizeof(tbuf), "expected %u, written %lu\n", (UINT)sizeof(tbuf), bytes);
             CloseHandle(ovl_write.hEvent);
 
             res = FlushFileBuffers(hcom);
-            ok(res, "FlushFileBuffers error %d\n", GetLastError());
+            ok(res, "FlushFileBuffers error %ld\n", GetLastError());
         }
 
         ClearCommError(hcom, &errors, &stat);
-        ok(stat.cbInQue == 0, "InQueue should be empty, got %d bytes\n", stat.cbInQue);
-        ok(stat.cbOutQue == 0, "OutQueue should be empty, got %d bytes\n", stat.cbOutQue);
-        ok(errors == 0, "ClearCommErrors: Unexpected error 0x%08x\n", errors);
+        ok(stat.cbInQue == 0, "InQueue should be empty, got %ld bytes\n", stat.cbInQue);
+        ok(stat.cbOutQue == 0, "OutQueue should be empty, got %ld bytes\n", stat.cbOutQue);
+        ok(errors == 0, "ClearCommErrors: Unexpected error 0x%08lx\n", errors);
 
         S(U(ovl_wait)).Offset = 0;
         S(U(ovl_wait)).OffsetHigh = 0;
@@ -939,7 +939,7 @@ static void test_waittxempty(void)
         SetLastError(0xdeadbeef);
         res = WaitCommEvent(hcom, &evtmask, &ovl_wait);
         ok(res /* busy system */ || GetLastError() == ERROR_IO_PENDING,
-           "%d: WaitCommEvent error %d\n", i, GetLastError());
+           "%ld: WaitCommEvent error %ld\n", i, GetLastError());
 
         res = WaitForSingleObject(ovl_wait.hEvent, TIMEOUT);
         if (i == 0)
@@ -949,14 +949,14 @@ static void test_waittxempty(void)
         if (res == WAIT_OBJECT_0)
         {
             res = GetOverlappedResult(hcom, &ovl_wait, &bytes, FALSE);
-            ok(res, "GetOverlappedResult reported error %d\n", GetLastError());
-            ok(bytes == sizeof(evtmask), "expected %u, written %u\n", (UINT)sizeof(evtmask), bytes);
-            ok(res, "WaitCommEvent error %d\n", GetLastError());
-            ok(evtmask & EV_TXEMPTY, "WaitCommEvent: expected EV_TXEMPTY, got %#x\n", evtmask);
+            ok(res, "GetOverlappedResult reported error %ld\n", GetLastError());
+            ok(bytes == sizeof(evtmask), "expected %u, written %lu\n", (UINT)sizeof(evtmask), bytes);
+            ok(res, "WaitCommEvent error %ld\n", GetLastError());
+            ok(evtmask & EV_TXEMPTY, "WaitCommEvent: expected EV_TXEMPTY, got %#lx\n", evtmask);
         }
         else
         {
-            ok(!evtmask, "WaitCommEvent: expected 0, got %#x\n", evtmask);
+            ok(!evtmask, "WaitCommEvent: expected 0, got %#lx\n", evtmask);
 
             S(U(ovl_wait2)).Offset = 0;
             S(U(ovl_wait2)).OffsetHigh = 0;
@@ -964,13 +964,13 @@ static void test_waittxempty(void)
             SetLastError(0xdeadbeef);
             res = WaitCommEvent(hcom, &evtmask, &ovl_wait2);
             ok(!res, "WaitCommEvent should fail if there is a pending wait\n");
-            ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+            ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
             CloseHandle(ovl_wait2.hEvent);
 
             /* unblock pending wait */
             trace("recovering after WAIT_TIMEOUT...\n");
             res = SetCommMask(hcom, EV_TXEMPTY);
-            ok(res, "SetCommMask error %d\n", GetLastError());
+            ok(res, "SetCommMask error %ld\n", GetLastError());
 
             res = WaitForSingleObject(ovl_wait.hEvent, TIMEOUT);
             ok(res == WAIT_OBJECT_0, "WaitCommEvent failed with a timeout\n");
@@ -992,9 +992,9 @@ static void test_ClearCommError(void)
     if (hcom == INVALID_HANDLE_VALUE) return;
 
     ok(ClearCommError(hcom, &errors, &lpStat), "ClearCommError failed\n");
-    ok(lpStat.cbInQue == 0, "Unexpected %d chars in InQueue\n", lpStat.cbInQue);
-    ok(lpStat.cbOutQue == 0, "Unexpected %d chars in OutQueue\n", lpStat.cbOutQue);
-    ok(errors == 0, "ClearCommErrors: Unexpected error 0x%08x\n", errors);
+    ok(lpStat.cbInQue == 0, "Unexpected %ld chars in InQueue\n", lpStat.cbInQue);
+    ok(lpStat.cbOutQue == 0, "Unexpected %ld chars in OutQueue\n", lpStat.cbOutQue);
+    ok(errors == 0, "ClearCommErrors: Unexpected error 0x%08lx\n", errors);
 
     CloseHandle(hcom);
 }
@@ -1012,7 +1012,7 @@ static void test_non_pending_errors(void)
     dcb.ByteSize = 255; /* likely bogus */
     ok(!SetCommState(hcom, &dcb), "SetCommState should have failed\n");
     ok(ClearCommError(hcom, &err, NULL), "ClearCommError should succeed\n");
-    ok(!(err & CE_MODE), "ClearCommError shouldn't set CE_MODE byte in this case (%x)\n", err);
+    ok(!(err & CE_MODE), "ClearCommError shouldn't set CE_MODE byte in this case (%lx)\n", err);
 
     CloseHandle(hcom);
 }
@@ -1051,20 +1051,20 @@ static void test_LoopbackRead(void)
     before = GetTickCount();
     ok(WriteFile(hcom,tbuf,sizeof(tbuf),&written, NULL), "WriteFile failed\n");
     after = GetTickCount();
-    ok(written == sizeof(tbuf),"WriteFile %d bytes written\n", written);
+    ok(written == sizeof(tbuf),"WriteFile %ld bytes written\n", written);
     diff = after -before;
 
     /* make sure all bytes are written, so Readfile will succeed in one call*/
     ok(WaitCommEvent(hcom, &evtmask, NULL), "WaitCommEvent failed\n");
     before = GetTickCount();
     ok(evtmask == EV_TXEMPTY,
-                 "WaitCommEvent: Unexpected EvtMask 0x%08x, expected 0x%08x\n",
+                 "WaitCommEvent: Unexpected EvtMask 0x%08lx, expected 0x%08x\n",
 		 evtmask, EV_TXEMPTY);
-    trace("Write %d ms WaitCommEvent EV_TXEMPTY %d ms\n", diff, before- after);
+    trace("Write %ld ms WaitCommEvent EV_TXEMPTY %ld ms\n", diff, before- after);
 
     read=0;
     ok(ReadFile(hcom, rbuf, sizeof(rbuf), &read, NULL), "Readfile failed\n");
-    ok(read == sizeof(tbuf),"ReadFile read %d bytes, expected \"%s\"\n", read,rbuf);
+    ok(read == sizeof(tbuf),"ReadFile read %ld bytes, expected \"%s\"\n", read,rbuf);
 
     /* Now do the same with a slower Baud rate.
        As we request more characters than written, we will hit the timeout
@@ -1081,22 +1081,22 @@ static void test_LoopbackRead(void)
 
     ok(SetCommMask(hcom, EV_RXCHAR), "SetCommMask failed\n");
     ok(WriteFile(hcom,tbuf,sizeof(tbuf),&written, NULL), "WriteFile failed\n");
-    ok(written == sizeof(tbuf),"WriteFile %d bytes written\n", written);
+    ok(written == sizeof(tbuf),"WriteFile %ld bytes written\n", written);
 
     trace("WaitCommEventEV_RXCHAR\n");
     ok(WaitCommEvent(hcom, &evtmask, NULL), "WaitCommEvent failed\n");
-    ok(evtmask == EV_RXCHAR, "WaitCommEvent: Unexpected EvtMask 0x%08x, expected 0x%08x\n",
+    ok(evtmask == EV_RXCHAR, "WaitCommEvent: Unexpected EvtMask 0x%08lx, expected 0x%08x\n",
        evtmask, EV_RXCHAR);
 
     before = GetTickCount();
     res = ReadFile(hcom, rbuf, sizeof(rbuf), &read, NULL);
     after = GetTickCount();
     ok(res, "Readfile failed\n");
-    ok(read == sizeof(tbuf),"ReadFile read %d bytes\n", read);
+    ok(read == sizeof(tbuf),"ReadFile read %ld bytes\n", read);
     diff = after - before;
-    trace("Readfile for %d chars took %d ms\n", read, diff);
+    trace("Readfile for %ld chars took %ld ms\n", read, diff);
     ok( (diff > TIMEOUT - TIMEDELTA) && (diff < TIMEOUT + TIMEDELTA),
-	"Timedout Wait took %d ms, expected around %d\n", diff, TIMEOUT);
+	"Timedout Wait took %ld ms, expected around %d\n", diff, TIMEOUT);
 
     /* now do a plain read with slow speed
      * This will result in several low level reads and a timeout to happen
@@ -1117,8 +1117,8 @@ static void test_LoopbackRead(void)
     }
     while ((read < sizeof(tbuf)) && (i <10));
     after =  GetTickCount();
-    ok( read == sizeof(tbuf),"ReadFile read %d bytes\n", read);
-    trace("Plain Read for %d char at %d baud took %d ms\n", read, SLOWBAUD, after-before);
+    ok( read == sizeof(tbuf),"ReadFile read %ld bytes\n", read);
+    trace("Plain Read for %ld char at %d baud took %ld ms\n", read, SLOWBAUD, after-before);
 
     CloseHandle(hcom);
 }
@@ -1149,11 +1149,11 @@ static void test_LoopbackCtsRts(void)
     {
 	ok(EscapeCommFunction(hcom, CLRRTS), "EscapeCommFunction failed to clear RTS\n");
 	ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
-	ok ((ModemStat & MS_CTS_ON) == 0, "CTS didn't react: 0x%04x,  expected 0x%04x\n",
+	ok ((ModemStat & MS_CTS_ON) == 0, "CTS didn't react: 0x%04lx,  expected 0x%04lx\n",
 	    ModemStat, (defaultStat & ~MS_CTS_ON));
 	ok(EscapeCommFunction(hcom, SETRTS), "EscapeCommFunction failed to clear RTS\n");
 	ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
-	ok (ModemStat ==  defaultStat, "Failed to restore CTS: 0x%04x, expected 0x%04x\n",
+	ok (ModemStat ==  defaultStat, "Failed to restore CTS: 0x%04lx, expected 0x%04lx\n",
 	    ModemStat, defaultStat);
     }
     else
@@ -1161,11 +1161,11 @@ static void test_LoopbackCtsRts(void)
 	ok(EscapeCommFunction(hcom, SETRTS), "EscapeCommFunction failed to set RTS\n");
 	ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
 	ok ((ModemStat & MS_CTS_ON) == MS_CTS_ON,
-            "CTS didn't react: 0x%04x,  expected 0x%04x\n",
+            "CTS didn't react: 0x%04lx,  expected 0x%04lx\n",
 	    ModemStat, (defaultStat | MS_CTS_ON));
 	ok(EscapeCommFunction(hcom, CLRRTS), "EscapeCommFunction failed to clear RTS\n");
 	ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
-	ok (ModemStat ==  defaultStat, "Failed to restore CTS: 0x%04x, expected 0x%04x\n",
+	ok (ModemStat ==  defaultStat, "Failed to restore CTS: 0x%04lx, expected 0x%04lx\n",
 	    ModemStat, defaultStat);
     }
 
@@ -1197,11 +1197,11 @@ static void test_LoopbackDtrDcd(void)
     {
 	ok(EscapeCommFunction(hcom, CLRDTR), "EscapeCommFunction failed to clear DTR\n");
 	ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
-	ok ((ModemStat & MS_RLSD_ON) == 0, "RLSD didn't react: 0x%04x,  expected 0x%04x\n",
+	ok ((ModemStat & MS_RLSD_ON) == 0, "RLSD didn't react: 0x%04lx,  expected 0x%04lx\n",
 	    ModemStat, (defaultStat & ~MS_RLSD_ON));
 	ok(EscapeCommFunction(hcom, SETDTR), "EscapeCommFunction failed to set DTR\n");
 	ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
-	ok (ModemStat ==  defaultStat, "Failed to restore RLSD: 0x%04x, expected 0x%04x\n",
+	ok (ModemStat ==  defaultStat, "Failed to restore RLSD: 0x%04lx, expected 0x%04lx\n",
 	    ModemStat, defaultStat);
     }
     else
@@ -1209,11 +1209,11 @@ static void test_LoopbackDtrDcd(void)
 	ok(EscapeCommFunction(hcom, SETDTR), "EscapeCommFunction failed to set DTR\n");
 	ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
 	ok ((ModemStat & MS_RLSD_ON) == MS_RLSD_ON,
-            "RLSD didn't react: 0x%04x,  expected 0x%04x\n",
+            "RLSD didn't react: 0x%04lx,  expected 0x%04lx\n",
 	    ModemStat, (defaultStat | MS_RLSD_ON));
 	ok(EscapeCommFunction(hcom, CLRDTR), "EscapeCommFunction failed to clear DTR\n");
 	ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
-	ok (ModemStat ==  defaultStat, "Failed to restore RLSD: 0x%04x, expected 0x%04x\n",
+	ok (ModemStat ==  defaultStat, "Failed to restore RLSD: 0x%04lx, expected 0x%04lx\n",
 	    ModemStat, defaultStat);
     }
 
@@ -1245,11 +1245,11 @@ static void test_LoopbackDtrDsr(void)
     {
 	ok(EscapeCommFunction(hcom, CLRDTR), "EscapeCommFunction failed to clear DTR\n");
 	ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
-	ok ((ModemStat & MS_DSR_ON) == 0, "CTS didn't react: 0x%04x,  expected 0x%04x\n",
+	ok ((ModemStat & MS_DSR_ON) == 0, "CTS didn't react: 0x%04lx,  expected 0x%04lx\n",
 	    ModemStat, (defaultStat & ~MS_DSR_ON));
 	ok(EscapeCommFunction(hcom, SETDTR), "EscapeCommFunction failed to clear DTR\n");
 	ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
-	ok (ModemStat ==  defaultStat, "Failed to restore DSR: 0x%04x, expected 0x%04x\n",
+	ok (ModemStat ==  defaultStat, "Failed to restore DSR: 0x%04lx, expected 0x%04lx\n",
 	    ModemStat, defaultStat);
     }
     else
@@ -1257,11 +1257,11 @@ static void test_LoopbackDtrDsr(void)
 	ok(EscapeCommFunction(hcom, SETDTR), "EscapeCommFunction failed to set DTR\n");
 	ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
 	ok ((ModemStat & MS_DSR_ON) == MS_DSR_ON,
-            "CTS didn't react: 0x%04x,expected 0x%04x\n",
+            "CTS didn't react: 0x%04lx,expected 0x%04lx\n",
 	    ModemStat, (defaultStat | MS_DSR_ON));
 	ok(EscapeCommFunction(hcom, CLRDTR), "EscapeCommFunction failed to clear DTR\n");
 	ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
-	ok (ModemStat ==  defaultStat, "Failed to restore DSR: 0x%04x, expected 0x%04x\n",
+	ok (ModemStat ==  defaultStat, "Failed to restore DSR: 0x%04lx, expected 0x%04lx\n",
 	    ModemStat, defaultStat);
     }
 
@@ -1293,11 +1293,11 @@ static void test_LoopbackDtrRing(void)
     {
 	ok(EscapeCommFunction(hcom, CLRDTR), "EscapeCommFunction failed to clear DTR\n");
 	ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
-	ok ((ModemStat & MS_RING_ON) == 0, "RING didn't react: 0x%04x,  expected 0x%04x\n",
+	ok ((ModemStat & MS_RING_ON) == 0, "RING didn't react: 0x%04lx,  expected 0x%04lx\n",
 	    ModemStat, (defaultStat & ~MS_RING_ON));
 	ok(EscapeCommFunction(hcom, SETDTR), "EscapeCommFunction failed to set DTR\n");
 	ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
-	ok (ModemStat ==  defaultStat, "Failed to restore RING: 0x%04x, expected 0x%04x\n",
+	ok (ModemStat ==  defaultStat, "Failed to restore RING: 0x%04lx, expected 0x%04lx\n",
 	    ModemStat, defaultStat);
     }
     else
@@ -1305,11 +1305,11 @@ static void test_LoopbackDtrRing(void)
 	ok(EscapeCommFunction(hcom, SETDTR), "EscapeCommFunction failed to set DTR\n");
 	ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
 	ok ((ModemStat & MS_RING_ON) == MS_RING_ON,
-            "RING didn't react: 0x%04x,expected 0x%04x\n",
+            "RING didn't react: 0x%04lx,expected 0x%04lx\n",
 	    ModemStat, (defaultStat | MS_RING_ON));
 	ok(EscapeCommFunction(hcom, CLRDTR), "EscapeCommFunction failed to clear DTR\n");
 	ok(GetCommModemStatus(hcom, &ModemStat), "GetCommModemStatus failed\n");
-	ok (ModemStat ==  defaultStat, "Failed to restore RING: 0x%04x, expected 0x%04x\n",
+	ok (ModemStat ==  defaultStat, "Failed to restore RING: 0x%04lx, expected 0x%04lx\n",
 	    ModemStat, defaultStat);
     }
 
@@ -1342,7 +1342,7 @@ static void test_WaitRx(void)
     overlapped.hEvent = hComPortEvent;
 
     hComWriteEvent = CreateEventW( NULL, TRUE, FALSE, NULL );
-    ok(hComWriteEvent != NULL, "CreateEvent res %d\n", GetLastError());
+    ok(hComWriteEvent != NULL, "CreateEvent res %ld\n", GetLastError());
     ZeroMemory( &overlapped_w, sizeof(overlapped_w));
     overlapped_w.hEvent = hComWriteEvent;
 
@@ -1350,47 +1350,47 @@ static void test_WaitRx(void)
     success_wait = WaitCommEvent(hcom, &evtmask, &overlapped);
     err_wait = GetLastError();
     after = GetTickCount();
-    trace("Success 0x%08x err %d evtmask 0x%08x\n", success_wait, err_wait, evtmask);
+    trace("Success 0x%08lx err %ld evtmask 0x%08lx\n", success_wait, err_wait, evtmask);
     ok(success_wait || err_wait == ERROR_IO_PENDING, "overlapped WaitCommEvent failed\n");
     trace("overlapped WaitCommEvent returned.\n");
 
     success_write= WriteFile(hcom, "X", 1, &written, &overlapped_w);
     err_write = GetLastError();
     ok(success_write || err_write == ERROR_IO_PENDING,
-       "overlapped WriteFile failed, err %d\n",
+       "overlapped WriteFile failed, err %ld\n",
        err_write);
 
     if (!success_write && (err_write == ERROR_IO_PENDING)) {
       success_write = WaitForSingleObjectEx(hComWriteEvent, TIMEOUT, TRUE);
       err_write = GetLastError();
-      ok(success_write == WAIT_OBJECT_0, "WaitForSingleObjectEx, res %d, err %d\n",
+      ok(success_write == WAIT_OBJECT_0, "WaitForSingleObjectEx, res %ld, err %ld\n",
 	 success_write, err_write);
     }
     Sleep(TIMEOUT >>1);
     success_write = GetOverlappedResult(hcom, &overlapped_w, &written, FALSE);
     err_write = GetLastError();
 
-    trace("Write after Wait res 0x%08x err %d\n",success_write, err_write);
-    ok(success_write && written ==1, "Write after Wait res 0x%08x err %d\n",
+    trace("Write after Wait res 0x%08lx err %ld\n",success_write, err_write);
+    ok(success_write && written ==1, "Write after Wait res 0x%08lx err %ld\n",
        success_write, err_write);
 
     if (!success_wait && (err_wait == ERROR_IO_PENDING)) {
       success_wait = WaitForSingleObjectEx(hComPortEvent, TIMEOUT, TRUE);
       err_wait = GetLastError();
-      ok(success_wait == WAIT_OBJECT_0, "wait hComPortEvent, res 0x%08x, err %d\n",
+      ok(success_wait == WAIT_OBJECT_0, "wait hComPortEvent, res 0x%08lx, err %ld\n",
 	 success_wait, err_wait);
     }
     success_wait = GetOverlappedResult(hcom, &overlapped, &written, FALSE);
     err_wait = GetLastError();
     after1 = GetTickCount();
-    trace("Success 0x%08x err %d evtmask 0x%08x diff1 %d, diff2 %d\n",
+    trace("Success 0x%08lx err %ld evtmask 0x%08lx diff1 %ld, diff2 %ld\n",
 	  success_wait, err_wait, evtmask, after-before, after1-before);
 
-    ok(evtmask & EV_RXCHAR, "Detect  EV_RXCHAR: 0x%08x, expected 0x%08x\n",
+    ok(evtmask & EV_RXCHAR, "Detect  EV_RXCHAR: 0x%08lx, expected 0x%08x\n",
        evtmask, EV_RXCHAR);
     diff = after1 - before;
     ok ((diff > (TIMEOUT>>1) -TIMEDELTA) && (diff < (TIMEOUT>>1) + TIMEDELTA),
-	"Unexpected time %d, expected around %d\n", diff, TIMEOUT>>1);
+	"Unexpected time %ld, expected around %d\n", diff, TIMEOUT>>1);
 
     CloseHandle(hcom);
 }
@@ -1407,13 +1407,13 @@ static DWORD CALLBACK toggle_ctlLine(LPVOID arg)
     HANDLE hComPortEvent = (HANDLE) args[3];
     DWORD success, err;
 
-    trace("toggle_ctlLine timeout %d ctl 0x%08x handle %p\n", timeout, ctl, hcom );
+    trace("toggle_ctlLine timeout %ld ctl 0x%08lx handle %p\n", timeout, ctl, hcom );
     Sleep(timeout);
-    ok(EscapeCommFunction(hcom, ctl),"EscapeCommFunction 0x%08x failed\n", ctl);
+    ok(EscapeCommFunction(hcom, ctl),"EscapeCommFunction 0x%08lx failed\n", ctl);
     trace("toggle_ctline done\n");
     success = WaitForSingleObjectEx(hComPortEvent, TIMEOUT, TRUE);
     err = GetLastError();
-    trace("toggle_ctline WaitForSingleObjectEx res 0x%08x err %d\n",
+    trace("toggle_ctline WaitForSingleObjectEx res 0x%08lx err %ld\n",
 	  success, err);
     return 0;
 }
@@ -1453,7 +1453,7 @@ static void test_WaitCts(void)
 	args[1] = SETRTS;
     args[2]=(DWORD_PTR)hcom;
 
-    trace("test_WaitCts timeout %ld clt 0x%08lx handle %p\n",args[0], args[1], hcom);
+    trace("test_WaitCts timeout %Id clt 0x%08Ix handle %p\n",args[0], args[1], hcom);
 
     ok(SetCommMask(hcom, EV_CTS), "SetCommMask failed\n");
     hComPortEvent =  CreateEventW( NULL, TRUE, FALSE, NULL );
@@ -1472,7 +1472,7 @@ static void test_WaitCts(void)
     err = GetLastError();
     after = GetTickCount();
 
-    trace("Success 0x%08x err %d evtmask 0x%08x\n", success, err, evtmask);
+    trace("Success 0x%08lx err %ld evtmask 0x%08lx\n", success, err, evtmask);
     ok(success || err == ERROR_IO_PENDING, "overlapped WaitCommEvent failed\n");
     trace("overlapped WaitCommEvent returned.\n");
     if (!success && (err == ERROR_IO_PENDING))
@@ -1481,10 +1481,10 @@ static void test_WaitCts(void)
     success = GetOverlappedResult(hcom, &overlapped, &written, FALSE);
     err = GetLastError();
     after1 = GetTickCount();
-    trace("Success 0x%08x err %d evtmask 0x%08x diff1 %d, diff2 %d\n",
+    trace("Success 0x%08lx err %ld evtmask 0x%08lx diff1 %ld, diff2 %ld\n",
 	  success, err, evtmask, after-before, after1-before);
 
-    ok(evtmask & EV_CTS, "Failed to detect  EV_CTS: 0x%08x, expected 0x%08x\n",
+    ok(evtmask & EV_CTS, "Failed to detect  EV_CTS: 0x%08lx, expected 0x%08x\n",
 		 evtmask, EV_CTS);
     ok(GetCommModemStatus(hcom, &evtmask), "GetCommModemStatus failed\n");
     if(defaultStat & MS_CTS_ON)
@@ -1494,7 +1494,7 @@ static void test_WaitCts(void)
 
     diff = after1 - before;
     ok ((diff > (TIMEOUT>>1) -TIMEDELTA) && (diff < (TIMEOUT>>1) + TIMEDELTA),
-                  "Unexpected time %d, expected around %d\n", diff, TIMEOUT>>1);
+                  "Unexpected time %ld, expected around %d\n", diff, TIMEOUT>>1);
 
     /*restore RTS Settings*/
     if(defaultStat & MS_CTS_ON)
@@ -1516,7 +1516,7 @@ static DWORD CALLBACK reset_CommMask(LPVOID arg)
     DWORD timeout = args[0];
     HANDLE hcom   = (HANDLE) args[1];
 
-    trace(" Changing CommMask on the fly for handle %p after timeout %d\n",
+    trace(" Changing CommMask on the fly for handle %p after timeout %ld\n",
 	  hcom, timeout);
     Sleep(timeout);
     ok(SetCommMask(hcom, 0),"SetCommMask %p failed\n", hcom);
@@ -1549,7 +1549,7 @@ static void test_AbortWaitCts(void)
     args[0]= TIMEOUT >>1;
     args[1]= (DWORD_PTR)hcom;
 
-    trace("test_AbortWaitCts timeout %ld handle %p\n",args[0], hcom);
+    trace("test_AbortWaitCts timeout %Id handle %p\n",args[0], hcom);
 
     ok(SetCommMask(hcom, EV_CTS), "SetCommMask failed\n");
     hComPortEvent =  CreateEventW( NULL, TRUE, FALSE, NULL );
@@ -1567,7 +1567,7 @@ static void test_AbortWaitCts(void)
     err = GetLastError();
     after = GetTickCount();
 
-    trace("Success 0x%08x err %d evtmask 0x%08x\n", success, err, evtmask);
+    trace("Success 0x%08lx err %ld evtmask 0x%08lx\n", success, err, evtmask);
     ok(success || err == ERROR_IO_PENDING, "overlapped WaitCommEvent failed\n");
     trace("overlapped WaitCommEvent returned.\n");
     if (!success && (err == ERROR_IO_PENDING))
@@ -1576,15 +1576,15 @@ static void test_AbortWaitCts(void)
     success = GetOverlappedResult(hcom, &overlapped, &written, FALSE);
     err = GetLastError();
     after1 = GetTickCount();
-    trace("Success 0x%08x err %d evtmask 0x%08x diff1 %d, diff2 %d\n",
+    trace("Success 0x%08lx err %ld evtmask 0x%08lx diff1 %ld, diff2 %ld\n",
 	  success, err, evtmask, after-before, after1-before);
 
-    ok(evtmask == 0, "Incorrect EventMask 0x%08x returned on Wait aborted bu SetCommMask, expected 0x%08x\n",
+    ok(evtmask == 0, "Incorrect EventMask 0x%08lx returned on Wait aborted bu SetCommMask, expected 0x%08x\n",
 		 evtmask, 0);
     ok(GetCommModemStatus(hcom, &evtmask), "GetCommModemStatus failed\n");
     diff = after1 - before;
     ok ((diff > (TIMEOUT>>1) -TIMEDELTA) && (diff < (TIMEOUT>>1) + TIMEDELTA),
-                  "Unexpected time %d, expected around %d\n", diff, TIMEOUT>>1);
+                  "Unexpected time %ld, expected around %d\n", diff, TIMEOUT>>1);
 
     CloseHandle(hcom);
     ok( !WaitForSingleObject( alarmThread, 10000 ), "thread still running\n" );
@@ -1623,7 +1623,7 @@ static void test_WaitDsr(void)
 	args[1] = SETDTR;
     args[2]= (DWORD_PTR)hcom;
 
-    trace("test_WaitDsr timeout %ld clt 0x%08lx handle %p\n",args[0], args[1], hcom);
+    trace("test_WaitDsr timeout %Id clt 0x%08Ix handle %p\n",args[0], args[1], hcom);
 
     ok(SetCommMask(hcom, EV_DSR), "SetCommMask failed\n");
     hComPortEvent =  CreateEventW( NULL, TRUE, FALSE, NULL );
@@ -1638,7 +1638,7 @@ static void test_WaitDsr(void)
     err = GetLastError();
     after = GetTickCount();
 
-    trace("Success 0x%08x err %d evtmask 0x%08x\n", success, err, evtmask);
+    trace("Success 0x%08lx err %ld evtmask 0x%08lx\n", success, err, evtmask);
     ok(success || err == ERROR_IO_PENDING, "overlapped WaitCommEvent failed\n");
     trace("overlapped WaitCommEvent returned.\n");
     if (!success && (err == ERROR_IO_PENDING))
@@ -1647,10 +1647,10 @@ static void test_WaitDsr(void)
     success = GetOverlappedResult(hcom, &overlapped, &written, FALSE);
     err = GetLastError();
     after1 = GetTickCount();
-    trace("Success 0x%08x err %d evtmask 0x%08x diff1 %d, diff2 %d\n",
+    trace("Success 0x%08lx err %ld evtmask 0x%08lx diff1 %ld, diff2 %ld\n",
 	  success, err, evtmask, after-before, after1-before);
 
-    ok(evtmask & EV_DSR, "Failed to detect  EV_DSR: 0x%08x, expected 0x%08x\n",
+    ok(evtmask & EV_DSR, "Failed to detect  EV_DSR: 0x%08lx, expected 0x%08x\n",
 		 evtmask, EV_DSR);
     ok(GetCommModemStatus(hcom, &evtmask), "GetCommModemStatus failed\n");
     if(defaultStat & MS_DSR_ON)
@@ -1660,7 +1660,7 @@ static void test_WaitDsr(void)
 
     diff = after1 - before;
     ok ((diff > (TIMEOUT>>1) -TIMEDELTA) && (diff < (TIMEOUT>>1) + TIMEDELTA),
-                  "Unexpected time %d, expected around %d\n", diff, TIMEOUT>>1);
+                  "Unexpected time %ld, expected around %d\n", diff, TIMEOUT>>1);
 
     /*restore RTS Settings*/
     if(defaultStat & MS_DSR_ON)
@@ -1711,7 +1711,7 @@ static void test_WaitRing(void)
 	args[1] = SETDTR;
     args[2]=(DWORD_PTR) hcom;
 
-    trace("test_WaitRing timeout %ld clt 0x%08lx handle %p\n",args[0], args[1], hcom);
+    trace("test_WaitRing timeout %Id clt 0x%08Ix handle %p\n",args[0], args[1], hcom);
 
     ok(SetCommMask(hcom, EV_RING), "SetCommMask failed\n");
     hComPortEvent =  CreateEventW( NULL, TRUE, FALSE, NULL );
@@ -1726,7 +1726,7 @@ static void test_WaitRing(void)
     err = GetLastError();
     after = GetTickCount();
 
-    trace("Success 0x%08x err %d evtmask 0x%08x\n", success, err, evtmask);
+    trace("Success 0x%08lx err %ld evtmask 0x%08lx\n", success, err, evtmask);
     ok(success || err == ERROR_IO_PENDING, "overlapped WaitCommEvent failed\n");
     trace("overlapped WaitCommEvent returned.\n");
     if (!success && (err == ERROR_IO_PENDING))
@@ -1735,10 +1735,10 @@ static void test_WaitRing(void)
     success = GetOverlappedResult(hcom, &overlapped, &written, FALSE);
     err = GetLastError();
     after1 = GetTickCount();
-    trace("Success 0x%08x err %d evtmask 0x%08x diff1 %d, diff2 %d\n",
+    trace("Success 0x%08lx err %ld evtmask 0x%08lx diff1 %ld, diff2 %ld\n",
 	  success, err, evtmask, after-before, after1-before);
 
-    ok(evtmask & EV_RING, "Failed to detect  EV_RING: 0x%08x, expected 0x%08x\n",
+    ok(evtmask & EV_RING, "Failed to detect  EV_RING: 0x%08lx, expected 0x%08x\n",
        evtmask, EV_RING);
     ok(GetCommModemStatus(hcom, &evtmask), "GetCommModemStatus failed\n");
     if(defaultStat & MS_RING_ON)
@@ -1748,7 +1748,7 @@ static void test_WaitRing(void)
 
     diff = after1 - before;
     ok ((diff > (TIMEOUT>>1) -TIMEDELTA) && (diff < (TIMEOUT>>1) + TIMEDELTA),
-                  "Unexpected time %d, expected around %d\n", diff, TIMEOUT>>1);
+                  "Unexpected time %ld, expected around %d\n", diff, TIMEOUT>>1);
 
     /*restore RTS Settings*/
     if(defaultStat & MS_RING_ON)
@@ -1792,7 +1792,7 @@ static void test_WaitDcd(void)
 	args[1] = SETDTR;
     args[2]= (DWORD_PTR)hcom;
 
-    trace("test_WaitDcd timeout %ld clt 0x%08lx handle %p\n",args[0], args[1], hcom);
+    trace("test_WaitDcd timeout %Id clt 0x%08Ix handle %p\n",args[0], args[1], hcom);
 
     ok(SetCommMask(hcom, EV_RLSD), "SetCommMask failed\n");
     hComPortEvent =  CreateEventW( NULL, TRUE, FALSE, NULL );
@@ -1807,7 +1807,7 @@ static void test_WaitDcd(void)
     err = GetLastError();
     after = GetTickCount();
 
-    trace("Success 0x%08x err %d evtmask 0x%08x\n", success, err, evtmask);
+    trace("Success 0x%08lx err %ld evtmask 0x%08lx\n", success, err, evtmask);
     ok(success || err == ERROR_IO_PENDING, "overlapped WaitCommEvent failed\n");
     trace("overlapped WaitCommEvent returned.\n");
     if (!success && (err == ERROR_IO_PENDING))
@@ -1816,10 +1816,10 @@ static void test_WaitDcd(void)
     success = GetOverlappedResult(hcom, &overlapped, &written, FALSE);
     err = GetLastError();
     after1 = GetTickCount();
-    trace("Success 0x%08x err %d evtmask 0x%08x diff1 %d, diff2 %d\n",
+    trace("Success 0x%08lx err %ld evtmask 0x%08lx diff1 %ld, diff2 %ld\n",
 	  success, err, evtmask, after-before, after1-before);
 
-    ok(evtmask & EV_RLSD, "Failed to detect  EV_RLSD: 0x%08x, expected 0x%08x\n",
+    ok(evtmask & EV_RLSD, "Failed to detect  EV_RLSD: 0x%08lx, expected 0x%08x\n",
 		 evtmask, EV_RLSD);
     ok(GetCommModemStatus(hcom, &evtmask), "GetCommModemStatus failed\n");
     if(defaultStat & MS_RLSD_ON)
@@ -1829,7 +1829,7 @@ static void test_WaitDcd(void)
 
     diff = after1 - before;
     ok ((diff > (TIMEOUT>>1) -TIMEDELTA) && (diff < (TIMEOUT>>1) + TIMEDELTA),
-                  "Unexpected time %d, expected around %d\n", diff, TIMEOUT>>1);
+                  "Unexpected time %ld, expected around %d\n", diff, TIMEOUT>>1);
 
     /*restore RTS Settings*/
     if(defaultStat & MS_RLSD_ON)
@@ -1851,7 +1851,7 @@ static DWORD CALLBACK set_CommBreak(LPVOID arg)
     DWORD timeout = args[0];
     HANDLE hcom   = (HANDLE) args[1];
 
-    trace("SetCommBreak for handle %p after timeout %d\n",
+    trace("SetCommBreak for handle %p after timeout %ld\n",
 	  hcom, timeout);
     Sleep(timeout);
     ok(SetCommBreak(hcom),"SetCommBreak %p failed\n", hcom);
@@ -1895,28 +1895,28 @@ static void test_WaitBreak(void)
     err = GetLastError();
     after = GetTickCount();
 
-    trace("Success 0x%08x err %d evtmask 0x%08x\n", success, err, evtmask);
+    trace("Success 0x%08lx err %ld evtmask 0x%08lx\n", success, err, evtmask);
     ok(success || err == ERROR_IO_PENDING, "overlapped WaitCommEvent failed\n");
     trace("overlapped WaitCommEvent returned.\n");
 
     if (!success && (err == ERROR_IO_PENDING))
     {
         success = WaitForSingleObjectEx(hComPortEvent, TIMEOUT, TRUE);
-        ok(!success, "wait hComPortEvent res %d\n", GetLastError());
+        ok(!success, "wait hComPortEvent res %ld\n", GetLastError());
     }
     success = GetOverlappedResult(hcom, &overlapped, &written, FALSE);
     err = GetLastError();
     after1 = GetTickCount();
-    trace("Success 0x%08x err %d evtmask 0x%08x diff1 %d, diff2 %d\n",
+    trace("Success 0x%08lx err %ld evtmask 0x%08lx diff1 %ld, diff2 %ld\n",
 	  success, err, evtmask, after-before, after1-before);
 
-    ok(evtmask & EV_BREAK, "Failed to detect  EV_BREAK: 0x%08x, expected 0x%08x\n",
+    ok(evtmask & EV_BREAK, "Failed to detect  EV_BREAK: 0x%08lx, expected 0x%08x\n",
        evtmask, EV_BREAK);
     ok(GetCommModemStatus(hcom, &evtmask), "GetCommModemStatus failed\n");
 
     diff = after1 - before;
     ok ((diff > (TIMEOUT>>1) -TIMEDELTA) && (diff < (TIMEOUT>>1) + TIMEDELTA),
-	"Unexpected time %d, expected around %d\n", diff, TIMEOUT>>1);
+	"Unexpected time %ld, expected around %d\n", diff, TIMEOUT>>1);
 
     ok(ClearCommBreak(hcom), "ClearCommBreak failed\n");
 
@@ -1932,7 +1932,7 @@ static void test_stdio(void)
     /* cygwin tries this to determine the stdin handle type */
     ok( !GetCommState( GetStdHandle(STD_INPUT_HANDLE), &dcb ), "GetCommState succeeded on stdin\n" );
     ok( GetLastError() == ERROR_INVALID_HANDLE || GetLastError() == ERROR_INVALID_FUNCTION,
-        "got error %u\n", GetLastError() );
+        "got error %lu\n", GetLastError() );
 }
 
 static void test_WaitCommEvent(void)
@@ -1947,7 +1947,7 @@ static void test_WaitCommEvent(void)
     test_GetModemStatus(hcom);
 
     ret = SetCommMask(hcom, 0x1fff);
-    ok(ret, "SetCommMask error %d\n", GetLastError());
+    ok(ret, "SetCommMask error %ld\n", GetLastError());
 
     S(U(ovl_wait)).Offset = 0;
     S(U(ovl_wait)).OffsetHigh = 0;
@@ -1961,7 +1961,7 @@ static void test_WaitCommEvent(void)
         evtmask = 0;
         SetLastError(0xdeadbeef);
         ret = WaitCommEvent(hcom, &evtmask, &ovl_wait);
-        ok(!ret && GetLastError() == ERROR_IO_PENDING, "WaitCommEvent returned %d, error %d\n", ret, GetLastError());
+        ok(!ret && GetLastError() == ERROR_IO_PENDING, "WaitCommEvent returned %ld, error %ld\n", ret, GetLastError());
         if (GetLastError() != ERROR_IO_PENDING) goto done; /* no point in further testing */
         for (;;)
         {
@@ -1971,9 +1971,9 @@ static void test_WaitCommEvent(void)
             {
                 last_event_time = after;
                 ret = GetOverlappedResult(hcom, &ovl_wait, &bytes, FALSE);
-                ok(ret, "GetOverlappedResult reported error %d\n", GetLastError());
-                ok(bytes == sizeof(evtmask), "expected %u, written %u\n", (UINT)sizeof(evtmask), bytes);
-                trace("WaitCommEvent: got events %#x\n", evtmask);
+                ok(ret, "GetOverlappedResult reported error %ld\n", GetLastError());
+                ok(bytes == sizeof(evtmask), "expected %u, written %lu\n", (UINT)sizeof(evtmask), bytes);
+                trace("WaitCommEvent: got events %#lx\n", evtmask);
                 test_GetModemStatus(hcom);
                 break;
             }
@@ -1999,17 +1999,17 @@ static void test_FlushFileBuffers(void)
     if (hcom == INVALID_HANDLE_VALUE) return;
 
     ret = WriteFile(hcom, "\0\0\0\0\0\0\0", 7, &bytes, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
-    ok(bytes == 7, "expected 7, got %u\n", bytes);
+    ok(ret, "WriteFile error %ld\n", GetLastError());
+    ok(bytes == 7, "expected 7, got %lu\n", bytes);
 
     ret = FlushFileBuffers(hcom);
-    ok(ret, "FlushFileBuffers error %d\n", GetLastError());
+    ok(ret, "FlushFileBuffers error %ld\n", GetLastError());
 
     ret = ClearCommError(hcom, &errors, &stat);
-    ok(ret, "ClearCommError error %d\n", GetLastError());
-    ok(stat.cbInQue == 0, "expected 0, got %d bytes in InQueue\n", stat.cbInQue);
-    ok(stat.cbOutQue == 0, "expected 0, got %d bytes in OutQueue\n", stat.cbOutQue);
-    ok(errors == 0, "expected errors 0, got %#x\n", errors);
+    ok(ret, "ClearCommError error %ld\n", GetLastError());
+    ok(stat.cbInQue == 0, "expected 0, got %ld bytes in InQueue\n", stat.cbInQue);
+    ok(stat.cbOutQue == 0, "expected 0, got %ld bytes in OutQueue\n", stat.cbOutQue);
+    ok(errors == 0, "expected errors 0, got %#lx\n", errors);
 
     CloseHandle(hcom);
 }
@@ -2037,7 +2037,7 @@ static void test_read_write(void)
     if (hcom == INVALID_HANDLE_VALUE) return;
 
     ret = GetCommState(hcom, &dcb);
-    ok(ret, "GetCommState error %d\n", GetLastError());
+    ok(ret, "GetCommState error %ld\n", GetLastError());
     dcb.BaudRate = 9600;
     dcb.ByteSize = 8;
     dcb.Parity = NOPARITY;
@@ -2045,29 +2045,29 @@ static void test_read_write(void)
     dcb.fDtrControl = DTR_CONTROL_ENABLE;
     dcb.StopBits = ONESTOPBIT;
     ret = SetCommState(hcom, &dcb);
-    ok(ret, "SetCommState error %d\n", GetLastError());
+    ok(ret, "SetCommState error %ld\n", GetLastError());
 
     memset(&timeouts, 0, sizeof(timeouts));
     timeouts.ReadTotalTimeoutConstant = TIMEOUT;
     ret = SetCommTimeouts(hcom, &timeouts);
-    ok(ret,"SetCommTimeouts error %d\n", GetLastError());
+    ok(ret,"SetCommTimeouts error %ld\n", GetLastError());
 
     ret = SetupComm(hcom, 1024, 1024);
-    ok(ret, "SetUpComm error %d\n", GetLastError());
+    ok(ret, "SetUpComm error %ld\n", GetLastError());
 
     bytes = 0xdeadbeef;
     SetLastError(0xdeadbeef);
     ret = WriteFile(hcom, atz, 0, &bytes, NULL);
     ok(!ret, "WriteFile should fail\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
-    ok(bytes == 0, "bytes %u\n", bytes);
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
+    ok(bytes == 0, "bytes %lu\n", bytes);
 
     U(iob).Status = -1;
     iob.Information = -1;
     status = pNtWriteFile(hcom, 0, NULL, NULL, &iob, atz, 0, NULL, NULL);
-    ok(status == STATUS_INVALID_PARAMETER, "expected STATUS_INVALID_PARAMETER, got %#x\n", status);
-    ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
-    ok(iob.Information == -1, "expected -1, got %ld\n", iob.Information);
+    ok(status == STATUS_INVALID_PARAMETER, "expected STATUS_INVALID_PARAMETER, got %#lx\n", status);
+    ok(U(iob).Status == -1, "expected -1, got %#lx\n", U(iob).Status);
+    ok(iob.Information == -1, "expected -1, got %Id\n", iob.Information);
 
     for (i = -20; i < 20; i++)
     {
@@ -2077,15 +2077,15 @@ static void test_read_write(void)
         status = pNtWriteFile(hcom, 0, NULL, NULL, &iob, atz, 0, &offset, NULL);
         if (i >= 0 || i == -1)
         {
-            ok(status == STATUS_SUCCESS, "%d: expected STATUS_SUCCESS, got %#x\n", i, status);
-            ok(U(iob).Status == STATUS_SUCCESS, "%d: expected STATUS_SUCCESS, got %#x\n", i, U(iob).Status);
-            ok(iob.Information == 0, "%d: expected 0, got %lu\n", i, iob.Information);
+            ok(status == STATUS_SUCCESS, "%ld: expected STATUS_SUCCESS, got %#lx\n", i, status);
+            ok(U(iob).Status == STATUS_SUCCESS, "%ld: expected STATUS_SUCCESS, got %#lx\n", i, U(iob).Status);
+            ok(iob.Information == 0, "%ld: expected 0, got %Iu\n", i, iob.Information);
         }
         else
         {
-            ok(status == STATUS_INVALID_PARAMETER, "%d: expected STATUS_INVALID_PARAMETER, got %#x\n", i, status);
-            ok(U(iob).Status == -1, "%d: expected -1, got %#x\n", i, U(iob).Status);
-            ok(iob.Information == -1, "%d: expected -1, got %ld\n", i, iob.Information);
+            ok(status == STATUS_INVALID_PARAMETER, "%ld: expected STATUS_INVALID_PARAMETER, got %#lx\n", i, status);
+            ok(U(iob).Status == -1, "%ld: expected -1, got %#lx\n", i, U(iob).Status);
+            ok(iob.Information == -1, "%ld: expected -1, got %Id\n", i, iob.Information);
         }
     }
 
@@ -2093,7 +2093,7 @@ static void test_read_write(void)
     iob.Information = -1;
     offset.QuadPart = 0;
     status = pNtWriteFile(hcom, 0, NULL, NULL, &iob, atz, sizeof(atz), &offset, NULL);
-    ok(status == STATUS_PENDING || status == STATUS_SUCCESS, "expected STATUS_PENDING or STATUS_SUCCESS, got %#x\n", status);
+    ok(status == STATUS_PENDING || status == STATUS_SUCCESS, "expected STATUS_PENDING or STATUS_SUCCESS, got %#lx\n", status);
     /* Under Windows checking IO_STATUS_BLOCK right after the call leads
      * to races, iob.Status is either -1 or STATUS_SUCCESS, which means
      * that it's set only when the operation completes.
@@ -2105,12 +2105,12 @@ static void test_read_write(void)
         CloseHandle(hcom);
         return;
     }
-    ok(ret == WAIT_OBJECT_0, "WaitForSingleObject error %d\n", ret);
-    ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
-    ok(iob.Information == sizeof(atz), "expected sizeof(atz), got %lu\n", iob.Information);
+    ok(ret == WAIT_OBJECT_0, "WaitForSingleObject error %ld\n", ret);
+    ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", U(iob).Status);
+    ok(iob.Information == sizeof(atz), "expected sizeof(atz), got %Iu\n", iob.Information);
 
     ret = SetCommMask(hcom, EV_RXCHAR);
-    ok(ret, "SetCommMask error %d\n", GetLastError());
+    ok(ret, "SetCommMask error %ld\n", GetLastError());
 
     S(U(ovl_wait)).Offset = 0;
     S(U(ovl_wait)).OffsetHigh = 0;
@@ -2124,7 +2124,7 @@ static void test_read_write(void)
         evtmask = 0;
         SetLastError(0xdeadbeef);
         ret = WaitCommEvent(hcom, &evtmask, &ovl_wait);
-        ok(!ret && GetLastError() == ERROR_IO_PENDING, "WaitCommEvent returned %d, error %d\n", ret, GetLastError());
+        ok(!ret && GetLastError() == ERROR_IO_PENDING, "WaitCommEvent returned %ld, error %ld\n", ret, GetLastError());
         if (GetLastError() != ERROR_IO_PENDING) goto done; /* no point in further testing */
         for (;;)
         {
@@ -2136,23 +2136,23 @@ static void test_read_write(void)
 
                 last_event_time = after;
                 ret = GetOverlappedResult(hcom, &ovl_wait, &bytes, FALSE);
-                ok(ret, "GetOverlappedResult reported error %d\n", GetLastError());
-                ok(bytes == sizeof(evtmask), "expected sizeof(evtmask), got %u\n", bytes);
+                ok(ret, "GetOverlappedResult reported error %ld\n", GetLastError());
+                ok(bytes == sizeof(evtmask), "expected sizeof(evtmask), got %lu\n", bytes);
                 ok(evtmask & EV_RXCHAR, "EV_RXCHAR should be set\n");
 
                 bytes = 0xdeadbeef;
                 SetLastError(0xdeadbeef);
                 ret = ReadFile(hcom, buf, 0, &bytes, NULL);
                 ok(!ret, "ReadFile should fail\n");
-                ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
-                ok(bytes == 0, "bytes %u\n", bytes);
+                ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
+                ok(bytes == 0, "bytes %lu\n", bytes);
 
                 U(iob).Status = -1;
                 iob.Information = -1;
                 status = pNtReadFile(hcom, 0, NULL, NULL, &iob, buf, 0, NULL, NULL);
-                ok(status == STATUS_INVALID_PARAMETER, "expected STATUS_INVALID_PARAMETER, got %#x\n", status);
-                ok(U(iob).Status == -1, "expected -1, got %#x\n", U(iob).Status);
-                ok(iob.Information == -1, "expected -1, got %ld\n", iob.Information);
+                ok(status == STATUS_INVALID_PARAMETER, "expected STATUS_INVALID_PARAMETER, got %#lx\n", status);
+                ok(U(iob).Status == -1, "expected -1, got %#lx\n", U(iob).Status);
+                ok(iob.Information == -1, "expected -1, got %Id\n", iob.Information);
 
                 for (i = -20; i < 20; i++)
                 {
@@ -2162,15 +2162,15 @@ static void test_read_write(void)
                     status = pNtReadFile(hcom, 0, NULL, NULL, &iob, buf, 0, &offset, NULL);
                     if (i >= 0)
                     {
-                        ok(status == STATUS_SUCCESS, "%d: expected STATUS_SUCCESS, got %#x\n", i, status);
-                        ok(U(iob).Status == STATUS_SUCCESS, "%d: expected STATUS_SUCCESS, got %#x\n", i, U(iob).Status);
-                        ok(iob.Information == 0, "%d: expected 0, got %lu\n", i, iob.Information);
+                        ok(status == STATUS_SUCCESS, "%ld: expected STATUS_SUCCESS, got %#lx\n", i, status);
+                        ok(U(iob).Status == STATUS_SUCCESS, "%ld: expected STATUS_SUCCESS, got %#lx\n", i, U(iob).Status);
+                        ok(iob.Information == 0, "%ld: expected 0, got %Iu\n", i, iob.Information);
                     }
                     else
                     {
-                        ok(status == STATUS_INVALID_PARAMETER, "%d: expected STATUS_INVALID_PARAMETER, got %#x\n", i, status);
-                        ok(U(iob).Status == -1, "%d: expected -1, got %#x\n", i, U(iob).Status);
-                        ok(iob.Information == -1, "%d: expected -1, got %ld\n", i, iob.Information);
+                        ok(status == STATUS_INVALID_PARAMETER, "%ld: expected STATUS_INVALID_PARAMETER, got %#lx\n", i, status);
+                        ok(U(iob).Status == -1, "%ld: expected -1, got %#lx\n", i, U(iob).Status);
+                        ok(iob.Information == -1, "%ld: expected -1, got %Id\n", i, iob.Information);
                     }
                 }
 
@@ -2178,9 +2178,9 @@ static void test_read_write(void)
                 iob.Information = -1;
                 offset.QuadPart = 0;
                 status = pNtReadFile(hcom, 0, NULL, NULL, &iob, buf, 1, &offset, NULL);
-                ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", status);
-                ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
-                ok(iob.Information == 1, "expected 1, got %lu\n", iob.Information);
+                ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", status);
+                ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", U(iob).Status);
+                ok(iob.Information == 1, "expected 1, got %Iu\n", iob.Information);
                 goto done;
             }
             else
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 5f5f0698040..b31febe0d56 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -100,7 +100,7 @@ static HANDLE create_unbound_handle(BOOL output, BOOL test_status)
                            FILE_WRITE_ATTRIBUTES, &attr, &iosb, NULL, FILE_ATTRIBUTE_NORMAL,
                            FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_CREATE,
                            FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0 );
-    if (test_status) ok(!status, "NtCreateFile failed: %#x\n", status);
+    if (test_status) ok(!status, "NtCreateFile failed: %#lx\n", status);
     return status ? NULL : handle;
 }
 
@@ -135,7 +135,7 @@ static void testCursor(HANDLE hCon, COORD sbSize)
 
     c.X = c.Y = 0;
     ok(SetConsoleCursorPosition(0, c) == 0, "No handle\n");
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError: expecting %u got %u\n",
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError: expecting %u got %lu\n",
        ERROR_INVALID_HANDLE, GetLastError());
 
     c.X = c.Y = 0;
@@ -150,25 +150,25 @@ static void testCursor(HANDLE hCon, COORD sbSize)
     c.X = sbSize.X;
     c.Y = sbSize.Y - 1;
     ok(SetConsoleCursorPosition(hCon, c) == 0, "Cursor is outside\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError: expecting %u got %u\n",
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError: expecting %u got %lu\n",
        ERROR_INVALID_PARAMETER, GetLastError());
 
     c.X = sbSize.X - 1;
     c.Y = sbSize.Y;
     ok(SetConsoleCursorPosition(hCon, c) == 0, "Cursor is outside\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError: expecting %u got %u\n",
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError: expecting %u got %lu\n",
        ERROR_INVALID_PARAMETER, GetLastError());
 
     c.X = -1;
     c.Y = 0;
     ok(SetConsoleCursorPosition(hCon, c) == 0, "Cursor is outside\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError: expecting %u got %u\n",
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError: expecting %u got %lu\n",
        ERROR_INVALID_PARAMETER, GetLastError());
 
     c.X = 0;
     c.Y = -1;
     ok(SetConsoleCursorPosition(hCon, c) == 0, "Cursor is outside\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError: expecting %u got %u\n",
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError: expecting %u got %lu\n",
        ERROR_INVALID_PARAMETER, GetLastError());
 }
 
@@ -181,7 +181,7 @@ static void testCursorInfo(HANDLE hCon)
     SetLastError(0xdeadbeef);
     ret = GetConsoleCursorInfo(NULL, NULL);
     ok(!ret, "Expected failure\n");
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError: expecting %u got %u\n",
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError: expecting %u got %lu\n",
        ERROR_INVALID_HANDLE, GetLastError());
 
     SetLastError(0xdeadbeef);
@@ -189,7 +189,7 @@ static void testCursorInfo(HANDLE hCon)
     ret = GetConsoleCursorInfo(NULL, &info);
     ok(!ret, "Expected failure\n");
     ok(info.dwSize == -1, "Expected no change for dwSize\n");
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError: expecting %u got %u\n",
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError: expecting %u got %lu\n",
        ERROR_INVALID_HANDLE, GetLastError());
 
     /* Test the correct call first to distinguish between win9x and the rest */
@@ -198,9 +198,9 @@ static void testCursorInfo(HANDLE hCon)
     ok(ret, "Expected success\n");
     ok(info.dwSize == 25 ||
        info.dwSize == 12 /* win9x */,
-       "Expected 12 or 25, got %d\n", info.dwSize);
+       "Expected 12 or 25, got %ld\n", info.dwSize);
     ok(info.bVisible, "Expected the cursor to be visible\n");
-    ok(GetLastError() == 0xdeadbeef, "GetLastError: expecting %u got %u\n",
+    ok(GetLastError() == 0xdeadbeef, "GetLastError: expecting %u got %lu\n",
        0xdeadbeef, GetLastError());
 
     CreatePipe(&pipe1, &pipe2, NULL, 0);
@@ -208,7 +208,7 @@ static void testCursorInfo(HANDLE hCon)
     ret = GetConsoleCursorInfo(pipe1, &info);
     ok(!ret, "Expected failure\n");
     ok(info.dwSize == -1, "Expected no change for dwSize\n");
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError: %u\n",  GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError: %lu\n",  GetLastError());
     CloseHandle(pipe1);
     CloseHandle(pipe2);
 
@@ -265,8 +265,8 @@ static void simple_write_console(HANDLE console, const char *text)
     ok(SetConsoleCursorPosition(console, c) != 0, "Cursor in upper-left\n");
 
     ret = WriteConsoleA(console, text, strlen(text), &len, NULL);
-    ok(ret, "WriteConsoleA failed: %u\n", GetLastError());
-    ok(len == strlen(text), "unexpected len %u\n", len);
+    ok(ret, "WriteConsoleA failed: %lu\n", GetLastError());
+    ok(len == strlen(text), "unexpected len %lu\n", len);
 }
 
 static void testWriteSimple(HANDLE hCon)
@@ -288,8 +288,8 @@ static void testWriteSimple(HANDLE hCon)
     okCHAR(hCon, c, ' ', DEFAULT_ATTRIB);
 
     ret = WriteFile(hCon, mytest, mylen, &len, NULL);
-    ok(ret, "WriteFile failed: %u\n", GetLastError());
-    ok(len == mylen, "unexpected len = %u\n", len);
+    ok(ret, "WriteFile failed: %lu\n", GetLastError());
+    ok(len == mylen, "unexpected len = %lu\n", len);
 
     for (c.X = 0; c.X < 2 * mylen; c.X++)
     {
@@ -317,7 +317,7 @@ static void testWriteNotWrappedNotProcessed(HANDLE hCon, COORD sbSize)
     ok(SetConsoleCursorPosition(hCon, c) != 0, "Cursor in upper-left-3\n");
 
     ret = WriteConsoleA(hCon, mytest, mylen, &len, NULL);
-    ok(ret != 0 && len == mylen, "Couldn't write, ret = %d, len = %d\n", ret, len);
+    ok(ret != 0 && len == mylen, "Couldn't write, ret = %d, len = %ld\n", ret, len);
     c.Y = 0;
     for (p = mylen - 3; p < mylen; p++)
     {
@@ -668,7 +668,7 @@ static void testScroll(HANDLE hCon, COORD sbSize)
     {
         /* Win9x will fail, Only accept ERROR_NOT_ENOUGH_MEMORY */
         ok(GetLastError() == ERROR_NOT_ENOUGH_MEMORY,
-            "Expected ERROR_NOT_ENOUGH_MEMORY, got %u\n", GetLastError());
+            "Expected ERROR_NOT_ENOUGH_MEMORY, got %lu\n", GetLastError());
     }
 
     /* clipping, src & dst rect do overlap */
@@ -689,7 +689,7 @@ static void testScroll(HANDLE hCon, COORD sbSize)
     clip.Bottom = min(H + H / 2, sbSize.Y - 1);
 
     ret = ScrollConsoleScreenBufferA(hCon, &scroll, &clip, dst, &ci);
-    ok(ret, "ScrollConsoleScreenBufferA failed: %u\n", GetLastError());
+    ok(ret, "ScrollConsoleScreenBufferA failed: %lu\n", GetLastError());
 
     for (c.Y = 0; c.Y < sbSize.Y; c.Y++)
     {
@@ -724,7 +724,7 @@ static BOOL WINAPI mch(DWORD event)
 static void testCtrlHandler(void)
 {
     ok(!SetConsoleCtrlHandler(mch, FALSE), "Shouldn't succeed\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Bad error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Bad error %lu\n", GetLastError());
     ok(SetConsoleCtrlHandler(mch, TRUE), "Couldn't set handler\n");
     /* wine requires the event for the test, as we cannot ensure, so far, that
      * events are processed synchronously in GenerateConsoleCtrlEvent()
@@ -748,7 +748,7 @@ static void testCtrlHandler(void)
     CloseHandle(mch_event);
     ok(SetConsoleCtrlHandler(mch, FALSE), "Couldn't remove handler\n");
     ok(!SetConsoleCtrlHandler(mch, FALSE), "Shouldn't succeed\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Bad error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Bad error %lu\n", GetLastError());
 }
 
 /*
@@ -830,26 +830,26 @@ static void testScreenBuffer(HANDLE hConOut)
     ok(!SetConsoleActiveScreenBuffer(INVALID_HANDLE_VALUE),
        "Shouldn't succeed\n");
     ok(GetLastError() == ERROR_INVALID_HANDLE,
-       "GetLastError: expecting %u got %u\n",
+       "GetLastError: expecting %u got %lu\n",
        ERROR_INVALID_HANDLE, GetLastError());
 
     /* Trying to set non-console handles */
     SetLastError(0);
     ok(!SetConsoleActiveScreenBuffer(hFileOutRW), "Shouldn't succeed\n");
     ok(GetLastError() == ERROR_INVALID_HANDLE,
-       "GetLastError: expecting %u got %u\n",
+       "GetLastError: expecting %u got %lu\n",
        ERROR_INVALID_HANDLE, GetLastError());
 
     SetLastError(0);
     ok(!SetConsoleActiveScreenBuffer(hFileOutRO), "Shouldn't succeed\n");
     ok(GetLastError() == ERROR_INVALID_HANDLE,
-       "GetLastError: expecting %u got %u\n",
+       "GetLastError: expecting %u got %lu\n",
        ERROR_INVALID_HANDLE, GetLastError());
 
     SetLastError(0);
     ok(!SetConsoleActiveScreenBuffer(hFileOutWT), "Shouldn't succeed\n");
     ok(GetLastError() == ERROR_INVALID_HANDLE,
-       "GetLastError: expecting %u got %u\n",
+       "GetLastError: expecting %u got %lu\n",
        ERROR_INVALID_HANDLE, GetLastError());
 
     /* trying to write non-console handle */
@@ -858,21 +858,21 @@ static void testScreenBuffer(HANDLE hConOut)
     error = GetLastError();
     ok(!ret, "Shouldn't succeed\n");
     ok(error == ERROR_INVALID_HANDLE || error == ERROR_INVALID_FUNCTION,
-       "GetLastError: got %u\n", error);
+       "GetLastError: got %lu\n", error);
 
     SetLastError(0xdeadbeef);
     ret = WriteConsoleA(hFileOutRO, test_str1, lstrlenA(test_str1), &len, NULL);
     error = GetLastError();
     ok(!ret, "Shouldn't succeed\n");
     ok(error == ERROR_INVALID_HANDLE || error == ERROR_INVALID_FUNCTION,
-       "GetLastError: got %u\n", error);
+       "GetLastError: got %lu\n", error);
 
     SetLastError(0xdeadbeef);
     ret = WriteConsoleA(hFileOutWT, test_str1, lstrlenA(test_str1), &len, NULL);
     error = GetLastError();
     ok(!ret, "Shouldn't succeed\n");
     ok(error == ERROR_INVALID_HANDLE || error == ERROR_INVALID_FUNCTION,
-       "GetLastError: got %u\n", error);
+       "GetLastError: got %lu\n", error);
 
     CloseHandle(hFileOutRW);
     CloseHandle(hFileOutRO);
@@ -882,7 +882,7 @@ static void testScreenBuffer(HANDLE hConOut)
     SetLastError(0);
     ok(!SetConsoleActiveScreenBuffer(hConOutRO), "Shouldn't succeed\n");
     ok(GetLastError() == ERROR_INVALID_HANDLE || broken(GetLastError() == ERROR_ACCESS_DENIED) /* win10 1809 */,
-       "unexpected last error %u\n", GetLastError());
+       "unexpected last error %lu\n", GetLastError());
 
     ok(SetConsoleActiveScreenBuffer(hConOutWT), "Couldn't set new WriteOnly SB\n");
 
@@ -990,18 +990,18 @@ static void test_new_screen_buffer_properties(HANDLE hConOut)
     cfi.cbSize = cfi2.cbSize = sizeof(CONSOLE_FONT_INFOEX);
 
     ret = GetCurrentConsoleFontEx(hConOut, FALSE, &cfi);
-    ok(ret, "GetCurrentConsoleFontEx failed: error %u\n", GetLastError());
+    ok(ret, "GetCurrentConsoleFontEx failed: error %lu\n", GetLastError());
 
     hConOut2 = CreateConsoleScreenBuffer(GENERIC_READ|GENERIC_WRITE, 0, NULL,
                                          CONSOLE_TEXTMODE_BUFFER, NULL);
-    ok(hConOut2 != INVALID_HANDLE_VALUE, "CreateConsoleScreenBuffer failed: error %u\n", GetLastError());
+    ok(hConOut2 != INVALID_HANDLE_VALUE, "CreateConsoleScreenBuffer failed: error %lu\n", GetLastError());
 
     ret = GetCurrentConsoleFontEx(hConOut2, FALSE, &cfi2);
-    ok(ret, "GetCurrentConsoleFontEx failed: error %u\n", GetLastError());
+    ok(ret, "GetCurrentConsoleFontEx failed: error %lu\n", GetLastError());
     CloseHandle(hConOut2);
 
     ok(cfi2.nFont == cfi.nFont, "Font index should match: "
-       "got %u, expected %u\n", cfi2.nFont, cfi.nFont);
+       "got %lu, expected %lu\n", cfi2.nFont, cfi.nFont);
     ok(cfi2.dwFontSize.X == cfi.dwFontSize.X, "Font width should match: "
       "got %d, expected %d\n", cfi2.dwFontSize.X, cfi.dwFontSize.X);
     ok(cfi2.dwFontSize.Y == cfi.dwFontSize.Y, "Font height should match: "
@@ -1015,14 +1015,14 @@ static void test_new_screen_buffer_properties(HANDLE hConOut)
 
     /* Display window size */
     ret = GetConsoleScreenBufferInfo(hConOut, &csbi);
-    ok(ret, "GetConsoleScreenBufferInfo failed: error %u\n", GetLastError());
+    ok(ret, "GetConsoleScreenBufferInfo failed: error %lu\n", GetLastError());
 
     hConOut2 = CreateConsoleScreenBuffer(GENERIC_READ|GENERIC_WRITE, 0, NULL,
                                          CONSOLE_TEXTMODE_BUFFER, NULL);
-    ok(hConOut2 != INVALID_HANDLE_VALUE, "CreateConsoleScreenBuffer failed: error %u\n", GetLastError());
+    ok(hConOut2 != INVALID_HANDLE_VALUE, "CreateConsoleScreenBuffer failed: error %lu\n", GetLastError());
 
     ret = GetConsoleScreenBufferInfo(hConOut2, &csbi2);
-    ok(ret, "GetConsoleScreenBufferInfo failed: error %u\n", GetLastError());
+    ok(ret, "GetConsoleScreenBufferInfo failed: error %lu\n", GetLastError());
     CloseHandle(hConOut2);
 
     ok(csbi2.srWindow.Left == csbi.srWindow.Left, "Left coordinate should match\n");
@@ -1041,16 +1041,16 @@ static void test_new_screen_buffer_color_attributes(HANDLE hConOut)
     csbi.cbSize = csbi2.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);
 
     ret = GetConsoleScreenBufferInfoEx(hConOut, &csbi);
-    ok(ret, "GetConsoleScreenBufferInfoEx failed: error %u\n", GetLastError());
+    ok(ret, "GetConsoleScreenBufferInfoEx failed: error %lu\n", GetLastError());
     orig_attr = csbi.wAttributes;
     orig_popup = csbi.wPopupAttributes;
 
     hConOut2 = CreateConsoleScreenBuffer(GENERIC_READ|GENERIC_WRITE, 0, NULL,
                                          CONSOLE_TEXTMODE_BUFFER, NULL);
-    ok(hConOut2 != INVALID_HANDLE_VALUE, "CreateConsoleScreenBuffer failed: error %u\n", GetLastError());
+    ok(hConOut2 != INVALID_HANDLE_VALUE, "CreateConsoleScreenBuffer failed: error %lu\n", GetLastError());
 
     ret = GetConsoleScreenBufferInfoEx(hConOut2, &csbi2);
-    ok(ret, "GetConsoleScreenBufferInfoEx failed: error %u\n", GetLastError());
+    ok(ret, "GetConsoleScreenBufferInfoEx failed: error %lu\n", GetLastError());
     CloseHandle(hConOut2);
 
     ok(csbi2.wAttributes == orig_attr, "Character Attributes should have been copied: "
@@ -1061,17 +1061,17 @@ static void test_new_screen_buffer_color_attributes(HANDLE hConOut)
     /* Test different Character Attributes */
     attr = FOREGROUND_BLUE|BACKGROUND_GREEN;
     ret = SetConsoleTextAttribute(hConOut, attr);
-    ok(ret, "SetConsoleTextAttribute failed: error %u\n", GetLastError());
+    ok(ret, "SetConsoleTextAttribute failed: error %lu\n", GetLastError());
 
     hConOut2 = CreateConsoleScreenBuffer(GENERIC_READ|GENERIC_WRITE, 0, NULL,
                                          CONSOLE_TEXTMODE_BUFFER, NULL);
-    ok(hConOut2 != INVALID_HANDLE_VALUE, "CreateConsoleScreenBuffer failed: error %u\n", GetLastError());
+    ok(hConOut2 != INVALID_HANDLE_VALUE, "CreateConsoleScreenBuffer failed: error %lu\n", GetLastError());
 
     memset(&csbi2, 0, sizeof(CONSOLE_SCREEN_BUFFER_INFOEX));
     csbi2.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);
 
     ret = GetConsoleScreenBufferInfoEx(hConOut2, &csbi2);
-    ok(ret, "GetConsoleScreenBufferInfoEx failed: error %u\n", GetLastError());
+    ok(ret, "GetConsoleScreenBufferInfoEx failed: error %lu\n", GetLastError());
     CloseHandle(hConOut2);
 
     ok(csbi2.wAttributes == attr, "Character Attributes should have been copied: "
@@ -1080,22 +1080,22 @@ static void test_new_screen_buffer_color_attributes(HANDLE hConOut)
     ok(csbi2.wPopupAttributes == attr, "Popup Attributes should match Character Attributes\n");
 
     ret = SetConsoleTextAttribute(hConOut, orig_attr);
-    ok(ret, "SetConsoleTextAttribute failed: error %u\n", GetLastError());
+    ok(ret, "SetConsoleTextAttribute failed: error %lu\n", GetLastError());
 
     /* Test inheritance of different Popup Attributes */
     csbi.wPopupAttributes = attr;
     ret = SetConsoleScreenBufferInfoEx(hConOut, &csbi);
-    ok(ret, "SetConsoleScreenBufferInfoEx failed: error %u\n", GetLastError());
+    ok(ret, "SetConsoleScreenBufferInfoEx failed: error %lu\n", GetLastError());
 
     hConOut2 = CreateConsoleScreenBuffer(GENERIC_READ|GENERIC_WRITE, 0, NULL,
                                          CONSOLE_TEXTMODE_BUFFER, NULL);
-    ok(hConOut2 != INVALID_HANDLE_VALUE, "CreateConsoleScreenBuffer failed: error %u\n", GetLastError());
+    ok(hConOut2 != INVALID_HANDLE_VALUE, "CreateConsoleScreenBuffer failed: error %lu\n", GetLastError());
 
     memset(&csbi2, 0, sizeof(CONSOLE_SCREEN_BUFFER_INFOEX));
     csbi2.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);
 
     ret = GetConsoleScreenBufferInfoEx(hConOut2, &csbi2);
-    ok(ret, "GetConsoleScreenBufferInfoEx failed: error %u\n", GetLastError());
+    ok(ret, "GetConsoleScreenBufferInfoEx failed: error %lu\n", GetLastError());
     CloseHandle(hConOut2);
 
     ok(csbi2.wAttributes == orig_attr, "Character Attributes should have been copied: "
@@ -1105,7 +1105,7 @@ static void test_new_screen_buffer_color_attributes(HANDLE hConOut)
 
     csbi.wPopupAttributes = orig_popup;
     ret = SetConsoleScreenBufferInfoEx(hConOut, &csbi);
-    ok(ret, "SetConsoleScreenBufferInfoEx failed: error %u\n", GetLastError());
+    ok(ret, "SetConsoleScreenBufferInfoEx failed: error %lu\n", GetLastError());
 }
 
 static void CALLBACK signaled_function(void *p, BOOLEAN timeout)
@@ -1146,7 +1146,7 @@ static void testWaitForConsoleInput(HANDLE input_handle)
     /* If the callback is still running, this fails with ERROR_IO_PENDING, but
        that's ok and expected. */
     ok(ret != 0 || GetLastError() == ERROR_IO_PENDING,
-        "UnregisterWait failed with error %d\n", GetLastError());
+        "UnregisterWait failed with error %ld\n", GetLastError());
 
     /* Test timeout case */
     FlushConsoleInputBuffer(input_handle);
@@ -1154,7 +1154,7 @@ static void testWaitForConsoleInput(HANDLE input_handle)
     wait_ret = WaitForSingleObject(complete_event, 100);
     ok(wait_ret == WAIT_TIMEOUT, "Expected the wait to time out\n");
     ret = UnregisterWait(wait_handle);
-    ok(ret, "UnregisterWait failed with error %d\n", GetLastError());
+    ok(ret, "UnregisterWait failed with error %ld\n", GetLastError());
 
     /* Clean up */
     CloseHandle(complete_event);
@@ -1179,54 +1179,54 @@ static void test_wait(HANDLE input, HANDLE orig_output)
     output = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE,
                                        FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
                                        CONSOLE_TEXTMODE_BUFFER, NULL);
-    ok(output != INVALID_HANDLE_VALUE, "CreateConsoleScreenBuffer failed: %u\n", GetLastError());
+    ok(output != INVALID_HANDLE_VALUE, "CreateConsoleScreenBuffer failed: %lu\n", GetLastError());
 
     ret = SetConsoleActiveScreenBuffer(output);
-    ok(ret, "SetConsoleActiveScreenBuffer failed: %u\n", GetLastError());
+    ok(ret, "SetConsoleActiveScreenBuffer failed: %lu\n", GetLastError());
     FlushConsoleInputBuffer(input);
 
     unbound_output = create_unbound_handle(TRUE, TRUE);
     unbound_input = create_unbound_handle(FALSE, TRUE);
 
     res = WaitForSingleObject(input, 0);
-    ok(res == WAIT_TIMEOUT, "WaitForSingleObject returned %x\n", res);
+    ok(res == WAIT_TIMEOUT, "WaitForSingleObject returned %lx\n", res);
     res = WaitForSingleObject(output, 0);
-    ok(res == WAIT_TIMEOUT, "WaitForSingleObject returned %x\n", res);
+    ok(res == WAIT_TIMEOUT, "WaitForSingleObject returned %lx\n", res);
     res = WaitForSingleObject(orig_output, 0);
-    ok(res == WAIT_TIMEOUT, "WaitForSingleObject returned %x\n", res);
+    ok(res == WAIT_TIMEOUT, "WaitForSingleObject returned %lx\n", res);
     res = WaitForSingleObject(unbound_output, 0);
-    ok(res == WAIT_TIMEOUT, "WaitForSingleObject returned %x\n", res);
+    ok(res == WAIT_TIMEOUT, "WaitForSingleObject returned %lx\n", res);
     res = WaitForSingleObject(unbound_input, 0);
-    ok(res == WAIT_TIMEOUT, "WaitForSingleObject returned %x\n", res);
+    ok(res == WAIT_TIMEOUT, "WaitForSingleObject returned %lx\n", res);
     status = NtWaitForSingleObject(input, FALSE, &zero);
     ok(status == STATUS_TIMEOUT || broken(status == STATUS_ACCESS_DENIED /* win2k8 */),
-       "NtWaitForSingleObject returned %x\n", status);
+       "NtWaitForSingleObject returned %lx\n", status);
     status = NtWaitForSingleObject(output, FALSE, &zero);
     ok(status == STATUS_TIMEOUT || broken(status == STATUS_ACCESS_DENIED /* win2k8 */),
-       "NtWaitForSingleObject returned %x\n", status);
+       "NtWaitForSingleObject returned %lx\n", status);
 
     ret = WriteConsoleInputW(input, &ir, 1, &count);
-    ok(ret, "WriteConsoleInputW failed: %u\n", GetLastError());
+    ok(ret, "WriteConsoleInputW failed: %lu\n", GetLastError());
 
     res = WaitForSingleObject(input, 0);
-    ok(!res, "WaitForSingleObject returned %x\n", res);
+    ok(!res, "WaitForSingleObject returned %lx\n", res);
     res = WaitForSingleObject(output, 0);
-    ok(!res, "WaitForSingleObject returned %x\n", res);
+    ok(!res, "WaitForSingleObject returned %lx\n", res);
     res = WaitForSingleObject(orig_output, 0);
-    ok(!res, "WaitForSingleObject returned %x\n", res);
+    ok(!res, "WaitForSingleObject returned %lx\n", res);
     res = WaitForSingleObject(unbound_output, 0);
-    ok(!res, "WaitForSingleObject returned %x\n", res);
+    ok(!res, "WaitForSingleObject returned %lx\n", res);
     res = WaitForSingleObject(unbound_input, 0);
-    ok(!res, "WaitForSingleObject returned %x\n", res);
+    ok(!res, "WaitForSingleObject returned %lx\n", res);
     status = NtWaitForSingleObject(input, FALSE, &zero);
     ok(!status || broken(status == STATUS_ACCESS_DENIED /* win2k8 */),
-       "NtWaitForSingleObject returned %x\n", status);
+       "NtWaitForSingleObject returned %lx\n", status);
     status = NtWaitForSingleObject(output, FALSE, &zero);
     ok(!status || broken(status == STATUS_ACCESS_DENIED /* win2k8 */),
-       "NtWaitForSingleObject returned %x\n", status);
+       "NtWaitForSingleObject returned %lx\n", status);
 
     ret = SetConsoleActiveScreenBuffer(orig_output);
-    ok(ret, "SetConsoleActiveScreenBuffer failed: %u\n", GetLastError());
+    ok(ret, "SetConsoleActiveScreenBuffer failed: %lu\n", GetLastError());
 
     CloseHandle(unbound_input);
     CloseHandle(unbound_output);
@@ -1244,13 +1244,13 @@ static void test_GetSetConsoleInputExeName(void)
     ret = pGetConsoleInputExeNameA(0, NULL);
     error = GetLastError();
     ok(ret, "GetConsoleInputExeNameA failed\n");
-    ok(error == ERROR_BUFFER_OVERFLOW, "got %u expected ERROR_BUFFER_OVERFLOW\n", error);
+    ok(error == ERROR_BUFFER_OVERFLOW, "got %lu expected ERROR_BUFFER_OVERFLOW\n", error);
 
     SetLastError(0xdeadbeef);
     ret = pGetConsoleInputExeNameA(0, buffer);
     error = GetLastError();
     ok(ret, "GetConsoleInputExeNameA failed\n");
-    ok(error == ERROR_BUFFER_OVERFLOW, "got %u expected ERROR_BUFFER_OVERFLOW\n", error);
+    ok(error == ERROR_BUFFER_OVERFLOW, "got %lu expected ERROR_BUFFER_OVERFLOW\n", error);
 
     GetModuleFileNameA(GetModuleHandleA(NULL), module, sizeof(module));
     p = strrchr(module, '\\') + 1;
@@ -1263,13 +1263,13 @@ static void test_GetSetConsoleInputExeName(void)
     ret = pSetConsoleInputExeNameA(NULL);
     error = GetLastError();
     ok(!ret, "SetConsoleInputExeNameA failed\n");
-    ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
+    ok(error == ERROR_INVALID_PARAMETER, "got %lu expected ERROR_INVALID_PARAMETER\n", error);
 
     SetLastError(0xdeadbeef);
     ret = pSetConsoleInputExeNameA("");
     error = GetLastError();
     ok(!ret, "SetConsoleInputExeNameA failed\n");
-    ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
+    ok(error == ERROR_INVALID_PARAMETER, "got %lu expected ERROR_INVALID_PARAMETER\n", error);
 
     ret = pSetConsoleInputExeNameA(input_exe);
     ok(ret, "SetConsoleInputExeNameA failed\n");
@@ -1293,14 +1293,14 @@ static void test_GetConsoleProcessList(void)
     ret = pGetConsoleProcessList(NULL, 0);
     ok(ret == 0, "Expected failure\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "Expected ERROR_INVALID_PARAMETER, got %d\n",
+       "Expected ERROR_INVALID_PARAMETER, got %ld\n",
        GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetConsoleProcessList(NULL, 1);
     ok(ret == 0, "Expected failure\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "Expected ERROR_INVALID_PARAMETER, got %d\n",
+       "Expected ERROR_INVALID_PARAMETER, got %ld\n",
        GetLastError());
 
     /* We should only have 1 process but only for these specific unit tests as
@@ -1313,12 +1313,12 @@ static void test_GetConsoleProcessList(void)
     ret = pGetConsoleProcessList(list, 0);
     ok(ret == 0, "Expected failure\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "Expected ERROR_INVALID_PARAMETER, got %d\n",
+       "Expected ERROR_INVALID_PARAMETER, got %ld\n",
        GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetConsoleProcessList(list, 1);
-    ok(ret == 1, "Expected 1, got %d\n", ret);
+    ok(ret == 1, "Expected 1, got %ld\n", ret);
 
     HeapFree(GetProcessHeap(), 0, list);
 
@@ -1326,12 +1326,12 @@ static void test_GetConsoleProcessList(void)
 
     SetLastError(0xdeadbeef);
     ret = pGetConsoleProcessList(list, ret);
-    ok(ret == 1, "Expected 1, got %d\n", ret);
+    ok(ret == 1, "Expected 1, got %ld\n", ret);
 
     if (ret == 1)
     {
         DWORD pid = GetCurrentProcessId();
-        ok(list[0] == pid, "Expected %d, got %d\n", pid, list[0]);
+        ok(list[0] == pid, "Expected %ld, got %ld\n", pid, list[0]);
     }
 
     HeapFree(GetProcessHeap(), 0, list);
@@ -1349,7 +1349,7 @@ static void test_OpenCON(void)
     {
         h = CreateFileW(conW, GENERIC_WRITE, 0, NULL, accesses[i], 0, NULL);
         ok(h != INVALID_HANDLE_VALUE || broken(accesses[i] == TRUNCATE_EXISTING /* Win8 */),
-           "Expected to open the CON device on write (%x)\n", accesses[i]);
+           "Expected to open the CON device on write (%lx)\n", accesses[i]);
         CloseHandle(h);
 
         h = CreateFileW(conW, GENERIC_READ, 0, NULL, accesses[i], 0, NULL);
@@ -1359,12 +1359,12 @@ static void test_OpenCON(void)
          * So don't test when disposition is TRUNCATE_EXISTING
          */
         ok(h != INVALID_HANDLE_VALUE || broken(accesses[i] == TRUNCATE_EXISTING /* Win7+ */),
-           "Expected to open the CON device on read (%x)\n", accesses[i]);
+           "Expected to open the CON device on read (%lx)\n", accesses[i]);
         CloseHandle(h);
         h = CreateFileW(conW, GENERIC_READ|GENERIC_WRITE, 0, NULL, accesses[i], 0, NULL);
-        ok(h == INVALID_HANDLE_VALUE, "Expected not to open the CON device on read-write (%x)\n", accesses[i]);
+        ok(h == INVALID_HANDLE_VALUE, "Expected not to open the CON device on read-write (%lx)\n", accesses[i]);
         ok(GetLastError() == ERROR_FILE_NOT_FOUND || GetLastError() == ERROR_INVALID_PARAMETER,
-           "Unexpected error %x\n", GetLastError());
+           "Unexpected error %lx\n", GetLastError());
     }
 }
 
@@ -1460,7 +1460,7 @@ static void test_OpenConsoleW(void)
            "Expected OpenConsoleW to return INVALID_HANDLE_VALUE for index %d, got %p\n",
            index, ret);
         ok(gle == invalid_table[index].gle || (gle != 0 && gle == invalid_table[index].gle2),
-           "Expected GetLastError() to return %u/%u for index %d, got %u\n",
+           "Expected GetLastError() to return %lu/%lu for index %d, got %lu\n",
            invalid_table[index].gle, invalid_table[index].gle2, index, gle);
     }
 
@@ -1545,7 +1545,7 @@ static void test_CreateFileW(void)
             ok(cf_table[index].gle,
                "Expected CreateFileW not to return INVALID_HANDLE_VALUE for index %d\n", index);
             ok(GetLastError() == cf_table[index].gle,
-                "Expected GetLastError() to return %u for index %d, got %u\n",
+                "Expected GetLastError() to return %lu for index %d, got %lu\n",
                 cf_table[index].gle, index, GetLastError());
         }
         else
@@ -1568,10 +1568,10 @@ static void test_CreateFileW(void)
                           cf_table[index].creation, FILE_ATTRIBUTE_NORMAL, NULL);
         if (cf_table[index].gle)
             ok(ret == INVALID_HANDLE_VALUE && GetLastError() == cf_table[index].gle,
-               "CreateFileW to returned %p %u for index %d\n", ret, GetLastError(), index);
+               "CreateFileW to returned %p %lu for index %d\n", ret, GetLastError(), index);
         else
             ok(ret != INVALID_HANDLE_VALUE && (!cf_table[index].gle || broken(cf_table[index].is_broken) /* Win7 */),
-               "CreateFileW to returned %p %u for index %d\n", ret, GetLastError(), index);
+               "CreateFileW to returned %p %lu for index %d\n", ret, GetLastError(), index);
         if (ret != INVALID_HANDLE_VALUE) CloseHandle(ret);
 
         if (cf_table[index].gle) continue;
@@ -1582,7 +1582,7 @@ static void test_CreateFileW(void)
         status = NtCreateFile(&ret, cf_table[index].access | SYNCHRONIZE | FILE_READ_ATTRIBUTES, &attr, &iosb, NULL,
                               FILE_ATTRIBUTE_NORMAL, 0, nt_disposition[cf_table[index].creation - CREATE_NEW],
                               FILE_NON_DIRECTORY_FILE, NULL, 0);
-        ok(!status, "NtCreateFile failed %x for %u\n", status, index);
+        ok(!status, "NtCreateFile failed %lx for %u\n", status, index);
         CloseHandle(ret);
 
         RtlInitUnicodeString(&string, cf_table[index].input ? L"\\??\\CONIN$" : L"\\??\\CONOUT$");
@@ -1590,7 +1590,7 @@ static void test_CreateFileW(void)
         status = NtCreateFile(&ret, cf_table[index].access | SYNCHRONIZE | FILE_READ_ATTRIBUTES, &attr, &iosb, NULL,
                               FILE_ATTRIBUTE_NORMAL, 0, nt_disposition[cf_table[index].creation - CREATE_NEW],
                               FILE_NON_DIRECTORY_FILE, NULL, 0);
-        ok(!status, "NtCreateFile failed %x for %u\n", status, index);
+        ok(!status, "NtCreateFile failed %lx for %u\n", status, index);
         CloseHandle(ret);
     }
 }
@@ -1611,28 +1611,28 @@ static void test_VerifyConsoleIoHandle( HANDLE handle )
     ret = pVerifyConsoleIoHandle((HANDLE)0xdeadbee0);
     error = GetLastError();
     ok(!ret, "expected VerifyConsoleIoHandle to fail\n");
-    ok(error == 0xdeadbeef, "wrong GetLastError() %d\n", error);
+    ok(error == 0xdeadbeef, "wrong GetLastError() %ld\n", error);
 
     /* invalid handle + 1 */
     SetLastError(0xdeadbeef);
     ret = pVerifyConsoleIoHandle((HANDLE)0xdeadbee1);
     error = GetLastError();
     ok(!ret, "expected VerifyConsoleIoHandle to fail\n");
-    ok(error == 0xdeadbeef, "wrong GetLastError() %d\n", error);
+    ok(error == 0xdeadbeef, "wrong GetLastError() %ld\n", error);
 
     /* invalid handle + 2 */
     SetLastError(0xdeadbeef);
     ret = pVerifyConsoleIoHandle((HANDLE)0xdeadbee2);
     error = GetLastError();
     ok(!ret, "expected VerifyConsoleIoHandle to fail\n");
-    ok(error == 0xdeadbeef, "wrong GetLastError() %d\n", error);
+    ok(error == 0xdeadbeef, "wrong GetLastError() %ld\n", error);
 
     /* invalid handle + 3 */
     SetLastError(0xdeadbeef);
     ret = pVerifyConsoleIoHandle((HANDLE)0xdeadbee3);
     error = GetLastError();
     ok(!ret, "expected VerifyConsoleIoHandle to fail\n");
-    ok(error == 0xdeadbeef, "wrong GetLastError() %d\n", error);
+    ok(error == 0xdeadbeef, "wrong GetLastError() %ld\n", error);
 
     /* valid handle */
     SetLastError(0xdeadbeef);
@@ -1641,7 +1641,7 @@ static void test_VerifyConsoleIoHandle( HANDLE handle )
     ok(ret ||
        broken(!ret), /* Windows 8 and 10 */
        "expected VerifyConsoleIoHandle to succeed\n");
-    ok(error == 0xdeadbeef, "wrong GetLastError() %d\n", error);
+    ok(error == 0xdeadbeef, "wrong GetLastError() %ld\n", error);
 }
 
 static void test_GetSetStdHandle(void)
@@ -1655,14 +1655,14 @@ static void test_GetSetStdHandle(void)
     handle = GetStdHandle(42);
     error = GetLastError();
     ok(error == ERROR_INVALID_HANDLE || broken(error == ERROR_INVALID_FUNCTION)/* Win9x */,
-       "wrong GetLastError() %d\n", error);
+       "wrong GetLastError() %ld\n", error);
     ok(handle == INVALID_HANDLE_VALUE, "expected INVALID_HANDLE_VALUE\n");
 
     /* get valid */
     SetLastError(0xdeadbeef);
     handle = GetStdHandle(STD_INPUT_HANDLE);
     error = GetLastError();
-    ok(error == 0xdeadbeef, "wrong GetLastError() %d\n", error);
+    ok(error == 0xdeadbeef, "wrong GetLastError() %ld\n", error);
 
     /* set invalid std handle */
     SetLastError(0xdeadbeef);
@@ -1670,14 +1670,14 @@ static void test_GetSetStdHandle(void)
     error = GetLastError();
     ok(!ret, "expected SetStdHandle to fail\n");
     ok(error == ERROR_INVALID_HANDLE || broken(error == ERROR_INVALID_FUNCTION)/* Win9x */,
-       "wrong GetLastError() %d\n", error);
+       "wrong GetLastError() %ld\n", error);
 
     /* set valid (restore old value) */
     SetLastError(0xdeadbeef);
     ret = SetStdHandle(STD_INPUT_HANDLE, handle);
     error = GetLastError();
     ok(ret, "expected SetStdHandle to succeed\n");
-    ok(error == 0xdeadbeef, "wrong GetLastError() %d\n", error);
+    ok(error == 0xdeadbeef, "wrong GetLastError() %ld\n", error);
 }
 
 static void test_DuplicateConsoleHandle(void)
@@ -1691,19 +1691,19 @@ static void test_DuplicateConsoleHandle(void)
 
     /* duplicate an event handle with DuplicateConsoleHandle */
     handle = DuplicateConsoleHandle(event, 0, FALSE, DUPLICATE_SAME_ACCESS);
-    ok(handle != NULL, "DuplicateConsoleHandle failed: %u\n", GetLastError());
+    ok(handle != NULL, "DuplicateConsoleHandle failed: %lu\n", GetLastError());
 
     ret = SetEvent(handle);
-    ok(ret, "SetEvent failed: %u\n", GetLastError());
+    ok(ret, "SetEvent failed: %lu\n", GetLastError());
 
     ret = CloseConsoleHandle(handle);
-    ok(ret, "CloseConsoleHandle failed: %u\n", GetLastError());
+    ok(ret, "CloseConsoleHandle failed: %lu\n", GetLastError());
     ret = CloseConsoleHandle(event);
-    ok(ret, "CloseConsoleHandle failed: %u\n", GetLastError());
+    ok(ret, "CloseConsoleHandle failed: %lu\n", GetLastError());
 
     handle = DuplicateConsoleHandle((HANDLE)0xdeadbeef, 0, FALSE, DUPLICATE_SAME_ACCESS);
-    ok(handle == INVALID_HANDLE_VALUE, "DuplicateConsoleHandle failed: %u\n", GetLastError());
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "last error = %u\n", GetLastError());
+    ok(handle == INVALID_HANDLE_VALUE, "DuplicateConsoleHandle failed: %lu\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "last error = %lu\n", GetLastError());
 }
 
 static void test_GetNumberOfConsoleInputEvents(HANDLE input_handle)
@@ -1735,10 +1735,10 @@ static void test_GetNumberOfConsoleInputEvents(HANDLE input_handle)
         if (invalid_table[i].nrofevents)
         {
             ok(count == 0xdeadbeef,
-               "[%d] Expected output count to be unmodified, got %u\n", i, count);
+               "[%d] Expected output count to be unmodified, got %lu\n", i, count);
         }
         ok(GetLastError() == invalid_table[i].last_error,
-           "[%d] Expected last error to be %u, got %u\n",
+           "[%d] Expected last error to be %lu, got %lu\n",
            i, invalid_table[i].last_error, GetLastError());
     }
 
@@ -1749,7 +1749,7 @@ static void test_GetNumberOfConsoleInputEvents(HANDLE input_handle)
         ret = GetNumberOfConsoleInputEvents(input_handle, NULL);
         ok(!ret, "Expected GetNumberOfConsoleInputEvents to return FALSE, got %d\n", ret);
         ok(GetLastError() == ERROR_INVALID_ACCESS,
-           "Expected last error to be ERROR_INVALID_ACCESS, got %u\n",
+           "Expected last error to be ERROR_INVALID_ACCESS, got %lu\n",
            GetLastError());
     }
 
@@ -1807,7 +1807,7 @@ static void test_WriteConsoleInputA(HANDLE input_handle)
     ok(ret == TRUE, "Expected GetConsoleMode to return TRUE, got %d\n", ret);
     if (!ret)
     {
-        skip("GetConsoleMode failed with last error %u\n", GetLastError());
+        skip("GetConsoleMode failed with last error %lu\n", GetLastError());
         return;
     }
 
@@ -1815,7 +1815,7 @@ static void test_WriteConsoleInputA(HANDLE input_handle)
     ok(ret == TRUE, "Expected SetConsoleMode to return TRUE, got %d\n", ret);
     if (!ret)
     {
-        skip("SetConsoleMode failed with last error %u\n", GetLastError());
+        skip("SetConsoleMode failed with last error %lu\n", GetLastError());
         return;
     }
 
@@ -1840,24 +1840,24 @@ static void test_WriteConsoleInputA(HANDLE input_handle)
         ok(!ret, "[%d] Expected WriteConsoleInputA to return FALSE, got %d\n", i, ret);
         gle = GetLastError();
         ok(gle == invalid_table[i].gle || (gle != 0 && gle == invalid_table[i].gle2),
-           "[%d] Expected last error to be %u or %u, got %u\n",
+           "[%d] Expected last error to be %lu or %lu, got %lu\n",
            i, invalid_table[i].gle, invalid_table[i].gle2, gle);
     }
 
     count = 0xdeadbeef;
     ret = WriteConsoleInputA(input_handle, NULL, 0, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = WriteConsoleInputA(input_handle, &event, 0, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = WriteConsoleInputA(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = FlushConsoleInputBuffer(input_handle);
     ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
@@ -1868,20 +1868,20 @@ static void test_WriteConsoleInputA(HANDLE input_handle)
 
     ret = WriteConsoleInputA(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = WriteConsoleInputA(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
     todo_wine
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = FlushConsoleInputBuffer(input_handle);
     ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
@@ -1896,33 +1896,33 @@ static void test_WriteConsoleInputA(HANDLE input_handle)
     ret = WriteConsoleInputA(input_handle, event_list, ARRAY_SIZE(event_list), &count);
     ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
     ok(count == ARRAY_SIZE(event_list),
-       "Expected count to be event list length, got %u\n", count);
+       "Expected count to be event list length, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
     ok(count == ARRAY_SIZE(event_list),
-       "Expected count to be event list length, got %u\n", count);
+       "Expected count to be event list length, got %lu\n", count);
 
     ret = WriteConsoleInputA(input_handle, event_list, ARRAY_SIZE(event_list), &count);
     ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
     ok(count == ARRAY_SIZE(event_list),
-       "Expected count to be event list length, got %u\n", count);
+       "Expected count to be event list length, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
     ok(count == 2*ARRAY_SIZE(event_list),
-       "Expected count to be twice event list length, got %u\n", count);
+       "Expected count to be twice event list length, got %lu\n", count);
 
     /* Again, writing a single mouse event with adjacent mouse events queued doesn't appear to affect the count. */
     ret = WriteConsoleInputA(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
     todo_wine
     ok(count == 2*ARRAY_SIZE(event_list),
-       "Expected count to be twice event list length, got %u\n", count);
+       "Expected count to be twice event list length, got %lu\n", count);
 
     ret = FlushConsoleInputBuffer(input_handle);
     ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
@@ -1940,19 +1940,19 @@ static void test_WriteConsoleInputA(HANDLE input_handle)
     /* Key events don't exhibit the same behavior as mouse events. */
     ret = WriteConsoleInputA(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = WriteConsoleInputA(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
-    ok(count == 2, "Expected count to be 2, got %u\n", count);
+    ok(count == 2, "Expected count to be 2, got %lu\n", count);
 
     ret = FlushConsoleInputBuffer(input_handle);
     ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
@@ -1963,33 +1963,33 @@ static void test_WriteConsoleInputA(HANDLE input_handle)
 
     ret = WriteConsoleInputA(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     event.EventType = KEY_EVENT;
     event.Event.KeyEvent = key_event;
 
     ret = WriteConsoleInputA(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
-    ok(count == 2, "Expected count to be 2, got %u\n", count);
+    ok(count == 2, "Expected count to be 2, got %lu\n", count);
 
     event.EventType = MOUSE_EVENT;
     event.Event.MouseEvent = mouse_event;
 
     ret = WriteConsoleInputA(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputA to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
-    ok(count == 3, "Expected count to be 3, got %u\n", count);
+    ok(count == 3, "Expected count to be 3, got %lu\n", count);
 
     /* Restore the old console mode. */
     ret = SetConsoleMode(input_handle, console_mode);
@@ -2044,7 +2044,7 @@ static void test_WriteConsoleInputW(HANDLE input_handle)
     ok(ret == TRUE, "Expected GetConsoleMode to return TRUE, got %d\n", ret);
     if (!ret)
     {
-        skip("GetConsoleMode failed with last error %u\n", GetLastError());
+        skip("GetConsoleMode failed with last error %lu\n", GetLastError());
         return;
     }
 
@@ -2052,7 +2052,7 @@ static void test_WriteConsoleInputW(HANDLE input_handle)
     ok(ret == TRUE, "Expected SetConsoleMode to return TRUE, got %d\n", ret);
     if (!ret)
     {
-        skip("SetConsoleMode failed with last error %u\n", GetLastError());
+        skip("SetConsoleMode failed with last error %lu\n", GetLastError());
         return;
     }
 
@@ -2077,24 +2077,24 @@ static void test_WriteConsoleInputW(HANDLE input_handle)
         ok(!ret, "[%d] Expected WriteConsoleInputW to return FALSE, got %d\n", i, ret);
         gle = GetLastError();
         ok(gle == invalid_table[i].gle || (gle != 0 && gle == invalid_table[i].gle2),
-           "[%d] Expected last error to be %u or %u, got %u\n",
+           "[%d] Expected last error to be %lu or %lu, got %lu\n",
            i, invalid_table[i].gle, invalid_table[i].gle2, gle);
     }
 
     count = 0xdeadbeef;
     ret = WriteConsoleInputW(input_handle, NULL, 0, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = WriteConsoleInputW(input_handle, &event, 0, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = WriteConsoleInputW(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = FlushConsoleInputBuffer(input_handle);
     ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
@@ -2105,20 +2105,20 @@ static void test_WriteConsoleInputW(HANDLE input_handle)
 
     ret = WriteConsoleInputW(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = WriteConsoleInputW(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
     todo_wine
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = FlushConsoleInputBuffer(input_handle);
     ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
@@ -2133,33 +2133,33 @@ static void test_WriteConsoleInputW(HANDLE input_handle)
     ret = WriteConsoleInputW(input_handle, event_list, ARRAY_SIZE(event_list), &count);
     ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
     ok(count == ARRAY_SIZE(event_list),
-       "Expected count to be event list length, got %u\n", count);
+       "Expected count to be event list length, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
     ok(count == ARRAY_SIZE(event_list),
-       "Expected count to be event list length, got %u\n", count);
+       "Expected count to be event list length, got %lu\n", count);
 
     ret = WriteConsoleInputW(input_handle, event_list, ARRAY_SIZE(event_list), &count);
     ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
     ok(count == ARRAY_SIZE(event_list),
-       "Expected count to be event list length, got %u\n", count);
+       "Expected count to be event list length, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
     ok(count == 2*ARRAY_SIZE(event_list),
-       "Expected count to be twice event list length, got %u\n", count);
+       "Expected count to be twice event list length, got %lu\n", count);
 
     /* Again, writing a single mouse event with adjacent mouse events queued doesn't appear to affect the count. */
     ret = WriteConsoleInputW(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
     todo_wine
     ok(count == 2*ARRAY_SIZE(event_list),
-       "Expected count to be twice event list length, got %u\n", count);
+       "Expected count to be twice event list length, got %lu\n", count);
 
     ret = FlushConsoleInputBuffer(input_handle);
     ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
@@ -2177,19 +2177,19 @@ static void test_WriteConsoleInputW(HANDLE input_handle)
     /* Key events don't exhibit the same behavior as mouse events. */
     ret = WriteConsoleInputW(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = WriteConsoleInputW(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
-    ok(count == 2, "Expected count to be 2, got %u\n", count);
+    ok(count == 2, "Expected count to be 2, got %lu\n", count);
 
     ret = FlushConsoleInputBuffer(input_handle);
     ok(ret == TRUE, "Expected FlushConsoleInputBuffer to return TRUE, got %d\n", ret);
@@ -2200,33 +2200,33 @@ static void test_WriteConsoleInputW(HANDLE input_handle)
 
     ret = WriteConsoleInputW(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     event.EventType = KEY_EVENT;
     event.Event.KeyEvent = key_event;
 
     ret = WriteConsoleInputW(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
-    ok(count == 2, "Expected count to be 2, got %u\n", count);
+    ok(count == 2, "Expected count to be 2, got %lu\n", count);
 
     event.EventType = MOUSE_EVENT;
     event.Event.MouseEvent = mouse_event;
 
     ret = WriteConsoleInputW(input_handle, &event, 1, &count);
     ok(ret == TRUE, "Expected WriteConsoleInputW to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     ret = GetNumberOfConsoleInputEvents(input_handle, &count);
     ok(ret == TRUE, "Expected GetNumberOfConsoleInputEvents to return TRUE, got %d\n", ret);
-    ok(count == 3, "Expected count to be 3, got %u\n", count);
+    ok(count == 3, "Expected count to be 3, got %lu\n", count);
 
     /* Restore the old console mode. */
     ret = SetConsoleMode(input_handle, console_mode);
@@ -2240,11 +2240,11 @@ static void test_FlushConsoleInputBuffer(HANDLE input, HANDLE output)
     BOOL ret;
 
     ret = FlushConsoleInputBuffer(input);
-    ok(ret, "FlushConsoleInputBuffer failed: %u\n", GetLastError());
+    ok(ret, "FlushConsoleInputBuffer failed: %lu\n", GetLastError());
 
     ret = GetNumberOfConsoleInputEvents(input, &count);
-    ok(ret, "GetNumberOfConsoleInputEvents failed: %u\n", GetLastError());
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(ret, "GetNumberOfConsoleInputEvents failed: %lu\n", GetLastError());
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     record.EventType = KEY_EVENT;
     record.Event.KeyEvent.bKeyDown = 1;
@@ -2254,39 +2254,39 @@ static void test_FlushConsoleInputBuffer(HANDLE input, HANDLE output)
     record.Event.KeyEvent.uChar.UnicodeChar = '\r';
     record.Event.KeyEvent.dwControlKeyState = 0;
     ret = WriteConsoleInputW(input, &record, 1, &count);
-    ok(ret, "WriteConsoleInputW failed: %u\n", GetLastError());
+    ok(ret, "WriteConsoleInputW failed: %lu\n", GetLastError());
 
     ret = GetNumberOfConsoleInputEvents(input, &count);
-    ok(ret, "GetNumberOfConsoleInputEvents failed: %u\n", GetLastError());
-    ok(count == 1, "Expected count to be 0, got %u\n", count);
+    ok(ret, "GetNumberOfConsoleInputEvents failed: %lu\n", GetLastError());
+    ok(count == 1, "Expected count to be 0, got %lu\n", count);
 
     ret = FlushConsoleInputBuffer(input);
-    ok(ret, "FlushConsoleInputBuffer failed: %u\n", GetLastError());
+    ok(ret, "FlushConsoleInputBuffer failed: %lu\n", GetLastError());
 
     ret = GetNumberOfConsoleInputEvents(input, &count);
-    ok(ret, "GetNumberOfConsoleInputEvents failed: %u\n", GetLastError());
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(ret, "GetNumberOfConsoleInputEvents failed: %lu\n", GetLastError());
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     ret = WriteConsoleInputW(input, &record, 1, &count);
-    ok(ret, "WriteConsoleInputW failed: %u\n", GetLastError());
+    ok(ret, "WriteConsoleInputW failed: %lu\n", GetLastError());
 
     ret = GetNumberOfConsoleInputEvents(input, &count);
-    ok(ret, "GetNumberOfConsoleInputEvents failed: %u\n", GetLastError());
-    ok(count == 1, "Expected count to be 0, got %u\n", count);
+    ok(ret, "GetNumberOfConsoleInputEvents failed: %lu\n", GetLastError());
+    ok(count == 1, "Expected count to be 0, got %lu\n", count);
 
     ret = FlushFileBuffers(input);
-    ok(ret, "FlushFileBuffers failed: %u\n", GetLastError());
+    ok(ret, "FlushFileBuffers failed: %lu\n", GetLastError());
 
     ret = GetNumberOfConsoleInputEvents(input, &count);
-    ok(ret, "GetNumberOfConsoleInputEvents failed: %u\n", GetLastError());
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(ret, "GetNumberOfConsoleInputEvents failed: %lu\n", GetLastError());
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     ret = FlushConsoleInputBuffer(output);
-    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "FlushConsoleInputBuffer returned: %x(%u)\n",
+    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "FlushConsoleInputBuffer returned: %x(%lu)\n",
        ret, GetLastError());
 
     ret = FlushFileBuffers(output);
-    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "FlushFileBuffers returned: %x(%u)\n",
+    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "FlushFileBuffers returned: %x(%lu)\n",
        ret, GetLastError());
 }
 
@@ -2350,34 +2350,34 @@ static void test_WriteConsoleOutputCharacterA(HANDLE output_handle)
         if (invalid_table[i].lpNumCharsWritten)
         {
             ok(count == invalid_table[i].expected_count,
-               "[%d] Expected count to be %u, got %u\n",
+               "[%d] Expected count to be %lu, got %lu\n",
                i, invalid_table[i].expected_count, count);
         }
         ok(GetLastError() == invalid_table[i].last_error,
-           "[%d] Expected last error to be %u, got %u\n",
+           "[%d] Expected last error to be %lu, got %lu\n",
            i, invalid_table[i].last_error, GetLastError());
     }
 
     count = 0xdeadbeef;
     ret = WriteConsoleOutputCharacterA(output_handle, NULL, 0, origin, &count);
     ok(ret == TRUE, "Expected WriteConsoleOutputCharacterA to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = WriteConsoleOutputCharacterA(output_handle, output, 0, origin, &count);
     ok(ret == TRUE, "Expected WriteConsoleOutputCharacterA to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = WriteConsoleOutputCharacterA(output_handle, output, 1, origin, &count);
     ok(ret == TRUE, "Expected WriteConsoleOutputCharacterA to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     count = 0xdeadbeef;
     origin.X = 200;
     ret = WriteConsoleOutputCharacterA(output_handle, output, 0, origin, &count);
     ok(ret == TRUE, "Expected WriteConsoleOutputCharacterA to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 }
 
 static void test_WriteConsoleOutputCharacterW(HANDLE output_handle)
@@ -2440,34 +2440,34 @@ static void test_WriteConsoleOutputCharacterW(HANDLE output_handle)
         if (invalid_table[i].lpNumCharsWritten)
         {
             ok(count == invalid_table[i].expected_count,
-               "[%d] Expected count to be %u, got %u\n",
+               "[%d] Expected count to be %lu, got %lu\n",
                i, invalid_table[i].expected_count, count);
         }
         ok(GetLastError() == invalid_table[i].last_error,
-           "[%d] Expected last error to be %u, got %u\n",
+           "[%d] Expected last error to be %lu, got %lu\n",
            i, invalid_table[i].last_error, GetLastError());
     }
 
     count = 0xdeadbeef;
     ret = WriteConsoleOutputCharacterW(output_handle, NULL, 0, origin, &count);
     ok(ret == TRUE, "Expected WriteConsoleOutputCharacterW to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = WriteConsoleOutputCharacterW(output_handle, outputW, 0, origin, &count);
     ok(ret == TRUE, "Expected WriteConsoleOutputCharacterW to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = WriteConsoleOutputCharacterW(output_handle, outputW, 1, origin, &count);
     ok(ret == TRUE, "Expected WriteConsoleOutputCharacterW to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     count = 0xdeadbeef;
     origin.X = 200;
     ret = WriteConsoleOutputCharacterW(output_handle, outputW, 0, origin, &count);
     ok(ret == TRUE, "Expected WriteConsoleOutputCharacterW to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
 }
 
@@ -2530,34 +2530,34 @@ static void test_WriteConsoleOutputAttribute(HANDLE output_handle)
         if (invalid_table[i].lpNumAttrsWritten)
         {
             ok(count == invalid_table[i].expected_count,
-               "[%d] Expected count to be %u, got %u\n",
+               "[%d] Expected count to be %lu, got %lu\n",
                i, invalid_table[i].expected_count, count);
         }
         ok(GetLastError() == invalid_table[i].last_error,
-           "[%d] Expected last error to be %u, got %u\n",
+           "[%d] Expected last error to be %lu, got %lu\n",
            i, invalid_table[i].last_error, GetLastError());
     }
 
     count = 0xdeadbeef;
     ret = WriteConsoleOutputAttribute(output_handle, NULL, 0, origin, &count);
     ok(ret == TRUE, "Expected WriteConsoleOutputAttribute to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = WriteConsoleOutputAttribute(output_handle, &attr, 0, origin, &count);
     ok(ret == TRUE, "Expected WriteConsoleOutputAttribute to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = WriteConsoleOutputAttribute(output_handle, &attr, 1, origin, &count);
     ok(ret == TRUE, "Expected WriteConsoleOutputAttribute to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     count = 0xdeadbeef;
     origin.X = 200;
     ret = WriteConsoleOutputAttribute(output_handle, &attr, 0, origin, &count);
     ok(ret == TRUE, "Expected WriteConsoleOutputAttribute to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 }
 
 static void set_region(SMALL_RECT *region, unsigned int left, unsigned int top, unsigned int right, unsigned int bottom)
@@ -2602,7 +2602,7 @@ static void test_WriteConsoleOutput(HANDLE console)
     }
 
     ret = GetConsoleScreenBufferInfo(console, &info);
-    ok(ret, "GetConsoleScreenBufferInfo failed: %u\n", GetLastError());
+    ok(ret, "GetConsoleScreenBufferInfo failed: %lu\n", GetLastError());
 
     size.X = 23;
     size.Y = 17;
@@ -2610,7 +2610,7 @@ static void test_WriteConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, 10, 7, 15, 11);
     ret = WriteConsoleOutputW(console, char_info_buf, size, coord, &region);
-    ok(ret, "WriteConsoleOutputW failed: %u\n", GetLastError());
+    ok(ret, "WriteConsoleOutputW failed: %lu\n", GetLastError());
     check_region(&region, 10, 7, 15, 11);
 
     size.X = 23;
@@ -2619,7 +2619,7 @@ static void test_WriteConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, 200, 7, 15, 211);
     ret = WriteConsoleOutputW(console, char_info_buf, size, coord, &region);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "WriteConsoleOutputW returned: %x(%u)\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "WriteConsoleOutputW returned: %x(%lu)\n", ret, GetLastError());
     check_region(&region, 200, 7, 15, 211);
 
     size.X = 23;
@@ -2628,7 +2628,7 @@ static void test_WriteConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, 200, 7, 211, 8);
     ret = WriteConsoleOutputW(console, char_info_buf, size, coord, &region);
-    ok(ret, "WriteConsoleOutputW failed: %u\n", GetLastError());
+    ok(ret, "WriteConsoleOutputW failed: %lu\n", GetLastError());
     check_region(&region, 200, 7, 211, 8);
 
     size.X = 23;
@@ -2637,7 +2637,7 @@ static void test_WriteConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, 10, 7, 9, 11);
     ret = WriteConsoleOutputW(console, char_info_buf, size, coord, &region);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "WriteConsoleOutputW returned: %x(%u)\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "WriteConsoleOutputW returned: %x(%lu)\n", ret, GetLastError());
     check_region(&region, 10, 7, 9, 11);
 
     size.X = 23;
@@ -2646,7 +2646,7 @@ static void test_WriteConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, 10, 7, 11, 6);
     ret = WriteConsoleOutputW(console, char_info_buf, size, coord, &region);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "WriteConsoleOutputW returned: %x(%u)\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "WriteConsoleOutputW returned: %x(%lu)\n", ret, GetLastError());
     check_region(&region, 10, 7, 11, 6);
 
     size.X = 2;
@@ -2655,7 +2655,7 @@ static void test_WriteConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, 10, 7, 15, 11);
     ret = WriteConsoleOutputW(console, char_info_buf, size, coord, &region);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "WriteConsoleOutputW returned: %x(%u)\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "WriteConsoleOutputW returned: %x(%lu)\n", ret, GetLastError());
     check_region(&region, 10, 7, 15, 11);
 
     size.X = 23;
@@ -2664,7 +2664,7 @@ static void test_WriteConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, 10, 7, 15, 11);
     ret = WriteConsoleOutputW(console, char_info_buf, size, coord, &region);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "WriteConsoleOutputW returned: %x(%u)\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "WriteConsoleOutputW returned: %x(%lu)\n", ret, GetLastError());
     check_region(&region, 10, 7, 15, 11);
 
     size.X = 6;
@@ -2673,7 +2673,7 @@ static void test_WriteConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, 10, 7, 15, 11);
     ret = WriteConsoleOutputW(console, char_info_buf, size, coord, &region);
-    ok(ret, "WriteConsoleOutputW failed: %u\n", GetLastError());
+    ok(ret, "WriteConsoleOutputW failed: %lu\n", GetLastError());
     check_region(&region, 10, 7, 13, 11);
 
     size.X = 6;
@@ -2682,7 +2682,7 @@ static void test_WriteConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, 10, 7, 15, 11);
     ret = WriteConsoleOutputW((HANDLE)0xdeadbeef, char_info_buf, size, coord, &region);
-    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "WriteConsoleOutputW returned: %x(%u)\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "WriteConsoleOutputW returned: %x(%lu)\n", ret, GetLastError());
     if (!skip_nt) check_region(&region, 10, 7, 13, 11);
 
     size.X = 16;
@@ -2691,7 +2691,7 @@ static void test_WriteConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, 10, 7, 15, 11);
     ret = WriteConsoleOutputW(console, char_info_buf, size, coord, &region);
-    ok(ret, "WriteConsoleOutputW failed: %u\n", GetLastError());
+    ok(ret, "WriteConsoleOutputW failed: %lu\n", GetLastError());
     check_region(&region, 10, 7, 15, 10);
 
     size.X = 16;
@@ -2700,7 +2700,7 @@ static void test_WriteConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, info.dwSize.X - 2, 7, info.dwSize.X + 2, 7);
     ret = WriteConsoleOutputW(console, char_info_buf, size, coord, &region);
-    ok(ret, "WriteConsoleOutputW failed: %u\n", GetLastError());
+    ok(ret, "WriteConsoleOutputW failed: %lu\n", GetLastError());
     check_region(&region, info.dwSize.X - 2, 7, info.dwSize.X - 1, 7);
 }
 
@@ -2748,19 +2748,19 @@ static void test_FillConsoleOutputCharacterA(HANDLE output_handle)
                                           invalid_table[i].lpNumCharsWritten);
         ok(!ret, "[%d] Expected FillConsoleOutputCharacterA to return FALSE, got %d\n", i, ret);
         ok(GetLastError() == invalid_table[i].last_error,
-           "[%d] Expected last error to be %u, got %u\n",
+           "[%d] Expected last error to be %lu, got %lu\n",
            i, invalid_table[i].last_error, GetLastError());
     }
 
     count = 0xdeadbeef;
     ret = FillConsoleOutputCharacterA(output_handle, 'a', 0, origin, &count);
     ok(ret == TRUE, "Expected FillConsoleOutputCharacterA to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = FillConsoleOutputCharacterA(output_handle, 'a', 1, origin, &count);
     ok(ret == TRUE, "Expected FillConsoleOutputCharacterA to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 }
 
 static void test_FillConsoleOutputCharacterW(HANDLE output_handle)
@@ -2807,19 +2807,19 @@ static void test_FillConsoleOutputCharacterW(HANDLE output_handle)
                                           invalid_table[i].lpNumCharsWritten);
         ok(!ret, "[%d] Expected FillConsoleOutputCharacterW to return FALSE, got %d\n", i, ret);
         ok(GetLastError() == invalid_table[i].last_error,
-           "[%d] Expected last error to be %u, got %u\n",
+           "[%d] Expected last error to be %lu, got %lu\n",
            i, invalid_table[i].last_error, GetLastError());
     }
 
     count = 0xdeadbeef;
     ret = FillConsoleOutputCharacterW(output_handle, 'a', 0, origin, &count);
     ok(ret == TRUE, "Expected FillConsoleOutputCharacterW to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = FillConsoleOutputCharacterW(output_handle, 'a', 1, origin, &count);
     ok(ret == TRUE, "Expected FillConsoleOutputCharacterW to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 }
 
 static void test_FillConsoleOutputAttribute(HANDLE output_handle)
@@ -2866,24 +2866,24 @@ static void test_FillConsoleOutputAttribute(HANDLE output_handle)
                                          invalid_table[i].lpNumAttrsWritten);
         ok(!ret, "[%d] Expected FillConsoleOutputAttribute to return FALSE, got %d\n", i, ret);
         ok(GetLastError() == invalid_table[i].last_error,
-           "[%d] Expected last error to be %u, got %u\n",
+           "[%d] Expected last error to be %lu, got %lu\n",
            i, invalid_table[i].last_error, GetLastError());
     }
 
     count = 0xdeadbeef;
     ret = FillConsoleOutputAttribute(output_handle, FOREGROUND_BLUE, 0, origin, &count);
     ok(ret == TRUE, "Expected FillConsoleOutputAttribute to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = FillConsoleOutputAttribute(output_handle, FOREGROUND_BLUE, 1, origin, &count);
     ok(ret == TRUE, "Expected FillConsoleOutputAttribute to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = FillConsoleOutputAttribute(output_handle, ~0, 1, origin, &count);
     ok(ret == TRUE, "Expected FillConsoleOutputAttribute to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 }
 
 static void test_ReadConsoleOutputCharacterA(HANDLE output_handle)
@@ -2946,34 +2946,34 @@ static void test_ReadConsoleOutputCharacterA(HANDLE output_handle)
         if (invalid_table[i].read_count)
         {
             ok(count == invalid_table[i].expected_count,
-               "[%d] Expected count to be %u, got %u\n",
+               "[%d] Expected count to be %lu, got %lu\n",
                i, invalid_table[i].expected_count, count);
         }
         ok(GetLastError() == invalid_table[i].last_error,
-           "[%d] Expected last error to be %u, got %u\n",
+           "[%d] Expected last error to be %lu, got %lu\n",
            i, invalid_table[i].last_error, GetLastError());
     }
 
     count = 0xdeadbeef;
     ret = ReadConsoleOutputCharacterA(output_handle, NULL, 0, origin, &count);
     ok(ret == TRUE, "Expected ReadConsoleOutputCharacterA to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = ReadConsoleOutputCharacterA(output_handle, &read, 0, origin, &count);
     ok(ret == TRUE, "Expected ReadConsoleOutputCharacterA to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = ReadConsoleOutputCharacterA(output_handle, &read, 1, origin, &count);
     ok(ret == TRUE, "Expected ReadConsoleOutputCharacterA to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     count = 0xdeadbeef;
     origin.X = 200;
     ret = ReadConsoleOutputCharacterA(output_handle, &read, 1, origin, &count);
     ok(ret == TRUE, "Expected ReadConsoleOutputCharacterA to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 }
 
 static void test_ReadConsoleOutputCharacterW(HANDLE output_handle)
@@ -3036,34 +3036,34 @@ static void test_ReadConsoleOutputCharacterW(HANDLE output_handle)
         if (invalid_table[i].read_count)
         {
             ok(count == invalid_table[i].expected_count,
-               "[%d] Expected count to be %u, got %u\n",
+               "[%d] Expected count to be %lu, got %lu\n",
                i, invalid_table[i].expected_count, count);
         }
         ok(GetLastError() == invalid_table[i].last_error,
-           "[%d] Expected last error to be %u, got %u\n",
+           "[%d] Expected last error to be %lu, got %lu\n",
            i, invalid_table[i].last_error, GetLastError());
     }
 
     count = 0xdeadbeef;
     ret = ReadConsoleOutputCharacterW(output_handle, NULL, 0, origin, &count);
     ok(ret == TRUE, "Expected ReadConsoleOutputCharacterW to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = ReadConsoleOutputCharacterW(output_handle, &read, 0, origin, &count);
     ok(ret == TRUE, "Expected ReadConsoleOutputCharacterW to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = ReadConsoleOutputCharacterW(output_handle, &read, 1, origin, &count);
     ok(ret == TRUE, "Expected ReadConsoleOutputCharacterW to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     count = 0xdeadbeef;
     origin.X = 200;
     ret = ReadConsoleOutputCharacterW(output_handle, &read, 1, origin, &count);
     ok(ret == TRUE, "Expected ReadConsoleOutputCharacterW to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 }
 
 static void test_ReadConsoleOutputAttribute(HANDLE output_handle)
@@ -3125,34 +3125,34 @@ static void test_ReadConsoleOutputAttribute(HANDLE output_handle)
         if (invalid_table[i].read_count)
         {
             ok(count == invalid_table[i].expected_count,
-               "[%d] Expected count to be %u, got %u\n",
+               "[%d] Expected count to be %lu, got %lu\n",
                i, invalid_table[i].expected_count, count);
         }
         ok(GetLastError() == invalid_table[i].last_error,
-           "[%d] Expected last error to be %u, got %u\n",
+           "[%d] Expected last error to be %lu, got %lu\n",
            i, invalid_table[i].last_error, GetLastError());
     }
 
     count = 0xdeadbeef;
     ret = ReadConsoleOutputAttribute(output_handle, NULL, 0, origin, &count);
     ok(ret == TRUE, "Expected ReadConsoleOutputAttribute to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = ReadConsoleOutputAttribute(output_handle, &attr, 0, origin, &count);
     ok(ret == TRUE, "Expected ReadConsoleOutputAttribute to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 0, got %u\n", count);
+    ok(count == 0, "Expected count to be 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     ret = ReadConsoleOutputAttribute(output_handle, &attr, 1, origin, &count);
     ok(ret == TRUE, "Expected ReadConsoleOutputAttribute to return TRUE, got %d\n", ret);
-    ok(count == 1, "Expected count to be 1, got %u\n", count);
+    ok(count == 1, "Expected count to be 1, got %lu\n", count);
 
     count = 0xdeadbeef;
     origin.X = 200;
     ret = ReadConsoleOutputAttribute(output_handle, &attr, 1, origin, &count);
     ok(ret == TRUE, "Expected ReadConsoleOutputAttribute to return TRUE, got %d\n", ret);
-    ok(count == 0, "Expected count to be 1, got %u\n", count);
+    ok(count == 0, "Expected count to be 1, got %lu\n", count);
 }
 
 static void test_ReadConsoleOutput(HANDLE console)
@@ -3168,7 +3168,7 @@ static void test_ReadConsoleOutput(HANDLE console)
     if (skip_nt) return;
 
     ret = GetConsoleScreenBufferInfo(console, &info);
-    ok(ret, "GetConsoleScreenBufferInfo failed: %u\n", GetLastError());
+    ok(ret, "GetConsoleScreenBufferInfo failed: %lu\n", GetLastError());
 
     size.X = 23;
     size.Y = 17;
@@ -3176,7 +3176,7 @@ static void test_ReadConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, 10, 7, 15, 11);
     ret = ReadConsoleOutputW(console, char_info_buf, size, coord, &region);
-    ok(ret, "ReadConsoleOutputW failed: %u\n", GetLastError());
+    ok(ret, "ReadConsoleOutputW failed: %lu\n", GetLastError());
     check_region(&region, 10, 7, 15, 11);
 
     size.X = 23;
@@ -3185,7 +3185,7 @@ static void test_ReadConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, 200, 7, 15, 211);
     ret = ReadConsoleOutputW(console, char_info_buf, size, coord, &region);
-    ok(!ret, "ReadConsoleOutputW returned: %x(%u)\n", ret, GetLastError());
+    ok(!ret, "ReadConsoleOutputW returned: %x(%lu)\n", ret, GetLastError());
     check_region(&region, 200, 7, -15, 0);
 
     size.X = 23;
@@ -3195,7 +3195,7 @@ static void test_ReadConsoleOutput(HANDLE console)
     set_region(&region, 200, 7, 211, 8);
     ret = ReadConsoleOutputW(console, char_info_buf, size, coord, &region);
     ok((!ret && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_INVALID_FUNCTION)) || broken(ret /* win8 */),
-       "ReadConsoleOutputW returned: %x %u\n", ret, GetLastError());
+       "ReadConsoleOutputW returned: %x %lu\n", ret, GetLastError());
     if (!ret && GetLastError() == ERROR_INVALID_PARAMETER) check_region(&region, 200, 7, -211, -8);
 
     size.X = 23;
@@ -3205,7 +3205,7 @@ static void test_ReadConsoleOutput(HANDLE console)
     set_region(&region, 10, 7, 9, 11);
     ret = ReadConsoleOutputW(console, char_info_buf, size, coord, &region);
     ok((!ret && (GetLastError() == ERROR_INVALID_FUNCTION || GetLastError() == ERROR_NOT_ENOUGH_MEMORY)) || broken(ret /* win8 */),
-       "ReadConsoleOutputW returned: %x(%u)\n", ret, GetLastError());
+       "ReadConsoleOutputW returned: %x(%lu)\n", ret, GetLastError());
     check_region(&region, 10, 7, 9, -11);
 
     size.X = 23;
@@ -3215,7 +3215,7 @@ static void test_ReadConsoleOutput(HANDLE console)
     set_region(&region, 10, 7, 11, 6);
     ret = ReadConsoleOutputW(console, char_info_buf, size, coord, &region);
     ok((!ret && (GetLastError() == ERROR_INVALID_FUNCTION || GetLastError() == ERROR_NOT_ENOUGH_MEMORY)) || broken(ret /* win8 */),
-       "ReadConsoleOutputW returned: %x(%u)\n", ret, GetLastError());
+       "ReadConsoleOutputW returned: %x(%lu)\n", ret, GetLastError());
     check_region(&region, 10, 7, -11, 6);
 
     size.X = 2;
@@ -3225,7 +3225,7 @@ static void test_ReadConsoleOutput(HANDLE console)
     set_region(&region, 10, 7, 15, 11);
     ret = ReadConsoleOutputW(console, char_info_buf, size, coord, &region);
     ok((!ret && (GetLastError() == ERROR_INVALID_FUNCTION || GetLastError() == ERROR_NOT_ENOUGH_MEMORY)) || broken(ret /* win8 */),
-       "ReadConsoleOutputW returned: %x(%u)\n", ret, GetLastError());
+       "ReadConsoleOutputW returned: %x(%lu)\n", ret, GetLastError());
     check_region(&region, 10, 7, -15, -11);
 
     size.X = 23;
@@ -3235,7 +3235,7 @@ static void test_ReadConsoleOutput(HANDLE console)
     set_region(&region, 10, 7, 15, 11);
     ret = ReadConsoleOutputW(console, char_info_buf, size, coord, &region);
     ok((!ret && (GetLastError() == ERROR_INVALID_FUNCTION || GetLastError() == ERROR_NOT_ENOUGH_MEMORY)) || broken(ret /* win8 */),
-       "ReadConsoleOutputW returned: %x(%u)\n", ret, GetLastError());
+       "ReadConsoleOutputW returned: %x(%lu)\n", ret, GetLastError());
     check_region(&region, 10, 7, -15, 6);
 
     size.X = 6;
@@ -3244,7 +3244,7 @@ static void test_ReadConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, 10, 7, 15, 11);
     ret = ReadConsoleOutputW(console, char_info_buf, size, coord, &region);
-    ok(ret, "ReadConsoleOutputW failed: %u\n", GetLastError());
+    ok(ret, "ReadConsoleOutputW failed: %lu\n", GetLastError());
     check_region(&region, 10, 7, 13, 11);
 
     size.X = 6;
@@ -3253,7 +3253,7 @@ static void test_ReadConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, 10, 7, 15, 11);
     ret = ReadConsoleOutputW((HANDLE)0xdeadbeef, char_info_buf, size, coord, &region);
-    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "ReadConsoleOutputW returned: %x(%u)\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "ReadConsoleOutputW returned: %x(%lu)\n", ret, GetLastError());
     if (!skip_nt) check_region(&region, 10, 7, 13, 11);
 
     size.X = 16;
@@ -3262,7 +3262,7 @@ static void test_ReadConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, 10, 7, 15, 11);
     ret = ReadConsoleOutputW(console, char_info_buf, size, coord, &region);
-    ok(ret, "ReadConsoleOutputW failed: %u\n", GetLastError());
+    ok(ret, "ReadConsoleOutputW failed: %lu\n", GetLastError());
     check_region(&region, 10, 7, 15, 10);
 
     size.X = 16;
@@ -3271,14 +3271,14 @@ static void test_ReadConsoleOutput(HANDLE console)
     coord.Y = 3;
     set_region(&region, info.dwSize.X - 2, 7, info.dwSize.X + 2, 7);
     ret = ReadConsoleOutputW(console, char_info_buf, size, coord, &region);
-    ok(ret || GetLastError() == ERROR_INVALID_PARAMETER, "ReadConsoleOutputW failed: %u\n", GetLastError());
+    ok(ret || GetLastError() == ERROR_INVALID_PARAMETER, "ReadConsoleOutputW failed: %lu\n", GetLastError());
     if (ret) check_region(&region, info.dwSize.X - 2, 7, info.dwSize.X - 1, 7);
 
     coord.X = 2;
     coord.Y = 3;
     ret = WriteConsoleOutputCharacterW(console, L"xyz", 3, coord, &count);
-    ok(ret, "WriteConsoleOutputCharacterW failed: %u\n", GetLastError());
-    ok(count == 3, "count = %u\n", count);
+    ok(ret, "WriteConsoleOutputCharacterW failed: %lu\n", GetLastError());
+    ok(count == 3, "count = %lu\n", count);
 
     memset(char_info_buf, 0xc0, sizeof(char_info_buf));
     size.X = 16;
@@ -3287,7 +3287,7 @@ static void test_ReadConsoleOutput(HANDLE console)
     coord.Y = 6;
     set_region(&region, 2, 3, 5, 3);
     ret = ReadConsoleOutputW(console, char_info_buf, size, coord, &region);
-    ok(ret, "ReadConsoleOutputW failed: %u\n", GetLastError());
+    ok(ret, "ReadConsoleOutputW failed: %lu\n", GetLastError());
     check_region(&region, 2, 3, 5, 3);
     ch = char_info_buf[coord.Y * size.X + coord.X].Char.UnicodeChar;
     ok(ch == 'x', "unexpected char %c/%x\n", ch, ch);
@@ -3305,52 +3305,52 @@ static void test_ReadConsole(HANDLE input)
 
     SetLastError(0xdeadbeef);
     ret = GetFileSize(input, NULL);
-    ok(ret == INVALID_FILE_SIZE, "expected INVALID_FILE_SIZE, got %#x\n", ret);
+    ok(ret == INVALID_FILE_SIZE, "expected INVALID_FILE_SIZE, got %#lx\n", ret);
     ok(GetLastError() == ERROR_INVALID_HANDLE ||
        GetLastError() == ERROR_INVALID_FUNCTION, /* Win 8, 10 */
-       "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
+       "expected ERROR_INVALID_HANDLE, got %ld\n", GetLastError());
 
     bytes = 0xdeadbeef;
     SetLastError(0xdeadbeef);
     ret = ReadFile(input, buf, -128, &bytes, NULL);
-    ok(!ret, "expected 0, got %u\n", ret);
+    ok(!ret, "expected 0, got %lu\n", ret);
     ok(GetLastError() == ERROR_NOT_ENOUGH_MEMORY ||
        GetLastError() == ERROR_NOACCESS, /* Win 8, 10 */
-       "expected ERROR_NOT_ENOUGH_MEMORY, got %d\n", GetLastError());
-    ok(!bytes, "expected 0, got %u\n", bytes);
+       "expected ERROR_NOT_ENOUGH_MEMORY, got %ld\n", GetLastError());
+    ok(!bytes, "expected 0, got %lu\n", bytes);
 
     bytes = 0xdeadbeef;
     SetLastError(0xdeadbeef);
     ret = ReadConsoleA(input, buf, -128, &bytes, NULL);
-    ok(!ret, "expected 0, got %u\n", ret);
+    ok(!ret, "expected 0, got %lu\n", ret);
     ok(GetLastError() == ERROR_NOT_ENOUGH_MEMORY ||
        GetLastError() == ERROR_NOACCESS, /* Win 8, 10 */
-       "expected ERROR_NOT_ENOUGH_MEMORY, got %d\n", GetLastError());
-    ok(bytes == 0xdeadbeef, "expected 0xdeadbeef, got %#x\n", bytes);
+       "expected ERROR_NOT_ENOUGH_MEMORY, got %ld\n", GetLastError());
+    ok(bytes == 0xdeadbeef, "expected 0xdeadbeef, got %#lx\n", bytes);
 
     bytes = 0xdeadbeef;
     SetLastError(0xdeadbeef);
     ret = ReadConsoleW(input, buf, -128, &bytes, NULL);
-    ok(!ret, "expected 0, got %u\n", ret);
+    ok(!ret, "expected 0, got %lu\n", ret);
     ok(GetLastError() == ERROR_NOT_ENOUGH_MEMORY ||
        GetLastError() == ERROR_NOACCESS, /* Win 8, 10 */
-       "expected ERROR_NOT_ENOUGH_MEMORY, got %d\n", GetLastError());
-    ok(bytes == 0xdeadbeef, "expected 0xdeadbeef, got %#x\n", bytes);
+       "expected ERROR_NOT_ENOUGH_MEMORY, got %ld\n", GetLastError());
+    ok(bytes == 0xdeadbeef, "expected 0xdeadbeef, got %#lx\n", bytes);
 
     output = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
     ok(output != INVALID_HANDLE_VALUE, "Could not open console\n");
 
     ret = ReadConsoleW(output, buf, sizeof(buf) / sizeof(WCHAR), &bytes, NULL);
     ok(!ret && GetLastError() == ERROR_INVALID_HANDLE,
-       "ReadConsoleW returned %x(%u)\n", ret, GetLastError());
+       "ReadConsoleW returned %lx(%lu)\n", ret, GetLastError());
 
     ret = ReadConsoleA(output, buf, sizeof(buf), &bytes, NULL);
     ok(!ret && GetLastError() == ERROR_INVALID_HANDLE,
-       "ReadConsoleA returned %x(%u)\n", ret, GetLastError());
+       "ReadConsoleA returned %lx(%lu)\n", ret, GetLastError());
 
     ret = ReadFile(output, buf, sizeof(buf), &bytes, NULL);
     ok(!ret && GetLastError() == ERROR_INVALID_HANDLE,
-       "ReadFile returned %x(%u)\n", ret, GetLastError());
+       "ReadFile returned %lx(%lu)\n", ret, GetLastError());
 
     CloseHandle(output);
 }
@@ -3368,7 +3368,7 @@ static void test_GetCurrentConsoleFont(HANDLE std_output)
     SetLastError(0xdeadbeef);
     ret = GetCurrentConsoleFont(NULL, FALSE, &cfi);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
     ok(!cfi.dwFontSize.X, "got %d, expected 0\n", cfi.dwFontSize.X);
     ok(!cfi.dwFontSize.Y, "got %d, expected 0\n", cfi.dwFontSize.Y);
 
@@ -3376,7 +3376,7 @@ static void test_GetCurrentConsoleFont(HANDLE std_output)
     SetLastError(0xdeadbeef);
     ret = GetCurrentConsoleFont(NULL, TRUE, &cfi);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
     ok(!cfi.dwFontSize.X, "got %d, expected 0\n", cfi.dwFontSize.X);
     ok(!cfi.dwFontSize.Y, "got %d, expected 0\n", cfi.dwFontSize.Y);
 
@@ -3384,7 +3384,7 @@ static void test_GetCurrentConsoleFont(HANDLE std_output)
     SetLastError(0xdeadbeef);
     ret = GetCurrentConsoleFont(GetStdHandle(STD_INPUT_HANDLE), FALSE, &cfi);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
     ok(!cfi.dwFontSize.X, "got %d, expected 0\n", cfi.dwFontSize.X);
     ok(!cfi.dwFontSize.Y, "got %d, expected 0\n", cfi.dwFontSize.Y);
 
@@ -3392,7 +3392,7 @@ static void test_GetCurrentConsoleFont(HANDLE std_output)
     SetLastError(0xdeadbeef);
     ret = GetCurrentConsoleFont(GetStdHandle(STD_INPUT_HANDLE), TRUE, &cfi);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
     ok(!cfi.dwFontSize.X, "got %d, expected 0\n", cfi.dwFontSize.X);
     ok(!cfi.dwFontSize.Y, "got %d, expected 0\n", cfi.dwFontSize.Y);
 
@@ -3401,7 +3401,7 @@ static void test_GetCurrentConsoleFont(HANDLE std_output)
     SetLastError(0xdeadbeef);
     ret = GetCurrentConsoleFont(pipe1, TRUE, &cfi);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
     ok(!cfi.dwFontSize.X, "got %d, expected 0\n", cfi.dwFontSize.X);
     ok(!cfi.dwFontSize.Y, "got %d, expected 0\n", cfi.dwFontSize.Y);
     CloseHandle(pipe1);
@@ -3411,7 +3411,7 @@ static void test_GetCurrentConsoleFont(HANDLE std_output)
     SetLastError(0xdeadbeef);
     ret = GetCurrentConsoleFont(std_output, FALSE, &cfi);
     ok(ret, "got %d, expected non-zero\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "got %lu, expected 0xdeadbeef\n", GetLastError());
     GetConsoleScreenBufferInfo(std_output, &csbi);
     width = csbi.srWindow.Right - csbi.srWindow.Left + 1;
     height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
@@ -3425,7 +3425,7 @@ static void test_GetCurrentConsoleFont(HANDLE std_output)
     SetLastError(0xdeadbeef);
     ret = GetCurrentConsoleFont(std_output, TRUE, &cfi);
     ok(ret, "got %d, expected non-zero\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "got %lu, expected 0xdeadbeef\n", GetLastError());
     ok(cfi.dwFontSize.X == csbi.dwMaximumWindowSize.X,
        "got %d, expected %d\n", cfi.dwFontSize.X, csbi.dwMaximumWindowSize.X);
     ok(cfi.dwFontSize.Y == csbi.dwMaximumWindowSize.Y,
@@ -3454,82 +3454,82 @@ static void test_GetCurrentConsoleFontEx(HANDLE std_output)
     SetLastError(0xdeadbeef);
     ret = pGetCurrentConsoleFontEx(NULL, FALSE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetCurrentConsoleFontEx(NULL, TRUE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetCurrentConsoleFontEx(std_input, FALSE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetCurrentConsoleFontEx(std_input, TRUE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetCurrentConsoleFontEx(std_output, FALSE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetCurrentConsoleFontEx(std_output, TRUE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 
     cfix.cbSize = sizeof(CONSOLE_FONT_INFOEX);
 
     SetLastError(0xdeadbeef);
     ret = pGetCurrentConsoleFontEx(NULL, FALSE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetCurrentConsoleFontEx(NULL, TRUE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetCurrentConsoleFontEx(std_input, FALSE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetCurrentConsoleFontEx(std_input, TRUE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     CreatePipe(&pipe1, &pipe2, NULL, 0);
     memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
     SetLastError(0xdeadbeef);
     ret = pGetCurrentConsoleFontEx(pipe1, TRUE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
     CloseHandle(pipe1);
     CloseHandle(pipe2);
 
     SetLastError(0xdeadbeef);
     ret = pGetCurrentConsoleFontEx(std_output, FALSE, &cfix);
     ok(ret, "got %d, expected non-zero\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "got %lu, expected 0xdeadbeef\n", GetLastError());
 
     memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
     SetLastError(0xdeadbeef);
     ret = GetCurrentConsoleFont(std_output, FALSE, &cfi);
     ok(ret, "got %d, expected non-zero\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "got %lu, expected 0xdeadbeef\n", GetLastError());
 
     ok(cfix.dwFontSize.X == cfi.dwFontSize.X, "expected values to match\n");
     ok(cfix.dwFontSize.Y == cfi.dwFontSize.Y, "expected values to match\n");
 
     SetLastError(0xdeadbeef);
     c = GetConsoleFontSize(std_output, cfix.nFont);
-    ok(c.X && c.Y, "GetConsoleFontSize failed; err = %u\n", GetLastError());
-    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+    ok(c.X && c.Y, "GetConsoleFontSize failed; err = %lu\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "got %lu, expected 0xdeadbeef\n", GetLastError());
 
     ok(cfix.dwFontSize.X == c.X, "Font width doesn't match; got %u, expected %u\n",
        cfix.dwFontSize.X, c.X);
@@ -3544,13 +3544,13 @@ static void test_GetCurrentConsoleFontEx(HANDLE std_output)
     SetLastError(0xdeadbeef);
     ret = pGetCurrentConsoleFontEx(std_output, TRUE, &cfix);
     ok(ret, "got %d, expected non-zero\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "got %lu, expected 0xdeadbeef\n", GetLastError());
 
     memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
     SetLastError(0xdeadbeef);
     ret = GetCurrentConsoleFont(std_output, TRUE, &cfi);
     ok(ret, "got %d, expected non-zero\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "got %lu, expected 0xdeadbeef\n", GetLastError());
 
     ok(cfix.dwFontSize.X == cfi.dwFontSize.X, "expected values to match\n");
     ok(cfix.dwFontSize.Y == cfi.dwFontSize.Y, "expected values to match\n");
@@ -3574,18 +3574,18 @@ static void test_SetCurrentConsoleFontEx(HANDLE std_output)
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(NULL, FALSE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(NULL, TRUE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 
     CreatePipe(&pipe1, &pipe2, NULL, 0);
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(pipe1, FALSE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
     CloseHandle(pipe1);
     CloseHandle(pipe2);
 
@@ -3593,47 +3593,47 @@ static void test_SetCurrentConsoleFontEx(HANDLE std_output)
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(pipe1, TRUE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
     CloseHandle(pipe1);
     CloseHandle(pipe2);
 
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(std_input, FALSE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(std_input, TRUE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(std_output, FALSE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(std_output, TRUE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 
     cfix = orig_cfix;
 
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(NULL, FALSE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(NULL, TRUE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     CreatePipe(&pipe1, &pipe2, NULL, 0);
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(pipe1, FALSE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
     CloseHandle(pipe1);
     CloseHandle(pipe2);
 
@@ -3641,35 +3641,35 @@ static void test_SetCurrentConsoleFontEx(HANDLE std_output)
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(pipe1, TRUE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
     CloseHandle(pipe1);
     CloseHandle(pipe2);
 
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(std_input, FALSE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(std_input, TRUE, &cfix);
     ok(!ret, "got %d, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(std_output, FALSE, &cfix);
     ok(ret, "got %d, expected non-zero\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "got %lu, expected 0xdeadbeef\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(std_output, TRUE, &cfix);
     ok(ret, "got %d, expected non-zero\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "got %lu, expected 0xdeadbeef\n", GetLastError());
 
     /* Restore original console font parameters */
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(std_output, FALSE, &orig_cfix);
     ok(ret, "got %d, expected non-zero\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "got %lu, expected 0xdeadbeef\n", GetLastError());
 }
 
 static void test_GetConsoleFontSize(HANDLE std_output)
@@ -3687,14 +3687,14 @@ static void test_GetConsoleFontSize(HANDLE std_output)
     memset(&c, 10, sizeof(COORD));
     SetLastError(0xdeadbeef);
     c = GetConsoleFontSize(NULL, index);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
     ok(!c.X, "got %d, expected 0\n", c.X);
     ok(!c.Y, "got %d, expected 0\n", c.Y);
 
     memset(&c, 10, sizeof(COORD));
     SetLastError(0xdeadbeef);
     c = GetConsoleFontSize(GetStdHandle(STD_INPUT_HANDLE), index);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
     ok(!c.X, "got %d, expected 0\n", c.X);
     ok(!c.Y, "got %d, expected 0\n", c.Y);
 
@@ -3702,7 +3702,7 @@ static void test_GetConsoleFontSize(HANDLE std_output)
     memset(&c, 10, sizeof(COORD));
     SetLastError(0xdeadbeef);
     c = GetConsoleFontSize(pipe1, index);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
     ok(!c.X, "got %d, expected 0\n", c.X);
     ok(!c.Y, "got %d, expected 0\n", c.Y);
     CloseHandle(pipe1);
@@ -3712,13 +3712,13 @@ static void test_GetConsoleFontSize(HANDLE std_output)
     memset(&c, 10, sizeof(COORD));
     SetLastError(0xdeadbeef);
     c = GetConsoleFontSize(std_output, cfi.nFont);
-    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "got %lu, expected 0xdeadbeef\n", GetLastError());
     GetClientRect(GetConsoleWindow(), &r);
     GetConsoleScreenBufferInfo(std_output, &csbi);
     font_width = (r.right - r.left) / (csbi.srWindow.Right - csbi.srWindow.Left + 1);
     font_height = (r.bottom - r.top) / (csbi.srWindow.Bottom - csbi.srWindow.Top + 1);
-    ok(c.X == font_width, "got %d, expected %d\n", c.X, font_width);
-    ok(c.Y == font_height, "got %d, expected %d\n", c.Y, font_height);
+    ok(c.X == font_width, "got %d, expected %ld\n", c.X, font_width);
+    ok(c.Y == font_height, "got %d, expected %ld\n", c.Y, font_height);
 
     hmod = GetModuleHandleA("kernel32.dll");
     pGetNumberOfConsoleFonts = (void *)GetProcAddress(hmod, "GetNumberOfConsoleFonts");
@@ -3733,7 +3733,7 @@ static void test_GetConsoleFontSize(HANDLE std_output)
     SetLastError(0xdeadbeef);
     c = GetConsoleFontSize(std_output, index);
     ok(GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef) /* win10 1809 */,
-        "unexpected last error %u\n", GetLastError());
+        "unexpected last error %lu\n", GetLastError());
     if (GetLastError() == ERROR_INVALID_PARAMETER)
     {
         ok(!c.X, "got %d, expected 0\n", c.X);
@@ -3758,14 +3758,14 @@ static void test_GetLargestConsoleWindowSize(HANDLE std_output)
     memset(&c, 10, sizeof(COORD));
     SetLastError(0xdeadbeef);
     c = GetLargestConsoleWindowSize(NULL);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
     ok(!c.X, "got %d, expected 0\n", c.X);
     ok(!c.Y, "got %d, expected 0\n", c.Y);
 
     memset(&c, 10, sizeof(COORD));
     SetLastError(0xdeadbeef);
     c = GetLargestConsoleWindowSize(GetStdHandle(STD_INPUT_HANDLE));
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
     ok(!c.X, "got %d, expected 0\n", c.X);
     ok(!c.Y, "got %d, expected 0\n", c.Y);
 
@@ -3773,7 +3773,7 @@ static void test_GetLargestConsoleWindowSize(HANDLE std_output)
     memset(&c, 10, sizeof(COORD));
     SetLastError(0xdeadbeef);
     c = GetLargestConsoleWindowSize(pipe1);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
     ok(!c.X, "got %d, expected 0\n", c.X);
     ok(!c.Y, "got %d, expected 0\n", c.Y);
     CloseHandle(pipe1);
@@ -3806,16 +3806,16 @@ static void test_GetLargestConsoleWindowSize(HANDLE std_output)
         memset(&c, 10, sizeof(COORD));
         SetLastError(0xdeadbeef);
         c = GetLargestConsoleWindowSize(std_output);
-        ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+        ok(GetLastError() == 0xdeadbeef, "got %lu, expected 0xdeadbeef\n", GetLastError());
         GetCurrentConsoleFont(std_output, FALSE, &cfi);
         font = GetConsoleFontSize(std_output, cfi.nFont);
         maxcon_w = workarea_w / font.X;
         maxcon_h = workarea_h / font.Y;
-        ok(c.X == maxcon_w || c.X == maxcon_w - 1 /* Win10 */, "got %d, expected %d\n", c.X, maxcon_w);
-        ok(c.Y == maxcon_h || c.Y == maxcon_h - 1 /* Win10 */, "got %d, expected %d\n", c.Y, maxcon_h);
+        ok(c.X == maxcon_w || c.X == maxcon_w - 1 /* Win10 */, "got %d, expected %ld\n", c.X, maxcon_w);
+        ok(c.Y == maxcon_h || c.Y == maxcon_h - 1 /* Win10 */, "got %d, expected %ld\n", c.Y, maxcon_h);
 
         ret = GetConsoleScreenBufferInfo(std_output, &sbi);
-        ok(ret, "GetConsoleScreenBufferInfo failed %u\n", GetLastError());
+        ok(ret, "GetConsoleScreenBufferInfo failed %lu\n", GetLastError());
         ok(sbi.dwMaximumWindowSize.X == min(c.X, sbi.dwSize.X), "got %d, expected %d\n",
            sbi.dwMaximumWindowSize.X, min(c.X, sbi.dwSize.X));
         ok(sbi.dwMaximumWindowSize.Y == min(c.Y, sbi.dwSize.Y), "got %d, expected %d\n",
@@ -3873,17 +3873,17 @@ static void test_GetConsoleFontInfo(HANDLE std_output)
         HeapFree(GetProcessHeap(), 0, cfi);
         return;
     }
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetConsoleFontInfo(GetStdHandle(STD_INPUT_HANDLE), FALSE, 0, cfi);
     ok(!ret, "got %d, expected zero\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetConsoleFontInfo(std_output, FALSE, 0, cfi);
     ok(!ret, "got %d, expected zero\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "got %lu, expected 0xdeadbeef\n", GetLastError());
 
     GetConsoleScreenBufferInfo(std_output, &csbi);
     win_width = csbi.srWindow.Right - csbi.srWindow.Left + 1;
@@ -3903,7 +3903,7 @@ static void test_GetConsoleFontInfo(HANDLE std_output)
 
     for (i = 0; i < num_fonts; i++)
     {
-        ok(cfi[i].nFont == i, "element out of order, got nFont %d, expected %d\n", cfi[i].nFont, i);
+        ok(cfi[i].nFont == i, "element out of order, got nFont %ld, expected %ld\n", cfi[i].nFont, i);
         tmp_font = GetConsoleFontSize(std_output, cfi[i].nFont);
         tmp_w = (double)orig_font.X / tmp_font.X * win_width;
         tmp_h = (double)orig_font.Y / tmp_font.Y * win_height;
@@ -3914,17 +3914,17 @@ static void test_GetConsoleFontInfo(HANDLE std_output)
     SetLastError(0xdeadbeef);
     ret = pGetConsoleFontInfo(NULL, TRUE, 0, cfi);
     ok(!ret, "got %d, expected zero\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetConsoleFontInfo(GetStdHandle(STD_INPUT_HANDLE), TRUE, 0, cfi);
     ok(!ret, "got %d, expected zero\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetConsoleFontInfo(std_output, TRUE, 0, cfi);
     ok(!ret, "got %d, expected zero\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "got %lu, expected 0xdeadbeef\n", GetLastError());
 
     memset(cfi, 0, memsize);
     ret = pGetConsoleFontInfo(std_output, TRUE, num_fonts, cfi);
@@ -3936,7 +3936,7 @@ static void test_GetConsoleFontInfo(HANDLE std_output)
 
     for (i = 0; i < num_fonts; i++)
     {
-        ok(cfi[i].nFont == i, "element out of order, got nFont %d, expected %d\n", cfi[i].nFont, i);
+        ok(cfi[i].nFont == i, "element out of order, got nFont %ld, expected %ld\n", cfi[i].nFont, i);
         tmp_font = GetConsoleFontSize(std_output, cfi[i].nFont);
         tmp_w = (double)orig_font.X / tmp_font.X * csbi.dwMaximumWindowSize.X;
         tmp_h = (double)orig_font.Y / tmp_font.Y * csbi.dwMaximumWindowSize.Y;
@@ -3973,12 +3973,12 @@ static void test_SetConsoleFont(HANDLE std_output)
         skip("SetConsoleFont is not implemented\n");
         return;
     }
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pSetConsoleFont(GetStdHandle(STD_INPUT_HANDLE), 0);
     ok(!ret, "got %d, expected zero\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     pGetNumberOfConsoleFonts = (void *)GetProcAddress(hmod, "GetNumberOfConsoleFonts");
     if (!pGetNumberOfConsoleFonts)
@@ -3992,7 +3992,7 @@ static void test_SetConsoleFont(HANDLE std_output)
     SetLastError(0xdeadbeef);
     ret = pSetConsoleFont(std_output, num_fonts);
     ok(!ret, "got %d, expected zero\n", ret);
-    todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 }
 
 static void test_GetConsoleScreenBufferInfoEx(HANDLE std_output)
@@ -4015,42 +4015,42 @@ static void test_GetConsoleScreenBufferInfoEx(HANDLE std_output)
     SetLastError(0xdeadbeef);
     ret = pGetConsoleScreenBufferInfoEx(NULL, &csbix);
     ok(!ret, "got %d, expected zero\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetConsoleScreenBufferInfoEx(std_input, &csbix);
     ok(!ret, "got %d, expected zero\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetConsoleScreenBufferInfoEx(std_output, &csbix);
     ok(!ret, "got %d, expected zero\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 
     csbix.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);
 
     SetLastError(0xdeadbeef);
     ret = pGetConsoleScreenBufferInfoEx(NULL, &csbix);
     ok(!ret, "got %d, expected zero\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetConsoleScreenBufferInfoEx(std_input, &csbix);
     ok(!ret, "got %d, expected zero\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     CreatePipe(&pipe1, &pipe2, NULL, 0);
     SetLastError(0xdeadbeef);
     ret = pGetConsoleScreenBufferInfoEx(std_input, &csbix);
     ok(!ret, "got %d, expected zero\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
     CloseHandle(pipe1);
     CloseHandle(pipe2);
 
     SetLastError(0xdeadbeef);
     ret = pGetConsoleScreenBufferInfoEx(std_output, &csbix);
     ok(ret, "got %d, expected non-zero\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "got %lu, expected 0xdeadbeef\n", GetLastError());
 }
 
 static void test_FreeConsole(void)
@@ -4066,7 +4066,7 @@ static void test_FreeConsole(void)
     ok(RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle != NULL, "ConsoleHandle is NULL\n");
     ok(!SetConsoleCtrlHandler(mydummych, FALSE), "dummy ctrl handler shouldn't be set\n");
     ret = SetConsoleCtrlHandler(mydummych, TRUE);
-    ok(ret, "SetConsoleCtrlHandler failed: %u\n", GetLastError());
+    ok(ret, "SetConsoleCtrlHandler failed: %lu\n", GetLastError());
     if (!skip_nt)
     {
         unbound_input  = create_unbound_handle(FALSE, TRUE);
@@ -4074,7 +4074,7 @@ static void test_FreeConsole(void)
     }
 
     ret = FreeConsole();
-    ok(ret, "FreeConsole failed: %u\n", GetLastError());
+    ok(ret, "FreeConsole failed: %lu\n", GetLastError());
 
     ok(RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle == NULL, "ConsoleHandle = %p\n",
        RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle);
@@ -4082,67 +4082,67 @@ static void test_FreeConsole(void)
     handle = CreateFileA("CONOUT$", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
     ok(handle == INVALID_HANDLE_VALUE &&
        (GetLastError() == ERROR_INVALID_HANDLE || broken(GetLastError() == ERROR_ACCESS_DENIED /* winxp */)),
-       "CreateFileA failed: %u\n", GetLastError());
+       "CreateFileA failed: %lu\n", GetLastError());
 
     handle = CreateFileA("CONIN$", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
     ok(handle == INVALID_HANDLE_VALUE &&
        (GetLastError() == ERROR_INVALID_HANDLE || broken(GetLastError() == ERROR_ACCESS_DENIED /* winxp */)),
-       "CreateFileA failed: %u\n", GetLastError());
+       "CreateFileA failed: %lu\n", GetLastError());
 
     handle = CreateFileA("CON", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
     ok(handle == INVALID_HANDLE_VALUE &&
        (GetLastError() == ERROR_INVALID_HANDLE || broken(GetLastError() == ERROR_ACCESS_DENIED /* winxp */)),
-       "CreateFileA failed: %u\n", GetLastError());
+       "CreateFileA failed: %lu\n", GetLastError());
 
     handle = CreateFileA("CON", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
     ok(handle == INVALID_HANDLE_VALUE &&
        (GetLastError() == ERROR_INVALID_HANDLE || broken(GetLastError() == ERROR_FILE_NOT_FOUND /* winxp */)),
-       "CreateFileA failed: %u\n", GetLastError());
+       "CreateFileA failed: %lu\n", GetLastError());
 
     handle = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE,
                                        FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
                                        CONSOLE_TEXTMODE_BUFFER, NULL);
     ok(handle == INVALID_HANDLE_VALUE && GetLastError() == ERROR_INVALID_HANDLE,
-       "CreateConsoleScreenBuffer returned: %p (%u)\n", handle, GetLastError());
+       "CreateConsoleScreenBuffer returned: %p (%lu)\n", handle, GetLastError());
 
     SetLastError(0xdeadbeef);
     cp = GetConsoleCP();
     ok(!cp, "cp = %x\n", cp);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "last error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "last error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     cp = GetConsoleOutputCP();
     ok(!cp, "cp = %x\n", cp);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "last error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "last error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = SetConsoleCP(GetOEMCP());
-    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "SetConsoleCP returned %x(%u)\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "SetConsoleCP returned %x(%lu)\n", ret, GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = SetConsoleOutputCP(GetOEMCP());
-    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "SetConsoleCP returned %x(%u)\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "SetConsoleCP returned %x(%lu)\n", ret, GetLastError());
 
     if (skip_nt) return;
 
     SetLastError(0xdeadbeef);
     memset( title, 0xc0, sizeof(title) );
     size = GetConsoleTitleW( title, ARRAY_SIZE(title) );
-    ok(!size, "GetConsoleTitleW returned %u\n", size);
+    ok(!size, "GetConsoleTitleW returned %lu\n", size);
     ok(title[0] == 0xc0c0, "title byffer changed\n");
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "last error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "last error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = SetConsoleTitleW( L"test" );
-    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "SetConsoleTitleW returned %x(%u)\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "SetConsoleTitleW returned %x(%lu)\n", ret, GetLastError());
 
     SetLastError(0xdeadbeef);
     hwnd = GetConsoleWindow();
     ok(!hwnd, "hwnd = %p\n", hwnd);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "last error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "last error %lu\n", GetLastError());
 
     ret = GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
-    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "GenerateConsoleCtrlEvent returned %x(%u)\n",
+    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "GenerateConsoleCtrlEvent returned %x(%lu)\n",
        ret, GetLastError());
 
     SetStdHandle( STD_INPUT_HANDLE, (HANDLE)0xdeadbeef );
@@ -4154,27 +4154,27 @@ static void test_FreeConsole(void)
 
     ret = ReadFile(unbound_input, buf, sizeof(buf), &size, NULL);
     ok(!ret && GetLastError() == ERROR_INVALID_HANDLE,
-       "ReadFile returned %x %u\n", ret, GetLastError());
+       "ReadFile returned %x %lu\n", ret, GetLastError());
 
     ret = FlushFileBuffers(unbound_input);
     ok(!ret && GetLastError() == ERROR_INVALID_HANDLE,
-       "ReadFile returned %x %u\n", ret, GetLastError());
+       "ReadFile returned %x %lu\n", ret, GetLastError());
 
     ret = WriteFile(unbound_input, "test", 4, &size, NULL);
     ok(!ret && GetLastError() == ERROR_INVALID_HANDLE,
-       "ReadFile returned %x %u\n", ret, GetLastError());
+       "ReadFile returned %x %lu\n", ret, GetLastError());
 
     ret = GetConsoleMode(unbound_input, &mode);
     ok(!ret && GetLastError() == ERROR_INVALID_HANDLE,
-       "GetConsoleMode returned %x %u\n", ret, GetLastError());
+       "GetConsoleMode returned %x %lu\n", ret, GetLastError());
     ret = GetConsoleMode(unbound_output, &mode);
     ok(!ret && GetLastError() == ERROR_INVALID_HANDLE,
-       "GetConsoleMode returned %x %u\n", ret, GetLastError());
+       "GetConsoleMode returned %x %lu\n", ret, GetLastError());
 
     type = GetFileType(unbound_input);
-    ok(type == FILE_TYPE_CHAR, "GetFileType returned %u\n", type);
+    ok(type == FILE_TYPE_CHAR, "GetFileType returned %lu\n", type);
     type = GetFileType(unbound_output);
-    ok(type == FILE_TYPE_CHAR, "GetFileType returned %u\n", type);
+    ok(type == FILE_TYPE_CHAR, "GetFileType returned %lu\n", type);
 
     todo_wine
     ok(!SetConsoleCtrlHandler(mydummych, FALSE), "FreeConsole() should have reset ctrl handlers' list\n");
@@ -4208,24 +4208,24 @@ static void test_SetConsoleScreenBufferInfoEx(HANDLE std_output)
     SetLastError(0xdeadbeef);
     ret = pSetConsoleScreenBufferInfoEx(NULL, &info);
     ok(!ret, "got %d, expected zero\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %lu, expected 6\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pSetConsoleScreenBufferInfoEx(std_output, &info);
     ok(ret, "got %d, expected one\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "got %lu, expected 0xdeadbeef\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pSetConsoleScreenBufferInfoEx(std_input, &info);
     ok(!ret, "got %d, expected zero\n", ret);
     ok(GetLastError() == ERROR_INVALID_HANDLE || GetLastError() == ERROR_ACCESS_DENIED,
-            "got %u, expected 5 or 6\n", GetLastError());
+            "got %lu, expected 5 or 6\n", GetLastError());
 
     info.cbSize = 0;
     SetLastError(0xdeadbeef);
     ret = pSetConsoleScreenBufferInfoEx(std_output, &info);
     ok(!ret, "got %d, expected zero\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %lu, expected 87\n", GetLastError());
 
     CloseHandle(std_input);
 }
@@ -4236,20 +4236,20 @@ static void test_console_title(void)
     BOOL ret;
 
     ret = SetConsoleTitleW(L"test");
-    ok(ret, "SetConsoleTitleW failed: %u\n", GetLastError());
+    ok(ret, "SetConsoleTitleW failed: %lu\n", GetLastError());
 
     ret = GetConsoleTitleW(buf, ARRAY_SIZE(buf));
-    ok(ret, "GetConsoleTitleW failed: %u\n", GetLastError());
+    ok(ret, "GetConsoleTitleW failed: %lu\n", GetLastError());
     ok(!wcscmp(buf, L"test"), "title = %s\n", wine_dbgstr_w(buf));
 
     if (!skip_nt)
     {
         ret = GetConsoleTitleW(buf, 2);
-        ok(ret, "GetConsoleTitleW failed: %u\n", GetLastError());
+        ok(ret, "GetConsoleTitleW failed: %lu\n", GetLastError());
         ok(!wcscmp(buf, L"t"), "title = %s\n", wine_dbgstr_w(buf));
 
         ret = GetConsoleTitleW(buf, 4);
-        ok(ret, "GetConsoleTitleW failed: %u\n", GetLastError());
+        ok(ret, "GetConsoleTitleW failed: %lu\n", GetLastError());
         ok(!wcscmp(buf, L"tes"), "title = %s\n", wine_dbgstr_w(buf));
     }
 }
@@ -4267,35 +4267,35 @@ static void test_file_info(HANDLE input, HANDLE output)
     if (skip_nt) return;
 
     status = NtQueryInformationFile(input, &io, &std_info, sizeof(std_info), FileStandardInformation);
-    ok(status == STATUS_INVALID_DEVICE_REQUEST, "NtQueryInformationFile returned: %#x\n", status);
+    ok(status == STATUS_INVALID_DEVICE_REQUEST, "NtQueryInformationFile returned: %#lx\n", status);
 
     status = NtQueryInformationFile(output, &io, &std_info, sizeof(std_info), FileStandardInformation);
-    ok(status == STATUS_INVALID_DEVICE_REQUEST, "NtQueryInformationFile returned: %#x\n", status);
+    ok(status == STATUS_INVALID_DEVICE_REQUEST, "NtQueryInformationFile returned: %#lx\n", status);
 
     ret = GetFileSizeEx(input, &size);
     ok(!ret && GetLastError() == ERROR_INVALID_FUNCTION,
-       "GetFileSizeEx returned %x(%u)\n", ret, GetLastError());
+       "GetFileSizeEx returned %x(%lu)\n", ret, GetLastError());
 
     ret = GetFileSizeEx(output, &size);
     ok(!ret && GetLastError() == ERROR_INVALID_FUNCTION,
-       "GetFileSizeEx returned %x(%u)\n", ret, GetLastError());
+       "GetFileSizeEx returned %x(%lu)\n", ret, GetLastError());
 
     status = NtQueryVolumeInformationFile(input, &io, &fs_info, sizeof(fs_info), FileFsDeviceInformation);
-    ok(!status, "NtQueryVolumeInformationFile failed: %#x\n", status);
-    ok(fs_info.DeviceType == FILE_DEVICE_CONSOLE, "DeviceType = %u\n", fs_info.DeviceType);
+    ok(!status, "NtQueryVolumeInformationFile failed: %#lx\n", status);
+    ok(fs_info.DeviceType == FILE_DEVICE_CONSOLE, "DeviceType = %lu\n", fs_info.DeviceType);
     ok(fs_info.Characteristics == FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL,
-       "Characteristics = %x\n", fs_info.Characteristics);
+       "Characteristics = %lx\n", fs_info.Characteristics);
 
     status = NtQueryVolumeInformationFile(output, &io, &fs_info, sizeof(fs_info), FileFsDeviceInformation);
-    ok(!status, "NtQueryVolumeInformationFile failed: %#x\n", status);
-    ok(fs_info.DeviceType == FILE_DEVICE_CONSOLE, "DeviceType = %u\n", fs_info.DeviceType);
+    ok(!status, "NtQueryVolumeInformationFile failed: %#lx\n", status);
+    ok(fs_info.DeviceType == FILE_DEVICE_CONSOLE, "DeviceType = %lu\n", fs_info.DeviceType);
     ok(fs_info.Characteristics == FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL,
-       "Characteristics = %x\n", fs_info.Characteristics);
+       "Characteristics = %lx\n", fs_info.Characteristics);
 
     type = GetFileType(input);
-    ok(type == FILE_TYPE_CHAR, "GetFileType returned %u\n", type);
+    ok(type == FILE_TYPE_CHAR, "GetFileType returned %lu\n", type);
     type = GetFileType(output);
-    ok(type == FILE_TYPE_CHAR, "GetFileType returned %u\n", type);
+    ok(type == FILE_TYPE_CHAR, "GetFileType returned %lu\n", type);
 }
 
 static void test_AttachConsole_child(DWORD console_pid)
@@ -4308,15 +4308,15 @@ static void test_AttachConsole_child(DWORD console_pid)
     BOOL res;
 
     res = CreatePipe(&pipe_in, &pipe_out, NULL, 0);
-    ok(res, "CreatePipe failed: %u\n", GetLastError());
+    ok(res, "CreatePipe failed: %lu\n", GetLastError());
 
     res = AttachConsole(console_pid);
     ok(!res && GetLastError() == ERROR_ACCESS_DENIED,
-       "AttachConsole returned: %x(%u)\n", res, GetLastError());
+       "AttachConsole returned: %x(%lu)\n", res, GetLastError());
 
     ok(RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle != NULL, "ConsoleHandle is NULL\n");
     res = FreeConsole();
-    ok(res, "FreeConsole failed: %u\n", GetLastError());
+    ok(res, "FreeConsole failed: %lu\n", GetLastError());
     ok(RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle == NULL, "ConsoleHandle = %p\n",
        RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle);
 
@@ -4324,10 +4324,10 @@ static void test_AttachConsole_child(DWORD console_pid)
 
     ok(!SetConsoleCtrlHandler(mydummych, FALSE), "dummy ctrl handler shouldn't be set\n");
     res = SetConsoleCtrlHandler(mydummych, TRUE);
-    ok(res, "SetConsoleCtrlHandler failed: %u\n", GetLastError());
+    ok(res, "SetConsoleCtrlHandler failed: %lu\n", GetLastError());
 
     res = AttachConsole(console_pid);
-    ok(res, "AttachConsole failed: %u\n", GetLastError());
+    ok(res, "AttachConsole failed: %lu\n", GetLastError());
 
     ok(pipe_out != GetStdHandle(STD_ERROR_HANDLE), "std handle not set to console\n");
     ok(RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle != NULL, "ConsoleHandle is NULL\n");
@@ -4336,21 +4336,21 @@ static void test_AttachConsole_child(DWORD console_pid)
     ok(console != INVALID_HANDLE_VALUE, "Could not open console\n");
 
     res = ReadConsoleOutputCharacterA(console, buf, 6, c, &len);
-    ok(res, "ReadConsoleOutputCharacterA failed: %u\n", GetLastError());
-    ok(len == 6, "len = %u\n", len);
+    ok(res, "ReadConsoleOutputCharacterA failed: %lu\n", GetLastError());
+    ok(len == 6, "len = %lu\n", len);
     ok(!memcmp(buf, "Parent", 6), "Unexpected console output\n");
 
     todo_wine
     ok(!SetConsoleCtrlHandler(mydummych, FALSE), "AttachConsole() should have reset ctrl handlers' list\n");
 
     res = FreeConsole();
-    ok(res, "FreeConsole failed: %u\n", GetLastError());
+    ok(res, "FreeConsole failed: %lu\n", GetLastError());
 
     SetStdHandle(STD_INPUT_HANDLE, pipe_in);
     SetStdHandle(STD_OUTPUT_HANDLE, pipe_out);
 
     res = AttachConsole(ATTACH_PARENT_PROCESS);
-    ok(res, "AttachConsole failed: %u\n", GetLastError());
+    ok(res, "AttachConsole failed: %lu\n", GetLastError());
 
     if (pGetConsoleProcessList)
     {
@@ -4359,14 +4359,14 @@ static void test_AttachConsole_child(DWORD console_pid)
 
         SetLastError(0xdeadbeef);
         len = pGetConsoleProcessList(list, 1);
-        ok(len == 2, "Expected 2 processes, got %d\n", len);
-        ok(list[0] == 0xbabebabe, "Unexpected value in list %u\n", list[0]);
+        ok(len == 2, "Expected 2 processes, got %ld\n", len);
+        ok(list[0] == 0xbabebabe, "Unexpected value in list %lu\n", list[0]);
 
         len = pGetConsoleProcessList(list, 2);
-        ok(len == 2, "Expected 2 processes, got %d\n", len);
+        ok(len == 2, "Expected 2 processes, got %ld\n", len);
         ok(list[0] == console_pid || list[1] == console_pid, "Parent PID not in list\n");
         ok(list[0] == pid || list[1] == pid, "PID not in list\n");
-        ok(GetLastError() == 0xdeadbeef, "Unexpected last error: %u\n", GetLastError());
+        ok(GetLastError() == 0xdeadbeef, "Unexpected last error: %lu\n", GetLastError());
     }
 
     ok(pipe_in != GetStdHandle(STD_INPUT_HANDLE), "std handle not set to console\n");
@@ -4376,15 +4376,15 @@ static void test_AttachConsole_child(DWORD console_pid)
     ok(console != INVALID_HANDLE_VALUE, "Could not open console\n");
 
     res = ReadConsoleOutputCharacterA(console, buf, 6, c, &len);
-    ok(res, "ReadConsoleOutputCharacterA failed: %u\n", GetLastError());
-    ok(len == 6, "len = %u\n", len);
+    ok(res, "ReadConsoleOutputCharacterA failed: %lu\n", GetLastError());
+    ok(len == 6, "len = %lu\n", len);
     ok(!memcmp(buf, "Parent", 6), "Unexpected console output\n");
 
     simple_write_console(console, "Child");
     CloseHandle(console);
 
     res = FreeConsole();
-    ok(res, "FreeConsole failed: %u\n", GetLastError());
+    ok(res, "FreeConsole failed: %lu\n", GetLastError());
 
     res = CloseHandle(pipe_in);
     ok(res, "pipe_in is no longer valid\n");
@@ -4404,17 +4404,17 @@ static void test_AttachConsole(HANDLE console)
     simple_write_console(console, "Parent console");
 
     winetest_get_mainargs(&argv);
-    sprintf(buf, "\"%s\" console attach_console %x", argv[0], GetCurrentProcessId());
+    sprintf(buf, "\"%s\" console attach_console %lx", argv[0], GetCurrentProcessId());
     res = CreateProcessA(NULL, buf, NULL, NULL, TRUE, 0, NULL, NULL, &si, &info);
-    ok(res, "CreateProcess failed: %u\n", GetLastError());
+    ok(res, "CreateProcess failed: %lu\n", GetLastError());
     CloseHandle(info.hThread);
 
     wait_child_process(info.hProcess);
     CloseHandle(info.hProcess);
 
     res = ReadConsoleOutputCharacterA(console, buf, 5, c, &len);
-    ok(res, "ReadConsoleOutputCharacterA failed: %u\n", GetLastError());
-    ok(len == 5, "len = %u\n", len);
+    ok(res, "ReadConsoleOutputCharacterA failed: %lu\n", GetLastError());
+    ok(len == 5, "len = %lu\n", len);
     ok(!memcmp(buf, "Child", 5), "Unexpected console output\n");
 }
 
@@ -4431,16 +4431,16 @@ static void test_AllocConsole_child(void)
     prev_output = GetStdHandle(STD_OUTPUT_HANDLE);
     res = DuplicateHandle(GetCurrentProcess(), prev_output, GetCurrentProcess(), &unbound_output,
                           0, FALSE, DUPLICATE_SAME_ACCESS);
-    ok(res, "DuplicateHandle failed: %u\n", GetLastError());
+    ok(res, "DuplicateHandle failed: %lu\n", GetLastError());
 
     res = GetConsoleMode(unbound_output, &mode);
-    ok(res, "GetConsoleMode failed: %u\n", GetLastError());
+    ok(res, "GetConsoleMode failed: %lu\n", GetLastError());
 
     prev_error = GetStdHandle(STD_ERROR_HANDLE);
     if (si.dwFlags & STARTF_USESTDHANDLES)
     {
         res = GetConsoleMode(prev_error, &mode);
-        ok(!res && GetLastError() == ERROR_INVALID_HANDLE, "GetConsoleMode failed: %u\n", GetLastError());
+        ok(!res && GetLastError() == ERROR_INVALID_HANDLE, "GetConsoleMode failed: %lu\n", GetLastError());
     }
 
     FreeConsole();
@@ -4448,13 +4448,13 @@ static void test_AllocConsole_child(void)
     ok(GetStdHandle(STD_OUTPUT_HANDLE) == prev_output, "GetStdHandle(STD_OUTPUT_HANDLE) = %p\n", GetStdHandle(STD_OUTPUT_HANDLE));
     ok(GetStdHandle(STD_ERROR_HANDLE) == prev_error, "GetStdHandle(STD_ERROR_HANDLE) = %p\n", GetStdHandle(STD_ERROR_HANDLE));
     res = GetConsoleMode(unbound_output, &mode);
-    ok(!res && GetLastError() == ERROR_INVALID_HANDLE, "GetConsoleMode failed: %u\n", GetLastError());
+    ok(!res && GetLastError() == ERROR_INVALID_HANDLE, "GetConsoleMode failed: %lu\n", GetLastError());
 
     ok(!SetConsoleCtrlHandler(mydummych, FALSE), "dummy ctrl handler shouldn't be set\n");
     res = SetConsoleCtrlHandler(mydummych, TRUE);
-    ok(res, "SetConsoleCtrlHandler failed: %u\n", GetLastError());
+    ok(res, "SetConsoleCtrlHandler failed: %lu\n", GetLastError());
     res = AllocConsole();
-    ok(res, "AllocConsole failed: %u\n", GetLastError());
+    ok(res, "AllocConsole failed: %lu\n", GetLastError());
 
     if (si.dwFlags & STARTF_USESTDHANDLES)
     {
@@ -4463,7 +4463,7 @@ static void test_AllocConsole_child(void)
     }
 
     res = GetConsoleMode(unbound_output, &mode);
-    ok(res, "GetConsoleMode failed: %u\n", GetLastError());
+    ok(res, "GetConsoleMode failed: %lu\n", GetLastError());
 
     todo_wine
     ok(!SetConsoleCtrlHandler(mydummych, FALSE), "AllocConsole() should have reset ctrl handlers' list\n");
@@ -4472,20 +4472,20 @@ static void test_AllocConsole_child(void)
     SetStdHandle(STD_OUTPUT_HANDLE, NULL);
     SetStdHandle(STD_ERROR_HANDLE, NULL);
     res = AllocConsole();
-    ok(res, "AllocConsole failed: %u\n", GetLastError());
+    ok(res, "AllocConsole failed: %lu\n", GetLastError());
 
     ok(GetStdHandle(STD_OUTPUT_HANDLE) != NULL, "GetStdHandle(STD_OUTPUT_HANDLE) = %p\n", GetStdHandle(STD_OUTPUT_HANDLE));
     ok(GetStdHandle(STD_ERROR_HANDLE) != NULL, "GetStdHandle(STD_ERROR_HANDLE) = %p\n", GetStdHandle(STD_ERROR_HANDLE));
 
     res = GetConsoleMode(unbound_output, &mode);
-    ok(res, "GetConsoleMode failed: %u\n", GetLastError());
+    ok(res, "GetConsoleMode failed: %lu\n", GetLastError());
     res = GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), &mode);
-    ok(res, "GetConsoleMode failed: %u\n", GetLastError());
+    ok(res, "GetConsoleMode failed: %lu\n", GetLastError());
     res = GetConsoleMode(GetStdHandle(STD_ERROR_HANDLE), &mode);
-    ok(res, "GetConsoleMode failed: %u\n", GetLastError());
+    ok(res, "GetConsoleMode failed: %lu\n", GetLastError());
 
     res = CloseHandle(unbound_output);
-    ok(res, "CloseHandle failed: %u\n", GetLastError());
+    ok(res, "CloseHandle failed: %lu\n", GetLastError());
 }
 
 static void test_AllocConsole(void)
@@ -4502,18 +4502,18 @@ static void test_AllocConsole(void)
     winetest_get_mainargs(&argv);
     sprintf(buf, "\"%s\" console alloc_console", argv[0]);
     res = CreateProcessA(NULL, buf, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &info);
-    ok(res, "CreateProcess failed: %u\n", GetLastError());
+    ok(res, "CreateProcess failed: %lu\n", GetLastError());
     CloseHandle(info.hThread);
     wait_child_process(info.hProcess);
     CloseHandle(info.hProcess);
 
     res = CreatePipe(&pipe_read, &pipe_write, &inheritable_attr, 0);
-    ok(res, "CreatePipe failed: %u\n", GetLastError());
+    ok(res, "CreatePipe failed: %lu\n", GetLastError());
 
     si.dwFlags = STARTF_USESTDHANDLES;
     si.hStdError = pipe_write;
     res = CreateProcessA(NULL, buf, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &info);
-    ok(res, "CreateProcess failed: %u\n", GetLastError());
+    ok(res, "CreateProcess failed: %lu\n", GetLastError());
     CloseHandle(info.hThread);
     wait_child_process(info.hProcess);
     CloseHandle(info.hProcess);
@@ -4531,39 +4531,39 @@ static void test_pseudo_console_child(HANDLE input, HANDLE output)
     BOOL ret;
 
     ret = GetConsoleMode(input, &mode);
-    ok(ret, "GetConsoleMode failed: %u\n", GetLastError());
+    ok(ret, "GetConsoleMode failed: %lu\n", GetLastError());
     ok(mode == (ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_MOUSE_INPUT |
                 ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS | ENABLE_AUTO_POSITION),
-       "mode = %x\n", mode);
+       "mode = %lx\n", mode);
 
     ret = SetConsoleMode(input, mode & ~ENABLE_AUTO_POSITION);
-    ok(ret, "SetConsoleMode failed: %u\n", GetLastError());
+    ok(ret, "SetConsoleMode failed: %lu\n", GetLastError());
 
     ret = GetConsoleMode(input, &mode);
-    ok(ret, "GetConsoleMode failed: %u\n", GetLastError());
+    ok(ret, "GetConsoleMode failed: %lu\n", GetLastError());
     ok(mode == (ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_MOUSE_INPUT |
-                ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS), "mode = %x\n", mode);
+                ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS), "mode = %lx\n", mode);
 
     ret = SetConsoleMode(input, mode | ENABLE_AUTO_POSITION);
-    ok(ret, "SetConsoleMode failed: %u\n", GetLastError());
+    ok(ret, "SetConsoleMode failed: %lu\n", GetLastError());
 
     ret = GetConsoleMode(output, &mode);
-    ok(ret, "GetConsoleMode failed: %u\n", GetLastError());
+    ok(ret, "GetConsoleMode failed: %lu\n", GetLastError());
     mode &= ~ENABLE_VIRTUAL_TERMINAL_PROCESSING;
-    ok(mode == (ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT), "mode = %x\n", mode);
+    ok(mode == (ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT), "mode = %lx\n", mode);
 
     ret = SetConsoleMode(output, mode & ~ENABLE_WRAP_AT_EOL_OUTPUT);
-    ok(ret, "SetConsoleMode failed: %u\n", GetLastError());
+    ok(ret, "SetConsoleMode failed: %lu\n", GetLastError());
 
     ret = GetConsoleMode(output, &mode);
-    ok(ret, "GetConsoleMode failed: %u\n", GetLastError());
-    ok(mode == ENABLE_PROCESSED_OUTPUT, "mode = %x\n", mode);
+    ok(ret, "GetConsoleMode failed: %lu\n", GetLastError());
+    ok(mode == ENABLE_PROCESSED_OUTPUT, "mode = %lx\n", mode);
 
     ret = SetConsoleMode(output, mode | ENABLE_WRAP_AT_EOL_OUTPUT);
-    ok(ret, "SetConsoleMode failed: %u\n", GetLastError());
+    ok(ret, "SetConsoleMode failed: %lu\n", GetLastError());
 
     ret = GetConsoleScreenBufferInfo(output, &sb_info);
-    ok(ret, "GetConsoleScreenBufferInfo failed: %u\n", GetLastError());
+    ok(ret, "GetConsoleScreenBufferInfo failed: %lu\n", GetLastError());
     ok(sb_info.dwSize.X == 40, "dwSize.X = %u\n", sb_info.dwSize.X);
     ok(sb_info.dwSize.Y == 30, "dwSize.Y = %u\n", sb_info.dwSize.Y);
     ok(sb_info.dwCursorPosition.X == 0, "dwCursorPosition.X = %u\n", sb_info.dwCursorPosition.X);
@@ -4577,8 +4577,8 @@ static void test_pseudo_console_child(HANDLE input, HANDLE output)
     ok(sb_info.dwMaximumWindowSize.Y == 30, "dwMaximumWindowSize.Y = %u\n", sb_info.dwMaximumWindowSize.Y);
 
     ret = GetConsoleCursorInfo(output, &cursor_info);
-    ok(ret, "GetConsoleCursorInfo failed: %u\n", GetLastError());
-    ok(cursor_info.dwSize == 25, "dwSize = %u\n", cursor_info.dwSize);
+    ok(ret, "GetConsoleCursorInfo failed: %lu\n", GetLastError());
+    ok(cursor_info.dwSize == 25, "dwSize = %lu\n", cursor_info.dwSize);
     ok(cursor_info.bVisible == TRUE, "bVisible = %x\n", cursor_info.bVisible);
 
     hwnd = GetConsoleWindow();
@@ -4593,7 +4593,7 @@ static DWORD WINAPI read_pipe_proc( void *handle )
     char buf[64];
     DWORD size;
     while (ReadFile(handle, buf, sizeof(buf), &size, NULL));
-    ok(GetLastError() == ERROR_BROKEN_PIPE, "ReadFile returned %u\n", GetLastError());
+    ok(GetLastError() == ERROR_BROKEN_PIPE, "ReadFile returned %lu\n", GetLastError());
     CloseHandle(handle);
     return 0;
 }
@@ -4618,11 +4618,11 @@ static void test_pseudo_console(void)
 
     console_pipe = CreateNamedPipeW(L"\\\\.\\pipe\\pseudoconsoleconn", PIPE_ACCESS_DUPLEX,
                                     PIPE_WAIT | PIPE_TYPE_BYTE, 1, 4096, 4096, NMPWAIT_USE_DEFAULT_WAIT, NULL);
-    ok(console_pipe != INVALID_HANDLE_VALUE, "CreateNamedPipeW failed: %u\n", GetLastError());
+    ok(console_pipe != INVALID_HANDLE_VALUE, "CreateNamedPipeW failed: %lu\n", GetLastError());
 
     console_pipe2 = CreateFileW(L"\\\\.\\pipe\\pseudoconsoleconn", GENERIC_READ | GENERIC_WRITE, 0, NULL,
                                 OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
-    ok(console_pipe2 != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
+    ok(console_pipe2 != INVALID_HANDLE_VALUE, "CreateFile failed: %lu\n", GetLastError());
 
     thread = CreateThread( NULL, 0, read_pipe_proc, console_pipe, 0, NULL );
     CloseHandle(thread);
@@ -4630,17 +4630,17 @@ static void test_pseudo_console(void)
     size.X = 0;
     size.Y = 30;
     hres = pCreatePseudoConsole(size, console_pipe2, console_pipe2, 0, &pseudo_console);
-    ok(hres == E_INVALIDARG, "CreatePseudoConsole failed: %08x\n", hres);
+    ok(hres == E_INVALIDARG, "CreatePseudoConsole failed: %08lx\n", hres);
 
     size.X = 40;
     size.Y = 0;
     hres = pCreatePseudoConsole(size, console_pipe2, console_pipe2, 0, &pseudo_console);
-    ok(hres == E_INVALIDARG, "CreatePseudoConsole failed: %08x\n", hres);
+    ok(hres == E_INVALIDARG, "CreatePseudoConsole failed: %08lx\n", hres);
 
     size.X = 40;
     size.Y = 30;
     hres = pCreatePseudoConsole(size, console_pipe2, console_pipe2, 0, &pseudo_console);
-    ok(hres == S_OK, "CreatePseudoConsole failed: %08x\n", hres);
+    ok(hres == S_OK, "CreatePseudoConsole failed: %08lx\n", hres);
     CloseHandle(console_pipe2);
 
     InitializeProcThreadAttributeList(NULL, 1, 0, &attr_size);
@@ -4652,7 +4652,7 @@ static void test_pseudo_console(void)
     winetest_get_mainargs(&argv);
     sprintf(cmdline, "\"%s\" %s --pseudo-console", argv[0], argv[1]);
     ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL, &startup.StartupInfo, &info);
-    ok(ret, "CreateProcessW failed: %u\n", GetLastError());
+    ok(ret, "CreateProcessW failed: %lu\n", GetLastError());
 
     CloseHandle(info.hThread);
     HeapFree(GetProcessHeap(), 0, startup.lpAttributeList);
@@ -4679,7 +4679,7 @@ START_TEST(console)
     if (argc > 3 && !strcmp(argv[2], "attach_console"))
     {
         DWORD parent_pid;
-        sscanf(argv[3], "%x", &parent_pid);
+        sscanf(argv[3], "%lx", &parent_pid);
         test_AttachConsole_child(parent_pid);
         return;
     }
@@ -4721,18 +4721,18 @@ START_TEST(console)
                 err = RegSetValueExA(console_key, "FaceName", 0, REG_SZ,
                                      (const BYTE *) font_name, sizeof(font_name));
                 if (err != ERROR_SUCCESS)
-                    trace("Unable to change default console font, error %d\n", err);
+                    trace("Unable to change default console font, error %ld\n", err);
             }
             else
             {
-                trace("Unable to query default console font, error %d\n", err);
+                trace("Unable to query default console font, error %ld\n", err);
                 RegCloseKey(console_key);
                 console_key = NULL;
             }
         }
         else
         {
-            trace("Unable to open HKCU\\Console, error %d\n", err);
+            trace("Unable to open HKCU\\Console, error %ld\n", err);
             console_key = NULL;
         }
 
@@ -4748,7 +4748,7 @@ START_TEST(console)
             else
                 err = RegSetValueExA(console_key, "FaceName", 0, REG_SZ,
                                      (const BYTE *) old_font, strlen(old_font) + 1);
-            ok(err == ERROR_SUCCESS, "Unable to restore default console font, error %d\n", err);
+            ok(err == ERROR_SUCCESS, "Unable to restore default console font, error %ld\n", err);
         }
     }
 
@@ -4765,7 +4765,7 @@ START_TEST(console)
         revert_output = CreateFileA("CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
         sb = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
                                        CONSOLE_TEXTMODE_BUFFER, NULL);
-        ok(sb != INVALID_HANDLE_VALUE, "Could not allocate screen buffer: %u\n", GetLastError());
+        ok(sb != INVALID_HANDLE_VALUE, "Could not allocate screen buffer: %lu\n", GetLastError());
         SetConsoleActiveScreenBuffer(sb);
     }
 
@@ -4795,7 +4795,7 @@ START_TEST(console)
     ok(ret, "Setting sb info\n");
     ret = GetConsoleScreenBufferInfo(hConOut, &sbi);
     ok(ret, "Getting sb info\n");
-    ok(sbi.dwSize.Y == size, "Unexpected buffer size: %d instead of %d\n", sbi.dwSize.Y, size);
+    ok(sbi.dwSize.Y == size, "Unexpected buffer size: %d instead of %ld\n", sbi.dwSize.Y, size);
     if (!ret) return;
 
     test_ReadConsole(hConIn);
diff --git a/dlls/kernel32/tests/debugger.c b/dlls/kernel32/tests/debugger.c
index 8b82aaecb9e..2e71c995323 100644
--- a/dlls/kernel32/tests/debugger.c
+++ b/dlls/kernel32/tests/debugger.c
@@ -157,8 +157,8 @@ static int load_blackbox(const char* logfile, void* blackbox, int size)
     }
     SetLastError(0xdeadbeef);
     ret=ReadFile(hFile, blackbox, size, &read, NULL);
-    ok(ret, "ReadFile failed: %d\n", GetLastError());
-    ok(read == size, "wrong size for '%s': read=%d\n", logfile, read);
+    ok(ret, "ReadFile failed: %ld\n", GetLastError());
+    ok(read == size, "wrong size for '%s': read=%ld\n", logfile, read);
     ret = ReadFile(hFile, buf, sizeof(buf) - 1, &read, NULL);
     if (ret && read)
     {
@@ -259,7 +259,7 @@ static void add_thread(struct debugger_context *ctx, DWORD tid)
 static struct debuggee_thread *get_debuggee_thread(struct debugger_context *ctx, DWORD tid)
 {
     struct wine_rb_entry *entry = wine_rb_get(&ctx->threads, &tid);
-    ok(entry != NULL, "unknown thread %x\n", tid);
+    ok(entry != NULL, "unknown thread %lx\n", tid);
     return WINE_RB_ENTRY_VALUE(entry, struct debuggee_thread, entry);
 }
 
@@ -301,13 +301,13 @@ static void fetch_thread_context_(unsigned line, struct debuggee_thread *thread)
     {
         thread->handle = OpenThread(THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_QUERY_INFORMATION,
                                     FALSE, thread->tid);
-        ok_(__FILE__,line)(thread->handle != NULL, "OpenThread failed: %u\n", GetLastError());
+        ok_(__FILE__,line)(thread->handle != NULL, "OpenThread failed: %lu\n", GetLastError());
     }
 
     memset(&thread->ctx, 0xaa, sizeof(thread->ctx));
     thread->ctx.ContextFlags = CONTEXT_FULL;
     ret = GetThreadContext(thread->handle, &thread->ctx);
-    ok_(__FILE__,line)(ret, "GetThreadContext failed: %u\n", GetLastError());
+    ok_(__FILE__,line)(ret, "GetThreadContext failed: %lu\n", GetLastError());
 }
 
 #define set_thread_context(a,b) set_thread_context_(__LINE__,a,b)
@@ -315,7 +315,7 @@ static void set_thread_context_(unsigned line, struct debugger_context *ctx, str
 {
     BOOL ret;
     ret = SetThreadContext(thread->handle, &thread->ctx);
-    ok_(__FILE__,line)(ret, "SetThreadContext failed: %u\n", GetLastError());
+    ok_(__FILE__,line)(ret, "SetThreadContext failed: %lu\n", GetLastError());
 }
 
 static void fetch_process_context(struct debugger_context *ctx)
@@ -343,14 +343,14 @@ static void next_event_(unsigned line, struct debugger_context *ctx, unsigned ti
         if (ctx->process_cnt && ctx->ev.dwDebugEventCode != -1)
         {
             ret = ContinueDebugEvent(ctx->ev.dwProcessId, ctx->ev.dwThreadId, DBG_CONTINUE);
-            ok_(__FILE__,line)(ret, "ContinueDebugEvent failed, last error %d.\n", GetLastError());
+            ok_(__FILE__,line)(ret, "ContinueDebugEvent failed, last error %ld.\n", GetLastError());
         }
 
         ret = WaitForDebugEvent(&ctx->ev, timeout);
         if (!ret)
         {
             ok_(__FILE__,line)(GetLastError() == ERROR_SEM_TIMEOUT,
-                               "WaitForDebugEvent failed, last error %d.\n", GetLastError());
+                               "WaitForDebugEvent failed, last error %ld.\n", GetLastError());
             ctx->ev.dwDebugEventCode = -1;
             return;
         }
@@ -401,8 +401,8 @@ static void wait_for_breakpoint_(unsigned line, struct debugger_context *ctx)
     while (ctx->ev.dwDebugEventCode == LOAD_DLL_DEBUG_EVENT || ctx->ev.dwDebugEventCode == UNLOAD_DLL_DEBUG_EVENT
            || ctx->ev.dwDebugEventCode == CREATE_THREAD_DEBUG_EVENT);
 
-    ok_(__FILE__,line)(ctx->ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx->ev.dwDebugEventCode);
-    ok_(__FILE__,line)(ctx->ev.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT, "ExceptionCode = %x\n",
+    ok_(__FILE__,line)(ctx->ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx->ev.dwDebugEventCode);
+    ok_(__FILE__,line)(ctx->ev.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT, "ExceptionCode = %lx\n",
                        ctx->ev.u.Exception.ExceptionRecord.ExceptionCode);
 }
 
@@ -413,12 +413,12 @@ static void process_attach_events(struct debugger_context *ctx, BOOL pass_except
 
     ctx->ev.dwDebugEventCode = -1;
     next_event(ctx, 0);
-    ok(ctx->ev.dwDebugEventCode == CREATE_PROCESS_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx->ev.dwDebugEventCode);
+    ok(ctx->ev.dwDebugEventCode == CREATE_PROCESS_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx->ev.dwDebugEventCode);
 
     next_event(ctx, 0);
     if (ctx->ev.dwDebugEventCode == LOAD_DLL_DEBUG_EVENT) /* Vista+ reports ntdll.dll before reporting threads */
     {
-        ok(ctx->ev.dwDebugEventCode == LOAD_DLL_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx->ev.dwDebugEventCode);
+        ok(ctx->ev.dwDebugEventCode == LOAD_DLL_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx->ev.dwDebugEventCode);
         ok(ctx->ev.u.LoadDll.lpBaseOfDll == ntdll, "The first reported DLL is not ntdll.dll\n");
         next_event(ctx, 0);
     }
@@ -430,7 +430,7 @@ static void process_attach_events(struct debugger_context *ctx, BOOL pass_except
     {
         /* even when there are more pending events, they are not reported until current event is continued */
         ret = WaitForDebugEvent(&ev, 10);
-        ok(GetLastError() == ERROR_SEM_TIMEOUT, "WaitForDebugEvent returned %x(%u)\n", ret, GetLastError());
+        ok(GetLastError() == ERROR_SEM_TIMEOUT, "WaitForDebugEvent returned %x(%lu)\n", ret, GetLastError());
 
         next_event(ctx, WAIT_EVENT_TIMEOUT);
         if (ctx->ev.dwDebugEventCode == LOAD_DLL_DEBUG_EVENT)
@@ -439,7 +439,7 @@ static void process_attach_events(struct debugger_context *ctx, BOOL pass_except
     ok(ctx->dll_cnt > 2, "dll_cnt = %d\n", ctx->dll_cnt);
 
     /* a new thread is created and it executes DbgBreakPoint, which causes the exception */
-    ok(ctx->ev.dwDebugEventCode == CREATE_THREAD_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx->ev.dwDebugEventCode);
+    ok(ctx->ev.dwDebugEventCode == CREATE_THREAD_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx->ev.dwDebugEventCode);
     if (ctx->ev.dwDebugEventCode == CREATE_THREAD_DEBUG_EVENT)
     {
         DWORD last_thread = ctx->ev.dwThreadId;
@@ -447,15 +447,15 @@ static void process_attach_events(struct debugger_context *ctx, BOOL pass_except
         ok(ctx->ev.dwThreadId == last_thread, "unexpected thread\n");
     }
 
-    ok(ctx->ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx->ev.dwDebugEventCode);
-    ok(ctx->ev.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT, "ExceptionCode = %x\n",
+    ok(ctx->ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx->ev.dwDebugEventCode);
+    ok(ctx->ev.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT, "ExceptionCode = %lx\n",
        ctx->ev.u.Exception.ExceptionRecord.ExceptionCode);
     ok(ctx->ev.u.Exception.ExceptionRecord.ExceptionAddress == pDbgBreakPoint, "ExceptionAddress != DbgBreakPoint\n");
 
     if (pass_exception)
     {
         ret = ContinueDebugEvent(ctx->ev.dwProcessId, ctx->ev.dwThreadId, DBG_EXCEPTION_NOT_HANDLED);
-        ok(ret, "ContinueDebugEvent failed, last error %d.\n", GetLastError());
+        ok(ret, "ContinueDebugEvent failed, last error %ld.\n", GetLastError());
         ctx->ev.dwDebugEventCode = -1;
     }
 
@@ -463,7 +463,7 @@ static void process_attach_events(struct debugger_context *ctx, BOOL pass_except
     do next_event(ctx, POLL_EVENT_TIMEOUT);
     while (ctx->ev.dwDebugEventCode == LOAD_DLL_DEBUG_EVENT || ctx->ev.dwDebugEventCode == UNLOAD_DLL_DEBUG_EVENT
            || ctx->ev.dwDebugEventCode == CREATE_THREAD_DEBUG_EVENT || ctx->ev.dwDebugEventCode == EXIT_THREAD_DEBUG_EVENT);
-    ok(ctx->ev.dwDebugEventCode == -1, "dwDebugEventCode = %d\n", ctx->ev.dwDebugEventCode);
+    ok(ctx->ev.dwDebugEventCode == -1, "dwDebugEventCode = %ld\n", ctx->ev.dwDebugEventCode);
 }
 
 static void doDebugger(int argc, char** argv)
@@ -509,8 +509,8 @@ static void doDebugger(int argc, char** argv)
     if (strstr(myARGV[2], "process"))
     {
         next_event(&ctx, WAIT_EVENT_TIMEOUT);
-        ok(ctx.ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
-        ok(ctx.ev.u.Exception.ExceptionRecord.ExceptionCode == STATUS_ACCESS_VIOLATION, "ExceptionCode = %x\n",
+        ok(ctx.ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
+        ok(ctx.ev.u.Exception.ExceptionRecord.ExceptionCode == STATUS_ACCESS_VIOLATION, "ExceptionCode = %lx\n",
            ctx.ev.u.Exception.ExceptionRecord.ExceptionCode);
     }
 
@@ -594,14 +594,14 @@ static void crash_and_debug(HKEY hkey, const char* argv0, const char* dbgtasks)
         return;
     }
 
-    ok(ret == ERROR_SUCCESS, "unable to set AeDebug/auto: ret=%d\n", ret);
+    ok(ret == ERROR_SUCCESS, "unable to set AeDebug/auto: ret=%ld\n", ret);
 
     get_file_name(dbglog);
     get_events(dbglog, &start_event, &done_event);
     cmd=HeapAlloc(GetProcessHeap(), 0, strlen(argv0)+10+strlen(dbgtasks)+1+strlen(dbglog)+2+34+1);
     sprintf(cmd, "%s debugger %s \"%s\" %%ld %%ld", argv0, dbgtasks, dbglog);
     ret=RegSetValueExA(hkey, "debugger", 0, REG_SZ, (BYTE*)cmd, strlen(cmd)+1);
-    ok(ret == ERROR_SUCCESS, "unable to set AeDebug/debugger: ret=%d\n", ret);
+    ok(ret == ERROR_SUCCESS, "unable to set AeDebug/debugger: ret=%ld\n", ret);
     HeapFree(GetProcessHeap(), 0, cmd);
 
     cmd = HeapAlloc(GetProcessHeap(), 0, strlen(argv0) + 16);
@@ -613,7 +613,7 @@ static void crash_and_debug(HKEY hkey, const char* argv0, const char* dbgtasks)
     startup.dwFlags = STARTF_USESHOWWINDOW;
     startup.wShowWindow = SW_SHOWNORMAL;
     ret=CreateProcessA(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info);
-    ok(ret, "CreateProcess: err=%d\n", GetLastError());
+    ok(ret, "CreateProcess: err=%ld\n", GetLastError());
     HeapFree(GetProcessHeap(), 0, cmd);
     CloseHandle(info.hThread);
 
@@ -635,7 +635,7 @@ static void crash_and_debug(HKEY hkey, const char* argv0, const char* dbgtasks)
 #endif
     ok(wait_code == WAIT_OBJECT_0, "Timed out waiting for the child to crash\n");
     bRet = GetExitCodeProcess(info.hProcess, &exit_code);
-    ok(bRet, "GetExitCodeProcess failed: err=%d\n", GetLastError());
+    ok(bRet, "GetExitCodeProcess failed: err=%ld\n", GetLastError());
     if (strstr(dbgtasks, "code2"))
     {
         /* If, after attaching to the debuggee, the debugger exits without
@@ -644,12 +644,12 @@ static void crash_and_debug(HKEY hkey, const char* argv0, const char* dbgtasks)
         ok(exit_code == STATUS_DEBUGGER_INACTIVE ||
            broken(exit_code == STATUS_ACCESS_VIOLATION) || /* Intermittent Vista+ */
            broken(exit_code == WAIT_ABANDONED), /* NT4, W2K */
-           "wrong exit code : %08x\n", exit_code);
+           "wrong exit code : %08lx\n", exit_code);
     }
     else
         ok(exit_code == STATUS_ACCESS_VIOLATION ||
            broken(exit_code == WAIT_ABANDONED), /* NT4, W2K, W2K3 */
-           "wrong exit code : %08x\n", exit_code);
+           "wrong exit code : %08lx\n", exit_code);
     CloseHandle(info.hProcess);
 
     /* ...before the debugger */
@@ -673,12 +673,12 @@ static void crash_and_debug(HKEY hkey, const char* argv0, const char* dbgtasks)
     ok(load_blackbox(dbglog, &dbg_blackbox, sizeof(dbg_blackbox)), "failed to open: %s\n", dbglog);
 
     ok(dbg_blackbox.argc == 6, "wrong debugger argument count: %d\n", dbg_blackbox.argc);
-    ok(dbg_blackbox.pid == info.dwProcessId, "the child and debugged pids don't match: %d != %d\n", info.dwProcessId, dbg_blackbox.pid);
-    ok(dbg_blackbox.debug_rc, "debugger: SetEvent(debug_event) failed err=%d\n", dbg_blackbox.debug_err);
-    ok(dbg_blackbox.attach_rc, "DebugActiveProcess(%d) failed err=%d\n", dbg_blackbox.pid, dbg_blackbox.attach_err);
-    ok(dbg_blackbox.nokill_rc, "DebugSetProcessKillOnExit(FALSE) failed err=%d\n", dbg_blackbox.nokill_err);
-    ok(dbg_blackbox.detach_rc, "DebugActiveProcessStop(%d) failed err=%d\n", dbg_blackbox.pid, dbg_blackbox.detach_err);
-    ok(!dbg_blackbox.failures, "debugger reported %u failures\n", dbg_blackbox.failures);
+    ok(dbg_blackbox.pid == info.dwProcessId, "the child and debugged pids don't match: %ld != %ld\n", info.dwProcessId, dbg_blackbox.pid);
+    ok(dbg_blackbox.debug_rc, "debugger: SetEvent(debug_event) failed err=%ld\n", dbg_blackbox.debug_err);
+    ok(dbg_blackbox.attach_rc, "DebugActiveProcess(%ld) failed err=%ld\n", dbg_blackbox.pid, dbg_blackbox.attach_err);
+    ok(dbg_blackbox.nokill_rc, "DebugSetProcessKillOnExit(FALSE) failed err=%ld\n", dbg_blackbox.nokill_err);
+    ok(dbg_blackbox.detach_rc, "DebugActiveProcessStop(%ld) failed err=%ld\n", dbg_blackbox.pid, dbg_blackbox.detach_err);
+    ok(!dbg_blackbox.failures, "debugger reported %lu failures\n", dbg_blackbox.failures);
 
     DeleteFileA(dbglog);
 }
@@ -693,7 +693,7 @@ static void crash_and_winedbg(HKEY hkey, const char* argv0)
     DWORD exit_code;
 
     ret=RegSetValueExA(hkey, "auto", 0, REG_SZ, (BYTE*)"1", 2);
-    ok(ret == ERROR_SUCCESS, "unable to set AeDebug/auto: ret=%d\n", ret);
+    ok(ret == ERROR_SUCCESS, "unable to set AeDebug/auto: ret=%ld\n", ret);
 
     cmd=HeapAlloc(GetProcessHeap(), 0, strlen(argv0)+15+1);
     sprintf(cmd, "%s debugger crash", argv0);
@@ -703,15 +703,15 @@ static void crash_and_winedbg(HKEY hkey, const char* argv0)
     startup.dwFlags = STARTF_USESHOWWINDOW;
     startup.wShowWindow = SW_SHOWNORMAL;
     ret=CreateProcessA(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info);
-    ok(ret, "CreateProcess: err=%d\n", GetLastError());
+    ok(ret, "CreateProcess: err=%ld\n", GetLastError());
     HeapFree(GetProcessHeap(), 0, cmd);
     CloseHandle(info.hThread);
 
     trace("waiting for child exit...\n");
     ok(WaitForSingleObject(info.hProcess, 60000) == WAIT_OBJECT_0, "Timed out waiting for the child to crash\n");
     bRet = GetExitCodeProcess(info.hProcess, &exit_code);
-    ok(bRet, "GetExitCodeProcess failed: err=%d\n", GetLastError());
-    ok(exit_code == STATUS_ACCESS_VIOLATION, "exit code = %08x\n", exit_code);
+    ok(bRet, "GetExitCodeProcess failed: err=%ld\n", GetLastError());
+    ok(exit_code == STATUS_ACCESS_VIOLATION, "exit code = %08lx\n", exit_code);
     CloseHandle(info.hProcess);
 }
 
@@ -749,7 +749,7 @@ static void test_ExitCode(void)
     }
     else if (ret != ERROR_FILE_NOT_FOUND)
     {
-        ok(0, "could not open the AeDebug key: %d\n", ret);
+        ok(0, "could not open the AeDebug key: %ld\n", ret);
         return;
     }
     else
@@ -776,7 +776,7 @@ static void test_ExitCode(void)
             RegCloseKey(hkeyWinedbg);
         }
         else
-            ok(0, "Couldn't access WineDbg Key - error %u\n", ret);
+            ok(0, "Couldn't access WineDbg Key - error %lu\n", ret);
     }
 
     if (winetest_interactive)
@@ -786,7 +786,7 @@ static void test_ExitCode(void)
         crash_and_debug(hkey, test_exe, "dbg,none");
     else
         skip("\"none\" debugger test needs user interaction\n");
-    ok(disposition == REG_OPENED_EXISTING_KEY, "expected REG_OPENED_EXISTING_KEY, got %d\n", disposition);
+    ok(disposition == REG_OPENED_EXISTING_KEY, "expected REG_OPENED_EXISTING_KEY, got %ld\n", disposition);
     crash_and_debug(hkey, test_exe, "dbg,event,order");
     crash_and_debug(hkey, test_exe, "dbg,attach,event,code2");
     crash_and_debug(hkey, test_exe, "dbg,attach,event,nokill");
@@ -820,7 +820,7 @@ static void test_RemoteDebugger(void)
     bret = pCheckRemoteDebuggerPresent(GetCurrentProcess(),&present);
     ok(bret , "expected CheckRemoteDebuggerPresent to succeed\n");
     ok(0xdeadbeef == GetLastError(),
-       "expected error to be unchanged, got %d/%x\n",GetLastError(), GetLastError());
+       "expected error to be unchanged, got %ld/%lx\n",GetLastError(), GetLastError());
 
     present = TRUE;
     SetLastError(0xdeadbeef);
@@ -828,13 +828,13 @@ static void test_RemoteDebugger(void)
     ok(!bret , "expected CheckRemoteDebuggerPresent to fail\n");
     ok(present, "expected parameter to be unchanged\n");
     ok(ERROR_INVALID_PARAMETER == GetLastError(),
-       "expected error ERROR_INVALID_PARAMETER, got %d/%x\n",GetLastError(), GetLastError());
+       "expected error ERROR_INVALID_PARAMETER, got %ld/%lx\n",GetLastError(), GetLastError());
 
     SetLastError(0xdeadbeef);
     bret = pCheckRemoteDebuggerPresent(GetCurrentProcess(),NULL);
     ok(!bret , "expected CheckRemoteDebuggerPresent to fail\n");
     ok(ERROR_INVALID_PARAMETER == GetLastError(),
-       "expected error ERROR_INVALID_PARAMETER, got %d/%x\n",GetLastError(), GetLastError());
+       "expected error ERROR_INVALID_PARAMETER, got %ld/%lx\n",GetLastError(), GetLastError());
 }
 
 struct child_blackbox
@@ -854,36 +854,36 @@ static void doChild(int argc, char **argv)
     BOOL ret;
 
     blackbox_file = argv[4];
-    sscanf(argv[3], "%08x", &ppid);
+    sscanf(argv[3], "%08lx", &ppid);
 
     parent = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, ppid);
-    child_ok(!!parent, "OpenProcess failed, last error %#x.\n", GetLastError());
+    child_ok(!!parent, "OpenProcess failed, last error %#lx.\n", GetLastError());
 
     ret = pCheckRemoteDebuggerPresent(parent, &debug);
-    child_ok(ret, "CheckRemoteDebuggerPresent failed, last error %#x.\n", GetLastError());
+    child_ok(ret, "CheckRemoteDebuggerPresent failed, last error %#lx.\n", GetLastError());
     child_ok(!debug, "Expected debug == 0, got %#x.\n", debug);
 
     ret = DebugActiveProcess(ppid);
-    child_ok(ret, "DebugActiveProcess failed, last error %#x.\n", GetLastError());
+    child_ok(ret, "DebugActiveProcess failed, last error %#lx.\n", GetLastError());
 
     ret = pCheckRemoteDebuggerPresent(parent, &debug);
-    child_ok(ret, "CheckRemoteDebuggerPresent failed, last error %#x.\n", GetLastError());
+    child_ok(ret, "CheckRemoteDebuggerPresent failed, last error %#lx.\n", GetLastError());
     child_ok(debug, "Expected debug != 0, got %#x.\n", debug);
 
     ret = DebugActiveProcessStop(ppid);
-    child_ok(ret, "DebugActiveProcessStop failed, last error %#x.\n", GetLastError());
+    child_ok(ret, "DebugActiveProcessStop failed, last error %#lx.\n", GetLastError());
 
     ret = pCheckRemoteDebuggerPresent(parent, &debug);
-    child_ok(ret, "CheckRemoteDebuggerPresent failed, last error %#x.\n", GetLastError());
+    child_ok(ret, "CheckRemoteDebuggerPresent failed, last error %#lx.\n", GetLastError());
     child_ok(!debug, "Expected debug == 0, got %#x.\n", debug);
 
     ret = CloseHandle(parent);
-    child_ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError());
+    child_ok(ret, "CloseHandle failed, last error %#lx.\n", GetLastError());
 
     ret = IsDebuggerPresent();
     child_ok(ret, "Expected ret != 0, got %#x.\n", ret);
     ret = pCheckRemoteDebuggerPresent(GetCurrentProcess(), &debug);
-    child_ok(ret, "CheckRemoteDebuggerPresent failed, last error %#x.\n", GetLastError());
+    child_ok(ret, "CheckRemoteDebuggerPresent failed, last error %#lx.\n", GetLastError());
     child_ok(debug, "Expected debug != 0, got %#x.\n", debug);
 
     NtCurrentTeb()->Peb->BeingDebugged = FALSE;
@@ -891,7 +891,7 @@ static void doChild(int argc, char **argv)
     ret = IsDebuggerPresent();
     child_ok(!ret, "Expected ret != 0, got %#x.\n", ret);
     ret = pCheckRemoteDebuggerPresent(GetCurrentProcess(), &debug);
-    child_ok(ret, "CheckRemoteDebuggerPresent failed, last error %#x.\n", GetLastError());
+    child_ok(ret, "CheckRemoteDebuggerPresent failed, last error %#lx.\n", GetLastError());
     child_ok(debug, "Expected debug != 0, got %#x.\n", debug);
 
     NtCurrentTeb()->Peb->BeingDebugged = TRUE;
@@ -902,11 +902,11 @@ static void doChild(int argc, char **argv)
     GetSystemDirectoryW( path, MAX_PATH );
     wcscat( path, L"\\oleaut32.dll" );
     file = CreateFileW( path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
-    child_ok( file != INVALID_HANDLE_VALUE, "failed to open %s: %u\n", debugstr_w(path), GetLastError());
+    child_ok( file != INVALID_HANDLE_VALUE, "failed to open %s: %lu\n", debugstr_w(path), GetLastError());
     map = CreateFileMappingW( file, NULL, SEC_IMAGE | PAGE_READONLY, 0, 0, NULL );
-    child_ok( map != NULL, "failed to create mapping %s: %u\n", debugstr_w(path), GetLastError() );
+    child_ok( map != NULL, "failed to create mapping %s: %lu\n", debugstr_w(path), GetLastError() );
     mod = MapViewOfFile( map, FILE_MAP_READ, 0, 0, 0 );
-    child_ok( mod != NULL, "failed to map %s: %u\n", debugstr_w(path), GetLastError() );
+    child_ok( mod != NULL, "failed to map %s: %lu\n", debugstr_w(path), GetLastError() );
     CloseHandle( file );
     CloseHandle( map );
     UnmapViewOfFile( mod );
@@ -923,11 +923,11 @@ static void doChild(int argc, char **argv)
     else goto done;
 
     file = CreateFileW( path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
-    child_ok( file != INVALID_HANDLE_VALUE, "failed to open %s: %u\n", debugstr_w(path), GetLastError());
+    child_ok( file != INVALID_HANDLE_VALUE, "failed to open %s: %lu\n", debugstr_w(path), GetLastError());
     map = CreateFileMappingW( file, NULL, SEC_IMAGE | PAGE_READONLY, 0, 0, NULL );
-    child_ok( map != NULL, "failed to create mapping %s: %u\n", debugstr_w(path), GetLastError() );
+    child_ok( map != NULL, "failed to create mapping %s: %lu\n", debugstr_w(path), GetLastError() );
     mod = MapViewOfFile( map, FILE_MAP_READ, 0, 0, 0 );
-    child_ok( mod != NULL, "failed to map %s: %u\n", debugstr_w(path), GetLastError() );
+    child_ok( mod != NULL, "failed to map %s: %lu\n", debugstr_w(path), GetLastError() );
     CloseHandle( file );
     CloseHandle( map );
     UnmapViewOfFile( mod );
@@ -987,17 +987,17 @@ static void test_debug_loop(int argc, char **argv)
 
     get_file_name(blackbox_file);
     cmd = HeapAlloc(GetProcessHeap(), 0, strlen(argv[0]) + strlen(arguments) + strlen(blackbox_file) + 2 + 10);
-    sprintf(cmd, "%s%s%08x \"%s\"", argv[0], arguments, pid, blackbox_file);
+    sprintf(cmd, "%s%s%08lx \"%s\"", argv[0], arguments, pid, blackbox_file);
 
     memset(&si, 0, sizeof(si));
     si.cb = sizeof(si);
     ret = CreateProcessA(NULL, cmd, NULL, NULL, FALSE, DEBUG_PROCESS, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess failed, last error %#x.\n", GetLastError());
+    ok(ret, "CreateProcess failed, last error %#lx.\n", GetLastError());
 
     HeapFree(GetProcessHeap(), 0, cmd);
 
     ret = pCheckRemoteDebuggerPresent(pi.hProcess, &debug);
-    ok(ret, "CheckRemoteDebuggerPresent failed, last error %#x.\n", GetLastError());
+    ok(ret, "CheckRemoteDebuggerPresent failed, last error %#lx.\n", GetLastError());
     ok(debug, "Expected debug != 0, got %#x.\n", debug);
 
     for (;;)
@@ -1005,7 +1005,7 @@ static void test_debug_loop(int argc, char **argv)
         DEBUG_EVENT ev;
 
         ret = WaitForDebugEvent(&ev, INFINITE);
-        ok(ret, "WaitForDebugEvent failed, last error %#x.\n", GetLastError());
+        ok(ret, "WaitForDebugEvent failed, last error %#lx.\n", GetLastError());
         if (!ret) break;
 
         if (ev.dwDebugEventCode == EXIT_PROCESS_DEBUG_EVENT) break;
@@ -1020,7 +1020,7 @@ static void test_debug_loop(int argc, char **argv)
         }
 #endif
         ret = ContinueDebugEvent(ev.dwProcessId, ev.dwThreadId, DBG_CONTINUE);
-        ok(ret, "ContinueDebugEvent failed, last error %#x.\n", GetLastError());
+        ok(ret, "ContinueDebugEvent failed, last error %#lx.\n", GetLastError());
         if (!ret) break;
     }
 
@@ -1033,15 +1033,15 @@ static void test_debug_loop(int argc, char **argv)
 #endif
 
     ret = CloseHandle(pi.hThread);
-    ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError());
+    ok(ret, "CloseHandle failed, last error %#lx.\n", GetLastError());
     ret = CloseHandle(pi.hProcess);
-    ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError());
+    ok(ret, "CloseHandle failed, last error %#lx.\n", GetLastError());
 
     load_blackbox(blackbox_file, &blackbox, sizeof(blackbox));
-    ok(!blackbox.failures, "Got %d failures from child process.\n", blackbox.failures);
+    ok(!blackbox.failures, "Got %ld failures from child process.\n", blackbox.failures);
 
     ret = DeleteFileA(blackbox_file);
-    ok(ret, "DeleteFileA failed, last error %#x.\n", GetLastError());
+    ok(ret, "DeleteFileA failed, last error %#lx.\n", GetLastError());
 }
 
 static void doChildren(int argc, char **argv)
@@ -1067,7 +1067,7 @@ static void doChildren(int argc, char **argv)
     strcpy(event_name, p);
     strcat(event_name, "_init");
     event = OpenEventA(EVENT_ALL_ACCESS, FALSE, event_name);
-    child_ok(event != NULL, "OpenEvent failed, last error %d.\n", GetLastError());
+    child_ok(event != NULL, "OpenEvent failed, last error %ld.\n", GetLastError());
     SetEvent(event);
     CloseHandle(event);
 
@@ -1076,7 +1076,7 @@ static void doChildren(int argc, char **argv)
     strcpy(event_name, p);
     strcat(event_name, "_attach");
     event = OpenEventA(EVENT_ALL_ACCESS, FALSE, event_name);
-    child_ok(event != NULL, "OpenEvent failed, last error %d.\n", GetLastError());
+    child_ok(event != NULL, "OpenEvent failed, last error %ld.\n", GetLastError());
     WaitForSingleObject(event, INFINITE);
     CloseHandle(event);
 
@@ -1086,15 +1086,15 @@ static void doChildren(int argc, char **argv)
     memset(&si, 0, sizeof(si));
     si.cb = sizeof(si);
     ret = CreateProcessA(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-    child_ok(ret, "CreateProcess failed, last error %d.\n", GetLastError());
+    child_ok(ret, "CreateProcess failed, last error %ld.\n", GetLastError());
 
     child_ok(WaitForSingleObject(pi.hProcess, 10000) == WAIT_OBJECT_0,
             "Timed out waiting for the child to exit\n");
 
     ret = CloseHandle(pi.hThread);
-    child_ok(ret, "CloseHandle failed, last error %d.\n", GetLastError());
+    child_ok(ret, "CloseHandle failed, last error %ld.\n", GetLastError());
     ret = CloseHandle(pi.hProcess);
-    child_ok(ret, "CloseHandle failed, last error %d.\n", GetLastError());
+    child_ok(ret, "CloseHandle failed, last error %ld.\n", GetLastError());
 
     blackbox.failures = child_failures;
     save_blackbox(blackbox_file, &blackbox, sizeof(blackbox), NULL);
@@ -1130,31 +1130,31 @@ static void test_debug_children(const char *name, DWORD flag, BOOL debug_child,
     strcpy(event_name, p);
     strcat(event_name, "_init");
     event_init = CreateEventA(NULL, FALSE, FALSE, event_name);
-    ok(event_init != NULL, "OpenEvent failed, last error %d.\n", GetLastError());
+    ok(event_init != NULL, "OpenEvent failed, last error %ld.\n", GetLastError());
 
     p = strrchr(blackbox_file, '\\');
     p = p ? p+1 : blackbox_file;
     strcpy(event_name, p);
     strcat(event_name, "_attach");
     event_attach = CreateEventA(NULL, FALSE, flag!=0, event_name);
-    ok(event_attach != NULL, "CreateEvent failed, last error %d.\n", GetLastError());
+    ok(event_attach != NULL, "CreateEvent failed, last error %ld.\n", GetLastError());
 
     memset(&si, 0, sizeof(si));
     si.cb = sizeof(si);
 
     ret = CreateProcessA(NULL, cmd, NULL, NULL, FALSE, flag, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess failed, last error %d.\n", GetLastError());
+    ok(ret, "CreateProcess failed, last error %ld.\n", GetLastError());
     HeapFree(GetProcessHeap(), 0, cmd);
     if (!flag)
     {
         WaitForSingleObject(event_init, INFINITE);
         Sleep(100);
         ret = DebugActiveProcess(pi.dwProcessId);
-        ok(ret, "DebugActiveProcess failed, last error %d.\n", GetLastError());
+        ok(ret, "DebugActiveProcess failed, last error %ld.\n", GetLastError());
     }
 
     ret = pCheckRemoteDebuggerPresent(pi.hProcess, &debug);
-    ok(ret, "CheckRemoteDebuggerPresent failed, last error %d.\n", GetLastError());
+    ok(ret, "CheckRemoteDebuggerPresent failed, last error %ld.\n", GetLastError());
     ok(debug, "Expected debug != 0, got %x.\n", debug);
 
     trace("starting debugger loop\n");
@@ -1164,19 +1164,19 @@ static void test_debug_children(const char *name, DWORD flag, BOOL debug_child,
         DWORD last_thread;
 
         next_event(&ctx, WAIT_EVENT_TIMEOUT);
-        ok(ctx.ev.dwDebugEventCode == CREATE_PROCESS_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
+        ok(ctx.ev.dwDebugEventCode == CREATE_PROCESS_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
         ok(ctx.pid == pi.dwProcessId, "unexpected dwProcessId %x\n", ctx.ev.dwProcessId == ctx.pid);
 
         next_event(&ctx, WAIT_EVENT_TIMEOUT);
-        ok(ctx.ev.dwDebugEventCode == LOAD_DLL_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
+        ok(ctx.ev.dwDebugEventCode == LOAD_DLL_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
         last_thread = ctx.ev.dwThreadId;
 
         wait_for_breakpoint(&ctx);
         ok(ctx.dll_cnt > 2, "dll_cnt = %d\n", ctx.dll_cnt);
 
-        ok(ctx.ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
+        ok(ctx.ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
         ok(ctx.ev.dwThreadId == last_thread, "unexpected thread\n");
-        ok(ctx.ev.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT, "ExceptionCode = %x\n",
+        ok(ctx.ev.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT, "ExceptionCode = %lx\n",
            ctx.ev.u.Exception.ExceptionRecord.ExceptionCode);
 
         /* Except for wxppro and w2008, the initial breakpoint is now somewhere else, possibly within LdrInitShimEngineDynamic,
@@ -1195,11 +1195,11 @@ static void test_debug_children(const char *name, DWORD flag, BOOL debug_child,
         if (pass_exception)
         {
             ret = ContinueDebugEvent(ctx.ev.dwProcessId, ctx.ev.dwThreadId, DBG_EXCEPTION_NOT_HANDLED);
-            ok(ret, "ContinueDebugEvent failed, last error %d.\n", GetLastError());
+            ok(ret, "ContinueDebugEvent failed, last error %ld.\n", GetLastError());
             ctx.ev.dwDebugEventCode = -1;
 
             next_event(&ctx, WAIT_EVENT_TIMEOUT);
-            ok(ctx.ev.dwDebugEventCode != EXCEPTION_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
+            ok(ctx.ev.dwDebugEventCode != EXCEPTION_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
         }
     }
     else
@@ -1207,32 +1207,32 @@ static void test_debug_children(const char *name, DWORD flag, BOOL debug_child,
         DWORD last_thread;
 
         process_attach_events(&ctx, pass_exception);
-        ok(ctx.pid == pi.dwProcessId, "unexpected dwProcessId %x\n", ctx.pid);
+        ok(ctx.pid == pi.dwProcessId, "unexpected dwProcessId %lx\n", ctx.pid);
 
         ret = DebugBreakProcess(pi.hProcess);
-        ok(ret, "BreakProcess failed: %u\n", GetLastError());
+        ok(ret, "BreakProcess failed: %lu\n", GetLastError());
 
         /* a new thread, which executes DbgBreakPoint, is created */
         next_event(&ctx, WAIT_EVENT_TIMEOUT);
-        ok(ctx.ev.dwDebugEventCode == CREATE_THREAD_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
+        ok(ctx.ev.dwDebugEventCode == CREATE_THREAD_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
         last_thread = ctx.ev.dwThreadId;
 
         if (ctx.ev.dwDebugEventCode == CREATE_THREAD_DEBUG_EVENT)
             next_event(&ctx, WAIT_EVENT_TIMEOUT);
 
-        ok(ctx.ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
+        ok(ctx.ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
         ok(ctx.ev.dwThreadId == last_thread, "unexpected thread\n");
-        ok(ctx.ev.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT, "ExceptionCode = %x\n",
+        ok(ctx.ev.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT, "ExceptionCode = %lx\n",
            ctx.ev.u.Exception.ExceptionRecord.ExceptionCode);
         ok(ctx.ev.u.Exception.ExceptionRecord.ExceptionAddress == pDbgBreakPoint, "ExceptionAddress != DbgBreakPoint\n");
 
         ret = SetEvent(event_attach);
-        ok(ret, "SetEvent failed, last error %d.\n", GetLastError());
+        ok(ret, "SetEvent failed, last error %ld.\n", GetLastError());
 
         if (pass_exception)
         {
             ret = ContinueDebugEvent(ctx.ev.dwProcessId, ctx.ev.dwThreadId, DBG_EXCEPTION_NOT_HANDLED);
-            ok(ret, "ContinueDebugEvent failed, last error %d.\n", GetLastError());
+            ok(ret, "ContinueDebugEvent failed, last error %ld.\n", GetLastError());
             ctx.ev.dwDebugEventCode = -1;
         }
     }
@@ -1241,27 +1241,27 @@ static void test_debug_children(const char *name, DWORD flag, BOOL debug_child,
     while (ctx.ev.dwDebugEventCode == LOAD_DLL_DEBUG_EVENT || ctx.ev.dwDebugEventCode == UNLOAD_DLL_DEBUG_EVENT
            || ctx.ev.dwDebugEventCode == CREATE_THREAD_DEBUG_EVENT || ctx.ev.dwDebugEventCode == EXIT_THREAD_DEBUG_EVENT);
 
-    ok(ctx.ev.dwDebugEventCode == EXIT_PROCESS_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
+    ok(ctx.ev.dwDebugEventCode == EXIT_PROCESS_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
     ret = ContinueDebugEvent(ctx.ev.dwProcessId, ctx.ev.dwThreadId, DBG_CONTINUE);
-    ok(ret, "ContinueDebugEvent failed, last error %d.\n", GetLastError());
+    ok(ret, "ContinueDebugEvent failed, last error %ld.\n", GetLastError());
 
     if(debug_child)
-        ok(ctx.process_cnt == 2, "didn't get any child events (flag: %x).\n", flag);
+        ok(ctx.process_cnt == 2, "didn't get any child events (flag: %lx).\n", flag);
     else
-        ok(ctx.process_cnt == 1, "got child event (flag: %x).\n", flag);
+        ok(ctx.process_cnt == 1, "got child event (flag: %lx).\n", flag);
     CloseHandle(event_init);
     CloseHandle(event_attach);
 
     ret = CloseHandle(pi.hThread);
-    ok(ret, "CloseHandle failed, last error %d.\n", GetLastError());
+    ok(ret, "CloseHandle failed, last error %ld.\n", GetLastError());
     ret = CloseHandle(pi.hProcess);
-    ok(ret, "CloseHandle failed, last error %d.\n", GetLastError());
+    ok(ret, "CloseHandle failed, last error %ld.\n", GetLastError());
 
     load_blackbox(blackbox_file, &blackbox, sizeof(blackbox));
-    ok(!blackbox.failures, "Got %d failures from child process.\n", blackbox.failures);
+    ok(!blackbox.failures, "Got %ld failures from child process.\n", blackbox.failures);
 
     ret = DeleteFileA(blackbox_file);
-    ok(ret, "DeleteFileA failed, last error %d.\n", GetLastError());
+    ok(ret, "DeleteFileA failed, last error %ld.\n", GetLastError());
 }
 
 static void wait_debugger(HANDLE event, unsigned int cnt)
@@ -1274,7 +1274,7 @@ static void wait_debugger(HANDLE event, unsigned int cnt)
 static void expect_event_(unsigned line, struct debugger_context *ctx, DWORD event_code)
 {
     next_event(ctx, WAIT_EVENT_TIMEOUT);
-    ok_(__FILE__,line)(ctx->ev.dwDebugEventCode == event_code, "dwDebugEventCode = %d expected %d\n",
+    ok_(__FILE__,line)(ctx->ev.dwDebugEventCode == event_code, "dwDebugEventCode = %ld expected %ld\n",
                        ctx->ev.dwDebugEventCode, event_code);
 }
 
@@ -1282,7 +1282,7 @@ static void expect_event_(unsigned line, struct debugger_context *ctx, DWORD eve
 static void expect_exception_(unsigned line, struct debugger_context *ctx, DWORD exception_code)
 {
     expect_event_(line, ctx, EXCEPTION_DEBUG_EVENT);
-    ok_(__FILE__,line)(ctx->ev.u.Exception.ExceptionRecord.ExceptionCode == exception_code, "ExceptionCode = %x expected %x\n",
+    ok_(__FILE__,line)(ctx->ev.u.Exception.ExceptionRecord.ExceptionCode == exception_code, "ExceptionCode = %lx expected %lx\n",
                        ctx->ev.u.Exception.ExceptionRecord.ExceptionCode, exception_code);
 }
 
@@ -1313,7 +1313,7 @@ static void single_step_(unsigned line, struct debugger_context *ctx, struct deb
     fetch_thread_context(thread);
     ok_(__FILE__,line)(get_ip(&thread->ctx) == expect_addr, "unexpected instruction pointer %p expected %p\n",
                        get_ip(&thread->ctx), expect_addr);
-    ok_(__FILE__,line)(!(thread->ctx.EFlags & 0x100), "EFlags = %x\n", thread->ctx.EFlags);
+    ok_(__FILE__,line)(!(thread->ctx.EFlags & 0x100), "EFlags = %lx\n", thread->ctx.EFlags);
 #endif
 }
 
@@ -1393,19 +1393,19 @@ static void test_debugger(const char *argv0)
     BOOL ret;
 
     event = CreateEventW(&sa, FALSE, FALSE, NULL);
-    ok(event != NULL, "CreateEvent failed: %u\n", GetLastError());
+    ok(event != NULL, "CreateEvent failed: %lu\n", GetLastError());
 
     cmd = heap_alloc(strlen(argv0) + strlen(arguments) + 16);
-    sprintf(cmd, "%s%s%x %u\n", argv0, arguments, (DWORD)(DWORD_PTR)event, OP_BP ? 3 : 1);
+    sprintf(cmd, "%s%s%lx %u\n", argv0, arguments, (DWORD)(DWORD_PTR)event, OP_BP ? 3 : 1);
 
     memset(&si, 0, sizeof(si));
     si.cb = sizeof(si);
     ret = CreateProcessA(NULL, cmd, NULL, NULL, TRUE, DEBUG_PROCESS, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess failed, last error %#x.\n", GetLastError());
+    ok(ret, "CreateProcess failed, last error %#lx.\n", GetLastError());
     heap_free(cmd);
 
     next_event(&ctx, WAIT_EVENT_TIMEOUT);
-    ok(ctx.ev.dwDebugEventCode == CREATE_PROCESS_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
+    ok(ctx.ev.dwDebugEventCode == CREATE_PROCESS_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
 
     if ((skip_reply_later = !ContinueDebugEvent(ctx.ev.dwProcessId, ctx.ev.dwThreadId, DBG_REPLY_LATER)))
         win_skip("Skipping unsupported DBG_REPLY_LATER tests\n");
@@ -1417,49 +1417,49 @@ static void test_debugger(const char *argv0)
         ctx.ev.dwDebugEventCode = -1;
         next_event(&ctx, WAIT_EVENT_TIMEOUT);
         ok(de.dwDebugEventCode == ctx.ev.dwDebugEventCode,
-           "dwDebugEventCode differs: %x (was %x)\n", ctx.ev.dwDebugEventCode, de.dwDebugEventCode);
+           "dwDebugEventCode differs: %lx (was %lx)\n", ctx.ev.dwDebugEventCode, de.dwDebugEventCode);
         ok(de.dwProcessId == ctx.ev.dwProcessId,
-           "dwProcessId differs: %x (was %x)\n", ctx.ev.dwProcessId, de.dwProcessId);
+           "dwProcessId differs: %lx (was %lx)\n", ctx.ev.dwProcessId, de.dwProcessId);
         ok(de.dwThreadId == ctx.ev.dwThreadId,
-           "dwThreadId differs: %x (was %x)\n", ctx.ev.dwThreadId, de.dwThreadId);
+           "dwThreadId differs: %lx (was %lx)\n", ctx.ev.dwThreadId, de.dwThreadId);
 
         /* Suspending the thread should prevent other attach debug events
          * to be received until it's resumed */
         thread = OpenThread(THREAD_SUSPEND_RESUME, FALSE, ctx.ev.dwThreadId);
-        ok(thread != INVALID_HANDLE_VALUE, "OpenThread failed, last error:%u\n", GetLastError());
+        ok(thread != INVALID_HANDLE_VALUE, "OpenThread failed, last error:%lu\n", GetLastError());
 
         status = NtSuspendThread(thread, NULL);
-        ok(!status, "NtSuspendThread failed, last error:%u\n", GetLastError());
+        ok(!status, "NtSuspendThread failed, last error:%lu\n", GetLastError());
 
         ret = ContinueDebugEvent(ctx.ev.dwProcessId, ctx.ev.dwThreadId, DBG_REPLY_LATER);
-        ok(ret, "ContinueDebugEvent failed, last error:%u\n", GetLastError());
+        ok(ret, "ContinueDebugEvent failed, last error:%lu\n", GetLastError());
         ok(!WaitForDebugEvent(&ctx.ev, POLL_EVENT_TIMEOUT), "WaitForDebugEvent succeeded.\n");
 
         status = NtResumeThread(thread, NULL);
-        ok(!status, "NtResumeThread failed, last error:%u\n", GetLastError());
+        ok(!status, "NtResumeThread failed, last error:%lu\n", GetLastError());
 
         ret = CloseHandle(thread);
-        ok(ret, "CloseHandle failed, last error %d.\n", GetLastError());
+        ok(ret, "CloseHandle failed, last error %ld.\n", GetLastError());
 
         ok(WaitForDebugEvent(&ctx.ev, POLL_EVENT_TIMEOUT), "WaitForDebugEvent failed.\n");
         ok(de.dwDebugEventCode == ctx.ev.dwDebugEventCode,
-           "dwDebugEventCode differs: %x (was %x)\n", ctx.ev.dwDebugEventCode, de.dwDebugEventCode);
+           "dwDebugEventCode differs: %lx (was %lx)\n", ctx.ev.dwDebugEventCode, de.dwDebugEventCode);
 
         next_event(&ctx, WAIT_EVENT_TIMEOUT);
-        ok(ctx.ev.dwDebugEventCode == LOAD_DLL_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
+        ok(ctx.ev.dwDebugEventCode == LOAD_DLL_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
         de = ctx.ev;
 
         ret = ContinueDebugEvent(ctx.ev.dwProcessId, ctx.ev.dwThreadId, DBG_REPLY_LATER);
-        ok(ret, "ContinueDebugEvent failed, last error:%u\n", GetLastError());
+        ok(ret, "ContinueDebugEvent failed, last error:%lu\n", GetLastError());
 
         ctx.ev.dwDebugEventCode = -1;
         next_event(&ctx, WAIT_EVENT_TIMEOUT);
         ok(de.dwDebugEventCode == ctx.ev.dwDebugEventCode,
-           "dwDebugEventCode differs: %x (was %x)\n", ctx.ev.dwDebugEventCode, de.dwDebugEventCode);
+           "dwDebugEventCode differs: %lx (was %lx)\n", ctx.ev.dwDebugEventCode, de.dwDebugEventCode);
         ok(de.dwProcessId == ctx.ev.dwProcessId,
-           "dwProcessId differs: %x (was %x)\n", ctx.ev.dwProcessId, de.dwProcessId);
+           "dwProcessId differs: %lx (was %lx)\n", ctx.ev.dwProcessId, de.dwProcessId);
         ok(de.dwThreadId == ctx.ev.dwThreadId,
-           "dwThreadId differs: %x (was %x)\n", ctx.ev.dwThreadId, de.dwThreadId);
+           "dwThreadId differs: %lx (was %lx)\n", ctx.ev.dwThreadId, de.dwThreadId);
     }
 
     wait_for_breakpoint(&ctx);
@@ -1467,7 +1467,7 @@ static void test_debugger(const char *argv0)
     while(ctx.ev.dwDebugEventCode != -1);
 
     mem = VirtualAllocEx(pi.hProcess, NULL, sizeof(buf), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
-    ok(mem != NULL, "VirtualAllocEx failed: %u\n", GetLastError());
+    ok(mem != NULL, "VirtualAllocEx failed: %lu\n", GetLastError());
     proc_code   = buf + 1024;
     thread_proc = mem + 1024;
 
@@ -1478,10 +1478,10 @@ static void test_debugger(const char *argv0)
         memcpy(proc_code, &loop_code, sizeof(loop_code));
         proc_code[0] = OP_BP; /* set a breakpoint */
         ret = WriteProcessMemory(pi.hProcess, mem, buf, sizeof(buf), NULL);
-        ok(ret, "WriteProcessMemory failed: %u\n", GetLastError());
+        ok(ret, "WriteProcessMemory failed: %lu\n", GetLastError());
 
         thread = CreateRemoteThread(pi.hProcess, NULL, 0, (void*)thread_proc, NULL, 0, NULL);
-        ok(thread != NULL, "CreateRemoteThread failed: %u\n", GetLastError());
+        ok(thread != NULL, "CreateRemoteThread failed: %lu\n", GetLastError());
 
         expect_event(&ctx, CREATE_THREAD_DEBUG_EVENT);
         debuggee_thread = get_debuggee_thread(&ctx, ctx.ev.dwThreadId);
@@ -1499,7 +1499,7 @@ static void test_debugger(const char *argv0)
 
         byte = 0xc3; /* ret */
         ret = WriteProcessMemory(pi.hProcess, thread_proc, &byte, 1, NULL);
-        ok(ret, "WriteProcessMemory failed: %u\n", GetLastError());
+        ok(ret, "WriteProcessMemory failed: %lu\n", GetLastError());
 
         expect_event(&ctx, EXIT_THREAD_DEBUG_EVENT);
     }
@@ -1511,23 +1511,23 @@ static void test_debugger(const char *argv0)
         memset(buf, OP_BP, sizeof(buf));
         memcpy(proc_code, call_debug_service_code, sizeof(call_debug_service_code));
         ret = WriteProcessMemory(pi.hProcess, mem, buf, sizeof(buf), NULL);
-        ok(ret, "WriteProcessMemory failed: %u\n", GetLastError());
+        ok(ret, "WriteProcessMemory failed: %lu\n", GetLastError());
 
         /* BREAKPOINT_PRINT */
         thread = CreateRemoteThread(pi.hProcess, NULL, 0, (void*)thread_proc, (void*)2, 0, NULL);
-        ok(thread != NULL, "CreateRemoteThread failed: %u\n", GetLastError());
+        ok(thread != NULL, "CreateRemoteThread failed: %lu\n", GetLastError());
         expect_event(&ctx, CREATE_THREAD_DEBUG_EVENT);
         expect_breakpoint_exception(&ctx, NULL);
         expect_event(&ctx, EXIT_THREAD_DEBUG_EVENT);
 
         /* BREAKPOINT_PROMPT */
         thread = CreateRemoteThread(pi.hProcess, NULL, 0, (void*)thread_proc, (void*)1, 0, NULL);
-        ok(thread != NULL, "CreateRemoteThread failed: %u\n", GetLastError());
+        ok(thread != NULL, "CreateRemoteThread failed: %lu\n", GetLastError());
         expect_event(&ctx, CREATE_THREAD_DEBUG_EVENT);
         next_event(&ctx, WAIT_EVENT_TIMEOUT);
         /* some 32-bit Windows versions report exception to the debugger */
         if (sizeof(void *) == 4 && ctx.ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT) next_event(&ctx, WAIT_EVENT_TIMEOUT);
-        ok(ctx.ev.dwDebugEventCode == EXIT_THREAD_DEBUG_EVENT, "unexpected debug event %u\n", ctx.ev.dwDebugEventCode);
+        ok(ctx.ev.dwDebugEventCode == EXIT_THREAD_DEBUG_EVENT, "unexpected debug event %lu\n", ctx.ev.dwDebugEventCode);
     }
     else win_skip("call_debug_service_code not supported on this architecture\n");
 
@@ -1541,64 +1541,64 @@ static void test_debugger(const char *argv0)
         memset(buf, OP_BP, sizeof(buf));
         memcpy(proc_code, &loop_code, sizeof(loop_code));
         ret = WriteProcessMemory(pi.hProcess, mem, buf, sizeof(buf), NULL);
-        ok(ret, "WriteProcessMemory failed: %u\n", GetLastError());
+        ok(ret, "WriteProcessMemory failed: %lu\n", GetLastError());
 
         byte = OP_BP;
         ret = WriteProcessMemory(pi.hProcess, thread_proc + 1, &byte, 1, NULL);
-        ok(ret, "WriteProcessMemory failed: %u\n", GetLastError());
+        ok(ret, "WriteProcessMemory failed: %lu\n", GetLastError());
 
         thread_a = CreateRemoteThread(pi.hProcess, NULL, 0, (void*)thread_proc, NULL, 0, NULL);
-        ok(thread_a != NULL, "CreateRemoteThread failed: %u\n", GetLastError());
+        ok(thread_a != NULL, "CreateRemoteThread failed: %lu\n", GetLastError());
         next_event(&ctx, WAIT_EVENT_TIMEOUT);
-        ok(ctx.ev.dwDebugEventCode == CREATE_THREAD_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
+        ok(ctx.ev.dwDebugEventCode == CREATE_THREAD_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
         de_a = ctx.ev;
 
         thread_b = CreateRemoteThread(pi.hProcess, NULL, 0, (void*)thread_proc, NULL, 0, NULL);
-        ok(thread_b != NULL, "CreateRemoteThread failed: %u\n", GetLastError());
+        ok(thread_b != NULL, "CreateRemoteThread failed: %lu\n", GetLastError());
         do next_event(&ctx, POLL_EVENT_TIMEOUT);
         while(ctx.ev.dwDebugEventCode != CREATE_THREAD_DEBUG_EVENT);
         de_b = ctx.ev;
 
         status = NtSuspendThread(thread_b, NULL);
-        ok(!status, "NtSuspendThread failed, last error:%u\n", GetLastError());
+        ok(!status, "NtSuspendThread failed, last error:%lu\n", GetLastError());
         ret = ContinueDebugEvent(ctx.ev.dwProcessId, ctx.ev.dwThreadId, DBG_REPLY_LATER);
-        ok(ret, "ContinueDebugEvent failed, last error:%u\n", GetLastError());
+        ok(ret, "ContinueDebugEvent failed, last error:%lu\n", GetLastError());
 
         ctx.ev.dwDebugEventCode = -1;
         next_event(&ctx, WAIT_EVENT_TIMEOUT);
         ok(ctx.ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT,
-           "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
+           "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
         ok(de_a.dwProcessId == ctx.ev.dwProcessId,
-           "dwProcessId differs: %x (was %x)\n", ctx.ev.dwProcessId, de_a.dwProcessId);
+           "dwProcessId differs: %lx (was %lx)\n", ctx.ev.dwProcessId, de_a.dwProcessId);
         ok(de_a.dwThreadId == ctx.ev.dwThreadId,
-           "dwThreadId differs: %x (was %x)\n", ctx.ev.dwThreadId, de_a.dwThreadId);
+           "dwThreadId differs: %lx (was %lx)\n", ctx.ev.dwThreadId, de_a.dwThreadId);
         de_a = ctx.ev;
 
         byte = 0xc3; /* ret */
         ret = WriteProcessMemory(pi.hProcess, thread_proc + 1, &byte, 1, NULL);
-        ok(ret, "WriteProcessMemory failed: %u\n", GetLastError());
+        ok(ret, "WriteProcessMemory failed: %lu\n", GetLastError());
 
         ok(pNtSuspendProcess != NULL, "NtSuspendProcess not found\n");
         ok(pNtResumeProcess != NULL, "pNtResumeProcess not found\n");
         if (pNtSuspendProcess && pNtResumeProcess)
         {
             status = pNtSuspendProcess(pi.hProcess);
-            ok(!status, "NtSuspendProcess failed, last error:%u\n", GetLastError());
+            ok(!status, "NtSuspendProcess failed, last error:%lu\n", GetLastError());
             ret = ContinueDebugEvent(ctx.ev.dwProcessId, ctx.ev.dwThreadId, DBG_REPLY_LATER);
-            ok(ret, "ContinueDebugEvent failed, last error:%u\n", GetLastError());
+            ok(ret, "ContinueDebugEvent failed, last error:%lu\n", GetLastError());
             ok(!WaitForDebugEvent(&ctx.ev, POLL_EVENT_TIMEOUT), "WaitForDebugEvent succeeded.\n");
 
             status = NtResumeThread(thread_b, NULL);
-            ok(!status, "NtResumeThread failed, last error:%u\n", GetLastError());
+            ok(!status, "NtResumeThread failed, last error:%lu\n", GetLastError());
             ok(!WaitForDebugEvent(&ctx.ev, POLL_EVENT_TIMEOUT), "WaitForDebugEvent succeeded.\n");
 
             status = pNtResumeProcess(pi.hProcess);
-            ok(!status, "pNtResumeProcess failed, last error:%u\n", GetLastError());
+            ok(!status, "pNtResumeProcess failed, last error:%lu\n", GetLastError());
         }
         else
         {
             status = NtResumeThread(thread_b, NULL);
-            ok(!status, "NtResumeThread failed, last error:%u\n", GetLastError());
+            ok(!status, "NtResumeThread failed, last error:%lu\n", GetLastError());
             ok(!WaitForDebugEvent(&ctx.ev, POLL_EVENT_TIMEOUT), "WaitForDebugEvent succeeded.\n");
         }
 
@@ -1622,74 +1622,74 @@ static void test_debugger(const char *argv0)
         if (ctx.ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT)
         {
             ok(de_a.dwDebugEventCode == ctx.ev.dwDebugEventCode,
-               "dwDebugEventCode differs: %x (was %x)\n", ctx.ev.dwDebugEventCode, de_a.dwDebugEventCode);
+               "dwDebugEventCode differs: %lx (was %lx)\n", ctx.ev.dwDebugEventCode, de_a.dwDebugEventCode);
             ok(de_a.dwProcessId == ctx.ev.dwProcessId,
-               "dwProcessId differs: %x (was %x)\n", ctx.ev.dwProcessId, de_a.dwProcessId);
+               "dwProcessId differs: %lx (was %lx)\n", ctx.ev.dwProcessId, de_a.dwProcessId);
             ok(de_a.dwThreadId == ctx.ev.dwThreadId,
-               "dwThreadId differs: %x (was %x)\n", ctx.ev.dwThreadId, de_a.dwThreadId);
+               "dwThreadId differs: %lx (was %lx)\n", ctx.ev.dwThreadId, de_a.dwThreadId);
 
             next_event(&ctx, POLL_EVENT_TIMEOUT);
             if (ctx.ev.dwDebugEventCode == EXIT_THREAD_DEBUG_EVENT)
             {
                 ok(de_a.dwProcessId == ctx.ev.dwProcessId,
-                   "dwProcessId differs: %x (was %x)\n", ctx.ev.dwProcessId, de_a.dwProcessId);
+                   "dwProcessId differs: %lx (was %lx)\n", ctx.ev.dwProcessId, de_a.dwProcessId);
                 ok(de_a.dwThreadId == ctx.ev.dwThreadId,
-                   "dwThreadId differs: %x (was %x)\n", ctx.ev.dwThreadId, de_a.dwThreadId);
+                   "dwThreadId differs: %lx (was %lx)\n", ctx.ev.dwThreadId, de_a.dwThreadId);
 
                 ret = CloseHandle(thread_a);
-                ok(ret, "CloseHandle failed, last error %d.\n", GetLastError());
+                ok(ret, "CloseHandle failed, last error %ld.\n", GetLastError());
                 thread_a = NULL;
 
                 next_event(&ctx, POLL_EVENT_TIMEOUT);
             }
 
             ok(de_b.dwDebugEventCode == ctx.ev.dwDebugEventCode,
-               "dwDebugEventCode differs: %x (was %x)\n", ctx.ev.dwDebugEventCode, de_b.dwDebugEventCode);
+               "dwDebugEventCode differs: %lx (was %lx)\n", ctx.ev.dwDebugEventCode, de_b.dwDebugEventCode);
             ok(de_b.dwProcessId == ctx.ev.dwProcessId,
-               "dwProcessId differs: %x (was %x)\n", ctx.ev.dwProcessId, de_b.dwProcessId);
+               "dwProcessId differs: %lx (was %lx)\n", ctx.ev.dwProcessId, de_b.dwProcessId);
             ok(de_b.dwThreadId == ctx.ev.dwThreadId,
-               "dwThreadId differs: %x (was %x)\n", ctx.ev.dwThreadId, de_b.dwThreadId);
+               "dwThreadId differs: %lx (was %lx)\n", ctx.ev.dwThreadId, de_b.dwThreadId);
         }
         else
         {
             ok(de_b.dwDebugEventCode == ctx.ev.dwDebugEventCode,
-               "dwDebugEventCode differs: %x (was %x)\n", ctx.ev.dwDebugEventCode, de_b.dwDebugEventCode);
+               "dwDebugEventCode differs: %lx (was %lx)\n", ctx.ev.dwDebugEventCode, de_b.dwDebugEventCode);
             ok(de_b.dwProcessId == ctx.ev.dwProcessId,
-               "dwProcessId differs: %x (was %x)\n", ctx.ev.dwProcessId, de_b.dwProcessId);
+               "dwProcessId differs: %lx (was %lx)\n", ctx.ev.dwProcessId, de_b.dwProcessId);
             ok(de_b.dwThreadId == ctx.ev.dwThreadId,
-               "dwThreadId differs: %x (was %x)\n", ctx.ev.dwThreadId, de_b.dwThreadId);
+               "dwThreadId differs: %lx (was %lx)\n", ctx.ev.dwThreadId, de_b.dwThreadId);
 
             next_event(&ctx, POLL_EVENT_TIMEOUT);
             if (ctx.ev.dwDebugEventCode == EXIT_THREAD_DEBUG_EVENT)
             {
                 ok(de_b.dwProcessId == ctx.ev.dwProcessId,
-                   "dwProcessId differs: %x (was %x)\n", ctx.ev.dwProcessId, de_b.dwProcessId);
+                   "dwProcessId differs: %lx (was %lx)\n", ctx.ev.dwProcessId, de_b.dwProcessId);
                 ok(de_b.dwThreadId == ctx.ev.dwThreadId,
-                   "dwThreadId differs: %x (was %x)\n", ctx.ev.dwThreadId, de_b.dwThreadId);
+                   "dwThreadId differs: %lx (was %lx)\n", ctx.ev.dwThreadId, de_b.dwThreadId);
 
                 ret = CloseHandle(thread_b);
-                ok(ret, "CloseHandle failed, last error %d.\n", GetLastError());
+                ok(ret, "CloseHandle failed, last error %ld.\n", GetLastError());
                 thread_b = NULL;
 
                 next_event(&ctx, POLL_EVENT_TIMEOUT);
             }
 
             ok(de_a.dwDebugEventCode == ctx.ev.dwDebugEventCode,
-               "dwDebugEventCode differs: %x (was %x)\n", ctx.ev.dwDebugEventCode, de_a.dwDebugEventCode);
+               "dwDebugEventCode differs: %lx (was %lx)\n", ctx.ev.dwDebugEventCode, de_a.dwDebugEventCode);
             ok(de_a.dwProcessId == ctx.ev.dwProcessId,
-               "dwProcessId differs: %x (was %x)\n", ctx.ev.dwProcessId, de_a.dwProcessId);
+               "dwProcessId differs: %lx (was %lx)\n", ctx.ev.dwProcessId, de_a.dwProcessId);
             ok(de_a.dwThreadId == ctx.ev.dwThreadId,
-               "dwThreadId differs: %x (was %x)\n", ctx.ev.dwThreadId, de_a.dwThreadId);
+               "dwThreadId differs: %lx (was %lx)\n", ctx.ev.dwThreadId, de_a.dwThreadId);
         }
 
         if (thread_a)
         {
             next_event(&ctx, POLL_EVENT_TIMEOUT);
             ok(ctx.ev.dwDebugEventCode == EXIT_THREAD_DEBUG_EVENT,
-               "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
+               "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
 
             ret = CloseHandle(thread_a);
-            ok(ret, "CloseHandle failed, last error %d.\n", GetLastError());
+            ok(ret, "CloseHandle failed, last error %ld.\n", GetLastError());
         }
 
 
@@ -1697,10 +1697,10 @@ static void test_debugger(const char *argv0)
         {
             next_event(&ctx, POLL_EVENT_TIMEOUT);
             ok(ctx.ev.dwDebugEventCode == EXIT_THREAD_DEBUG_EVENT,
-               "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
+               "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
 
             ret = CloseHandle(thread_b);
-            ok(ret, "CloseHandle failed, last error %d.\n", GetLastError());
+            ok(ret, "CloseHandle failed, last error %ld.\n", GetLastError());
         }
     }
 
@@ -1711,7 +1711,7 @@ static void test_debugger(const char *argv0)
         memset(buf, OP_BP, sizeof(buf));
         memcpy(proc_code, &loop_code, sizeof(loop_code));
         ret = WriteProcessMemory(pi.hProcess, mem, buf, sizeof(buf), NULL);
-        ok(ret, "WriteProcessMemory failed: %u\n", GetLastError());
+        ok(ret, "WriteProcessMemory failed: %lu\n", GetLastError());
 
         ctx.thread_tag = 1;
 
@@ -1719,18 +1719,18 @@ static void test_debugger(const char *argv0)
         for (i = 0; i < worker_cnt; i++)
         {
             thread = CreateRemoteThread(pi.hProcess, NULL, 0, (void*)thread_proc, NULL, 0, NULL);
-            ok(thread != NULL, "CreateRemoteThread failed: %u\n", GetLastError());
+            ok(thread != NULL, "CreateRemoteThread failed: %lu\n", GetLastError());
 
             next_event(&ctx, WAIT_EVENT_TIMEOUT);
-            ok(ctx.ev.dwDebugEventCode == CREATE_THREAD_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
+            ok(ctx.ev.dwDebugEventCode == CREATE_THREAD_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
 
             ret = CloseHandle(thread);
-            ok(ret, "CloseHandle failed, last error %d.\n", GetLastError());
+            ok(ret, "CloseHandle failed, last error %ld.\n", GetLastError());
         }
 
         byte = OP_BP;
         ret = WriteProcessMemory(pi.hProcess, thread_proc + 1, &byte, 1, NULL);
-        ok(ret, "WriteProcessMemory failed: %u\n", GetLastError());
+        ok(ret, "WriteProcessMemory failed: %lu\n", GetLastError());
 
         expect_breakpoint_exception(&ctx, thread_proc + 1);
         exception_cnt = 1;
@@ -1740,7 +1740,7 @@ static void test_debugger(const char *argv0)
 
         byte = 0xc3; /* ret */
         ret = WriteProcessMemory(pi.hProcess, thread_proc + 1, &byte, 1, NULL);
-        ok(ret, "WriteProcessMemory failed: %u\n", GetLastError());
+        ok(ret, "WriteProcessMemory failed: %lu\n", GetLastError());
 
         for (;;)
         {
@@ -1748,12 +1748,12 @@ static void test_debugger(const char *argv0)
 
             /* even when there are more pending events, they are not reported until current event is continued */
             ret = WaitForDebugEvent(&ev, 10);
-            ok(GetLastError() == ERROR_SEM_TIMEOUT, "WaitForDebugEvent returned %x(%u)\n", ret, GetLastError());
+            ok(GetLastError() == ERROR_SEM_TIMEOUT, "WaitForDebugEvent returned %x(%lu)\n", ret, GetLastError());
 
             next_event(&ctx, POLL_EVENT_TIMEOUT);
             if (ctx.ev.dwDebugEventCode != EXCEPTION_DEBUG_EVENT) break;
-            trace("exception at %p in thread %04x\n", ctx.ev.u.Exception.ExceptionRecord.ExceptionAddress, ctx.ev.dwThreadId);
-            ok(ctx.ev.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT, "ExceptionCode = %x\n",
+            trace("exception at %p in thread %04lx\n", ctx.ev.u.Exception.ExceptionRecord.ExceptionAddress, ctx.ev.dwThreadId);
+            ok(ctx.ev.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT, "ExceptionCode = %lx\n",
                ctx.ev.u.Exception.ExceptionRecord.ExceptionCode);
             ok(ctx.ev.u.Exception.ExceptionRecord.ExceptionAddress == thread_proc + 1,
                "ExceptionAddress = %p\n", ctx.ev.u.Exception.ExceptionRecord.ExceptionAddress);
@@ -1775,7 +1775,7 @@ static void test_debugger(const char *argv0)
         {
             ok(ctx.ev.dwDebugEventCode == EXIT_THREAD_DEBUG_EVENT
                || broken(ctx.ev.dwDebugEventCode == CREATE_THREAD_DEBUG_EVENT), /* sometimes happens on vista */
-               "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
+               "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
             if (ctx.ev.dwDebugEventCode == EXIT_THREAD_DEBUG_EVENT && !--worker_cnt) break;
             next_event(&ctx, WAIT_EVENT_TIMEOUT);
         }
@@ -1792,7 +1792,7 @@ static void test_debugger(const char *argv0)
 
         fetch_thread_context(ctx.main_thread);
         ret = ReadProcessMemory(pi.hProcess, get_ip(&ctx.main_thread->ctx), &instr, 1, NULL);
-        ok(ret, "ReadProcessMemory failed: %u\n", GetLastError());
+        ok(ret, "ReadProcessMemory failed: %lu\n", GetLastError());
 
         orig_context = ctx.main_thread->ctx;
         ip = get_ip(&ctx.main_thread->ctx);
@@ -1825,36 +1825,36 @@ static void test_debugger(const char *argv0)
         fetch_thread_context(ctx.main_thread);
 #if defined(__i386__)
         /* win2k8 do not preserve eax, rcx and edx; newer versions do */
-        ok(ctx.main_thread->ctx.Ebx == 102, "Ebx = %x\n", ctx.main_thread->ctx.Ebx);
-        ok(ctx.main_thread->ctx.Esi == 105, "Esi = %x\n", ctx.main_thread->ctx.Esi);
-        ok(ctx.main_thread->ctx.Edi == 106, "Edi = %x\n", ctx.main_thread->ctx.Edi);
+        ok(ctx.main_thread->ctx.Ebx == 102, "Ebx = %lx\n", ctx.main_thread->ctx.Ebx);
+        ok(ctx.main_thread->ctx.Esi == 105, "Esi = %lx\n", ctx.main_thread->ctx.Esi);
+        ok(ctx.main_thread->ctx.Edi == 106, "Edi = %lx\n", ctx.main_thread->ctx.Edi);
 #elif defined(__x86_64__)
-        ok(ctx.main_thread->ctx.Rax == 101,   "Rax = %x\n", ctx.main_thread->ctx.Rax);
-        ok(ctx.main_thread->ctx.Rbx == 102, "Rbx = %x\n", ctx.main_thread->ctx.Rbx);
-        ok(ctx.main_thread->ctx.Rcx == 103, "Rcx = %x\n", ctx.main_thread->ctx.Rcx);
-        ok(ctx.main_thread->ctx.Rdx == 104, "Rdx = %x\n", ctx.main_thread->ctx.Rdx);
-        ok(ctx.main_thread->ctx.Rsi == 105, "Rsi = %x\n", ctx.main_thread->ctx.Rsi);
-        ok(ctx.main_thread->ctx.Rdi == 106, "Rdi = %x\n", ctx.main_thread->ctx.Rdi);
-        ok(ctx.main_thread->ctx.R8  == 107, "R8 = %x\n",  ctx.main_thread->ctx.R8);
-        ok(ctx.main_thread->ctx.R9  == 108, "R9 = %x\n",  ctx.main_thread->ctx.R9);
-        ok(ctx.main_thread->ctx.R10 == 109, "R10 = %x\n", ctx.main_thread->ctx.R10);
-        ok(ctx.main_thread->ctx.R11 == 110, "R11 = %x\n", ctx.main_thread->ctx.R11);
-        ok(ctx.main_thread->ctx.R12 == 111, "R12 = %x\n", ctx.main_thread->ctx.R12);
-        ok(ctx.main_thread->ctx.R13 == 112, "R13 = %x\n", ctx.main_thread->ctx.R13);
-        ok(ctx.main_thread->ctx.R14 == 113, "R14 = %x\n", ctx.main_thread->ctx.R14);
-        ok(ctx.main_thread->ctx.R15 == 114, "R15 = %x\n", ctx.main_thread->ctx.R15);
+        ok(ctx.main_thread->ctx.Rax == 101, "Rax = %llx\n", ctx.main_thread->ctx.Rax);
+        ok(ctx.main_thread->ctx.Rbx == 102, "Rbx = %llx\n", ctx.main_thread->ctx.Rbx);
+        ok(ctx.main_thread->ctx.Rcx == 103, "Rcx = %llx\n", ctx.main_thread->ctx.Rcx);
+        ok(ctx.main_thread->ctx.Rdx == 104, "Rdx = %llx\n", ctx.main_thread->ctx.Rdx);
+        ok(ctx.main_thread->ctx.Rsi == 105, "Rsi = %llx\n", ctx.main_thread->ctx.Rsi);
+        ok(ctx.main_thread->ctx.Rdi == 106, "Rdi = %llx\n", ctx.main_thread->ctx.Rdi);
+        ok(ctx.main_thread->ctx.R8  == 107, "R8 = %llx\n",  ctx.main_thread->ctx.R8);
+        ok(ctx.main_thread->ctx.R9  == 108, "R9 = %llx\n",  ctx.main_thread->ctx.R9);
+        ok(ctx.main_thread->ctx.R10 == 109, "R10 = %llx\n", ctx.main_thread->ctx.R10);
+        ok(ctx.main_thread->ctx.R11 == 110, "R11 = %llx\n", ctx.main_thread->ctx.R11);
+        ok(ctx.main_thread->ctx.R12 == 111, "R12 = %llx\n", ctx.main_thread->ctx.R12);
+        ok(ctx.main_thread->ctx.R13 == 112, "R13 = %llx\n", ctx.main_thread->ctx.R13);
+        ok(ctx.main_thread->ctx.R14 == 113, "R14 = %llx\n", ctx.main_thread->ctx.R14);
+        ok(ctx.main_thread->ctx.R15 == 114, "R15 = %llx\n", ctx.main_thread->ctx.R15);
 #endif
 
         byte = OP_BP;
         ret = WriteProcessMemory(pi.hProcess, ip, &byte, 1, NULL);
-        ok(ret, "WriteProcessMemory failed: %u\n", GetLastError());
+        ok(ret, "WriteProcessMemory failed: %lu\n", GetLastError());
 
         SetEvent(event);
         ResumeThread(ctx.main_thread->handle);
 
         next_event(&ctx, 2000);
-        ok(ctx.ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
-        ok(ctx.ev.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT, "ExceptionCode = %x\n",
+        ok(ctx.ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
+        ok(ctx.ev.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT, "ExceptionCode = %lx\n",
            ctx.ev.u.Exception.ExceptionRecord.ExceptionCode);
         ok(ctx.ev.u.Exception.ExceptionRecord.ExceptionAddress == ip,
            "ExceptionAddress = %p\n", ctx.ev.u.Exception.ExceptionRecord.ExceptionAddress);
@@ -1863,27 +1863,27 @@ static void test_debugger(const char *argv0)
         ok(get_ip(&ctx.main_thread->ctx) == ip + 1, "unexpected instruction pointer %p\n", get_ip(&ctx.main_thread->ctx));
 
 #if defined(__i386__)
-        ok(ctx.main_thread->ctx.Eax == 0,   "Eax = %x\n", ctx.main_thread->ctx.Eax);
-        ok(ctx.main_thread->ctx.Ebx == 102, "Ebx = %x\n", ctx.main_thread->ctx.Ebx);
-        ok(ctx.main_thread->ctx.Ecx != 103, "Ecx = %x\n", ctx.main_thread->ctx.Ecx);
-        ok(ctx.main_thread->ctx.Edx != 104, "Edx = %x\n", ctx.main_thread->ctx.Edx);
-        ok(ctx.main_thread->ctx.Esi == 105, "Esi = %x\n", ctx.main_thread->ctx.Esi);
-        ok(ctx.main_thread->ctx.Edi == 106, "Edi = %x\n", ctx.main_thread->ctx.Edi);
+        ok(ctx.main_thread->ctx.Eax == 0,   "Eax = %lx\n", ctx.main_thread->ctx.Eax);
+        ok(ctx.main_thread->ctx.Ebx == 102, "Ebx = %lx\n", ctx.main_thread->ctx.Ebx);
+        ok(ctx.main_thread->ctx.Ecx != 103, "Ecx = %lx\n", ctx.main_thread->ctx.Ecx);
+        ok(ctx.main_thread->ctx.Edx != 104, "Edx = %lx\n", ctx.main_thread->ctx.Edx);
+        ok(ctx.main_thread->ctx.Esi == 105, "Esi = %lx\n", ctx.main_thread->ctx.Esi);
+        ok(ctx.main_thread->ctx.Edi == 106, "Edi = %lx\n", ctx.main_thread->ctx.Edi);
 #elif defined(__x86_64__)
-        ok(ctx.main_thread->ctx.Rax == 0,   "Rax = %x\n", ctx.main_thread->ctx.Rax);
-        ok(ctx.main_thread->ctx.Rbx == 102, "Rbx = %x\n", ctx.main_thread->ctx.Rbx);
-        ok(ctx.main_thread->ctx.Rcx != 103, "Rcx = %x\n", ctx.main_thread->ctx.Rcx);
-        ok(ctx.main_thread->ctx.Rdx != 104, "Rdx = %x\n", ctx.main_thread->ctx.Rdx);
-        ok(ctx.main_thread->ctx.Rsi == 105, "Rsi = %x\n", ctx.main_thread->ctx.Rsi);
-        ok(ctx.main_thread->ctx.Rdi == 106, "Rdi = %x\n", ctx.main_thread->ctx.Rdi);
-        ok(ctx.main_thread->ctx.R8  != 107, "R8 = %x\n",  ctx.main_thread->ctx.R8);
-        ok(ctx.main_thread->ctx.R9  != 108, "R9 = %x\n",  ctx.main_thread->ctx.R9);
-        ok(ctx.main_thread->ctx.R10 != 109, "R10 = %x\n", ctx.main_thread->ctx.R10);
-        ok(ctx.main_thread->ctx.R11 != 110, "R11 = %x\n", ctx.main_thread->ctx.R11);
-        ok(ctx.main_thread->ctx.R12 == 111, "R12 = %x\n", ctx.main_thread->ctx.R12);
-        ok(ctx.main_thread->ctx.R13 == 112, "R13 = %x\n", ctx.main_thread->ctx.R13);
-        ok(ctx.main_thread->ctx.R14 == 113, "R14 = %x\n", ctx.main_thread->ctx.R14);
-        ok(ctx.main_thread->ctx.R15 == 114, "R15 = %x\n", ctx.main_thread->ctx.R15);
+        ok(ctx.main_thread->ctx.Rax == 0,   "Rax = %llx\n", ctx.main_thread->ctx.Rax);
+        ok(ctx.main_thread->ctx.Rbx == 102, "Rbx = %llx\n", ctx.main_thread->ctx.Rbx);
+        ok(ctx.main_thread->ctx.Rcx != 103, "Rcx = %llx\n", ctx.main_thread->ctx.Rcx);
+        ok(ctx.main_thread->ctx.Rdx != 104, "Rdx = %llx\n", ctx.main_thread->ctx.Rdx);
+        ok(ctx.main_thread->ctx.Rsi == 105, "Rsi = %llx\n", ctx.main_thread->ctx.Rsi);
+        ok(ctx.main_thread->ctx.Rdi == 106, "Rdi = %llx\n", ctx.main_thread->ctx.Rdi);
+        ok(ctx.main_thread->ctx.R8  != 107, "R8 = %llx\n",  ctx.main_thread->ctx.R8);
+        ok(ctx.main_thread->ctx.R9  != 108, "R9 = %llx\n",  ctx.main_thread->ctx.R9);
+        ok(ctx.main_thread->ctx.R10 != 109, "R10 = %llx\n", ctx.main_thread->ctx.R10);
+        ok(ctx.main_thread->ctx.R11 != 110, "R11 = %llx\n", ctx.main_thread->ctx.R11);
+        ok(ctx.main_thread->ctx.R12 == 111, "R12 = %llx\n", ctx.main_thread->ctx.R12);
+        ok(ctx.main_thread->ctx.R13 == 112, "R13 = %llx\n", ctx.main_thread->ctx.R13);
+        ok(ctx.main_thread->ctx.R14 == 113, "R14 = %llx\n", ctx.main_thread->ctx.R14);
+        ok(ctx.main_thread->ctx.R15 == 114, "R15 = %llx\n", ctx.main_thread->ctx.R15);
 #endif
 
         ctx.main_thread->ctx = orig_context;
@@ -1891,11 +1891,11 @@ static void test_debugger(const char *argv0)
         set_thread_context(&ctx, ctx.main_thread);
 
         ret = WriteProcessMemory(pi.hProcess, ip, &instr, 1, NULL);
-        ok(ret, "WriteProcessMemory failed: %u\n", GetLastError());
+        ok(ret, "WriteProcessMemory failed: %lu\n", GetLastError());
 
         memset(buf + 10, 0x90, 10); /* nop */
         ret = WriteProcessMemory(pi.hProcess, mem + 10, buf + 10, 10, NULL);
-        ok(ret, "WriteProcessMemory failed: %u\n", GetLastError());
+        ok(ret, "WriteProcessMemory failed: %lu\n", GetLastError());
 
         next_event(&ctx, POLL_EVENT_TIMEOUT);
 
@@ -1918,8 +1918,8 @@ static void test_debugger(const char *argv0)
         next_event(&ctx, WAIT_EVENT_TIMEOUT);
         if (sizeof(void*) != 4 || ctx.ev.u.Exception.ExceptionRecord.ExceptionCode != EXCEPTION_BREAKPOINT)
         {
-            ok(ctx.ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT, "dwDebugEventCode = %d\n", ctx.ev.dwDebugEventCode);
-            ok(ctx.ev.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_SINGLE_STEP, "ExceptionCode = %x\n",
+            ok(ctx.ev.dwDebugEventCode == EXCEPTION_DEBUG_EVENT, "dwDebugEventCode = %ld\n", ctx.ev.dwDebugEventCode);
+            ok(ctx.ev.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_SINGLE_STEP, "ExceptionCode = %lx\n",
                ctx.ev.u.Exception.ExceptionRecord.ExceptionCode);
             ok(ctx.ev.u.Exception.ExceptionRecord.ExceptionAddress == mem + 10 ||
                ctx.ev.u.Exception.ExceptionRecord.ExceptionAddress == mem + 11,
@@ -1946,11 +1946,11 @@ static void test_debugger(const char *argv0)
     while (ctx.ev.dwDebugEventCode != EXIT_PROCESS_DEBUG_EVENT);
 
     ret = CloseHandle(event);
-    ok(ret, "CloseHandle failed, last error %d.\n", GetLastError());
+    ok(ret, "CloseHandle failed, last error %ld.\n", GetLastError());
     ret = CloseHandle(pi.hThread);
-    ok(ret, "CloseHandle failed, last error %d.\n", GetLastError());
+    ok(ret, "CloseHandle failed, last error %ld.\n", GetLastError());
     ret = CloseHandle(pi.hProcess);
-    ok(ret, "CloseHandle failed, last error %d.\n", GetLastError());
+    ok(ret, "CloseHandle failed, last error %ld.\n", GetLastError());
 }
 
 static DWORD run_child_wait( char *cmd, HANDLE event )
@@ -1961,14 +1961,14 @@ static DWORD run_child_wait( char *cmd, HANDLE event )
     DWORD exit_code;
 
     ret = CreateProcessA(NULL, cmd, NULL, NULL, TRUE, DEBUG_PROCESS, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess failed, last error %#x.\n", GetLastError());
+    ok(ret, "CreateProcess failed, last error %#lx.\n", GetLastError());
     Sleep(200);
     CloseHandle( pDbgUiGetThreadDebugObject() );
     pDbgUiSetThreadDebugObject( 0 );
     SetEvent( event );
     WaitForSingleObject( pi.hProcess, 1000 );
     ret = GetExitCodeProcess( pi.hProcess, &exit_code );
-    ok( ret, "GetExitCodeProcess failed err=%d\n", GetLastError());
+    ok( ret, "GetExitCodeProcess failed err=%ld\n", GetLastError());
     CloseHandle( pi.hProcess );
     CloseHandle( pi.hThread );
     return exit_code;
@@ -1986,11 +1986,11 @@ static DWORD WINAPI debug_and_exit(void *arg)
     BOOL ret;
 
     ret = CreateProcessA(NULL, cmd, NULL, NULL, TRUE, DEBUG_PROCESS, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess failed, last error %#x.\n", GetLastError());
+    ok(ret, "CreateProcess failed, last error %#lx.\n", GetLastError());
     debug = pDbgUiGetThreadDebugObject();
     status = pNtSetInformationDebugObject( debug, DebugObjectKillProcessOnExitInformation,
                                            &val, sizeof(val), NULL );
-    ok( !status, "NtSetInformationDebugObject failed %x\n", status );
+    ok( !status, "NtSetInformationDebugObject failed %lx\n", status );
     *(HANDLE *)arg = debug;
     Sleep(200);
     ExitThread(0);
@@ -2006,11 +2006,11 @@ static DWORD WINAPI debug_and_wait(void *arg)
 
     pDbgUiSetThreadDebugObject( debug );
     ret = CreateProcessA(NULL, cmd, NULL, NULL, TRUE, DEBUG_PROCESS, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess failed, last error %#x.\n", GetLastError());
+    ok(ret, "CreateProcess failed, last error %#lx.\n", GetLastError());
     debug = pDbgUiGetThreadDebugObject();
     status = pNtSetInformationDebugObject( debug, DebugObjectKillProcessOnExitInformation,
                                            &val, sizeof(val), NULL );
-    ok( !status, "NtSetInformationDebugObject failed %x\n", status );
+    ok( !status, "NtSetInformationDebugObject failed %lx\n", status );
     Sleep(INFINITE);
     ExitThread(0);
 }
@@ -2020,7 +2020,7 @@ static DWORD WINAPI create_debug_port(void *arg)
     STARTUPINFOA si = { sizeof(si) };
     NTSTATUS status = pDbgUiConnectToDbg();
 
-    ok( !status, "DbgUiConnectToDbg failed %x\n", status );
+    ok( !status, "DbgUiConnectToDbg failed %lx\n", status );
     *(HANDLE *)arg = pDbgUiGetThreadDebugObject();
     Sleep( INFINITE );
     ExitThread(0);
@@ -2037,50 +2037,50 @@ static void test_kill_on_exit(const char *argv0)
     ULONG val;
 
     event = CreateEventW(&sa, FALSE, FALSE, NULL);
-    ok(event != NULL, "CreateEvent failed: %u\n", GetLastError());
+    ok(event != NULL, "CreateEvent failed: %lu\n", GetLastError());
 
     cmd = heap_alloc(strlen(argv0) + strlen(arguments) + 16);
-    sprintf(cmd, "%s%s%x\n", argv0, arguments, (DWORD)(DWORD_PTR)event);
+    sprintf(cmd, "%s%s%lx\n", argv0, arguments, (DWORD)(DWORD_PTR)event);
 
     status = pNtCreateDebugObject( &debug, DEBUG_ALL_ACCESS, &attr, 0 );
-    ok( !status, "NtCreateDebugObject failed %x\n", status );
+    ok( !status, "NtCreateDebugObject failed %lx\n", status );
     pDbgUiSetThreadDebugObject( debug );
     exit_code = run_child_wait( cmd, event );
-    ok( exit_code == 0, "exit code = %08x\n", exit_code);
+    ok( exit_code == 0, "exit code = %08lx\n", exit_code);
 
     status = pNtCreateDebugObject( &debug, DEBUG_ALL_ACCESS, &attr, DEBUG_KILL_ON_CLOSE );
-    ok( !status, "NtCreateDebugObject failed %x\n", status );
+    ok( !status, "NtCreateDebugObject failed %lx\n", status );
     pDbgUiSetThreadDebugObject( debug );
     exit_code = run_child_wait( cmd, event );
-    ok( exit_code == STATUS_DEBUGGER_INACTIVE, "exit code = %08x\n", exit_code);
+    ok( exit_code == STATUS_DEBUGGER_INACTIVE, "exit code = %08lx\n", exit_code);
 
     status = pNtCreateDebugObject( &debug, DEBUG_ALL_ACCESS, &attr, 0xfffe );
-    ok( status == STATUS_INVALID_PARAMETER, "NtCreateDebugObject failed %x\n", status );
+    ok( status == STATUS_INVALID_PARAMETER, "NtCreateDebugObject failed %lx\n", status );
 
     status = pNtCreateDebugObject( &debug, DEBUG_ALL_ACCESS, &attr, 0 );
-    ok( !status, "NtCreateDebugObject failed %x\n", status );
+    ok( !status, "NtCreateDebugObject failed %lx\n", status );
     pDbgUiSetThreadDebugObject( debug );
     val = DEBUG_KILL_ON_CLOSE;
     status = pNtSetInformationDebugObject( debug, DebugObjectKillProcessOnExitInformation,
                                            &val, sizeof(val), NULL );
-    ok( !status, "NtSetInformationDebugObject failed %x\n", status );
+    ok( !status, "NtSetInformationDebugObject failed %lx\n", status );
     exit_code = run_child_wait( cmd, event );
-    ok( exit_code == STATUS_DEBUGGER_INACTIVE, "exit code = %08x\n", exit_code);
+    ok( exit_code == STATUS_DEBUGGER_INACTIVE, "exit code = %08lx\n", exit_code);
 
     status = pNtCreateDebugObject( &debug, DEBUG_ALL_ACCESS, &attr, DEBUG_KILL_ON_CLOSE );
-    ok( !status, "NtCreateDebugObject failed %x\n", status );
+    ok( !status, "NtCreateDebugObject failed %lx\n", status );
     pDbgUiSetThreadDebugObject( debug );
     val = 0;
     status = pNtSetInformationDebugObject( debug, DebugObjectKillProcessOnExitInformation,
                                            &val, sizeof(val), NULL );
-    ok( !status, "NtSetInformationDebugObject failed %x\n", status );
+    ok( !status, "NtSetInformationDebugObject failed %lx\n", status );
     exit_code = run_child_wait( cmd, event );
-    ok( exit_code == 0, "exit code = %08x\n", exit_code);
+    ok( exit_code == 0, "exit code = %08lx\n", exit_code);
 
     status = pDbgUiConnectToDbg();
-    ok( !status, "DbgUiConnectToDbg failed %x\n", status );
+    ok( !status, "DbgUiConnectToDbg failed %lx\n", status );
     exit_code = run_child_wait( cmd, event );
-    ok( exit_code == STATUS_DEBUGGER_INACTIVE, "exit code = %08x\n", exit_code);
+    ok( exit_code == STATUS_DEBUGGER_INACTIVE, "exit code = %08lx\n", exit_code);
 
     /* test that threads close the debug port on exit */
     thread = CreateThread(NULL, 0, debug_and_exit, &debug, 0, &tid);
@@ -2090,41 +2090,41 @@ static void test_kill_on_exit(const char *argv0)
     status = pNtSetInformationDebugObject( debug, DebugObjectKillProcessOnExitInformation,
                                            &val, sizeof(val), NULL );
     ok( status == STATUS_INVALID_HANDLE || broken(status == STATUS_SUCCESS),  /* wow64 */
-        "NtSetInformationDebugObject failed %x\n", status );
+        "NtSetInformationDebugObject failed %lx\n", status );
     SetEvent( event );
     if (!status)
     {
         WaitForSingleObject( pi.hProcess, 100 );
         GetExitCodeProcess( pi.hProcess, &exit_code );
-        ok( exit_code == STILL_ACTIVE, "exit code = %08x\n", exit_code);
+        ok( exit_code == STILL_ACTIVE, "exit code = %08lx\n", exit_code);
         CloseHandle( debug );
     }
     WaitForSingleObject( pi.hProcess, 1000 );
     GetExitCodeProcess( pi.hProcess, &exit_code );
-    ok( exit_code == 0, "exit code = %08x\n", exit_code);
+    ok( exit_code == 0, "exit code = %08lx\n", exit_code);
     CloseHandle( pi.hProcess );
     CloseHandle( pi.hThread );
     CloseHandle( thread );
 
     /* but not on forced exit */
     status = pNtCreateDebugObject( &debug, DEBUG_ALL_ACCESS, &attr, DEBUG_KILL_ON_CLOSE );
-    ok( !status, "NtCreateDebugObject failed %x\n", status );
+    ok( !status, "NtCreateDebugObject failed %lx\n", status );
     thread = CreateThread(NULL, 0, debug_and_wait, &debug, 0, &tid);
     Sleep( 100 );
     ok( debug != 0, "no debug port\n" );
     val = 1;
     status = pNtSetInformationDebugObject( debug, DebugObjectKillProcessOnExitInformation,
                                            &val, sizeof(val), NULL );
-    ok( status == STATUS_SUCCESS, "NtSetInformationDebugObject failed %x\n", status );
+    ok( status == STATUS_SUCCESS, "NtSetInformationDebugObject failed %lx\n", status );
     TerminateThread( thread, 0 );
     status = pNtSetInformationDebugObject( debug, DebugObjectKillProcessOnExitInformation,
                                            &val, sizeof(val), NULL );
-    ok( status == STATUS_SUCCESS, "NtSetInformationDebugObject failed %x\n", status );
+    ok( status == STATUS_SUCCESS, "NtSetInformationDebugObject failed %lx\n", status );
     WaitForSingleObject( pi.hProcess, 300 );
     GetExitCodeProcess( pi.hProcess, &exit_code );
     todo_wine
     ok( exit_code == STATUS_DEBUGGER_INACTIVE || broken(exit_code == STILL_ACTIVE), /* wow64 */
-        "exit code = %08x\n", exit_code);
+        "exit code = %08lx\n", exit_code);
     CloseHandle( pi.hProcess );
     CloseHandle( pi.hThread );
     CloseHandle( thread );
@@ -2137,11 +2137,11 @@ static void test_kill_on_exit(const char *argv0)
     val = 0;
     status = pNtSetInformationDebugObject( debug, DebugObjectKillProcessOnExitInformation,
                                            &val, sizeof(val), NULL );
-    ok( status == STATUS_SUCCESS, "NtSetInformationDebugObject failed %x\n", status );
+    ok( status == STATUS_SUCCESS, "NtSetInformationDebugObject failed %lx\n", status );
     TerminateThread( thread, 0 );
     status = pNtSetInformationDebugObject( debug, DebugObjectKillProcessOnExitInformation,
                                            &val, sizeof(val), NULL );
-    ok( status == STATUS_SUCCESS, "NtSetInformationDebugObject failed %x\n", status );
+    ok( status == STATUS_SUCCESS, "NtSetInformationDebugObject failed %lx\n", status );
     CloseHandle( debug );
     CloseHandle( thread );
 
@@ -2191,7 +2191,7 @@ START_TEST(debugger)
     else if (myARGC >= 4 && !strcmp(myARGV[2], "wait"))
     {
         DWORD event, cnt = 1;
-        sscanf(myARGV[3], "%x", &event);
+        sscanf(myARGV[3], "%lx", &event);
         if (myARGC >= 5) cnt = atoi(myARGV[4]);
         wait_debugger((HANDLE)(DWORD_PTR)event, cnt);
     }
diff --git a/dlls/kernel32/tests/directory.c b/dlls/kernel32/tests/directory.c
index de78c616816..d9f6ee4c9a5 100644
--- a/dlls/kernel32/tests/directory.c
+++ b/dlls/kernel32/tests/directory.c
@@ -42,9 +42,9 @@ static void test_granted_access(HANDLE handle, ACCESS_MASK access, int line)
 
     status = pNtQueryObject(handle, ObjectBasicInformation, &obj_info,
                             sizeof(obj_info), NULL);
-    ok_(__FILE__, line)(!status, "NtQueryObject with err: %08x\n", status);
+    ok_(__FILE__, line)(!status, "NtQueryObject with err: %08lx\n", status);
     ok_(__FILE__, line)(obj_info.GrantedAccess == access, "Granted access should "
-        "be 0x%08x, instead of 0x%08x\n", access, obj_info.GrantedAccess);
+        "be 0x%08lx, instead of 0x%08lx\n", access, obj_info.GrantedAccess);
 }
 
 /* If you change something in these tests, please do the same
@@ -185,12 +185,12 @@ static void test_CreateDirectoryA(void)
     ret = CreateDirectoryA(NULL, NULL);
     ok(ret == FALSE && (GetLastError() == ERROR_PATH_NOT_FOUND ||
                         GetLastError() == ERROR_INVALID_PARAMETER),
-       "CreateDirectoryA(NULL): ret=%d err=%d\n", ret, GetLastError());
+       "CreateDirectoryA(NULL): ret=%d err=%ld\n", ret, GetLastError());
 
     ret = CreateDirectoryA("", NULL);
     ok(ret == FALSE && (GetLastError() == ERROR_BAD_PATHNAME ||
                         GetLastError() == ERROR_PATH_NOT_FOUND),
-       "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
+       "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError());
 
     ret = GetSystemDirectoryA(tmpdir, MAX_PATH);
     ok(ret < MAX_PATH, "System directory should fit into MAX_PATH\n");
@@ -201,53 +201,53 @@ static void test_CreateDirectoryA(void)
 
     ret = CreateDirectoryA(".", NULL);
     ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS,
-       "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
+       "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError());
 
 
     ret = CreateDirectoryA("..", NULL);
     ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS,
-       "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
+       "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError());
 
     GetTempPathA(MAX_PATH, tmpdir);
     tmpdir[3] = 0; /* truncate the path */
     ret = CreateDirectoryA(tmpdir, NULL);
     ok(ret == FALSE && (GetLastError() == ERROR_ALREADY_EXISTS ||
                         GetLastError() == ERROR_ACCESS_DENIED),
-       "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
+       "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError());
 
     GetTempPathA(MAX_PATH, tmpdir);
     lstrcatA(tmpdir, "Please Remove Me");
     ret = CreateDirectoryA(tmpdir, NULL);
-    ok(ret == TRUE,       "CreateDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
+    ok(ret == TRUE,       "CreateDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError());
 
     ret = CreateDirectoryA(tmpdir, NULL);
     ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS,
-       "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
+       "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError());
 
     ret = RemoveDirectoryA(tmpdir);
     ok(ret == TRUE,
-       "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
+       "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError());
 
 
     lstrcatA(tmpdir, "?");
     ret = CreateDirectoryA(tmpdir, NULL);
     ok(ret == FALSE && (GetLastError() == ERROR_INVALID_NAME ||
 			GetLastError() == ERROR_PATH_NOT_FOUND),
-       "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
+       "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError());
     RemoveDirectoryA(tmpdir);
 
     tmpdir[lstrlenA(tmpdir) - 1] = '*';
     ret = CreateDirectoryA(tmpdir, NULL);
     ok(ret == FALSE && (GetLastError() == ERROR_INVALID_NAME ||
 			GetLastError() == ERROR_PATH_NOT_FOUND),
-       "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
+       "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError());
     RemoveDirectoryA(tmpdir);
 
     GetTempPathA(MAX_PATH, tmpdir);
     lstrcatA(tmpdir, "Please Remove Me/Please Remove Me");
     ret = CreateDirectoryA(tmpdir, NULL);
     ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND, 
-       "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
+       "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError());
     RemoveDirectoryA(tmpdir);
 
     /* Test behavior with a trailing dot.
@@ -257,21 +257,21 @@ static void test_CreateDirectoryA(void)
     lstrcatA(tmpdir, "Please Remove Me.");
     ret = CreateDirectoryA(tmpdir, NULL);
     ok(ret == TRUE,
-       "CreateDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
+       "CreateDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError());
 
     lstrcatA(tmpdir, "/Please Remove Me");
     ret = CreateDirectoryA(tmpdir, NULL);
     ok(ret == TRUE,
-       "CreateDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
+       "CreateDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError());
     ret = RemoveDirectoryA(tmpdir);
     ok(ret == TRUE,
-       "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
+       "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError());
 
     GetTempPathA(MAX_PATH, tmpdir);
     lstrcatA(tmpdir, "Please Remove Me");
     ret = RemoveDirectoryA(tmpdir);
     ok(ret == TRUE,
-       "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
+       "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError());
 
     /* Test behavior with two trailing dots.
      * The directory should be created without the trailing dots.
@@ -280,25 +280,25 @@ static void test_CreateDirectoryA(void)
     lstrcatA(tmpdir, "Please Remove Me..");
     ret = CreateDirectoryA(tmpdir, NULL);
     ok(ret == TRUE,
-       "CreateDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
+       "CreateDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError());
 
     lstrcatA(tmpdir, "/Please Remove Me");
     ret = CreateDirectoryA(tmpdir, NULL);
     ok(ret == TRUE || /* On Win98 */
        (ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND), /* On NT! */
-       "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
+       "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError());
     if (ret == TRUE)
     {
         ret = RemoveDirectoryA(tmpdir);
         ok(ret == TRUE,
-           "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
+           "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError());
     }
 
     GetTempPathA(MAX_PATH, tmpdir);
     lstrcatA(tmpdir, "Please Remove Me");
     ret = RemoveDirectoryA(tmpdir);
     ok(ret == TRUE,
-       "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
+       "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError());
 
     /* Test behavior with a trailing space.
      * The directory should be created without the trailing space.
@@ -307,25 +307,25 @@ static void test_CreateDirectoryA(void)
     lstrcatA(tmpdir, "Please Remove Me ");
     ret = CreateDirectoryA(tmpdir, NULL);
     ok(ret == TRUE,
-       "CreateDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
+       "CreateDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError());
 
     lstrcatA(tmpdir, "/Please Remove Me");
     ret = CreateDirectoryA(tmpdir, NULL);
     ok(ret == TRUE || /* On Win98 */
        (ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND), /* On NT! */
-       "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
+       "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError());
     if (ret == TRUE)
     {
         ret = RemoveDirectoryA(tmpdir);
         ok(ret == TRUE,
-           "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
+           "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError());
     }
 
     GetTempPathA(MAX_PATH, tmpdir);
     lstrcatA(tmpdir, "Please Remove Me");
     ret = RemoveDirectoryA(tmpdir);
     ok(ret == TRUE,
-       "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
+       "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError());
 
     /* Test behavior with a trailing space.
      * The directory should be created without the trailing spaces.
@@ -334,25 +334,25 @@ static void test_CreateDirectoryA(void)
     lstrcatA(tmpdir, "Please Remove Me  ");
     ret = CreateDirectoryA(tmpdir, NULL);
     ok(ret == TRUE,
-       "CreateDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
+       "CreateDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError());
 
     lstrcatA(tmpdir, "/Please Remove Me");
     ret = CreateDirectoryA(tmpdir, NULL);
     ok(ret == TRUE || /* On Win98 */
        (ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND), /* On NT! */
-       "CreateDirectoryA(%s): ret=%d err=%d\n", tmpdir, ret, GetLastError());
+       "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError());
     if (ret == TRUE)
     {
         ret = RemoveDirectoryA(tmpdir);
         ok(ret == TRUE,
-           "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
+           "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError());
     }
 
     GetTempPathA(MAX_PATH, tmpdir);
     lstrcatA(tmpdir, "Please Remove Me");
     ret = RemoveDirectoryA(tmpdir);
     ok(ret == TRUE,
-       "RemoveDirectoryA(%s) failed err=%d\n", tmpdir, GetLastError());
+       "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError());
     SetCurrentDirectoryW(curdir);
 }
 
@@ -375,32 +375,32 @@ static void test_CreateDirectoryW(void)
         return;
     }
     ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND,
-       "should not create NULL path ret %u err %u\n", ret, GetLastError());
+       "should not create NULL path ret %u err %lu\n", ret, GetLastError());
 
     ret = CreateDirectoryW(empty_strW, NULL);
     ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND,
-       "should not create empty path ret %u err %u\n", ret, GetLastError());
+       "should not create empty path ret %u err %lu\n", ret, GetLastError());
 
     ret = GetSystemDirectoryW(tmpdir, MAX_PATH);
     ok(ret < MAX_PATH, "System directory should fit into MAX_PATH\n");
 
     GetCurrentDirectoryW(MAX_PATH, curdir);
     ret = SetCurrentDirectoryW(tmpdir);
-    ok(ret == TRUE, "could not chdir to the System directory ret %u err %u\n", ret, GetLastError());
+    ok(ret == TRUE, "could not chdir to the System directory ret %u err %lu\n", ret, GetLastError());
 
     ret = CreateDirectoryW(dotW, NULL);
     ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS,
-       "should not create existing path ret %u err %u\n", ret, GetLastError());
+       "should not create existing path ret %u err %lu\n", ret, GetLastError());
 
     ret = CreateDirectoryW(dotdotW, NULL);
     ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS,
-       "should not create existing path ret %u err %u\n", ret, GetLastError());
+       "should not create existing path ret %u err %lu\n", ret, GetLastError());
 
     GetTempPathW(MAX_PATH, tmpdir);
     tmpdir[3] = 0; /* truncate the path */
     ret = CreateDirectoryW(tmpdir, NULL);
     ok(ret == FALSE && (GetLastError() == ERROR_ACCESS_DENIED || GetLastError() == ERROR_ALREADY_EXISTS),
-       "should deny access to the drive root ret %u err %u\n", ret, GetLastError());
+       "should deny access to the drive root ret %u err %lu\n", ret, GetLastError());
 
     GetTempPathW(MAX_PATH, tmpdir);
     lstrcatW(tmpdir, tmp_dir_name);
@@ -409,7 +409,7 @@ static void test_CreateDirectoryW(void)
 
     ret = CreateDirectoryW(tmpdir, NULL);
     ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS,
-       "should not create existing path ret %u err %u\n", ret, GetLastError());
+       "should not create existing path ret %u err %lu\n", ret, GetLastError());
 
     ret = RemoveDirectoryW(tmpdir);
     ok(ret == TRUE, "RemoveDirectoryW should always succeed\n");
@@ -417,7 +417,7 @@ static void test_CreateDirectoryW(void)
     lstrcatW(tmpdir, questionW);
     ret = CreateDirectoryW(tmpdir, NULL);
     ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
-       "CreateDirectoryW with ? wildcard name should fail with error 183, ret=%s error=%d\n",
+       "CreateDirectoryW with ? wildcard name should fail with error 183, ret=%s error=%ld\n",
        ret ? " True" : "False", GetLastError());
     ret = RemoveDirectoryW(tmpdir);
     ok(ret == FALSE, "RemoveDirectoryW should have failed\n");
@@ -425,7 +425,7 @@ static void test_CreateDirectoryW(void)
     tmpdir[lstrlenW(tmpdir) - 1] = '*';
     ret = CreateDirectoryW(tmpdir, NULL);
     ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
-       "CreateDirectoryW with * wildcard name should fail with error 183, ret=%s error=%d\n",
+       "CreateDirectoryW with * wildcard name should fail with error 183, ret=%s error=%ld\n",
        ret ? " True" : "False", GetLastError());
     ret = RemoveDirectoryW(tmpdir);
     ok(ret == FALSE, "RemoveDirectoryW should have failed\n");
@@ -436,7 +436,7 @@ static void test_CreateDirectoryW(void)
     lstrcatW(tmpdir, tmp_dir_name);
     ret = CreateDirectoryW(tmpdir, NULL);
     ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND,
-      "CreateDirectoryW with multiple nonexistent directories in path should fail ret %u err %u\n",
+      "CreateDirectoryW with multiple nonexistent directories in path should fail ret %u err %lu\n",
        ret, GetLastError());
     ret = RemoveDirectoryW(tmpdir);
     ok(ret == FALSE, "RemoveDirectoryW should have failed\n");
@@ -461,7 +461,7 @@ static void test_RemoveDirectoryA(void)
     SetLastError(0xdeadbeef);
     ok(!RemoveDirectoryA(tmpdir), "RemoveDirectoryA succeeded\n");
     ok(GetLastError() == ERROR_SHARING_VIOLATION,
-       "Expected ERROR_SHARING_VIOLATION, got %u\n", GetLastError());
+       "Expected ERROR_SHARING_VIOLATION, got %lu\n", GetLastError());
 
     TEST_GRANTED_ACCESS(NtCurrentTeb()->Peb->ProcessParameters->CurrentDirectory.Handle,
                         FILE_TRAVERSE | SYNCHRONIZE);
@@ -474,14 +474,14 @@ static void test_RemoveDirectoryA(void)
     ret = RemoveDirectoryA(tmpdir);
     ok(ret == FALSE && (GetLastError() == ERROR_INVALID_NAME ||
 			GetLastError() == ERROR_PATH_NOT_FOUND),
-       "RemoveDirectoryA with ? wildcard name should fail, ret=%s error=%d\n",
+       "RemoveDirectoryA with ? wildcard name should fail, ret=%s error=%ld\n",
        ret ? " True" : "False", GetLastError());
 
     tmpdir[lstrlenA(tmpdir) - 1] = '*';
     ret = RemoveDirectoryA(tmpdir);
     ok(ret == FALSE && (GetLastError() == ERROR_INVALID_NAME ||
 			GetLastError() == ERROR_PATH_NOT_FOUND),
-       "RemoveDirectoryA with * wildcard name should fail, ret=%s error=%d\n",
+       "RemoveDirectoryA with * wildcard name should fail, ret=%s error=%ld\n",
        ret ? " True" : "False", GetLastError());
 }
 
@@ -510,7 +510,7 @@ static void test_RemoveDirectoryW(void)
     SetLastError(0xdeadbeef);
     ok(!RemoveDirectoryW(tmpdir), "RemoveDirectoryW succeeded\n");
     ok(GetLastError() == ERROR_SHARING_VIOLATION,
-       "Expected ERROR_SHARING_VIOLATION, got %u\n", GetLastError());
+       "Expected ERROR_SHARING_VIOLATION, got %lu\n", GetLastError());
 
     TEST_GRANTED_ACCESS(NtCurrentTeb()->Peb->ProcessParameters->CurrentDirectory.Handle,
                         FILE_TRAVERSE | SYNCHRONIZE);
@@ -522,13 +522,13 @@ static void test_RemoveDirectoryW(void)
     lstrcatW(tmpdir, questionW);
     ret = RemoveDirectoryW(tmpdir);
     ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
-       "RemoveDirectoryW with wildcard should fail with error 183, ret=%s error=%d\n",
+       "RemoveDirectoryW with wildcard should fail with error 183, ret=%s error=%ld\n",
        ret ? " True" : "False", GetLastError());
 
     tmpdir[lstrlenW(tmpdir) - 1] = '*';
     ret = RemoveDirectoryW(tmpdir);
     ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
-       "RemoveDirectoryW with * wildcard name should fail with error 183, ret=%s error=%d\n",
+       "RemoveDirectoryW with * wildcard name should fail with error 183, ret=%s error=%ld\n",
        ret ? " True" : "False", GetLastError());
 }
 
@@ -536,9 +536,9 @@ static void test_SetCurrentDirectoryA(void)
 {
     SetLastError(0);
     ok( !SetCurrentDirectoryA( "\\some_dummy_dir" ), "SetCurrentDirectoryA succeeded\n" );
-    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %ld\n", GetLastError() );
     ok( !SetCurrentDirectoryA( "\\some_dummy\\subdir" ), "SetCurrentDirectoryA succeeded\n" );
-    ok( GetLastError() == ERROR_PATH_NOT_FOUND, "wrong error %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_PATH_NOT_FOUND, "wrong error %ld\n", GetLastError() );
 }
 
 static void test_CreateDirectory_root(void)
@@ -551,7 +551,7 @@ static void test_CreateDirectory_root(void)
     GetCurrentDirectoryA(sizeof(curdir), curdir);
 
     ret = SetCurrentDirectoryA("C:\\");
-    ok(ret, "SetCurrentDirectory error %u\n", GetLastError());
+    ok(ret, "SetCurrentDirectory error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = CreateDirectoryA("C:\\", NULL);
@@ -562,22 +562,22 @@ static void test_CreateDirectory_root(void)
         SetCurrentDirectoryA(curdir);
         return;
     }
-    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = CreateDirectoryA("C:", NULL);
     ok(!ret, "CreateDirectory should fail\n");
-    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = CreateDirectoryW(drive_c_root, NULL);
     ok(!ret, "CreateDirectory should fail\n");
-    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = CreateDirectoryW(drive_c, NULL);
     ok(!ret, "CreateDirectory should fail\n");
-    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got %lu\n", GetLastError());
 
     SetCurrentDirectoryA(curdir);
 }
diff --git a/dlls/kernel32/tests/drive.c b/dlls/kernel32/tests/drive.c
index 98dc454f340..e03c44c1947 100644
--- a/dlls/kernel32/tests/drive.c
+++ b/dlls/kernel32/tests/drive.c
@@ -35,7 +35,7 @@ static void test_GetDriveTypeA(void)
     UINT type;
 
     logical_drives = GetLogicalDrives();
-    ok(logical_drives != 0, "GetLogicalDrives error %d\n", GetLastError());
+    ok(logical_drives != 0, "GetLogicalDrives error %ld\n", GetLastError());
 
     for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
     {
@@ -88,7 +88,7 @@ static void test_GetDriveTypeW(void)
     UINT type;
 
     logical_drives = GetLogicalDrives();
-    ok(logical_drives != 0, "GetLogicalDrives error %d\n", GetLastError());
+    ok(logical_drives != 0, "GetLogicalDrives error %ld\n", GetLastError());
 
     for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
     {
@@ -142,21 +142,21 @@ static void test_GetDiskFreeSpaceA(void)
     DWORD logical_drives;
 
     ret = GetDiskFreeSpaceA(NULL, &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
-    ok(ret, "GetDiskFreeSpaceA error %d\n", GetLastError());
+    ok(ret, "GetDiskFreeSpaceA error %ld\n", GetLastError());
 
     ret = GetDiskFreeSpaceA("", &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
     ok(!ret && (GetLastError() == ERROR_PATH_NOT_FOUND || GetLastError() == ERROR_INVALID_NAME),
-       "GetDiskFreeSpaceA(\"\"): ret=%d GetLastError=%d\n",
+       "GetDiskFreeSpaceA(\"\"): ret=%d GetLastError=%ld\n",
        ret, GetLastError());
 
     ret = GetDiskFreeSpaceA("\\", &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
-    ok(ret, "GetDiskFreeSpaceA error %d\n", GetLastError());
+    ok(ret, "GetDiskFreeSpaceA error %ld\n", GetLastError());
 
     ret = GetDiskFreeSpaceA("/", &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
-    ok(ret, "GetDiskFreeSpaceA error %d\n", GetLastError());
+    ok(ret, "GetDiskFreeSpaceA error %ld\n", GetLastError());
 
     logical_drives = GetLogicalDrives();
-    ok(logical_drives != 0, "GetLogicalDrives error %d\n", GetLastError());
+    ok(logical_drives != 0, "GetLogicalDrives error %ld\n", GetLastError());
 
     for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
     {
@@ -169,7 +169,7 @@ static void test_GetDiskFreeSpaceA(void)
             ret = GetDiskFreeSpaceA(drive, &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
             if (!(logical_drives & 1))
                 ok(!ret && (GetLastError() == ERROR_PATH_NOT_FOUND || GetLastError() == ERROR_INVALID_DRIVE),
-                   "GetDiskFreeSpaceA(%s): ret=%d GetLastError=%d\n",
+                   "GetDiskFreeSpaceA(%s): ret=%d GetLastError=%ld\n",
                    drive, ret, GetLastError());
             else
             {
@@ -177,12 +177,12 @@ static void test_GetDiskFreeSpaceA(void)
                 if (!ret)
                     /* GetDiskFreeSpaceA() should succeed, but it can fail with too many
                        different GetLastError() results to be usable for an ok() */
-                    trace("GetDiskFreeSpaceA(%s) failed with %d\n", drive, GetLastError());
+                    trace("GetDiskFreeSpaceA(%s) failed with %ld\n", drive, GetLastError());
 
                 if( GetVersion() & 0x80000000)
                     /* win3.0 through winME */
                     ok( total_clusters <= 65535,
-                            "total clusters is %d > 65535\n", total_clusters);
+                            "total clusters is %ld > 65535\n", total_clusters);
                 else if (pGetDiskFreeSpaceExA) {
                     /* NT, 2k, XP : GetDiskFreeSpace should be accurate */
                     ULARGE_INTEGER totEx, tot, d;
@@ -194,7 +194,7 @@ static void test_GetDiskFreeSpaceA(void)
                     if (!ret)
                         /* GetDiskFreeSpaceExA() should succeed, but it can fail with too many
                            different GetLastError() results to be usable for an ok() */
-                        trace("GetDiskFreeSpaceExA(%s) failed with %d\n", drive, GetLastError());
+                        trace("GetDiskFreeSpaceExA(%s) failed with %ld\n", drive, GetLastError());
 
                     ok( bytes_per_sector == 0 || /* empty cd rom drive */
                         totEx.QuadPart <= tot.QuadPart,
@@ -222,21 +222,21 @@ static void test_GetDiskFreeSpaceW(void)
         win_skip("GetDiskFreeSpaceW is not available\n");
         return;
     }
-    ok(ret, "GetDiskFreeSpaceW error %d\n", GetLastError());
+    ok(ret, "GetDiskFreeSpaceW error %ld\n", GetLastError());
 
     ret = GetDiskFreeSpaceW(empty_pathW, &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
     ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND,
-       "GetDiskFreeSpaceW(\"\"): ret=%d GetLastError=%d\n",
+       "GetDiskFreeSpaceW(\"\"): ret=%d GetLastError=%ld\n",
        ret, GetLastError());
 
     ret = GetDiskFreeSpaceW(root_pathW, &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
-    ok(ret, "GetDiskFreeSpaceW(\"\") error %d\n", GetLastError());
+    ok(ret, "GetDiskFreeSpaceW(\"\") error %ld\n", GetLastError());
 
     ret = GetDiskFreeSpaceW(unix_style_root_pathW, &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
-    ok(ret, "GetDiskFreeSpaceW error %d\n", GetLastError());
+    ok(ret, "GetDiskFreeSpaceW error %ld\n", GetLastError());
 
     logical_drives = GetLogicalDrives();
-    ok(logical_drives != 0, "GetLogicalDrives error %d\n", GetLastError());
+    ok(logical_drives != 0, "GetLogicalDrives error %ld\n", GetLastError());
 
     for (drive[0] = 'A'; drive[0] <= 'Z'; drive[0]++)
     {
@@ -247,12 +247,12 @@ static void test_GetDiskFreeSpaceW(void)
             ret = GetDiskFreeSpaceW(drive, &sectors_per_cluster, &bytes_per_sector, &free_clusters, &total_clusters);
             if (!(logical_drives & 1))
                 ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND,
-                   "GetDiskFreeSpaceW(%c): ret=%d GetLastError=%d\n",
+                   "GetDiskFreeSpaceW(%c): ret=%d GetLastError=%ld\n",
                    drive[0], ret, GetLastError());
             else if (!ret)
                 /* GetDiskFreeSpaceW() should succeed, but it can fail with too many
                    different GetLastError() results to be usable for an ok() */
-                trace("GetDiskFreeSpaceW(%c) failed with %d\n", drive[0], GetLastError());
+                trace("GetDiskFreeSpaceW(%c) failed with %ld\n", drive[0], GetLastError());
         }
         logical_drives >>= 1;
     }
diff --git a/dlls/kernel32/tests/environ.c b/dlls/kernel32/tests/environ.c
index d19b8700c5f..c1a49e175be 100644
--- a/dlls/kernel32/tests/environ.c
+++ b/dlls/kernel32/tests/environ.c
@@ -68,15 +68,15 @@ static void test_Predefined(void)
         return;
     }
     NoErr = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &Token);
-    ok(NoErr, "Failed to open token, error %u\n", GetLastError());
+    ok(NoErr, "Failed to open token, error %lu\n", GetLastError());
     DataSize = sizeof(Data);
     NoErr = pGetUserProfileDirectoryA(Token, Data, &DataSize);
-    ok(NoErr, "Failed to get user profile dir, error %u\n", GetLastError());
+    ok(NoErr, "Failed to get user profile dir, error %lu\n", GetLastError());
     if (NoErr)
     {
         EnvSize = GetEnvironmentVariableA("USERPROFILE", Env, sizeof(Env));
         ok(EnvSize != 0 && EnvSize <= sizeof(Env),
-           "Failed to retrieve environment variable USERPROFILE, error %u\n",
+           "Failed to retrieve environment variable USERPROFILE, error %lu\n",
            GetLastError());
         ok(strcmp(Data, Env) == 0,
            "USERPROFILE env var %s doesn't match GetUserProfileDirectory %s\n",
@@ -85,7 +85,7 @@ static void test_Predefined(void)
     else
         skip("Skipping USERPROFILE check, can't get user profile dir\n");
     NoErr = CloseHandle(Token);
-    ok(NoErr, "Failed to close token, error %u\n", GetLastError());
+    ok(NoErr, "Failed to close token, error %lu\n", GetLastError());
 }
 
 static void test_GetSetEnvironmentVariableA(void)
@@ -99,34 +99,34 @@ static void test_GetSetEnvironmentVariableA(void)
 
     ret = SetEnvironmentVariableA(name, value);
     ok(ret == TRUE,
-       "unexpected error in SetEnvironmentVariableA, GetLastError=%d\n",
+       "unexpected error in SetEnvironmentVariableA, GetLastError=%ld\n",
        GetLastError());
 
     /* Try to retrieve the environment variable we just set */
     SetLastError(0xdeadbeef);
     ret_size = GetEnvironmentVariableA(name, NULL, 0);
     ok(ret_size == strlen(value) + 1,
-       "should return length with terminating 0 ret_size=%d\n", ret_size);
+       "should return length with terminating 0 ret_size=%ld\n", ret_size);
     ok(GetLastError() == 0xdeadbeef,
-       "should not fail with zero size but GetLastError=%d\n", GetLastError());
+       "should not fail with zero size but GetLastError=%ld\n", GetLastError());
 
     lstrcpyA(buf, "foo");
     ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value));
     ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
     ok(ret_size == strlen(value) + 1,
-       "should return length with terminating 0 ret_size=%d\n", ret_size);
+       "should return length with terminating 0 ret_size=%ld\n", ret_size);
 
     lstrcpyA(buf, "foo");
     ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value) + 1);
     ok(lstrcmpA(buf, value) == 0, "should touch the buffer\n");
     ok(ret_size == strlen(value),
-       "should return length without terminating 0 ret_size=%d\n", ret_size);
+       "should return length without terminating 0 ret_size=%ld\n", ret_size);
 
     lstrcpyA(buf, "foo");
     ret_size = GetEnvironmentVariableA(name_cased, buf, lstrlenA(value) + 1);
     ok(lstrcmpA(buf, value) == 0, "should touch the buffer\n");
     ok(ret_size == strlen(value),
-       "should return length without terminating 0 ret_size=%d\n", ret_size);
+       "should return length without terminating 0 ret_size=%ld\n", ret_size);
 
     /* Remove that environment variable */
     ret = SetEnvironmentVariableA(name_cased, NULL);
@@ -137,24 +137,24 @@ static void test_GetSetEnvironmentVariableA(void)
     ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value) + 1);
     ok(lstrcmpA(buf, "foo") == 0, "should not touch the buffer\n");
     ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
-       "should not find variable but ret_size=%d GetLastError=%d\n",
+       "should not find variable but ret_size=%ld GetLastError=%ld\n",
        ret_size, GetLastError());
 
     /* Check behavior of SetEnvironmentVariableA(name, "") */
     ret = SetEnvironmentVariableA(name, value);
     ok(ret == TRUE,
-       "unexpected error in SetEnvironmentVariableA, GetLastError=%d\n",
+       "unexpected error in SetEnvironmentVariableA, GetLastError=%ld\n",
        GetLastError());
 
     lstrcpyA(buf, "foo");
     ret_size = GetEnvironmentVariableA(name_cased, buf, lstrlenA(value) + 1);
     ok(lstrcmpA(buf, value) == 0, "should touch the buffer\n");
     ok(ret_size == strlen(value),
-       "should return length without terminating 0 ret_size=%d\n", ret_size);
+       "should return length without terminating 0 ret_size=%ld\n", ret_size);
 
     ret = SetEnvironmentVariableA(name_cased, "");
     ok(ret == TRUE,
-       "should not fail with empty value but GetLastError=%d\n", GetLastError());
+       "should not fail with empty value but GetLastError=%ld\n", GetLastError());
 
     lstrcpyA(buf, "foo");
     SetLastError(0xdeadbeef);
@@ -162,36 +162,36 @@ static void test_GetSetEnvironmentVariableA(void)
     ok(ret_size == 0 &&
        ((GetLastError() == 0xdeadbeef && lstrcmpA(buf, "") == 0) ||
         (GetLastError() == ERROR_ENVVAR_NOT_FOUND)),
-       "%s should be set to \"\" (NT) or removed (Win9x) but ret_size=%d GetLastError=%d and buf=%s\n",
+       "%s should be set to \"\" (NT) or removed (Win9x) but ret_size=%ld GetLastError=%ld and buf=%s\n",
        name, ret_size, GetLastError(), buf);
 
     SetLastError(0xdeadbeef);
     ret_size = GetEnvironmentVariableA(name, NULL, 0);
     ok(ret_size == 1 ||
        broken(ret_size == 0), /* XP */
-       "should return 1 for empty string but ret_size=%d GetLastError=%d\n",
+       "should return 1 for empty string but ret_size=%ld GetLastError=%ld\n",
        ret_size, GetLastError());
     ok(GetLastError() == 0xdeadbeef ||
        broken(GetLastError() == ERROR_MORE_DATA), /* XP */
-       "should not fail with zero size but GetLastError=%d\n", GetLastError());
+       "should not fail with zero size but GetLastError=%ld\n", GetLastError());
 
     /* Test the limits */
     SetLastError(0xdeadbeef);
     ret_size = GetEnvironmentVariableA(NULL, NULL, 0);
     ok(ret_size == 0 && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ENVVAR_NOT_FOUND),
-       "should not find variable but ret_size=%d GetLastError=%d\n",
+       "should not find variable but ret_size=%ld GetLastError=%ld\n",
        ret_size, GetLastError());
 
     SetLastError(0xdeadbeef);
     ret_size = GetEnvironmentVariableA(NULL, buf, lstrlenA(value) + 1);
     ok(ret_size == 0 && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ENVVAR_NOT_FOUND),
-       "should not find variable but ret_size=%d GetLastError=%d\n",
+       "should not find variable but ret_size=%ld GetLastError=%ld\n",
        ret_size, GetLastError());
 
     SetLastError(0xdeadbeef);
     ret_size = GetEnvironmentVariableA("", buf, lstrlenA(value) + 1);
     ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
-       "should not find variable but ret_size=%d GetLastError=%d\n",
+       "should not find variable but ret_size=%ld GetLastError=%ld\n",
        ret_size, GetLastError());
 }
 
@@ -214,17 +214,17 @@ static void test_GetSetEnvironmentVariableW(void)
         return;
     }
     ok(ret == TRUE,
-       "unexpected error in SetEnvironmentVariableW, GetLastError=%d\n",
+       "unexpected error in SetEnvironmentVariableW, GetLastError=%ld\n",
        GetLastError());
 
     /* Try to retrieve the environment variable we just set */
     SetLastError(0xdeadbeef);
     ret_size = GetEnvironmentVariableW(name, NULL, 0);
     ok(ret_size == lstrlenW(value) + 1,
-       "should return length with terminating 0 ret_size=%d\n",
+       "should return length with terminating 0 ret_size=%ld\n",
        ret_size);
     ok(GetLastError() == 0xdeadbeef,
-       "should not fail with zero size but GetLastError=%d\n", GetLastError());
+       "should not fail with zero size but GetLastError=%ld\n", GetLastError());
 
     lstrcpyW(buf, fooW);
     ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value));
@@ -233,19 +233,19 @@ static void test_GetSetEnvironmentVariableW(void)
          "Expected untouched or empty buffer, got \"%s\"\n", buf);
 
     ok(ret_size == lstrlenW(value) + 1,
-       "should return length with terminating 0 ret_size=%d\n", ret_size);
+       "should return length with terminating 0 ret_size=%ld\n", ret_size);
 
     lstrcpyW(buf, fooW);
     ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
     ok(lstrcmpW(buf, value) == 0, "should touch the buffer\n");
     ok(ret_size == lstrlenW(value),
-       "should return length without terminating 0 ret_size=%d\n", ret_size);
+       "should return length without terminating 0 ret_size=%ld\n", ret_size);
 
     lstrcpyW(buf, fooW);
     ret_size = GetEnvironmentVariableW(name_cased, buf, lstrlenW(value) + 1);
     ok(lstrcmpW(buf, value) == 0, "should touch the buffer\n");
     ok(ret_size == lstrlenW(value),
-       "should return length without terminating 0 ret_size=%d\n", ret_size);
+       "should return length without terminating 0 ret_size=%ld\n", ret_size);
 
     /* Remove that environment variable */
     ret = SetEnvironmentVariableW(name_cased, NULL);
@@ -256,23 +256,23 @@ static void test_GetSetEnvironmentVariableW(void)
     ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
     ok(lstrcmpW(buf, fooW) == 0, "should not touch the buffer\n");
     ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
-       "should not find variable but ret_size=%d GetLastError=%d\n",
+       "should not find variable but ret_size=%ld GetLastError=%ld\n",
        ret_size, GetLastError());
 
     /* Check behavior of SetEnvironmentVariableW(name, "") */
     ret = SetEnvironmentVariableW(name, value);
     ok(ret == TRUE,
-       "unexpected error in SetEnvironmentVariableW, GetLastError=%d\n",
+       "unexpected error in SetEnvironmentVariableW, GetLastError=%ld\n",
        GetLastError());
 
     lstrcpyW(buf, fooW);
     ret_size = GetEnvironmentVariableW(name, buf, lstrlenW(value) + 1);
     ok(lstrcmpW(buf, value) == 0, "should touch the buffer\n");
     ok(ret_size == lstrlenW(value),
-       "should return length without terminating 0 ret_size=%d\n", ret_size);
+       "should return length without terminating 0 ret_size=%ld\n", ret_size);
 
     ret = SetEnvironmentVariableW(name_cased, empty_strW);
-    ok(ret == TRUE, "should not fail with empty value but GetLastError=%d\n", GetLastError());
+    ok(ret == TRUE, "should not fail with empty value but GetLastError=%ld\n", GetLastError());
 
     lstrcpyW(buf, fooW);
     SetLastError(0xdeadbeef);
@@ -280,7 +280,7 @@ static void test_GetSetEnvironmentVariableW(void)
     ok(ret_size == 0 &&
        ((GetLastError() == 0xdeadbeef && lstrcmpW(buf, empty_strW) == 0) ||
         (GetLastError() == ERROR_ENVVAR_NOT_FOUND)),
-       "should be set to \"\" (NT) or removed (Win9x) but ret_size=%d GetLastError=%d\n",
+       "should be set to \"\" (NT) or removed (Win9x) but ret_size=%ld GetLastError=%ld\n",
        ret_size, GetLastError());
     ok(lstrcmpW(buf, empty_strW) == 0, "should copy an empty string\n");
 
@@ -288,17 +288,17 @@ static void test_GetSetEnvironmentVariableW(void)
     ret_size = GetEnvironmentVariableW(name, NULL, 0);
     ok(ret_size == 1 ||
        broken(ret_size == 0), /* XP */
-       "should return 1 for empty string but ret_size=%d GetLastError=%d\n",
+       "should return 1 for empty string but ret_size=%ld GetLastError=%ld\n",
        ret_size, GetLastError());
     ok(GetLastError() == 0xdeadbeef ||
        broken(GetLastError() == ERROR_MORE_DATA), /* XP */
-       "should not fail with zero size but GetLastError=%d\n", GetLastError());
+       "should not fail with zero size but GetLastError=%ld\n", GetLastError());
 
     /* Test the limits */
     SetLastError(0xdeadbeef);
     ret_size = GetEnvironmentVariableW(NULL, NULL, 0);
     ok(ret_size == 0 && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ENVVAR_NOT_FOUND),
-       "should not find variable but ret_size=%d GetLastError=%d\n",
+       "should not find variable but ret_size=%ld GetLastError=%ld\n",
        ret_size, GetLastError());
 
     if (0) /* Both tests crash on Vista */
@@ -306,13 +306,13 @@ static void test_GetSetEnvironmentVariableW(void)
         SetLastError(0xdeadbeef);
         ret_size = GetEnvironmentVariableW(NULL, buf, lstrlenW(value) + 1);
         ok(ret_size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND,
-           "should not find variable but ret_size=%d GetLastError=%d\n",
+           "should not find variable but ret_size=%ld GetLastError=%ld\n",
            ret_size, GetLastError());
 
         SetLastError(0xdeadbeef);
         ret = SetEnvironmentVariableW(NULL, NULL);
         ok(ret == FALSE && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ENVVAR_NOT_FOUND),
-           "should fail with NULL, NULL but ret=%d and GetLastError=%d\n",
+           "should fail with NULL, NULL but ret=%d and GetLastError=%ld\n",
            ret, GetLastError());
     }
 }
@@ -336,46 +336,46 @@ static void test_GetSetEnvironmentVariableAW(void)
 
     /* Write W, read A */
     ret = SetEnvironmentVariableW(nameW, valueW);
-    ok(ret == TRUE, "SetEnvironmentVariableW failed, last error %d\n", GetLastError());
+    ok(ret == TRUE, "SetEnvironmentVariableW failed, last error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret_size = GetEnvironmentVariableA(name, NULL, 0);
-    todo_wine ok(ret_size == lstrlenA(value) + 1, "expected ret_size %d, got %d\n", lstrlenA(value) + 1, ret_size);
-    ok(GetLastError() == 0xdeadbeef, "expected last error 0xdeadbeef, got %d\n", GetLastError());
+    todo_wine ok(ret_size == lstrlenA(value) + 1, "expected ret_size %d, got %ld\n", lstrlenA(value) + 1, ret_size);
+    ok(GetLastError() == 0xdeadbeef, "expected last error 0xdeadbeef, got %ld\n", GetLastError());
 
     lstrcpyA(buf, "foo");
     SetLastError(0xdeadbeef);
     ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value) + 1);
     todo_wine ok(lstrcmpA(buf, value) == 0, "expected %s, got %s\n", debugstr_a(value), debugstr_a(buf));
-    todo_wine ok(ret_size == lstrlenA(value), "expected ret_size %d, got %d\n", lstrlenA(value), ret_size);
-    ok(GetLastError() == 0xdeadbeef, "expected last error 0xdeadbeef, got %d\n", GetLastError());
+    todo_wine ok(ret_size == lstrlenA(value), "expected ret_size %d, got %ld\n", lstrlenA(value), ret_size);
+    ok(GetLastError() == 0xdeadbeef, "expected last error 0xdeadbeef, got %ld\n", GetLastError());
 
     /* Write A, read A/W */
     ret = SetEnvironmentVariableA(name, value);
-    ok(ret == TRUE, "SetEnvironmentVariableW failed, last error %d\n", GetLastError());
+    ok(ret == TRUE, "SetEnvironmentVariableW failed, last error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret_size = GetEnvironmentVariableA(name, NULL, 0);
-    todo_wine ok(ret_size == lstrlenA(value) + 1, "expected ret_size %d, got %d\n", lstrlenA(value) + 1, ret_size);
-    ok(GetLastError() == 0xdeadbeef, "expected last error 0xdeadbeef, got %d\n", GetLastError());
+    todo_wine ok(ret_size == lstrlenA(value) + 1, "expected ret_size %d, got %ld\n", lstrlenA(value) + 1, ret_size);
+    ok(GetLastError() == 0xdeadbeef, "expected last error 0xdeadbeef, got %ld\n", GetLastError());
 
     lstrcpyA(buf, "foo");
     SetLastError(0xdeadbeef);
     ret_size = GetEnvironmentVariableA(name, buf, lstrlenA(value) + 1);
     todo_wine ok(lstrcmpA(buf, value) == 0, "expected %s, got %s\n", debugstr_a(value), debugstr_a(buf));
-    todo_wine ok(ret_size == lstrlenA(value), "expected ret_size %d, got %d\n", lstrlenA(value), ret_size);
-    ok(GetLastError() == 0xdeadbeef, "expected last error 0xdeadbeef, got %d\n", GetLastError());
+    todo_wine ok(ret_size == lstrlenA(value), "expected ret_size %d, got %ld\n", lstrlenA(value), ret_size);
+    ok(GetLastError() == 0xdeadbeef, "expected last error 0xdeadbeef, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret_size = GetEnvironmentVariableW(nameW, NULL, 0);
-    ok(ret_size == lstrlenW(valueW) + 1, "expected ret_size %d, got %d\n", lstrlenW(valueW) + 1, ret_size);
-    ok(GetLastError() == 0xdeadbeef, "expected last error 0xdeadbeef, got %d\n", GetLastError());
+    ok(ret_size == lstrlenW(valueW) + 1, "expected ret_size %d, got %ld\n", lstrlenW(valueW) + 1, ret_size);
+    ok(GetLastError() == 0xdeadbeef, "expected last error 0xdeadbeef, got %ld\n", GetLastError());
 
     lstrcpyW(bufW, L"foo");
     SetLastError(0xdeadbeef);
     ret_size = GetEnvironmentVariableW(nameW, bufW, lstrlenW(valueW) + 1);
-    ok(ret_size == lstrlenW(valueW), "expected ret_size %d, got %d\n", lstrlenW(valueW), ret_size);
-    ok(GetLastError() == 0xdeadbeef, "expected last error 0xdeadbeef, got %d\n", GetLastError());
+    ok(ret_size == lstrlenW(valueW), "expected ret_size %d, got %ld\n", lstrlenW(valueW), ret_size);
+    ok(GetLastError() == 0xdeadbeef, "expected last error 0xdeadbeef, got %ld\n", GetLastError());
     ok(lstrcmpW(bufW, valueW) == 0, "expected %s, got %s\n", debugstr_w(valueW), debugstr_w(bufW));
 }
 
@@ -390,7 +390,7 @@ static void test_ExpandEnvironmentStringsA(void)
 
     ret_size = ExpandEnvironmentStringsA(NULL, buf1, sizeof(buf1));
     ok(ret_size == 1 || ret_size == 0 /* Win9x */ || ret_size == 2 /* NT4 */,
-       "ExpandEnvironmentStrings returned %d\n", ret_size);
+       "ExpandEnvironmentStrings returned %ld\n", ret_size);
 
     /* Try to get the required buffer size 'the natural way' */
     strcpy(buf, "%EnvVar%");
@@ -399,7 +399,7 @@ static void test_ExpandEnvironmentStringsA(void)
        ret_size == (strlen(value)+1)*2 || /* NT4 */
        ret_size == strlen(value)+2 || /* win2k, XP, win2k3 */
        ret_size == 0 /* Win95 */,
-       "ExpandEnvironmentStrings returned %d instead of %d, %d or %d\n",
+       "ExpandEnvironmentStrings returned %ld instead of %d, %d or %d\n",
        ret_size, lstrlenA(value)+1, lstrlenA(value)+2, 0);
 
     /* Again, side-stepping the Win95 bug */
@@ -407,7 +407,7 @@ static void test_ExpandEnvironmentStringsA(void)
     /* v5.1.2600.2945 (XP SP2) returns len + 2 here! */
     ok(ret_size == strlen(value)+1 || ret_size == strlen(value)+2 ||
        ret_size == (strlen(value)+1)*2 /* NT4 */,
-       "ExpandEnvironmentStrings returned %d instead of %d\n",
+       "ExpandEnvironmentStrings returned %ld instead of %d\n",
        ret_size, lstrlenA(value)+1);
 
     /* Try with a buffer that's too small */
@@ -415,7 +415,7 @@ static void test_ExpandEnvironmentStringsA(void)
     /* v5.1.2600.2945 (XP SP2) returns len + 2 here! */
     ok(ret_size == strlen(value)+1 || ret_size == strlen(value)+2 ||
        ret_size == (strlen(value)+1)*2 /* NT4 */,
-       "ExpandEnvironmentStrings returned %d instead of %d\n",
+       "ExpandEnvironmentStrings returned %ld instead of %d\n",
        ret_size, lstrlenA(value)+1);
 
     /* Try with a buffer of just the right size */
@@ -423,7 +423,7 @@ static void test_ExpandEnvironmentStringsA(void)
     ret_size = ExpandEnvironmentStringsA(buf, buf1, ret_size);
     ok(ret_size == strlen(value)+1 || ret_size == strlen(value)+2 ||
        ret_size == (strlen(value)+1)*2 /* NT4 */,
-       "ExpandEnvironmentStrings returned %d instead of %d\n",
+       "ExpandEnvironmentStrings returned %ld instead of %d\n",
        ret_size, lstrlenA(value)+1);
     ok(!strcmp(buf1, value), "ExpandEnvironmentStrings returned [%s]\n", buf1);
 
@@ -432,13 +432,13 @@ static void test_ExpandEnvironmentStringsA(void)
     ret_size = ExpandEnvironmentStringsA(buf, buf1, sizeof(buf1));
     ok(ret_size == strlen(not_an_env_var)+1 ||
        ret_size == (strlen(not_an_env_var)+1)*2 /* NT4 */,
-       "ExpandEnvironmentStrings returned %d instead of %d\n", ret_size, lstrlenA(not_an_env_var)+1);
+       "ExpandEnvironmentStrings returned %ld instead of %d\n", ret_size, lstrlenA(not_an_env_var)+1);
     ok(!strcmp(buf1, not_an_env_var), "ExpandEnvironmentStrings returned [%s]\n", buf1);
 
     /* test a large destination size */
     strcpy(buf, "12345");
     ret_size = ExpandEnvironmentStringsA(buf, buf2, sizeof(buf2));
-    ok(!strcmp(buf, buf2), "ExpandEnvironmentStrings failed %s vs %s. ret_size = %d\n", buf, buf2, ret_size);
+    ok(!strcmp(buf, buf2), "ExpandEnvironmentStrings failed %s vs %s. ret_size = %ld\n", buf, buf2, ret_size);
 
     SetLastError(0xdeadbeef);
     ret_size1 = GetWindowsDirectoryA(buf1,256);
@@ -446,7 +446,7 @@ static void test_ExpandEnvironmentStringsA(void)
     ret_size = ExpandEnvironmentStringsA("%SystemRoot%",buf,sizeof(buf));
     if (ERROR_ENVVAR_NOT_FOUND != GetLastError())
     {
-        ok(!strcmp(buf, buf1), "ExpandEnvironmentStrings failed %s vs %s. ret_size = %d\n", buf, buf1, ret_size);
+        ok(!strcmp(buf, buf1), "ExpandEnvironmentStrings failed %s vs %s. ret_size = %ld\n", buf, buf1, ret_size);
     }
 
     /* Try with a variable that references another */
@@ -456,7 +456,7 @@ static void test_ExpandEnvironmentStringsA(void)
     ret_size = ExpandEnvironmentStringsA(buf, buf1, sizeof(buf1));
     ok(ret_size == strlen(buf2)+1 ||
        ret_size == (strlen(buf2)+1)*2 /* NT4 */,
-       "ExpandEnvironmentStrings returned %d instead of %d\n", ret_size, lstrlenA(buf2)+1);
+       "ExpandEnvironmentStrings returned %ld instead of %d\n", ret_size, lstrlenA(buf2)+1);
     ok(!strcmp(buf1, buf2), "ExpandEnvironmentStrings returned [%s]\n", buf1);
     SetEnvironmentVariableA("IndirectVar", NULL);
 
@@ -476,27 +476,27 @@ static void test_GetComputerName(void)
     SetLastError(0xdeadbeef);
     ret = GetComputerNameA((LPSTR)0xdeadbeef, &size);
     error = GetLastError();
-    ok(!ret && error == ERROR_BUFFER_OVERFLOW, "GetComputerNameA should have failed with ERROR_BUFFER_OVERFLOW instead of %d\n", error);
+    ok(!ret && error == ERROR_BUFFER_OVERFLOW, "GetComputerNameA should have failed with ERROR_BUFFER_OVERFLOW instead of %ld\n", error);
 
     /* Only Vista returns the computer name length as documented in the MSDN */
     if (size != 0)
     {
         size++; /* nul terminating character */
         name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
-        ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
+        ok(name != NULL, "HeapAlloc failed with error %ld\n", GetLastError());
         ret = GetComputerNameA(name, &size);
-        ok(ret, "GetComputerNameA failed with error %d\n", GetLastError());
+        ok(ret, "GetComputerNameA failed with error %ld\n", GetLastError());
         HeapFree(GetProcessHeap(), 0, name);
     }
 
     size = MAX_COMPUTERNAME_LENGTH + 1;
     name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
-    ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
+    ok(name != NULL, "HeapAlloc failed with error %ld\n", GetLastError());
     ret = GetComputerNameA(name, &size);
-    ok(ret, "GetComputerNameA failed with error %d\n", GetLastError());
+    ok(ret, "GetComputerNameA failed with error %ld\n", GetLastError());
     trace("computer name is \"%s\"\n", name);
     name_len = strlen(name);
-    ok(size == name_len, "size should be same as length, name_len=%d, size=%d\n", name_len, size);
+    ok(size == name_len, "size should be same as length, name_len=%d, size=%ld\n", name_len, size);
     HeapFree(GetProcessHeap(), 0, name);
 
     size = 0;
@@ -507,12 +507,12 @@ static void test_GetComputerName(void)
         win_skip("GetComputerNameW is not implemented\n");
     else
     {
-        ok(!ret && error == ERROR_BUFFER_OVERFLOW, "GetComputerNameW should have failed with ERROR_BUFFER_OVERFLOW instead of %d\n", error);
+        ok(!ret && error == ERROR_BUFFER_OVERFLOW, "GetComputerNameW should have failed with ERROR_BUFFER_OVERFLOW instead of %ld\n", error);
         size++; /* nul terminating character */
         nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(nameW[0]));
-        ok(nameW != NULL, "HeapAlloc failed with error %d\n", GetLastError());
+        ok(nameW != NULL, "HeapAlloc failed with error %ld\n", GetLastError());
         ret = GetComputerNameW(nameW, &size);
-        ok(ret, "GetComputerNameW failed with error %d\n", GetLastError());
+        ok(ret, "GetComputerNameW failed with error %ld\n", GetLastError());
         HeapFree(GetProcessHeap(), 0, nameW);
     }
 }
@@ -537,7 +537,7 @@ static void test_GetComputerNameExA(void)
     ret = pGetComputerNameExA(ComputerNameDnsDomain, (LPSTR)0xdeadbeef, &size);
     error = GetLastError();
     ok(ret == 0, "Expected 0, got %d\n", ret);
-    ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", error);
+    ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %ld\n", error);
 
     /* size is not set in win2k */
     if (size == 0)
@@ -546,9 +546,9 @@ static void test_GetComputerNameExA(void)
         size = MAX_COMP_NAME;
     }
     name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
-    ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
+    ok(name != NULL, "HeapAlloc failed with error %ld\n", GetLastError());
     ret = pGetComputerNameExA(ComputerNameDnsDomain, name, &size);
-    ok(ret, "GetComputerNameExA(ComputerNameDnsDomain) failed with error %d\n", GetLastError());
+    ok(ret, "GetComputerNameExA(ComputerNameDnsDomain) failed with error %ld\n", GetLastError());
     trace("domain name is \"%s\"\n", name);
     HeapFree(GetProcessHeap(), 0, name);
 
@@ -557,15 +557,15 @@ static void test_GetComputerNameExA(void)
     ret = pGetComputerNameExA(ComputerNameDnsFullyQualified, (LPSTR)0xdeadbeef, &size);
     error = GetLastError();
     ok(ret == 0, "Expected 0, got %d\n", ret);
-    ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", error);
+    ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %ld\n", error);
 
     /* size is not set in win2k */
     if (size == 0)
         size = MAX_COMP_NAME;
     name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
-    ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
+    ok(name != NULL, "HeapAlloc failed with error %ld\n", GetLastError());
     ret = pGetComputerNameExA(ComputerNameDnsFullyQualified, name, &size);
-    ok(ret, "GetComputerNameExA(ComputerNameDnsFullyQualified) failed with error %d\n", GetLastError());
+    ok(ret, "GetComputerNameExA(ComputerNameDnsFullyQualified) failed with error %ld\n", GetLastError());
     trace("fully qualified hostname is \"%s\"\n", name);
     HeapFree(GetProcessHeap(), 0, name);
 
@@ -574,15 +574,15 @@ static void test_GetComputerNameExA(void)
     ret = pGetComputerNameExA(ComputerNameDnsHostname, (LPSTR)0xdeadbeef, &size);
     error = GetLastError();
     ok(ret == 0, "Expected 0, got %d\n", ret);
-    ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", error);
+    ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %ld\n", error);
 
     /* size is not set in win2k */
     if (size == 0)
         size = MAX_COMP_NAME;
     name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
-    ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
+    ok(name != NULL, "HeapAlloc failed with error %ld\n", GetLastError());
     ret = pGetComputerNameExA(ComputerNameDnsHostname, name, &size);
-    ok(ret, "GetComputerNameExA(ComputerNameDnsHostname) failed with error %d\n", GetLastError());
+    ok(ret, "GetComputerNameExA(ComputerNameDnsHostname) failed with error %ld\n", GetLastError());
     trace("hostname is \"%s\"\n", name);
     HeapFree(GetProcessHeap(), 0, name);
 
@@ -591,22 +591,22 @@ static void test_GetComputerNameExA(void)
     ret = pGetComputerNameExA(ComputerNameNetBIOS, (LPSTR)0xdeadbeef, &size);
     error = GetLastError();
     ok(ret == 0, "Expected 0, got %d\n", ret);
-    ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", error);
+    ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %ld\n", error);
 
     size = 0;
     SetLastError(0xdeadbeef);
     ret = pGetComputerNameExA(ComputerNameNetBIOS, NULL, &size);
     error = GetLastError();
     ok(ret == 0, "Expected 0, got %d\n", ret);
-    ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", error);
+    ok(error == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %ld\n", error);
 
     /* size is not set in win2k */
     if (size == 0)
         size = MAX_COMP_NAME;
     name = HeapAlloc(GetProcessHeap(), 0, size * sizeof(name[0]));
-    ok(name != NULL, "HeapAlloc failed with error %d\n", GetLastError());
+    ok(name != NULL, "HeapAlloc failed with error %ld\n", GetLastError());
     ret = pGetComputerNameExA(ComputerNameNetBIOS, name, &size);
-    ok(ret, "GetComputerNameExA(ComputerNameNetBIOS) failed with error %d\n", GetLastError());
+    ok(ret, "GetComputerNameExA(ComputerNameNetBIOS) failed with error %ld\n", GetLastError());
     trace("NetBIOS name is \"%s\"\n", name);
     HeapFree(GetProcessHeap(), 0, name);
 }
@@ -628,51 +628,51 @@ static void test_GetComputerNameExW(void)
     SetLastError(0xdeadbeef);
     ret = pGetComputerNameExW(ComputerNameDnsDomain, (LPWSTR)0xdeadbeef, &size);
     error = GetLastError();
-    ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %d\n", error);
+    ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %ld\n", error);
     nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(nameW[0]));
-    ok(nameW != NULL, "HeapAlloc failed with error %d\n", GetLastError());
+    ok(nameW != NULL, "HeapAlloc failed with error %ld\n", GetLastError());
     ret = pGetComputerNameExW(ComputerNameDnsDomain, nameW, &size);
-    ok(ret, "GetComputerNameExW(ComputerNameDnsDomain) failed with error %d\n", GetLastError());
+    ok(ret, "GetComputerNameExW(ComputerNameDnsDomain) failed with error %ld\n", GetLastError());
     HeapFree(GetProcessHeap(), 0, nameW);
 
     size = 0;
     SetLastError(0xdeadbeef);
     ret = pGetComputerNameExW(ComputerNameDnsFullyQualified, (LPWSTR)0xdeadbeef, &size);
     error = GetLastError();
-    ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %d\n", error);
+    ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %ld\n", error);
     nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(nameW[0]));
-    ok(nameW != NULL, "HeapAlloc failed with error %d\n", GetLastError());
+    ok(nameW != NULL, "HeapAlloc failed with error %ld\n", GetLastError());
     ret = pGetComputerNameExW(ComputerNameDnsFullyQualified, nameW, &size);
-    ok(ret, "GetComputerNameExW(ComputerNameDnsFullyQualified) failed with error %d\n", GetLastError());
+    ok(ret, "GetComputerNameExW(ComputerNameDnsFullyQualified) failed with error %ld\n", GetLastError());
     HeapFree(GetProcessHeap(), 0, nameW);
 
     size = 0;
     SetLastError(0xdeadbeef);
     ret = pGetComputerNameExW(ComputerNameDnsHostname, (LPWSTR)0xdeadbeef, &size);
     error = GetLastError();
-    ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %d\n", error);
+    ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %ld\n", error);
     nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(nameW[0]));
-    ok(nameW != NULL, "HeapAlloc failed with error %d\n", GetLastError());
+    ok(nameW != NULL, "HeapAlloc failed with error %ld\n", GetLastError());
     ret = pGetComputerNameExW(ComputerNameDnsHostname, nameW, &size);
-    ok(ret, "GetComputerNameExW(ComputerNameDnsHostname) failed with error %d\n", GetLastError());
+    ok(ret, "GetComputerNameExW(ComputerNameDnsHostname) failed with error %ld\n", GetLastError());
     HeapFree(GetProcessHeap(), 0, nameW);
 
     size = 0;
     SetLastError(0xdeadbeef);
     ret = pGetComputerNameExW(ComputerNameNetBIOS, (LPWSTR)0xdeadbeef, &size);
     error = GetLastError();
-    ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %d\n", error);
+    ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %ld\n", error);
     nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(nameW[0]));
-    ok(nameW != NULL, "HeapAlloc failed with error %d\n", GetLastError());
+    ok(nameW != NULL, "HeapAlloc failed with error %ld\n", GetLastError());
     ret = pGetComputerNameExW(ComputerNameNetBIOS, nameW, &size);
-    ok(ret, "GetComputerNameExW(ComputerNameNetBIOS) failed with error %d\n", GetLastError());
+    ok(ret, "GetComputerNameExW(ComputerNameNetBIOS) failed with error %ld\n", GetLastError());
     HeapFree(GetProcessHeap(), 0, nameW);
 
     size = 0;
     SetLastError(0xdeadbeef);
     ret = pGetComputerNameExW(ComputerNameNetBIOS, NULL, &size);
     error = GetLastError();
-    ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %d\n", error);
+    ok(!ret && error == ERROR_MORE_DATA, "GetComputerNameExW should have failed with ERROR_MORE_DATA instead of %ld\n", error);
 }
 
 static void test_GetEnvironmentStringsW(void)
@@ -697,13 +697,13 @@ static void check_env_var_(int line, const char *var, const char *value)
     DWORD size = GetEnvironmentVariableA(var, buffer, sizeof(buffer));
     if (value)
     {
-        ok_(__FILE__, line)(size == strlen(value), "wrong size %u\n", size);
+        ok_(__FILE__, line)(size == strlen(value), "wrong size %lu\n", size);
         ok_(__FILE__, line)(!strcmp(buffer, value), "wrong value %s\n", debugstr_a(buffer));
     }
     else
     {
-        ok_(__FILE__, line)(!size, "wrong size %u\n", size);
-        ok_(__FILE__, line)(GetLastError() == ERROR_ENVVAR_NOT_FOUND, "got error %u\n", GetLastError());
+        ok_(__FILE__, line)(!size, "wrong size %lu\n", size);
+        ok_(__FILE__, line)(GetLastError() == ERROR_ENVVAR_NOT_FOUND, "got error %lu\n", GetLastError());
     }
 }
 #define check_env_var(a, b) check_env_var_(__LINE__, a, b)
@@ -722,15 +722,15 @@ static void test_SetEnvironmentStrings(void)
     }
 
     ret = SetEnvironmentVariableA("testenv1", "heis");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ret = SetEnvironmentVariableA("testenv2", "dyo");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     old_env = GetEnvironmentStringsW();
 
     memcpy(env, testenv, sizeof(testenv));
     ret = pSetEnvironmentStringsW(env);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ok(!memcmp(env, testenv, sizeof(testenv)), "input parameter should not be changed\n");
 
     check_env_var("testenv1", "unus");
@@ -739,7 +739,7 @@ static void test_SetEnvironmentStrings(void)
     check_env_var("PATH", NULL);
 
     ret = pSetEnvironmentStringsW(old_env);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     check_env_var("testenv1", "heis");
     check_env_var("testenv2", "dyo");
@@ -752,24 +752,24 @@ static void test_SetEnvironmentStrings(void)
     SetLastError(0xdeadbeef);
     ret = pSetEnvironmentStringsW(env);
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %lu\n", GetLastError());
 
     copy_string(env, L"=unus\0");
     SetLastError(0xdeadbeef);
     ret = pSetEnvironmentStringsW(env);
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %lu\n", GetLastError());
 
     copy_string(env, L"one=two=three four=five\0");
     ret = pSetEnvironmentStringsW(env);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     check_env_var("one", "two=three four=five");
 
     ret = pSetEnvironmentStringsW(old_env);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ret = FreeEnvironmentStringsW(old_env);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 }
 
 START_TEST(environ)
diff --git a/dlls/kernel32/tests/fiber.c b/dlls/kernel32/tests/fiber.c
index 9ae45c2091b..509bbb51dbb 100644
--- a/dlls/kernel32/tests/fiber.c
+++ b/dlls/kernel32/tests/fiber.c
@@ -109,11 +109,11 @@ static VOID WINAPI FiberMainProc(LPVOID lpFiberParameter)
         SetLastError( 0xdeadbeef );
         ret = pFlsGetValue(fls_index_to_set);
         ok(ret == NULL, "FlsGetValue returned %p, expected NULL\n", ret);
-        ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %u.\n", GetLastError());
+        ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %lu.\n", GetLastError());
 
         /* Set the FLS value */
         bret = pFlsSetValue(fls_index_to_set, fls_value_to_set);
-        ok(bret, "FlsSetValue failed with error %u\n", GetLastError());
+        ok(bret, "FlsSetValue failed with error %lu\n", GetLastError());
 
         ok(!!teb->FlsSlots, "Got unexpected FlsSlots %p.\n", teb->FlsSlots);
 
@@ -121,7 +121,7 @@ static VOID WINAPI FiberMainProc(LPVOID lpFiberParameter)
         SetLastError( 0xdeadbeef );
         ret = pFlsGetValue(fls_index_to_set);
         ok(ret == fls_value_to_set, "FlsGetValue returned %p, expected %p\n", ret, fls_value_to_set);
-        ok(GetLastError() == ERROR_SUCCESS, "FlsGetValue error %u\n", GetLastError());
+        ok(GetLastError() == ERROR_SUCCESS, "FlsGetValue error %lu\n", GetLastError());
     }
     pSwitchToFiber(fibers[0]);
 }
@@ -133,12 +133,12 @@ static void test_ConvertThreadToFiber(void)
     if (pConvertThreadToFiber)
     {
         fibers[0] = pConvertThreadToFiber(&testparam);
-        ok(fibers[0] != NULL, "ConvertThreadToFiber failed with error %u\n", GetLastError());
+        ok(fibers[0] != NULL, "ConvertThreadToFiber failed with error %lu\n", GetLastError());
 
         SetLastError(0xdeadbeef);
         ret = pConvertThreadToFiber(&testparam);
         ok(!ret, "Got non NULL ret.\n");
-        ok(GetLastError() == ERROR_ALREADY_FIBER, "Got unexpected error %u.\n", GetLastError());
+        ok(GetLastError() == ERROR_ALREADY_FIBER, "Got unexpected error %lu.\n", GetLastError());
     }
     else
     {
@@ -153,12 +153,12 @@ static void test_ConvertThreadToFiberEx(void)
     if (pConvertThreadToFiberEx)
     {
         fibers[0] = pConvertThreadToFiberEx(&testparam, 0);
-        ok(fibers[0] != NULL, "ConvertThreadToFiberEx failed with error %u\n", GetLastError());
+        ok(fibers[0] != NULL, "ConvertThreadToFiberEx failed with error %lu\n", GetLastError());
 
         SetLastError(0xdeadbeef);
         ret = pConvertThreadToFiberEx(&testparam, 0);
         ok(!ret, "Got non NULL ret.\n");
-        ok(GetLastError() == ERROR_ALREADY_FIBER, "Got unexpected error %u.\n", GetLastError());
+        ok(GetLastError() == ERROR_ALREADY_FIBER, "Got unexpected error %lu.\n", GetLastError());
     }
     else
     {
@@ -171,7 +171,7 @@ static void test_ConvertFiberToThread(void)
     if (pConvertFiberToThread)
     {
         BOOL ret = pConvertFiberToThread();
-        ok(ret, "ConvertFiberToThread failed with error %u\n", GetLastError());
+        ok(ret, "ConvertFiberToThread failed with error %lu\n", GetLastError());
     }
     else
     {
@@ -183,7 +183,7 @@ static void test_FiberHandling(void)
 {
     fiberCount = 0;
     fibers[0] = pCreateFiber(0,FiberMainProc,&testparam);
-    ok(fibers[0] != NULL, "CreateFiber failed with error %u\n", GetLastError());
+    ok(fibers[0] != NULL, "CreateFiber failed with error %lu\n", GetLastError());
     pDeleteFiber(fibers[0]);
 
     test_ConvertThreadToFiber();
@@ -194,7 +194,7 @@ static void test_FiberHandling(void)
         test_ConvertThreadToFiber();
 
     fibers[1] = pCreateFiber(0,FiberMainProc,&testparam);
-    ok(fibers[1] != NULL, "CreateFiber failed with error %u\n", GetLastError());
+    ok(fibers[1] != NULL, "CreateFiber failed with error %lu\n", GetLastError());
 
     pSwitchToFiber(fibers[1]);
     ok(fiberCount == 1, "Wrong fiber count: %d\n", fiberCount);
@@ -203,7 +203,7 @@ static void test_FiberHandling(void)
     if (pCreateFiberEx)
     {
         fibers[1] = pCreateFiberEx(0,0,0,FiberMainProc,&testparam);
-        ok(fibers[1] != NULL, "CreateFiberEx failed with error %u\n", GetLastError());
+        ok(fibers[1] != NULL, "CreateFiberEx failed with error %lu\n", GetLastError());
 
         pSwitchToFiber(fibers[1]);
         ok(fiberCount == 2, "Wrong fiber count: %d\n", fiberCount);
@@ -285,6 +285,7 @@ static void test_FiberLocalStorage(void)
     PEB *peb = teb->Peb;
     NTSTATUS status;
     HANDLE hthread;
+    ULONG index2;
     SIZE_T size;
     void* val;
     BOOL ret;
@@ -300,7 +301,7 @@ static void test_FiberLocalStorage(void)
         if (pRtlFlsGetValue)
         {
             status = pRtlFlsGetValue(0, NULL);
-            ok(status == STATUS_INVALID_PARAMETER, "Got unexpected status %#x.\n", status);
+            ok(status == STATUS_INVALID_PARAMETER, "Got unexpected status %#lx.\n", status);
         }
         else
         {
@@ -311,16 +312,16 @@ static void test_FiberLocalStorage(void)
         {
             fls_indices[i] = 0xdeadbeef;
             status = pRtlFlsAlloc(test_fls_callback, &fls_indices[i]);
-            ok(!status || status == STATUS_NO_MEMORY, "Got unexpected status %#x.\n", status);
+            ok(!status || status == STATUS_NO_MEMORY, "Got unexpected status %#lx.\n", status);
             if (status)
             {
-                ok(fls_indices[i] == 0xdeadbeef, "Got unexpected index %#x.\n", fls_indices[i]);
+                ok(fls_indices[i] == 0xdeadbeef, "Got unexpected index %#lx.\n", fls_indices[i]);
                 break;
             }
             if (pRtlFlsSetValue)
             {
                 status = pRtlFlsSetValue(fls_indices[i], (void *)(ULONG_PTR)(i + 1));
-                ok(!status, "Got unexpected status %#x.\n", status);
+                ok(!status, "Got unexpected status %#lx.\n", status);
             }
         }
         count = i;
@@ -335,7 +336,7 @@ static void test_FiberLocalStorage(void)
             ok(pRtlFlsSetValue && pRtlFlsGetValue, "Missing RtlFlsGetValue / RtlFlsSetValue.\n");
             ok(!peb->FlsBitmap, "Got unexpected FlsBitmap %p.\n", peb->FlsBitmap);
             ok(!peb->FlsListHead.Flink && !peb->FlsListHead.Blink, "Got nonzero FlsListHead.\n");
-            ok(!peb->FlsHighIndex, "Got unexpected FlsHighIndex %u.\n", peb->FlsHighIndex);
+            ok(!peb->FlsHighIndex, "Got unexpected FlsHighIndex %lu.\n", peb->FlsHighIndex);
 
             fls_list_head = fls_data->fls_list_entry.Flink;
 
@@ -345,13 +346,13 @@ static void test_FiberLocalStorage(void)
 
             g_fls_data = CONTAINING_RECORD(fls_list_head, GLOBAL_FLS_DATA, fls_list_head);
 
-            ok(g_fls_data->fls_high_index == 0xfef, "Got unexpected fls_high_index %#x.\n", g_fls_data->fls_high_index);
+            ok(g_fls_data->fls_high_index == 0xfef, "Got unexpected fls_high_index %#lx.\n", g_fls_data->fls_high_index);
 
             for (i = 0; i < 8; ++i)
             {
                 ok(!!g_fls_data->fls_callback_chunks[i], "Got zero fls_callback_chunks[%u].\n", i);
                 ok(g_fls_data->fls_callback_chunks[i]->count == test_fls_chunk_size(i),
-                        "Got unexpected g_fls_data->fls_callback_chunks[%u]->count %u.\n",
+                        "Got unexpected g_fls_data->fls_callback_chunks[%u]->count %lu.\n",
                         i, g_fls_data->fls_callback_chunks[i]->count);
 
                 size = HeapSize(GetProcessHeap(), 0, g_fls_data->fls_callback_chunks[i]);
@@ -391,12 +392,12 @@ static void test_FiberLocalStorage(void)
             j = test_fls_chunk_index_from_index(fls_indices[0x10], &index);
             g_fls_data->fls_callback_chunks[j]->callbacks[index].callback = NULL;
             status = pRtlFlsFree(fls_indices[0x10]);
-            ok(status == STATUS_INVALID_PARAMETER, "Got unexpected status %#x.\n", status);
+            ok(status == STATUS_INVALID_PARAMETER, "Got unexpected status %#lx.\n", status);
 
             g_fls_data->fls_callback_chunks[j]->callbacks[index].callback = test_fls_callback;
             test_fls_callback_call_count = 0;
             status = pRtlFlsFree(fls_indices[0x10]);
-            ok(!status, "Got unexpected status %#x.\n", status);
+            ok(!status, "Got unexpected status %#lx.\n", status);
             ok(test_fls_callback_call_count == 1, "Got unexpected callback call count %u.\n",
                     test_fls_callback_call_count);
 
@@ -407,27 +408,27 @@ static void test_FiberLocalStorage(void)
                     g_fls_data->fls_callback_chunks[j]->callbacks[index].callback);
 
             fls_data->fls_data_chunks[j][index + 1] = (void *)(ULONG_PTR)0x28;
-            status = pRtlFlsAlloc(test_fls_callback, &i);
-            ok(!status, "Got unexpected status %#x.\n", status);
-            ok(i == fls_indices[0x10], "Got unexpected index %u.\n", i);
+            status = pRtlFlsAlloc(test_fls_callback, &index2);
+            ok(!status, "Got unexpected status %#lx.\n", status);
+            ok(index2 == fls_indices[0x10], "Got unexpected index %lu.\n", index2);
             ok(fls_data->fls_data_chunks[j][index + 1] == (void *)(ULONG_PTR)0x28, "Got unexpected data %p.\n",
                     fls_data->fls_data_chunks[j][index + 1]);
 
             status = pRtlFlsSetValue(i, (void *)(ULONG_PTR)0x11);
-            ok(!status, "Got unexpected status %#x.\n", status);
+            ok(!status, "Got unexpected status %#lx.\n", status);
 
             teb->FlsSlots = NULL;
 
             val = (void *)0xdeadbeef;
             status = pRtlFlsGetValue(fls_indices[1], &val);
             new_fls_data = teb->FlsSlots;
-            ok(status == STATUS_INVALID_PARAMETER, "Got unexpected status %#x.\n", status);
+            ok(status == STATUS_INVALID_PARAMETER, "Got unexpected status %#lx.\n", status);
             ok(val == (void *)0xdeadbeef, "Got unexpected val %p.\n", val);
             ok(!new_fls_data, "Got unexpected teb->FlsSlots %p.\n", new_fls_data);
 
             status = pRtlFlsSetValue(fls_indices[1], (void *)(ULONG_PTR)0x28);
             new_fls_data = teb->FlsSlots;
-            ok(!status, "Got unexpected status %#x.\n", status);
+            ok(!status, "Got unexpected status %#lx.\n", status);
             ok(!!new_fls_data, "Got unexpected teb->FlsSlots %p.\n", new_fls_data);
 
             entry_count = check_linked_list(fls_list_head, &fls_data->fls_list_entry, &index);
@@ -438,7 +439,7 @@ static void test_FiberLocalStorage(void)
 
             val = (void *)0xdeadbeef;
             status = pRtlFlsGetValue(fls_indices[2], &val);
-            ok(!status, "Got unexpected status %#x.\n", status);
+            ok(!status, "Got unexpected status %#lx.\n", status);
             ok(!val, "Got unexpected val %p.\n", val);
 
 
@@ -467,7 +468,7 @@ static void test_FiberLocalStorage(void)
             hthread = CreateThread(NULL, 0, test_FiberLocalStorage_thread, NULL, 0, NULL);
             ok(!!hthread, "CreateThread failed.\n");
             result = WaitForSingleObject(test_fiberlocalstorage_peb_locked_event, INFINITE);
-            ok(result == WAIT_OBJECT_0, "Got unexpected result %u.\n", result);
+            ok(result == WAIT_OBJECT_0, "Got unexpected result %lu.\n", result);
             teb->FlsSlots = NULL;
 
             test_fls_callback_call_count = 0;
@@ -525,17 +526,17 @@ static void test_FiberLocalStorage(void)
             if (pRtlFlsGetValue)
             {
                 status = pRtlFlsGetValue(fls_indices[i], &val);
-                ok(!status, "Got unexpected status %#x.\n", status);
+                ok(!status, "Got unexpected status %#lx.\n", status);
                 ok(val == (void *)(ULONG_PTR)(i + 1), "Got unexpected val %p, i %u.\n", val, i);
             }
 
             status = pRtlFlsFree(fls_indices[i]);
-            ok(!status, "Got unexpected status %#x, i %u.\n", status, i);
+            ok(!status, "Got unexpected status %#lx, i %u.\n", status, i);
         }
 
         if (!peb->FlsCallback)
         {
-            ok(g_fls_data->fls_high_index == 0xfef, "Got unexpected fls_high_index %#x.\n",
+            ok(g_fls_data->fls_high_index == 0xfef, "Got unexpected fls_high_index %#lx.\n",
                     g_fls_data->fls_high_index);
 
             for (i = 0; i < 8; ++i)
@@ -558,34 +559,34 @@ static void test_FiberLocalStorage(void)
     ret = pFlsFree( 127 );
     ok( !ret, "freeing fls index 127 (unallocated) succeeded\n" );
     ok( GetLastError() == ERROR_INVALID_PARAMETER,
-        "freeing fls index 127 (unallocated) wrong error %u\n", GetLastError() );
+        "freeing fls index 127 (unallocated) wrong error %lu\n", GetLastError() );
 
     val = pFlsGetValue( 127 );
     ok( val == NULL,
-        "getting fls index 127 (unallocated) failed with error %u\n", GetLastError() );
+        "getting fls index 127 (unallocated) failed with error %lu\n", GetLastError() );
 
     if (pRtlFlsGetValue)
     {
         val = (void *)0xdeadbeef;
         status = pRtlFlsGetValue(127, &val);
-        ok( !status, "Got unexpected status %#x.\n", status );
+        ok( !status, "Got unexpected status %#lx.\n", status );
         ok( !val, "Got unexpected val %p.\n", val );
     }
 
     ret = pFlsSetValue( 127, (void*) 0x217 );
-    ok( ret, "setting fls index 127 (unallocated) failed with error %u\n", GetLastError() );
+    ok( ret, "setting fls index 127 (unallocated) failed with error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     val = pFlsGetValue( 127 );
     ok( val == (void*) 0x217, "fls index 127 (unallocated) wrong value %p\n", val );
     ok( GetLastError() == ERROR_SUCCESS,
-        "getting fls index 127 (unallocated) failed with error %u\n", GetLastError() );
+        "getting fls index 127 (unallocated) failed with error %lu\n", GetLastError() );
 
     if (pRtlFlsGetValue)
     {
         val = (void *)0xdeadbeef;
         status = pRtlFlsGetValue(127, &val);
-        ok( !status, "Got unexpected status %#x.\n", status );
+        ok( !status, "Got unexpected status %#lx.\n", status );
         ok( val == (void*)0x217, "Got unexpected val %p.\n", val );
     }
 
@@ -596,86 +597,86 @@ static void test_FiberLocalStorage(void)
     ret = pFlsFree( 128 );
     ok( !ret, "freeing fls index 128 (out of bounds) succeeded\n" );
     ok( GetLastError() == ERROR_INVALID_PARAMETER,
-        "freeing fls index 128 (out of bounds) wrong error %u\n", GetLastError() );
+        "freeing fls index 128 (out of bounds) wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     ret = pFlsSetValue( 128, (void*) 0x217 );
     ok( ret || GetLastError() == ERROR_INVALID_PARAMETER,
-        "setting fls index 128 (out of bounds) wrong error %u\n", GetLastError() );
+        "setting fls index 128 (out of bounds) wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     val = pFlsGetValue( 128 );
     ok( GetLastError() == ERROR_INVALID_PARAMETER || val == (void *)0x217,
-        "getting fls index 128 (out of bounds) wrong error %u\n", GetLastError() );
+        "getting fls index 128 (out of bounds) wrong error %lu\n", GetLastError() );
 
     /* Test index 0 */
     SetLastError( 0xdeadbeef );
     val = pFlsGetValue( 0 );
     ok( !val, "fls index 0 set to %p\n", val );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "setting fls index wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "setting fls index wrong error %lu\n", GetLastError() );
     if (pRtlFlsGetValue)
     {
         val = (void *)0xdeadbeef;
         status = pRtlFlsGetValue(0, &val);
-        ok( status == STATUS_INVALID_PARAMETER, "Got unexpected status %#x.\n", status );
+        ok( status == STATUS_INVALID_PARAMETER, "Got unexpected status %#lx.\n", status );
         ok( val == (void*)0xdeadbeef, "Got unexpected val %p.\n", val );
     }
 
     SetLastError( 0xdeadbeef );
     ret = pFlsSetValue( 0, (void *)0xdeadbeef );
     ok( !ret, "setting fls index 0 succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "setting fls index wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "setting fls index wrong error %lu\n", GetLastError() );
     if (pRtlFlsSetValue)
     {
         status = pRtlFlsSetValue( 0, (void *)0xdeadbeef );
-        ok( status == STATUS_INVALID_PARAMETER, "Got unexpected status %#x.\n", status );
+        ok( status == STATUS_INVALID_PARAMETER, "Got unexpected status %#lx.\n", status );
     }
     SetLastError( 0xdeadbeef );
     val = pFlsGetValue( 0 );
     ok( !val, "fls index 0 wrong value %p\n", val );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "setting fls index wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "setting fls index wrong error %lu\n", GetLastError() );
 
     /* Test creating an FLS index */
     fls = pFlsAlloc( NULL );
     ok( fls != FLS_OUT_OF_INDEXES, "FlsAlloc failed\n" );
     ok( fls != 0, "fls index 0 allocated\n" );
     val = pFlsGetValue( fls );
-    ok( !val, "fls index %u wrong value %p\n", fls, val );
+    ok( !val, "fls index %lu wrong value %p\n", fls, val );
     SetLastError( 0xdeadbeef );
     ret = pFlsSetValue( fls, (void *)0xdeadbeef );
-    ok( ret, "setting fls index %u failed\n", fls );
-    ok( GetLastError() == 0xdeadbeef, "setting fls index wrong error %u\n", GetLastError() );
+    ok( ret, "setting fls index %lu failed\n", fls );
+    ok( GetLastError() == 0xdeadbeef, "setting fls index wrong error %lu\n", GetLastError() );
     SetLastError( 0xdeadbeef );
     val = pFlsGetValue( fls );
-    ok( val == (void *)0xdeadbeef, "fls index %u wrong value %p\n", fls, val );
+    ok( val == (void *)0xdeadbeef, "fls index %lu wrong value %p\n", fls, val );
     ok( GetLastError() == ERROR_SUCCESS,
-        "getting fls index %u failed with error %u\n", fls, GetLastError() );
+        "getting fls index %lu failed with error %lu\n", fls, GetLastError() );
     pFlsFree( fls );
 
     /* Undefined behavior: verify the value is NULL after it the slot is freed */
     SetLastError( 0xdeadbeef );
     val = pFlsGetValue( fls );
-    ok( val == NULL, "fls index %u wrong value %p\n", fls, val );
+    ok( val == NULL, "fls index %lu wrong value %p\n", fls, val );
     ok( GetLastError() == ERROR_SUCCESS,
-        "getting fls index %u failed with error %u\n", fls, GetLastError() );
+        "getting fls index %lu failed with error %lu\n", fls, GetLastError() );
 
     /* Undefined behavior: verify the value is settable after the slot is freed */
     ret = pFlsSetValue( fls, (void *)0xdeadbabe );
-    ok( ret, "setting fls index %u failed\n", fls );
+    ok( ret, "setting fls index %lu failed\n", fls );
     val = pFlsGetValue( fls );
-    ok( val == (void *)0xdeadbabe, "fls index %u wrong value %p\n", fls, val );
+    ok( val == (void *)0xdeadbabe, "fls index %lu wrong value %p\n", fls, val );
 
     /* Try to create the same FLS index again, and verify that is initialized to NULL */
     fls_2 = pFlsAlloc( NULL );
-    ok( fls != FLS_OUT_OF_INDEXES, "FlsAlloc failed with error %u\n", GetLastError() );
+    ok( fls != FLS_OUT_OF_INDEXES, "FlsAlloc failed with error %lu\n", GetLastError() );
     /* If this fails it is not an API error, but the test will be inconclusive */
-    ok( fls_2 == fls, "different FLS index allocated, was %u, now %u\n", fls, fls_2 );
+    ok( fls_2 == fls, "different FLS index allocated, was %lu, now %lu\n", fls, fls_2 );
 
     SetLastError( 0xdeadbeef );
     val = pFlsGetValue( fls_2 );
-    ok( val == NULL || val == (void *)0xdeadbabe, "fls index %u wrong value %p\n", fls, val );
+    ok( val == NULL || val == (void *)0xdeadbabe, "fls index %lu wrong value %p\n", fls, val );
     ok( GetLastError() == ERROR_SUCCESS,
-        "getting fls index %u failed with error %u\n", fls_2, GetLastError() );
+        "getting fls index %lu failed with error %lu\n", fls_2, GetLastError() );
     pFlsFree( fls_2 );
 }
 
@@ -694,30 +695,30 @@ static void test_FiberLocalStorageCallback(PFLS_CALLBACK_FUNCTION cbfunc)
     /* Test that the callback is executed */
     cbCount = 0;
     fls = pFlsAlloc( cbfunc );
-    ok( fls != FLS_OUT_OF_INDEXES, "FlsAlloc failed with error %u\n", GetLastError() );
+    ok( fls != FLS_OUT_OF_INDEXES, "FlsAlloc failed with error %lu\n", GetLastError() );
 
     val = (void*) 0x1587;
     fls_value_to_set = val;
     ret = pFlsSetValue( fls, val );
-    ok(ret, "FlsSetValue failed with error %u\n", GetLastError() );
+    ok(ret, "FlsSetValue failed with error %lu\n", GetLastError() );
 
     val2 = pFlsGetValue( fls );
     ok(val == val2, "FlsGetValue returned %p, expected %p\n", val2, val);
 
     ret = pFlsFree( fls );
-    ok(ret, "FlsFree failed with error %u\n", GetLastError() );
+    ok(ret, "FlsFree failed with error %lu\n", GetLastError() );
     ok( cbCount == 1, "Wrong callback count: %d\n", cbCount );
 
     /* Test that callback is not executed if value is NULL */
     cbCount = 0;
     fls = pFlsAlloc( cbfunc );
-    ok( fls != FLS_OUT_OF_INDEXES, "FlsAlloc failed with error %u\n", GetLastError() );
+    ok( fls != FLS_OUT_OF_INDEXES, "FlsAlloc failed with error %lu\n", GetLastError() );
 
     ret = pFlsSetValue( fls, NULL );
-    ok( ret, "FlsSetValue failed with error %u\n", GetLastError() );
+    ok( ret, "FlsSetValue failed with error %lu\n", GetLastError() );
 
     pFlsFree( fls );
-    ok( ret, "FlsFree failed with error %u\n", GetLastError() );
+    ok( ret, "FlsFree failed with error %lu\n", GetLastError() );
     ok( cbCount == 0, "Wrong callback count: %d\n", cbCount );
 }
 
@@ -734,7 +735,7 @@ static void test_FiberLocalStorageWithFibers(PFLS_CALLBACK_FUNCTION cbfunc)
     }
 
     fls_index_to_set = pFlsAlloc(cbfunc);
-    ok(fls_index_to_set != FLS_OUT_OF_INDEXES, "FlsAlloc failed with error %u\n", GetLastError());
+    ok(fls_index_to_set != FLS_OUT_OF_INDEXES, "FlsAlloc failed with error %lu\n", GetLastError());
 
     test_ConvertThreadToFiber();
 
@@ -742,8 +743,8 @@ static void test_FiberLocalStorageWithFibers(PFLS_CALLBACK_FUNCTION cbfunc)
     cbCount = 0;
     fibers[1] = pCreateFiber(0,FiberMainProc,&testparam);
     fibers[2] = pCreateFiber(0,FiberMainProc,&testparam);
-    ok(fibers[1] != NULL, "CreateFiber failed with error %u\n", GetLastError());
-    ok(fibers[2] != NULL, "CreateFiber failed with error %u\n", GetLastError());
+    ok(fibers[1] != NULL, "CreateFiber failed with error %lu\n", GetLastError());
+    ok(fibers[2] != NULL, "CreateFiber failed with error %lu\n", GetLastError());
     ok(fiberCount == 0, "Wrong fiber count: %d\n", fiberCount);
     ok(cbCount == 0, "Wrong callback count: %d\n", cbCount);
 
@@ -840,7 +841,7 @@ static void test_fls_exit_deadlock(void)
     winetest_get_mainargs(&argv);
     sprintf(cmdline, "%s %s fls_exit_deadlock", argv[0], argv[1]);
     ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-    ok(ret, "failed to create child, error %u\n", GetLastError());
+    ok(ret, "failed to create child, error %lu\n", GetLastError());
     ret = WaitForSingleObject(pi.hProcess, 1000);
     ok(!ret, "wait failed\n");
     CloseHandle(pi.hProcess);
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c
index f16a092a4df..1c4cdfea1b4 100644
--- a/dlls/kernel32/tests/file.c
+++ b/dlls/kernel32/tests/file.c
@@ -131,7 +131,7 @@ static void test__hread( void )
     filehandle = _lcreat( filename, 0 );
     if (filehandle == HFILE_ERROR)
     {
-        ok(0,"couldn't create file \"%s\" (err=%d)\n",filename,GetLastError());
+        ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
         return;
     }
 
@@ -141,7 +141,7 @@ static void test__hread( void )
 
     filehandle = _lopen( filename, OF_READ );
 
-    ok( HFILE_ERROR != filehandle, "couldn't open file \"%s\" again (err=%d)\n", filename, GetLastError(  ) );
+    ok( HFILE_ERROR != filehandle, "couldn't open file \"%s\" again (err=%ld)\n", filename, GetLastError(  ) );
 
     bytes_read = _hread( filehandle, buffer, 2 * strlen( sillytext ) );
 
@@ -160,7 +160,7 @@ static void test__hread( void )
     ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains\n" );
 
     ret = DeleteFileA( filename );
-    ok( ret != 0, "DeleteFile failed (%d)\n", GetLastError(  ) );
+    ok( ret != 0, "DeleteFile failed (%ld)\n", GetLastError(  ) );
 }
 
 
@@ -180,7 +180,7 @@ static void test__hwrite( void )
     filehandle = _lcreat( filename, 0 );
     if (filehandle == HFILE_ERROR)
     {
-        ok(0,"couldn't create file \"%s\" (err=%d)\n",filename,GetLastError());
+        ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
         return;
     }
 
@@ -245,7 +245,7 @@ static void test__hwrite( void )
     ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains\n" );
 
     ret = DeleteFileA( filename );
-    ok( ret != 0, "DeleteFile failed (%d)\n", GetLastError(  ) );
+    ok( ret != 0, "DeleteFile failed (%ld)\n", GetLastError(  ) );
 
     LocalFree( contents );
 }
@@ -259,7 +259,7 @@ static void test__lclose( void )
     filehandle = _lcreat( filename, 0 );
     if (filehandle == HFILE_ERROR)
     {
-        ok(0,"couldn't create file \"%s\" (err=%d)\n",filename,GetLastError());
+        ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
         return;
     }
 
@@ -268,7 +268,7 @@ static void test__lclose( void )
     ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
 
     ret = DeleteFileA( filename );
-    ok( ret != 0, "DeleteFile failed (%d)\n", GetLastError(  ) );
+    ok( ret != 0, "DeleteFile failed (%ld)\n", GetLastError(  ) );
 }
 
 /* helper function for test__lcreat */
@@ -282,7 +282,7 @@ static void get_nt_pathW( const char *name, UNICODE_STRING *nameW )
     pRtlInitAnsiString( &str, name );
 
     status = pRtlAnsiStringToUnicodeString( &strW, &str, TRUE );
-    ok( !status, "RtlAnsiStringToUnicodeString failed with %08x\n", status );
+    ok( !status, "RtlAnsiStringToUnicodeString failed with %08lx\n", status );
 
     ret = pRtlDosPathNameToNtPathName_U( strW.Buffer, nameW, NULL, NULL );
     ok( ret, "RtlDosPathNameToNtPathName_U failed\n" );
@@ -307,7 +307,7 @@ static void test__lcreat( void )
     filehandle = _lcreat( filename, 0 );
     if (filehandle == HFILE_ERROR)
     {
-        ok(0,"couldn't create file \"%s\" (err=%d)\n",filename,GetLastError());
+        ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
         return;
     }
 
@@ -324,10 +324,10 @@ static void test__lcreat( void )
     FindClose( find );
 
     ret = DeleteFileA(filename);
-    ok( ret != 0, "DeleteFile failed (%d)\n", GetLastError());
+    ok( ret != 0, "DeleteFile failed (%ld)\n", GetLastError());
 
     filehandle = _lcreat( filename, 1 ); /* readonly */
-    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)\n", filename, GetLastError(  ) );
+    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%ld)\n", filename, GetLastError(  ) );
 
     ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite shouldn't be able to write never the less\n" );
 
@@ -339,14 +339,14 @@ static void test__lcreat( void )
 
     SetLastError( 0xdeadbeef );
     ok( 0 == DeleteFileA( filename ), "shouldn't be able to delete a readonly file\n" );
-    ok( GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError() );
 
     ok( SetFileAttributesA(filename, FILE_ATTRIBUTE_NORMAL ) != 0, "couldn't change attributes on file\n" );
 
     ok( DeleteFileA( filename ) != 0, "now it should be possible to delete the file!\n" );
 
     filehandle = _lcreat( filename, 1 ); /* readonly */
-    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)\n", filename, GetLastError() );
+    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%ld)\n", filename, GetLastError() );
     ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen(sillytext) ),
         "_hwrite shouldn't be able to write never the less\n" );
     ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
@@ -366,24 +366,24 @@ static void test__lcreat( void )
     status = pNtCreateFile( &file, GENERIC_READ | GENERIC_WRITE | DELETE, &attr, &io, NULL, 0,
                            FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
                            FILE_OPEN, FILE_DELETE_ON_CLOSE | FILE_NON_DIRECTORY_FILE, NULL, 0 );
-    ok( status == STATUS_ACCESS_DENIED, "expected STATUS_ACCESS_DENIED, got %08x\n", status );
+    ok( status == STATUS_ACCESS_DENIED, "expected STATUS_ACCESS_DENIED, got %08lx\n", status );
     ok( GetFileAttributesA( filename ) != INVALID_FILE_ATTRIBUTES, "file was deleted\n" );
 
     status = pNtCreateFile( &file, DELETE, &attr, &io, NULL, 0,
                            FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
                            FILE_OPEN, FILE_DELETE_ON_CLOSE | FILE_NON_DIRECTORY_FILE, NULL, 0 );
-    ok( status == STATUS_CANNOT_DELETE, "expected STATUS_CANNOT_DELETE, got %08x\n", status );
+    ok( status == STATUS_CANNOT_DELETE, "expected STATUS_CANNOT_DELETE, got %08lx\n", status );
 
     status = pNtCreateFile( &file, DELETE, &attr, &io, NULL, 0,
                            FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
                            FILE_OPEN, FILE_DELETE_ON_CLOSE | FILE_DIRECTORY_FILE, NULL, 0 );
-    ok( status == STATUS_NOT_A_DIRECTORY, "expected STATUS_NOT_A_DIRECTORY, got %08x\n", status );
+    ok( status == STATUS_NOT_A_DIRECTORY, "expected STATUS_NOT_A_DIRECTORY, got %08lx\n", status );
 
     status = pNtCreateFile( &file, DELETE, &attr, &io, NULL, 0,
                            FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
                            FILE_OPEN_IF, FILE_DELETE_ON_CLOSE | FILE_NON_DIRECTORY_FILE, NULL, 0 );
     todo_wine
-    ok( status == STATUS_CANNOT_DELETE, "expected STATUS_CANNOT_DELETE, got %08x\n", status );
+    ok( status == STATUS_CANNOT_DELETE, "expected STATUS_CANNOT_DELETE, got %08lx\n", status );
     if (!status) CloseHandle( file );
 
     pRtlFreeUnicodeString( &filenameW );
@@ -396,7 +396,7 @@ static void test__lcreat( void )
     ok( DeleteFileA( filename ) != 0, "now it should be possible to delete the file\n" );
 
     filehandle = _lcreat( filename, 2 );
-    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)\n", filename, GetLastError(  ) );
+    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%ld)\n", filename, GetLastError(  ) );
 
     ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains\n" );
 
@@ -411,10 +411,10 @@ static void test__lcreat( void )
     FindClose( find );
 
     ret = DeleteFileA( filename );
-    ok( ret, "DeleteFile failed (%d)\n", GetLastError(  ) );
+    ok( ret, "DeleteFile failed (%ld)\n", GetLastError(  ) );
 
     filehandle = _lcreat( filename, 4 ); /* SYSTEM file */
-    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)\n", filename, GetLastError(  ) );
+    ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%ld)\n", filename, GetLastError(  ) );
 
     ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen( sillytext ) ), "_hwrite complains\n" );
 
@@ -429,7 +429,7 @@ static void test__lcreat( void )
     FindClose( find );
 
     ret = DeleteFileA( filename );
-    ok( ret, "DeleteFile failed (%d)\n", GetLastError(  ) );
+    ok( ret, "DeleteFile failed (%ld)\n", GetLastError(  ) );
 
     filehandle=_lcreat (slashname, 0); /* illegal name */
     if (HFILE_ERROR==filehandle) {
@@ -442,16 +442,16 @@ static void test__lcreat( void )
       if (INVALID_HANDLE_VALUE!=find)
       {
         ret = FindClose (find);
-        ok (0 != ret, "FindClose complains (%d)\n", GetLastError ());
+        ok (0 != ret, "FindClose complains (%ld)\n", GetLastError ());
         slashname[strlen(slashname)-1]=0;
         ok (!strcmp (slashname, search_results.cFileName),
             "found unexpected name \"%s\"\n", search_results.cFileName);
         ok (FILE_ATTRIBUTE_ARCHIVE==search_results.dwFileAttributes,
-            "attributes of file \"%s\" are 0x%04x\n", search_results.cFileName,
+            "attributes of file \"%s\" are 0x%04lx\n", search_results.cFileName,
             search_results.dwFileAttributes);
       }
     ret = DeleteFileA( slashname );
-    ok( ret, "DeleteFile failed (%d)\n", GetLastError(  ) );
+    ok( ret, "DeleteFile failed (%ld)\n", GetLastError(  ) );
     }
 
     filehandle=_lcreat (filename, 8); /* illegal attribute */
@@ -469,17 +469,17 @@ static void test__lcreat( void )
         else name = filename;
 
         ret = FindClose(find);
-        ok ( 0 != ret, "FindClose complains (%d)\n", GetLastError ());
+        ok ( 0 != ret, "FindClose complains (%ld)\n", GetLastError ());
         ok (!strcmp (name, search_results.cFileName),
             "expected \"%s\", got \"%s\"\n", name, search_results.cFileName);
         search_results.dwFileAttributes &= ~FILE_ATTRIBUTE_NOT_CONTENT_INDEXED;
         search_results.dwFileAttributes &= ~FILE_ATTRIBUTE_COMPRESSED;
         ok (FILE_ATTRIBUTE_ARCHIVE==search_results.dwFileAttributes,
-            "attributes of file \"%s\" are 0x%04x\n", search_results.cFileName,
+            "attributes of file \"%s\" are 0x%04lx\n", search_results.cFileName,
             search_results.dwFileAttributes);
       }
     ret = DeleteFileA( filename );
-    ok( ret, "DeleteFile failed (%d)\n", GetLastError(  ) );
+    ok( ret, "DeleteFile failed (%ld)\n", GetLastError(  ) );
     }
 }
 
@@ -495,7 +495,7 @@ static void test__llseek( void )
     filehandle = _lcreat( filename, 0 );
     if (filehandle == HFILE_ERROR)
     {
-        ok(0,"couldn't create file \"%s\" (err=%d)\n",filename,GetLastError());
+        ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
         return;
     }
 
@@ -518,7 +518,7 @@ static void test__llseek( void )
     ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
 
     ret = DeleteFileA( filename );
-    ok( ret, "DeleteFile failed (%d)\n", GetLastError(  ) );
+    ok( ret, "DeleteFile failed (%ld)\n", GetLastError(  ) );
 }
 
 
@@ -532,7 +532,7 @@ static void test__llopen( void )
     filehandle = _lcreat( filename, 0 );
     if (filehandle == HFILE_ERROR)
     {
-        ok(0,"couldn't create file \"%s\" (err=%d)\n",filename,GetLastError());
+        ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
         return;
     }
 
@@ -557,7 +557,7 @@ static void test__llopen( void )
     ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
 
     ret = DeleteFileA( filename );
-    ok( ret, "DeleteFile failed (%d)\n", GetLastError(  ) );
+    ok( ret, "DeleteFile failed (%ld)\n", GetLastError(  ) );
     /* TODO - add tests for the SHARE modes  -  use two processes to pull this one off */
 }
 
@@ -574,7 +574,7 @@ static void test__lread( void )
     filehandle = _lcreat( filename, 0 );
     if (filehandle == HFILE_ERROR)
     {
-        ok(0,"couldn't create file \"%s\" (err=%d)\n",filename,GetLastError());
+        ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
         return;
     }
 
@@ -584,7 +584,7 @@ static void test__lread( void )
 
     filehandle = _lopen( filename, OF_READ );
 
-    ok( HFILE_ERROR != filehandle, "couldn't open file \"%s\" again (err=%d)\n", filename, GetLastError());
+    ok( HFILE_ERROR != filehandle, "couldn't open file \"%s\" again (err=%ld)\n", filename, GetLastError());
 
     bytes_read = _lread( filehandle, buffer, 2 * strlen( sillytext ) );
 
@@ -603,7 +603,7 @@ static void test__lread( void )
     ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
 
     ret = DeleteFileA( filename );
-    ok( ret, "DeleteFile failed (%d)\n", GetLastError(  ) );
+    ok( ret, "DeleteFile failed (%ld)\n", GetLastError(  ) );
 }
 
 
@@ -623,7 +623,7 @@ static void test__lwrite( void )
     filehandle = _lcreat( filename, 0 );
     if (filehandle == HFILE_ERROR)
     {
-        ok(0,"couldn't create file \"%s\" (err=%d)\n",filename,GetLastError());
+        ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
         return;
     }
 
@@ -688,7 +688,7 @@ static void test__lwrite( void )
     ok( HFILE_ERROR != _lclose( filehandle ), "_lclose complains\n" );
 
     ret = DeleteFileA( filename );
-    ok( ret, "DeleteFile failed (%d)\n", GetLastError(  ) );
+    ok( ret, "DeleteFile failed (%ld)\n", GetLastError(  ) );
 
     LocalFree( contents );
 }
@@ -706,147 +706,147 @@ static void test_CopyFileA(void)
     BOOL retok;
 
     ret = GetTempPathA(MAX_PATH, temp_path);
-    ok(ret != 0, "GetTempPathA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempPathA error %ld\n", GetLastError());
     ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
 
     ret = GetTempFileNameA(temp_path, prefix, 0, source);
-    ok(ret != 0, "GetTempFileNameA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
 
     /* copying a file to itself must fail */
     retok = CopyFileA(source, source, FALSE);
     ok( !retok && (GetLastError() == ERROR_SHARING_VIOLATION || broken(GetLastError() == ERROR_FILE_EXISTS) /* Win 9x */),
-        "copying a file to itself didn't fail (ret=%d, err=%d)\n", retok, GetLastError());
+        "copying a file to itself didn't fail (ret=%d, err=%ld)\n", retok, GetLastError());
 
     /* make the source have not zero size */
     hfile = CreateFileA(source, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0 );
     ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file\n");
     retok = WriteFile(hfile, prefix, sizeof(prefix), &ret, NULL );
     ok( retok && ret == sizeof(prefix),
-       "WriteFile error %d\n", GetLastError());
+       "WriteFile error %ld\n", GetLastError());
     ok(GetFileSize(hfile, NULL) == sizeof(prefix), "source file has wrong size\n");
     /* get the file time and change it to prove the difference */
     ret = GetFileTime(hfile, NULL, NULL, &ft1);
-    ok( ret, "GetFileTime error %d\n", GetLastError());
+    ok( ret, "GetFileTime error %ld\n", GetLastError());
     ft1.dwLowDateTime -= 600000000; /* 60 second */
     ret = SetFileTime(hfile, NULL, NULL, &ft1);
-    ok( ret, "SetFileTime error %d\n", GetLastError());
+    ok( ret, "SetFileTime error %ld\n", GetLastError());
     GetFileTime(hfile, NULL, NULL, &ft1);  /* get the actual time back */
     CloseHandle(hfile);
 
     ret = GetTempFileNameA(temp_path, prefix, 0, dest);
-    ok(ret != 0, "GetTempFileNameA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = CopyFileA(source, dest, TRUE);
     ok(!ret && GetLastError() == ERROR_FILE_EXISTS,
-       "CopyFileA: unexpected error %d\n", GetLastError());
+       "CopyFileA: unexpected error %ld\n", GetLastError());
 
     ret = CopyFileA(source, dest, FALSE);
-    ok(ret, "CopyFileA: error %d\n", GetLastError());
+    ok(ret, "CopyFileA: error %ld\n", GetLastError());
 
     /* NULL checks */
     retok = CopyFileA(NULL, dest, TRUE);
     ok(!retok && GetLastError() == ERROR_PATH_NOT_FOUND,
-        "CopyFileA: ret = %d, unexpected error %d\n", retok, GetLastError());
+        "CopyFileA: ret = %d, unexpected error %ld\n", retok, GetLastError());
     retok = CopyFileA(source, NULL, TRUE);
     ok(!retok && GetLastError() == ERROR_PATH_NOT_FOUND,
-        "CopyFileA: ret = %d, unexpected error %d\n", retok, GetLastError());
+        "CopyFileA: ret = %d, unexpected error %ld\n", retok, GetLastError());
 
     /* copying from a read-locked source fails */
     hfile = CreateFileA(source, GENERIC_READ, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file, error %ld\n", GetLastError());
     retok = CopyFileA(source, dest, FALSE);
     ok(!retok && GetLastError() == ERROR_SHARING_VIOLATION,
         "copying from a read-locked file succeeded when it shouldn't have\n");
     /* in addition, the source is opened before the destination */
     retok = CopyFileA("25f99d3b-4ba4-4f66-88f5-2906886993cc", dest, FALSE);
     ok(!retok && GetLastError() == ERROR_FILE_NOT_FOUND,
-        "copying from a file that doesn't exist failed in an unexpected way (ret=%d, err=%d)\n", retok, GetLastError());
+        "copying from a file that doesn't exist failed in an unexpected way (ret=%d, err=%ld)\n", retok, GetLastError());
     CloseHandle(hfile);
 
     /* copying from a r+w opened, r shared source succeeds */
     hfile = CreateFileA(source, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file, error %ld\n", GetLastError());
     retok = CopyFileA(source, dest, FALSE);
     ok(retok,
-        "copying from an r+w opened and r shared file failed (ret=%d, err=%d)\n", retok, GetLastError());
+        "copying from an r+w opened and r shared file failed (ret=%d, err=%ld)\n", retok, GetLastError());
     CloseHandle(hfile);
 
     /* copying from a delete-locked source mostly succeeds */
     hfile = CreateFileA(source, DELETE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file, error %ld\n", GetLastError());
     retok = CopyFileA(source, dest, FALSE);
     ok(retok || broken(!retok && GetLastError() == ERROR_SHARING_VIOLATION) /* NT, 2000, XP */,
-        "copying from a delete-locked file failed (ret=%d, err=%d)\n", retok, GetLastError());
+        "copying from a delete-locked file failed (ret=%d, err=%ld)\n", retok, GetLastError());
     CloseHandle(hfile);
 
     /* copying to a write-locked destination fails */
     hfile = CreateFileA(dest, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %ld\n", GetLastError());
     retok = CopyFileA(source, dest, FALSE);
     ok(!retok && GetLastError() == ERROR_SHARING_VIOLATION,
-        "copying to a write-locked file didn't fail (ret=%d, err=%d)\n", retok, GetLastError());
+        "copying to a write-locked file didn't fail (ret=%d, err=%ld)\n", retok, GetLastError());
     CloseHandle(hfile);
 
     /* copying to a r+w opened, w shared destination mostly succeeds */
     hfile = CreateFileA(dest, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %ld\n", GetLastError());
     retok = CopyFileA(source, dest, FALSE);
     ok(retok || broken(!retok && GetLastError() == ERROR_SHARING_VIOLATION) /* Win 9x */,
-        "copying to a r+w opened and w shared file failed (ret=%d, err=%d)\n", retok, GetLastError());
+        "copying to a r+w opened and w shared file failed (ret=%d, err=%ld)\n", retok, GetLastError());
     CloseHandle(hfile);
 
     /* copying to a delete-locked destination fails, even when the destination is delete-shared */
     hfile = CreateFileA(dest, DELETE, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, 0);
     ok(hfile != INVALID_HANDLE_VALUE || broken(GetLastError() == ERROR_INVALID_PARAMETER) /* Win 9x */,
-        "failed to open destination file, error %d\n", GetLastError());
+        "failed to open destination file, error %ld\n", GetLastError());
     if (hfile != INVALID_HANDLE_VALUE)
     {
         retok = CopyFileA(source, dest, FALSE);
         ok(!retok && GetLastError() == ERROR_SHARING_VIOLATION,
-            "copying to a delete-locked shared file didn't fail (ret=%d, err=%d)\n", retok, GetLastError());
+            "copying to a delete-locked shared file didn't fail (ret=%d, err=%ld)\n", retok, GetLastError());
         CloseHandle(hfile);
     }
 
     /* copy to a file that's opened the way Wine opens the source */
     hfile = CreateFileA(dest, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %ld\n", GetLastError());
     retok = CopyFileA(source, dest, FALSE);
     ok(retok || broken(GetLastError() == ERROR_SHARING_VIOLATION) /* Win 9x */,
-        "copying to a file opened the way Wine opens the source failed (ret=%d, err=%d)\n", retok, GetLastError());
+        "copying to a file opened the way Wine opens the source failed (ret=%d, err=%ld)\n", retok, GetLastError());
     CloseHandle(hfile);
 
     /* make sure that destination has correct size */
     hfile = CreateFileA(dest, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
     ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file\n");
     ret = GetFileSize(hfile, NULL);
-    ok(ret == sizeof(prefix), "destination file has wrong size %d\n", ret);
+    ok(ret == sizeof(prefix), "destination file has wrong size %ld\n", ret);
 
     /* make sure that destination has the same filetime */
     ret = GetFileTime(hfile, NULL, NULL, &ft2);
-    ok( ret, "GetFileTime error %d\n", GetLastError());
+    ok( ret, "GetFileTime error %ld\n", GetLastError());
     ok(CompareFileTime(&ft1, &ft2) == 0, "destination file has wrong filetime\n");
 
     SetLastError(0xdeadbeef);
     ret = CopyFileA(source, dest, FALSE);
     ok(!ret && GetLastError() == ERROR_SHARING_VIOLATION,
-       "CopyFileA: ret = %d, unexpected error %d\n", ret, GetLastError());
+       "CopyFileA: ret = %ld, unexpected error %ld\n", ret, GetLastError());
 
     /* make sure that destination still has correct size */
     ret = GetFileSize(hfile, NULL);
-    ok(ret == sizeof(prefix), "destination file has wrong size %d\n", ret);
+    ok(ret == sizeof(prefix), "destination file has wrong size %ld\n", ret);
     retok = ReadFile(hfile, buf, sizeof(buf), &ret, NULL);
     ok( retok && ret == sizeof(prefix),
-       "ReadFile: error %d\n", GetLastError());
+       "ReadFile: error %ld\n", GetLastError());
     ok(!memcmp(prefix, buf, sizeof(prefix)), "buffer contents mismatch\n");
 
     /* check error on copying over a mapped file that was opened with FILE_SHARE_READ */
     hmapfile = CreateFileMappingW(hfile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL);
-    ok(hmapfile != NULL, "CreateFileMapping: error %d\n", GetLastError());
+    ok(hmapfile != NULL, "CreateFileMapping: error %ld\n", GetLastError());
 
     ret = CopyFileA(source, dest, FALSE);
     ok(!ret && GetLastError() == ERROR_SHARING_VIOLATION,
-       "CopyFileA with mapped dest file: expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
+       "CopyFileA with mapped dest file: expected ERROR_SHARING_VIOLATION, got %ld\n", GetLastError());
 
     CloseHandle(hmapfile);
     CloseHandle(hfile);
@@ -856,21 +856,21 @@ static void test_CopyFileA(void)
 
     /* check error on copying over a mapped file that was opened with FILE_SHARE_WRITE */
     hmapfile = CreateFileMappingW(hfile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL);
-    ok(hmapfile != NULL, "CreateFileMapping: error %d\n", GetLastError());
+    ok(hmapfile != NULL, "CreateFileMapping: error %ld\n", GetLastError());
 
     ret = CopyFileA(source, dest, FALSE);
     ok(!ret, "CopyFileA: expected failure\n");
     ok(GetLastError() == ERROR_USER_MAPPED_FILE ||
        broken(GetLastError() == ERROR_SHARING_VIOLATION), /* Win9x */
-       "CopyFileA with mapped dest file: expected ERROR_USER_MAPPED_FILE, got %d\n", GetLastError());
+       "CopyFileA with mapped dest file: expected ERROR_USER_MAPPED_FILE, got %ld\n", GetLastError());
 
     CloseHandle(hmapfile);
     CloseHandle(hfile);
 
     ret = DeleteFileA(source);
-    ok(ret, "DeleteFileA: error %d\n", GetLastError());
+    ok(ret, "DeleteFileA: error %ld\n", GetLastError());
     ret = DeleteFileA(dest);
-    ok(ret, "DeleteFileA: error %d\n", GetLastError());
+    ok(ret, "DeleteFileA: error %ld\n", GetLastError());
 }
 
 static void test_CopyFileW(void)
@@ -886,26 +886,26 @@ static void test_CopyFileW(void)
         win_skip("GetTempPathW is not available\n");
         return;
     }
-    ok(ret != 0, "GetTempPathW error %d\n", GetLastError());
+    ok(ret != 0, "GetTempPathW error %ld\n", GetLastError());
     ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
 
     ret = GetTempFileNameW(temp_path, prefix, 0, source);
-    ok(ret != 0, "GetTempFileNameW error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameW error %ld\n", GetLastError());
 
     ret = GetTempFileNameW(temp_path, prefix, 0, dest);
-    ok(ret != 0, "GetTempFileNameW error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameW error %ld\n", GetLastError());
 
     ret = CopyFileW(source, dest, TRUE);
     ok(!ret && GetLastError() == ERROR_FILE_EXISTS,
-       "CopyFileW: unexpected error %d\n", GetLastError());
+       "CopyFileW: unexpected error %ld\n", GetLastError());
 
     ret = CopyFileW(source, dest, FALSE);
-    ok(ret, "CopyFileW: error %d\n", GetLastError());
+    ok(ret, "CopyFileW: error %ld\n", GetLastError());
 
     ret = DeleteFileW(source);
-    ok(ret, "DeleteFileW: error %d\n", GetLastError());
+    ok(ret, "DeleteFileW: error %ld\n", GetLastError());
     ret = DeleteFileW(dest);
-    ok(ret, "DeleteFileW: error %d\n", GetLastError());
+    ok(ret, "DeleteFileW: error %ld\n", GetLastError());
 }
 
 static void test_CopyFile2(void)
@@ -927,14 +927,14 @@ static void test_CopyFile2(void)
     }
 
     ret = GetTempPathW(MAX_PATH, temp_path);
-    ok(ret != 0, "GetTempPathW error %d\n", GetLastError());
+    ok(ret != 0, "GetTempPathW error %ld\n", GetLastError());
     ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
 
     ret = GetTempFileNameW(temp_path, prefix, 0, source);
-    ok(ret != 0, "GetTempFileNameW error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameW error %ld\n", GetLastError());
 
     ret = GetTempFileNameW(temp_path, prefix, 0, dest);
-    ok(ret != 0, "GetTempFileNameW error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameW error %ld\n", GetLastError());
 
     /* fail if exists */
     memset(&params, 0, sizeof(params));
@@ -943,15 +943,15 @@ static void test_CopyFile2(void)
 
     SetLastError(0xdeadbeef);
     hr = pCopyFile2(source, dest, &params);
-    ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "CopyFile2: unexpected error 0x%08x\n", hr);
-    ok(GetLastError() == ERROR_FILE_EXISTS, "CopyFile2: last error %d\n", GetLastError());
+    ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "CopyFile2: unexpected error 0x%08lx\n", hr);
+    ok(GetLastError() == ERROR_FILE_EXISTS, "CopyFile2: last error %ld\n", GetLastError());
 
     /* don't fail if exists */
     params.dwSize = sizeof(params);
     params.dwCopyFlags = 0;
 
     hr = pCopyFile2(source, dest, &params);
-    ok(hr == S_OK, "CopyFile2: error 0x%08x\n", hr);
+    ok(hr == S_OK, "CopyFile2: error 0x%08lx\n", hr);
 
     /* copying a file to itself must fail */
     params.dwSize = sizeof(params);
@@ -959,160 +959,160 @@ static void test_CopyFile2(void)
 
     SetLastError(0xdeadbeef);
     hr = pCopyFile2(source, source, &params);
-    ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "CopyFile2: copying a file to itself didn't fail, 0x%08x\n", hr);
-    ok(GetLastError() == ERROR_SHARING_VIOLATION, "CopyFile2: last error %d\n", GetLastError());
+    ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "CopyFile2: copying a file to itself didn't fail, 0x%08lx\n", hr);
+    ok(GetLastError() == ERROR_SHARING_VIOLATION, "CopyFile2: last error %ld\n", GetLastError());
 
     /* make the source have not zero size */
     hfile = CreateFileW(source, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0 );
     ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file\n");
     ret = WriteFile(hfile, prefix, sizeof(prefix), &len, NULL );
-    ok(ret && len == sizeof(prefix), "WriteFile error %d\n", GetLastError());
+    ok(ret && len == sizeof(prefix), "WriteFile error %ld\n", GetLastError());
     ok(GetFileSize(hfile, NULL) == sizeof(prefix), "source file has wrong size\n");
 
     /* get the file time and change it to prove the difference */
     ret = GetFileTime(hfile, NULL, NULL, &ft1);
-    ok(ret, "GetFileTime error %d\n", GetLastError());
+    ok(ret, "GetFileTime error %ld\n", GetLastError());
     ft1.dwLowDateTime -= 600000000; /* 60 second */
     ret = SetFileTime(hfile, NULL, NULL, &ft1);
-    ok(ret, "SetFileTime error %d\n", GetLastError());
+    ok(ret, "SetFileTime error %ld\n", GetLastError());
     GetFileTime(hfile, NULL, NULL, &ft1);  /* get the actual time back */
     CloseHandle(hfile);
 
     ret = GetTempFileNameW(temp_path, prefix, 0, dest);
-    ok(ret != 0, "GetTempFileNameA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
 
     params.dwSize = sizeof(params);
     params.dwCopyFlags = COPY_FILE_FAIL_IF_EXISTS;
 
     SetLastError(0xdeadbeef);
     hr = pCopyFile2(source, dest, &params);
-    ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "CopyFile2: unexpected error 0x%08x\n", hr);
-    ok(GetLastError() == ERROR_FILE_EXISTS, "CopyFile2: last error %d\n", GetLastError());
+    ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "CopyFile2: unexpected error 0x%08lx\n", hr);
+    ok(GetLastError() == ERROR_FILE_EXISTS, "CopyFile2: last error %ld\n", GetLastError());
 
     params.dwSize = sizeof(params);
     params.dwCopyFlags = 0;
     hr = pCopyFile2(source, dest, &params);
-    ok(ret, "CopyFile2: error 0x%08x\n", hr);
+    ok(ret, "CopyFile2: error 0x%08lx\n", hr);
 
     /* copying from a read-locked source fails */
     hfile = CreateFileW(source, GENERIC_READ, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file, error %ld\n", GetLastError());
 
     params.dwSize = sizeof(params);
     params.dwCopyFlags = 0;
     SetLastError(0xdeadbeef);
     hr = pCopyFile2(source, dest, &params);
-    ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "CopyFile2: unexpected error 0x%08x\n", hr);
-    ok(GetLastError() == ERROR_SHARING_VIOLATION, "CopyFile2: last error %d\n", GetLastError());
+    ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "CopyFile2: unexpected error 0x%08lx\n", hr);
+    ok(GetLastError() == ERROR_SHARING_VIOLATION, "CopyFile2: last error %ld\n", GetLastError());
 
     /* in addition, the source is opened before the destination */
     params.dwSize = sizeof(params);
     params.dwCopyFlags = 0;
     SetLastError(0xdeadbeef);
     hr = pCopyFile2(doesntexistW, dest, &params);
-    ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr);
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "CopyFile2: last error %d\n", GetLastError());
+    ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08lx\n", hr);
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "CopyFile2: last error %ld\n", GetLastError());
     CloseHandle(hfile);
 
     /* copying from a r+w opened, r shared source succeeds */
     hfile = CreateFileW(source, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file, error %ld\n", GetLastError());
 
     params.dwSize = sizeof(params);
     params.dwCopyFlags = 0;
     hr = pCopyFile2(source, dest, &params);
-    ok(hr == S_OK, "failed 0x%08x\n", hr);
+    ok(hr == S_OK, "failed 0x%08lx\n", hr);
     CloseHandle(hfile);
 
     /* copying from a delete-locked source mostly succeeds */
     hfile = CreateFileW(source, DELETE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file, error %ld\n", GetLastError());
 
     params.dwSize = sizeof(params);
     params.dwCopyFlags = 0;
     hr = pCopyFile2(source, dest, &params);
-    ok(hr == S_OK, "failed 0x%08x\n", hr);
+    ok(hr == S_OK, "failed 0x%08lx\n", hr);
     CloseHandle(hfile);
 
     /* copying to a write-locked destination fails */
     hfile = CreateFileW(dest, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %ld\n", GetLastError());
 
     params.dwSize = sizeof(params);
     params.dwCopyFlags = 0;
     SetLastError(0xdeadbeef);
     hr = pCopyFile2(source, dest, FALSE);
-    ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "CopyFile2: unexpected error 0x%08x\n", hr);
-    ok(GetLastError() == ERROR_SHARING_VIOLATION, "CopyFile2: last error %d\n", GetLastError());
+    ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "CopyFile2: unexpected error 0x%08lx\n", hr);
+    ok(GetLastError() == ERROR_SHARING_VIOLATION, "CopyFile2: last error %ld\n", GetLastError());
     CloseHandle(hfile);
 
     /* copying to a r+w opened, w shared destination mostly succeeds */
     hfile = CreateFileW(dest, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %ld\n", GetLastError());
 
     params.dwSize = sizeof(params);
     params.dwCopyFlags = 0;
     hr = pCopyFile2(source, dest, FALSE);
-    ok(hr == S_OK, "got 0x%08x\n", hr);
+    ok(hr == S_OK, "got 0x%08lx\n", hr);
     CloseHandle(hfile);
 
     /* copying to a delete-locked destination fails, even when the destination is delete-shared */
     hfile = CreateFileW(dest, DELETE, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %ld\n", GetLastError());
 
     params.dwSize = sizeof(params);
     params.dwCopyFlags = 0;
     SetLastError(0xdeadbeef);
     hr = pCopyFile2(source, dest, &params);
-    ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "CopyFile2: unexpected error 0x%08x\n", hr);
-    ok(GetLastError() == ERROR_SHARING_VIOLATION, "CopyFile2: last error %d\n", GetLastError());
+    ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "CopyFile2: unexpected error 0x%08lx\n", hr);
+    ok(GetLastError() == ERROR_SHARING_VIOLATION, "CopyFile2: last error %ld\n", GetLastError());
     CloseHandle(hfile);
 
     /* copy to a file that's opened the way Wine opens the source */
     hfile = CreateFileW(dest, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %ld\n", GetLastError());
 
     params.dwSize = sizeof(params);
     params.dwCopyFlags = 0;
     hr = pCopyFile2(source, dest, &params);
-    ok(hr == S_OK, "got 0x%08x\n", hr);
+    ok(hr == S_OK, "got 0x%08lx\n", hr);
     CloseHandle(hfile);
 
     /* make sure that destination has correct size */
     hfile = CreateFileW(dest, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
     ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file\n");
     ret = GetFileSize(hfile, NULL);
-    ok(ret == sizeof(prefix), "destination file has wrong size %d\n", ret);
+    ok(ret == sizeof(prefix), "destination file has wrong size %ld\n", ret);
 
     /* make sure that destination has the same filetime */
     ret = GetFileTime(hfile, NULL, NULL, &ft2);
-    ok(ret, "GetFileTime error %d\n", GetLastError());
+    ok(ret, "GetFileTime error %ld\n", GetLastError());
     ok(CompareFileTime(&ft1, &ft2) == 0, "destination file has wrong filetime\n");
 
     params.dwSize = sizeof(params);
     params.dwCopyFlags = 0;
     SetLastError(0xdeadbeef);
     hr = pCopyFile2(source, dest, &params);
-    ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "CopyFile2: unexpected error 0x%08x\n", hr);
-    ok(GetLastError() == ERROR_SHARING_VIOLATION, "CopyFile2: last error %d\n", GetLastError());
+    ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "CopyFile2: unexpected error 0x%08lx\n", hr);
+    ok(GetLastError() == ERROR_SHARING_VIOLATION, "CopyFile2: last error %ld\n", GetLastError());
 
     /* make sure that destination still has correct size */
     ret = GetFileSize(hfile, NULL);
-    ok(ret == sizeof(prefix), "destination file has wrong size %d\n", ret);
+    ok(ret == sizeof(prefix), "destination file has wrong size %ld\n", ret);
     ret = ReadFile(hfile, buf, sizeof(buf), &len, NULL);
-    ok(ret && len == sizeof(prefix), "ReadFile: error %d\n", GetLastError());
+    ok(ret && len == sizeof(prefix), "ReadFile: error %ld\n", GetLastError());
     ok(!memcmp(prefix, buf, sizeof(prefix)), "buffer contents mismatch\n");
 
     /* check error on copying over a mapped file that was opened with FILE_SHARE_READ */
     hmapfile = CreateFileMappingW(hfile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL);
-    ok(hmapfile != NULL, "CreateFileMapping: error %d\n", GetLastError());
+    ok(hmapfile != NULL, "CreateFileMapping: error %ld\n", GetLastError());
 
     params.dwSize = sizeof(params);
     params.dwCopyFlags = 0;
     SetLastError(0xdeadbeef);
     hr = pCopyFile2(source, dest, &params);
-    ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "CopyFile2: unexpected error 0x%08x\n", hr);
-    ok(GetLastError() == ERROR_SHARING_VIOLATION, "CopyFile2: last error %d\n", GetLastError());
+    ok(hr == HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), "CopyFile2: unexpected error 0x%08lx\n", hr);
+    ok(GetLastError() == ERROR_SHARING_VIOLATION, "CopyFile2: last error %ld\n", GetLastError());
 
     CloseHandle(hmapfile);
     CloseHandle(hfile);
@@ -1122,13 +1122,13 @@ static void test_CopyFile2(void)
 
     /* check error on copying over a mapped file that was opened with FILE_SHARE_WRITE */
     hmapfile = CreateFileMappingW(hfile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL);
-    ok(hmapfile != NULL, "CreateFileMapping: error %d\n", GetLastError());
+    ok(hmapfile != NULL, "CreateFileMapping: error %ld\n", GetLastError());
 
     params.dwSize = sizeof(params);
     params.dwCopyFlags = 0;
     hr = pCopyFile2(source, dest, &params);
-    ok(hr == HRESULT_FROM_WIN32(ERROR_USER_MAPPED_FILE), "CopyFile2: unexpected error 0x%08x\n", hr);
-    ok(GetLastError() == ERROR_USER_MAPPED_FILE, "CopyFile2: last error %d\n", GetLastError());
+    ok(hr == HRESULT_FROM_WIN32(ERROR_USER_MAPPED_FILE), "CopyFile2: unexpected error 0x%08lx\n", hr);
+    ok(GetLastError() == ERROR_USER_MAPPED_FILE, "CopyFile2: last error %ld\n", GetLastError());
 
     CloseHandle(hmapfile);
     CloseHandle(hfile);
@@ -1141,7 +1141,7 @@ static DWORD WINAPI copy_progress_cb(LARGE_INTEGER total_size, LARGE_INTEGER tot
                                      LARGE_INTEGER stream_size, LARGE_INTEGER stream_transferred,
                                      DWORD stream, DWORD reason, HANDLE source, HANDLE dest, LPVOID userdata)
 {
-    ok(reason == CALLBACK_STREAM_SWITCH, "expected CALLBACK_STREAM_SWITCH, got %u\n", reason);
+    ok(reason == CALLBACK_STREAM_SWITCH, "expected CALLBACK_STREAM_SWITCH, got %lu\n", reason);
     CloseHandle(userdata);
     return PROGRESS_CANCEL;
 }
@@ -1156,47 +1156,47 @@ static void test_CopyFileEx(void)
     BOOL retok;
 
     ret = GetTempPathA(MAX_PATH, temp_path);
-    ok(ret != 0, "GetTempPathA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempPathA error %ld\n", GetLastError());
     ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
 
     ret = GetTempFileNameA(temp_path, prefix, 0, source);
-    ok(ret != 0, "GetTempFileNameA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
 
     ret = GetTempFileNameA(temp_path, prefix, 0, dest);
-    ok(ret != 0, "GetTempFileNameA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
 
     hfile = CreateFileA(dest, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     retok = CopyFileExA(source, dest, copy_progress_cb, hfile, NULL, 0);
     todo_wine
     ok(!retok, "CopyFileExA unexpectedly succeeded\n");
     todo_wine
-    ok(GetLastError() == ERROR_REQUEST_ABORTED, "expected ERROR_REQUEST_ABORTED, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_REQUEST_ABORTED, "expected ERROR_REQUEST_ABORTED, got %ld\n", GetLastError());
     ok(GetFileAttributesA(dest) != INVALID_FILE_ATTRIBUTES, "file was deleted\n");
 
     hfile = CreateFileA(dest, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_DELETE,
                         NULL, OPEN_EXISTING, 0, 0);
     todo_wine
-    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     retok = CopyFileExA(source, dest, copy_progress_cb, hfile, NULL, 0);
     todo_wine
     ok(!retok, "CopyFileExA unexpectedly succeeded\n");
     todo_wine
-    ok(GetLastError() == ERROR_REQUEST_ABORTED, "expected ERROR_REQUEST_ABORTED, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_REQUEST_ABORTED, "expected ERROR_REQUEST_ABORTED, got %ld\n", GetLastError());
     todo_wine
     ok(GetFileAttributesA(dest) == INVALID_FILE_ATTRIBUTES, "file was not deleted\n");
 
     retok = CopyFileExA(source, NULL, copy_progress_cb, hfile, NULL, 0);
     ok(!retok, "CopyFileExA unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_PATH_NOT_FOUND, "expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_PATH_NOT_FOUND, "expected ERROR_PATH_NOT_FOUND, got %ld\n", GetLastError());
     retok = CopyFileExA(NULL, dest, copy_progress_cb, hfile, NULL, 0);
     ok(!retok, "CopyFileExA unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_PATH_NOT_FOUND, "expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_PATH_NOT_FOUND, "expected ERROR_PATH_NOT_FOUND, got %ld\n", GetLastError());
 
     ret = DeleteFileA(source);
-    ok(ret, "DeleteFileA failed with error %d\n", GetLastError());
+    ok(ret, "DeleteFileA failed with error %ld\n", GetLastError());
     ret = DeleteFileA(dest);
     ok(!ret, "DeleteFileA unexpectedly succeeded\n");
 }
@@ -1256,11 +1256,11 @@ static void test_CreateFileA(void)
     WCHAR curdir[MAX_PATH];
 
     ret = GetTempPathA(MAX_PATH, temp_path);
-    ok(ret != 0, "GetTempPathA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempPathA error %ld\n", GetLastError());
     ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
 
     ret = GetTempFileNameA(temp_path, prefix, 0, filename);
-    ok(ret != 0, "GetTempFileNameA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     hFile = CreateFileA(filename, GENERIC_READ, 0, NULL,
@@ -1272,7 +1272,7 @@ static void test_CreateFileA(void)
     hFile = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
                         CREATE_ALWAYS, FILE_FLAG_RANDOM_ACCESS, 0);
     ok(hFile != INVALID_HANDLE_VALUE && GetLastError() == ERROR_ALREADY_EXISTS,
-       "hFile %p, last error %u\n", hFile, GetLastError());
+       "hFile %p, last error %lu\n", hFile, GetLastError());
 
     CloseHandle(hFile);
 
@@ -1280,43 +1280,43 @@ static void test_CreateFileA(void)
     hFile = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
                         OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, 0);
     ok(hFile != INVALID_HANDLE_VALUE && GetLastError() == ERROR_ALREADY_EXISTS,
-       "hFile %p, last error %u\n", hFile, GetLastError());
+       "hFile %p, last error %lu\n", hFile, GetLastError());
 
     CloseHandle(hFile);
 
     ret = DeleteFileA(filename);
-    ok(ret, "DeleteFileA: error %d\n", GetLastError());
+    ok(ret, "DeleteFileA: error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     hFile = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
                         OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, 0);
     ok(hFile != INVALID_HANDLE_VALUE && GetLastError() == 0,
-       "hFile %p, last error %u\n", hFile, GetLastError());
+       "hFile %p, last error %lu\n", hFile, GetLastError());
 
     CloseHandle(hFile);
 
     ret = DeleteFileA(filename);
-    ok(ret, "DeleteFileA: error %d\n", GetLastError());
+    ok(ret, "DeleteFileA: error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     hFile = CreateFileA("c:\\*.*", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
     ok(hFile == INVALID_HANDLE_VALUE, "hFile should have been INVALID_HANDLE_VALUE\n");
     ok(GetLastError() == ERROR_INVALID_NAME ||
         broken(GetLastError() == ERROR_FILE_NOT_FOUND), /* Win98 */
-        "LastError should have been ERROR_INVALID_NAME or ERROR_FILE_NOT_FOUND but got %u\n", GetLastError());
+        "LastError should have been ERROR_INVALID_NAME or ERROR_FILE_NOT_FOUND but got %lu\n", GetLastError());
 
     /* get windows drive letter */
     ret = GetWindowsDirectoryA(windowsdir, sizeof(windowsdir));
     ok(ret < sizeof(windowsdir), "windowsdir is abnormally long!\n");
-    ok(ret != 0, "GetWindowsDirectory: error %d\n", GetLastError());
+    ok(ret != 0, "GetWindowsDirectory: error %ld\n", GetLastError());
 
     /* test error return codes from CreateFile for some cases */
     ret = GetTempPathA(MAX_PATH, temp_path);
-    ok(ret != 0, "GetTempPathA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempPathA error %ld\n", GetLastError());
     strcpy(dirname, temp_path);
     strcat(dirname, directory);
     ret = CreateDirectoryA(dirname, NULL);
-    ok( ret, "Createdirectory failed, gle=%d\n", GetLastError() );
+    ok( ret, "Createdirectory failed, gle=%ld\n", GetLastError() );
     /* set current drive & directory to known location */
     GetCurrentDirectoryW( MAX_PATH, curdir);
     SetCurrentDirectoryA( temp_path );
@@ -1353,7 +1353,7 @@ static void test_CreateFileA(void)
             p[i].err != ERROR_ACCESS_DENIED)
         {
             if (p[i].todo_flag)
-                skip("Either no authority to volume, or is todo_wine for %s err=%d should be %d\n", filename, GetLastError(), p[i].err);
+                skip("Either no authority to volume, or is todo_wine for %s err=%ld should be %ld\n", filename, GetLastError(), p[i].err);
             else
                 skip("Do not have authority to access volumes. Test for %s skipped\n", filename);
         }
@@ -1364,7 +1364,7 @@ static void test_CreateFileA(void)
                 ok((hFile == INVALID_HANDLE_VALUE &&
                    (p[i].err == GetLastError() || p[i].err2 == GetLastError())) ||
                    (hFile != INVALID_HANDLE_VALUE && p[i].err == ERROR_SUCCESS),
-                "CreateFileA failed on %s, hFile %p, err=%u, should be %u\n",
+                "CreateFileA failed on %s, hFile %p, err=%lu, should be %lu\n",
                 filename, hFile, GetLastError(), p[i].err);
         }
         if (hFile != INVALID_HANDLE_VALUE)
@@ -1372,7 +1372,7 @@ static void test_CreateFileA(void)
         i++;
     }
     ret = RemoveDirectoryA(dirname);
-    ok(ret, "RemoveDirectoryA: error %d\n", GetLastError());
+    ok(ret, "RemoveDirectoryA: error %ld\n", GetLastError());
     SetCurrentDirectoryW(curdir);
 
     /* test opening directory as a directory */
@@ -1384,7 +1384,7 @@ static void test_CreateFileA(void)
     if (hFile != INVALID_HANDLE_VALUE && GetLastError() != ERROR_PATH_NOT_FOUND)
     {
         ok(hFile != INVALID_HANDLE_VALUE && GetLastError() == ERROR_SUCCESS,
-            "CreateFileA did not work, last error %u on volume <%s>\n",
+            "CreateFileA did not work, last error %lu on volume <%s>\n",
              GetLastError(), temp_path );
 
         if (hFile != INVALID_HANDLE_VALUE)
@@ -1393,7 +1393,7 @@ static void test_CreateFileA(void)
             if (ret)
             {
                 ok(Finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY,
-                    "CreateFileA probably did not open temp directory %s correctly\n   file information does not include FILE_ATTRIBUTE_DIRECTORY, actual=0x%08x\n",
+                    "CreateFileA probably did not open temp directory %s correctly\n   file information does not include FILE_ATTRIBUTE_DIRECTORY, actual=0x%08lx\n",
                 temp_path, Finfo.dwFileAttributes);
             }
             CloseHandle( hFile );
@@ -1417,7 +1417,7 @@ static void test_CreateFileA(void)
         (GetLastError() != ERROR_ACCESS_DENIED && GetLastError() != ERROR_BAD_NETPATH))
     {
         /* if we have adm rights to volume, then try rest of tests */
-        ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA did not open %s, last error=%u\n",
+        ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA did not open %s, last error=%lu\n",
             filename, GetLastError());
         if (hFile != INVALID_HANDLE_VALUE)
         {
@@ -1426,7 +1426,7 @@ static void test_CreateFileA(void)
             /* what the data is at this time.                            */
             len = 512;
             ret = ReadFile( hFile, buffer, len, &len, NULL );
-            todo_wine ok(ret, "Failed to read volume, last error %u, %u, for %s\n",
+            todo_wine ok(ret, "Failed to read volume, last error %lu, %lu, for %s\n",
                 GetLastError(), ret, filename);
             if (ret)
             {
@@ -1447,7 +1447,7 @@ static void test_CreateFileA(void)
                         FILE_ATTRIBUTE_NORMAL | FILE_FLAG_NO_BUFFERING, NULL );
         todo_wine
         ok(hFile == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PATH_NOT_FOUND,
-            "CreateFileA should have returned ERROR_PATH_NOT_FOUND on %s, but got %u\n",
+            "CreateFileA should have returned ERROR_PATH_NOT_FOUND on %s, but got %lu\n",
             filename, GetLastError());
         if (hFile != INVALID_HANDLE_VALUE)
             CloseHandle( hFile );
@@ -1462,7 +1462,7 @@ static void test_CreateFileA(void)
                         NULL, OPEN_EXISTING,
                         FILE_FLAG_BACKUP_SEMANTICS, NULL );
         ok(hFile != INVALID_HANDLE_VALUE,
-            "CreateFileA should have worked on %s, but got %u\n",
+            "CreateFileA should have worked on %s, but got %lu\n",
             filename, GetLastError());
         if (hFile != INVALID_HANDLE_VALUE)
             CloseHandle( hFile );
@@ -1476,7 +1476,7 @@ static void test_CreateFileA(void)
                         FILE_SHARE_READ | FILE_SHARE_WRITE,
                         NULL, OPEN_EXISTING,
                         FILE_ATTRIBUTE_NORMAL | FILE_FLAG_NO_BUFFERING, NULL );
-        ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA did not open %s, last error=%u\n",
+        ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA did not open %s, last error=%lu\n",
             filename, GetLastError());
         if (hFile != INVALID_HANDLE_VALUE)
             CloseHandle( hFile );
@@ -1495,7 +1495,7 @@ static void test_CreateFileA(void)
         strcpy(filename, "c:\\");
         filename[0] = windowsdir[0];
         ret = pGetVolumeNameForVolumeMountPointA( filename, Volume_1, MAX_PATH );
-        ok(ret, "GetVolumeNameForVolumeMountPointA failed, for %s, last error=%d\n", filename, GetLastError());
+        ok(ret, "GetVolumeNameForVolumeMountPointA failed, for %s, last error=%ld\n", filename, GetLastError());
         if (ret)
         {
             ok(strlen(Volume_1) == 49, "GetVolumeNameForVolumeMountPointA returned wrong length name <%s>\n", Volume_1);
@@ -1515,7 +1515,7 @@ static void test_CreateFileA(void)
                 filename, hFile);
             todo_wine
             ok(hFile == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PATH_NOT_FOUND,
-                "CreateFileA should have returned ERROR_PATH_NOT_FOUND on %s, but got %u\n",
+                "CreateFileA should have returned ERROR_PATH_NOT_FOUND on %s, but got %lu\n",
                 filename, GetLastError());
             if (hFile != INVALID_HANDLE_VALUE)
                 CloseHandle( hFile );
@@ -1532,7 +1532,7 @@ static void test_CreateFileA(void)
                         FILE_FLAG_BACKUP_SEMANTICS, NULL );
             todo_wine
             ok(hFile != INVALID_HANDLE_VALUE,
-                "CreateFileA should have opened %s, but got %u\n",
+                "CreateFileA should have opened %s, but got %lu\n",
                 filename, GetLastError());
             if (hFile != INVALID_HANDLE_VALUE)
                 CloseHandle( hFile );
@@ -1551,7 +1551,7 @@ static void test_CreateFileA(void)
             if (hFile != INVALID_HANDLE_VALUE || GetLastError() != ERROR_ACCESS_DENIED)
             {
                 /* if we have adm rights to volume, then try rest of tests */
-                ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA did not open %s, last error=%u\n",
+                ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA did not open %s, last error=%lu\n",
                     filename, GetLastError());
                 if (hFile != INVALID_HANDLE_VALUE)
                 {
@@ -1560,7 +1560,7 @@ static void test_CreateFileA(void)
                     /* what the data is at this time.                            */
                     len = 512;
                     ret = ReadFile( hFile, buffer, len, &len, NULL );
-                    todo_wine ok(ret, "Failed to read volume, last error %u, %u, for %s\n",
+                    todo_wine ok(ret, "Failed to read volume, last error %lu, %lu, for %s\n",
                         GetLastError(), ret, filename);
                     if (ret)
                     {
@@ -1596,11 +1596,11 @@ static void test_CreateFileW(void)
         win_skip("GetTempPathW is not available\n");
         return;
     }
-    ok(ret != 0, "GetTempPathW error %d\n", GetLastError());
+    ok(ret != 0, "GetTempPathW error %ld\n", GetLastError());
     ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
 
     ret = GetTempFileNameW(temp_path, prefix, 0, filename);
-    ok(ret != 0, "GetTempFileNameW error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameW error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     hFile = CreateFileW(filename, GENERIC_READ, 0, NULL,
@@ -1612,7 +1612,7 @@ static void test_CreateFileW(void)
     hFile = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
                         CREATE_ALWAYS, FILE_FLAG_RANDOM_ACCESS, 0);
     ok(hFile != INVALID_HANDLE_VALUE && GetLastError() == ERROR_ALREADY_EXISTS,
-       "hFile %p, last error %u\n", hFile, GetLastError());
+       "hFile %p, last error %lu\n", hFile, GetLastError());
 
     CloseHandle(hFile);
 
@@ -1620,23 +1620,23 @@ static void test_CreateFileW(void)
     hFile = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
                         OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, 0);
     ok(hFile != INVALID_HANDLE_VALUE && GetLastError() == ERROR_ALREADY_EXISTS,
-       "hFile %p, last error %u\n", hFile, GetLastError());
+       "hFile %p, last error %lu\n", hFile, GetLastError());
 
     CloseHandle(hFile);
 
     ret = DeleteFileW(filename);
-    ok(ret, "DeleteFileW: error %d\n", GetLastError());
+    ok(ret, "DeleteFileW: error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     hFile = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
                         OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, 0);
     ok(hFile != INVALID_HANDLE_VALUE && GetLastError() == 0,
-       "hFile %p, last error %u\n", hFile, GetLastError());
+       "hFile %p, last error %lu\n", hFile, GetLastError());
 
     CloseHandle(hFile);
 
     ret = DeleteFileW(filename);
-    ok(ret, "DeleteFileW: error %d\n", GetLastError());
+    ok(ret, "DeleteFileW: error %ld\n", GetLastError());
 
     if (0)
     {
@@ -1644,29 +1644,29 @@ static void test_CreateFileW(void)
         hFile = CreateFileW(NULL, GENERIC_READ, 0, NULL,
                             CREATE_NEW, FILE_FLAG_RANDOM_ACCESS, 0);
         ok(hFile == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PATH_NOT_FOUND,
-           "CreateFileW(NULL) returned ret=%p error=%u\n",hFile,GetLastError());
+           "CreateFileW(NULL) returned ret=%p error=%lu\n",hFile,GetLastError());
     }
 
     hFile = CreateFileW(emptyW, GENERIC_READ, 0, NULL,
                         CREATE_NEW, FILE_FLAG_RANDOM_ACCESS, 0);
     ok(hFile == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PATH_NOT_FOUND,
-       "CreateFileW(\"\") returned ret=%p error=%d\n",hFile,GetLastError());
+       "CreateFileW(\"\") returned ret=%p error=%ld\n",hFile,GetLastError());
 
     /* test the result of opening a nonexistent driver name */
     hFile = CreateFileW(bogus, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
                         OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
     ok(hFile == INVALID_HANDLE_VALUE && GetLastError() == ERROR_FILE_NOT_FOUND,
-       "CreateFileW on invalid VxD name returned ret=%p error=%d\n",hFile,GetLastError());
+       "CreateFileW on invalid VxD name returned ret=%p error=%ld\n",hFile,GetLastError());
 
     ret = CreateDirectoryW(filename, NULL);
     ok(ret == TRUE, "couldn't create temporary directory\n");
     hFile = CreateFileW(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
 			OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL);
     ok(hFile != INVALID_HANDLE_VALUE,
-       "expected CreateFile to succeed on existing directory, error: %d\n", GetLastError());
+       "expected CreateFile to succeed on existing directory, error: %ld\n", GetLastError());
     CloseHandle(hFile);
     ret = RemoveDirectoryW(filename);
-    ok(ret, "DeleteFileW: error %d\n", GetLastError());
+    ok(ret, "DeleteFileW: error %ld\n", GetLastError());
 }
 
 static void test_CreateFile2(void)
@@ -1687,11 +1687,11 @@ static void test_CreateFile2(void)
     }
 
     ret = GetTempPathW(MAX_PATH, temp_path);
-    ok(ret != 0, "GetTempPathW error %d\n", GetLastError());
+    ok(ret != 0, "GetTempPathW error %ld\n", GetLastError());
     ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
 
     ret = GetTempFileNameW(temp_path, prefix, 0, filename);
-    ok(ret != 0, "GetTempFileNameW error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameW error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     exparams.dwSize = sizeof(exparams);
@@ -1707,36 +1707,36 @@ static void test_CreateFile2(void)
     SetLastError(0xdeadbeef);
     hFile = pCreateFile2(filename, GENERIC_READ, FILE_SHARE_READ, CREATE_ALWAYS, &exparams);
     ok(hFile != INVALID_HANDLE_VALUE && GetLastError() == ERROR_ALREADY_EXISTS,
-       "hFile %p, last error %u\n", hFile, GetLastError());
+       "hFile %p, last error %lu\n", hFile, GetLastError());
     CloseHandle(hFile);
 
     SetLastError(0xdeadbeef);
     hFile = pCreateFile2(filename, GENERIC_READ, FILE_SHARE_READ, OPEN_ALWAYS, &exparams);
     ok(hFile != INVALID_HANDLE_VALUE && GetLastError() == ERROR_ALREADY_EXISTS,
-       "hFile %p, last error %u\n", hFile, GetLastError());
+       "hFile %p, last error %lu\n", hFile, GetLastError());
     CloseHandle(hFile);
 
     ret = DeleteFileW(filename);
-    ok(ret, "DeleteFileW: error %d\n", GetLastError());
+    ok(ret, "DeleteFileW: error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     hFile = pCreateFile2(filename, GENERIC_READ, FILE_SHARE_READ, OPEN_ALWAYS, &exparams);
     ok(hFile != INVALID_HANDLE_VALUE && GetLastError() == 0,
-       "hFile %p, last error %u\n", hFile, GetLastError());
+       "hFile %p, last error %lu\n", hFile, GetLastError());
     CloseHandle(hFile);
 
     ret = DeleteFileW(filename);
-    ok(ret, "DeleteFileW: error %d\n", GetLastError());
+    ok(ret, "DeleteFileW: error %ld\n", GetLastError());
 
     hFile = pCreateFile2(emptyW, GENERIC_READ, 0, CREATE_NEW, &exparams);
     ok(hFile == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PATH_NOT_FOUND,
-       "CreateFile2(\"\") returned ret=%p error=%d\n",hFile,GetLastError());
+       "CreateFile2(\"\") returned ret=%p error=%ld\n",hFile,GetLastError());
 
     /* test the result of opening a nonexistent driver name */
     exparams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
     hFile = pCreateFile2(bogus, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING, &exparams);
     ok(hFile == INVALID_HANDLE_VALUE && GetLastError() == ERROR_FILE_NOT_FOUND,
-       "CreateFile2 on invalid VxD name returned ret=%p error=%d\n",hFile,GetLastError());
+       "CreateFile2 on invalid VxD name returned ret=%p error=%ld\n",hFile,GetLastError());
 
     ret = CreateDirectoryW(filename, NULL);
     ok(ret == TRUE, "couldn't create temporary directory\n");
@@ -1745,10 +1745,10 @@ static void test_CreateFile2(void)
     SetLastError(0xdeadbeef);
     hFile = pCreateFile2(filename, GENERIC_READ | GENERIC_WRITE, 0, OPEN_ALWAYS, &exparams);
     ok(hFile != INVALID_HANDLE_VALUE,
-       "CreateFile2 failed with FILE_FLAG_BACKUP_SEMANTICS on existing directory, error: %d\n", GetLastError());
+       "CreateFile2 failed with FILE_FLAG_BACKUP_SEMANTICS on existing directory, error: %ld\n", GetLastError());
     CloseHandle(hFile);
     ret = RemoveDirectoryW(filename);
-    ok(ret, "DeleteFileW: error %d\n", GetLastError());
+    ok(ret, "DeleteFileW: error %ld\n", GetLastError());
 
     for (i = 0; i < 2; ++i)
     {
@@ -1767,18 +1767,18 @@ static void test_CreateFile2(void)
 
         SetLastError(0xdeadbeef);
         hFile = pCreateFile2(filename, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, CREATE_ALWAYS, &exparams);
-        ok(hFile != INVALID_HANDLE_VALUE && GetLastError() == 0, "%d: hFile %p, last error %u\n", i, hFile, GetLastError());
+        ok(hFile != INVALID_HANDLE_VALUE && GetLastError() == 0, "%ld: hFile %p, last error %lu\n", i, hFile, GetLastError());
 
         iocp = CreateIoCompletionPort(hFile, NULL, 0, 2);
-        if (i == 1) ok(iocp == NULL && GetLastError() == ERROR_INVALID_PARAMETER, "%d: CreateIoCompletionPort returned %p, error %u\n", i, iocp, GetLastError());
-        else ok(iocp != INVALID_HANDLE_VALUE && GetLastError() == 0, "%d: CreateIoCompletionPort returned %p, error %u\n", i, iocp, GetLastError());
+        if (i == 1) ok(iocp == NULL && GetLastError() == ERROR_INVALID_PARAMETER, "%ld: CreateIoCompletionPort returned %p, error %lu\n", i, iocp, GetLastError());
+        else ok(iocp != INVALID_HANDLE_VALUE && GetLastError() == 0, "%ld: CreateIoCompletionPort returned %p, error %lu\n", i, iocp, GetLastError());
 
         CloseHandle(iocp);
         CloseHandle(hFile);
 
         ret = DeleteFileW(filename);
-        if (i == 1) ok(ret, "%d: unexpected DeleteFileW failure, error %u\n", i, GetLastError());
-        else ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "%d: unexpected DeleteFileW result, ret %d error %u\n", i, ret, GetLastError());
+        if (i == 1) ok(ret, "%ld: unexpected DeleteFileW failure, error %lu\n", i, GetLastError());
+        else ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "%ld: unexpected DeleteFileW result, ret %ld error %lu\n", i, ret, GetLastError());
     }
 }
 
@@ -1792,7 +1792,7 @@ static void test_GetTempFileNameA(void)
 
     result = GetWindowsDirectoryA(windowsdir, sizeof(windowsdir));
     ok(result < sizeof(windowsdir), "windowsdir is abnormally long!\n");
-    ok(result != 0, "GetWindowsDirectory: error %d\n", GetLastError());
+    ok(result != 0, "GetWindowsDirectory: error %ld\n", GetLastError());
 
     /* If the Windows directory is the root directory, it ends in backslash, not else. */
     if (strlen(windowsdir) != 3) /* As in  "C:\"  or  "F:\"  */
@@ -1805,13 +1805,13 @@ static void test_GetTempFileNameA(void)
     windowsdrive[2] = '\0';
 
     result = GetTempFileNameA(windowsdrive, "abc", 1, out);
-    ok(result != 0, "GetTempFileNameA: error %d\n", GetLastError());
+    ok(result != 0, "GetTempFileNameA: error %ld\n", GetLastError());
     ok(((out[0] == windowsdrive[0]) && (out[1] == ':')) && (out[2] == '\\'),
        "GetTempFileNameA: first three characters should be %c:\\, string was actually %s\n",
        windowsdrive[0], out);
 
     result = GetTempFileNameA(windowsdir, "abc", 2, out);
-    ok(result != 0, "GetTempFileNameA: error %d\n", GetLastError());
+    ok(result != 0, "GetTempFileNameA: error %ld\n", GetLastError());
     expected[0] = '\0';
     strcat(expected, windowsdir);
     strcat(expected, "abc2.tmp");
@@ -1829,68 +1829,68 @@ static void test_DeleteFileA( void )
     ret = DeleteFileA(NULL);
     ok(!ret && (GetLastError() == ERROR_INVALID_PARAMETER ||
                 GetLastError() == ERROR_PATH_NOT_FOUND),
-       "DeleteFileA(NULL) returned ret=%d error=%d\n",ret,GetLastError());
+       "DeleteFileA(NULL) returned ret=%d error=%ld\n",ret,GetLastError());
 
     ret = DeleteFileA("");
     ok(!ret && (GetLastError() == ERROR_PATH_NOT_FOUND ||
                 GetLastError() == ERROR_BAD_PATHNAME),
-       "DeleteFileA(\"\") returned ret=%d error=%d\n",ret,GetLastError());
+       "DeleteFileA(\"\") returned ret=%d error=%ld\n",ret,GetLastError());
 
     ret = DeleteFileA("nul");
     ok(!ret && (GetLastError() == ERROR_FILE_NOT_FOUND ||
                 GetLastError() == ERROR_INVALID_PARAMETER ||
                 GetLastError() == ERROR_ACCESS_DENIED ||
                 GetLastError() == ERROR_INVALID_FUNCTION),
-       "DeleteFileA(\"nul\") returned ret=%d error=%d\n",ret,GetLastError());
+       "DeleteFileA(\"nul\") returned ret=%d error=%ld\n",ret,GetLastError());
 
     ret = DeleteFileA("nonexist.txt");
-    ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "DeleteFileA(\"nonexist.txt\") returned ret=%d error=%d\n",ret,GetLastError());
+    ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "DeleteFileA(\"nonexist.txt\") returned ret=%d error=%ld\n",ret,GetLastError());
 
     GetTempPathA(MAX_PATH, temp_path);
     GetTempFileNameA(temp_path, "tst", 0, temp_file);
 
     SetLastError(0xdeadbeef);
     hfile = CreateFileA(temp_file, GENERIC_READ, FILE_SHARE_DELETE | FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = DeleteFileA(temp_file);
-    ok(ret, "DeleteFile error %d\n", GetLastError());
+    ok(ret, "DeleteFile error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = CloseHandle(hfile);
-    ok(ret, "CloseHandle error %d\n", GetLastError());
+    ok(ret, "CloseHandle error %ld\n", GetLastError());
     ret = DeleteFileA(temp_file);
     ok(!ret, "DeleteFile should fail\n");
 
     SetLastError(0xdeadbeef);
     ret = CreateDirectoryA("testdir", NULL);
-    ok(ret, "CreateDirectory failed, got err %d\n", GetLastError());
+    ok(ret, "CreateDirectory failed, got err %ld\n", GetLastError());
     ret = DeleteFileA("testdir");
     ok(!ret && GetLastError() == ERROR_ACCESS_DENIED,
-        "Expected ERROR_ACCESS_DENIED, got error %d\n", GetLastError());
+        "Expected ERROR_ACCESS_DENIED, got error %ld\n", GetLastError());
     ret = RemoveDirectoryA("testdir");
-    ok(ret, "Remove a directory failed, got error %d\n", GetLastError());
+    ok(ret, "Remove a directory failed, got error %ld\n", GetLastError());
 
     winetest_get_mainargs(&argv);
 
     ret = CopyFileA(argv[0], temp_file, FALSE);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     hfile = CreateFileA(temp_file, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError());
 
     mapping = CreateFileMappingA(hfile, NULL, PAGE_READONLY | SEC_IMAGE, 0, 0, NULL);
-    ok(!!mapping, "got error %u\n", GetLastError());
+    ok(!!mapping, "got error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = DeleteFileA(temp_file);
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "got error %lu\n", GetLastError());
 
     CloseHandle(mapping);
 
     ret = DeleteFileA(temp_file);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     CloseHandle(hfile);
 }
@@ -1911,11 +1911,11 @@ static void test_DeleteFileW( void )
         return;
     }
     ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND,
-       "DeleteFileW(NULL) returned ret=%d error=%d\n",ret,GetLastError());
+       "DeleteFileW(NULL) returned ret=%d error=%ld\n",ret,GetLastError());
 
     ret = DeleteFileW(emptyW);
     ok(!ret && GetLastError() == ERROR_PATH_NOT_FOUND,
-       "DeleteFileW(\"\") returned ret=%d error=%d\n",ret,GetLastError());
+       "DeleteFileW(\"\") returned ret=%d error=%ld\n",ret,GetLastError());
 
     /* test DeleteFile on empty directory */
     ret = GetTempPathW(MAX_PATH, pathW);
@@ -1961,40 +1961,40 @@ static void test_MoveFileA(void)
     BOOL retok;
 
     ret = GetTempPathA(MAX_PATH, tempdir);
-    ok(ret != 0, "GetTempPathA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempPathA error %ld\n", GetLastError());
     ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
 
     ret = GetTempFileNameA(tempdir, prefix, 0, source);
-    ok(ret != 0, "GetTempFileNameA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
 
     ret = GetTempFileNameA(tempdir, prefix, 0, dest);
-    ok(ret != 0, "GetTempFileNameA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
 
     ret = MoveFileA(source, source);
-    ok(ret, "MoveFileA: failed, error %d\n", GetLastError());
+    ok(ret, "MoveFileA: failed, error %ld\n", GetLastError());
 
     ret = MoveFileA(source, dest);
     ok(!ret && GetLastError() == ERROR_ALREADY_EXISTS,
-       "MoveFileA: unexpected error %d\n", GetLastError());
+       "MoveFileA: unexpected error %ld\n", GetLastError());
 
     ret = DeleteFileA(dest);
-    ok(ret, "DeleteFileA: error %d\n", GetLastError());
+    ok(ret, "DeleteFileA: error %ld\n", GetLastError());
 
     hfile = CreateFileA(source, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
     ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file\n");
 
     retok = WriteFile(hfile, prefix, sizeof(prefix), &ret, NULL );
     ok( retok && ret == sizeof(prefix),
-       "WriteFile error %d\n", GetLastError());
+       "WriteFile error %ld\n", GetLastError());
 
     hmapfile = CreateFileMappingW(hfile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL);
-    ok(hmapfile != NULL, "CreateFileMapping: error %d\n", GetLastError());
+    ok(hmapfile != NULL, "CreateFileMapping: error %ld\n", GetLastError());
 
     ret = MoveFileA(source, dest);
     ok(!ret, "MoveFileA: expected failure\n");
     ok(GetLastError() == ERROR_SHARING_VIOLATION ||
        broken(GetLastError() == ERROR_ACCESS_DENIED), /* Win9x and WinMe */
-       "MoveFileA: expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
+       "MoveFileA: expected ERROR_SHARING_VIOLATION, got %ld\n", GetLastError());
 
     CloseHandle(hmapfile);
     CloseHandle(hfile);
@@ -2006,13 +2006,13 @@ static void test_MoveFileA(void)
     ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file\n");
 
     hmapfile = CreateFileMappingW(hfile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL);
-    ok(hmapfile != NULL, "CreateFileMapping: error %d\n", GetLastError());
+    ok(hmapfile != NULL, "CreateFileMapping: error %ld\n", GetLastError());
 
     ret = MoveFileA(source, dest);
     ok(!ret, "MoveFileA: expected failure\n");
     ok(GetLastError() == ERROR_SHARING_VIOLATION ||
        broken(GetLastError() == ERROR_ACCESS_DENIED), /* Win9x and WinMe */
-       "MoveFileA: expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
+       "MoveFileA: expected ERROR_SHARING_VIOLATION, got %ld\n", GetLastError());
 
     CloseHandle(hmapfile);
     CloseHandle(hfile);
@@ -2021,7 +2021,7 @@ static void test_MoveFileA(void)
     if (ret) MoveFileA(dest, source);
 
     ret = MoveFileA(source, dest);
-    ok(ret, "MoveFileA: failed, error %d\n", GetLastError());
+    ok(ret, "MoveFileA: failed, error %ld\n", GetLastError());
 
     lstrcatA(tempdir, "Remove Me");
 
@@ -2034,10 +2034,10 @@ static void test_MoveFileA(void)
     CloseHandle(hfile);
 
     ret = MoveFileA(source, tempdir);
-    ok(ret, "MoveFileA: failed, error %d\n", GetLastError());
+    ok(ret, "MoveFileA: failed, error %ld\n", GetLastError());
 
     hfile = FindFirstFileA(tempdir, &find_data);
-    ok(hfile != INVALID_HANDLE_VALUE, "FindFirstFileA: failed, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "FindFirstFileA: failed, error %ld\n", GetLastError());
     if (hfile != INVALID_HANDLE_VALUE)
     {
         todo_wine ok(!lstrcmpA(strrchr(tempdir, '\\') + 1, find_data.cFileName),
@@ -2054,14 +2054,14 @@ static void test_MoveFileA(void)
 
     ret = MoveFileA(tempdir, source);
     ok(!ret, "MoveFileA: expected failure\n");
-    ok(GetLastError() == ERROR_ALREADY_EXISTS, "MoveFileA: expected ERROR_ALREADY_EXISTS, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_ALREADY_EXISTS, "MoveFileA: expected ERROR_ALREADY_EXISTS, got %ld\n", GetLastError());
     ret = MoveFileExA(tempdir, source, MOVEFILE_REPLACE_EXISTING);
-    ok(ret, "MoveFileExA: failed, error %d\n", GetLastError());
+    ok(ret, "MoveFileExA: failed, error %ld\n", GetLastError());
 
     tempdir[lstrlenA(tempdir) - 2] = 'm';
 
     hfile = FindFirstFileA(tempdir, &find_data);
-    ok(hfile != INVALID_HANDLE_VALUE, "FindFirstFileA: failed, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "FindFirstFileA: failed, error %ld\n", GetLastError());
     if (hfile != INVALID_HANDLE_VALUE)
     {
         ok(!lstrcmpA(strrchr(source, '\\') + 1, find_data.cFileName),
@@ -2070,7 +2070,7 @@ static void test_MoveFileA(void)
     CloseHandle(hfile);
 
     ret = DeleteFileA(tempdir);
-    ok(ret, "DeleteFileA: error %d\n", GetLastError());
+    ok(ret, "DeleteFileA: error %ld\n", GetLastError());
 
     /* now test a directory from "Remove me" to uppercase "Me" */
     ret = CreateDirectoryA(tempdir, NULL);
@@ -2079,10 +2079,10 @@ static void test_MoveFileA(void)
     lstrcpyA(source, tempdir);
     tempdir[lstrlenA(tempdir) - 2] = 'M';
     ret = MoveFileA(source, tempdir);
-    ok(ret, "MoveFileA: failed, error %d\n", GetLastError());
+    ok(ret, "MoveFileA: failed, error %ld\n", GetLastError());
 
     hfile = FindFirstFileA(tempdir, &find_data);
-    ok(hfile != INVALID_HANDLE_VALUE, "FindFirstFileA: failed, error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "FindFirstFileA: failed, error %ld\n", GetLastError());
     if (hfile != INVALID_HANDLE_VALUE)
     {
         todo_wine ok(!lstrcmpA(strrchr(tempdir, '\\') + 1, find_data.cFileName),
@@ -2098,7 +2098,7 @@ static void test_MoveFileA(void)
     ok(!ret, "MoveFileA: shouldn't move to wildcard file\n");
     ok(GetLastError() == ERROR_INVALID_NAME || /* NT */
        GetLastError() == ERROR_FILE_NOT_FOUND, /* Win9x */
-       "MoveFileA: with wildcards, unexpected error %d\n", GetLastError());
+       "MoveFileA: with wildcards, unexpected error %ld\n", GetLastError());
     if (ret || (GetLastError() != ERROR_INVALID_NAME))
     {
         WIN32_FIND_DATAA fd;
@@ -2123,11 +2123,11 @@ static void test_MoveFileA(void)
         }
     }
     ret = DeleteFileA(source);
-    ok(ret, "DeleteFileA: error %d\n", GetLastError());
+    ok(ret, "DeleteFileA: error %ld\n", GetLastError());
     ret = DeleteFileA(dest);
-    ok(!ret, "DeleteFileA: error %d\n", GetLastError());
+    ok(!ret, "DeleteFileA: error %ld\n", GetLastError());
     ret = RemoveDirectoryA(tempdir);
-    ok(ret, "DeleteDirectoryA: error %d\n", GetLastError());
+    ok(ret, "DeleteDirectoryA: error %ld\n", GetLastError());
 }
 
 static void test_MoveFileW(void)
@@ -2143,23 +2143,23 @@ static void test_MoveFileW(void)
         win_skip("GetTempPathW is not available\n");
         return;
     }
-    ok(ret != 0, "GetTempPathW error %d\n", GetLastError());
+    ok(ret != 0, "GetTempPathW error %ld\n", GetLastError());
     ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
 
     ret = GetTempFileNameW(temp_path, prefix, 0, source);
-    ok(ret != 0, "GetTempFileNameW error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameW error %ld\n", GetLastError());
 
     ret = GetTempFileNameW(temp_path, prefix, 0, dest);
-    ok(ret != 0, "GetTempFileNameW error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameW error %ld\n", GetLastError());
 
     ret = MoveFileW(source, dest);
     ok(!ret && GetLastError() == ERROR_ALREADY_EXISTS,
-       "CopyFileW: unexpected error %d\n", GetLastError());
+       "CopyFileW: unexpected error %ld\n", GetLastError());
 
     ret = DeleteFileW(source);
-    ok(ret, "DeleteFileW: error %d\n", GetLastError());
+    ok(ret, "DeleteFileW: error %ld\n", GetLastError());
     ret = DeleteFileW(dest);
-    ok(ret, "DeleteFileW: error %d\n", GetLastError());
+    ok(ret, "DeleteFileW: error %ld\n", GetLastError());
 }
 
 #define PATTERN_OFFSET 0x10
@@ -2176,19 +2176,19 @@ static void test_offset_in_overlapped_structure(void)
     BOOL ret;
 
     ret =GetTempPathA(MAX_PATH, temp_path);
-    ok( ret, "GetTempPathA error %d\n", GetLastError());
+    ok( ret, "GetTempPathA error %ld\n", GetLastError());
     ret =GetTempFileNameA(temp_path, "pfx", 0, temp_fname);
-    ok( ret, "GetTempFileNameA error %d\n", GetLastError());
+    ok( ret, "GetTempFileNameA error %ld\n", GetLastError());
 
     /*** Write File *****************************************************/
 
     hFile = CreateFileA(temp_fname, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
-    ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA error %d\n", GetLastError());
+    ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA error %ld\n", GetLastError());
 
     for(i = 0; i < sizeof(buf); i++) buf[i] = i;
     ret = WriteFile(hFile, buf, sizeof(buf), &done, NULL);
-    ok( ret, "WriteFile error %d\n", GetLastError());
-    ok(done == sizeof(buf), "expected number of bytes written %u\n", done);
+    ok( ret, "WriteFile error %ld\n", GetLastError());
+    ok(done == sizeof(buf), "expected number of bytes written %lu\n", done);
 
     memset(&ov, 0, sizeof(ov));
     S(U(ov)).Offset = PATTERN_OFFSET;
@@ -2196,18 +2196,18 @@ static void test_offset_in_overlapped_structure(void)
     rc=WriteFile(hFile, pattern, sizeof(pattern), &done, &ov);
     /* Win 9x does not support the overlapped I/O on files */
     if (rc || GetLastError()!=ERROR_INVALID_PARAMETER) {
-        ok(rc, "WriteFile error %d\n", GetLastError());
-        ok(done == sizeof(pattern), "expected number of bytes written %u\n", done);
+        ok(rc, "WriteFile error %ld\n", GetLastError());
+        ok(done == sizeof(pattern), "expected number of bytes written %lu\n", done);
         offset = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
-        ok(offset == PATTERN_OFFSET + sizeof(pattern), "wrong file offset %d\n", offset);
+        ok(offset == PATTERN_OFFSET + sizeof(pattern), "wrong file offset %ld\n", offset);
 
         S(U(ov)).Offset = sizeof(buf) * 2;
         S(U(ov)).OffsetHigh = 0;
         ret = WriteFile(hFile, pattern, sizeof(pattern), &done, &ov);
-        ok( ret, "WriteFile error %d\n", GetLastError());
-        ok(done == sizeof(pattern), "expected number of bytes written %u\n", done);
+        ok( ret, "WriteFile error %ld\n", GetLastError());
+        ok(done == sizeof(pattern), "expected number of bytes written %lu\n", done);
         offset = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
-        ok(offset == sizeof(buf) * 2 + sizeof(pattern), "wrong file offset %d\n", offset);
+        ok(offset == sizeof(buf) * 2 + sizeof(pattern), "wrong file offset %ld\n", offset);
     }
 
     CloseHandle(hFile);
@@ -2215,7 +2215,7 @@ static void test_offset_in_overlapped_structure(void)
     /*** Read File *****************************************************/
 
     hFile = CreateFileA(temp_fname, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
-    ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA error %d\n", GetLastError());
+    ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA error %ld\n", GetLastError());
 
     memset(buf, 0, sizeof(buf));
     memset(&ov, 0, sizeof(ov));
@@ -2224,17 +2224,17 @@ static void test_offset_in_overlapped_structure(void)
     rc=ReadFile(hFile, buf, sizeof(pattern), &done, &ov);
     /* Win 9x does not support the overlapped I/O on files */
     if (rc || GetLastError()!=ERROR_INVALID_PARAMETER) {
-        ok(rc, "ReadFile error %d\n", GetLastError());
-        ok(done == sizeof(pattern), "expected number of bytes read %u\n", done);
+        ok(rc, "ReadFile error %ld\n", GetLastError());
+        ok(done == sizeof(pattern), "expected number of bytes read %lu\n", done);
         offset = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
-        ok(offset == PATTERN_OFFSET + sizeof(pattern), "wrong file offset %d\n", offset);
+        ok(offset == PATTERN_OFFSET + sizeof(pattern), "wrong file offset %ld\n", offset);
         ok(!memcmp(buf, pattern, sizeof(pattern)), "pattern match failed\n");
     }
 
     CloseHandle(hFile);
 
     ret = DeleteFileA(temp_fname);
-    ok( ret, "DeleteFileA error %d\n", GetLastError());
+    ok( ret, "DeleteFileA error %ld\n", GetLastError());
 }
 
 static void test_LockFile(void)
@@ -2251,7 +2251,7 @@ static void test_LockFile(void)
                           CREATE_ALWAYS, 0, 0 );
     if (handle == INVALID_HANDLE_VALUE)
     {
-        ok(0,"couldn't create file \"%s\" (err=%d)\n",filename,GetLastError());
+        ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
         return;
     }
     handle2 = CreateFileA( filename, GENERIC_READ | GENERIC_WRITE,
@@ -2259,7 +2259,7 @@ static void test_LockFile(void)
                            OPEN_EXISTING, 0, 0 );
     if (handle2 == INVALID_HANDLE_VALUE)
     {
-        ok( 0, "couldn't open file \"%s\" (err=%d)\n", filename, GetLastError() );
+        ok( 0, "couldn't open file \"%s\" (err=%ld)\n", filename, GetLastError() );
         goto cleanup;
     }
     ok( WriteFile( handle, sillytext, strlen(sillytext), &written, NULL ), "write failed\n" );
@@ -2336,7 +2336,7 @@ static void test_LockFile(void)
         ok( UnlockFile( handle, 0, 0x10000000, 0, 0xf0000000 ), "UnlockFile failed\n" );
     }
     else  /* win9x */
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong LockFile error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong LockFile error %lu\n", GetLastError() );
 
     /* wrap-around lock should not do anything */
     /* (but still succeeds on NT4 so we don't check result) */
@@ -2506,7 +2506,7 @@ static void test_file_sharing(void)
     /* make sure the file exists */
     if (!create_fake_dll( filename ))
     {
-        ok(0, "couldn't create file \"%s\" (err=%d)\n", filename, GetLastError());
+        ok(0, "couldn't create file \"%s\" (err=%ld)\n", filename, GetLastError());
         return;
     }
 
@@ -2519,7 +2519,7 @@ static void test_file_sharing(void)
                              NULL, OPEN_EXISTING, 0, 0 );
             if (h == INVALID_HANDLE_VALUE)
             {
-                ok(0,"couldn't create file \"%s\" (err=%d)\n",filename,GetLastError());
+                ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
                 return;
             }
             for (a2 = 0; a2 < ARRAY_SIZE(access_modes); a2++)
@@ -2564,11 +2564,11 @@ static void test_file_sharing(void)
         h = CreateFileA( filename, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0 );
         if (h == INVALID_HANDLE_VALUE)
         {
-            ok(0,"couldn't create file \"%s\" (err=%d)\n",filename,GetLastError());
+            ok(0,"couldn't create file \"%s\" (err=%ld)\n",filename,GetLastError());
             return;
         }
         m = CreateFileMappingA( h, NULL, mapping_modes[a1].dw, 0, 0, NULL );
-        ok( m != 0, "failed to create mapping %s err %u\n", mapping_modes[a1].str, GetLastError() );
+        ok( m != 0, "failed to create mapping %s err %lu\n", mapping_modes[a1].str, GetLastError() );
         CloseHandle( h );
         if (!m) continue;
 
@@ -2641,15 +2641,15 @@ static void test_file_sharing(void)
 
     SetLastError(0xdeadbeef);
     h = CreateFileA( filename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, 0 );
-    ok( h != INVALID_HANDLE_VALUE, "CreateFileA error %d\n", GetLastError() );
+    ok( h != INVALID_HANDLE_VALUE, "CreateFileA error %ld\n", GetLastError() );
 
     SetLastError(0xdeadbeef);
     h2 = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
     ok( h2 == INVALID_HANDLE_VALUE, "CreateFileA should fail\n");
-    ok( GetLastError() == ERROR_SHARING_VIOLATION, "wrong error code %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_SHARING_VIOLATION, "wrong error code %ld\n", GetLastError() );
 
     h2 = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
-    ok( h2 != INVALID_HANDLE_VALUE, "CreateFileA error %d\n", GetLastError() );
+    ok( h2 != INVALID_HANDLE_VALUE, "CreateFileA error %ld\n", GetLastError() );
 
     CloseHandle(h);
     CloseHandle(h2);
@@ -2770,15 +2770,15 @@ static void test_FindFirstFileA(void)
     ok( 0 == lstrcmpiA(data.cFileName, "nul"), "wrong name %s\n", data.cFileName );
     ok( FILE_ATTRIBUTE_ARCHIVE == data.dwFileAttributes ||
         FILE_ATTRIBUTE_DEVICE == data.dwFileAttributes /* Win9x */,
-        "wrong attributes %x\n", data.dwFileAttributes );
+        "wrong attributes %lx\n", data.dwFileAttributes );
     if (data.dwFileAttributes == FILE_ATTRIBUTE_ARCHIVE)
     {
-        ok( 0 == data.nFileSizeHigh, "wrong size %d\n", data.nFileSizeHigh );
-        ok( 0 == data.nFileSizeLow, "wrong size %d\n", data.nFileSizeLow );
+        ok( 0 == data.nFileSizeHigh, "wrong size %ld\n", data.nFileSizeHigh );
+        ok( 0 == data.nFileSizeLow, "wrong size %ld\n", data.nFileSizeLow );
     }
     SetLastError( 0xdeadbeaf );
     ok( !FindNextFileA( handle, &data ), "FindNextFileA succeeded\n" );
-    ok( GetLastError() == ERROR_NO_MORE_FILES, "bad error %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_NO_MORE_FILES, "bad error %ld\n", GetLastError() );
     ok( FindClose( handle ), "failed to close handle\n" );
 
     /* try FindFirstFileA on "lpt1" */
@@ -2790,15 +2790,15 @@ static void test_FindFirstFileA(void)
     ok( 0 == lstrcmpiA(data.cFileName, "lpt1"), "wrong name %s\n", data.cFileName );
     ok( FILE_ATTRIBUTE_ARCHIVE == data.dwFileAttributes ||
         FILE_ATTRIBUTE_DEVICE == data.dwFileAttributes /* Win9x */,
-        "wrong attributes %x\n", data.dwFileAttributes );
+        "wrong attributes %lx\n", data.dwFileAttributes );
     if (data.dwFileAttributes == FILE_ATTRIBUTE_ARCHIVE)
     {
-        ok( 0 == data.nFileSizeHigh, "wrong size %d\n", data.nFileSizeHigh );
-        ok( 0 == data.nFileSizeLow, "wrong size %d\n", data.nFileSizeLow );
+        ok( 0 == data.nFileSizeHigh, "wrong size %ld\n", data.nFileSizeHigh );
+        ok( 0 == data.nFileSizeLow, "wrong size %ld\n", data.nFileSizeLow );
     }
     SetLastError( 0xdeadbeaf );
     ok( !FindNextFileA( handle, &data ), "FindNextFileA succeeded\n" );
-    ok( GetLastError() == ERROR_NO_MORE_FILES, "bad error %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_NO_MORE_FILES, "bad error %ld\n", GetLastError() );
     ok( FindClose( handle ), "failed to close handle\n" );
 
     /* try FindFirstFileA on "c:\nul\*" */
@@ -2873,7 +2873,7 @@ static void test_FindFirstFileExA(FINDEX_INFO_LEVELS level, FINDEX_SEARCH_OPS se
         return;
     }
 
-    trace("Running FindFirstFileExA tests with level=%d, search_ops=%d, flags=%u\n",
+    trace("Running FindFirstFileExA tests with level=%d, search_ops=%d, flags=%lu\n",
           level, search_ops, flags);
 
     CreateDirectoryA("test-dir", NULL);
@@ -2901,7 +2901,7 @@ static void test_FindFirstFileExA(FINDEX_INFO_LEVELS level, FINDEX_SEARCH_OPS se
 #define CHECK_NAME(fn) (strcmp((fn), "file1") == 0 || strcmp((fn), "file2") == 0 || strcmp((fn), "dir1") == 0)
 #define CHECK_LEVEL(fn) (level != FindExInfoBasic || !(fn)[0])
 
-    ok(handle != INVALID_HANDLE_VALUE, "FindFirstFile failed (err=%u)\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "FindFirstFile failed (err=%lu)\n", GetLastError());
     ok(strcmp(search_results.cFileName, ".") == 0, "First entry should be '.', is %s\n", search_results.cFileName);
     ok(CHECK_LEVEL(search_results.cAlternateFileName), "FindFirstFile unexpectedly returned an alternate filename\n");
 
@@ -2948,12 +2948,12 @@ static void test_FindFirstFileExA(FINDEX_INFO_LEVELS level, FINDEX_SEARCH_OPS se
     if (flags & FIND_FIRST_EX_CASE_SENSITIVE)
     {
         ok(handle != INVALID_HANDLE_VALUE || GetLastError() == ERROR_PATH_NOT_FOUND,
-           "Unexpected error %x, expected valid handle or ERROR_PATH_NOT_FOUND\n", GetLastError());
+           "Unexpected error %lx, expected valid handle or ERROR_PATH_NOT_FOUND\n", GetLastError());
         trace("FindFirstFileExA flag FIND_FIRST_EX_CASE_SENSITIVE is %signored\n",
               (handle == INVALID_HANDLE_VALUE) ? "not " : "");
     }
     else
-        ok(handle != INVALID_HANDLE_VALUE, "Unexpected error %x, expected valid handle\n", GetLastError());
+        ok(handle != INVALID_HANDLE_VALUE, "Unexpected error %lx, expected valid handle\n", GetLastError());
     if (handle != INVALID_HANDLE_VALUE)
         FindClose( handle );
 
@@ -3153,19 +3153,19 @@ static void test_GetFileType(void)
     HANDLE h = CreateFileA( filename, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
     ok( h != INVALID_HANDLE_VALUE, "open %s failed\n", filename );
     type = GetFileType(h);
-    ok( type == FILE_TYPE_DISK, "expected type disk got %d\n", type );
+    ok( type == FILE_TYPE_DISK, "expected type disk got %ld\n", type );
     CloseHandle( h );
     h = CreateFileA( "nul", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0 );
     ok( h != INVALID_HANDLE_VALUE, "open nul failed\n" );
     type = GetFileType(h);
-    ok( type == FILE_TYPE_CHAR, "expected type char for nul got %d\n", type );
+    ok( type == FILE_TYPE_CHAR, "expected type char for nul got %ld\n", type );
     CloseHandle( h );
     DeleteFileA( filename );
     h = GetStdHandle( STD_OUTPUT_HANDLE );
     ok( h != INVALID_HANDLE_VALUE, "GetStdHandle failed\n" );
     type = GetFileType( (HANDLE)STD_OUTPUT_HANDLE );
     type2 = GetFileType( h );
-    ok(type == type2, "expected type %d for STD_OUTPUT_HANDLE got %d\n", type2, type);
+    ok(type == type2, "expected type %ld for STD_OUTPUT_HANDLE got %ld\n", type2, type);
 }
 
 static int completion_count;
@@ -3236,36 +3236,36 @@ static void test_read_write(void)
     static const char prefix[] = "pfx";
 
     ret = GetTempPathA(MAX_PATH, temp_path);
-    ok(ret != 0, "GetTempPathA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempPathA error %ld\n", GetLastError());
     ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
 
     ret = GetTempFileNameA(temp_path, prefix, 0, filename);
-    ok(ret != 0, "GetTempFileNameA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
 
     hFile = CreateFileA(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                         CREATE_ALWAYS, FILE_FLAG_RANDOM_ACCESS, 0);
-    ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA: error %d\n", GetLastError());
+    ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA: error %ld\n", GetLastError());
 
     user_apc_ran = FALSE;
     ret = QueueUserAPC(&user_apc, GetCurrentThread(), 0);
-    ok(ret, "QueueUserAPC failed: %d\n", GetLastError());
+    ok(ret, "QueueUserAPC failed: %ld\n", GetLastError());
 
     SetLastError(12345678);
     bytes = 12345678;
     ret = WriteFile(hFile, NULL, 0, &bytes, NULL);
     ok(ret && GetLastError() == 12345678,
-	"ret = %d, error %d\n", ret, GetLastError());
-    ok(!bytes, "bytes = %d\n", bytes);
+	"ret = %ld, error %ld\n", ret, GetLastError());
+    ok(!bytes, "bytes = %ld\n", bytes);
 
     SetLastError(12345678);
     bytes = 12345678;
     ret = WriteFile(hFile, NULL, 10, &bytes, NULL);
     ok((!ret && GetLastError() == ERROR_INVALID_USER_BUFFER) || /* Win2k */
 	(ret && GetLastError() == 12345678), /* Win9x */
-	"ret = %d, error %d\n", ret, GetLastError());
+	"ret = %ld, error %ld\n", ret, GetLastError());
     ok(!bytes || /* Win2k */
 	bytes == 10, /* Win9x */
-	"bytes = %d\n", bytes);
+	"bytes = %ld\n", bytes);
 
     /* make sure the file contains data */
     WriteFile(hFile, "this is the test data", 21, &bytes, NULL);
@@ -3275,16 +3275,16 @@ static void test_read_write(void)
     bytes = 12345678;
     ret = ReadFile(hFile, NULL, 0, &bytes, NULL);
     ok(ret && GetLastError() == 12345678,
-	"ret = %d, error %d\n", ret, GetLastError());
-    ok(!bytes, "bytes = %d\n", bytes);
+	"ret = %ld, error %ld\n", ret, GetLastError());
+    ok(!bytes, "bytes = %ld\n", bytes);
 
     SetLastError(12345678);
     bytes = 12345678;
     ret = ReadFile(hFile, NULL, 10, &bytes, NULL);
     ok(!ret && (GetLastError() == ERROR_NOACCESS || /* Win2k */
 		GetLastError() == ERROR_INVALID_PARAMETER), /* Win9x */
-	"ret = %d, error %d\n", ret, GetLastError());
-    ok(!bytes, "bytes = %d\n", bytes);
+	"ret = %ld, error %ld\n", ret, GetLastError());
+    ok(!bytes, "bytes = %ld\n", bytes);
 
     ok(user_apc_ran == FALSE, "UserAPC ran, file using alertable io mode\n");
     SleepEx(0, TRUE); /* get rid of apc */
@@ -3292,38 +3292,38 @@ static void test_read_write(void)
     /* test passing protected memory as buffer */
 
     mem = VirtualAlloc( NULL, 0x4000, MEM_COMMIT, PAGE_READWRITE );
-    ok( mem != NULL, "failed to allocate virtual mem error %u\n", GetLastError() );
+    ok( mem != NULL, "failed to allocate virtual mem error %lu\n", GetLastError() );
 
     ret = WriteFile( hFile, mem, 0x4000, &bytes, NULL );
-    ok( ret, "WriteFile failed error %u\n", GetLastError() );
-    ok( bytes == 0x4000, "only wrote %x bytes\n", bytes );
+    ok( ret, "WriteFile failed error %lu\n", GetLastError() );
+    ok( bytes == 0x4000, "only wrote %lx bytes\n", bytes );
 
     ret = VirtualProtect( mem + 0x2000, 0x2000, PAGE_NOACCESS, &old_prot );
-    ok( ret, "VirtualProtect failed error %u\n", GetLastError() );
+    ok( ret, "VirtualProtect failed error %lu\n", GetLastError() );
 
     ret = WriteFile( hFile, mem, 0x4000, &bytes, NULL );
     ok( !ret, "WriteFile succeeded\n" );
     ok( GetLastError() == ERROR_INVALID_USER_BUFFER ||
         GetLastError() == ERROR_INVALID_PARAMETER,  /* win9x */
-        "wrong error %u\n", GetLastError() );
-    ok( bytes == 0, "wrote %x bytes\n", bytes );
+        "wrong error %lu\n", GetLastError() );
+    ok( bytes == 0, "wrote %lx bytes\n", bytes );
 
     ret = WriteFile( (HANDLE)0xdead, mem, 0x4000, &bytes, NULL );
     ok( !ret, "WriteFile succeeded\n" );
     ok( GetLastError() == ERROR_INVALID_HANDLE || /* handle is checked before buffer on NT */
         GetLastError() == ERROR_INVALID_PARAMETER,  /* win9x */
-        "wrong error %u\n", GetLastError() );
-    ok( bytes == 0, "wrote %x bytes\n", bytes );
+        "wrong error %lu\n", GetLastError() );
+    ok( bytes == 0, "wrote %lx bytes\n", bytes );
 
     ret = VirtualProtect( mem, 0x2000, PAGE_NOACCESS, &old_prot );
-    ok( ret, "VirtualProtect failed error %u\n", GetLastError() );
+    ok( ret, "VirtualProtect failed error %lu\n", GetLastError() );
 
     ret = WriteFile( hFile, mem, 0x4000, &bytes, NULL );
     ok( !ret, "WriteFile succeeded\n" );
     ok( GetLastError() == ERROR_INVALID_USER_BUFFER ||
         GetLastError() == ERROR_INVALID_PARAMETER,  /* win9x */
-        "wrong error %u\n", GetLastError() );
-    ok( bytes == 0, "wrote %x bytes\n", bytes );
+        "wrong error %lu\n", GetLastError() );
+    ok( bytes == 0, "wrote %lx bytes\n", bytes );
 
     SetFilePointer( hFile, 0, NULL, FILE_BEGIN );
 
@@ -3331,28 +3331,28 @@ static void test_read_write(void)
     ok( !ret, "ReadFile succeeded\n" );
     ok( GetLastError() == ERROR_NOACCESS ||
         GetLastError() == ERROR_INVALID_PARAMETER,  /* win9x */
-        "wrong error %u\n", GetLastError() );
-    ok( bytes == 0, "read %x bytes\n", bytes );
+        "wrong error %lu\n", GetLastError() );
+    ok( bytes == 0, "read %lx bytes\n", bytes );
 
     ret = VirtualProtect( mem, 0x2000, PAGE_READONLY, &old_prot );
-    ok( ret, "VirtualProtect failed error %u\n", GetLastError() );
+    ok( ret, "VirtualProtect failed error %lu\n", GetLastError() );
 
     ret = ReadFile( hFile, mem, 0x4000, &bytes, NULL );
     ok( !ret, "ReadFile succeeded\n" );
     ok( GetLastError() == ERROR_NOACCESS ||
         GetLastError() == ERROR_INVALID_PARAMETER,  /* win9x */
-        "wrong error %u\n", GetLastError() );
-    ok( bytes == 0, "read %x bytes\n", bytes );
+        "wrong error %lu\n", GetLastError() );
+    ok( bytes == 0, "read %lx bytes\n", bytes );
 
     ret = VirtualProtect( mem, 0x2000, PAGE_READWRITE, &old_prot );
-    ok( ret, "VirtualProtect failed error %u\n", GetLastError() );
+    ok( ret, "VirtualProtect failed error %lu\n", GetLastError() );
 
     ret = ReadFile( hFile, mem, 0x4000, &bytes, NULL );
     ok( !ret, "ReadFile succeeded\n" );
     ok( GetLastError() == ERROR_NOACCESS ||
         GetLastError() == ERROR_INVALID_PARAMETER,  /* win9x */
-        "wrong error %u\n", GetLastError() );
-    ok( bytes == 0, "read %x bytes\n", bytes );
+        "wrong error %lu\n", GetLastError() );
+    ok( bytes == 0, "read %lx bytes\n", bytes );
 
     SetFilePointer( hFile, 0x1234, NULL, FILE_BEGIN );
     SetEndOfFile( hFile );
@@ -3362,26 +3362,26 @@ static void test_read_write(void)
     ok( !ret, "ReadFile succeeded\n" );
     ok( GetLastError() == ERROR_NOACCESS ||
         GetLastError() == ERROR_INVALID_PARAMETER,  /* win9x */
-        "wrong error %u\n", GetLastError() );
-    ok( bytes == 0, "read %x bytes\n", bytes );
+        "wrong error %lu\n", GetLastError() );
+    ok( bytes == 0, "read %lx bytes\n", bytes );
 
     ret = ReadFile( hFile, mem, 0x2000, &bytes, NULL );
-    ok( ret, "ReadFile failed error %u\n", GetLastError() );
-    ok( bytes == 0x1234, "read %x bytes\n", bytes );
+    ok( ret, "ReadFile failed error %lu\n", GetLastError() );
+    ok( bytes == 0x1234, "read %lx bytes\n", bytes );
 
     ret = ReadFile( hFile, NULL, 1, &bytes, NULL );
     ok( !ret, "ReadFile succeeded\n" );
     ok( GetLastError() == ERROR_NOACCESS ||
         GetLastError() == ERROR_INVALID_PARAMETER,  /* win9x */
-        "wrong error %u\n", GetLastError() );
-    ok( bytes == 0, "read %x bytes\n", bytes );
+        "wrong error %lu\n", GetLastError() );
+    ok( bytes == 0, "read %lx bytes\n", bytes );
 
     VirtualFree( mem, 0, MEM_RELEASE );
 
     ret = CloseHandle(hFile);
-    ok( ret, "CloseHandle: error %d\n", GetLastError());
+    ok( ret, "CloseHandle: error %ld\n", GetLastError());
     ret = DeleteFileA(filename);
-    ok( ret, "DeleteFileA: error %d\n", GetLastError());
+    ok( ret, "DeleteFileA: error %ld\n", GetLastError());
 }
 
 static void test_OpenFile(void)
@@ -3420,9 +3420,9 @@ static void test_OpenFile(void)
         SetLastError(0xfaceabee);
 
         hFile = OpenFile(buff, &ofs, OF_EXIST);
-        ok( hFile == TRUE, "%s not found : %d\n", buff, GetLastError() );
+        ok( hFile == TRUE, "%s not found : %ld\n", buff, GetLastError() );
         ok( GetLastError() == 0xfaceabee || GetLastError() == ERROR_SUCCESS, 
-            "GetLastError() returns %d\n", GetLastError() );
+            "GetLastError() returns %ld\n", GetLastError() );
         ok( ofs.cBytes == sizeof(ofs), "OpenFile set ofs.cBytes to %d\n", ofs.cBytes );
         ok( ofs.nErrCode == ERROR_SUCCESS, "OpenFile set ofs.nErrCode to %d\n", ofs.nErrCode );
         ok( lstrcmpiA(ofs.szPathName, buff) == 0,
@@ -3443,8 +3443,8 @@ static void test_OpenFile(void)
         SetLastError(0xfaceabee);
 
         hFile = OpenFile(foo, &ofs, OF_EXIST);
-        ok( hFile == HFILE_ERROR, "hFile != HFILE_ERROR : %d\n", GetLastError());
-        ok( GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError() returns %d\n", GetLastError() );
+        ok( hFile == HFILE_ERROR, "hFile != HFILE_ERROR : %ld\n", GetLastError());
+        ok( GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError() returns %ld\n", GetLastError() );
         todo_wine
         ok( ofs.cBytes == 0xA5, "OpenFile set ofs.cBytes to %d\n", ofs.cBytes );
         ok( ofs.nErrCode == ERROR_FILE_NOT_FOUND, "OpenFile set ofs.nErrCode to %d\n", ofs.nErrCode );
@@ -3464,9 +3464,9 @@ static void test_OpenFile(void)
         SetLastError(0xfaceabee);
 
         hFile = OpenFile(foo_too_long, &ofs, OF_EXIST);
-        ok( hFile == HFILE_ERROR, "hFile != HFILE_ERROR : %d\n", GetLastError());
+        ok( hFile == HFILE_ERROR, "hFile != HFILE_ERROR : %ld\n", GetLastError());
         ok( GetLastError() == ERROR_INVALID_DATA || GetLastError() == ERROR_FILENAME_EXCED_RANGE, 
-            "GetLastError() returns %d\n", GetLastError() );
+            "GetLastError() returns %ld\n", GetLastError() );
         todo_wine
         ok( ofs.cBytes == 0xA5, "OpenFile set ofs.cBytes to %d\n", ofs.cBytes );
         ok( ofs.nErrCode == ERROR_INVALID_DATA || ofs.nErrCode == ERROR_FILENAME_EXCED_RANGE,
@@ -3482,14 +3482,14 @@ static void test_OpenFile(void)
     hFile = OpenFile(filename, &ofs, OF_CREATE);
     ok( hFile != HFILE_ERROR, "OpenFile failed to create nonexistent file\n" );
     ok( GetLastError() == 0xfaceabee || GetLastError() == ERROR_SUCCESS, 
-        "GetLastError() returns %d\n", GetLastError() );
+        "GetLastError() returns %ld\n", GetLastError() );
     ok( ofs.cBytes == sizeof(OFSTRUCT), "OpenFile set ofs.cBytes to %d\n", ofs.cBytes );
     ok( ofs.nErrCode == ERROR_SUCCESS || broken(ofs.nErrCode != ERROR_SUCCESS) /* win9x */,
         "OpenFile set ofs.nErrCode to %d\n", ofs.nErrCode );
     ret = _lclose(hFile);
     ok( !ret, "_lclose() returns %d\n", ret );
     retval = GetFileAttributesA(filename);
-    ok( retval != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA: error %d\n", GetLastError() );
+    ok( retval != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA: error %ld\n", GetLastError() );
 
     memset(&ofs, 0xA5, sizeof(ofs));
     SetLastError(0xfaceabee);
@@ -3498,7 +3498,7 @@ static void test_OpenFile(void)
     hFile = OpenFile(filename, &ofs, OF_READ);
     ok( hFile != HFILE_ERROR, "OpenFile failed on read\n" );
     ok( GetLastError() == 0xfaceabee || GetLastError() == ERROR_SUCCESS, 
-        "GetLastError() returns %d\n", GetLastError() );
+        "GetLastError() returns %ld\n", GetLastError() );
     ok( ofs.cBytes == sizeof(OFSTRUCT), "OpenFile set ofs.cBytes to %d\n", ofs.cBytes );
     ok( ofs.nErrCode == ERROR_SUCCESS || broken(ofs.nErrCode != ERROR_SUCCESS) /* win9x */,
         "OpenFile set ofs.nErrCode to %d\n", ofs.nErrCode );
@@ -3513,7 +3513,7 @@ static void test_OpenFile(void)
     hFile = OpenFile(filename, &ofs, OF_WRITE);
     ok( hFile != HFILE_ERROR, "OpenFile failed on write\n" );
     ok( GetLastError() == 0xfaceabee || GetLastError() == ERROR_SUCCESS, 
-        "GetLastError() returns %d\n", GetLastError() );
+        "GetLastError() returns %ld\n", GetLastError() );
     ok( ofs.cBytes == sizeof(OFSTRUCT), "OpenFile set ofs.cBytes to %d\n", ofs.cBytes );
     ok( ofs.nErrCode == ERROR_SUCCESS || broken(ofs.nErrCode != ERROR_SUCCESS) /* win9x */,
         "OpenFile set ofs.nErrCode to %d\n", ofs.nErrCode );
@@ -3528,7 +3528,7 @@ static void test_OpenFile(void)
     hFile = OpenFile(filename, &ofs, OF_READWRITE);
     ok( hFile != HFILE_ERROR, "OpenFile failed on read/write\n" );
     ok( GetLastError() == 0xfaceabee || GetLastError() == ERROR_SUCCESS, 
-        "GetLastError() returns %d\n", GetLastError() );
+        "GetLastError() returns %ld\n", GetLastError() );
     ok( ofs.cBytes == sizeof(OFSTRUCT), "OpenFile set ofs.cBytes to %d\n", ofs.cBytes );
     ok( ofs.nErrCode == ERROR_SUCCESS || broken(ofs.nErrCode != ERROR_SUCCESS) /* win9x */,
         "OpenFile set ofs.nErrCode to %d\n", ofs.nErrCode );
@@ -3543,7 +3543,7 @@ static void test_OpenFile(void)
     hFile = OpenFile(filename, &ofs, OF_EXIST);
     ok( hFile == 1, "OpenFile failed on finding our created file\n" );
     ok( GetLastError() == 0xfaceabee || GetLastError() == ERROR_SUCCESS, 
-        "GetLastError() returns %d\n", GetLastError() );
+        "GetLastError() returns %ld\n", GetLastError() );
     ok( ofs.cBytes == sizeof(OFSTRUCT), "OpenFile set ofs.cBytes to %d\n", ofs.cBytes );
     ok( ofs.nErrCode == ERROR_SUCCESS || broken(ofs.nErrCode != ERROR_SUCCESS) /* win9x */,
         "OpenFile set ofs.nErrCode to %d\n", ofs.nErrCode );
@@ -3556,7 +3556,7 @@ static void test_OpenFile(void)
     hFile = OpenFile(filename, &ofs, OF_DELETE);
     ok( hFile == 1, "OpenFile failed on delete (%d)\n", hFile );
     ok( GetLastError() == 0xfaceabee || GetLastError() == ERROR_SUCCESS, 
-        "GetLastError() returns %d\n", GetLastError() );
+        "GetLastError() returns %ld\n", GetLastError() );
     ok( ofs.cBytes == sizeof(OFSTRUCT), "OpenFile set ofs.cBytes to %d\n", ofs.cBytes );
     ok( ofs.nErrCode == ERROR_SUCCESS || broken(ofs.nErrCode != ERROR_SUCCESS) /* win9x */,
         "OpenFile set ofs.nErrCode to %d\n", ofs.nErrCode );
@@ -3584,27 +3584,27 @@ static void test_overlapped(void)
     result = 1;
     r = GetOverlappedResult(0, &ov, &result, 0);
     if (r)
-        ok( result == 0, "wrong result %u\n", result );
+        ok( result == 0, "wrong result %lu\n", result );
     else  /* win9x */
-        ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %lu\n", GetLastError() );
 
     result = 0;
     ov.Internal = 0;
     ov.InternalHigh = 0xabcd;
     r = GetOverlappedResult(0, &ov, &result, 0);
     if (r)
-        ok( result == 0xabcd, "wrong result %u\n", result );
+        ok( result == 0xabcd, "wrong result %lu\n", result );
     else  /* win9x */
-        ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xb00 );
     result = 0;
     ov.Internal = STATUS_INVALID_HANDLE;
     ov.InternalHigh = 0xabcd;
     r = GetOverlappedResult(0, &ov, &result, 0);
-    ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %lu\n", GetLastError() );
     ok( r == FALSE, "should return false\n");
-    ok( result == 0xabcd || result == 0 /* win9x */, "wrong result %u\n", result );
+    ok( result == 0xabcd || result == 0 /* win9x */, "wrong result %lu\n", result );
 
     SetLastError( 0xb00 );
     result = 0;
@@ -3612,9 +3612,9 @@ static void test_overlapped(void)
     ov.InternalHigh = 0xabcd;
     r = GetOverlappedResult(0, &ov, &result, 0);
     ok( GetLastError() == ERROR_IO_INCOMPLETE || GetLastError() == ERROR_INVALID_HANDLE /* win9x */,
-        "wrong error %u\n", GetLastError() );
+        "wrong error %lu\n", GetLastError() );
     ok( r == FALSE, "should return false\n");
-    ok( result == 0, "wrong result %u\n", result );
+    ok( result == 0, "wrong result %lu\n", result );
 
     SetLastError( 0xb00 );
     ov.hEvent = CreateEventW( NULL, 1, 1, NULL );
@@ -3622,13 +3622,13 @@ static void test_overlapped(void)
     ov.InternalHigh = 0xabcd;
     r = GetOverlappedResult(0, &ov, &result, 0);
     ok( GetLastError() == ERROR_IO_INCOMPLETE || GetLastError() == ERROR_INVALID_HANDLE /* win9x */,
-        "wrong error %u\n", GetLastError() );
+        "wrong error %lu\n", GetLastError() );
     ok( r == FALSE, "should return false\n");
 
     r = GetOverlappedResult( 0, &ov, &result, TRUE );
     ok( r == TRUE, "should return TRUE\n" );
-    ok( result == 0xabcd, "wrong result %u\n", result );
-    ok( ov.Internal == STATUS_PENDING, "expected STATUS_PENDING, got %08lx\n", ov.Internal );
+    ok( result == 0xabcd, "wrong result %lu\n", result );
+    ok( ov.Internal == STATUS_PENDING, "expected STATUS_PENDING, got %08Ix\n", ov.Internal );
 
     ResetEvent( ov.hEvent );
 
@@ -3637,7 +3637,7 @@ static void test_overlapped(void)
     ov.InternalHigh = 0;
     r = GetOverlappedResult(0, &ov, &result, 0);
     ok( GetLastError() == ERROR_IO_INCOMPLETE || GetLastError() == ERROR_INVALID_HANDLE /* win9x */,
-        "wrong error %u\n", GetLastError() );
+        "wrong error %lu\n", GetLastError() );
     ok( r == FALSE, "should return false\n");
 
     r = CloseHandle( ov.hEvent );
@@ -3650,19 +3650,19 @@ static void test_RemoveDirectory(void)
     char directory[] = "removeme";
 
     rc = CreateDirectoryA(directory, NULL);
-    ok( rc, "Createdirectory failed, gle=%d\n", GetLastError() );
+    ok( rc, "Createdirectory failed, gle=%ld\n", GetLastError() );
 
     rc = SetCurrentDirectoryA(directory);
-    ok( rc, "SetCurrentDirectory failed, gle=%d\n", GetLastError() );
+    ok( rc, "SetCurrentDirectory failed, gle=%ld\n", GetLastError() );
 
     rc = RemoveDirectoryA(".");
     if (!rc)
     {
         rc = SetCurrentDirectoryA("..");
-        ok( rc, "SetCurrentDirectory failed, gle=%d\n", GetLastError() );
+        ok( rc, "SetCurrentDirectory failed, gle=%ld\n", GetLastError() );
 
         rc = RemoveDirectoryA(directory);
-        ok( rc, "RemoveDirectory failed, gle=%d\n", GetLastError() );
+        ok( rc, "RemoveDirectory failed, gle=%ld\n", GetLastError() );
     }
 }
 
@@ -3688,17 +3688,17 @@ static void test_ReplaceFileA(void)
     char **argv;
 
     ret = GetTempPathA(MAX_PATH, temp_path);
-    ok(ret != 0, "GetTempPathA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempPathA error %ld\n", GetLastError());
     ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
 
     ret = GetTempFileNameA(temp_path, prefix, 0, replaced);
-    ok(ret != 0, "GetTempFileNameA error (replaced) %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error (replaced) %ld\n", GetLastError());
 
     ret = GetTempFileNameA(temp_path, prefix, 0, replacement);
-    ok(ret != 0, "GetTempFileNameA error (replacement) %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error (replacement) %ld\n", GetLastError());
 
     ret = GetTempFileNameA(temp_path, prefix, 0, backup);
-    ok(ret != 0, "GetTempFileNameA error (backup) %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error (backup) %ld\n", GetLastError());
 
     /* place predictable data in the file to be replaced */
     hReplacedFile = CreateFileA(replaced, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0 );
@@ -3706,7 +3706,7 @@ static void test_ReplaceFileA(void)
         "failed to open replaced file\n");
     retok = WriteFile(hReplacedFile, replacedData, sizeof(replacedData), &ret, NULL );
     ok( retok && ret == sizeof(replacedData),
-       "WriteFile error (replaced) %d\n", GetLastError());
+       "WriteFile error (replaced) %ld\n", GetLastError());
     ok(GetFileSize(hReplacedFile, NULL) == sizeof(replacedData),
         "replaced file has wrong size\n");
     /* place predictable data in the file to be the replacement */
@@ -3715,7 +3715,7 @@ static void test_ReplaceFileA(void)
         "failed to open replacement file\n");
     retok = WriteFile(hReplacementFile, replacementData, sizeof(replacementData), &ret, NULL );
     ok( retok && ret == sizeof(replacementData),
-       "WriteFile error (replacement) %d\n", GetLastError());
+       "WriteFile error (replacement) %ld\n", GetLastError());
     ok(GetFileSize(hReplacementFile, NULL) == sizeof(replacementData),
         "replacement file has wrong size\n");
     /* place predictable data in the backup file (to be over-written) */
@@ -3724,28 +3724,28 @@ static void test_ReplaceFileA(void)
         "failed to open backup file\n");
     retok = WriteFile(hBackupFile, backupData, sizeof(backupData), &ret, NULL );
     ok( retok && ret == sizeof(backupData),
-       "WriteFile error (replacement) %d\n", GetLastError());
+       "WriteFile error (replacement) %ld\n", GetLastError());
     ok(GetFileSize(hBackupFile, NULL) == sizeof(backupData),
         "backup file has wrong size\n");
     /* change the filetime on the "replaced" file to ensure that it changes */
     ret = GetFileTime(hReplacedFile, NULL, NULL, &ftReplaced);
-    ok( ret, "GetFileTime error (replaced) %d\n", GetLastError());
+    ok( ret, "GetFileTime error (replaced) %ld\n", GetLastError());
     ftReplaced.dwLowDateTime -= 600000000; /* 60 second */
     ret = SetFileTime(hReplacedFile, NULL, NULL, &ftReplaced);
-    ok( ret, "SetFileTime error (replaced) %d\n", GetLastError());
+    ok( ret, "SetFileTime error (replaced) %ld\n", GetLastError());
     GetFileTime(hReplacedFile, NULL, NULL, &ftReplaced);  /* get the actual time back */
     CloseHandle(hReplacedFile);
     /* change the filetime on the backup to ensure that it changes */
     ret = GetFileTime(hBackupFile, NULL, NULL, &ftBackup);
-    ok( ret, "GetFileTime error (backup) %d\n", GetLastError());
+    ok( ret, "GetFileTime error (backup) %ld\n", GetLastError());
     ftBackup.dwLowDateTime -= 1200000000; /* 120 second */
     ret = SetFileTime(hBackupFile, NULL, NULL, &ftBackup);
-    ok( ret, "SetFileTime error (backup) %d\n", GetLastError());
+    ok( ret, "SetFileTime error (backup) %ld\n", GetLastError());
     GetFileTime(hBackupFile, NULL, NULL, &ftBackup);  /* get the actual time back */
     CloseHandle(hBackupFile);
     /* get the filetime on the replacement file to perform checks */
     ret = GetFileTime(hReplacementFile, NULL, NULL, &ftReplacement);
-    ok( ret, "GetFileTime error (replacement) %d\n", GetLastError());
+    ok( ret, "GetFileTime error (replacement) %ld\n", GetLastError());
     CloseHandle(hReplacementFile);
 
     /* perform replacement w/ backup
@@ -3753,37 +3753,37 @@ static void test_ReplaceFileA(void)
      */
     SetLastError(0xdeadbeef);
     ret = ReplaceFileA(replaced, replacement, backup, 0, 0, 0);
-    ok(ret, "ReplaceFileA: unexpected error %d\n", GetLastError());
+    ok(ret, "ReplaceFileA: unexpected error %ld\n", GetLastError());
     /* make sure that the backup has the size of the old "replaced" file */
     hBackupFile = CreateFileA(backup, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
     ok(hBackupFile != INVALID_HANDLE_VALUE,
         "failed to open backup file\n");
     ret = GetFileSize(hBackupFile, NULL);
     ok(ret == sizeof(replacedData),
-        "backup file has wrong size %d\n", ret);
+        "backup file has wrong size %ld\n", ret);
     /* make sure that the "replaced" file has the size of the replacement file */
     hReplacedFile = CreateFileA(replaced, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
     ok(hReplacedFile != INVALID_HANDLE_VALUE,
-        "failed to open replaced file: %d\n", GetLastError());
+        "failed to open replaced file: %ld\n", GetLastError());
     if (hReplacedFile != INVALID_HANDLE_VALUE)
     {
         ret = GetFileSize(hReplacedFile, NULL);
         ok(ret == sizeof(replacementData),
-            "replaced file has wrong size %d\n", ret);
+            "replaced file has wrong size %ld\n", ret);
         /* make sure that the replacement file no-longer exists */
         hReplacementFile = CreateFileA(replacement, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
         ok(hReplacementFile == INVALID_HANDLE_VALUE,
-           "unexpected error, replacement file should not exist %d\n", GetLastError());
+           "unexpected error, replacement file should not exist %ld\n", GetLastError());
         /* make sure that the backup has the old "replaced" filetime */
         ret = GetFileTime(hBackupFile, NULL, NULL, &ftBackup);
-        ok( ret, "GetFileTime error (backup %d\n", GetLastError());
+        ok( ret, "GetFileTime error (backup %ld\n", GetLastError());
         ok(check_file_time(&ftBackup, &ftReplaced, 20000000), "backup file has wrong filetime\n");
         CloseHandle(hBackupFile);
         /* make sure that the "replaced" has the old replacement filetime */
         ret = GetFileTime(hReplacedFile, NULL, NULL, &ftReplaced);
-        ok( ret, "GetFileTime error (backup %d\n", GetLastError());
+        ok( ret, "GetFileTime error (backup %ld\n", GetLastError());
         ok(check_file_time(&ftReplaced, &ftReplacement, 20000000),
-           "replaced file has wrong filetime %x%08x / %x%08x\n",
+           "replaced file has wrong filetime %lx%08lx / %lx%08lx\n",
            ftReplaced.dwHighDateTime, ftReplaced.dwLowDateTime,
            ftReplacement.dwHighDateTime, ftReplacement.dwLowDateTime );
         CloseHandle(hReplacedFile);
@@ -3793,64 +3793,64 @@ static void test_ReplaceFileA(void)
 
     /* re-create replacement file for pass w/o backup (blank) */
     ret = GetTempFileNameA(temp_path, prefix, 0, replacement);
-    ok(ret != 0, "GetTempFileNameA error (replacement) %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error (replacement) %ld\n", GetLastError());
     /* perform replacement w/o backup
      * TODO: flags are not implemented
      */
     SetLastError(0xdeadbeef);
     ret = ReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
     ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
-       "ReplaceFileA: unexpected error %d\n", GetLastError());
+       "ReplaceFileA: unexpected error %ld\n", GetLastError());
 
     /* re-create replacement file for pass w/ backup (backup-file not existing) */
     DeleteFileA(replacement);
     ret = GetTempFileNameA(temp_path, prefix, 0, replacement);
-    ok(ret != 0, "GetTempFileNameA error (replacement) %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error (replacement) %ld\n", GetLastError());
     ret = DeleteFileA(backup);
-    ok(ret, "DeleteFileA: error (backup) %d\n", GetLastError());
+    ok(ret, "DeleteFileA: error (backup) %ld\n", GetLastError());
     /* perform replacement w/ backup (no pre-existing backup)
      * TODO: flags are not implemented
      */
     SetLastError(0xdeadbeef);
     ret = ReplaceFileA(replaced, replacement, backup, 0, 0, 0);
     ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
-       "ReplaceFileA: unexpected error %d\n", GetLastError());
+       "ReplaceFileA: unexpected error %ld\n", GetLastError());
     if (ret)
         removeBackup = TRUE;
 
     /* re-create replacement file for pass w/ no permissions to "replaced" */
     DeleteFileA(replacement);
     ret = GetTempFileNameA(temp_path, prefix, 0, replacement);
-    ok(ret != 0, "GetTempFileNameA error (replacement) %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error (replacement) %ld\n", GetLastError());
     ret = SetFileAttributesA(replaced, FILE_ATTRIBUTE_READONLY);
     ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
-       "SetFileAttributesA: error setting to read only %d\n", GetLastError());
+       "SetFileAttributesA: error setting to read only %ld\n", GetLastError());
     /* perform replacement w/ backup (no permission to "replaced")
      * TODO: flags are not implemented
      */
     SetLastError(0xdeadbeef);
     ret = ReplaceFileA(replaced, replacement, backup, 0, 0, 0);
-    ok(ret == 0 && GetLastError() == ERROR_ACCESS_DENIED, "ReplaceFileA: unexpected error %d\n", GetLastError());
+    ok(ret == 0 && GetLastError() == ERROR_ACCESS_DENIED, "ReplaceFileA: unexpected error %ld\n", GetLastError());
     /* make sure that the replacement file still exists */
     hReplacementFile = CreateFileA(replacement, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
     ok(hReplacementFile != INVALID_HANDLE_VALUE ||
        broken(GetLastError() == ERROR_FILE_NOT_FOUND), /* win2k */
-       "unexpected error, replacement file should still exist %d\n", GetLastError());
+       "unexpected error, replacement file should still exist %ld\n", GetLastError());
     CloseHandle(hReplacementFile);
     ret = SetFileAttributesA(replaced, FILE_ATTRIBUTE_NORMAL);
     ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
-       "SetFileAttributesA: error setting to normal %d\n", GetLastError());
+       "SetFileAttributesA: error setting to normal %ld\n", GetLastError());
 
     /* replacement readonly */
     DeleteFileA(replacement);
     ret = GetTempFileNameA(temp_path, prefix, 0, replacement);
-    ok(ret != 0, "GetTempFileNameA error (replacement) %#x\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error (replacement) %#lx\n", GetLastError());
     ret = SetFileAttributesA(replacement, FILE_ATTRIBUTE_READONLY);
-    ok(ret, "SetFileAttributesA: error setting to readonly %#x\n", GetLastError());
+    ok(ret, "SetFileAttributesA: error setting to readonly %#lx\n", GetLastError());
     ret = ReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "ReplaceFileA: unexpected error %#x\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "ReplaceFileA: unexpected error %#lx\n", GetLastError());
     ret = SetFileAttributesA(replacement, FILE_ATTRIBUTE_NORMAL);
-    ok(ret, "SetFileAttributesA: error setting to normal %#x\n", GetLastError());
+    ok(ret, "SetFileAttributesA: error setting to normal %#lx\n", GetLastError());
 
     /* re-create replacement file for pass w/ replaced opened with
      * the same permissions as an exe (Replicating an exe trying to
@@ -3858,32 +3858,32 @@ static void test_ReplaceFileA(void)
      */
     DeleteFileA(replacement);
     ret = GetTempFileNameA(temp_path, prefix, 0, replacement);
-    ok(ret != 0, "GetTempFileNameA error (replacement) %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error (replacement) %ld\n", GetLastError());
 
     /* make sure that the replaced file is opened like an exe*/
     hReplacedFile = CreateFileA(replaced, GENERIC_READ | SYNCHRONIZE, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, 0);
     ok(hReplacedFile != INVALID_HANDLE_VALUE,
-       "unexpected error, replaced file should be able to be opened %d\n", GetLastError());
+       "unexpected error, replaced file should be able to be opened %ld\n", GetLastError());
     /*Calling ReplaceFileA on an exe should succeed*/
     ret = ReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
-    ok(ret, "ReplaceFileA: unexpected error %d\n", GetLastError());
+    ok(ret, "ReplaceFileA: unexpected error %ld\n", GetLastError());
     CloseHandle(hReplacedFile);
 
     /* replace file while replacement is opened */
     ret = GetTempFileNameA(temp_path, prefix, 0, replacement);
-    ok(ret != 0, "GetTempFileNameA error (replacement) %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error (replacement) %ld\n", GetLastError());
     hReplacementFile = CreateFileA(replacement, GENERIC_READ | SYNCHRONIZE, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, 0);
-    ok(hReplacementFile != INVALID_HANDLE_VALUE, "unexpected error, replacement file should be able to be opened %d\n",
+    ok(hReplacementFile != INVALID_HANDLE_VALUE, "unexpected error, replacement file should be able to be opened %ld\n",
        GetLastError());
     ret = ReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
     ok(!ret, "expect failure\n");
-    ok(GetLastError() == ERROR_SHARING_VIOLATION, "expect ERROR_SHARING_VIOLATION, got %#x.\n", GetLastError());
+    ok(GetLastError() == ERROR_SHARING_VIOLATION, "expect ERROR_SHARING_VIOLATION, got %#lx.\n", GetLastError());
     CloseHandle(hReplacementFile);
 
     /* replacement file still exists, make pass w/o "replaced" */
     ret = DeleteFileA(replaced);
     ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
-       "DeleteFileA: error (replaced) %d\n", GetLastError());
+       "DeleteFileA: error (replaced) %ld\n", GetLastError());
     /* perform replacement w/ backup (no pre-existing backup or "replaced")
      * TODO: flags are not implemented
      */
@@ -3891,7 +3891,7 @@ static void test_ReplaceFileA(void)
     ret = ReplaceFileA(replaced, replacement, backup, 0, 0, 0);
     ok(!ret && (GetLastError() == ERROR_FILE_NOT_FOUND ||
        GetLastError() == ERROR_ACCESS_DENIED),
-       "ReplaceFileA: unexpected error %d\n", GetLastError());
+       "ReplaceFileA: unexpected error %ld\n", GetLastError());
 
     /* perform replacement w/o existing "replacement" file
      * TODO: flags are not implemented
@@ -3900,7 +3900,7 @@ static void test_ReplaceFileA(void)
     ret = ReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
     ok(!ret && (GetLastError() == ERROR_FILE_NOT_FOUND ||
         GetLastError() == ERROR_ACCESS_DENIED),
-        "ReplaceFileA: unexpected error %d\n", GetLastError());
+        "ReplaceFileA: unexpected error %ld\n", GetLastError());
     DeleteFileA( replacement );
 
     /*
@@ -3915,45 +3915,45 @@ static void test_ReplaceFileA(void)
         ret = DeleteFileA(backup);
         ok(ret ||
            broken(GetLastError() == ERROR_ACCESS_DENIED), /* win2k */
-           "DeleteFileA: error (backup) %d\n", GetLastError());
+           "DeleteFileA: error (backup) %ld\n", GetLastError());
     }
 
     ret = GetTempFileNameA(temp_path, prefix, 0, replaced);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     hReplacedFile = CreateFileA(replaced, 0, 0, NULL, OPEN_EXISTING, 0, 0);
-    ok(hReplacedFile != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
+    ok(hReplacedFile != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError());
 
     ret = GetTempFileNameA(temp_path, prefix, 0, replacement);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     ret = ReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     CloseHandle(hReplacedFile);
     ret = DeleteFileA(replaced);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     winetest_get_mainargs(&argv);
 
     ret = CopyFileA(argv[0], replaced, FALSE);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     hReplacedFile = CreateFileA(replaced, GENERIC_READ,
             FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, 0);
-    ok(hReplacedFile != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
+    ok(hReplacedFile != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError());
 
     mapping = CreateFileMappingA(hReplacedFile, NULL, PAGE_READONLY | SEC_IMAGE, 0, 0, NULL);
-    ok(!!mapping, "got error %u\n", GetLastError());
+    ok(!!mapping, "got error %lu\n", GetLastError());
 
     ret = GetTempFileNameA(temp_path, prefix, 0, replacement);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     ret = ReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     CloseHandle(mapping);
     CloseHandle(hReplacedFile);
     ret = DeleteFileA(replaced);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 }
 
 /*
@@ -3980,60 +3980,60 @@ static void test_ReplaceFileW(void)
         win_skip("GetTempPathW is not available\n");
         return;
     }
-    ok(ret != 0, "GetTempPathW error %d\n", GetLastError());
+    ok(ret != 0, "GetTempPathW error %ld\n", GetLastError());
     ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
 
     ret = GetTempFileNameW(temp_path, prefix, 0, replaced);
-    ok(ret != 0, "GetTempFileNameW error (replaced) %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameW error (replaced) %ld\n", GetLastError());
 
     ret = GetTempFileNameW(temp_path, prefix, 0, replacement);
-    ok(ret != 0, "GetTempFileNameW error (replacement) %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameW error (replacement) %ld\n", GetLastError());
 
     ret = GetTempFileNameW(temp_path, prefix, 0, backup);
-    ok(ret != 0, "GetTempFileNameW error (backup) %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameW error (backup) %ld\n", GetLastError());
 
     ret = pReplaceFileW(replaced, replacement, backup, 0, 0, 0);
-    ok(ret, "ReplaceFileW: error %d\n", GetLastError());
+    ok(ret, "ReplaceFileW: error %ld\n", GetLastError());
 
     ret = GetTempFileNameW(temp_path, prefix, 0, replacement);
-    ok(ret != 0, "GetTempFileNameW error (replacement) %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameW error (replacement) %ld\n", GetLastError());
     ret = pReplaceFileW(replaced, replacement, NULL, 0, 0, 0);
     ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
-       "ReplaceFileW: error %d\n", GetLastError());
+       "ReplaceFileW: error %ld\n", GetLastError());
 
     ret = GetTempFileNameW(temp_path, prefix, 0, replacement);
-    ok(ret != 0, "GetTempFileNameW error (replacement) %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameW error (replacement) %ld\n", GetLastError());
     ret = DeleteFileW(backup);
-    ok(ret, "DeleteFileW: error (backup) %d\n", GetLastError());
+    ok(ret, "DeleteFileW: error (backup) %ld\n", GetLastError());
     ret = pReplaceFileW(replaced, replacement, backup, 0, 0, 0);
     ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
-       "ReplaceFileW: error %d\n", GetLastError());
+       "ReplaceFileW: error %ld\n", GetLastError());
 
     ret = GetTempFileNameW(temp_path, prefix, 0, replacement);
-    ok(ret != 0, "GetTempFileNameW error (replacement) %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameW error (replacement) %ld\n", GetLastError());
     ret = SetFileAttributesW(replaced, FILE_ATTRIBUTE_READONLY);
     ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
-       "SetFileAttributesW: error setting to read only %d\n", GetLastError());
+       "SetFileAttributesW: error setting to read only %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pReplaceFileW(replaced, replacement, backup, 0, 0, 0);
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "got error %lu\n", GetLastError());
     ret = SetFileAttributesW(replaced, FILE_ATTRIBUTE_NORMAL);
     ok(ret || GetLastError() == ERROR_ACCESS_DENIED,
-       "SetFileAttributesW: error setting to normal %d\n", GetLastError());
+       "SetFileAttributesW: error setting to normal %ld\n", GetLastError());
     if (ret)
         removeBackup = TRUE;
 
     ret = DeleteFileW(replaced);
-    ok(ret, "DeleteFileW: error (replaced) %d\n", GetLastError());
+    ok(ret, "DeleteFileW: error (replaced) %ld\n", GetLastError());
     ret = pReplaceFileW(replaced, replacement, backup, 0, 0, 0);
-    ok(!ret, "ReplaceFileW: error %d\n", GetLastError());
+    ok(!ret, "ReplaceFileW: error %ld\n", GetLastError());
 
     ret = pReplaceFileW(replaced, replacement, NULL, 0, 0, 0);
     ok(!ret && (GetLastError() == ERROR_FILE_NOT_FOUND ||
        GetLastError() == ERROR_ACCESS_DENIED),
-        "ReplaceFileW: unexpected error %d\n", GetLastError());
+        "ReplaceFileW: unexpected error %ld\n", GetLastError());
     DeleteFileW( replacement );
 
     if (removeBackup)
@@ -4041,7 +4041,7 @@ static void test_ReplaceFileW(void)
         ret = DeleteFileW(backup);
         ok(ret ||
            broken(GetLastError() == ERROR_ACCESS_DENIED), /* win2k */
-           "DeleteFileW: error (backup) %d\n", GetLastError());
+           "DeleteFileW: error (backup) %ld\n", GetLastError());
     }
 }
 
@@ -4100,25 +4100,25 @@ static void test_CreateFile(void)
         {
             /* FIXME: remove once Wine is fixed */
             todo_wine_if (i == 5)
-            ok(GetLastError() == ERROR_INVALID_PARAMETER, "%d: expected ERROR_INVALID_PARAMETER, got %d\n", i, GetLastError());
+            ok(GetLastError() == ERROR_INVALID_PARAMETER, "%ld: expected ERROR_INVALID_PARAMETER, got %ld\n", i, GetLastError());
         }
         else
         {
             /* FIXME: remove once Wine is fixed */
             todo_wine_if (i == 1)
-            ok(GetLastError() == ERROR_ACCESS_DENIED, "%d: expected ERROR_ACCESS_DENIED, got %d\n", i, GetLastError());
+            ok(GetLastError() == ERROR_ACCESS_DENIED, "%ld: expected ERROR_ACCESS_DENIED, got %ld\n", i, GetLastError());
         }
 
         SetLastError(0xdeadbeef);
         hfile = CreateFileA(temp_path, GENERIC_WRITE, 0, NULL, i, 0, 0);
         ok(hfile == INVALID_HANDLE_VALUE, "CreateFile should fail\n");
         if (i == 0)
-            ok(GetLastError() == ERROR_INVALID_PARAMETER, "%d: expected ERROR_INVALID_PARAMETER, got %d\n", i, GetLastError());
+            ok(GetLastError() == ERROR_INVALID_PARAMETER, "%ld: expected ERROR_INVALID_PARAMETER, got %ld\n", i, GetLastError());
         else
         {
             /* FIXME: remove once Wine is fixed */
             todo_wine_if (i == 1)
-            ok(GetLastError() == ERROR_ACCESS_DENIED, "%d: expected ERROR_ACCESS_DENIED, got %d\n", i, GetLastError());
+            ok(GetLastError() == ERROR_ACCESS_DENIED, "%ld: expected ERROR_ACCESS_DENIED, got %ld\n", i, GetLastError());
         }
     }
 
@@ -4128,27 +4128,27 @@ static void test_CreateFile(void)
         hfile = CreateFileA(file_name, td[i].access, 0, NULL, td[i].disposition, 0, 0);
         if (!td[i].error)
         {
-            ok(hfile != INVALID_HANDLE_VALUE, "%d: CreateFile error %d\n", i, GetLastError());
+            ok(hfile != INVALID_HANDLE_VALUE, "%ld: CreateFile error %ld\n", i, GetLastError());
             written = 0xdeadbeef;
             SetLastError(0xdeadbeef);
             ret = WriteFile(hfile, &td[i].error, sizeof(td[i].error), &written, NULL);
             if (td[i].access & GENERIC_WRITE)
-                ok(ret, "%d: WriteFile error %d\n", i, GetLastError());
+                ok(ret, "%ld: WriteFile error %ld\n", i, GetLastError());
             else
             {
-                ok(!ret, "%d: WriteFile should fail\n", i);
-                ok(GetLastError() == ERROR_ACCESS_DENIED, "%d: expected ERROR_ACCESS_DENIED, got %d\n", i, GetLastError());
+                ok(!ret, "%ld: WriteFile should fail\n", i);
+                ok(GetLastError() == ERROR_ACCESS_DENIED, "%ld: expected ERROR_ACCESS_DENIED, got %ld\n", i, GetLastError());
             }
             SetLastError(0xdeadbeef);
             ret = SetFileTime(hfile, NULL, NULL, NULL);
             if (td[i].access & GENERIC_WRITE) /* actually FILE_WRITE_ATTRIBUTES */
-                ok(ret, "%d: SetFileTime error %d\n", i, GetLastError());
+                ok(ret, "%ld: SetFileTime error %ld\n", i, GetLastError());
             else
             {
                 todo_wine
                 {
-                ok(!ret, "%d: SetFileTime should fail\n", i);
-                ok(GetLastError() == ERROR_ACCESS_DENIED, "%d: expected ERROR_ACCESS_DENIED, got %d\n", i, GetLastError());
+                ok(!ret, "%ld: SetFileTime should fail\n", i);
+                ok(GetLastError() == ERROR_ACCESS_DENIED, "%ld: expected ERROR_ACCESS_DENIED, got %ld\n", i, GetLastError());
                 }
             }
             CloseHandle(hfile);
@@ -4160,15 +4160,15 @@ static void test_CreateFile(void)
             {
                 todo_wine
                 {
-                ok(hfile == INVALID_HANDLE_VALUE, "%d: CreateFile should fail\n", i);
-                ok(GetLastError() == td[i].error, "%d: expected %d, got %d\n", i, td[i].error, GetLastError());
+                ok(hfile == INVALID_HANDLE_VALUE, "%ld: CreateFile should fail\n", i);
+                ok(GetLastError() == td[i].error, "%ld: expected %ld, got %ld\n", i, td[i].error, GetLastError());
                 }
                 CloseHandle(hfile);
             }
             else
             {
-            ok(hfile == INVALID_HANDLE_VALUE, "%d: CreateFile should fail\n", i);
-            ok(GetLastError() == td[i].error, "%d: expected %d, got %d\n", i, td[i].error, GetLastError());
+            ok(hfile == INVALID_HANDLE_VALUE, "%ld: CreateFile should fail\n", i);
+            ok(GetLastError() == td[i].error, "%ld: expected %ld, got %ld\n", i, td[i].error, GetLastError());
             }
         }
 
@@ -4214,26 +4214,26 @@ static void test_GetFileInformationByHandleEx(void)
     }
 
     ret2 = GetTempPathA(sizeof(tempPath), tempPath);
-    ok(ret2, "GetFileInformationByHandleEx: GetTempPathA failed, got error %u.\n", GetLastError());
+    ok(ret2, "GetFileInformationByHandleEx: GetTempPathA failed, got error %lu.\n", GetLastError());
 
     /* ensure the existence of a file in the temp folder */
     ret2 = GetTempFileNameA(tempPath, "abc", 0, tempFileName);
-    ok(ret2, "GetFileInformationByHandleEx: GetTempFileNameA failed, got error %u.\n", GetLastError());
+    ok(ret2, "GetFileInformationByHandleEx: GetTempFileNameA failed, got error %lu.\n", GetLastError());
     ret2 = GetFileAttributesA(tempFileName);
     ok(ret2 != INVALID_FILE_ATTRIBUTES, "GetFileInformationByHandleEx: "
-        "GetFileAttributesA failed to find the temp file, got error %u.\n", GetLastError());
+        "GetFileAttributesA failed to find the temp file, got error %lu.\n", GetLastError());
 
     directory = CreateFileA(tempPath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
         NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
     ok(directory != INVALID_HANDLE_VALUE, "GetFileInformationByHandleEx: failed to open the temp folder, "
-        "got error %u.\n", GetLastError());
+        "got error %lu.\n", GetLastError());
 
     for (i = 0; i < ARRAY_SIZE(checks); i += 1)
     {
         SetLastError(0xdeadbeef);
         ret = pGetFileInformationByHandleEx(directory, checks[i].handleClass, checks[i].ptr, checks[i].size);
-        ok(!ret && GetLastError() == checks[i].errorCode, "GetFileInformationByHandleEx: expected error %u, "
-           "got %u.\n", checks[i].errorCode, GetLastError());
+        ok(!ret && GetLastError() == checks[i].errorCode, "GetFileInformationByHandleEx: expected error %lu, "
+           "got %lu.\n", checks[i].errorCode, GetLastError());
     }
 
     while (TRUE)
@@ -4242,7 +4242,7 @@ static void test_GetFileInformationByHandleEx(void)
         ret = pGetFileInformationByHandleEx(directory, FileIdBothDirectoryInfo, buffer, sizeof(buffer));
         if (!ret && GetLastError() == ERROR_NO_MORE_FILES)
             break;
-        ok(ret, "GetFileInformationByHandleEx: failed to query for FileIdBothDirectoryInfo, got error %u.\n", GetLastError());
+        ok(ret, "GetFileInformationByHandleEx: failed to query for FileIdBothDirectoryInfo, got error %lu.\n", GetLastError());
         if (!ret)
             break;
         bothDirInfo = (FILE_ID_BOTH_DIR_INFO *)buffer;
@@ -4262,12 +4262,12 @@ static void test_GetFileInformationByHandleEx(void)
     file = CreateFileA(tempFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
         NULL, OPEN_EXISTING, 0, NULL);
     ok(file != INVALID_HANDLE_VALUE, "GetFileInformationByHandleEx: failed to open the temp file, "
-        "got error %u.\n", GetLastError());
+        "got error %lu.\n", GetLastError());
 
     /* Test FileBasicInfo; make sure the write time changes when a file is updated */
     memset(buffer, 0xff, sizeof(buffer));
     ret = pGetFileInformationByHandleEx(file, FileBasicInfo, buffer, sizeof(buffer));
-    ok(ret, "GetFileInformationByHandleEx: failed to get FileBasicInfo, %u\n", GetLastError());
+    ok(ret, "GetFileInformationByHandleEx: failed to get FileBasicInfo, %lu\n", GetLastError());
     basicInfo = (FILE_BASIC_INFO *)buffer;
     prevWrite = basicInfo->LastWriteTime;
     CloseHandle(file);
@@ -4278,7 +4278,7 @@ static void test_GetFileInformationByHandleEx(void)
     file = CreateFileA(tempFileName, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
         NULL, OPEN_EXISTING, 0, NULL);
     ok(file != INVALID_HANDLE_VALUE, "GetFileInformationByHandleEx: failed to open the temp file, "
-        "got error %u.\n", GetLastError());
+        "got error %lu.\n", GetLastError());
     ret = WriteFile(file, tempFileName, strlen(tempFileName), &written, NULL);
     ok(ret, "GetFileInformationByHandleEx: Write failed\n");
     CloseHandle(file);
@@ -4286,11 +4286,11 @@ static void test_GetFileInformationByHandleEx(void)
     file = CreateFileA(tempFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
         NULL, OPEN_EXISTING, 0, NULL);
     ok(file != INVALID_HANDLE_VALUE, "GetFileInformationByHandleEx: failed to open the temp file, "
-        "got error %u.\n", GetLastError());
+        "got error %lu.\n", GetLastError());
 
     memset(buffer, 0xff, sizeof(buffer));
     ret = pGetFileInformationByHandleEx(file, FileBasicInfo, buffer, sizeof(buffer));
-    ok(ret, "GetFileInformationByHandleEx: failed to get FileBasicInfo, %u\n", GetLastError());
+    ok(ret, "GetFileInformationByHandleEx: failed to get FileBasicInfo, %lu\n", GetLastError());
     basicInfo = (FILE_BASIC_INFO *)buffer;
     /* Could also check that the creation time didn't change - on windows
      * it doesn't, but on wine, it does change even if it shouldn't. */
@@ -4300,7 +4300,7 @@ static void test_GetFileInformationByHandleEx(void)
     /* Test FileStandardInfo, check some basic parameters */
     memset(buffer, 0xff, sizeof(buffer));
     ret = pGetFileInformationByHandleEx(file, FileStandardInfo, buffer, sizeof(buffer));
-    ok(ret, "GetFileInformationByHandleEx: failed to get FileStandardInfo, %u\n", GetLastError());
+    ok(ret, "GetFileInformationByHandleEx: failed to get FileStandardInfo, %lu\n", GetLastError());
     standardInfo = (FILE_STANDARD_INFO *)buffer;
     ok(standardInfo->NumberOfLinks == 1, "GetFileInformationByHandleEx: Unexpected number of links\n");
     ok(standardInfo->DeletePending == FALSE, "GetFileInformationByHandleEx: Unexpected pending delete\n");
@@ -4309,7 +4309,7 @@ static void test_GetFileInformationByHandleEx(void)
     /* Test FileNameInfo */
     memset(buffer, 0xff, sizeof(buffer));
     ret = pGetFileInformationByHandleEx(file, FileNameInfo, buffer, sizeof(buffer));
-    ok(ret, "GetFileInformationByHandleEx: failed to get FileNameInfo, %u\n", GetLastError());
+    ok(ret, "GetFileInformationByHandleEx: failed to get FileNameInfo, %lu\n", GetLastError());
     nameInfo = (FILE_NAME_INFO *)buffer;
     strPtr = strchr(tempFileName, '\\');
     ok(strPtr != NULL, "GetFileInformationByHandleEx: Temp filename didn't contain backslash\n");
@@ -4322,23 +4322,23 @@ static void test_GetFileInformationByHandleEx(void)
     /* invalid classes */
     SetLastError(0xdeadbeef);
     ret = pGetFileInformationByHandleEx(file, FileEndOfFileInfo, &eofinfo, sizeof(eofinfo));
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %ld\n", ret, GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetFileInformationByHandleEx(file, FileIoPriorityHintInfo, &priohintinfo, sizeof(priohintinfo));
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %ld\n", ret, GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetFileInformationByHandleEx(file, FileAllocationInfo, &allocinfo, sizeof(allocinfo));
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %ld\n", ret, GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetFileInformationByHandleEx(file, FileDispositionInfo, &dispinfo, sizeof(dispinfo));
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %ld\n", ret, GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetFileInformationByHandleEx(file, FileRenameInfo, &renameinfo, sizeof(renameinfo));
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %ld\n", ret, GetLastError());
 
     CloseHandle(file);
     DeleteFileA(tempFileName);
@@ -4361,38 +4361,38 @@ static void test_OpenFileById(void)
     }
 
     ret2 = GetTempPathA(sizeof(tempPath), tempPath);
-    ok(ret2, "OpenFileById: GetTempPath failed, got error %u.\n", GetLastError());
+    ok(ret2, "OpenFileById: GetTempPath failed, got error %lu.\n", GetLastError());
 
     /* ensure the existence of a file in the temp folder */
     ret2 = GetTempFileNameA(tempPath, "abc", 0, tempFileName);
-    ok(ret2, "OpenFileById: GetTempFileNameA failed, got error %u.\n", GetLastError());
+    ok(ret2, "OpenFileById: GetTempFileNameA failed, got error %lu.\n", GetLastError());
     ret2 = GetFileAttributesA(tempFileName);
     ok(ret2 != INVALID_FILE_ATTRIBUTES,
-        "OpenFileById: GetFileAttributesA failed to find the temp file, got error %u\n", GetLastError());
+        "OpenFileById: GetFileAttributesA failed to find the temp file, got error %lu\n", GetLastError());
 
     ret2 = MultiByteToWideChar(CP_ACP, 0, tempFileName + strlen(tempPath), -1, tempFileNameW, ARRAY_SIZE(tempFileNameW));
-    ok(ret2, "OpenFileById: MultiByteToWideChar failed to convert tempFileName, got error %u.\n", GetLastError());
+    ok(ret2, "OpenFileById: MultiByteToWideChar failed to convert tempFileName, got error %lu.\n", GetLastError());
     tempFileNameLen = ret2 - 1;
 
     tempFile = CreateFileA(tempFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
     ok(tempFile != INVALID_HANDLE_VALUE, "OpenFileById: failed to create a temp file, "
-	    "got error %u.\n", GetLastError());
-    ret2 = sprintf(tickCount, "%u", GetTickCount());
+	    "got error %lu.\n", GetLastError());
+    ret2 = sprintf(tickCount, "%lu", GetTickCount());
     ret = WriteFile(tempFile, tickCount, ret2, &count, NULL);
-    ok(ret, "OpenFileById: WriteFile failed, got error %u.\n", GetLastError());
+    ok(ret, "OpenFileById: WriteFile failed, got error %lu.\n", GetLastError());
     CloseHandle(tempFile);
 
     directory = CreateFileA(tempPath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
         NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
     ok(directory != INVALID_HANDLE_VALUE, "OpenFileById: failed to open the temp folder, "
-        "got error %u.\n", GetLastError());
+        "got error %lu.\n", GetLastError());
 
     /* get info about the temp folder itself */
     bothDirInfo = (FILE_ID_BOTH_DIR_INFO *)buffer;
     ret = pGetFileInformationByHandleEx(directory, FileIdBothDirectoryInfo, buffer, sizeof(buffer));
-    ok(ret, "OpenFileById: failed to query for FileIdBothDirectoryInfo, got error %u.\n", GetLastError());
+    ok(ret, "OpenFileById: failed to query for FileIdBothDirectoryInfo, got error %lu.\n", GetLastError());
     ok(bothDirInfo->FileNameLength == sizeof(WCHAR) && bothDirInfo->FileName[0] == '.',
-        "OpenFileById: failed to return the temp folder at the first entry, got error %u.\n", GetLastError());
+        "OpenFileById: failed to return the temp folder at the first entry, got error %lu.\n", GetLastError());
 
     /* open the temp folder itself */
     fileIdDescr.dwSize    = sizeof(fileIdDescr);
@@ -4400,7 +4400,7 @@ static void test_OpenFileById(void)
     U(fileIdDescr).FileId = bothDirInfo->FileId;
     handle = pOpenFileById(directory, &fileIdDescr, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, 0);
     todo_wine
-    ok(handle != INVALID_HANDLE_VALUE, "OpenFileById: failed to open the temp folder itself, got error %u.\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "OpenFileById: failed to open the temp folder itself, got error %lu.\n", GetLastError());
     CloseHandle(handle);
 
     /* find the temp file in the temp folder */
@@ -4408,7 +4408,7 @@ static void test_OpenFileById(void)
     while (!found)
     {
         ret = pGetFileInformationByHandleEx(directory, FileIdBothDirectoryInfo, buffer, sizeof(buffer));
-        ok(ret, "OpenFileById: failed to query for FileIdBothDirectoryInfo, got error %u.\n", GetLastError());
+        ok(ret, "OpenFileById: failed to query for FileIdBothDirectoryInfo, got error %lu.\n", GetLastError());
         if (!ret)
             break;
         bothDirInfo = (FILE_ID_BOTH_DIR_INFO *)buffer;
@@ -4430,17 +4430,17 @@ static void test_OpenFileById(void)
     SetLastError(0xdeadbeef);
     handle = pOpenFileById(directory, NULL, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, 0);
     ok(handle == INVALID_HANDLE_VALUE && GetLastError() == ERROR_INVALID_PARAMETER,
-        "OpenFileById: expected ERROR_INVALID_PARAMETER, got error %u.\n", GetLastError());
+        "OpenFileById: expected ERROR_INVALID_PARAMETER, got error %lu.\n", GetLastError());
 
     fileIdDescr.dwSize    = sizeof(fileIdDescr);
     fileIdDescr.Type      = FileIdType;
     U(fileIdDescr).FileId = bothDirInfo->FileId;
     handle = pOpenFileById(directory, &fileIdDescr, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, 0);
-    ok(handle != INVALID_HANDLE_VALUE, "OpenFileById: failed to open the file, got error %u.\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "OpenFileById: failed to open the file, got error %lu.\n", GetLastError());
 
     ret = ReadFile(handle, buffer, sizeof(buffer), &count, NULL);
     buffer[count] = 0;
-    ok(ret, "OpenFileById: ReadFile failed, got error %u.\n", GetLastError());
+    ok(ret, "OpenFileById: ReadFile failed, got error %lu.\n", GetLastError());
     ok(strcmp(tickCount, buffer) == 0, "OpenFileById: invalid contents of the temp file.\n");
 
     CloseHandle(handle);
@@ -4472,13 +4472,13 @@ static void test_SetFileValidData(void)
     ret = pSetFileValidData(INVALID_HANDLE_VALUE, 0);
     error = GetLastError();
     ok(!ret, "SetFileValidData succeeded\n");
-    ok(error == ERROR_INVALID_HANDLE, "got %u\n", error);
+    ok(error == ERROR_INVALID_HANDLE, "got %lu\n", error);
 
     SetLastError(0xdeadbeef);
     ret = pSetFileValidData(INVALID_HANDLE_VALUE, -1);
     error = GetLastError();
     ok(!ret, "SetFileValidData succeeded\n");
-    ok(error == ERROR_INVALID_HANDLE, "got %u\n", error);
+    ok(error == ERROR_INVALID_HANDLE, "got %lu\n", error);
 
     /* file opened for reading */
     handle = CreateFileA(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
@@ -4487,13 +4487,13 @@ static void test_SetFileValidData(void)
     ret = pSetFileValidData(handle, 0);
     ok(!ret, "SetFileValidData succeeded\n");
     error = GetLastError();
-    ok(error == ERROR_ACCESS_DENIED, "got %u\n", error);
+    ok(error == ERROR_ACCESS_DENIED, "got %lu\n", error);
 
     SetLastError(0xdeadbeef);
     ret = pSetFileValidData(handle, -1);
     error = GetLastError();
     ok(!ret, "SetFileValidData succeeded\n");
-    ok(error == ERROR_ACCESS_DENIED, "got %u\n", error);
+    ok(error == ERROR_ACCESS_DENIED, "got %lu\n", error);
     CloseHandle(handle);
 
     handle = CreateFileA(filename, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
@@ -4502,7 +4502,7 @@ static void test_SetFileValidData(void)
     ret = pSetFileValidData(handle, 0);
     error = GetLastError();
     ok(!ret, "SetFileValidData succeeded\n");
-    todo_wine ok(error == ERROR_PRIVILEGE_NOT_HELD, "got %u\n", error);
+    todo_wine ok(error == ERROR_PRIVILEGE_NOT_HELD, "got %lu\n", error);
     CloseHandle(handle);
 
     privs.PrivilegeCount = 1;
@@ -4524,58 +4524,58 @@ static void test_SetFileValidData(void)
     ret = pSetFileValidData(handle, 0);
     error = GetLastError();
     ok(!ret, "SetFileValidData succeeded\n");
-    ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
+    ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
 
     SetLastError(0xdeadbeef);
     ret = pSetFileValidData(handle, -1);
     error = GetLastError();
     ok(!ret, "SetFileValidData succeeded\n");
-    ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
+    ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
 
     SetLastError(0xdeadbeef);
     ret = pSetFileValidData(handle, 2);
     error = GetLastError();
     todo_wine ok(!ret, "SetFileValidData succeeded\n");
-    todo_wine ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
+    todo_wine ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
 
     ret = pSetFileValidData(handle, 4);
-    ok(ret, "SetFileValidData failed %u\n", GetLastError());
+    ok(ret, "SetFileValidData failed %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pSetFileValidData(handle, 8);
     error = GetLastError();
     ok(!ret, "SetFileValidData succeeded\n");
-    ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
+    ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
 
     count = SetFilePointer(handle, 1024, NULL, FILE_END);
-    ok(count != INVALID_SET_FILE_POINTER, "SetFilePointer failed %u\n", GetLastError());
+    ok(count != INVALID_SET_FILE_POINTER, "SetFilePointer failed %lu\n", GetLastError());
     ret = SetEndOfFile(handle);
-    ok(ret, "SetEndOfFile failed %u\n", GetLastError());
+    ok(ret, "SetEndOfFile failed %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pSetFileValidData(handle, 2);
     error = GetLastError();
     todo_wine ok(!ret, "SetFileValidData succeeded\n");
-    todo_wine ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
+    todo_wine ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
 
     ret = pSetFileValidData(handle, 4);
-    ok(ret, "SetFileValidData failed %u\n", GetLastError());
+    ok(ret, "SetFileValidData failed %lu\n", GetLastError());
 
     ret = pSetFileValidData(handle, 8);
-    ok(ret, "SetFileValidData failed %u\n", GetLastError());
+    ok(ret, "SetFileValidData failed %lu\n", GetLastError());
 
     ret = pSetFileValidData(handle, 4);
     error = GetLastError();
     todo_wine ok(!ret, "SetFileValidData succeeded\n");
-    todo_wine ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
+    todo_wine ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
 
     ret = pSetFileValidData(handle, 1024);
-    ok(ret, "SetFileValidData failed %u\n", GetLastError());
+    ok(ret, "SetFileValidData failed %lu\n", GetLastError());
 
     ret = pSetFileValidData(handle, 2048);
     error = GetLastError();
     ok(!ret, "SetFileValidData succeeded\n");
-    ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
+    ok(error == ERROR_INVALID_PARAMETER, "got %lu\n", error);
 
     privs.Privileges[0].Attributes = 0;
     AdjustTokenPrivileges(token, FALSE, &privs, sizeof(privs), NULL, NULL);
@@ -4626,54 +4626,54 @@ static void test_ReOpenFile(void)
 
     file = CreateFileA(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL,
                        CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
-    ok(file != INVALID_HANDLE_VALUE, "failed to create file, error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "failed to create file, error %lu\n", GetLastError());
     ret = WriteFile(file, "foo", 4, &size, NULL);
-    ok(ret, "failed to write file, error %u\n", GetLastError());
+    ok(ret, "failed to write file, error %lu\n", GetLastError());
 
     for (i = 0; i < ARRAY_SIZE(invalid_attributes); ++i)
     {
         SetLastError(0xdeadbeef);
         new = pReOpenFile(file, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, invalid_attributes[i]);
         ok(new == INVALID_HANDLE_VALUE, "got %p\n", new);
-        ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %u\n", GetLastError());
+        ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %lu\n", GetLastError());
     }
 
     new = pReOpenFile(file, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0);
-    ok(new != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
+    ok(new != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError());
 
     ret = ReadFile(new, buffer, sizeof(buffer), &size, NULL);
-    ok(ret, "failed to read file, error %u\n", GetLastError());
-    ok(size == 4, "got size %u\n", size);
+    ok(ret, "failed to read file, error %lu\n", GetLastError());
+    ok(size == 4, "got size %lu\n", size);
     ok(!strcmp(buffer, "foo"), "got wrong data\n");
     CloseHandle(new);
 
     for (i = 0; i < ARRAY_SIZE(valid_attributes); ++i)
     {
         new = pReOpenFile(file, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, valid_attributes[i]);
-        ok(new != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
+        ok(new != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError());
         CloseHandle(new);
     }
 
     SetLastError(0xdeadbeef);
     new = pReOpenFile(file, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0);
     ok(new == INVALID_HANDLE_VALUE, "got %p\n", new);
-    ok(GetLastError() == ERROR_SHARING_VIOLATION, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_SHARING_VIOLATION, "got error %lu\n", GetLastError());
 
     CloseHandle(file);
     ret = DeleteFileA(filename);
-    ok(ret, "failed to delete file, error %u\n", GetLastError());
+    ok(ret, "failed to delete file, error %lu\n", GetLastError());
 
     file = CreateNamedPipeA("\\\\.\\pipe\\test_pipe", PIPE_ACCESS_DUPLEX, 0, 1, 1000, 1000, 1000, NULL);
-    ok(file != INVALID_HANDLE_VALUE, "failed to create pipe, error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "failed to create pipe, error %lu\n", GetLastError());
 
     new = pReOpenFile(file, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0);
-    ok(new != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
+    ok(new != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError());
 
     ret = WriteFile(file, "foo", 4, &size, NULL);
-    ok(ret, "failed to write file, error %u\n", GetLastError());
+    ok(ret, "failed to write file, error %lu\n", GetLastError());
     ret = ReadFile(new, buffer, sizeof(buffer), &size, NULL);
-    ok(ret, "failed to read file, error %u\n", GetLastError());
-    ok(size == 4, "got size %u\n", size);
+    ok(ret, "failed to read file, error %lu\n", GetLastError());
+    ok(size == 4, "got size %lu\n", size);
     ok(!strcmp(buffer, "foo"), "got wrong data\n");
 
     CloseHandle(new);
@@ -4695,29 +4695,29 @@ static void test_WriteFileGather(void)
     evt = CreateEventW( NULL, TRUE, FALSE, NULL );
 
     ret = GetTempPathA( MAX_PATH, temp_path );
-    ok( ret != 0, "GetTempPathA error %d\n", GetLastError() );
+    ok( ret != 0, "GetTempPathA error %ld\n", GetLastError() );
     ok( ret < MAX_PATH, "temp path should fit into MAX_PATH\n" );
     ret = GetTempFileNameA( temp_path, "wfg", 0, filename );
-    ok( ret != 0, "GetTempFileNameA error %d\n", GetLastError() );
+    ok( ret != 0, "GetTempFileNameA error %ld\n", GetLastError() );
 
     hfile = CreateFileA( filename, GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_ALWAYS,
                          FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED | FILE_ATTRIBUTE_NORMAL, 0 );
-    ok( hfile != INVALID_HANDLE_VALUE, "CreateFile failed err %u\n", GetLastError() );
+    ok( hfile != INVALID_HANDLE_VALUE, "CreateFile failed err %lu\n", GetLastError() );
     if (hfile == INVALID_HANDLE_VALUE) return;
 
     hiocp1 = CreateIoCompletionPort( INVALID_HANDLE_VALUE, NULL, 999, 0 );
     hiocp2 = CreateIoCompletionPort( hfile, hiocp1, 999, 0 );
-    ok( hiocp2 != 0, "CreateIoCompletionPort failed err %u\n", GetLastError() );
+    ok( hiocp2 != 0, "CreateIoCompletionPort failed err %lu\n", GetLastError() );
 
     GetSystemInfo( &si );
     wbuf = VirtualAlloc( NULL, si.dwPageSize, MEM_COMMIT, PAGE_READWRITE );
-    ok( wbuf != NULL, "VirtualAlloc failed err %u\n", GetLastError() );
+    ok( wbuf != NULL, "VirtualAlloc failed err %lu\n", GetLastError() );
 
     rbuf1 = VirtualAlloc( NULL, si.dwPageSize, MEM_COMMIT, PAGE_READWRITE );
-    ok( rbuf1 != NULL, "VirtualAlloc failed err %u\n", GetLastError() );
+    ok( rbuf1 != NULL, "VirtualAlloc failed err %lu\n", GetLastError() );
 
     rbuf2 = VirtualAlloc( NULL, si.dwPageSize, MEM_COMMIT, PAGE_READWRITE );
-    ok( rbuf2 != NULL, "VirtualAlloc failed err %u\n", GetLastError() );
+    ok( rbuf2 != NULL, "VirtualAlloc failed err %lu\n", GetLastError() );
 
     memset( &ovl, 0, sizeof(ovl) );
     ovl.hEvent = evt;
@@ -4726,16 +4726,16 @@ static void test_WriteFileGather(void)
     memset( wbuf, 0x42, si.dwPageSize );
     SetLastError( 0xdeadbeef );
     if (!WriteFileGather( hfile, fse, si.dwPageSize, NULL, &ovl ))
-        ok( GetLastError() == ERROR_IO_PENDING, "WriteFileGather failed err %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_IO_PENDING, "WriteFileGather failed err %lu\n", GetLastError() );
 
     ret = GetQueuedCompletionStatus( hiocp2, &size, &key, &povl, 1000 );
-    ok( ret, "GetQueuedCompletionStatus failed err %u\n", GetLastError());
+    ok( ret, "GetQueuedCompletionStatus failed err %lu\n", GetLastError());
     ok( povl == &ovl, "wrong ovl %p\n", povl );
 
     tx = 0;
     br = GetOverlappedResult( hfile, &ovl, &tx, TRUE );
-    ok( br == TRUE, "GetOverlappedResult failed: %u\n", GetLastError() );
-    ok( tx == si.dwPageSize, "got unexpected bytes transferred: %u\n", tx );
+    ok( br == TRUE, "GetOverlappedResult failed: %lu\n", GetLastError() );
+    ok( tx == si.dwPageSize, "got unexpected bytes transferred: %lu\n", tx );
 
     ResetEvent( evt );
 
@@ -4748,16 +4748,16 @@ static void test_WriteFileGather(void)
     SetLastError( 0xdeadbeef );
     br = ReadFileScatter( hfile, fse, si.dwPageSize, NULL, &ovl );
     ok( br == FALSE, "ReadFileScatter should be asynchronous\n" );
-    ok( GetLastError() == ERROR_IO_PENDING, "ReadFileScatter failed err %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_IO_PENDING, "ReadFileScatter failed err %lu\n", GetLastError() );
 
     ret = GetQueuedCompletionStatus( hiocp2, &size, &key, &povl, 1000 );
-    ok( ret, "GetQueuedCompletionStatus failed err %u\n", GetLastError());
+    ok( ret, "GetQueuedCompletionStatus failed err %lu\n", GetLastError());
     ok( povl == &ovl, "wrong ovl %p\n", povl );
 
     tx = 0;
     br = GetOverlappedResult( hfile, &ovl, &tx, TRUE );
-    ok( br == TRUE, "GetOverlappedResult failed: %u\n", GetLastError() );
-    ok( tx == si.dwPageSize, "got unexpected bytes transferred: %u\n", tx );
+    ok( br == TRUE, "GetOverlappedResult failed: %lu\n", GetLastError() );
+    ok( tx == si.dwPageSize, "got unexpected bytes transferred: %lu\n", tx );
 
     ok( memcmp( rbuf1, wbuf, si.dwPageSize ) == 0,
             "data was not read into buffer\n" );
@@ -4775,26 +4775,26 @@ static void test_WriteFileGather(void)
     br = ReadFileScatter( hfile, fse, si.dwPageSize, NULL, &ovl );
     ok( br == FALSE, "ReadFileScatter should have failed\n" );
     ok( GetLastError() == ERROR_HANDLE_EOF ||
-            GetLastError() == ERROR_IO_PENDING, "ReadFileScatter gave wrong error %u\n", GetLastError() );
+            GetLastError() == ERROR_IO_PENDING, "ReadFileScatter gave wrong error %lu\n", GetLastError() );
     if (GetLastError() == ERROR_IO_PENDING)
     {
         SetLastError( 0xdeadbeef );
         ret = GetQueuedCompletionStatus( hiocp2, &size, &key, &povl, 1000 );
         ok( !ret, "GetQueuedCompletionStatus should have returned failure\n" );
-        ok( GetLastError() == ERROR_HANDLE_EOF, "Got wrong error: %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_HANDLE_EOF, "Got wrong error: %lu\n", GetLastError() );
         ok( povl == &ovl, "wrong ovl %p\n", povl );
 
         SetLastError( 0xdeadbeef );
         br = GetOverlappedResult( hfile, &ovl, &tx, TRUE );
         ok( br == FALSE, "GetOverlappedResult should have failed\n" );
-        ok( GetLastError() == ERROR_HANDLE_EOF, "Got wrong error: %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_HANDLE_EOF, "Got wrong error: %lu\n", GetLastError() );
     }
     else
     {
         SetLastError( 0xdeadbeef );
         ret = GetQueuedCompletionStatus( hiocp2, &size, &key, &povl, 100 );
-        ok( !ret, "GetQueuedCompletionStatus failed err %u\n", GetLastError() );
-        ok( GetLastError() == WAIT_TIMEOUT, "GetQueuedCompletionStatus gave wrong error %u\n", GetLastError() );
+        ok( !ret, "GetQueuedCompletionStatus failed err %lu\n", GetLastError() );
+        ok( GetLastError() == WAIT_TIMEOUT, "GetQueuedCompletionStatus gave wrong error %lu\n", GetLastError() );
         ok( povl == NULL, "wrong ovl %p\n", povl );
     }
 
@@ -4811,16 +4811,16 @@ static void test_WriteFileGather(void)
     SetLastError( 0xdeadbeef );
     br = ReadFileScatter( hfile, fse, si.dwPageSize * 2, NULL, &ovl );
     ok( br == FALSE, "ReadFileScatter should be asynchronous\n" );
-    ok( GetLastError() == ERROR_IO_PENDING, "ReadFileScatter failed err %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_IO_PENDING, "ReadFileScatter failed err %lu\n", GetLastError() );
 
     ret = GetQueuedCompletionStatus( hiocp2, &size, &key, &povl, 1000 );
-    ok( ret, "GetQueuedCompletionStatus failed err %u\n", GetLastError() );
+    ok( ret, "GetQueuedCompletionStatus failed err %lu\n", GetLastError() );
     ok( povl == &ovl, "wrong ovl %p\n", povl );
 
     tx = 0;
     br = GetOverlappedResult( hfile, &ovl, &tx, TRUE );
-    ok( br == TRUE, "GetOverlappedResult failed: %u\n", GetLastError() );
-    ok( tx == si.dwPageSize, "got unexpected bytes transferred: %u\n", tx );
+    ok( br == TRUE, "GetOverlappedResult failed: %lu\n", GetLastError() );
+    ok( tx == si.dwPageSize, "got unexpected bytes transferred: %lu\n", tx );
 
     ok( memcmp( rbuf1, wbuf, si.dwPageSize ) == 0,
             "data was not read into buffer\n" );
@@ -4839,16 +4839,16 @@ static void test_WriteFileGather(void)
     SetLastError( 0xdeadbeef );
     br = ReadFileScatter( hfile, fse, si.dwPageSize / 2, NULL, &ovl );
     ok( br == FALSE, "ReadFileScatter should be asynchronous\n" );
-    ok( GetLastError() == ERROR_IO_PENDING, "ReadFileScatter failed err %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_IO_PENDING, "ReadFileScatter failed err %lu\n", GetLastError() );
 
     ret = GetQueuedCompletionStatus( hiocp2, &size, &key, &povl, 1000 );
-    ok( ret, "GetQueuedCompletionStatus failed err %u\n", GetLastError() );
+    ok( ret, "GetQueuedCompletionStatus failed err %lu\n", GetLastError() );
     ok( povl == &ovl, "wrong ovl %p\n", povl );
 
     tx = 0;
     br = GetOverlappedResult( hfile, &ovl, &tx, TRUE );
-    ok( br == TRUE, "GetOverlappedResult failed: %u\n", GetLastError() );
-    ok( tx == si.dwPageSize / 2, "got unexpected bytes transferred: %u\n", tx );
+    ok( br == TRUE, "GetOverlappedResult failed: %lu\n", GetLastError() );
+    ok( tx == si.dwPageSize / 2, "got unexpected bytes transferred: %lu\n", tx );
 
     ok( memcmp( rbuf1, wbuf, si.dwPageSize / 2 ) == 0,
             "invalid data was read into buffer\n" );
@@ -4859,19 +4859,19 @@ static void test_WriteFileGather(void)
     if (pSetFileCompletionNotificationModes)
     {
         br = pSetFileCompletionNotificationModes(hfile, FILE_SKIP_COMPLETION_PORT_ON_SUCCESS);
-        ok(br, "SetFileCompletionNotificationModes failed, error %u.\n", GetLastError());
+        ok(br, "SetFileCompletionNotificationModes failed, error %lu.\n", GetLastError());
 
         br = ReadFileScatter(hfile, fse, si.dwPageSize, NULL, &ovl);
         ok(br == FALSE, "ReadFileScatter should be asynchronous.\n");
-        ok(GetLastError() == ERROR_IO_PENDING, "ReadFileScatter failed, error %u.\n", GetLastError());
+        ok(GetLastError() == ERROR_IO_PENDING, "ReadFileScatter failed, error %lu.\n", GetLastError());
 
         br = GetQueuedCompletionStatus(hiocp2, &size, &key, &povl, 1000);
-        ok(br, "GetQueuedCompletionStatus failed, err %u.\n", GetLastError());
+        ok(br, "GetQueuedCompletionStatus failed, err %lu.\n", GetLastError());
         ok(povl == &ovl, "Wrong ovl %p.\n", povl);
 
         br = GetOverlappedResult(hfile, &ovl, &tx, TRUE);
-        ok(br, "GetOverlappedResult failed, err %u.\n", GetLastError());
-        ok(tx == si.dwPageSize, "Got unexpected size %u.\n", tx);
+        ok(br, "GetOverlappedResult failed, err %lu.\n", GetLastError());
+        ok(tx == si.dwPageSize, "Got unexpected size %lu.\n", tx);
 
         ResetEvent(evt);
     }
@@ -4885,7 +4885,7 @@ static void test_WriteFileGather(void)
     /* file handle must be overlapped */
     hfile = CreateFileA( filename, GENERIC_READ, 0, 0, OPEN_EXISTING,
                          FILE_FLAG_NO_BUFFERING | FILE_ATTRIBUTE_NORMAL, 0 );
-    ok( hfile != INVALID_HANDLE_VALUE, "CreateFile failed err %u\n", GetLastError() );
+    ok( hfile != INVALID_HANDLE_VALUE, "CreateFile failed err %lu\n", GetLastError() );
 
     memset( &ovl, 0, sizeof(ovl) );
     memset( fse, 0, sizeof(fse) );
@@ -4894,7 +4894,7 @@ static void test_WriteFileGather(void)
     SetLastError( 0xdeadbeef );
     br = ReadFileScatter( hfile, fse, si.dwPageSize, NULL, &ovl );
     ok( br == FALSE, "ReadFileScatter should fail\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "ReadFileScatter failed err %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "ReadFileScatter failed err %lu\n", GetLastError() );
 
     VirtualFree( wbuf, 0, MEM_RELEASE );
     VirtualFree( rbuf1, 0, MEM_RELEASE );
@@ -4952,12 +4952,12 @@ static void test_file_access(void)
                            FILE_FLAG_DELETE_ON_CLOSE, 0);
         if (td[i].create_error)
         {
-            ok(hfile == INVALID_HANDLE_VALUE, "%d: CreateFile should fail\n", i);
-            ok(td[i].create_error == GetLastError(), "%d: expected %d, got %d\n", i, td[i].create_error, GetLastError());
+            ok(hfile == INVALID_HANDLE_VALUE, "%ld: CreateFile should fail\n", i);
+            ok(td[i].create_error == GetLastError(), "%ld: expected %d, got %ld\n", i, td[i].create_error, GetLastError());
             continue;
         }
         else
-            ok(hfile != INVALID_HANDLE_VALUE, "%d: CreateFile error %d\n", i, GetLastError());
+            ok(hfile != INVALID_HANDLE_VALUE, "%ld: CreateFile error %ld\n", i, GetLastError());
 
         for (j = 0; j < ARRAY_SIZE(td); j++)
         {
@@ -4965,7 +4965,7 @@ static void test_file_access(void)
             ret = DuplicateHandle(GetCurrentProcess(), hfile, GetCurrentProcess(), &hdup,
                                   td[j].access, 0, 0);
             if (is_access_compatible(td[i].access, td[j].access))
-                ok(ret, "DuplicateHandle(%#x => %#x) error %d\n", td[i].access, td[j].access, GetLastError());
+                ok(ret, "DuplicateHandle(%#x => %#x) error %ld\n", td[i].access, td[j].access, GetLastError());
             else
             {
                 /* FIXME: Remove once Wine is fixed */
@@ -4975,7 +4975,7 @@ static void test_file_access(void)
                              (!(td[i].access & (GENERIC_WRITE)) && (td[j].access & FILE_APPEND_DATA))))
                 {
                 ok(!ret, "DuplicateHandle(%#x => %#x) should fail\n", td[i].access, td[j].access);
-                ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+                ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
                 }
             }
             if (ret) CloseHandle(hdup);
@@ -4986,38 +4986,38 @@ static void test_file_access(void)
         ret = WriteFile(hfile, "\x5e\xa7", 2, &bytes, NULL);
         if (td[i].write_error)
         {
-            ok(!ret, "%d: WriteFile should fail\n", i);
-            ok(td[i].write_error == GetLastError(), "%d: expected %d, got %d\n", i, td[i].write_error, GetLastError());
-            ok(bytes == 0, "%d: expected 0, got %u\n", i, bytes);
+            ok(!ret, "%ld: WriteFile should fail\n", i);
+            ok(td[i].write_error == GetLastError(), "%ld: expected %d, got %ld\n", i, td[i].write_error, GetLastError());
+            ok(bytes == 0, "%ld: expected 0, got %lu\n", i, bytes);
         }
         else
         {
-            ok(ret, "%d: WriteFile error %d\n", i, GetLastError());
-            ok(bytes == 2, "%d: expected 2, got %u\n", i, bytes);
+            ok(ret, "%ld: WriteFile error %ld\n", i, GetLastError());
+            ok(bytes == 2, "%ld: expected 2, got %lu\n", i, bytes);
         }
 
         SetLastError(0xdeadbeef);
         ret = SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
-        ok(ret != INVALID_SET_FILE_POINTER, "SetFilePointer error %d\n", GetLastError());
+        ok(ret != INVALID_SET_FILE_POINTER, "SetFilePointer error %ld\n", GetLastError());
 
         SetLastError(0xdeadbeef);
         bytes = 0xdeadbeef;
         ret = ReadFile(hfile, buf, sizeof(buf), &bytes, NULL);
         if (td[i].read_error)
         {
-            ok(!ret, "%d: ReadFile should fail\n", i);
-            ok(td[i].read_error == GetLastError(), "%d: expected %d, got %d\n", i, td[i].read_error, GetLastError());
-            ok(bytes == 0, "%d: expected 0, got %u\n", i, bytes);
+            ok(!ret, "%ld: ReadFile should fail\n", i);
+            ok(td[i].read_error == GetLastError(), "%ld: expected %d, got %ld\n", i, td[i].read_error, GetLastError());
+            ok(bytes == 0, "%ld: expected 0, got %lu\n", i, bytes);
         }
         else
         {
-            ok(ret, "%d: ReadFile error %d\n", i, GetLastError());
+            ok(ret, "%ld: ReadFile error %ld\n", i, GetLastError());
             if (td[i].write_error)
-                ok(bytes == 0, "%d: expected 0, got %u\n", i, bytes);
+                ok(bytes == 0, "%ld: expected 0, got %lu\n", i, bytes);
             else
             {
-                ok(bytes == 2, "%d: expected 2, got %u\n", i, bytes);
-                ok(buf[0] == 0x5e && buf[1] == 0xa7, "%d: expected 5ea7, got %02x%02x\n", i, buf[0], buf[1]);
+                ok(bytes == 2, "%ld: expected 2, got %lu\n", i, bytes);
+                ok(buf[0] == 0x5e && buf[1] == 0xa7, "%ld: expected 5ea7, got %02x%02x\n", i, buf[0], buf[1]);
             }
         }
 
@@ -5045,66 +5045,66 @@ static void test_GetFinalPathNameByHandleA(void)
     /* Test calling with INVALID_HANDLE_VALUE */
     SetLastError(0xdeadbeaf);
     count = pGetFinalPathNameByHandleA(INVALID_HANDLE_VALUE, result_path, MAX_PATH, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-    ok(count == 0, "Expected length 0, got %u\n", count);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %u\n", GetLastError());
+    ok(count == 0, "Expected length 0, got %lu\n", count);
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %lu\n", GetLastError());
 
     count = GetTempPathA(MAX_PATH, temp_path);
-    ok(count, "Failed to get temp path, error %u\n", GetLastError());
+    ok(count, "Failed to get temp path, error %lu\n", GetLastError());
     ret = GetTempFileNameA(temp_path, prefix, 0, test_path);
-    ok(ret != 0, "GetTempFileNameA error %u\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error %lu\n", GetLastError());
     ret = GetLongPathNameA(test_path, long_path, MAX_PATH);
-    ok(ret != 0, "GetLongPathNameA error %u\n", GetLastError());
+    ok(ret != 0, "GetLongPathNameA error %lu\n", GetLastError());
     strcpy(dos_path, dos_prefix);
     strcat(dos_path, long_path);
 
     count = pGetFinalPathNameByHandleA(INVALID_HANDLE_VALUE, NULL, 0, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-    ok(count == 0, "Expected length 0, got %u\n", count);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %u\n", GetLastError());
+    ok(count == 0, "Expected length 0, got %lu\n", count);
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %lu\n", GetLastError());
 
     file = CreateFileA(test_path, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                        CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, 0);
-    ok(file != INVALID_HANDLE_VALUE, "CreateFileA error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "CreateFileA error %lu\n", GetLastError());
 
     if (0) {
         /* Windows crashes on NULL path */
         count = pGetFinalPathNameByHandleA(file, NULL, MAX_PATH, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-        ok(count == 0, "Expected length 0, got %u\n", count);
-        ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %u\n", GetLastError());
+        ok(count == 0, "Expected length 0, got %lu\n", count);
+        ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %lu\n", GetLastError());
     }
 
     /* Test 0-length path */
     count = pGetFinalPathNameByHandleA(file, result_path, 0, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-    ok(count == strlen(dos_path), "Expected length %u, got %u\n", lstrlenA(dos_path), count);
+    ok(count == strlen(dos_path), "Expected length %u, got %lu\n", lstrlenA(dos_path), count);
 
     /* Test 0 and NULL path */
     count = pGetFinalPathNameByHandleA(file, NULL, 0, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-    ok(count == strlen(dos_path), "Expected length %u, got %u\n", lstrlenA(dos_path), count);
+    ok(count == strlen(dos_path), "Expected length %u, got %lu\n", lstrlenA(dos_path), count);
 
     /* Test VOLUME_NAME_DOS with sufficient buffer size */
     memset(result_path, 0x11, sizeof(result_path));
     count = pGetFinalPathNameByHandleA(file, result_path, MAX_PATH, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-    ok(count == strlen(dos_path), "Expected length %u, got %u\n", (DWORD)strlen(dos_path), count);
+    ok(count == strlen(dos_path), "Expected length %lu, got %lu\n", (DWORD)strlen(dos_path), count);
     ok(lstrcmpiA(dos_path, result_path) == 0, "Expected %s, got %s\n", dos_path, result_path);
 
     /* Test VOLUME_NAME_DOS with insufficient buffer size */
     memset(result_path, 0x11, sizeof(result_path));
     count = pGetFinalPathNameByHandleA(file, result_path, strlen(dos_path)-2, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-    ok(count == strlen(dos_path), "Expected length %u, got %u\n", (DWORD)strlen(dos_path), count);
+    ok(count == strlen(dos_path), "Expected length %lu, got %lu\n", (DWORD)strlen(dos_path), count);
     ok(result_path[0] == 0x11, "Result path was modified\n");
 
     memset(result_path, 0x11, sizeof(result_path));
     count = pGetFinalPathNameByHandleA(file, result_path, strlen(dos_path)-1, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-    ok(count == strlen(dos_path), "Expected length %u, got %u\n", (DWORD)strlen(dos_path), count);
+    ok(count == strlen(dos_path), "Expected length %lu, got %lu\n", (DWORD)strlen(dos_path), count);
     ok(result_path[0] == 0x11, "Result path was modified\n");
 
     memset(result_path, 0x11, sizeof(result_path));
     count = pGetFinalPathNameByHandleA(file, result_path, strlen(dos_path), FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-    ok(count == strlen(dos_path), "Expected length %u, got %u\n", (DWORD)strlen(dos_path), count);
+    ok(count == strlen(dos_path), "Expected length %lu, got %lu\n", (DWORD)strlen(dos_path), count);
     ok(result_path[0] == 0x11, "Result path was modified\n");
 
     memset(result_path, 0x11, sizeof(result_path));
     count = pGetFinalPathNameByHandleA(file, result_path, strlen(dos_path)+1, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-    ok(count == strlen(dos_path), "Expected length %u, got %u\n", (DWORD)strlen(dos_path), count);
+    ok(count == strlen(dos_path), "Expected length %lu, got %lu\n", (DWORD)strlen(dos_path), count);
     ok(result_path[0] != 0x11, "Result path was not modified\n");
     ok(!result_path[strlen(dos_path)], "Expected nullterminated string\n");
     ok(result_path[strlen(dos_path)+1] == 0x11, "Buffer overflow\n");
@@ -5138,77 +5138,77 @@ static void test_GetFinalPathNameByHandleW(void)
     /* Test calling with INVALID_HANDLE_VALUE */
     SetLastError(0xdeadbeaf);
     count = pGetFinalPathNameByHandleW(INVALID_HANDLE_VALUE, result_path, MAX_PATH, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-    ok(count == 0, "Expected length 0, got %u\n", count);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %u\n", GetLastError());
+    ok(count == 0, "Expected length 0, got %lu\n", count);
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %lu\n", GetLastError());
 
     count = pGetFinalPathNameByHandleW(INVALID_HANDLE_VALUE, NULL, 0, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-    ok(count == 0, "Expected length 0, got %u\n", count);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %u\n", GetLastError());
+    ok(count == 0, "Expected length 0, got %lu\n", count);
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %lu\n", GetLastError());
 
     count = GetTempPathW(MAX_PATH, temp_path);
-    ok(count, "Failed to get temp path, error %u\n", GetLastError());
+    ok(count, "Failed to get temp path, error %lu\n", GetLastError());
     ret = GetTempFileNameW(temp_path, prefix, 0, test_path);
-    ok(ret != 0, "GetTempFileNameW error %u\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameW error %lu\n", GetLastError());
     ret = GetLongPathNameW(test_path, long_path, MAX_PATH);
-    ok(ret != 0, "GetLongPathNameW error %u\n", GetLastError());
+    ok(ret != 0, "GetLongPathNameW error %lu\n", GetLastError());
     lstrcpyW(dos_path, dos_prefix);
     lstrcatW(dos_path, long_path);
 
     file = CreateFileW(test_path, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                        CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, 0);
-    ok(file != INVALID_HANDLE_VALUE, "CreateFileW error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "CreateFileW error %lu\n", GetLastError());
 
     if (0) {
         /* Windows crashes on NULL path */
         count = pGetFinalPathNameByHandleW(file, NULL, MAX_PATH, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-        ok(count == 0, "Expected length 0, got %u\n", count);
-        ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %u\n", GetLastError());
+        ok(count == 0, "Expected length 0, got %lu\n", count);
+        ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %lu\n", GetLastError());
     }
 
     /* Test 0-length path */
     count = pGetFinalPathNameByHandleW(file, result_path, 0, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
     ok(count == lstrlenW(dos_path) + 1 ||
-            broken(count == lstrlenW(dos_path) + 2), "Expected length %u, got %u\n", lstrlenW(dos_path) + 1, count);
+            broken(count == lstrlenW(dos_path) + 2), "Expected length %u, got %lu\n", lstrlenW(dos_path) + 1, count);
 
     /* Test 0 and NULL path */
     count = pGetFinalPathNameByHandleW(file, NULL, 0, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
     ok(count == lstrlenW(dos_path) + 1 ||
-            broken(count == lstrlenW(dos_path) + 2), "Expected length %u, got %u\n", lstrlenW(dos_path) + 1, count);
+            broken(count == lstrlenW(dos_path) + 2), "Expected length %u, got %lu\n", lstrlenW(dos_path) + 1, count);
 
     /* Test VOLUME_NAME_DOS with sufficient buffer size */
     memset(result_path, 0x11, sizeof(result_path));
     count = pGetFinalPathNameByHandleW(file, result_path, MAX_PATH, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-    ok(count == lstrlenW(dos_path), "Expected length %u, got %u\n", lstrlenW(dos_path), count);
+    ok(count == lstrlenW(dos_path), "Expected length %u, got %lu\n", lstrlenW(dos_path), count);
     ok(lstrcmpiW(dos_path, result_path) == 0, "Expected %s, got %s\n", wine_dbgstr_w(dos_path), wine_dbgstr_w(result_path));
 
     /* Test VOLUME_NAME_DOS with insufficient buffer size */
     memset(result_path, 0x11, sizeof(result_path));
     count = pGetFinalPathNameByHandleW(file, result_path, lstrlenW(dos_path)-1, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-    ok(count == lstrlenW(dos_path) + 1, "Expected length %u, got %u\n", lstrlenW(dos_path) + 1, count);
+    ok(count == lstrlenW(dos_path) + 1, "Expected length %u, got %lu\n", lstrlenW(dos_path) + 1, count);
     ok(result_path[0] == 0x1111, "Result path was modified\n");
 
     memset(result_path, 0x11, sizeof(result_path));
     count = pGetFinalPathNameByHandleW(file, result_path, lstrlenW(dos_path), FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-    ok(count == lstrlenW(dos_path) + 1, "Expected length %u, got %u\n", lstrlenW(dos_path) + 1, count);
+    ok(count == lstrlenW(dos_path) + 1, "Expected length %u, got %lu\n", lstrlenW(dos_path) + 1, count);
     ok(result_path[0] == 0x1111, "Result path was modified\n");
 
     memset(result_path, 0x11, sizeof(result_path));
     count = pGetFinalPathNameByHandleW(file, result_path, lstrlenW(dos_path)+1, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
-    ok(count == lstrlenW(dos_path), "Expected length %u, got %u\n", lstrlenW(dos_path), count);
+    ok(count == lstrlenW(dos_path), "Expected length %u, got %lu\n", lstrlenW(dos_path), count);
     ok(result_path[0] != 0x1111, "Result path was not modified\n");
     ok(!result_path[lstrlenW(dos_path)], "Expected nullterminated string\n");
     ok(result_path[lstrlenW(dos_path)+1] == 0x1111, "Buffer overflow\n");
 
     success = GetVolumePathNameW(long_path, drive_part, MAX_PATH);
-    ok(success, "GetVolumePathNameW error %u\n", GetLastError());
+    ok(success, "GetVolumePathNameW error %lu\n", GetLastError());
     success = GetVolumeNameForVolumeMountPointW(drive_part, volume_path, ARRAY_SIZE(volume_path));
-    ok(success, "GetVolumeNameForVolumeMountPointW error %u\n", GetLastError());
+    ok(success, "GetVolumeNameForVolumeMountPointW error %lu\n", GetLastError());
 
     /* Test for VOLUME_NAME_GUID */
     lstrcatW(volume_path, long_path + lstrlenW(drive_part));
     memset(result_path, 0x11, sizeof(result_path));
     count = pGetFinalPathNameByHandleW(file, result_path, MAX_PATH, FILE_NAME_NORMALIZED | VOLUME_NAME_GUID);
-    ok(count == lstrlenW(volume_path), "Expected length %u, got %u\n", lstrlenW(volume_path), count);
+    ok(count == lstrlenW(volume_path), "Expected length %u, got %lu\n", lstrlenW(volume_path), count);
     ok(lstrcmpiW(volume_path, result_path) == 0, "Expected %s, got %s\n",
        wine_dbgstr_w(volume_path), wine_dbgstr_w(result_path));
 
@@ -5216,19 +5216,19 @@ static void test_GetFinalPathNameByHandleW(void)
     file_part = long_path + lstrlenW(drive_part) - 1;
     memset(result_path, 0x11, sizeof(result_path));
     count = pGetFinalPathNameByHandleW(file, result_path, MAX_PATH, FILE_NAME_NORMALIZED | VOLUME_NAME_NONE);
-    ok(count == lstrlenW(file_part), "Expected length %u, got %u\n", lstrlenW(file_part), count);
+    ok(count == lstrlenW(file_part), "Expected length %u, got %lu\n", lstrlenW(file_part), count);
     ok(lstrcmpiW(file_part, result_path) == 0, "Expected %s, got %s\n",
        wine_dbgstr_w(file_part), wine_dbgstr_w(result_path));
 
     drive_part[lstrlenW(drive_part)-1] = 0;
     success = QueryDosDeviceW(drive_part, nt_path, ARRAY_SIZE(nt_path));
-    ok(success, "QueryDosDeviceW error %u\n", GetLastError());
+    ok(success, "QueryDosDeviceW error %lu\n", GetLastError());
 
     /* Test for VOLUME_NAME_NT */
     lstrcatW(nt_path, file_part);
     memset(result_path, 0x11, sizeof(result_path));
     count = pGetFinalPathNameByHandleW(file, result_path, MAX_PATH, FILE_NAME_NORMALIZED | VOLUME_NAME_NT);
-    ok(count == lstrlenW(nt_path), "Expected length %u, got %u\n", lstrlenW(nt_path), count);
+    ok(count == lstrlenW(nt_path), "Expected length %u, got %lu\n", lstrlenW(nt_path), count);
     ok(lstrcmpiW(nt_path, result_path) == 0, "Expected %s, got %s\n",
        wine_dbgstr_w(nt_path), wine_dbgstr_w(result_path));
 
@@ -5257,97 +5257,97 @@ static void test_SetFileInformationByHandle(void)
     }
 
     ret = GetTempPathA(sizeof(tempPath), tempPath);
-    ok(ret, "GetTempPathA failed, got error %u.\n", GetLastError());
+    ok(ret, "GetTempPathA failed, got error %lu.\n", GetLastError());
 
     /* ensure the existence of a file in the temp folder */
     ret = GetTempFileNameA(tempPath, "abc", 0, tempFileName);
-    ok(ret, "GetTempFileNameA failed, got error %u.\n", GetLastError());
+    ok(ret, "GetTempFileNameA failed, got error %lu.\n", GetLastError());
 
     file = CreateFileA(tempFileName, GENERIC_READ | FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
         NULL, OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, NULL);
-    ok(file != INVALID_HANDLE_VALUE, "failed to open the temp file, error %u.\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "failed to open the temp file, error %lu.\n", GetLastError());
 
     /* invalid classes */
     SetLastError(0xdeadbeef);
     ret = pSetFileInformationByHandle(file, FileStandardInfo, &stdinfo, sizeof(stdinfo));
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %ld\n", ret, GetLastError());
 
     memset(&compressinfo, 0, sizeof(compressinfo));
     SetLastError(0xdeadbeef);
     ret = pSetFileInformationByHandle(file, FileCompressionInfo, &compressinfo, sizeof(compressinfo));
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %ld\n", ret, GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pSetFileInformationByHandle(file, FileAttributeTagInfo, &fileattrinfo, sizeof(fileattrinfo));
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %ld\n", ret, GetLastError());
 
     SetLastError(0xdeadbeef);
     hintinfo.PriorityHint = MaximumIoPriorityHintType;
     ret = pSetFileInformationByHandle(file, FileIoPriorityHintInfo, &hintinfo, sizeof(hintinfo));
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %ld\n", ret, GetLastError());
 
     hintinfo.PriorityHint = IoPriorityHintNormal;
     ret = pSetFileInformationByHandle(file, FileIoPriorityHintInfo, &hintinfo, sizeof(hintinfo));
-    ok(ret, "setting FileIoPriorityHintInfo got %d, error %d\n", ret, GetLastError());
+    ok(ret, "setting FileIoPriorityHintInfo got %d, error %ld\n", ret, GetLastError());
 
     hintinfo.PriorityHint = IoPriorityHintVeryLow;
     ret = pSetFileInformationByHandle(file, FileIoPriorityHintInfo, &hintinfo, sizeof(hintinfo));
-    ok(ret, "setting FileIoPriorityHintInfo got %d, error %d\n", ret, GetLastError());
+    ok(ret, "setting FileIoPriorityHintInfo got %d, error %ld\n", ret, GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pSetFileInformationByHandle(file, FileIoPriorityHintInfo, &hintinfo, sizeof(hintinfo) - 1);
-    ok(!ret && GetLastError() == ERROR_BAD_LENGTH, "got %d, error %d\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_BAD_LENGTH, "got %d, error %ld\n", ret, GetLastError());
 
     SetLastError(0xdeadbeef);
     hintinfo.PriorityHint = IoPriorityHintVeryLow - 1;
     ret = pSetFileInformationByHandle(file, FileIoPriorityHintInfo, &hintinfo, sizeof(hintinfo));
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %ld\n", ret, GetLastError());
 
     memset(&protinfo, 0, sizeof(protinfo));
     protinfo.StructureVersion = 1;
     protinfo.StructureSize = sizeof(protinfo);
     SetLastError(0xdeadbeef);
     ret = pSetFileInformationByHandle(file, FileRemoteProtocolInfo, &protinfo, sizeof(protinfo));
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %ld\n", ret, GetLastError());
 
     /* test FileDispositionInfo, additional details already covered by ntdll tests */
     SetLastError(0xdeadbeef);
     ret = pSetFileInformationByHandle(file, FileDispositionInfo, &dispinfo, 0);
     todo_wine
-    ok(!ret && GetLastError() == ERROR_BAD_LENGTH, "got %d, error %d\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_BAD_LENGTH, "got %d, error %ld\n", ret, GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pSetFileInformationByHandle(file, FileBasicInfo, &basicinfo, 0);
     todo_wine
-    ok(!ret && GetLastError() == ERROR_BAD_LENGTH, "got %d, error %d\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_BAD_LENGTH, "got %d, error %ld\n", ret, GetLastError());
 
     memset(&basicinfo, 0, sizeof(basicinfo));
     ret = pGetFileInformationByHandleEx(file, FileBasicInfo, &basicinfo, sizeof(basicinfo));
-    ok(ret, "Failed to get basic info, error %d.\n", GetLastError());
+    ok(ret, "Failed to get basic info, error %ld.\n", GetLastError());
     atime = basicinfo.LastAccessTime;
 
     basicinfo.LastAccessTime.QuadPart++;
     ret = pSetFileInformationByHandle(file, FileBasicInfo, &basicinfo, sizeof(basicinfo));
-    ok(ret, "Failed to set basic info, error %d.\n", GetLastError());
+    ok(ret, "Failed to set basic info, error %ld.\n", GetLastError());
 
     memset(&basicinfo, 0, sizeof(basicinfo));
     ret = pGetFileInformationByHandleEx(file, FileBasicInfo, &basicinfo, sizeof(basicinfo));
-    ok(ret, "Failed to get basic info, error %d.\n", GetLastError());
+    ok(ret, "Failed to get basic info, error %ld.\n", GetLastError());
     ok(atime.QuadPart + 1 == basicinfo.LastAccessTime.QuadPart, "Unexpected access time.\n");
 
     memset(&basicinfo, 0, sizeof(basicinfo));
     basicinfo.LastAccessTime.QuadPart = -1;
     ret = pSetFileInformationByHandle(file, FileBasicInfo, &basicinfo, sizeof(basicinfo));
-    ok(ret, "Failed to set basic info, error %d.\n", GetLastError());
+    ok(ret, "Failed to set basic info, error %ld.\n", GetLastError());
 
     memset(&basicinfo, 0, sizeof(basicinfo));
     ret = pGetFileInformationByHandleEx(file, FileBasicInfo, &basicinfo, sizeof(basicinfo));
-    ok(ret, "Failed to get basic info, error %d.\n", GetLastError());
+    ok(ret, "Failed to get basic info, error %ld.\n", GetLastError());
     ok(atime.QuadPart + 1 == basicinfo.LastAccessTime.QuadPart, "Unexpected access time.\n");
 
     dispinfo.DeleteFile = TRUE;
     ret = pSetFileInformationByHandle(file, FileDispositionInfo, &dispinfo, sizeof(dispinfo));
-    ok(ret, "setting FileDispositionInfo failed, error %d\n", GetLastError());
+    ok(ret, "setting FileDispositionInfo failed, error %ld\n", GetLastError());
 
     CloseHandle(file);
 }
@@ -5368,19 +5368,19 @@ static void test_SetFileRenameInfo(void)
     }
 
     ret = GetTempPathW(MAX_PATH, tempPath);
-    ok(ret, "GetTempPathW failed, got error %u.\n", GetLastError());
+    ok(ret, "GetTempPathW failed, got error %lu.\n", GetLastError());
 
     ret = GetTempFileNameW(tempPath, L"abc", 0, tempFileFrom);
-    ok(ret, "GetTempFileNameW failed, got error %u.\n", GetLastError());
+    ok(ret, "GetTempFileNameW failed, got error %lu.\n", GetLastError());
 
     ret = GetTempFileNameW(tempPath, L"abc", 0, tempFileTo1);
-    ok(ret, "GetTempFileNameW failed, got error %u.\n", GetLastError());
+    ok(ret, "GetTempFileNameW failed, got error %lu.\n", GetLastError());
 
     ret = GetTempFileNameW(tempPath, L"abc", 1, tempFileTo2);
-    ok(ret, "GetTempFileNameW failed, got error %u.\n", GetLastError());
+    ok(ret, "GetTempFileNameW failed, got error %lu.\n", GetLastError());
 
     file = CreateFileW(tempFileFrom, GENERIC_READ | GENERIC_WRITE | DELETE, 0, 0, OPEN_EXISTING, 0, 0);
-    ok(file != INVALID_HANDLE_VALUE, "failed to create temp file, error %u.\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "failed to create temp file, error %lu.\n", GetLastError());
 
     size = sizeof(FILE_RENAME_INFORMATION) + MAX_PATH;
     fri = HeapAlloc(GetProcessHeap(), 0, size);
@@ -5390,27 +5390,27 @@ static void test_SetFileRenameInfo(void)
     fri->FileNameLength = wcslen(tempFileTo1) * sizeof(WCHAR);
     memcpy(fri->FileName, tempFileTo1, fri->FileNameLength + sizeof(WCHAR));
     ret = pSetFileInformationByHandle(file, FileRenameInfo, fri, size);
-    ok(!ret && GetLastError() == ERROR_ALREADY_EXISTS, "FileRenameInfo unexpected result %d\n", GetLastError());
+    ok(!ret && GetLastError() == ERROR_ALREADY_EXISTS, "FileRenameInfo unexpected result %ld\n", GetLastError());
 
     fri->ReplaceIfExists = TRUE;
     ret = pSetFileInformationByHandle(file, FileRenameInfo, fri, size);
-    ok(ret, "FileRenameInfo failed, error %d\n", GetLastError());
+    ok(ret, "FileRenameInfo failed, error %ld\n", GetLastError());
 
     fri->ReplaceIfExists = FALSE;
     fri->FileNameLength = wcslen(tempFileTo2) * sizeof(WCHAR);
     memcpy(fri->FileName, tempFileTo2, fri->FileNameLength + sizeof(WCHAR));
     ret = pSetFileInformationByHandle(file, FileRenameInfo, fri, size);
-    ok(ret, "FileRenameInfo failed, error %d\n", GetLastError());
+    ok(ret, "FileRenameInfo failed, error %ld\n", GetLastError());
     CloseHandle(file);
 
     file = CreateFileW(tempFileTo2, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
-    ok(file != INVALID_HANDLE_VALUE, "file not renamed, error %d\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "file not renamed, error %ld\n", GetLastError());
 
     fri->FileNameLength = wcslen(tempFileTo1) * sizeof(WCHAR);
     memcpy(fri->FileName, tempFileTo1, fri->FileNameLength + sizeof(WCHAR));
     ret = pSetFileInformationByHandle(file, FileRenameInfo, fri, size);
     todo_wine
-    ok(!ret && GetLastError() == ERROR_ACCESS_DENIED, "FileRenameInfo unexpected result %d\n", GetLastError());
+    ok(!ret && GetLastError() == ERROR_ACCESS_DENIED, "FileRenameInfo unexpected result %ld\n", GetLastError());
     CloseHandle(file);
 
     HeapFree(GetProcessHeap(), 0, fri);
@@ -5439,13 +5439,13 @@ static void test_GetFileAttributesExW(void)
 
     for (test_idx = 0; test_idx < ARRAY_SIZE(tests); ++test_idx)
     {
-        winetest_push_context("Test %u", test_idx);
+        winetest_push_context("Test %lu", test_idx);
 
         SetLastError(0xdeadbeef);
         ret = GetFileAttributesExW(tests[test_idx].path, GetFileExInfoStandard, &info);
         error = GetLastError();
         ok(!ret, "GetFileAttributesExW succeeded\n");
-        ok(error == tests[test_idx].expected_error, "Expected error %u, got %u\n",
+        ok(error == tests[test_idx].expected_error, "Expected error %lu, got %lu\n",
            tests[test_idx].expected_error, error);
 
         winetest_pop_context();
@@ -5463,24 +5463,24 @@ static void test_post_completion(void)
     BOOL ret;
 
     port = CreateIoCompletionPort( INVALID_HANDLE_VALUE, NULL, 999, 0 );
-    ok(port != NULL, "CreateIoCompletionPort failed: %u\n", GetLastError());
+    ok(port != NULL, "CreateIoCompletionPort failed: %lu\n", GetLastError());
 
     ret = GetQueuedCompletionStatus( port, &size, &key, &povl, 0 );
     ok(!ret, "GetQueuedCompletionStatus succeeded\n");
-    ok(GetLastError() == WAIT_TIMEOUT, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == WAIT_TIMEOUT, "wrong error %lu\n", GetLastError());
 
     ret = PostQueuedCompletionStatus( port, 123, 456, &ovl );
-    ok(ret, "PostQueuedCompletionStatus failed: %u\n", GetLastError());
+    ok(ret, "PostQueuedCompletionStatus failed: %lu\n", GetLastError());
 
     ret = GetQueuedCompletionStatus( port, &size, &key, &povl, 0 );
-    ok(ret, "GetQueuedCompletionStatus failed: %u\n", GetLastError());
-    ok(size == 123, "wrong size %u\n", size);
-    ok(key == 456, "wrong key %lu\n", key);
+    ok(ret, "GetQueuedCompletionStatus failed: %lu\n", GetLastError());
+    ok(size == 123, "wrong size %lu\n", size);
+    ok(key == 456, "wrong key %Iu\n", key);
     ok(povl == &ovl, "wrong ovl %p\n", povl);
 
     ret = GetQueuedCompletionStatus( port, &size, &key, &povl, 0 );
     ok(!ret, "GetQueuedCompletionStatus succeeded\n");
-    ok(GetLastError() == WAIT_TIMEOUT, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == WAIT_TIMEOUT, "wrong error %lu\n", GetLastError());
 
     if (!pGetQueuedCompletionStatusEx)
     {
@@ -5492,67 +5492,67 @@ static void test_post_completion(void)
     count = 0xdeadbeef;
     ret = pGetQueuedCompletionStatusEx( port, entries, 2, &count, 0, FALSE );
     ok(!ret, "GetQueuedCompletionStatusEx succeeded\n");
-    ok(GetLastError() == WAIT_TIMEOUT, "wrong error %u\n", GetLastError());
-    ok(count == 1, "wrong count %u\n", count);
+    ok(GetLastError() == WAIT_TIMEOUT, "wrong error %lu\n", GetLastError());
+    ok(count == 1, "wrong count %lu\n", count);
 
     ret = PostQueuedCompletionStatus( port, 123, 456, &ovl );
-    ok(ret, "PostQueuedCompletionStatus failed: %u\n", GetLastError());
+    ok(ret, "PostQueuedCompletionStatus failed: %lu\n", GetLastError());
 
     count = 0xdeadbeef;
     memset( entries, 0xcc, sizeof(entries) );
     ret = pGetQueuedCompletionStatusEx( port, entries, 2, &count, 0, FALSE );
     ok(ret, "GetQueuedCompletionStatusEx failed\n");
-    ok(count == 1, "wrong count %u\n", count);
-    ok(entries[0].lpCompletionKey == 456, "wrong key %lu\n", entries[0].lpCompletionKey);
+    ok(count == 1, "wrong count %lu\n", count);
+    ok(entries[0].lpCompletionKey == 456, "wrong key %Iu\n", entries[0].lpCompletionKey);
     ok(entries[0].lpOverlapped == &ovl, "wrong ovl %p\n", entries[0].lpOverlapped);
-    ok(!(ULONG)entries[0].Internal, "wrong internal %#x\n", (ULONG)entries[0].Internal);
-    ok(entries[0].dwNumberOfBytesTransferred == 123, "wrong size %u\n", entries[0].dwNumberOfBytesTransferred);
+    ok(!(ULONG)entries[0].Internal, "wrong internal %#lx\n", (ULONG)entries[0].Internal);
+    ok(entries[0].dwNumberOfBytesTransferred == 123, "wrong size %lu\n", entries[0].dwNumberOfBytesTransferred);
 
     ret = PostQueuedCompletionStatus( port, 123, 456, &ovl );
-    ok(ret, "PostQueuedCompletionStatus failed: %u\n", GetLastError());
+    ok(ret, "PostQueuedCompletionStatus failed: %lu\n", GetLastError());
 
     ret = PostQueuedCompletionStatus( port, 654, 321, &ovl2 );
-    ok(ret, "PostQueuedCompletionStatus failed: %u\n", GetLastError());
+    ok(ret, "PostQueuedCompletionStatus failed: %lu\n", GetLastError());
 
     count = 0xdeadbeef;
     memset( entries, 0xcc, sizeof(entries) );
     ret = pGetQueuedCompletionStatusEx( port, entries, 2, &count, 0, FALSE );
     ok(ret, "GetQueuedCompletionStatusEx failed\n");
-    ok(count == 2, "wrong count %u\n", count);
-    ok(entries[0].lpCompletionKey == 456, "wrong key %lu\n", entries[0].lpCompletionKey);
+    ok(count == 2, "wrong count %lu\n", count);
+    ok(entries[0].lpCompletionKey == 456, "wrong key %Iu\n", entries[0].lpCompletionKey);
     ok(entries[0].lpOverlapped == &ovl, "wrong ovl %p\n", entries[0].lpOverlapped);
-    ok(!(ULONG)entries[0].Internal, "wrong internal %#x\n", (ULONG)entries[0].Internal);
-    ok(entries[0].dwNumberOfBytesTransferred == 123, "wrong size %u\n", entries[0].dwNumberOfBytesTransferred);
-    ok(entries[1].lpCompletionKey == 321, "wrong key %lu\n", entries[1].lpCompletionKey);
+    ok(!(ULONG)entries[0].Internal, "wrong internal %#lx\n", (ULONG)entries[0].Internal);
+    ok(entries[0].dwNumberOfBytesTransferred == 123, "wrong size %lu\n", entries[0].dwNumberOfBytesTransferred);
+    ok(entries[1].lpCompletionKey == 321, "wrong key %Iu\n", entries[1].lpCompletionKey);
     ok(entries[1].lpOverlapped == &ovl2, "wrong ovl %p\n", entries[1].lpOverlapped);
-    ok(!(ULONG)entries[1].Internal, "wrong internal %#x\n", (ULONG)entries[1].Internal);
-    ok(entries[1].dwNumberOfBytesTransferred == 654, "wrong size %u\n", entries[1].dwNumberOfBytesTransferred);
+    ok(!(ULONG)entries[1].Internal, "wrong internal %#lx\n", (ULONG)entries[1].Internal);
+    ok(entries[1].dwNumberOfBytesTransferred == 654, "wrong size %lu\n", entries[1].dwNumberOfBytesTransferred);
 
     user_apc_ran = FALSE;
     QueueUserAPC( user_apc, GetCurrentThread(), 0 );
 
     ret = pGetQueuedCompletionStatusEx( port, entries, 2, &count, 0, FALSE );
     ok(!ret, "GetQueuedCompletionStatusEx succeeded\n");
-    ok(GetLastError() == WAIT_TIMEOUT, "wrong error %u\n", GetLastError());
-    ok(count == 1, "wrong count %u\n", count);
+    ok(GetLastError() == WAIT_TIMEOUT, "wrong error %lu\n", GetLastError());
+    ok(count == 1, "wrong count %lu\n", count);
     ok(!user_apc_ran, "user APC should not have run\n");
 
     ret = pGetQueuedCompletionStatusEx( port, entries, 2, &count, 0, TRUE );
     ok(!ret || broken(ret) /* Vista */, "GetQueuedCompletionStatusEx succeeded\n");
     if (!ret)
-        ok(GetLastError() == WAIT_IO_COMPLETION, "wrong error %u\n", GetLastError());
-    ok(count == 1, "wrong count %u\n", count);
+        ok(GetLastError() == WAIT_IO_COMPLETION, "wrong error %lu\n", GetLastError());
+    ok(count == 1, "wrong count %lu\n", count);
     ok(user_apc_ran, "user APC should have run\n");
 
     user_apc_ran = FALSE;
     QueueUserAPC( user_apc, GetCurrentThread(), 0 );
 
     ret = PostQueuedCompletionStatus( port, 123, 456, &ovl );
-    ok(ret, "PostQueuedCompletionStatus failed: %u\n", GetLastError());
+    ok(ret, "PostQueuedCompletionStatus failed: %lu\n", GetLastError());
 
     ret = pGetQueuedCompletionStatusEx( port, entries, 2, &count, 0, TRUE );
     ok(ret, "GetQueuedCompletionStatusEx failed\n");
-    ok(count == 1, "wrong count %u\n", count);
+    ok(count == 1, "wrong count %lu\n", count);
     ok(!user_apc_ran, "user APC should not have run\n");
 
     SleepEx(0, TRUE);
@@ -5575,34 +5575,34 @@ static void test_overlapped_read(void)
     DWORD ret;
 
     ret = GetTempPathA(MAX_PATH, temp_path);
-    ok(ret, "Unexpected error %u.\n", GetLastError());
+    ok(ret, "Unexpected error %lu.\n", GetLastError());
     ret = GetTempFileNameA(temp_path, prefix, 0, file_name);
-    ok(ret, "Unexpected error %u.\n", GetLastError());
+    ok(ret, "Unexpected error %lu.\n", GetLastError());
 
     hfile = CreateFileA(file_name, GENERIC_WRITE, 0,
             NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_NO_BUFFERING, NULL);
-    ok(hfile != INVALID_HANDLE_VALUE, "Failed to create file, GetLastError() %u.\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "Failed to create file, GetLastError() %lu.\n", GetLastError());
     memset(buffer, 0x55, sizeof(buffer));
     ret = WriteFile(hfile, buffer, TEST_OVERLAPPED_READ_SIZE, &bytes_count, NULL);
     ok(ret && bytes_count == TEST_OVERLAPPED_READ_SIZE,
-            "Unexpected WriteFile result, ret %#x, bytes_count %u, GetLastError() %u.\n",
+            "Unexpected WriteFile result, ret %#lx, bytes_count %lu, GetLastError() %lu.\n",
             ret, bytes_count, GetLastError());
     CloseHandle(hfile);
 
     hfile = CreateFileA(file_name, GENERIC_READ, FILE_SHARE_READ,
             NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, NULL);
-    ok(hfile != INVALID_HANDLE_VALUE, "Failed to create file, GetLastError() %u.\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "Failed to create file, GetLastError() %lu.\n", GetLastError());
 
     memset(&ov, 0, sizeof(ov));
 
     bytes_count = 0xffffffff;
     ret = ReadFile(hfile, buffer, TEST_OVERLAPPED_READ_SIZE, &bytes_count, &ov);
     ok(!ret && GetLastError() == ERROR_IO_PENDING,
-            "Unexpected ReadFile result, ret %#x, GetLastError() %u.\n", ret, GetLastError());
-    ok(!bytes_count, "Unexpected read size %u.\n", bytes_count);
+            "Unexpected ReadFile result, ret %#lx, GetLastError() %lu.\n", ret, GetLastError());
+    ok(!bytes_count, "Unexpected read size %lu.\n", bytes_count);
     ret = GetOverlappedResult(hfile, &ov, &bytes_count, TRUE);
-    ok(ret, "Unexpected error %u.\n", GetLastError());
-    ok(bytes_count == TEST_OVERLAPPED_READ_SIZE, "Unexpected read size %u.\n", bytes_count);
+    ok(ret, "Unexpected error %lu.\n", GetLastError());
+    ok(bytes_count == TEST_OVERLAPPED_READ_SIZE, "Unexpected read size %lu.\n", bytes_count);
 
     S(U(ov)).Offset = bytes_count;
     ret = ReadFile(hfile, buffer, TEST_OVERLAPPED_READ_SIZE, &bytes_count, &ov);
@@ -5610,18 +5610,18 @@ static void test_overlapped_read(void)
     /* Win8+ return ERROR_IO_PENDING like stated in MSDN, while older ones
      * return ERROR_HANDLE_EOF right away. */
     ok(!ret && (err == ERROR_IO_PENDING || broken(err == ERROR_HANDLE_EOF)),
-            "Unexpected ReadFile result, ret %#x, GetLastError() %u.\n", ret, GetLastError());
+            "Unexpected ReadFile result, ret %#lx, GetLastError() %lu.\n", ret, GetLastError());
     if (err == ERROR_IO_PENDING)
     {
         ret = GetOverlappedResult(hfile, &ov, &bytes_count, TRUE);
-        ok(!ret && GetLastError() == ERROR_HANDLE_EOF, "Unexpected result %#x, GetLasttError() %u.\n",
+        ok(!ret && GetLastError() == ERROR_HANDLE_EOF, "Unexpected result %#lx, GetLasttError() %lu.\n",
                 ret, GetLastError());
     }
-    ok(!bytes_count, "Unexpected read size %u.\n", bytes_count);
+    ok(!bytes_count, "Unexpected read size %lu.\n", bytes_count);
 
     CloseHandle(hfile);
     ret = DeleteFileA(file_name);
-    ok(ret, "Unexpected error %u.\n", GetLastError());
+    ok(ret, "Unexpected error %lu.\n", GetLastError());
 }
 
 static void test_file_readonly_access(void)
@@ -5636,21 +5636,21 @@ static void test_file_readonly_access(void)
 
     /* Set up */
     ret = GetTempPathA(MAX_PATH, temp_path);
-    ok(ret != 0, "GetTempPathA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempPathA error %ld\n", GetLastError());
     ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
 
     ret = GetTempFileNameA(temp_path, prefix, 0, file_name);
-    ok(ret != 0, "GetTempFileNameA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
     ret = DeleteFileA(file_name);
     ok(ret, "expect success\n");
 
     ret = GetTempFileNameA(temp_path, prefix, 0, file_name2);
-    ok(ret != 0, "GetTempFileNameA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
     ret = DeleteFileA(file_name2);
     ok(ret, "expect success\n");
 
     handle = CreateFileA(file_name, 0, default_sharing, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_READONLY, 0);
-    ok(handle != INVALID_HANDLE_VALUE, "CreateFileA: error %d\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "CreateFileA: error %ld\n", GetLastError());
     CloseHandle(handle);
 
     /* CreateFile GENERIC_WRITE */
@@ -5658,7 +5658,7 @@ static void test_file_readonly_access(void)
     handle = CreateFileA(file_name, GENERIC_WRITE, default_sharing, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
     error = GetLastError();
     ok(handle == INVALID_HANDLE_VALUE, "expect failure\n");
-    ok(error == ERROR_ACCESS_DENIED, "wrong error code: %#x\n", error);
+    ok(error == ERROR_ACCESS_DENIED, "wrong error code: %#lx\n", error);
 
     /* CreateFile DELETE without FILE_FLAG_DELETE_ON_CLOSE */
     handle = CreateFileA(file_name, DELETE, default_sharing, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
@@ -5671,7 +5671,7 @@ static void test_file_readonly_access(void)
                          FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_NORMAL, 0);
     error = GetLastError();
     ok(handle == INVALID_HANDLE_VALUE, "expect failure\n");
-    ok(error == ERROR_ACCESS_DENIED, "wrong error code: %#x\n", error);
+    ok(error == ERROR_ACCESS_DENIED, "wrong error code: %#lx\n", error);
 
     ret = MoveFileA(file_name, file_name2);
     ok(ret, "expect success\n");
@@ -5682,15 +5682,15 @@ static void test_file_readonly_access(void)
     ret = DeleteFileA(file_name);
     error = GetLastError();
     ok(!ret, "expect failure\n");
-    ok(error == ERROR_ACCESS_DENIED, "wrong error code: %#x\n", error);
+    ok(error == ERROR_ACCESS_DENIED, "wrong error code: %#lx\n", error);
 
     ret = GetFileAttributesA(file_name);
-    ok(ret & FILE_ATTRIBUTE_READONLY, "got wrong attribute: %#x.\n", ret);
+    ok(ret & FILE_ATTRIBUTE_READONLY, "got wrong attribute: %#lx.\n", ret);
 
     /* Clean up */
     SetFileAttributesA(file_name, FILE_ATTRIBUTE_NORMAL);
     ret = DeleteFileA(file_name);
-    ok(ret, "DeleteFileA: error %d\n", GetLastError());
+    ok(ret, "DeleteFileA: error %ld\n", GetLastError());
 }
 
 static void test_find_file_stream(void)
@@ -5722,35 +5722,35 @@ static void test_SetFileTime(void)
     HANDLE hfile;
 
     ret = GetTempPathW(MAX_PATH, temp_path);
-    ok(ret != 0, "GetTempPathW error %d\n", GetLastError());
+    ok(ret != 0, "GetTempPathW error %ld\n", GetLastError());
     ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
 
     ret = GetTempFileNameW(temp_path, prefix, 0, path);
-    ok(ret != 0, "GetTempFileNameW error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameW error %ld\n", GetLastError());
 
     hfile = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, 0);
     ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file\n");
     ret = WriteFile(hfile, prefix, sizeof(prefix), &len, NULL );
-    ok(ret && len == sizeof(prefix), "WriteFile error %d\n", GetLastError());
+    ok(ret && len == sizeof(prefix), "WriteFile error %ld\n", GetLastError());
     ok(GetFileSize(hfile, NULL) == sizeof(prefix), "source file has wrong size\n");
 
     ret = GetFileTime(hfile, NULL, NULL, &ft1);
-    ok(ret, "GetFileTime error %d\n", GetLastError());
+    ok(ret, "GetFileTime error %ld\n", GetLastError());
     ft2 = ft1;
     ft2.dwLowDateTime -= 600000000; /* 60 second */
     ret = SetFileTime(hfile, NULL, NULL, &ft2);
-    ok(ret, "SetFileTime error %d\n", GetLastError());
+    ok(ret, "SetFileTime error %ld\n", GetLastError());
     memset(&ft2, 0, sizeof(ft2));
     ret = GetFileTime(hfile, NULL, NULL, &ft2);  /* get the actual time back */
-    ok(ret, "GetFileTime error %d\n", GetLastError());
+    ok(ret, "GetFileTime error %ld\n", GetLastError());
     ok(memcmp(&ft1, &ft2, sizeof(ft1)), "Unexpected write time.\n");
 
     memset(&ft1, 0xff, sizeof(ft1));
     ret = SetFileTime(hfile, NULL, NULL, &ft1);
-    ok(ret, "SetFileTime error %d\n", GetLastError());
+    ok(ret, "SetFileTime error %ld\n", GetLastError());
     memset(&ft1, 0, sizeof(ft1));
     ret = GetFileTime(hfile, NULL, NULL, &ft1);  /* get the actual time back */
-    ok(ret, "GetFileTime error %d\n", GetLastError());
+    ok(ret, "GetFileTime error %ld\n", GetLastError());
     ok(!memcmp(&ft1, &ft2, sizeof(ft1)), "Unexpected write time.\n");
 
     CloseHandle(hfile);
@@ -5771,67 +5771,67 @@ static void test_hard_link(void)
     SetCurrentDirectoryA( temp_dir );
 
     ret = CreateDirectoryA( "winetest_dir1", NULL );
-    ok(ret, "failed to create directory, error %u\n", GetLastError());
+    ok(ret, "failed to create directory, error %lu\n", GetLastError());
     ret = CreateDirectoryA( "winetest_dir2", NULL );
-    ok(ret, "failed to create directory, error %u\n", GetLastError());
+    ok(ret, "failed to create directory, error %lu\n", GetLastError());
     create_file( "winetest_file1" );
     create_file( "winetest_file2" );
 
     ret = CreateHardLinkA( "winetest_file3", "winetest_file1", NULL );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     file = CreateFileA( "winetest_file3", FILE_READ_DATA, 0, NULL, OPEN_EXISTING, 0, NULL );
-    ok(file != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError());
 
     status = NtQueryInformationFile( file, &io, name_buffer, sizeof(name_buffer), FileNameInformation );
-    ok(!status, "got status %#x\n", status);
+    ok(!status, "got status %#lx\n", status);
     ok(!wcsncmp(name_info->FileName + (name_info->FileNameLength / sizeof(WCHAR)) - wcslen(L"\\winetest_file3"),
             L"\\winetest_file3", wcslen(L"\\winetest_file3")), "got name %s\n",
             debugstr_wn(name_info->FileName, name_info->FileNameLength / sizeof(WCHAR)));
 
     ret = ReadFile( file, buffer, sizeof(buffer), &size, NULL );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ok(!memcmp( buffer, "winetest_file1", size ), "got file contents %s\n", debugstr_an( buffer, size ));
 
     CloseHandle( file );
 
     ret = DeleteFileA( "winetest_file3" );
-    ok(ret, "failed to delete file, error %u\n", GetLastError());
+    ok(ret, "failed to delete file, error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = CreateHardLinkA( "winetest_file2", "winetest_file1", NULL );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = CreateHardLinkA( "WineTest_File1", "winetest_file1", NULL );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = CreateHardLinkA( "winetest_file3", "winetest_dir1", NULL );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "got error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = CreateHardLinkA( "winetest_dir2", "winetest_dir1", NULL );
     ok(!ret, "expected failure\n");
     ok(GetLastError() == ERROR_ACCESS_DENIED
-            || GetLastError() == ERROR_ALREADY_EXISTS /* XP */, "got error %u\n", GetLastError());
+            || GetLastError() == ERROR_ALREADY_EXISTS /* XP */, "got error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = CreateHardLinkA( "winetest_dir1", "winetest_file1", NULL );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got error %lu\n", GetLastError());
 
     ret = RemoveDirectoryA( "winetest_dir1" );
-    ok(ret, "failed to remove directory, error %u\n", GetLastError());
+    ok(ret, "failed to remove directory, error %lu\n", GetLastError());
     ret = RemoveDirectoryA( "winetest_dir2" );
-    ok(ret, "failed to remove directory, error %u\n", GetLastError());
+    ok(ret, "failed to remove directory, error %lu\n", GetLastError());
     ret = DeleteFileA( "winetest_file1" );
-    ok(ret, "failed to delete file, error %u\n", GetLastError());
+    ok(ret, "failed to delete file, error %lu\n", GetLastError());
     ret = DeleteFileA( "winetest_file2" );
-    ok(ret, "failed to delete file, error %u\n", GetLastError());
+    ok(ret, "failed to delete file, error %lu\n", GetLastError());
     SetCurrentDirectoryA( cwd );
 }
 
@@ -5846,14 +5846,14 @@ static void test_move_file(void)
     SetCurrentDirectoryA( temp_dir );
 
     ret = CreateDirectoryA( "winetest_dir1", NULL );
-    ok(ret, "failed to create directory, error %u\n", GetLastError());
+    ok(ret, "failed to create directory, error %lu\n", GetLastError());
     ret = CreateDirectoryA( "winetest_dir2", NULL );
-    ok(ret, "failed to create directory, error %u\n", GetLastError());
+    ok(ret, "failed to create directory, error %lu\n", GetLastError());
     create_file( "winetest_file1" );
     create_file( "winetest_file2" );
 
     ret = MoveFileA( "winetest_file1", "winetest_file3" );
-    ok(ret, "failed to move file, error %u\n", GetLastError());
+    ok(ret, "failed to move file, error %lu\n", GetLastError());
     ret = GetFileAttributesA( "winetest_file1" );
     ok(ret == INVALID_FILE_ATTRIBUTES, "got %#x\n", ret);
     ret = GetFileAttributesA( "winetest_file3" );
@@ -5862,32 +5862,32 @@ static void test_move_file(void)
     SetLastError(0xdeadbeef);
     ret = MoveFileA( "winetest_file3", "winetest_file2" );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = MoveFileA( "winetest_file1", "winetest_file4" );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %lu\n", GetLastError());
 
     ret = MoveFileA( "winetest_dir1", "winetest_dir3" );
-    ok(ret, "failed to move file, error %u\n", GetLastError());
+    ok(ret, "failed to move file, error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = MoveFileA( "winetest_dir3", "winetest_dir2" );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_ALREADY_EXISTS, "got error %lu\n", GetLastError());
 
     file = CreateFileA( "winetest_file3", DELETE, 0, NULL, OPEN_EXISTING, 0, 0 );
-    ok(file != INVALID_HANDLE_VALUE, "failed to open file, error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "failed to open file, error %lu\n", GetLastError());
     ret = MoveFileA( "winetest_file3", "winetest_file1" );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_SHARING_VIOLATION, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_SHARING_VIOLATION, "got error %lu\n", GetLastError());
     CloseHandle( file );
 
     file = CreateFileA( "winetest_file3", 0, 0, NULL, OPEN_EXISTING, 0, 0 );
-    ok(file != INVALID_HANDLE_VALUE, "failed to open file, error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "failed to open file, error %lu\n", GetLastError());
     ret = MoveFileA( "winetest_file3", "winetest_file1" );
-    ok(ret, "failed to move file, error %u\n", GetLastError());
+    ok(ret, "failed to move file, error %lu\n", GetLastError());
     ret = GetFileAttributesA( "winetest_file1" );
     ok(ret != INVALID_FILE_ATTRIBUTES, "got %#x\n", ret);
     ret = GetFileAttributesA( "winetest_file3" );
@@ -5895,36 +5895,36 @@ static void test_move_file(void)
     CloseHandle( file );
 
     ret = MoveFileExA( "winetest_file1", "winetest_file2", MOVEFILE_REPLACE_EXISTING );
-    ok(ret, "failed to move file, error %u\n", GetLastError());
+    ok(ret, "failed to move file, error %lu\n", GetLastError());
 
     file = CreateFileA( "winetest_file1", GENERIC_ALL,
             FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, CREATE_NEW, 0, 0 );
-    ok(file != INVALID_HANDLE_VALUE, "failed to open file, error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "failed to open file, error %lu\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = MoveFileExA( "winetest_file2", "winetest_file1", MOVEFILE_REPLACE_EXISTING );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "got error %lu\n", GetLastError());
     CloseHandle( file );
 
     SetLastError(0xdeadbeef);
     ret = MoveFileExA( "winetest_file2", "winetest_dir2", MOVEFILE_REPLACE_EXISTING );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "got error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = MoveFileExA( "winetest_dir3", "winetest_dir2", MOVEFILE_REPLACE_EXISTING );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "got error %lu\n", GetLastError());
 
     ret = MoveFileExA( "winetest_dir2", "winetest_file2", MOVEFILE_REPLACE_EXISTING );
-    ok(ret, "failed to move file, error %u\n", GetLastError());
+    ok(ret, "failed to move file, error %lu\n", GetLastError());
 
     ret = RemoveDirectoryA( "winetest_dir3" );
-    ok(ret, "failed to remove directory, error %u\n", GetLastError());
+    ok(ret, "failed to remove directory, error %lu\n", GetLastError());
     ret = RemoveDirectoryA( "winetest_file2" );
-    ok(ret, "failed to remove directory, error %u\n", GetLastError());
+    ok(ret, "failed to remove directory, error %lu\n", GetLastError());
     ret = DeleteFileA( "winetest_file1" );
-    ok(ret, "failed to delete file, error %u\n", GetLastError());
+    ok(ret, "failed to delete file, error %lu\n", GetLastError());
     SetCurrentDirectoryA( cwd );
 }
 
@@ -5954,23 +5954,23 @@ static void test_eof(void)
     GetTempFileNameA(temp_path, "eof", 0, filename);
 
     file = CreateFileA(filename, GENERIC_READ | GENERIC_WRITE | DELETE, 0, NULL, CREATE_ALWAYS, 0, 0);
-    ok(file != INVALID_HANDLE_VALUE, "failed to create file, error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "failed to create file, error %lu\n", GetLastError());
 
     ret = GetFileSizeEx(file, &file_size);
-    ok(ret, "failed to get size, error %u\n", GetLastError());
+    ok(ret, "failed to get size, error %lu\n", GetLastError());
     ok(!file_size.QuadPart, "got size %I64d\n", file_size.QuadPart);
 
     SetFilePointer(file, 2, NULL, SEEK_SET);
 
     ret = GetFileSizeEx(file, &file_size);
-    ok(ret, "failed to get size, error %u\n", GetLastError());
+    ok(ret, "failed to get size, error %lu\n", GetLastError());
     ok(!file_size.QuadPart, "got size %I64d\n", file_size.QuadPart);
 
     SetLastError(0xdeadbeef);
     ret = ReadFile(file, buffer, sizeof(buffer), &size, NULL);
-    ok(ret, "failed to read, error %u\n", GetLastError());
-    ok(!size, "got size %u\n", size);
-    ok(GetLastError() == 0xdeadbeef, "got error %u\n", GetLastError());
+    ok(ret, "failed to read, error %lu\n", GetLastError());
+    ok(!size, "got size %lu\n", size);
+    ok(GetLastError() == 0xdeadbeef, "got error %lu\n", GetLastError());
 
     SetFilePointer(file, 2, NULL, SEEK_SET);
 
@@ -5979,155 +5979,155 @@ static void test_eof(void)
     overlapped.Offset = 2;
     ret = ReadFile(file, buffer, sizeof(buffer), &size, &overlapped);
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_HANDLE_EOF, "got error %u\n", GetLastError());
-    ok(!size, "got size %u\n", size);
-    todo_wine ok((NTSTATUS)overlapped.Internal == STATUS_PENDING, "got status %#x\n", (NTSTATUS)overlapped.Internal);
+    ok(GetLastError() == ERROR_HANDLE_EOF, "got error %lu\n", GetLastError());
+    ok(!size, "got size %lu\n", size);
+    todo_wine ok((NTSTATUS)overlapped.Internal == STATUS_PENDING, "got status %#lx\n", (NTSTATUS)overlapped.Internal);
     ok(!overlapped.InternalHigh, "got size %Iu\n", overlapped.InternalHigh);
 
     SetFilePointer(file, 2, NULL, SEEK_SET);
 
     ret = SetEndOfFile(file);
-    ok(ret, "failed to set EOF, error %u\n", GetLastError());
+    ok(ret, "failed to set EOF, error %lu\n", GetLastError());
 
     ret = GetFileSizeEx(file, &file_size);
-    ok(ret, "failed to get size, error %u\n", GetLastError());
+    ok(ret, "failed to get size, error %lu\n", GetLastError());
     ok(file_size.QuadPart == 2, "got size %I64d\n", file_size.QuadPart);
 
     ret = WriteFile(file, "data", 4, &size, NULL);
-    ok(ret, "failed to write, error %u\n", GetLastError());
-    ok(size == 4, "got size %u\n", size);
+    ok(ret, "failed to write, error %lu\n", GetLastError());
+    ok(size == 4, "got size %lu\n", size);
 
     ret = GetFileSizeEx(file, &file_size);
-    ok(ret, "failed to get size, error %u\n", GetLastError());
+    ok(ret, "failed to get size, error %lu\n", GetLastError());
     ok(file_size.QuadPart == 6, "got size %I64d\n", file_size.QuadPart);
 
     SetFilePointer(file, 4, NULL, SEEK_SET);
     ret = SetEndOfFile(file);
-    ok(ret, "failed to set EOF, error %u\n", GetLastError());
+    ok(ret, "failed to set EOF, error %lu\n", GetLastError());
 
     ret = GetFileSizeEx(file, &file_size);
-    ok(ret, "failed to get size, error %u\n", GetLastError());
+    ok(ret, "failed to get size, error %lu\n", GetLastError());
     ok(file_size.QuadPart == 4, "got size %I64d\n", file_size.QuadPart);
 
     SetFilePointer(file, 0, NULL, SEEK_SET);
     ret = ReadFile(file, buffer, sizeof(buffer), &size, NULL);
-    ok(ret, "failed to read, error %u\n", GetLastError());
-    ok(size == 4, "got size %u\n", size);
+    ok(ret, "failed to read, error %lu\n", GetLastError());
+    ok(size == 4, "got size %lu\n", size);
     ok(!memcmp(buffer, "\0\0da", 4), "wrong data\n");
 
     SetFilePointer(file, 6, NULL, SEEK_SET);
     ret = SetEndOfFile(file);
-    ok(ret, "failed to set EOF, error %u\n", GetLastError());
+    ok(ret, "failed to set EOF, error %lu\n", GetLastError());
 
     ret = GetFileSizeEx(file, &file_size);
-    ok(ret, "failed to get size, error %u\n", GetLastError());
+    ok(ret, "failed to get size, error %lu\n", GetLastError());
     ok(file_size.QuadPart == 6, "got size %I64d\n", file_size.QuadPart);
 
     SetFilePointer(file, 0, NULL, SEEK_SET);
     ret = ReadFile(file, buffer, sizeof(buffer), &size, NULL);
-    ok(ret, "failed to read, error %u\n", GetLastError());
-    ok(size == 6, "got size %u\n", size);
+    ok(ret, "failed to read, error %lu\n", GetLastError());
+    ok(size == 6, "got size %lu\n", size);
     ok(!memcmp(buffer, "\0\0da\0\0", 6), "wrong data\n");
 
     ret = SetEndOfFile(file);
-    ok(ret, "failed to set EOF, error %u\n", GetLastError());
+    ok(ret, "failed to set EOF, error %lu\n", GetLastError());
 
     SetFilePointer(file, 2, NULL, SEEK_SET);
     ret = WriteFile(file, "data", 4, &size, NULL);
-    ok(ret, "failed to write, error %u\n", GetLastError());
-    ok(size == 4, "got size %u\n", size);
+    ok(ret, "failed to write, error %lu\n", GetLastError());
+    ok(size == 4, "got size %lu\n", size);
 
     ret = GetFileSizeEx(file, &file_size);
-    ok(ret, "failed to get size, error %u\n", GetLastError());
+    ok(ret, "failed to get size, error %lu\n", GetLastError());
     ok(file_size.QuadPart == 6, "got size %I64d\n", file_size.QuadPart);
 
     SetFilePointer(file, 0, NULL, SEEK_SET);
     ret = ReadFile(file, buffer, sizeof(buffer), &size, NULL);
-    ok(ret, "failed to read, error %u\n", GetLastError());
-    ok(size == 6, "got size %u\n", size);
+    ok(ret, "failed to read, error %lu\n", GetLastError());
+    ok(size == 6, "got size %lu\n", size);
     ok(!memcmp(buffer, "\0\0data", 6), "wrong data\n");
 
     for (i = 0; i < ARRAY_SIZE(map_tests); ++i)
     {
         mapping = CreateFileMappingA(file, NULL, map_tests[i].protection, 0, 4, NULL);
-        ok(!!mapping, "failed to create mapping, error %u\n", GetLastError());
+        ok(!!mapping, "failed to create mapping, error %lu\n", GetLastError());
 
         ret = GetFileSizeEx(file, &file_size);
-        ok(ret, "failed to get size, error %u\n", GetLastError());
+        ok(ret, "failed to get size, error %lu\n", GetLastError());
         ok(file_size.QuadPart == 6, "got size %I64d\n", file_size.QuadPart);
 
         SetFilePointer(file, 6, NULL, SEEK_SET);
         ret = SetEndOfFile(file);
-        ok(ret, "failed to set EOF, error %u\n", GetLastError());
+        ok(ret, "failed to set EOF, error %lu\n", GetLastError());
         ret = GetFileSizeEx(file, &file_size);
-        ok(ret, "failed to get size, error %u\n", GetLastError());
+        ok(ret, "failed to get size, error %lu\n", GetLastError());
         ok(file_size.QuadPart == 6, "got size %I64d\n", file_size.QuadPart);
 
         SetFilePointer(file, 8, NULL, SEEK_SET);
         ret = SetEndOfFile(file);
-        ok(ret, "failed to set EOF, error %u\n", GetLastError());
+        ok(ret, "failed to set EOF, error %lu\n", GetLastError());
         ret = GetFileSizeEx(file, &file_size);
-        ok(ret, "failed to get size, error %u\n", GetLastError());
+        ok(ret, "failed to get size, error %lu\n", GetLastError());
         ok(file_size.QuadPart == 8, "got size %I64d\n", file_size.QuadPart);
 
         SetLastError(0xdeadbeef);
         SetFilePointer(file, 6, NULL, SEEK_SET);
         ret = SetEndOfFile(file);
         ok(!ret, "expected failure\n");
-        ok(GetLastError() == ERROR_USER_MAPPED_FILE, "got error %u\n", GetLastError());
+        ok(GetLastError() == ERROR_USER_MAPPED_FILE, "got error %lu\n", GetLastError());
         ret = GetFileSizeEx(file, &file_size);
-        ok(ret, "failed to get size, error %u\n", GetLastError());
+        ok(ret, "failed to get size, error %lu\n", GetLastError());
         ok(file_size.QuadPart == 8, "got size %I64d\n", file_size.QuadPart);
 
         SetFilePointer(file, 8192, NULL, SEEK_SET);
         ret = SetEndOfFile(file);
-        ok(ret, "failed to set EOF, error %u\n", GetLastError());
+        ok(ret, "failed to set EOF, error %lu\n", GetLastError());
         ret = GetFileSizeEx(file, &file_size);
-        ok(ret, "failed to get size, error %u\n", GetLastError());
+        ok(ret, "failed to get size, error %lu\n", GetLastError());
         ok(file_size.QuadPart == 8192, "got size %I64d\n", file_size.QuadPart);
 
         SetFilePointer(file, 8191, NULL, SEEK_SET);
         ret = SetEndOfFile(file);
         ok(!ret, "expected failure\n");
-        ok(GetLastError() == ERROR_USER_MAPPED_FILE, "got error %u\n", GetLastError());
+        ok(GetLastError() == ERROR_USER_MAPPED_FILE, "got error %lu\n", GetLastError());
         ret = GetFileSizeEx(file, &file_size);
-        ok(ret, "failed to get size, error %u\n", GetLastError());
+        ok(ret, "failed to get size, error %lu\n", GetLastError());
         ok(file_size.QuadPart == 8192, "got size %I64d\n", file_size.QuadPart);
 
         view = MapViewOfFile(mapping, map_tests[i].view_access, 0, 0, 4);
-        ok(!!view, "failed to map view, error %u\n", GetLastError());
+        ok(!!view, "failed to map view, error %lu\n", GetLastError());
 
         CloseHandle(mapping);
 
         SetFilePointer(file, 16384, NULL, SEEK_SET);
         ret = SetEndOfFile(file);
-        ok(ret, "failed to set EOF, error %u\n", GetLastError());
+        ok(ret, "failed to set EOF, error %lu\n", GetLastError());
         ret = GetFileSizeEx(file, &file_size);
-        ok(ret, "failed to get size, error %u\n", GetLastError());
+        ok(ret, "failed to get size, error %lu\n", GetLastError());
         ok(file_size.QuadPart == 16384, "got size %I64d\n", file_size.QuadPart);
 
         SetFilePointer(file, 16383, NULL, SEEK_SET);
         ret = SetEndOfFile(file);
         ok(!ret, "expected failure\n");
-        ok(GetLastError() == ERROR_USER_MAPPED_FILE, "got error %u\n", GetLastError());
+        ok(GetLastError() == ERROR_USER_MAPPED_FILE, "got error %lu\n", GetLastError());
         ret = GetFileSizeEx(file, &file_size);
-        ok(ret, "failed to get size, error %u\n", GetLastError());
+        ok(ret, "failed to get size, error %lu\n", GetLastError());
         ok(file_size.QuadPart == 16384, "got size %I64d\n", file_size.QuadPart);
 
         ret = UnmapViewOfFile(view);
-        ok(ret, "failed to unmap view, error %u\n", GetLastError());
+        ok(ret, "failed to unmap view, error %lu\n", GetLastError());
 
         SetFilePointer(file, 6, NULL, SEEK_SET);
         ret = SetEndOfFile(file);
-        ok(ret, "failed to set EOF, error %u\n", GetLastError());
+        ok(ret, "failed to set EOF, error %lu\n", GetLastError());
         ret = GetFileSizeEx(file, &file_size);
-        ok(ret, "failed to get size, error %u\n", GetLastError());
+        ok(ret, "failed to get size, error %lu\n", GetLastError());
         ok(file_size.QuadPart == 6, "got size %I64d\n", file_size.QuadPart);
     }
 
     CloseHandle(file);
     ret = DeleteFileA(filename);
-    ok(ret, "failed to delete %s, error %u\n", debugstr_a(filename), GetLastError());
+    ok(ret, "failed to delete %s, error %lu\n", debugstr_a(filename), GetLastError());
 }
 
 START_TEST(file)
@@ -6138,11 +6138,11 @@ START_TEST(file)
     InitFunctionPointers();
 
     ret = GetTempPathA(MAX_PATH, temp_path);
-    ok(ret != 0, "GetTempPath error %u\n", GetLastError());
+    ok(ret != 0, "GetTempPath error %lu\n", GetLastError());
     ret = GetTempFileNameA(temp_path, "tmp", 0, filename);
-    ok(ret != 0, "GetTempFileName error %u\n", GetLastError());
+    ok(ret != 0, "GetTempFileName error %lu\n", GetLastError());
     ret = DeleteFileA(filename);
-    ok(ret != 0, "DeleteFile error %u\n", GetLastError());
+    ok(ret != 0, "DeleteFile error %lu\n", GetLastError());
 
     test__hread(  );
     test__hwrite(  );
diff --git a/dlls/kernel32/tests/format_msg.c b/dlls/kernel32/tests/format_msg.c
index 0e09ba904d0..2d317d1bb9e 100644
--- a/dlls/kernel32/tests/format_msg.c
+++ b/dlls/kernel32/tests/format_msg.c
@@ -60,7 +60,7 @@ static void test_message_from_string_wide(void)
     /* the basics */
     r = FormatMessageW(FORMAT_MESSAGE_FROM_STRING, L"test", 0, 0, out, ARRAY_SIZE(out), NULL);
     ok(!lstrcmpW(L"test", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4, "failed: r=%d\n", r);
+    ok(r==4, "failed: r=%ld\n", r);
 
     /* null string, crashes on Windows */
     if (0)
@@ -76,8 +76,8 @@ static void test_message_from_string_wide(void)
     r = FormatMessageW(FORMAT_MESSAGE_FROM_STRING, L"", 0, 0, out, ARRAY_SIZE(out), NULL);
     error = GetLastError();
     ok(!lstrcmpW(L"", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==0, "succeeded: r=%d\n", r);
-    ok(error == ERROR_NO_WORK_DONE || broken(error == 0xdeadbeef), "last error %u\n", error);
+    ok(r==0, "succeeded: r=%ld\n", r);
+    ok(error == ERROR_NO_WORK_DONE || broken(error == 0xdeadbeef), "last error %lu\n", error);
 
     /* format placeholder with no specifier */
     SetLastError(0xdeadbeef);
@@ -86,8 +86,8 @@ static void test_message_from_string_wide(void)
     error = GetLastError();
     ok(!lstrcmpW( out, L"xxxxxx" ),
        "Expected the buffer to be unchanged\n");
-    ok(r==0, "succeeded: r=%d\n", r);
-    ok(error==ERROR_INVALID_PARAMETER, "last error %u\n", error);
+    ok(r==0, "succeeded: r=%ld\n", r);
+    ok(error==ERROR_INVALID_PARAMETER, "last error %lu\n", error);
 
     /* test string with format placeholder with no specifier */
     SetLastError(0xdeadbeef);
@@ -96,8 +96,8 @@ static void test_message_from_string_wide(void)
     error = GetLastError();
     ok(!lstrcmpW(out, L"testxx") || broken(!lstrcmpW( out, L"xxxxxx" )), /* winxp */
        "Expected the buffer to be unchanged\n");
-    ok(r==0, "succeeded: r=%d\n", r);
-    ok(error==ERROR_INVALID_PARAMETER, "last error %u\n", error);
+    ok(r==0, "succeeded: r=%ld\n", r);
+    ok(error==ERROR_INVALID_PARAMETER, "last error %lu\n", error);
 
     /* insertion with no variadic arguments */
     SetLastError(0xdeadbeef);
@@ -106,8 +106,8 @@ static void test_message_from_string_wide(void)
     error = GetLastError();
     ok(!lstrcmpW( out, L"xxxxxx" ),
        "Expected the buffer to be unchanged\n");
-    ok(r==0, "succeeded: r=%d\n", r);
-    ok(error==ERROR_INVALID_PARAMETER, "last error %u\n", error);
+    ok(r==0, "succeeded: r=%ld\n", r);
+    ok(error==ERROR_INVALID_PARAMETER, "last error %lu\n", error);
 
     SetLastError(0xdeadbeef);
     lstrcpyW( out, L"xxxxxx" );
@@ -116,194 +116,194 @@ static void test_message_from_string_wide(void)
     error = GetLastError();
     ok(!lstrcmpW( out, L"xxxxxx" ),
        "Expected the buffer to be unchanged\n");
-    ok(r==0, "succeeded: r=%d\n", r);
-    ok(error==ERROR_INVALID_PARAMETER, "last error %u\n", error);
+    ok(r==0, "succeeded: r=%ld\n", r);
+    ok(error==ERROR_INVALID_PARAMETER, "last error %lu\n", error);
 
     /* using the format feature */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!s!", 0, 0, out, ARRAY_SIZE(out), L"test");
     ok(!lstrcmpW(L"test", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* no format */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1", 0, 0, out, ARRAY_SIZE(out), L"test");
     ok(!lstrcmpW(L"test", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* two pieces */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1%2", 0, 0, out, ARRAY_SIZE(out), L"te", L"st");
     ok(!lstrcmpW(L"test", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* three pieces */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1%3%2%1", 0, 0, out, ARRAY_SIZE(out), L"t", L"s", L"e");
     ok(!lstrcmpW(L"test", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* ls is unicode */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!ls!", 0, 0, out, ARRAY_SIZE(out), L"test");
     ok(!lstrcmpW(L"test", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4, "failed: r=%d\n", r);
+    ok(r==4, "failed: r=%ld\n", r);
 
     /* S is ansi */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!S!", 0, 0, out, ARRAY_SIZE(out), "test");
     ok(!lstrcmpW(L"test", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4, "failed: r=%d\n", r);
+    ok(r==4, "failed: r=%ld\n", r);
 
     /* ws is unicode */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!ws!", 0, 0, out, ARRAY_SIZE(out), L"test");
     ok(!lstrcmpW(L"test", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4, "failed: r=%d\n", r);
+    ok(r==4, "failed: r=%ld\n", r);
 
     /* as characters */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!c!%2!c!%3!c!%1!c!", 0, 0, out, ARRAY_SIZE(out), 't', 'e', 's');
     ok(!lstrcmpW(L"test", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* lc is unicode */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!lc!%2!lc!%3!lc!%1!lc!", 0, 0, out, ARRAY_SIZE(out), 't', 'e', 's');
     ok(!lstrcmpW(L"test", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* wc is unicode */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!wc!%2!wc!%3!wc!%1!wc!", 0, 0, out, ARRAY_SIZE(out), 't', 'e', 's');
     ok(!lstrcmpW(L"test", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* C is unicode */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!C!%2!C!%3!C!%1!C!", 0, 0, out, ARRAY_SIZE(out), 't', 'e', 's');
     ok(!lstrcmpW(L"test", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* some numbers */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!d!%2!d!%3!d!", 0, 0, out, ARRAY_SIZE(out), 1, 2, 3);
     ok(!lstrcmpW(L"123", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==3,"failed: r=%d\n", r);
+    ok(r==3,"failed: r=%ld\n", r);
 
     /* a single digit with some spacing */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!4d!", 0, 0, out, ARRAY_SIZE(out), 1);
     ok(!lstrcmpW(L"   1", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* a single digit, left justified */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!-4d!", 0, 0, out, ARRAY_SIZE(out), 1);
     ok(!lstrcmpW(L"1   ", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* two digit decimal number */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!4d!", 0, 0, out, ARRAY_SIZE(out), 11);
     ok(!lstrcmpW(L"  11", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* a hex number */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!4x!", 0, 0, out, ARRAY_SIZE(out), 11);
     ok(!lstrcmpW(L"   b", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* a hex number, upper case */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!4X!", 0, 0, out, ARRAY_SIZE(out), 11);
     ok(!lstrcmpW(L"   B", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* a hex number, upper case, left justified */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!-4X!", 0, 0, out, ARRAY_SIZE(out), 11);
     ok(!lstrcmpW(L"B   ", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* a long hex number, upper case */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!4X!", 0, 0, out, ARRAY_SIZE(out), 0x1ab);
     ok(!lstrcmpW(L" 1AB", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* two percent... */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L" %%%% ", 0, 0, out, ARRAY_SIZE(out));
     ok(!lstrcmpW(L" %% ", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* periods are special cases */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L" %.%.  %1!d!", 0, 0, out, ARRAY_SIZE(out), 0x1ab);
     ok(!lstrcmpW(L" ..  427", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==8,"failed: r=%d\n", r);
+    ok(r==8,"failed: r=%ld\n", r);
 
     /* %0 ends the line */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"test%0test", 0, 0, out, ARRAY_SIZE(out));
     ok(!lstrcmpW(L"test", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* %! prints an exclamation */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"yah%!%0   ", 0, 0, out, ARRAY_SIZE(out));
     ok(!lstrcmpW(L"yah!", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* %space */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"% %   ", 0, 0, out, ARRAY_SIZE(out));
     ok(!lstrcmpW(L"    ", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* %n yields \r\n, %r yields \r, %t yields \t */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%n%r%t", 0, 0, out, ARRAY_SIZE(out));
     ok(!lstrcmpW(L"\r\n\r\t", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* line feed */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"hi\n", 0, 0, out, ARRAY_SIZE(out));
     ok(!lstrcmpW(L"hi\r\n", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* carriage return line feed */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"hi\r\n", 0, 0, out, ARRAY_SIZE(out));
     ok(!lstrcmpW(L"hi\r\n", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* carriage return */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"\r", 0, 0, out, ARRAY_SIZE(out));
     ok(!lstrcmpW(L"\r\n", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==2,"failed: r=%d\n", r);
+    ok(r==2,"failed: r=%ld\n", r);
 
     /* double carriage return line feed */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"\r\r\n", 0, 0, out, ARRAY_SIZE(out));
     ok(!lstrcmpW(L"\r\n\r\n", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n", r);
+    ok(r==4,"failed: r=%ld\n", r);
 
     /* null string as argument */
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1", 0, 0, out, ARRAY_SIZE(out), NULL);
     ok(!lstrcmpW(L"(null)", out),"failed out=[%s]\n", wine_dbgstr_w(out));
-    ok(r==6,"failed: r=%d\n",r);
+    ok(r==6,"failed: r=%ld\n",r);
 
     /* precision and width */
 
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!3s!", 0, 0, out, ARRAY_SIZE(out), L"t" );
     ok(!lstrcmpW(L"  t", out),"failed out=[%s]\n", wine_dbgstr_w(out));
-    ok(r==3, "failed: r=%d\n",r);
+    ok(r==3, "failed: r=%ld\n",r);
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!*s!", 0, 0, out, ARRAY_SIZE(out), 4, L"t" );
     ok(!lstrcmpW( L"   t", out),"failed out=[%s]\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!4.2u!", 0, 0, out, ARRAY_SIZE(out), 3 );
     ok(!lstrcmpW( L"  03", out),"failed out=[%s]\n", wine_dbgstr_w(out));
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!*.*u!", 0, 0, out, ARRAY_SIZE(out), 5, 3, 1 );
     ok(!lstrcmpW( L"  001", out),"failed out=[%s]\n", wine_dbgstr_w(out));
-    ok(r==5,"failed: r=%d\n",r);
+    ok(r==5,"failed: r=%ld\n",r);
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!*.*u!,%1!*.*u!", 0, 0, out, ARRAY_SIZE(out),
               5, 3, 1, 4, 2 );
     ok(!lstrcmpW( L"  001, 0002", out),"failed out=[%s]\n", wine_dbgstr_w(out));
-    ok(r==11,"failed: r=%d\n",r);
+    ok(r==11,"failed: r=%ld\n",r);
     r = doitW(FORMAT_MESSAGE_FROM_STRING, L"%1!*.*u!,%3!*.*u!", 0, 0, out, ARRAY_SIZE(out),
               5, 3, 1, 6, 4, 2 );
     ok(!lstrcmpW( L"  001,  0002", out) ||
        broken(!lstrcmpW(L"  001,000004", out)), /* NT4/Win2k */
        "failed out=[%s]\n", wine_dbgstr_w(out));
-    ok(r==12,"failed: r=%d\n",r);
+    ok(r==12,"failed: r=%ld\n",r);
     /* args are not counted the same way with an argument array */
     {
         ULONG_PTR args[] = { 6, 4, 2, 5, 3, 1 };
         r = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, L"%1!*.*u!,%1!*.*u!",
                            0, 0, out, ARRAY_SIZE(out), (va_list *)args );
         ok(!lstrcmpW(L"  0002, 00003", out),"failed out=[%s]\n", wine_dbgstr_w(out));
-        ok(r==13,"failed: r=%d\n",r);
+        ok(r==13,"failed: r=%ld\n",r);
         r = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, L"%1!*.*u!,%4!*.*u!",
                            0, 0, out, ARRAY_SIZE(out), (va_list *)args );
         ok(!lstrcmpW(L"  0002,  001", out),"failed out=[%s]\n", wine_dbgstr_w(out));
-        ok(r==12,"failed: r=%d\n",r);
+        ok(r==12,"failed: r=%ld\n",r);
     }
 
     /* change of pace... test the low byte of dwflags */
@@ -312,25 +312,25 @@ static void test_message_from_string_wide(void)
     r = doitW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK, L"hi\n", 0,
               0, out, ARRAY_SIZE(out));
     ok(!lstrcmpW(L"hi ", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==3,"failed: r=%d\n", r);
+    ok(r==3,"failed: r=%ld\n", r);
 
     /* carriage return line feed */
     r = doitW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK, L"hi\r\n", 0,
               0, out, ARRAY_SIZE(out));
     ok(!lstrcmpW(L"hi ", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==3,"failed: r=%d\n", r);
+    ok(r==3,"failed: r=%ld\n", r);
 
     /* carriage return */
     r = doitW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK, L"\r", 0,
               0, out, ARRAY_SIZE(out));
     ok(!lstrcmpW(L" ", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==1,"failed: r=%d\n", r);
+    ok(r==1,"failed: r=%ld\n", r);
 
     /* double carriage return line feed */
     r = doitW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK, L"\r\r\n", 0,
               0, out, ARRAY_SIZE(out));
     ok(!lstrcmpW(L"  ", out), "failed out=%s\n", wine_dbgstr_w(out));
-    ok(r==2,"failed: r=%d\n", r);
+    ok(r==2,"failed: r=%ld\n", r);
 }
 
 static void test_message_from_string(void)
@@ -342,7 +342,7 @@ static void test_message_from_string(void)
     /* the basics */
     r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING, "test", 0, 0, out, ARRAY_SIZE(out),NULL);
     ok(!strcmp("test", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* null string, crashes on Windows */
     if (0)
@@ -357,9 +357,9 @@ static void test_message_from_string(void)
     memcpy(out, init_buf, sizeof(init_buf));
     r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING, "", 0, 0, out, ARRAY_SIZE(out), NULL);
     ok(!memcmp(out, init_buf, sizeof(init_buf)), "Expected the buffer to be untouched\n");
-    ok(r==0, "succeeded: r=%d\n", r);
+    ok(r==0, "succeeded: r=%ld\n", r);
     ok(GetLastError() == ERROR_NO_WORK_DONE || broken(GetLastError() == 0xdeadbeef),
-       "last error %u\n", GetLastError());
+       "last error %lu\n", GetLastError());
 
     /* format placeholder with no specifier */
     SetLastError(0xdeadbeef);
@@ -367,9 +367,9 @@ static void test_message_from_string(void)
     r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING, "%", 0, 0, out, ARRAY_SIZE(out), NULL);
     ok(!memcmp(out, init_buf, sizeof(init_buf)),
        "Expected the buffer to be untouched\n");
-    ok(r==0, "succeeded: r=%d\n", r);
+    ok(r==0, "succeeded: r=%ld\n", r);
     ok(GetLastError()==ERROR_INVALID_PARAMETER,
-       "last error %u\n", GetLastError());
+       "last error %lu\n", GetLastError());
 
     /* test string with format placeholder with no specifier */
     SetLastError(0xdeadbeef);
@@ -377,210 +377,210 @@ static void test_message_from_string(void)
     r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING, "test%", 0, 0, out, ARRAY_SIZE(out), NULL);
     ok(!memcmp(out, init_buf, sizeof(init_buf)),
        "Expected the buffer to be untouched\n");
-    ok(r==0, "succeeded: r=%d\n", r);
+    ok(r==0, "succeeded: r=%ld\n", r);
     ok(GetLastError()==ERROR_INVALID_PARAMETER,
-       "last error %u\n", GetLastError());
+       "last error %lu\n", GetLastError());
 
     /* insertion with no variadic arguments */
     SetLastError(0xdeadbeef);
     memcpy(out, init_buf, sizeof(init_buf));
     r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING, "%1", 0, 0, out, ARRAY_SIZE(out), NULL);
     ok(!memcmp(out, init_buf, sizeof(init_buf)), "Expected the buffer to be untouched\n");
-    ok(r==0, "succeeded: r=%d\n", r);
-    ok(GetLastError()==ERROR_INVALID_PARAMETER, "last error %u\n", GetLastError());
+    ok(r==0, "succeeded: r=%ld\n", r);
+    ok(GetLastError()==ERROR_INVALID_PARAMETER, "last error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     memcpy(out, init_buf, sizeof(init_buf));
     r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, "%1", 0,
                        0, out, ARRAY_SIZE(out), NULL);
     ok(!memcmp(out, init_buf, sizeof(init_buf)), "Expected the buffer to be untouched\n");
-    ok(r==0, "succeeded: r=%d\n", r);
-    ok(GetLastError()==ERROR_INVALID_PARAMETER, "last error %u\n", GetLastError());
+    ok(r==0, "succeeded: r=%ld\n", r);
+    ok(GetLastError()==ERROR_INVALID_PARAMETER, "last error %lu\n", GetLastError());
 
     /* using the format feature */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!s!", 0, 0, out, ARRAY_SIZE(out), "test");
     ok(!strcmp("test", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* no format */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1", 0, 0, out, ARRAY_SIZE(out), "test");
     ok(!strcmp("test", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* two pieces */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1%2", 0, 0, out, ARRAY_SIZE(out), "te","st");
     ok(!strcmp("test", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* three pieces */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1%3%2%1", 0, 0, out, ARRAY_SIZE(out), "t","s","e");
     ok(!strcmp("test", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* s is ansi */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!s!", 0, 0, out, ARRAY_SIZE(out), "test");
     ok(!strcmp("test", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* ls is unicode */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!ls!", 0, 0, out, ARRAY_SIZE(out), L"test");
     ok(!strcmp("test", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* S is unicode */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!S!", 0, 0, out, ARRAY_SIZE(out), L"test");
     ok(!strcmp("test", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* ws is unicode */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!ws!", 0, 0, out, ARRAY_SIZE(out), L"test");
     ok(!strcmp("test", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* as characters */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!c!%2!c!%3!c!%1!c!", 0, 0, out, ARRAY_SIZE(out),
              't','e','s');
     ok(!strcmp("test", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* lc is unicode */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!lc!%2!lc!%3!lc!%1!lc!", 0, 0, out, ARRAY_SIZE(out),
              't','e','s');
     ok(!strcmp("test", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* wc is unicode */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!wc!%2!wc!%3!wc!%1!wc!", 0, 0, out, ARRAY_SIZE(out),
              't','e','s');
     ok(!strcmp("test", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* C is unicode */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!C!%2!C!%3!C!%1!C!", 0, 0, out, ARRAY_SIZE(out),
              't','e','s');
     ok(!strcmp("test", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* some numbers */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!d!%2!d!%3!d!", 0, 0, out, ARRAY_SIZE(out), 1,2,3);
     ok(!strcmp("123", out),"failed out=[%s]\n",out);
-    ok(r==3,"failed: r=%d\n",r);
+    ok(r==3,"failed: r=%ld\n",r);
 
     /* a single digit with some spacing */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4d!", 0, 0, out, ARRAY_SIZE(out), 1);
     ok(!strcmp("   1", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* a single digit, left justified */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!-4d!", 0, 0, out, ARRAY_SIZE(out), 1);
     ok(!strcmp("1   ", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* two digit decimal number */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4d!", 0, 0, out, ARRAY_SIZE(out), 11);
     ok(!strcmp("  11", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* a hex number */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4x!", 0, 0, out, ARRAY_SIZE(out), 11);
     ok(!strcmp("   b", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* a hex number, upper case */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4X!", 0, 0, out, ARRAY_SIZE(out), 11);
     ok(!strcmp("   B", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* a hex number, upper case, left justified */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!-4X!", 0, 0, out, ARRAY_SIZE(out), 11);
     ok(!strcmp("B   ", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* a long hex number, upper case */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4X!", 0, 0, out, ARRAY_SIZE(out), 0x1ab);
     ok(!strcmp(" 1AB", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* two percent... */
     r = doit(FORMAT_MESSAGE_FROM_STRING, " %%%% ", 0, 0, out, ARRAY_SIZE(out));
     ok(!strcmp(" %% ", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* periods are special cases */
     r = doit(FORMAT_MESSAGE_FROM_STRING, " %.%. %1!d!", 0, 0, out, ARRAY_SIZE(out), 0x1ab);
     ok(!strcmp(" .. 427", out),"failed out=[%s]\n",out);
-    ok(r==7,"failed: r=%d\n",r);
+    ok(r==7,"failed: r=%ld\n",r);
 
     /* %0 ends the line */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "test%0test", 0, 0, out, ARRAY_SIZE(out));
     ok(!strcmp("test", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* %! prints an exclamation */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "yah%!%0   ", 0, 0, out, ARRAY_SIZE(out));
     ok(!strcmp("yah!", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* %space */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "% %   ", 0, 0, out, ARRAY_SIZE(out));
     ok(!strcmp("    ", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* %n yields \r\n, %r yields \r, %t yields \t */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%n%r%t", 0, 0, out, ARRAY_SIZE(out));
     ok(!strcmp("\r\n\r\t", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* line feed */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "hi\n", 0, 0, out, ARRAY_SIZE(out));
     ok(!strcmp("hi\r\n", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* carriage return line feed */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "hi\r\n", 0, 0, out, ARRAY_SIZE(out));
     ok(!strcmp("hi\r\n", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* carriage return */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "\r", 0, 0, out, ARRAY_SIZE(out));
     ok(!strcmp("\r\n", out),"failed out=[%s]\n",out);
-    ok(r==2,"failed: r=%d\n",r);
+    ok(r==2,"failed: r=%ld\n",r);
 
     /* double carriage return line feed */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "\r\r\n", 0, 0, out, ARRAY_SIZE(out));
     ok(!strcmp("\r\n\r\n", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
+    ok(r==4,"failed: r=%ld\n",r);
 
     /* null string as argument */
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1", 0, 0, out, ARRAY_SIZE(out), NULL);
     ok(!strcmp("(null)", out),"failed out=[%s]\n",out);
-    ok(r==6,"failed: r=%d\n",r);
+    ok(r==6,"failed: r=%ld\n",r);
 
     /* precision and width */
 
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!3s!",
              0, 0, out, sizeof(out), "t" );
     ok(!strcmp("  t", out),"failed out=[%s]\n",out);
-    ok(r==3, "failed: r=%d\n",r);
+    ok(r==3, "failed: r=%ld\n",r);
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*s!",
              0, 0, out, sizeof(out), 4, "t");
     if (!strcmp("*s",out)) win_skip( "width/precision not supported\n" );
     else
     {
         ok(!strcmp( "   t", out),"failed out=[%s]\n",out);
-        ok(r==4,"failed: r=%d\n",r);
+        ok(r==4,"failed: r=%ld\n",r);
         r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4.2u!",
                  0, 0, out, sizeof(out), 3 );
         ok(!strcmp( "  03", out),"failed out=[%s]\n",out);
-        ok(r==4,"failed: r=%d\n",r);
+        ok(r==4,"failed: r=%ld\n",r);
         r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*.*u!",
                  0, 0, out, sizeof(out), 5, 3, 1 );
         ok(!strcmp( "  001", out),"failed out=[%s]\n",out);
-        ok(r==5,"failed: r=%d\n",r);
+        ok(r==5,"failed: r=%ld\n",r);
         r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*.*u!,%1!*.*u!",
                  0, 0, out, sizeof(out), 5, 3, 1, 4, 2 );
         ok(!strcmp( "  001, 0002", out),"failed out=[%s]\n",out);
-        ok(r==11,"failed: r=%d\n",r);
+        ok(r==11,"failed: r=%ld\n",r);
         r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*.*u!,%3!*.*u!",
                  0, 0, out, sizeof(out), 5, 3, 1, 6, 4, 2 );
         /* older Win versions marked as broken even though this is arguably the correct behavior */
@@ -588,18 +588,18 @@ static void test_message_from_string(void)
         ok(!strcmp( "  001,  0002", out) ||
            broken(!strcmp("  001,000004", out)), /* NT4/Win2k */
            "failed out=[%s]\n",out);
-        ok(r==12,"failed: r=%d\n",r);
+        ok(r==12,"failed: r=%ld\n",r);
         /* args are not counted the same way with an argument array */
         {
             ULONG_PTR args[] = { 6, 4, 2, 5, 3, 1 };
             r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
                                "%1!*.*u!,%1!*.*u!", 0, 0, out, sizeof(out), (va_list *)args );
             ok(!strcmp("  0002, 00003", out),"failed out=[%s]\n",out);
-            ok(r==13,"failed: r=%d\n",r);
+            ok(r==13,"failed: r=%ld\n",r);
             r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
                                "%1!*.*u!,%4!*.*u!", 0, 0, out, sizeof(out), (va_list *)args );
             ok(!strcmp("  0002,  001", out),"failed out=[%s]\n",out);
-            ok(r==12,"failed: r=%d\n",r);
+            ok(r==12,"failed: r=%ld\n",r);
         }
     }
 
@@ -609,25 +609,25 @@ static void test_message_from_string(void)
     r = doit(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK, "hi\n", 0,
              0, out, ARRAY_SIZE(out));
     ok(!strcmp("hi ", out), "failed out=[%s]\n",out);
-    ok(r==3, "failed: r=%d\n",r);
+    ok(r==3, "failed: r=%ld\n",r);
 
     /* carriage return line feed */
     r = doit(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK, "hi\r\n", 0,
              0, out, ARRAY_SIZE(out));
     ok(!strcmp("hi ", out),"failed out=[%s]\n",out);
-    ok(r==3,"failed: r=%d\n",r);
+    ok(r==3,"failed: r=%ld\n",r);
 
     /* carriage return */
     r = doit(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK, "\r", 0,
              0, out, ARRAY_SIZE(out));
     ok(!strcmp(" ", out),"failed out=[%s]\n",out);
-    ok(r==1,"failed: r=%d\n",r);
+    ok(r==1,"failed: r=%ld\n",r);
 
     /* double carriage return line feed */
     r = doit(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK, "\r\r\n", 0,
              0, out, ARRAY_SIZE(out));
     ok(!strcmp("  ", out),"failed out=[%s]\n",out);
-    ok(r==2,"failed: r=%d\n",r);
+    ok(r==2,"failed: r=%ld\n",r);
 }
 
 static void test_message_ignore_inserts(void)
@@ -639,18 +639,18 @@ static void test_message_ignore_inserts(void)
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, "test", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %d\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %ld\n", ret);
     ok(!strcmp("test", out), "Expected output string \"test\", got %s\n", out);
 
     /* The %0 escape sequence is handled. */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, "test%0", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %d\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %ld\n", ret);
     ok(!strcmp("test", out), "Expected output string \"test\", got %s\n", out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, "test%0test", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %d\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %ld\n", ret);
     ok(!strcmp("test", out), "Expected output string \"test\", got %s\n", out);
 
     /* While FormatMessageA returns 0 in this case, no last error code is set. */
@@ -658,68 +658,68 @@ static void test_message_ignore_inserts(void)
     memcpy(out, init_buf, sizeof(init_buf));
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, "%0test", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 0, "Expected FormatMessageA to return 0, got %d\n", ret);
+    ok(ret == 0, "Expected FormatMessageA to return 0, got %ld\n", ret);
     ok(!memcmp(out, init_buf, sizeof(init_buf)), "Expected the output buffer to be untouched\n");
     ok(GetLastError() == ERROR_NO_WORK_DONE || broken(GetLastError() == 0xdeadbeef),
-        "Expected GetLastError() to return ERROR_NO_WORK_DONE, got %u\n", GetLastError());
+        "Expected GetLastError() to return ERROR_NO_WORK_DONE, got %lu\n", GetLastError());
 
     /* Insert sequences are ignored. */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, "test%1%2!*.*s!%99", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 17, "Expected FormatMessageA to return 17, got %d\n", ret);
+    ok(ret == 17, "Expected FormatMessageA to return 17, got %ld\n", ret);
     ok(!strcmp("test%1%2!*.*s!%99", out), "Expected output string \"test%%1%%2!*.*s!%%99\", got %s\n", out);
 
     /* Only the "%n", "%r", and "%t" escape sequences are processed. */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, "%%% %.%!", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 8, "Expected FormatMessageA to return 8, got %d\n", ret);
+    ok(ret == 8, "Expected FormatMessageA to return 8, got %ld\n", ret);
     ok(!strcmp("%%% %.%!", out), "Expected output string \"%%%%%% %%.%%!\", got %s\n", out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, "%n%r%t", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %d\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %ld\n", ret);
     ok(!strcmp("\r\n\r\t", out), "Expected output string \"\\r\\n\\r\\t\", got %s\n", out);
 
     /* CRLF characters are processed normally. */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, "hi\n", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %d\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %ld\n", ret);
     ok(!strcmp("hi\r\n", out), "Expected output string \"hi\\r\\n\", got %s\n", out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, "hi\r\n", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %d\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %ld\n", ret);
     ok(!strcmp("hi\r\n", out), "Expected output string \"hi\\r\\n\", got %s\n", out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, "\r", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 2, "Expected FormatMessageA to return 2, got %d\n", ret);
+    ok(ret == 2, "Expected FormatMessageA to return 2, got %ld\n", ret);
     ok(!strcmp("\r\n", out), "Expected output string \"\\r\\n\", got %s\n", out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, "\r\r\n", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %d\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %ld\n", ret);
     ok(!strcmp("\r\n\r\n", out), "Expected output string \"\\r\\n\\r\\n\", got %s\n", out);
 
     /* The width parameter is handled the same also. */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS |
                          FORMAT_MESSAGE_MAX_WIDTH_MASK, "hi\n", 0, 0, out, ARRAY_SIZE(out), NULL);
     ok(!strcmp("hi ", out), "Expected output string \"hi \", got %s\n", out);
-    ok(ret == 3, "Expected FormatMessageA to return 3, got %d\n", ret);
+    ok(ret == 3, "Expected FormatMessageA to return 3, got %ld\n", ret);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS |
                          FORMAT_MESSAGE_MAX_WIDTH_MASK, "hi\r\n", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 3, "Expected FormatMessageA to return 3, got %d\n", ret);
+    ok(ret == 3, "Expected FormatMessageA to return 3, got %ld\n", ret);
     ok(!strcmp("hi ", out), "Expected output string \"hi \", got %s\n", out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS |
                          FORMAT_MESSAGE_MAX_WIDTH_MASK, "\r", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 1, "Expected FormatMessageA to return 1, got %d\n", ret);
+    ok(ret == 1, "Expected FormatMessageA to return 1, got %ld\n", ret);
     ok(!strcmp(" ", out), "Expected output string \" \", got %s\n", out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS |
                          FORMAT_MESSAGE_MAX_WIDTH_MASK, "\r\r\n", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 2, "Expected FormatMessageA to return 2, got %d\n", ret);
+    ok(ret == 2, "Expected FormatMessageA to return 2, got %ld\n", ret);
     ok(!strcmp("  ", out), "Expected output string \"  \", got %s\n", out);
 }
 
@@ -730,89 +730,89 @@ static void test_message_ignore_inserts_wide(void)
 
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, L"test", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageW to return 4, got %d\n", ret);
+    ok(ret == 4, "Expected FormatMessageW to return 4, got %ld\n", ret);
     ok(!lstrcmpW(L"test", out), "Expected output string \"test\", got %s\n", wine_dbgstr_w(out));
 
     /* The %0 escape sequence is handled. */
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, L"test%0", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageW to return 4, got %d\n", ret);
+    ok(ret == 4, "Expected FormatMessageW to return 4, got %ld\n", ret);
     ok(!lstrcmpW(L"test", out), "Expected output string \"test\", got %s\n", wine_dbgstr_w(out));
 
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, L"test%0test", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageW to return 4, got %d\n", ret);
+    ok(ret == 4, "Expected FormatMessageW to return 4, got %ld\n", ret);
     ok(!lstrcmpW(L"test", out), "Expected output string \"test\", got %s\n", wine_dbgstr_w(out));
 
     /* While FormatMessageA returns 0 in this case, no last error code is set. */
     SetLastError(0xdeadbeef);
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, L"%0test", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 0, "Expected FormatMessageW to return 0, got %d\n", ret);
+    ok(ret == 0, "Expected FormatMessageW to return 0, got %ld\n", ret);
     ok(!lstrcmpW(L"", out), "Expected the output buffer to be the empty string, got %s\n", wine_dbgstr_w(out));
     ok(GetLastError() == ERROR_NO_WORK_DONE || broken(GetLastError() == 0xdeadbeef),
-      "Expected GetLastError() to return ERROR_NO_WORK_DONE, got %u\n", GetLastError());
+      "Expected GetLastError() to return ERROR_NO_WORK_DONE, got %lu\n", GetLastError());
 
     /* Insert sequences are ignored. */
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, L"test%1%2!*.*s!%99", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 17, "Expected FormatMessageW to return 17, got %d\n", ret);
+    ok(ret == 17, "Expected FormatMessageW to return 17, got %ld\n", ret);
     ok(!lstrcmpW(L"test%1%2!*.*s!%99", out), "Expected output string \"test%%1%%2!*.*s!%%99\", got %s\n", wine_dbgstr_w(out));
 
     /* Only the "%n", "%r", and "%t" escape sequences are processed. */
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, L"%%% %.%!", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 8, "Expected FormatMessageW to return 8, got %d\n", ret);
+    ok(ret == 8, "Expected FormatMessageW to return 8, got %ld\n", ret);
     ok(!lstrcmpW(L"%%% %.%!", out), "Expected output string \"%%%%%% %%.%%!\", got %s\n", wine_dbgstr_w(out));
 
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, L"%n%r%t", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageW to return 4, got %d\n", ret);
+    ok(ret == 4, "Expected FormatMessageW to return 4, got %ld\n", ret);
     ok(!lstrcmpW(L"\r\n\r\t", out), "Expected output string \"\\r\\n\\r\\t\", got %s\n", wine_dbgstr_w(out));
 
     /* CRLF characters are processed normally. */
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, L"hi\n", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageW to return 4, got %d\n", ret);
+    ok(ret == 4, "Expected FormatMessageW to return 4, got %ld\n", ret);
     ok(!lstrcmpW(L"hi\r\n", out), "Expected output string \"hi\\r\\n\", got %s\n", wine_dbgstr_w(out));
 
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, L"hi\r\n", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageW to return 4, got %d\n", ret);
+    ok(ret == 4, "Expected FormatMessageW to return 4, got %ld\n", ret);
     ok(!lstrcmpW(L"hi\r\n", out), "Expected output string \"hi\\r\\n\", got %s\n", wine_dbgstr_w(out));
 
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, L"\r", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 2, "Expected FormatMessageW to return 2, got %d\n", ret);
+    ok(ret == 2, "Expected FormatMessageW to return 2, got %ld\n", ret);
     ok(!lstrcmpW(L"\r\n", out), "Expected output string \"\\r\\n\", got %s\n", wine_dbgstr_w(out));
 
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS, L"\r\r\n", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageW to return 4, got %d\n", ret);
+    ok(ret == 4, "Expected FormatMessageW to return 4, got %ld\n", ret);
     ok(!lstrcmpW(L"\r\n\r\n", out), "Expected output string \"\\r\\n\\r\\n\", got %s\n", wine_dbgstr_w(out));
 
     /* The width parameter is handled the same also. */
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS |
                          FORMAT_MESSAGE_MAX_WIDTH_MASK, L"hi\n", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 3, "Expected FormatMessageW to return 3, got %d\n", ret);
+    ok(ret == 3, "Expected FormatMessageW to return 3, got %ld\n", ret);
     ok(!lstrcmpW(L"hi ", out), "Expected output string \"hi \", got %s\n", wine_dbgstr_w(out));
 
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS |
                          FORMAT_MESSAGE_MAX_WIDTH_MASK, L"hi\r\n", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 3, "Expected FormatMessageW to return 3, got %d\n", ret);
+    ok(ret == 3, "Expected FormatMessageW to return 3, got %ld\n", ret);
     ok(!lstrcmpW(L"hi ", out), "Expected output string \"hi \", got %s\n", wine_dbgstr_w(out));
 
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS |
                          FORMAT_MESSAGE_MAX_WIDTH_MASK, L"\r", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 1, "Expected FormatMessageW to return 1, got %d\n", ret);
+    ok(ret == 1, "Expected FormatMessageW to return 1, got %ld\n", ret);
     ok(!lstrcmpW(L" ", out), "Expected output string \" \", got %s\n", wine_dbgstr_w(out));
 
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS |
                          FORMAT_MESSAGE_MAX_WIDTH_MASK, L"\r\r\n", 0, 0, out,
                          ARRAY_SIZE(out), NULL);
-    ok(ret == 2, "Expected FormatMessageW to return 2, got %d\n", ret);
+    ok(ret == 2, "Expected FormatMessageW to return 2, got %ld\n", ret);
     ok(!lstrcmpW(L"  ", out), "Expected output string \"  \", got %s\n", wine_dbgstr_w(out));
 }
 
@@ -825,134 +825,134 @@ static void test_message_wrap(void)
     /* No need for wrapping */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 20,
                          "short long line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 15, "Expected FormatMessageW to return 15, got %d\n", ret);
+    ok(ret == 15, "Expected FormatMessageW to return 15, got %ld\n", ret);
     ok(!strcmp("short long line", out),"failed out=[%s]\n",out);
 
     /* Wrap the last word */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 11,
                          "short long line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 16, "Expected FormatMessageW to return 16, got %d\n", ret);
+    ok(ret == 16, "Expected FormatMessageW to return 16, got %ld\n", ret);
     ok(!strcmp("short long\r\nline", out),"failed out=[%s]\n",out);
 
     /* Wrap the very last word */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 20,
                          "short long long line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 21, "Expected FormatMessageW to return 21, got %d\n", ret);
+    ok(ret == 21, "Expected FormatMessageW to return 21, got %ld\n", ret);
     ok(!strcmp("short long long\r\nline", out),"failed out=[%s]\n",out);
 
     /* Strictly less than 10 characters per line! */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 10,
                          "short long line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 16, "Expected FormatMessageW to return 16, got %d\n", ret);
+    ok(ret == 16, "Expected FormatMessageW to return 16, got %ld\n", ret);
     ok(!strcmp("short\r\nlong line", out),"failed out=[%s]\n",out);
 
     /* Handling of duplicate spaces */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 16,
                          "short long    line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 16, "Expected FormatMessageW to return 16, got %d\n", ret);
+    ok(ret == 16, "Expected FormatMessageW to return 16, got %ld\n", ret);
     ok(!strcmp("short long\r\nline", out),"failed out=[%s]\n",out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 16,
                          "short long    wordlongerthanaline", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 33, "Expected FormatMessageW to return 33, got %d\n", ret);
+    ok(ret == 33, "Expected FormatMessageW to return 33, got %ld\n", ret);
     ok(!strcmp("short long\r\nwordlongerthanal\r\nine", out),"failed out=[%s]\n",out);
 
     /* Breaking in the middle of spaces */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 12,
                          "short long    line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 18, "Expected FormatMessageW to return 18, got %d\n", ret);
+    ok(ret == 18, "Expected FormatMessageW to return 18, got %ld\n", ret);
     ok(!strcmp("short long\r\n  line", out),"failed out=[%s]\n",out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 12,
                          "short long    wordlongerthanaline", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 35, "Expected FormatMessageW to return 35, got %d\n", ret);
+    ok(ret == 35, "Expected FormatMessageW to return 35, got %ld\n", ret);
     ok(!strcmp("short long\r\n\r\nwordlongerth\r\nanaline", out),"failed out=[%s]\n",out);
 
     /* Handling of start-of-string spaces */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 15,
                          "   short line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 13, "Expected FormatMessageW to return 13, got %d\n", ret);
+    ok(ret == 13, "Expected FormatMessageW to return 13, got %ld\n", ret);
     ok(!strcmp("   short line", out),"failed out=[%s]\n",out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 11,
                          "   shortlong line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 17, "Expected FormatMessageW to return 17, got %d\n", ret);
+    ok(ret == 17, "Expected FormatMessageW to return 17, got %ld\n", ret);
     ok(!strcmp("\r\nshortlong\r\nline", out),"failed out=[%s]\n",out);
 
     /* Handling of start-of-line spaces */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 11,
                          "l1%n   shortlong line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 21, "Expected FormatMessageW to return 21, got %d\n", ret);
+    ok(ret == 21, "Expected FormatMessageW to return 21, got %ld\n", ret);
     ok(!strcmp("l1\r\n\r\nshortlong\r\nline", out),"failed out=[%s]\n",out);
 
     /* Pure space wrapping */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 5,
                          "                ", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 7, "Expected FormatMessageW to return 7, got %d\n", ret);
+    ok(ret == 7, "Expected FormatMessageW to return 7, got %ld\n", ret);
     ok(!strcmp("\r\n\r\n\r\n ", out),"failed out=[%s]\n",out);
 
     /* Handling of trailing spaces */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 5,
                          "l1               ", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 10, "Expected FormatMessageW to return 10, got %d\n", ret);
+    ok(ret == 10, "Expected FormatMessageW to return 10, got %ld\n", ret);
     ok(!strcmp("l1\r\n\r\n\r\n  ", out),"failed out=[%s]\n",out);
 
     /* Word that just fills the line */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 8,
                          "shortlon", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 10, "Expected FormatMessageW to return 10, got %d\n", ret);
+    ok(ret == 10, "Expected FormatMessageW to return 10, got %ld\n", ret);
     ok(!strcmp("shortlon\r\n", out),"failed out=[%s]\n",out);
 
     /* Word longer than the line */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 8,
                          "shortlongline", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 15, "Expected FormatMessageW to return 15, got %d\n", ret);
+    ok(ret == 15, "Expected FormatMessageW to return 15, got %ld\n", ret);
     ok(!strcmp("shortlon\r\ngline", out),"failed out=[%s]\n",out);
 
     /* Wrap the line multiple times */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 7,
                          "short long line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 17, "Expected FormatMessageW to return 17, got %d\n", ret);
+    ok(ret == 17, "Expected FormatMessageW to return 17, got %ld\n", ret);
     ok(!strcmp("short\r\nlong\r\nline", out),"failed out=[%s]\n",out);
 
     /* '\n's in the source are ignored */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 11,
                          "short\nlong line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 16, "Expected FormatMessageW to return 16, got %d\n", ret);
+    ok(ret == 16, "Expected FormatMessageW to return 16, got %ld\n", ret);
     ok(!strcmp("short long\r\nline", out),"failed out=[%s]\n",out);
 
     /* Wrap even before a '%n' */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 8,
                          "shortlon%n", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 12, "Expected FormatMessageW to return 12, got %d\n", ret);
+    ok(ret == 12, "Expected FormatMessageW to return 12, got %ld\n", ret);
     ok(!strcmp("shortlon\r\n\r\n", out),"failed out=[%s]\n",out);
 
     /* '%n's count as starting a new line and combine with line wrapping */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 10,
                          "short%nlong line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 16, "Expected FormatMessageW to return 16, got %d\n", ret);
+    ok(ret == 16, "Expected FormatMessageW to return 16, got %ld\n", ret);
     ok(!strcmp("short\r\nlong line", out),"failed out=[%s]\n",out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 8,
                          "short%nlong line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 17, "Expected FormatMessageW to return 17, got %d\n", ret);
+    ok(ret == 17, "Expected FormatMessageW to return 17, got %ld\n", ret);
     ok(!strcmp("short\r\nlong\r\nline", out),"failed out=[%s]\n",out);
 
     /* '%r's also count as starting a new line and all */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 10,
                          "short%rlong line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 15, "Expected FormatMessageW to return 15, got %d\n", ret);
+    ok(ret == 15, "Expected FormatMessageW to return 15, got %ld\n", ret);
     ok(!strcmp("short\rlong line", out),"failed out=[%s]\n",out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 8,
                          "short%rlong line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 16, "Expected FormatMessageW to return 16, got %d\n", ret);
+    ok(ret == 16, "Expected FormatMessageW to return 16, got %ld\n", ret);
     ok(!strcmp("short\rlong\r\nline", out),"failed out=[%s]\n",out);
 
     /* IGNORE_INSERTS does not prevent line wrapping or disable '%n' */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS | 8,
                          "short%nlong line%1", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 19, "Expected FormatMessageW to return 19, got %d\n", ret);
+    ok(ret == 19, "Expected FormatMessageW to return 19, got %ld\n", ret);
     ok(!strcmp("short\r\nlong\r\nline%1", out),"failed out=[%s]\n",out);
 
     /* MAX_WIDTH_MASK is the same as specifying an infinite line width */
@@ -965,43 +965,43 @@ static void test_message_wrap(void)
     }
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_MAX_WIDTH_MASK,
                          in, 0, 0, out, sizeof(out), NULL);
-    ok(ret == 272, "Expected FormatMessageW to return 272, got %d\n", ret);
+    ok(ret == 272, "Expected FormatMessageW to return 272, got %ld\n", ret);
     ok(!strcmp(ref, out),"failed out=[%s]\n",out);
 
     /* Wrapping and non-space characters */
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 11,
                          "short long\tline", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 16, "Expected FormatMessageW to return 16, got %d\n", ret);
+    ok(ret == 16, "Expected FormatMessageW to return 16, got %ld\n", ret);
     ok(!strcmp("short\r\nlong\tline", out),"failed out=[%s]\n",out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 11,
                          "short long-line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 16, "Expected FormatMessageW to return 16, got %d\n", ret);
+    ok(ret == 16, "Expected FormatMessageW to return 16, got %ld\n", ret);
     ok(!strcmp("short\r\nlong-line", out),"failed out=[%s]\n",out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 11,
                          "short long_line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 16, "Expected FormatMessageW to return 16, got %d\n", ret);
+    ok(ret == 16, "Expected FormatMessageW to return 16, got %ld\n", ret);
     ok(!strcmp("short\r\nlong_line", out),"failed out=[%s]\n",out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 11,
                          "short long.line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 16, "Expected FormatMessageW to return 16, got %d\n", ret);
+    ok(ret == 16, "Expected FormatMessageW to return 16, got %ld\n", ret);
     ok(!strcmp("short\r\nlong.line", out),"failed out=[%s]\n",out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 11,
                          "short long,line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 16, "Expected FormatMessageW to return 16, got %d\n", ret);
+    ok(ret == 16, "Expected FormatMessageW to return 16, got %ld\n", ret);
     ok(!strcmp("short\r\nlong,line", out),"failed out=[%s]\n",out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 11,
                          "short long!line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 16, "Expected FormatMessageW to return 16, got %d\n", ret);
+    ok(ret == 16, "Expected FormatMessageW to return 16, got %ld\n", ret);
     ok(!strcmp("short\r\nlong!line", out),"failed out=[%s]\n",out);
 
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 11,
                          "short long?line", 0, 0, out, sizeof(out), NULL);
-    ok(ret == 16, "Expected FormatMessageW to return 16, got %d\n", ret);
+    ok(ret == 16, "Expected FormatMessageW to return 16, got %ld\n", ret);
     ok(!strcmp("short\r\nlong?line", out),"failed out=[%s]\n",out);
 }
 
@@ -1015,9 +1015,9 @@ static void test_message_insufficient_buffer(void)
     SetLastError(0xdeadbeef);
     memcpy(out, init_buf, sizeof(init_buf));
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING, "test", 0, 0, out, 0, NULL);
-    ok(ret == 0, "Expected FormatMessageA to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageA to return 0, got %lu\n", ret);
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-       "Expected GetLastError() to return ERROR_INSUFFICIENT_BUFFER, got %u\n",
+       "Expected GetLastError() to return ERROR_INSUFFICIENT_BUFFER, got %lu\n",
        GetLastError());
     ok(!memcmp(expected_buf, out, sizeof(expected_buf)),
        "Expected the buffer to be untouched\n");
@@ -1025,9 +1025,9 @@ static void test_message_insufficient_buffer(void)
     SetLastError(0xdeadbeef);
     memcpy(out, init_buf, sizeof(init_buf));
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING, "test", 0, 0, out, 1, NULL);
-    ok(ret == 0, "Expected FormatMessageA to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageA to return 0, got %lu\n", ret);
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-       "Expected GetLastError() to return ERROR_INSUFFICIENT_BUFFER, got %u\n",
+       "Expected GetLastError() to return ERROR_INSUFFICIENT_BUFFER, got %lu\n",
        GetLastError());
     ok(!memcmp(expected_buf, out, sizeof(expected_buf)),
        "Expected the buffer to be untouched\n");
@@ -1035,9 +1035,9 @@ static void test_message_insufficient_buffer(void)
     SetLastError(0xdeadbeef);
     memcpy(out, init_buf, sizeof(init_buf));
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING, "test", 0, 0, out, ARRAY_SIZE(out) - 1, NULL);
-    ok(ret == 0, "Expected FormatMessageA to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageA to return 0, got %lu\n", ret);
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-       "Expected GetLastError() to return ERROR_INSUFFICIENT_BUFFER, got %u\n",
+       "Expected GetLastError() to return ERROR_INSUFFICIENT_BUFFER, got %lu\n",
        GetLastError());
     ok(!memcmp(expected_buf, out, sizeof(expected_buf)),
        "Expected the buffer to be untouched\n");
@@ -1053,27 +1053,27 @@ static void test_message_insufficient_buffer(void)
         ret = FormatMessageA( FORMAT_MESSAGE_FROM_STRING, tmp, 0, 0, buf, size, NULL );
         if (size < 32768)
         {
-            ok( ret == size - 1, "%u: got %u\n", size, ret );
+            ok( ret == size - 1, "%lu: got %lu\n", size, ret );
             ok( !strcmp( tmp, buf ), "wrong buffer\n" );
         }
         else
         {
-            ok( ret == 0, "%u: got %u\n", size, ret );
-            ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+            ok( ret == 0, "%lu: got %lu\n", size, ret );
+            ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
         }
 
         SetLastError( 0xdeadbeef );
         ret = doit( FORMAT_MESSAGE_FROM_STRING, "%1", 0, 0, buf, size, tmp );
         if (size < 32768)
         {
-            ok( ret == size - 1, "%u: got %u\n", size, ret );
+            ok( ret == size - 1, "%lu: got %lu\n", size, ret );
             ok( !strcmp( tmp, buf ), "wrong buffer\n" );
         }
         else
         {
-            ok( ret == 0, "%u: got %u\n", size, ret );
+            ok( ret == 0, "%lu: got %lu\n", size, ret );
             ok( GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == ERROR_MORE_DATA), /* winxp */
-                "wrong error %u\n", GetLastError() );
+                "wrong error %lu\n", GetLastError() );
         }
         HeapFree( GetProcessHeap(), 0, buf );
 
@@ -1082,14 +1082,14 @@ static void test_message_insufficient_buffer(void)
                               tmp, 0, 0, (char *)&buf, size, NULL );
         if (size < 32768)
         {
-            ok( ret == size - 1, "%u: got %u\n", size, ret );
+            ok( ret == size - 1, "%lu: got %lu\n", size, ret );
             ok( !strcmp( tmp, buf ), "wrong buffer\n" );
             HeapFree( GetProcessHeap(), 0, buf );
         }
         else
         {
-            ok( ret == 0, "%u: got %u\n", size, ret );
-            ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+            ok( ret == 0, "%lu: got %lu\n", size, ret );
+            ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
         }
         HeapFree( GetProcessHeap(), 0, tmp );
     }
@@ -1103,9 +1103,9 @@ static void test_message_insufficient_buffer_wide(void)
     SetLastError(0xdeadbeef);
     lstrcpyW( out, L"xxxxxx" );
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING, L"test", 0, 0, out, 0, NULL);
-    ok(ret == 0, "Expected FormatMessageA to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageA to return 0, got %lu\n", ret);
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-       "Expected GetLastError() to return ERROR_INSUFFICIENT_BUFFER, got %u\n",
+       "Expected GetLastError() to return ERROR_INSUFFICIENT_BUFFER, got %lu\n",
        GetLastError());
     ok(!lstrcmpW( out, L"xxxxxx" ),
        "Expected the buffer to be untouched\n");
@@ -1113,9 +1113,9 @@ static void test_message_insufficient_buffer_wide(void)
     SetLastError(0xdeadbeef);
     lstrcpyW( out, L"xxxxxx" );
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING, L"test", 0, 0, out, 1, NULL);
-    ok(ret == 0, "Expected FormatMessageA to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageA to return 0, got %lu\n", ret);
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-       "Expected GetLastError() to return ERROR_INSUFFICIENT_BUFFER, got %u\n",
+       "Expected GetLastError() to return ERROR_INSUFFICIENT_BUFFER, got %lu\n",
        GetLastError());
     ok(!memcmp(out, L"\0xxxxx", 6 * sizeof(WCHAR)) ||
         broken(!lstrcmpW( out, L"xxxxxx" )), /* winxp */
@@ -1124,9 +1124,9 @@ static void test_message_insufficient_buffer_wide(void)
     SetLastError(0xdeadbeef);
     lstrcpyW( out, L"xxxxxx" );
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING, L"test", 0, 0, out, 4, NULL);
-    ok(ret == 0, "Expected FormatMessageA to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageA to return 0, got %lu\n", ret);
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-       "Expected GetLastError() to return ERROR_INSUFFICIENT_BUFFER, got %u\n",
+       "Expected GetLastError() to return ERROR_INSUFFICIENT_BUFFER, got %lu\n",
        GetLastError());
     ok(!memcmp(out, L"tes\0xx", 6 * sizeof(WCHAR)) ||
         broken(!lstrcmpW( out, L"xxxxxx" )), /* winxp */
@@ -1139,16 +1139,16 @@ static void test_message_insufficient_buffer_wide(void)
         for (i = 0; i < size; i++) tmp[i] = 'A' + i % 26;
         tmp[size - 1] = 0;
         ret = FormatMessageW( FORMAT_MESSAGE_FROM_STRING, tmp, 0, 0, buf, size, NULL );
-        ok(ret == size - 1 || broken(!ret), /* winxp */ "got %u\n", ret);
+        ok(ret == size - 1 || broken(!ret), /* winxp */ "got %lu\n", ret);
         if (!ret) break;
         ok( !lstrcmpW( tmp, buf ), "wrong buffer\n" );
         ret = doitW( FORMAT_MESSAGE_FROM_STRING, L"%1", 0, 0, buf, size, tmp );
-        ok(ret == size - 1, "got %u\n", ret);
+        ok(ret == size - 1, "got %lu\n", ret);
         ok( !lstrcmpW( tmp, buf ), "wrong buffer\n" );
         HeapFree( GetProcessHeap(), 0, buf );
         ret = FormatMessageW( FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
                               tmp, 0, 0, (WCHAR *)&buf, size, NULL );
-        ok(ret == size - 1, "got %u\n", ret);
+        ok(ret == size - 1, "got %lu\n", ret);
         ok( !lstrcmpW( tmp, buf ), "wrong buffer\n" );
         HeapFree( GetProcessHeap(), 0, tmp );
         HeapFree( GetProcessHeap(), 0, buf );
@@ -1163,14 +1163,14 @@ static void test_message_null_buffer(void)
     SetLastError(0xdeadbeef);
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, 0, 0, NULL, 0, NULL);
     error = GetLastError();
-    ok(!ret, "FormatMessageA returned %u\n", ret);
-    ok(error == ERROR_INSUFFICIENT_BUFFER, "last error %u\n", error);
+    ok(!ret, "FormatMessageA returned %lu\n", ret);
+    ok(error == ERROR_INSUFFICIENT_BUFFER, "last error %lu\n", error);
 
     SetLastError(0xdeadbeef);
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, 0, 0, NULL, 1, NULL);
     error = GetLastError();
-    ok(!ret, "FormatMessageA returned %u\n", ret);
-    ok(error == ERROR_INSUFFICIENT_BUFFER, "last error %u\n", error);
+    ok(!ret, "FormatMessageA returned %lu\n", ret);
+    ok(error == ERROR_INSUFFICIENT_BUFFER, "last error %lu\n", error);
 
     if (0) /* crashes on Windows */
     {
@@ -1181,20 +1181,20 @@ static void test_message_null_buffer(void)
     SetLastError(0xdeadbeef);
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, 0, 0, NULL, 0, NULL);
     error = GetLastError();
-    ok(!ret, "FormatMessageA returned %u\n", ret);
-    ok(error == ERROR_NOT_ENOUGH_MEMORY, "last error %u\n", error);
+    ok(!ret, "FormatMessageA returned %lu\n", ret);
+    ok(error == ERROR_NOT_ENOUGH_MEMORY, "last error %lu\n", error);
 
     SetLastError(0xdeadbeef);
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, 0, 0, NULL, 1, NULL);
     error = GetLastError();
-    ok(!ret, "FormatMessageA returned %u\n", ret);
-    ok(error == ERROR_NOT_ENOUGH_MEMORY, "last error %u\n", error);
+    ok(!ret, "FormatMessageA returned %lu\n", ret);
+    ok(error == ERROR_NOT_ENOUGH_MEMORY, "last error %lu\n", error);
 
     SetLastError(0xdeadbeef);
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, 0, 0, NULL, 256, NULL);
     error = GetLastError();
-    ok(!ret, "FormatMessageA returned %u\n", ret);
-    ok(error == ERROR_NOT_ENOUGH_MEMORY, "last error %u\n", error);
+    ok(!ret, "FormatMessageA returned %lu\n", ret);
+    ok(error == ERROR_NOT_ENOUGH_MEMORY, "last error %lu\n", error);
 }
 
 static void test_message_null_buffer_wide(void)
@@ -1204,38 +1204,38 @@ static void test_message_null_buffer_wide(void)
     SetLastError(0xdeadbeef);
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, NULL, 0, 0, NULL, 0, NULL);
     error = GetLastError();
-    ok(!ret, "FormatMessageW returned %u\n", ret);
-    ok(error == ERROR_INVALID_PARAMETER, "last error %u\n", error);
+    ok(!ret, "FormatMessageW returned %lu\n", ret);
+    ok(error == ERROR_INVALID_PARAMETER, "last error %lu\n", error);
 
     SetLastError(0xdeadbeef);
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, NULL, 0, 0, NULL, 1, NULL);
     error = GetLastError();
-    ok(!ret, "FormatMessageW returned %u\n", ret);
-    ok(error == ERROR_INVALID_PARAMETER, "last error %u\n", error);
+    ok(!ret, "FormatMessageW returned %lu\n", ret);
+    ok(error == ERROR_INVALID_PARAMETER, "last error %lu\n", error);
 
     SetLastError(0xdeadbeef);
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, NULL, 0, 0, NULL, 256, NULL);
     error = GetLastError();
-    ok(!ret, "FormatMessageW returned %u\n", ret);
-    ok(error == ERROR_INVALID_PARAMETER, "last error %u\n", error);
+    ok(!ret, "FormatMessageW returned %lu\n", ret);
+    ok(error == ERROR_INVALID_PARAMETER, "last error %lu\n", error);
 
     SetLastError(0xdeadbeef);
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, 0, 0, NULL, 0, NULL);
     error = GetLastError();
-    ok(!ret, "FormatMessageW returned %u\n", ret);
-    ok(error == ERROR_INVALID_PARAMETER, "last error %u\n", error);
+    ok(!ret, "FormatMessageW returned %lu\n", ret);
+    ok(error == ERROR_INVALID_PARAMETER, "last error %lu\n", error);
 
     SetLastError(0xdeadbeef);
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, 0, 0, NULL, 1, NULL);
     error = GetLastError();
-    ok(!ret, "FormatMessageW returned %u\n", ret);
-    ok(error == ERROR_INVALID_PARAMETER, "last error %u\n", error);
+    ok(!ret, "FormatMessageW returned %lu\n", ret);
+    ok(error == ERROR_INVALID_PARAMETER, "last error %lu\n", error);
 
     SetLastError(0xdeadbeef);
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, 0, 0, NULL, 256, NULL);
     error = GetLastError();
-    ok(!ret, "FormatMessageW returned %u\n", ret);
-    ok(error == ERROR_INVALID_PARAMETER, "last error %u\n", error);
+    ok(!ret, "FormatMessageW returned %lu\n", ret);
+    ok(error == ERROR_INVALID_PARAMETER, "last error %lu\n", error);
 }
 
 static void test_message_allocate_buffer(void)
@@ -1254,15 +1254,15 @@ static void test_message_allocate_buffer(void)
     buf = (char *)0xdeadbeef;
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
                          "", 0, 0, (char *)&buf, 0, NULL);
-    ok(ret == 0, "Expected FormatMessageA to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageA to return 0, got %lu\n", ret);
     ok(buf == NULL, "Expected output buffer pointer to be NULL\n");
     ok(GetLastError() == ERROR_NO_WORK_DONE || broken(GetLastError() == 0xdeadbeef),
-       "Expected GetLastError() to return ERROR_NO_WORK_DONE, got %u\n", GetLastError());
+       "Expected GetLastError() to return ERROR_NO_WORK_DONE, got %lu\n", GetLastError());
 
     buf = (char *)0xdeadbeef;
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
                          "test", 0, 0, (char *)&buf, 0, NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %u\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %lu\n", ret);
     ok(buf != NULL && buf != (char *)0xdeadbeef,
        "Expected output buffer pointer to be valid\n");
     if (buf != NULL && buf != (char *)0xdeadbeef)
@@ -1275,7 +1275,7 @@ static void test_message_allocate_buffer(void)
     buf = (char *)0xdeadbeef;
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
                          "test", 0, 0, (char *)&buf, strlen("test"), NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %u\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %lu\n", ret);
     ok(buf != NULL && buf != (char *)0xdeadbeef,
        "Expected output buffer pointer to be valid\n");
     if (buf != NULL && buf != (char *)0xdeadbeef)
@@ -1288,7 +1288,7 @@ static void test_message_allocate_buffer(void)
     buf = (char *)0xdeadbeef;
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
                          "test", 0, 0, (char *)&buf, strlen("test") + 1, NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %u\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %lu\n", ret);
     ok(buf != NULL && buf != (char *)0xdeadbeef,
        "Expected output buffer pointer to be valid\n");
    if (buf != NULL && buf != (char *)0xdeadbeef)
@@ -1301,7 +1301,7 @@ static void test_message_allocate_buffer(void)
     buf = (char *)0xdeadbeef;
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
                          "test", 0, 0, (char *)&buf, strlen("test") + 2, NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %u\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %lu\n", ret);
     ok(buf != NULL && buf != (char *)0xdeadbeef,
        "Expected output buffer pointer to be valid\n");
     if (buf != NULL && buf != (char *)0xdeadbeef)
@@ -1314,7 +1314,7 @@ static void test_message_allocate_buffer(void)
     buf = (char *)0xdeadbeef;
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
                          "test", 0, 0, (char *)&buf, 1024, NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %u\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %lu\n", ret);
     ok(buf != NULL && buf != (char *)0xdeadbeef,
        "Expected output buffer pointer to be valid\n");
     if (buf != NULL && buf != (char *)0xdeadbeef)
@@ -1348,24 +1348,24 @@ static void test_message_allocate_buffer_wide(void)
     buf = (WCHAR *)0xdeadbeef;
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
                          L"", 0, 0, (WCHAR *)&buf, 0, NULL);
-    ok(ret == 0, "Expected FormatMessageW to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageW to return 0, got %lu\n", ret);
     ok(buf == NULL, "Expected output buffer pointer to be NULL\n");
     ok(GetLastError() == ERROR_NO_WORK_DONE || broken(GetLastError() == 0xdeadbeef),
-       "Expected GetLastError() to return ERROR_NO_WORK_DONE, got %u\n", GetLastError());
+       "Expected GetLastError() to return ERROR_NO_WORK_DONE, got %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     buf = (WCHAR *)0xdeadbeef;
     ret = doitW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER, L"%1",
                 0, 0, (WCHAR *)&buf, 0, L"" );
-    ok(ret == 0, "Expected FormatMessageW to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageW to return 0, got %lu\n", ret);
     ok(buf == NULL, "Expected output buffer pointer to be NULL\n");
     ok(GetLastError() == ERROR_NO_WORK_DONE || broken(GetLastError() == 0xdeadbeef),
-       "Expected GetLastError() to return ERROR_NO_WORK_DONE, got %u\n", GetLastError());
+       "Expected GetLastError() to return ERROR_NO_WORK_DONE, got %lu\n", GetLastError());
 
     buf = (WCHAR *)0xdeadbeef;
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
                          L"test", 0, 0, (WCHAR *)&buf, 0, NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %u\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %lu\n", ret);
     ok(buf != NULL && buf != (WCHAR *)0xdeadbeef,
        "Expected output buffer pointer to be valid\n");
     if (buf != NULL && buf != (WCHAR *)0xdeadbeef)
@@ -1378,7 +1378,7 @@ static void test_message_allocate_buffer_wide(void)
     buf = (WCHAR *)0xdeadbeef;
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
                          L"test", 0, 0, (WCHAR *)&buf, 4, NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %u\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %lu\n", ret);
     ok(buf != NULL && buf != (WCHAR *)0xdeadbeef,
        "Expected output buffer pointer to be valid\n");
     if (buf != NULL && buf != (WCHAR *)0xdeadbeef)
@@ -1391,7 +1391,7 @@ static void test_message_allocate_buffer_wide(void)
     buf = (WCHAR *)0xdeadbeef;
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
                          L"test", 0, 0, (WCHAR *)&buf, 5, NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %u\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %lu\n", ret);
     ok(buf != NULL && buf != (WCHAR *)0xdeadbeef,
        "Expected output buffer pointer to be valid\n");
     if (buf != NULL && buf != (WCHAR *)0xdeadbeef)
@@ -1404,7 +1404,7 @@ static void test_message_allocate_buffer_wide(void)
     buf = (WCHAR *)0xdeadbeef;
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
                          L"test", 0, 0, (WCHAR *)&buf, 6, NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %u\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %lu\n", ret);
     ok(buf != NULL && buf != (WCHAR *)0xdeadbeef,
        "Expected output buffer pointer to be valid\n");
     if (buf != NULL && buf != (WCHAR *)0xdeadbeef)
@@ -1417,7 +1417,7 @@ static void test_message_allocate_buffer_wide(void)
     buf = (WCHAR *)0xdeadbeef;
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
                          L"test", 0, 0, (WCHAR *)&buf, 1024, NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %u\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %lu\n", ret);
     ok(buf != NULL && buf != (WCHAR *)0xdeadbeef,
        "Expected output buffer pointer to be valid\n");
     if (buf != NULL && buf != (WCHAR *)0xdeadbeef)
@@ -1467,52 +1467,52 @@ static void test_message_from_hmodule(void)
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044,
                          MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), out, ARRAY_SIZE(out), NULL);
     error = GetLastError();
-    ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
+    ok(ret == 0, "FormatMessageA returned %lu instead of 0\n", ret);
     ok(error == ERROR_MR_MID_NOT_FOUND ||
        error == ERROR_MUI_FILE_NOT_FOUND ||
-       error == ERROR_RESOURCE_TYPE_NOT_FOUND, "Unexpected last error %u.\n", error);
+       error == ERROR_RESOURCE_TYPE_NOT_FOUND, "Unexpected last error %lu.\n", error);
 
     SetLastError(0xdeadbeef);
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044,
                          MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), out, ARRAY_SIZE(out), NULL);
     error = GetLastError();
-    ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
+    ok(ret == 0, "FormatMessageA returned %lu instead of 0\n", ret);
     ok(error == ERROR_MR_MID_NOT_FOUND ||
        error == ERROR_MUI_FILE_NOT_LOADED ||
-       error == ERROR_RESOURCE_TYPE_NOT_FOUND, "Unexpected last error %u.\n", error);
+       error == ERROR_RESOURCE_TYPE_NOT_FOUND, "Unexpected last error %lu.\n", error);
 
     SetLastError(0xdeadbeef);
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044,
                          MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT), out, ARRAY_SIZE(out), NULL);
     error = GetLastError();
-    ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
+    ok(ret == 0, "FormatMessageA returned %lu instead of 0\n", ret);
     ok(error == ERROR_MR_MID_NOT_FOUND ||
        error == ERROR_MUI_FILE_NOT_LOADED ||
-       error == ERROR_RESOURCE_TYPE_NOT_FOUND, "Unexpected last error %u.\n", error);
+       error == ERROR_RESOURCE_TYPE_NOT_FOUND, "Unexpected last error %lu.\n", error);
 
     SetLastError(0xdeadbeef);
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044,
                          MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), out, ARRAY_SIZE(out), NULL);
     error = GetLastError();
-    ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
+    ok(ret == 0, "FormatMessageA returned %lu instead of 0\n", ret);
     ok(error == ERROR_RESOURCE_LANG_NOT_FOUND ||
        error == ERROR_RESOURCE_TYPE_NOT_FOUND ||
        error == ERROR_MR_MID_NOT_FOUND ||
        error == ERROR_MUI_FILE_NOT_FOUND ||
        error == ERROR_MUI_FILE_NOT_LOADED,
-       "last error %u\n", error);
+       "last error %lu\n", error);
 
     SetLastError(0xdeadbeef);
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044,
                          MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_UK), out, ARRAY_SIZE(out), NULL);
     error = GetLastError();
-    ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
+    ok(ret == 0, "FormatMessageA returned %lu instead of 0\n", ret);
     ok(error == ERROR_RESOURCE_LANG_NOT_FOUND ||
        error == ERROR_RESOURCE_TYPE_NOT_FOUND ||
        error == ERROR_MR_MID_NOT_FOUND ||
        error == ERROR_MUI_FILE_NOT_FOUND ||
        error == ERROR_MUI_FILE_NOT_LOADED,
-       "last error %u\n", error);
+       "last error %lu\n", error);
 }
 
 static void test_message_invalid_flags(void)
@@ -1526,50 +1526,50 @@ static void test_message_invalid_flags(void)
     SetLastError(0xdeadbeef);
     memcpy(out, init_buf, sizeof(init_buf));
     ret = FormatMessageA(0, "test", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 0, "Expected FormatMessageA to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageA to return 0, got %lu\n", ret);
     ok(!memcmp(out, init_buf, sizeof(init_buf)),
        "Expected the output buffer to be untouched\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
+       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %lu\n",
        GetLastError());
 
     SetLastError(0xdeadbeef);
     ptr = (char *)0xdeadbeef;
     ret = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER, "test", 0, 0, (char *)&ptr, 0, NULL);
-    ok(ret == 0, "Expected FormatMessageA to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageA to return 0, got %lu\n", ret);
     ok(ptr == NULL, "Expected output pointer to be initialized to NULL, got %p\n", ptr);
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
+       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %lu\n",
        GetLastError());
 
     SetLastError(0xdeadbeef);
     memcpy(out, init_buf, sizeof(init_buf));
     ret = FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS, "test", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 0, "Expected FormatMessageA to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageA to return 0, got %lu\n", ret);
     ok(!memcmp(out, init_buf, sizeof(init_buf)),
        "Expected the output buffer to be untouched\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
+       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %lu\n",
        GetLastError());
 
     SetLastError(0xdeadbeef);
     memcpy(out, init_buf, sizeof(init_buf));
     ret = FormatMessageA(FORMAT_MESSAGE_ARGUMENT_ARRAY, "test", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 0, "Expected FormatMessageA to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageA to return 0, got %lu\n", ret);
     ok(!memcmp(out, init_buf, sizeof(init_buf)),
        "Expected the output buffer to be untouched\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
+       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %lu\n",
        GetLastError());
 
     SetLastError(0xdeadbeef);
     memcpy(out, init_buf, sizeof(init_buf));
     ret = FormatMessageA(FORMAT_MESSAGE_MAX_WIDTH_MASK, "test", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 0, "Expected FormatMessageA to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageA to return 0, got %lu\n", ret);
     ok(!memcmp(out, init_buf, sizeof(init_buf)),
        "Expected the output buffer to be untouched\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
+       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %lu\n",
        GetLastError());
 
     /* Simultaneously setting FORMAT_MESSAGE_FROM_STRING with other source
@@ -1579,21 +1579,21 @@ static void test_message_invalid_flags(void)
     memcpy(out, init_buf, sizeof(init_buf));
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_FROM_SYSTEM,
                          "test", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %u\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %lu\n", ret);
     ok(!strcmp("test", out),
        "Expected the output buffer to be untouched\n");
 
     memcpy(out, init_buf, sizeof(init_buf));
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_FROM_HMODULE,
                          "test", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %u\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %lu\n", ret);
     ok(!strcmp("test", out),
        "Expected the output buffer to be untouched\n");
 
     memcpy(out, init_buf, sizeof(init_buf));
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_FROM_HMODULE |
                          FORMAT_MESSAGE_FROM_SYSTEM, "test", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageA to return 4, got %u\n", ret);
+    ok(ret == 4, "Expected FormatMessageA to return 4, got %lu\n", ret);
     ok(!strcmp("test", out),
        "Expected the output buffer to be untouched\n");
 }
@@ -1607,50 +1607,50 @@ static void test_message_invalid_flags_wide(void)
     SetLastError(0xdeadbeef);
     lstrcpyW( out, L"xxxxxx" );
     ret = FormatMessageW(0, L"test", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 0, "Expected FormatMessageW to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageW to return 0, got %lu\n", ret);
     ok(!lstrcmpW( out, L"xxxxxx" ),
        "Expected the output buffer to be untouched\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
+       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %lu\n",
        GetLastError());
 
     SetLastError(0xdeadbeef);
     ptr = (WCHAR *)0xdeadbeef;
     ret = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER, L"test", 0, 0, (WCHAR *)&ptr, 0, NULL);
-    ok(ret == 0, "Expected FormatMessageW to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageW to return 0, got %lu\n", ret);
     ok(ptr == NULL, "Expected output pointer to be initialized to NULL, got %p\n", ptr);
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
+       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %lu\n",
        GetLastError());
 
     SetLastError(0xdeadbeef);
     lstrcpyW( out, L"xxxxxx" );
     ret = FormatMessageW(FORMAT_MESSAGE_IGNORE_INSERTS, L"test", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 0, "Expected FormatMessageW to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageW to return 0, got %lu\n", ret);
     ok(!lstrcmpW( out, L"xxxxxx" ),
        "Expected the output buffer to be untouched\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
+       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %lu\n",
        GetLastError());
 
     SetLastError(0xdeadbeef);
     lstrcpyW( out, L"xxxxxx" );
     ret = FormatMessageW(FORMAT_MESSAGE_ARGUMENT_ARRAY, L"test", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 0, "Expected FormatMessageW to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageW to return 0, got %lu\n", ret);
     ok(!lstrcmpW( out, L"xxxxxx" ),
        "Expected the output buffer to be untouched\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
+       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %lu\n",
        GetLastError());
 
     SetLastError(0xdeadbeef);
     lstrcpyW( out, L"xxxxxx" );
     ret = FormatMessageW(FORMAT_MESSAGE_MAX_WIDTH_MASK, L"test", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 0, "Expected FormatMessageW to return 0, got %u\n", ret);
+    ok(ret == 0, "Expected FormatMessageW to return 0, got %lu\n", ret);
     ok(!lstrcmpW( out, L"xxxxxx" ),
        "Expected the output buffer to be untouched\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
+       "Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %lu\n",
        GetLastError());
 
     /* Simultaneously setting FORMAT_MESSAGE_FROM_STRING with other source
@@ -1660,21 +1660,21 @@ static void test_message_invalid_flags_wide(void)
     lstrcpyW( out, L"xxxxxx" );
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_FROM_SYSTEM,
                          L"test", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageW to return 4, got %u\n", ret);
+    ok(ret == 4, "Expected FormatMessageW to return 4, got %lu\n", ret);
     ok(!lstrcmpW(L"test", out),
        "Expected the output buffer to be untouched\n");
 
     lstrcpyW( out, L"xxxxxx" );
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_FROM_HMODULE,
                          L"test", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageW to return 4, got %u\n", ret);
+    ok(ret == 4, "Expected FormatMessageW to return 4, got %lu\n", ret);
     ok(!lstrcmpW(L"test", out),
        "Expected the output buffer to be untouched\n");
 
     lstrcpyW( out, L"xxxxxx" );
     ret = FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_FROM_HMODULE |
                          FORMAT_MESSAGE_FROM_SYSTEM, L"test", 0, 0, out, ARRAY_SIZE(out), NULL);
-    ok(ret == 4, "Expected FormatMessageW to return 4, got %u\n", ret);
+    ok(ret == 4, "Expected FormatMessageW to return 4, got %lu\n", ret);
     ok(!lstrcmpW(L"test", out),
        "Expected the output buffer to be untouched\n");
 }
@@ -1719,12 +1719,12 @@ static void test_message_from_64bit_number(void)
         MultiByteToWideChar(CP_ACP, 0, unsigned_tests[i].expected, -1, expW, ARRAY_SIZE(expW));
         ok(!lstrcmpW(outW, expW),"[%d] failed, expected %s, got %s\n", i,
                      unsigned_tests[i].expected, wine_dbgstr_w(outW));
-        ok(r == unsigned_tests[i].len,"[%d] failed: r=%d\n", i, r);
+        ok(r == unsigned_tests[i].len,"[%d] failed: r=%ld\n", i, r);
         r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!I64u!",
                   0, 0, outA, sizeof(outA), unsigned_tests[i].number);
         ok(!strcmp(outA, unsigned_tests[i].expected),"[%d] failed, expected %s, got %s\n", i,
                    unsigned_tests[i].expected, outA);
-        ok(r == unsigned_tests[i].len,"[%d] failed: r=%d\n", i, r);
+        ok(r == unsigned_tests[i].len,"[%d] failed: r=%ld\n", i, r);
     }
 
     for (i = 0; i < ARRAY_SIZE(signed_tests); i++)
@@ -1734,12 +1734,12 @@ static void test_message_from_64bit_number(void)
         MultiByteToWideChar(CP_ACP, 0, signed_tests[i].expected, -1, expW, ARRAY_SIZE(expW));
         ok(!lstrcmpW(outW, expW),"[%d] failed, expected %s, got %s\n", i,
                      signed_tests[i].expected, wine_dbgstr_w(outW));
-        ok(r == signed_tests[i].len,"[%d] failed: r=%d\n", i, r);
+        ok(r == signed_tests[i].len,"[%d] failed: r=%ld\n", i, r);
         r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!I64d!",
                   0, 0, outA, sizeof(outA), signed_tests[i].number);
         ok(!strcmp(outA, signed_tests[i].expected),"[%d] failed, expected %s, got %s\n", i,
                    signed_tests[i].expected, outA);
-        ok(r == signed_tests[i].len,"[%d] failed: r=%d\n", i, r);
+        ok(r == signed_tests[i].len,"[%d] failed: r=%ld\n", i, r);
     }
 }
 
@@ -1766,7 +1766,7 @@ static void test_message_system_errors(void)
     {
         len = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, tests[i].error_code,
                 LANG_USER_DEFAULT, buffer, ARRAY_SIZE(buffer), NULL);
-        ok(len || broken(tests[i].broken), "Got zero len, code %#x.\n", tests[i].error_code);
+        ok(len || broken(tests[i].broken), "Got zero len, code %#lx.\n", tests[i].error_code);
     }
 }
 
diff --git a/dlls/kernel32/tests/heap.c b/dlls/kernel32/tests/heap.c
index 8558bd7f1b3..bc573050d16 100644
--- a/dlls/kernel32/tests/heap.c
+++ b/dlls/kernel32/tests/heap.c
@@ -107,7 +107,7 @@ static void test_heap(void)
         mem = HeapAlloc(GetProcessHeap(), 0, size);
         heap_size = HeapSize(GetProcessHeap(), 0, mem);
         ok(heap_size == size || heap_size == resize_9x(size), 
-            "HeapSize returned %lu instead of %lu or %lu\n", heap_size, size, resize_9x(size));
+            "HeapSize returned %Iu instead of %Iu or %Iu\n", heap_size, size, resize_9x(size));
         HeapFree(GetProcessHeap(), 0, mem);
     }
 
@@ -126,7 +126,7 @@ static void test_heap(void)
     ok(msecond != NULL, "HeapReAlloc(0) should have succeeded\n");
     size = HeapSize(GetProcessHeap(), 0, msecond);
     ok(size == 0 || broken(size == 1) /* some vista and win7 */,
-       "HeapSize should have returned 0 instead of %lu\n", size);
+       "HeapSize should have returned 0 instead of %Iu\n", size);
     HeapFree(GetProcessHeap(), 0, msecond);
 
     /* large blocks must be 16-byte aligned */
@@ -143,16 +143,16 @@ static void test_heap(void)
     gbl = GlobalReAlloc(gbl, 10, GMEM_MOVEABLE);
     ok(gbl != NULL, "Can't realloc global memory\n");
     size = GlobalSize(gbl);
-    ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size);
+    ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%Id\n", size);
 
     gbl = GlobalReAlloc(gbl, 0, GMEM_MOVEABLE);
     ok(gbl != NULL, "GlobalReAlloc should not fail on size 0\n");
 
     size = GlobalSize(gbl);
-    ok(size == 0, "Memory not resized to size 0, instead size=%ld\n", size);
+    ok(size == 0, "Memory not resized to size 0, instead size=%Id\n", size);
     ok(GlobalFree(gbl) == NULL, "Memory not freed\n");
     size = GlobalSize(gbl);
-    ok(size == 0, "Memory should have been freed, size=%ld\n", size);
+    ok(size == 0, "Memory should have been freed, size=%Id\n", size);
 
     gbl = GlobalReAlloc(0, 10, GMEM_MOVEABLE);
     ok(gbl == NULL, "global realloc allocated memory\n");
@@ -162,39 +162,39 @@ static void test_heap(void)
 
     SetLastError(MAGIC_DEAD);
     mem = GlobalLock(gbl);      /* #1 */
-    ok(mem != NULL, "returned %p with %d (expected '!= NULL')\n", mem, GetLastError());
+    ok(mem != NULL, "returned %p with %ld (expected '!= NULL')\n", mem, GetLastError());
     SetLastError(MAGIC_DEAD);
     flags = GlobalFlags(gbl);
-    ok( flags == 1, "returned 0x%04x with %d (expected '0x0001')\n",
+    ok( flags == 1, "returned 0x%04x with %ld (expected '0x0001')\n",
         flags, GetLastError());
 
     SetLastError(MAGIC_DEAD);
     msecond = GlobalLock(gbl);   /* #2 */
-    ok( msecond == mem, "returned %p with %d (expected '%p')\n",
+    ok( msecond == mem, "returned %p with %ld (expected '%p')\n",
         msecond, GetLastError(), mem);
     SetLastError(MAGIC_DEAD);
     flags = GlobalFlags(gbl);
-    ok( flags == 2, "returned 0x%04x with %d (expected '0x0002')\n",
+    ok( flags == 2, "returned 0x%04x with %ld (expected '0x0002')\n",
         flags, GetLastError());
     SetLastError(MAGIC_DEAD);
 
     SetLastError(MAGIC_DEAD);
     res = GlobalUnlock(gbl);    /* #1 */
-    ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
+    ok(res, "returned %ld with %ld (expected '!= 0')\n", res, GetLastError());
     SetLastError(MAGIC_DEAD);
     flags = GlobalFlags(gbl);
-    ok( flags , "returned 0x%04x with %d (expected '!= 0')\n",
+    ok( flags , "returned 0x%04x with %ld (expected '!= 0')\n",
         flags, GetLastError());
 
     SetLastError(MAGIC_DEAD);
     res = GlobalUnlock(gbl);    /* #0 */
     /* NT: ERROR_SUCCESS (documented on MSDN), 9x: untouched */
     ok(!res && ((GetLastError() == ERROR_SUCCESS) || (GetLastError() == MAGIC_DEAD)),
-        "returned %d with %d (expected '0' with: ERROR_SUCCESS or "
+        "returned %ld with %ld (expected '0' with: ERROR_SUCCESS or "
         "MAGIC_DEAD)\n", res, GetLastError());
     SetLastError(MAGIC_DEAD);
     flags = GlobalFlags(gbl);
-    ok( !flags , "returned 0x%04x with %d (expected '0')\n",
+    ok( !flags , "returned 0x%04x with %ld (expected '0')\n",
         flags, GetLastError());
 
     /* Unlock an already unlocked Handle */
@@ -203,7 +203,7 @@ static void test_heap(void)
     /* NT: ERROR_NOT_LOCKED,  9x: untouched */
     ok( !res &&
         ((GetLastError() == ERROR_NOT_LOCKED) || (GetLastError() == MAGIC_DEAD)),
-        "returned %d with %d (expected '0' with: ERROR_NOT_LOCKED or "
+        "returned %ld with %ld (expected '0' with: ERROR_NOT_LOCKED or "
         "MAGIC_DEAD)\n", res, GetLastError());
 
     GlobalFree(gbl);
@@ -211,35 +211,35 @@ static void test_heap(void)
     SetLastError(MAGIC_DEAD);
     hsecond = GlobalFree(gbl);      /* invalid handle: free memory twice */
     ok( (hsecond == gbl) && (GetLastError() == ERROR_INVALID_HANDLE),
-        "returned %p with 0x%08x (expected %p with ERROR_INVALID_HANDLE)\n",
+        "returned %p with 0x%08lx (expected %p with ERROR_INVALID_HANDLE)\n",
         hsecond, GetLastError(), gbl);
     SetLastError(MAGIC_DEAD);
     hsecond = GlobalFree(LongToHandle(0xdeadbeef)); /* bogus handle */
     ok( (hsecond == LongToHandle(0xdeadbeef)) && (GetLastError() == ERROR_INVALID_HANDLE),
-        "returned %p with 0x%08x (expected %p with ERROR_INVALID_HANDLE)\n",
+        "returned %p with 0x%08lx (expected %p with ERROR_INVALID_HANDLE)\n",
         hsecond, GetLastError(), LongToHandle(0xdeadbeef));
     SetLastError(MAGIC_DEAD);
     hsecond = GlobalFree(LongToHandle(0xdeadbee0)); /* bogus pointer */
     ok( (hsecond == LongToHandle(0xdeadbee0)) &&
         ((GetLastError() == ERROR_INVALID_HANDLE) || broken(GetLastError() == ERROR_NOACCESS) /* wvista+ */),
-        "returned %p with 0x%08x (expected %p with ERROR_NOACCESS)\n",
+        "returned %p with 0x%08lx (expected %p with ERROR_NOACCESS)\n",
         hsecond, GetLastError(), LongToHandle(0xdeadbee0));
 
     SetLastError(MAGIC_DEAD);
     flags = GlobalFlags(gbl);
     ok( (flags == GMEM_INVALID_HANDLE) && (GetLastError() == ERROR_INVALID_HANDLE),
-        "returned 0x%04x with 0x%08x (expected GMEM_INVALID_HANDLE with "
+        "returned 0x%04x with 0x%08lx (expected GMEM_INVALID_HANDLE with "
         "ERROR_INVALID_HANDLE)\n", flags, GetLastError());
     SetLastError(MAGIC_DEAD);
     size = GlobalSize(gbl);
     ok( (size == 0) && (GetLastError() == ERROR_INVALID_HANDLE),
-        "returned %ld with 0x%08x (expected '0' with ERROR_INVALID_HANDLE)\n",
+        "returned %Id with 0x%08lx (expected '0' with ERROR_INVALID_HANDLE)\n",
         size, GetLastError());
 
     SetLastError(MAGIC_DEAD);
     mem = GlobalLock(gbl);
     ok( (mem == NULL) && (GetLastError() == ERROR_INVALID_HANDLE),
-        "returned %p with 0x%08x (expected NULL with ERROR_INVALID_HANDLE)\n",
+        "returned %p with 0x%08lx (expected NULL with ERROR_INVALID_HANDLE)\n",
         mem, GetLastError());
 
     /* documented on MSDN: GlobalUnlock() return FALSE on failure.
@@ -249,7 +249,7 @@ static void test_heap(void)
     SetLastError(MAGIC_DEAD);
     res = GlobalUnlock(gbl);
     ok(GetLastError() == ERROR_INVALID_HANDLE,
-        "returned %d with %d (expected ERROR_INVALID_HANDLE)\n",
+        "returned %ld with %ld (expected ERROR_INVALID_HANDLE)\n",
         res, GetLastError());
 
     gbl = GlobalAlloc(GMEM_DDESHARE, 100);
@@ -267,7 +267,7 @@ static void test_heap(void)
         if (mem == gbl)
             ok(GetLastError() == ERROR_INVALID_HANDLE ||
                GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */
-               "Expected ERROR_INVALID_HANDLE or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+               "Expected ERROR_INVALID_HANDLE or ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
     }
 
     /* GMEM_FIXED block expands in place only without flags */
@@ -276,7 +276,7 @@ static void test_heap(void)
         SetLastError(MAGIC_DEAD);
         hsecond = GlobalReAlloc(gbl, size + init_size, 0);
         ok(hsecond == gbl || (hsecond == NULL && GetLastError() == ERROR_NOT_ENOUGH_MEMORY),
-           "got %p with %x (expected %p or NULL) @%ld\n", hsecond, GetLastError(), gbl, size);
+           "got %p with %lx (expected %p or NULL) @%Id\n", hsecond, GetLastError(), gbl, size);
         GlobalFree(gbl);
     }
 
@@ -286,9 +286,9 @@ static void test_heap(void)
         SetLastError(MAGIC_DEAD);
         hsecond = GlobalReAlloc(gbl, size + init_size, GMEM_MOVEABLE);
         ok(hsecond != NULL,
-           "got %p with %x (expected non-NULL) @%ld\n", hsecond, GetLastError(), size);
+           "got %p with %lx (expected non-NULL) @%Id\n", hsecond, GetLastError(), size);
         mem = GlobalLock(hsecond);
-        ok(mem == hsecond, "got %p (expected %p) @%ld\n", mem, hsecond, size);
+        ok(mem == hsecond, "got %p (expected %p) @%Id\n", mem, hsecond, size);
         GlobalFree(hsecond);
     }
 
@@ -297,12 +297,12 @@ static void test_heap(void)
     res = GlobalUnlock(gbl);
     ok(res == 1 ||
        broken(res == 0), /* win9x */
-       "Expected 1 or 0, got %d\n", res);
+       "Expected 1 or 0, got %ld\n", res);
 
     res = GlobalUnlock(gbl);
     ok(res == 1 ||
        broken(res == 0), /* win9x */
-       "Expected 1 or 0, got %d\n", res);
+       "Expected 1 or 0, got %ld\n", res);
 
     GlobalFree(gbl);
 
@@ -312,8 +312,8 @@ static void test_heap(void)
     res = GlobalUnlock(gbl);
     ok(res == 1 ||
        broken(res == 0), /* win9x */
-       "Expected 1 or 0, got %d\n", res);
-    ok(GetLastError() == 0xdeadbeef, "got %d\n", GetLastError());
+       "Expected 1 or 0, got %ld\n", res);
+    ok(GetLastError() == 0xdeadbeef, "got %ld\n", GetLastError());
 
     GlobalFree(gbl);
 
@@ -322,16 +322,16 @@ static void test_heap(void)
     {
         SetLastError(MAGIC_DEAD);
         size = GlobalSize((HGLOBAL)0xc042);
-        ok(size == 0, "Expected 0, got %ld\n", size);
+        ok(size == 0, "Expected 0, got %Id\n", size);
         ok(GetLastError() == ERROR_INVALID_HANDLE ||
            GetLastError() == ERROR_INVALID_PARAMETER, /* win9x */
-           "Expected ERROR_INVALID_HANDLE or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+           "Expected ERROR_INVALID_HANDLE or ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
     }
 
     gbl = GlobalAlloc( GMEM_FIXED, 0 );
     SetLastError(0xdeadbeef);
     size = GlobalSize( gbl );
-    ok( size == 1, "wrong size %lu\n", size );
+    ok( size == 1, "wrong size %Iu\n", size );
     GlobalFree( gbl );
 
     /* ####################################### */
@@ -342,16 +342,16 @@ static void test_heap(void)
     gbl = LocalReAlloc(gbl, 10, LMEM_MOVEABLE);
     ok(gbl != NULL, "Can't realloc local memory\n");
     size = LocalSize(gbl);
-    ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size);
+    ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%Id\n", size);
 
     gbl = LocalReAlloc(gbl, 0, LMEM_MOVEABLE);
     ok(gbl != NULL, "LocalReAlloc should not fail on size 0\n");
 
     size = LocalSize(gbl);
-    ok(size == 0, "Memory not resized to size 0, instead size=%ld\n", size);
+    ok(size == 0, "Memory not resized to size 0, instead size=%Id\n", size);
     ok(LocalFree(gbl) == NULL, "Memory not freed\n");
     size = LocalSize(gbl);
-    ok(size == 0, "Memory should have been freed, size=%ld\n", size);
+    ok(size == 0, "Memory should have been freed, size=%Id\n", size);
 
     gbl = LocalReAlloc(0, 10, LMEM_MOVEABLE);
     ok(gbl == NULL, "local realloc allocated memory\n");
@@ -360,39 +360,39 @@ static void test_heap(void)
     gbl = LocalAlloc(LMEM_MOVEABLE, 256);
     SetLastError(MAGIC_DEAD);
     mem = LocalLock(gbl);      /* #1 */
-    ok(mem != NULL, "returned %p with %d (expected '!= NULL')\n", mem, GetLastError());
+    ok(mem != NULL, "returned %p with %ld (expected '!= NULL')\n", mem, GetLastError());
     SetLastError(MAGIC_DEAD);
     flags = LocalFlags(gbl);
-    ok( flags == 1, "returned 0x%04x with %d (expected '0x0001')\n",
+    ok( flags == 1, "returned 0x%04x with %ld (expected '0x0001')\n",
         flags, GetLastError());
 
     SetLastError(MAGIC_DEAD);
     msecond = LocalLock(gbl);   /* #2 */
-    ok( msecond == mem, "returned %p with %d (expected '%p')\n",
+    ok( msecond == mem, "returned %p with %ld (expected '%p')\n",
         msecond, GetLastError(), mem);
     SetLastError(MAGIC_DEAD);
     flags = LocalFlags(gbl);
-    ok( flags == 2, "returned 0x%04x with %d (expected '0x0002')\n",
+    ok( flags == 2, "returned 0x%04x with %ld (expected '0x0002')\n",
         flags, GetLastError());
     SetLastError(MAGIC_DEAD);
 
     SetLastError(MAGIC_DEAD);
     res = LocalUnlock(gbl);    /* #1 */
-    ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
+    ok(res, "returned %ld with %ld (expected '!= 0')\n", res, GetLastError());
     SetLastError(MAGIC_DEAD);
     flags = LocalFlags(gbl);
-    ok( flags , "returned 0x%04x with %d (expected '!= 0')\n",
+    ok( flags , "returned 0x%04x with %ld (expected '!= 0')\n",
         flags, GetLastError());
 
     SetLastError(MAGIC_DEAD);
     res = LocalUnlock(gbl);    /* #0 */
     /* NT: ERROR_SUCCESS (documented on MSDN), 9x: untouched */
     ok(!res && ((GetLastError() == ERROR_SUCCESS) || (GetLastError() == MAGIC_DEAD)),
-        "returned %d with %d (expected '0' with: ERROR_SUCCESS or "
+        "returned %ld with %ld (expected '0' with: ERROR_SUCCESS or "
         "MAGIC_DEAD)\n", res, GetLastError());
     SetLastError(MAGIC_DEAD);
     flags = LocalFlags(gbl);
-    ok( !flags , "returned 0x%04x with %d (expected '0')\n",
+    ok( !flags , "returned 0x%04x with %ld (expected '0')\n",
         flags, GetLastError());
 
     /* Unlock an already unlocked Handle */
@@ -401,7 +401,7 @@ static void test_heap(void)
     /* NT: ERROR_NOT_LOCKED,  9x: untouched */
     ok( !res &&
         ((GetLastError() == ERROR_NOT_LOCKED) || (GetLastError() == MAGIC_DEAD)),
-        "returned %d with %d (expected '0' with: ERROR_NOT_LOCKED or "
+        "returned %ld with %ld (expected '0' with: ERROR_NOT_LOCKED or "
         "MAGIC_DEAD)\n", res, GetLastError());
 
     LocalFree(gbl);
@@ -409,30 +409,30 @@ static void test_heap(void)
     SetLastError(MAGIC_DEAD);
     hsecond = LocalFree(gbl);       /* invalid handle: free memory twice */
     ok( (hsecond == gbl) && (GetLastError() == ERROR_INVALID_HANDLE),
-        "returned %p with 0x%08x (expected %p with ERROR_INVALID_HANDLE)\n",
+        "returned %p with 0x%08lx (expected %p with ERROR_INVALID_HANDLE)\n",
         hsecond, GetLastError(), gbl);
     SetLastError(MAGIC_DEAD);
     flags = LocalFlags(gbl);
     ok( (flags == LMEM_INVALID_HANDLE) && (GetLastError() == ERROR_INVALID_HANDLE),
-        "returned 0x%04x with 0x%08x (expected LMEM_INVALID_HANDLE with "
+        "returned 0x%04x with 0x%08lx (expected LMEM_INVALID_HANDLE with "
         "ERROR_INVALID_HANDLE)\n", flags, GetLastError());
     SetLastError(MAGIC_DEAD);
     size = LocalSize(gbl);
     ok( (size == 0) && (GetLastError() == ERROR_INVALID_HANDLE),
-        "returned %ld with 0x%08x (expected '0' with ERROR_INVALID_HANDLE)\n",
+        "returned %Id with 0x%08lx (expected '0' with ERROR_INVALID_HANDLE)\n",
         size, GetLastError());
 
     SetLastError(MAGIC_DEAD);
     mem = LocalLock(gbl);
     ok( (mem == NULL) && (GetLastError() == ERROR_INVALID_HANDLE),
-        "returned %p with 0x%08x (expected NULL with ERROR_INVALID_HANDLE)\n",
+        "returned %p with 0x%08lx (expected NULL with ERROR_INVALID_HANDLE)\n",
         mem, GetLastError());
 
     /* This Test works the same on all Systems (GlobalUnlock() is different) */
     SetLastError(MAGIC_DEAD);
     res = LocalUnlock(gbl);
     ok(!res && (GetLastError() == ERROR_INVALID_HANDLE),
-        "returned %d with %d (expected '0' with ERROR_INVALID_HANDLE)\n",
+        "returned %ld with %ld (expected '0' with ERROR_INVALID_HANDLE)\n",
         res, GetLastError());
 
     /* LMEM_FIXED block expands in place only without flags */
@@ -441,7 +441,7 @@ static void test_heap(void)
         SetLastError(MAGIC_DEAD);
         hsecond = LocalReAlloc(gbl, size + init_size, 0);
         ok(hsecond == gbl || (hsecond == NULL && GetLastError() == ERROR_NOT_ENOUGH_MEMORY),
-           "got %p with %x (expected %p or NULL) @%ld\n", hsecond, GetLastError(), gbl, size);
+           "got %p with %lx (expected %p or NULL) @%Id\n", hsecond, GetLastError(), gbl, size);
         LocalFree(gbl);
     }
 
@@ -451,9 +451,9 @@ static void test_heap(void)
         SetLastError(MAGIC_DEAD);
         hsecond = LocalReAlloc(gbl, size + init_size, LMEM_MOVEABLE);
         ok(hsecond != NULL,
-           "got %p with %x (expected non-NULL) @%ld\n", hsecond, GetLastError(), size);
+           "got %p with %lx (expected non-NULL) @%Id\n", hsecond, GetLastError(), size);
         mem = LocalLock(hsecond);
-        ok(mem == hsecond, "got %p (expected %p) @%ld\n", mem, hsecond, size);
+        ok(mem == hsecond, "got %p (expected %p) @%Id\n", mem, hsecond, size);
         LocalFree(hsecond);
     }
 
@@ -461,16 +461,16 @@ static void test_heap(void)
     gbl = LocalAlloc(LMEM_FIXED, 100);
     SetLastError(0xdeadbeef);
     res = LocalUnlock(gbl);
-    ok(res == 0, "Expected 0, got %d\n", res);
+    ok(res == 0, "Expected 0, got %ld\n", res);
     ok(GetLastError() == ERROR_NOT_LOCKED ||
-       broken(GetLastError() == 0xdeadbeef) /* win9x */, "got %d\n", GetLastError());
+       broken(GetLastError() == 0xdeadbeef) /* win9x */, "got %ld\n", GetLastError());
     LocalFree(gbl);
 
     gbl = LocalAlloc( LMEM_FIXED, 0 );
     SetLastError(0xdeadbeef);
     size = LocalSize( gbl );
     ok( !size || broken(size == 1), /* vistau64 */
-        "wrong size %lu\n", size );
+        "wrong size %Iu\n", size );
     LocalFree( gbl );
 
     /* trying to lock empty memory should give an error */
@@ -481,7 +481,7 @@ static void test_heap(void)
     /* NT: ERROR_DISCARDED,  9x: untouched */
     ok( (mem == NULL) &&
         ((GetLastError() == ERROR_DISCARDED) || (GetLastError() == MAGIC_DEAD)),
-        "returned %p with 0x%x/%d (expected 'NULL' with: ERROR_DISCARDED or "
+        "returned %p with 0x%lx/%ld (expected 'NULL' with: ERROR_DISCARDED or "
         "MAGIC_DEAD)\n", mem, GetLastError(), GetLastError());
 
     GlobalFree(gbl);
@@ -495,8 +495,8 @@ static void test_heap(void)
 
     size = GlobalSize(gbl);
     size2 = GlobalSize(mem);
-    ok(size == 0x123, "got %lu\n", size);
-    ok(size2 == 0x123, "got %lu\n", size2);
+    ok(size == 0x123, "got %Iu\n", size);
+    ok(size2 == 0x123, "got %Iu\n", size2);
 
     GlobalFree(gbl);
 
@@ -508,12 +508,12 @@ static void test_heap(void)
     ok(gbl == mem, "got %p, %p.\n", gbl, mem);
 
     size = GlobalSize(gbl);
-    ok(size == 0x123, "got %lu\n", size);
+    ok(size == 0x123, "got %Iu\n", size);
 
     GlobalFree(gbl);
 
     size = GlobalSize((void *)0xdeadbee0);
-    ok(size == 0, "got %lu\n", size);
+    ok(size == 0, "got %Iu\n", size);
 
 }
 
@@ -646,7 +646,7 @@ static void test_GlobalAlloc(void)
 
     /* Check that a 'zeroing' alloc works */
     mem2=GlobalAlloc(GMEM_ZEROINIT,memchunk);
-    ok(mem2!=NULL,"GlobalAlloc failed: error=%d\n",GetLastError());
+    ok(mem2!=NULL,"GlobalAlloc failed: error=%ld\n",GetLastError());
     if(mem2) {
       ok(GlobalSize(mem2)>=memchunk,"GlobalAlloc should return a big enough memory block\n");
       mem2ptr=GlobalLock(mem2);
@@ -720,18 +720,18 @@ static void test_LocalAlloc(void)
 
     /* Check that a normal alloc works */
     mem1=LocalAlloc(0,memchunk);
-    ok(mem1!=NULL,"LocalAlloc failed: error=%d\n",GetLastError());
+    ok(mem1!=NULL,"LocalAlloc failed: error=%ld\n",GetLastError());
     if(mem1) {
       ok(LocalSize(mem1)>=memchunk, "LocalAlloc should return a big enough memory block\n");
     }
 
     /* Check that a 'zeroing' and lock alloc works */
     mem2=LocalAlloc(LMEM_ZEROINIT|LMEM_MOVEABLE,memchunk);
-    ok(mem2!=NULL,"LocalAlloc failed: error=%d\n",GetLastError());
+    ok(mem2!=NULL,"LocalAlloc failed: error=%ld\n",GetLastError());
     if(mem2) {
       ok(LocalSize(mem2)>=memchunk,"LocalAlloc should return a big enough memory block\n");
       mem2ptr=LocalLock(mem2);
-      ok(mem2ptr!=NULL,"LocalLock: error=%d\n",GetLastError());
+      ok(mem2ptr!=NULL,"LocalLock: error=%ld\n",GetLastError());
       if(mem2ptr) {
         error=FALSE;
         for(i=0;i<memchunk;i++) {
@@ -743,7 +743,7 @@ static void test_LocalAlloc(void)
         SetLastError(0);
         error=LocalUnlock(mem2);
         ok(!error && GetLastError()==NO_ERROR,
-           "LocalUnlock Failed: rc=%d err=%d\n",error,GetLastError());
+           "LocalUnlock Failed: rc=%d err=%ld\n",error,GetLastError());
       }
     }
    mem2a=LocalFree(mem2);
@@ -751,11 +751,11 @@ static void test_LocalAlloc(void)
 
    /* Reallocate mem2 as moveable memory */
    mem2=LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT,memchunk);
-   ok(mem2!=NULL, "LocalAlloc failed to create moveable memory, error=%d\n",GetLastError());
+   ok(mem2!=NULL, "LocalAlloc failed to create moveable memory, error=%ld\n",GetLastError());
 
    /* Check that ReAllocing memory works as expected */
     mem2a=LocalReAlloc(mem2,2*memchunk,LMEM_MOVEABLE | LMEM_ZEROINIT);
-    ok(mem2a!=NULL,"LocalReAlloc failed, error=%d\n",GetLastError());
+    ok(mem2a!=NULL,"LocalReAlloc failed, error=%ld\n",GetLastError());
     if(mem2a) {
       ok(LocalSize(mem2a)>=2*memchunk,"LocalReAlloc failed\n");
       mem2ptr=LocalLock(mem2a);
@@ -830,7 +830,7 @@ static void test_obsolete_flags(void)
 
         ok( resultflags == test_global_flags[i].globalflags ||
             broken(resultflags == (test_global_flags[i].globalflags & ~GMEM_DDESHARE)), /* win9x */
-            "%u: expected 0x%08x, but returned 0x%08x with %d\n",
+            "%u: expected 0x%08x, but returned 0x%08x with %ld\n",
             i, test_global_flags[i].globalflags, resultflags, GetLastError() );
 
         GlobalFree(gbl);
@@ -869,8 +869,8 @@ static void test_HeapQueryInformation(void)
                                 NULL, 0, &size);
     ok(!ret, "HeapQueryInformation should fail\n");
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-       "expected ERROR_INSUFFICIENT_BUFFER got %u\n", GetLastError());
-    ok(size == sizeof(ULONG), "expected 4, got %lu\n", size);
+       "expected ERROR_INSUFFICIENT_BUFFER got %lu\n", GetLastError());
+    ok(size == sizeof(ULONG), "expected 4, got %Iu\n", size);
 
     SetLastError(0xdeadbeef);
     ret = pHeapQueryInformation(GetProcessHeap(),
@@ -878,15 +878,15 @@ static void test_HeapQueryInformation(void)
                                 NULL, 0, NULL);
     ok(!ret, "HeapQueryInformation should fail\n");
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-       "expected ERROR_INSUFFICIENT_BUFFER got %u\n", GetLastError());
+       "expected ERROR_INSUFFICIENT_BUFFER got %lu\n", GetLastError());
 
     info = 0xdeadbeaf;
     SetLastError(0xdeadbeef);
     ret = pHeapQueryInformation(GetProcessHeap(),
                                 HeapCompatibilityInformation,
                                 &info, sizeof(info) + 1, NULL);
-    ok(ret, "HeapQueryInformation error %u\n", GetLastError());
-    ok(info == 0 || info == 1 || info == 2, "expected 0, 1 or 2, got %u\n", info);
+    ok(ret, "HeapQueryInformation error %lu\n", GetLastError());
+    ok(info == 0 || info == 1 || info == 2, "expected 0, 1 or 2, got %lu\n", info);
 }
 
 static void test_heap_checks( DWORD flags )
@@ -896,7 +896,7 @@ static void test_heap_checks( DWORD flags )
     SIZE_T i, size, large_size = 3000 * 1024 + 37;
 
     if (flags & HEAP_PAGE_ALLOCS) return;  /* no tests for that case yet */
-    trace( "testing heap flags %08x\n", flags );
+    trace( "testing heap flags %08lx\n", flags );
 
     p = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 17 );
     ok( p != NULL, "HeapAlloc failed\n" );
@@ -905,7 +905,7 @@ static void test_heap_checks( DWORD flags )
     ok( ret, "HeapValidate failed\n" );
 
     size = HeapSize( GetProcessHeap(), 0, p );
-    ok( size == 17, "Wrong size %lu\n", size );
+    ok( size == 17, "Wrong size %Iu\n", size );
 
     ok( p[14] == 0, "wrong data %x\n", p[14] );
     ok( p[15] == 0, "wrong data %x\n", p[15] );
@@ -952,7 +952,7 @@ static void test_heap_checks( DWORD flags )
         if (flags & HEAP_VALIDATE)
         {
             size = HeapSize( GetProcessHeap(), 0, p );
-            ok( size == ~(SIZE_T)0 || broken(size == ~0u), "Wrong size %lu\n", size );
+            ok( size == ~(SIZE_T)0 || broken(size == ~0u), "Wrong size %Iu\n", size );
 
             p2 = HeapReAlloc( GetProcessHeap(), 0, p, 14 );
             ok( p2 == NULL, "HeapReAlloc succeeded\n" );
@@ -964,7 +964,7 @@ static void test_heap_checks( DWORD flags )
 
         p[17] = old;
         size = HeapSize( GetProcessHeap(), 0, p );
-        ok( size == 17, "Wrong size %lu\n", size );
+        ok( size == 17, "Wrong size %Iu\n", size );
 
         p2 = HeapReAlloc( GetProcessHeap(), 0, p, 14 );
         ok( p2 != NULL, "HeapReAlloc failed\n" );
@@ -1010,7 +1010,7 @@ static void test_heap_checks( DWORD flags )
     ok( ret, "HeapValidate failed\n" );
 
     size = HeapSize( GetProcessHeap(), 0, p );
-    ok( size == large_size, "Wrong size %lu\n", size );
+    ok( size == large_size, "Wrong size %Iu\n", size );
 
     ok( p[large_size - 2] == 0, "wrong data %x\n", p[large_size - 2] );
     ok( p[large_size - 1] == 0, "wrong data %x\n", p[large_size - 1] );
@@ -1031,7 +1031,7 @@ static void test_heap_checks( DWORD flags )
             if (flags & HEAP_VALIDATE)
             {
                 size = HeapSize( GetProcessHeap(), 0, p );
-                ok( size == ~(SIZE_T)0, "Wrong size %lu\n", size );
+                ok( size == ~(SIZE_T)0, "Wrong size %Iu\n", size );
 
                 p2 = HeapReAlloc( GetProcessHeap(), 0, p, large_size - 3 );
                 ok( p2 == NULL, "HeapReAlloc succeeded\n" );
@@ -1053,7 +1053,7 @@ static void test_heap_checks( DWORD flags )
         {
             p = HeapAlloc( GetProcessHeap(), 0, size );
             for (i = 0; i < 32; i++) if (p[size + i] != 0xab) break;
-            ok( i >= 8, "only %lu tail bytes for size %lu\n", i, size );
+            ok( i >= 8, "only %Iu tail bytes for size %Iu\n", i, size );
             HeapFree( GetProcessHeap(), 0, p );
         }
     }
@@ -1083,7 +1083,7 @@ static void test_debug_heap( const char *argv0, DWORD flags )
         skip("Not authorized to change the image file execution options\n");
         return;
     }
-    ok( !err, "failed to create '%s' error %u\n", keyname, err );
+    ok( !err, "failed to create '%s' error %lu\n", keyname, err );
     if (err) return;
 
     if (flags == 0xdeadbeef)  /* magic value for unsetting it */
@@ -1094,9 +1094,9 @@ static void test_debug_heap( const char *argv0, DWORD flags )
     memset( &startup, 0, sizeof(startup) );
     startup.cb = sizeof(startup);
 
-    sprintf( buffer, "%s heap.c 0x%x", argv0, flags );
+    sprintf( buffer, "%s heap.c 0x%lx", argv0, flags );
     ret = CreateProcessA( NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info );
-    ok( ret, "failed to create child process error %u\n", GetLastError() );
+    ok( ret, "failed to create child process error %lu\n", GetLastError() );
     if (ret)
     {
         wait_child_process( info.hProcess );
@@ -1157,13 +1157,13 @@ static void test_child_heap( const char *arg )
     }
 
     ok( pRtlGetNtGlobalFlags() == expected,
-        "%s: got global flags %08x expected %08x\n", arg, pRtlGetNtGlobalFlags(), expected );
+        "%s: got global flags %08lx expected %08lx\n", arg, pRtlGetNtGlobalFlags(), expected );
 
     expect_heap = heap_flags_from_global_flag( expected );
 
     if (!(heap->flags & HEAP_GROWABLE) || heap->pattern == 0xffeeffee)  /* vista layout */
     {
-        ok( (heap->flags & ~HEAP_GROWABLE) == 0, "%s: got heap flags %08x\n", arg, heap->flags );
+        ok( (heap->flags & ~HEAP_GROWABLE) == 0, "%s: got heap flags %08lx\n", arg, heap->flags );
     }
     else if (heap->pattern == 0xeeeeeeee && heap->flags == 0xeeeeeeee)
     {
@@ -1172,9 +1172,9 @@ static void test_child_heap( const char *arg )
     else
     {
         ok( heap->flags == (expect_heap | HEAP_GROWABLE),
-            "%s: got heap flags %08x expected %08x\n", arg, heap->flags, expect_heap );
+            "%s: got heap flags %08lx expected %08lx\n", arg, heap->flags, expect_heap );
         ok( heap->force_flags == (expect_heap & ~0x18000080),
-            "%s: got heap force flags %08x expected %08x\n", arg, heap->force_flags, expect_heap );
+            "%s: got heap force flags %08lx expected %08lx\n", arg, heap->force_flags, expect_heap );
         expect_heap = heap->flags;
     }
 
@@ -1199,11 +1199,11 @@ static void test_GetPhysicallyInstalledSystemMemory(void)
     ret = pGetPhysicallyInstalledSystemMemory(NULL);
     ok(!ret, "GetPhysicallyInstalledSystemMemory should fail\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
+       "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
 
     total_memory = 0;
     ret = pGetPhysicallyInstalledSystemMemory(&total_memory);
-    ok(ret, "GetPhysicallyInstalledSystemMemory unexpectedly failed (%u)\n", GetLastError());
+    ok(ret, "GetPhysicallyInstalledSystemMemory unexpectedly failed (%lu)\n", GetLastError());
     ok(total_memory != 0, "expected total_memory != 0\n");
 
     memstatus.dwLength = sizeof(memstatus);
diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 6b5099ea612..365f4465fc7 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -211,16 +211,16 @@ static DWORD create_test_dll( const IMAGE_DOS_HEADER *dos_header, UINT dos_size,
     GetTempFileNameA(temp_path, "ldr", 0, dll_name);
 
     hfile = CreateFileA(dll_name, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, 0);
-    ok( hfile != INVALID_HANDLE_VALUE, "failed to create %s err %u\n", dll_name, GetLastError() );
+    ok( hfile != INVALID_HANDLE_VALUE, "failed to create %s err %lu\n", dll_name, GetLastError() );
     if (hfile == INVALID_HANDLE_VALUE) return 0;
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, dos_header, dos_size, &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, nt_header, sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     if (nt_header->FileHeader.SizeOfOptionalHeader)
     {
@@ -228,14 +228,14 @@ static DWORD create_test_dll( const IMAGE_DOS_HEADER *dos_header, UINT dos_size,
         ret = WriteFile(hfile, &nt_header->OptionalHeader,
                         sizeof(IMAGE_OPTIONAL_HEADER),
                         &dummy, NULL);
-        ok(ret, "WriteFile error %d\n", GetLastError());
+        ok(ret, "WriteFile error %ld\n", GetLastError());
         if (nt_header->FileHeader.SizeOfOptionalHeader > sizeof(IMAGE_OPTIONAL_HEADER))
         {
             file_align = nt_header->FileHeader.SizeOfOptionalHeader - sizeof(IMAGE_OPTIONAL_HEADER);
             assert(file_align < sizeof(filler));
             SetLastError(0xdeadbeef);
             ret = WriteFile(hfile, filler, file_align, &dummy, NULL);
-            ok(ret, "WriteFile error %d\n", GetLastError());
+            ok(ret, "WriteFile error %ld\n", GetLastError());
         }
     }
 
@@ -261,12 +261,12 @@ static DWORD create_test_dll( const IMAGE_DOS_HEADER *dos_header, UINT dos_size,
 
         SetLastError(0xdeadbeef);
         ret = WriteFile(hfile, &section, sizeof(section), &dummy, NULL);
-        ok(ret, "WriteFile error %d\n", GetLastError());
+        ok(ret, "WriteFile error %ld\n", GetLastError());
 
         /* section data */
         SetLastError(0xdeadbeef);
         ret = WriteFile(hfile, section_data, sizeof(section_data), &dummy, NULL);
-        ok(ret, "WriteFile error %d\n", GetLastError());
+        ok(ret, "WriteFile error %ld\n", GetLastError());
     }
 
     /* Minimal PE image that Windows7+ is able to load: 268 bytes */
@@ -276,7 +276,7 @@ static DWORD create_test_dll( const IMAGE_DOS_HEADER *dos_header, UINT dos_size,
         file_align = 268 - size;
         SetLastError(0xdeadbeef);
         ret = WriteFile(hfile, filler, file_align, &dummy, NULL);
-        ok(ret, "WriteFile error %d\n", GetLastError());
+        ok(ret, "WriteFile error %ld\n", GetLastError());
     }
 
     size = GetFileSize(hfile, NULL);
@@ -297,28 +297,28 @@ static DWORD create_test_dll_sections( const IMAGE_DOS_HEADER *dos_header, const
     GetTempFileNameA(temp_path, "ldr", 0, dll_name);
 
     hfile = CreateFileA(dll_name, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, 0);
-    ok( hfile != INVALID_HANDLE_VALUE, "failed to create %s err %u\n", dll_name, GetLastError() );
+    ok( hfile != INVALID_HANDLE_VALUE, "failed to create %s err %lu\n", dll_name, GetLastError() );
     if (hfile == INVALID_HANDLE_VALUE) return 0;
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, dos_header, sizeof(*dos_header), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, nt_header, offsetof(IMAGE_NT_HEADERS, OptionalHeader) + nt_header->FileHeader.SizeOfOptionalHeader, &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, sections, sizeof(*sections) * nt_header->FileHeader.NumberOfSections,
                     &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++)
     {
         SetFilePointer(hfile, sections[i].PointerToRawData, NULL, FILE_BEGIN);
         SetLastError(0xdeadbeef);
         ret = WriteFile(hfile, section_data, sections[i].SizeOfRawData, &dummy, NULL);
-        ok(ret, "WriteFile error %d\n", GetLastError());
+        ok(ret, "WriteFile error %ld\n", GetLastError());
     }
     size = GetFileSize(hfile, NULL);
     CloseHandle(hfile);
@@ -345,20 +345,20 @@ static BOOL query_image_section( int id, const char *dll_name, const IMAGE_NT_HE
 
     file = CreateFileA( dll_name, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE,
                         NULL, OPEN_EXISTING, 0, 0 );
-    ok( file != INVALID_HANDLE_VALUE, "%u: CreateFile error %d\n", id, GetLastError() );
+    ok( file != INVALID_HANDLE_VALUE, "%u: CreateFile error %ld\n", id, GetLastError() );
     file_size = GetFileSize( file, NULL );
 
     status = pNtCreateSection( &mapping, STANDARD_RIGHTS_REQUIRED | SECTION_MAP_READ | SECTION_QUERY,
                                NULL, NULL, PAGE_READONLY, SEC_IMAGE, file );
-    ok( !status, "%u: NtCreateSection failed err %x\n", id, status );
+    ok( !status, "%u: NtCreateSection failed err %lx\n", id, status );
     if (status)
     {
         CloseHandle( file );
         return FALSE;
     }
     status = pNtQuerySection( mapping, SectionImageInformation, &image, sizeof(image), &info_size );
-    ok( !status, "%u: NtQuerySection failed err %x\n", id, status );
-    ok( info_size == sizeof(image), "%u: NtQuerySection wrong size %lu\n", id, info_size );
+    ok( !status, "%u: NtQuerySection failed err %lx\n", id, status );
+    ok( info_size == sizeof(image), "%u: NtQuerySection wrong size %Iu\n", id, info_size );
     if (nt_header->OptionalHeader.Magic == (is_win64 ? IMAGE_NT_OPTIONAL_HDR64_MAGIC
                                                      : IMAGE_NT_OPTIONAL_HDR32_MAGIC))
     {
@@ -397,19 +397,19 @@ static BOOL query_image_section( int id, const char *dll_name, const IMAGE_NT_HE
     }
     ok( (char *)image.TransferAddress == (char *)entry_point ||
         (S(U(image)).ImageDynamicallyRelocated && LOWORD(image.TransferAddress) == LOWORD(entry_point)),
-        "%u: TransferAddress wrong %p / %p (%08x)\n", id,
+        "%u: TransferAddress wrong %p / %p (%08lx)\n", id,
         image.TransferAddress, entry_point, nt_header->OptionalHeader.AddressOfEntryPoint );
-    ok( image.ZeroBits == 0, "%u: ZeroBits wrong %08x\n", id, image.ZeroBits );
+    ok( image.ZeroBits == 0, "%u: ZeroBits wrong %08lx\n", id, image.ZeroBits );
     ok( image.MaximumStackSize == max_stack || broken(truncated),
-        "%u: MaximumStackSize wrong %lx / %lx\n", id, image.MaximumStackSize, max_stack );
+        "%u: MaximumStackSize wrong %Ix / %Ix\n", id, image.MaximumStackSize, max_stack );
     ok( image.CommittedStackSize == commit_stack || broken(truncated),
-        "%u: CommittedStackSize wrong %lx / %lx\n", id, image.CommittedStackSize, commit_stack );
+        "%u: CommittedStackSize wrong %Ix / %Ix\n", id, image.CommittedStackSize, commit_stack );
     if (truncated)
         ok( !image.SubSystemType || broken(truncated),
-            "%u: SubSystemType wrong %08x / 00000000\n", id, image.SubSystemType );
+            "%u: SubSystemType wrong %08lx / 00000000\n", id, image.SubSystemType );
     else
         ok( image.SubSystemType == nt_header->OptionalHeader.Subsystem,
-            "%u: SubSystemType wrong %08x / %08x\n", id,
+            "%u: SubSystemType wrong %08lx / %08x\n", id,
             image.SubSystemType, nt_header->OptionalHeader.Subsystem );
     ok( image.MinorSubsystemVersion == nt_header->OptionalHeader.MinorSubsystemVersion,
         "%u: MinorSubsystemVersion wrong %04x / %04x\n", id,
@@ -432,11 +432,11 @@ static BOOL query_image_section( int id, const char *dll_name, const IMAGE_NT_HE
         image.DllCharacteristics, nt_header->OptionalHeader.DllCharacteristics );
     ok( image.Machine == nt_header->FileHeader.Machine, "%u: Machine wrong %04x / %04x\n", id,
         image.Machine, nt_header->FileHeader.Machine );
-    ok( image.LoaderFlags == (cor_header != NULL), "%u: LoaderFlags wrong %08x\n", id, image.LoaderFlags );
+    ok( image.LoaderFlags == (cor_header != NULL), "%u: LoaderFlags wrong %08lx\n", id, image.LoaderFlags );
     ok( image.ImageFileSize == file_size || broken(!image.ImageFileSize), /* winxpsp1 */
-        "%u: ImageFileSize wrong %08x / %08x\n", id, image.ImageFileSize, file_size );
+        "%u: ImageFileSize wrong %08lx / %08lx\n", id, image.ImageFileSize, file_size );
     ok( image.CheckSum == nt_header->OptionalHeader.CheckSum || broken(truncated),
-        "%u: CheckSum wrong %08x / %08x\n", id,
+        "%u: CheckSum wrong %08lx / %08lx\n", id,
         image.CheckSum, nt_header->OptionalHeader.CheckSum );
 
     if (nt_header->OptionalHeader.SizeOfCode || nt_header->OptionalHeader.AddressOfEntryPoint)
@@ -500,39 +500,39 @@ static BOOL query_image_section( int id, const char *dll_name, const IMAGE_NT_HE
 
     map_size.QuadPart = (nt_header->OptionalHeader.SizeOfImage + page_size - 1) & ~(page_size - 1);
     status = pNtQuerySection( mapping, SectionBasicInformation, &info, sizeof(info), NULL );
-    ok( !status, "NtQuerySection failed err %x\n", status );
-    ok( info.Size.QuadPart == map_size.QuadPart, "NtQuerySection wrong size %x%08x / %x%08x\n",
+    ok( !status, "NtQuerySection failed err %lx\n", status );
+    ok( info.Size.QuadPart == map_size.QuadPart, "NtQuerySection wrong size %lx%08lx / %lx%08lx\n",
         info.Size.u.HighPart, info.Size.u.LowPart, map_size.u.HighPart, map_size.u.LowPart );
     CloseHandle( mapping );
 
     map_size.QuadPart = (nt_header->OptionalHeader.SizeOfImage + page_size - 1) & ~(page_size - 1);
     status = pNtCreateSection( &mapping, STANDARD_RIGHTS_REQUIRED | SECTION_MAP_READ | SECTION_QUERY,
                                NULL, &map_size, PAGE_READONLY, SEC_IMAGE, file );
-    ok( !status, "%u: NtCreateSection failed err %x\n", id, status );
+    ok( !status, "%u: NtCreateSection failed err %lx\n", id, status );
     status = pNtQuerySection( mapping, SectionBasicInformation, &info, sizeof(info), NULL );
-    ok( !status, "NtQuerySection failed err %x\n", status );
-    ok( info.Size.QuadPart == map_size.QuadPart, "NtQuerySection wrong size %x%08x / %x%08x\n",
+    ok( !status, "NtQuerySection failed err %lx\n", status );
+    ok( info.Size.QuadPart == map_size.QuadPart, "NtQuerySection wrong size %lx%08lx / %lx%08lx\n",
         info.Size.u.HighPart, info.Size.u.LowPart, map_size.u.HighPart, map_size.u.LowPart );
     CloseHandle( mapping );
 
     map_size.QuadPart++;
     status = pNtCreateSection( &mapping, STANDARD_RIGHTS_REQUIRED | SECTION_MAP_READ | SECTION_QUERY,
                                NULL, &map_size, PAGE_READONLY, SEC_IMAGE, file );
-    ok( status == STATUS_SECTION_TOO_BIG, "%u: NtCreateSection failed err %x\n", id, status );
+    ok( status == STATUS_SECTION_TOO_BIG, "%u: NtCreateSection failed err %lx\n", id, status );
 
     SetFilePointerEx( file, map_size, NULL, FILE_BEGIN );
     SetEndOfFile( file );
     status = pNtCreateSection( &mapping, STANDARD_RIGHTS_REQUIRED | SECTION_MAP_READ | SECTION_QUERY,
                                NULL, &map_size, PAGE_READONLY, SEC_IMAGE, file );
-    ok( status == STATUS_SECTION_TOO_BIG, "%u: NtCreateSection failed err %x\n", id, status );
+    ok( status == STATUS_SECTION_TOO_BIG, "%u: NtCreateSection failed err %lx\n", id, status );
 
     map_size.QuadPart = 1;
     status = pNtCreateSection( &mapping, STANDARD_RIGHTS_REQUIRED | SECTION_MAP_READ | SECTION_QUERY,
                                NULL, &map_size, PAGE_READONLY, SEC_IMAGE, file );
-    ok( !status, "%u: NtCreateSection failed err %x\n", id, status );
+    ok( !status, "%u: NtCreateSection failed err %lx\n", id, status );
     status = pNtQuerySection( mapping, SectionBasicInformation, &info, sizeof(info), NULL );
-    ok( !status, "NtQuerySection failed err %x\n", status );
-    ok( info.Size.QuadPart == map_size.QuadPart, "NtQuerySection wrong size %x%08x / %x%08x\n",
+    ok( !status, "NtQuerySection failed err %lx\n", status );
+    ok( info.Size.QuadPart == map_size.QuadPart, "NtQuerySection wrong size %lx%08lx / %lx%08lx\n",
         info.Size.u.HighPart, info.Size.u.LowPart, map_size.u.HighPart, map_size.u.LowPart );
     CloseHandle( mapping );
 
@@ -612,7 +612,7 @@ static NTSTATUS map_image_section( const IMAGE_NT_HEADERS *nt_header, const IMAG
     file_size = create_test_dll_sections( &dos_header, nt_header, sections, section_data, dll_name );
 
     file = CreateFileA(dll_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
-    ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "CreateFile error %ld\n", GetLastError());
 
     size.QuadPart = file_size;
     status = pNtCreateSection(&map, STANDARD_RIGHTS_REQUIRED | SECTION_MAP_READ | SECTION_QUERY,
@@ -631,11 +631,11 @@ static NTSTATUS map_image_section( const IMAGE_NT_HEADERS *nt_header, const IMAG
         SECTION_BASIC_INFORMATION info;
         SIZE_T info_size = 0xdeadbeef;
         NTSTATUS ret = pNtQuerySection( map, SectionBasicInformation, &info, sizeof(info), &info_size );
-        ok( !ret, "NtQuerySection failed err %x\n", ret );
-        ok( info_size == sizeof(info), "NtQuerySection wrong size %lu\n", info_size );
-        ok( info.Attributes == (SEC_IMAGE | SEC_FILE), "NtQuerySection wrong attr %x\n", info.Attributes );
+        ok( !ret, "NtQuerySection failed err %lx\n", ret );
+        ok( info_size == sizeof(info), "NtQuerySection wrong size %Iu\n", info_size );
+        ok( info.Attributes == (SEC_IMAGE | SEC_FILE), "NtQuerySection wrong attr %lx\n", info.Attributes );
         ok( info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", info.BaseAddress );
-        ok( info.Size.QuadPart == file_size, "NtQuerySection wrong size %x%08x / %08x\n",
+        ok( info.Size.QuadPart == file_size, "NtQuerySection wrong size %lx%08lx / %08lx\n",
             info.Size.u.HighPart, info.Size.u.LowPart, file_size );
         has_code = query_image_section( line, dll_name, nt_header, section_data );
 
@@ -655,12 +655,12 @@ static NTSTATUS map_image_section( const IMAGE_NT_HEADERS *nt_header, const IMAG
             if (!has_code && is_win64)
             {
                 ok_(__FILE__,line)( mod != NULL || want_32bit || broken(il_only), /* <= win7 */
-                    "loading failed err %u\n", GetLastError() );
+                    "loading failed err %lu\n", GetLastError() );
             }
             else
             {
                 ok_(__FILE__, line)( !mod, "loading succeeded\n" );
-                ok_(__FILE__, line)( GetLastError() == ERROR_BAD_EXE_FORMAT, "wrong error %u\n", GetLastError() );
+                ok_(__FILE__, line)( GetLastError() == ERROR_BAD_EXE_FORMAT, "wrong error %lu\n", GetLastError() );
             }
         }
         else
@@ -669,7 +669,7 @@ static NTSTATUS map_image_section( const IMAGE_NT_HEADERS *nt_header, const IMAG
 
             ok( mod != NULL || broken(il_only) || /* <= win7 */
                 broken( wrong_machine ), /* win8 */
-                "%u: loading failed err %u\n", line, GetLastError() );
+                "%u: loading failed err %lu\n", line, GetLastError() );
             if (!mod && wrong_machine) expect_status = STATUS_INVALID_IMAGE_FORMAT;
         }
         if (mod) FreeLibrary( mod );
@@ -690,7 +690,7 @@ static NTSTATUS map_image_section( const IMAGE_NT_HEADERS *nt_header, const IMAG
             if (!expect_status)
                 ok( !expect_fallback, "%u: got test dll but expected fallback\n", line );
             else
-                ok( !expect_fallback, "%u: got test dll but expected failure %x\n", line, expect_status );
+                ok( !expect_fallback, "%u: got test dll but expected failure %lx\n", line, expect_status );
         }
         else if (!lstrcmpiW( path, load_fallback_name ))
         {
@@ -703,7 +703,7 @@ static NTSTATUS map_image_section( const IMAGE_NT_HEADERS *nt_header, const IMAG
                     "%u: got fallback but expected test dll\n", line );
             else
                 ok( broken(expect_status == STATUS_INVALID_IMAGE_FORMAT), /* <= vista */
-                    "%u: got fallback but expected failure %x\n", line, expect_status );
+                    "%u: got fallback but expected failure %lx\n", line, expect_status );
         }
         else ok( 0, "%u: got unexpected path %s instead of %s\n", line, wine_dbgstr_w(path), wine_dbgstr_w(load_test_name));
         pLdrUnloadDll( ldr_mod );
@@ -720,9 +720,9 @@ static NTSTATUS map_image_section( const IMAGE_NT_HEADERS *nt_header, const IMAG
         ok( ldr_status == expect_status ||
             broken(il_only && !expect_status && ldr_status == STATUS_INVALID_IMAGE_FORMAT) ||
             broken(nt_header->Signature == IMAGE_OS2_SIGNATURE && ldr_status == STATUS_INVALID_IMAGE_NE_FORMAT),
-            "%u: wrong status %x/%x\n", line, ldr_status, expect_status );
+            "%u: wrong status %lx/%lx\n", line, ldr_status, expect_status );
         ok( !expect_fallback || broken(il_only) || broken(wrong_machine),
-            "%u: failed with %x expected fallback\n", line, ldr_status );
+            "%u: failed with %lx expected fallback\n", line, ldr_status );
     }
 
 done:
@@ -925,50 +925,50 @@ static void test_Loader(void)
             SetLastError(0xdeadbeef);
             size = VirtualQuery(hlib, &info, sizeof(info));
             ok(size == sizeof(info),
-                "%d: VirtualQuery error %d\n", i, GetLastError());
+                "%d: VirtualQuery error %ld\n", i, GetLastError());
             ok(info.BaseAddress == hlib, "%p != %p\n", info.BaseAddress, hlib);
             ok(info.AllocationBase == hlib, "%p != %p\n", info.AllocationBase, hlib);
-            ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%x != PAGE_EXECUTE_WRITECOPY\n", info.AllocationProtect);
-            ok(info.RegionSize == ALIGN_SIZE(nt_header.OptionalHeader.SizeOfImage, page_size), "got %lx != expected %x\n",
+            ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%lx != PAGE_EXECUTE_WRITECOPY\n", info.AllocationProtect);
+            ok(info.RegionSize == ALIGN_SIZE(nt_header.OptionalHeader.SizeOfImage, page_size), "got %Ix != expected %lx\n",
                info.RegionSize, ALIGN_SIZE(nt_header.OptionalHeader.SizeOfImage, page_size));
-            ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
+            ok(info.State == MEM_COMMIT, "%lx != MEM_COMMIT\n", info.State);
             if (nt_header.OptionalHeader.SectionAlignment < page_size)
-                ok(info.Protect == PAGE_EXECUTE_WRITECOPY, "%x != PAGE_EXECUTE_WRITECOPY\n", info.Protect);
+                ok(info.Protect == PAGE_EXECUTE_WRITECOPY, "%lx != PAGE_EXECUTE_WRITECOPY\n", info.Protect);
             else
-                ok(info.Protect == PAGE_READONLY, "%x != PAGE_READONLY\n", info.Protect);
-            ok(info.Type == SEC_IMAGE, "%x != SEC_IMAGE\n", info.Type);
+                ok(info.Protect == PAGE_READONLY, "%lx != PAGE_READONLY\n", info.Protect);
+            ok(info.Type == SEC_IMAGE, "%lx != SEC_IMAGE\n", info.Type);
 
             SetLastError(0xdeadbeef);
             ptr = VirtualAlloc(hlib, page_size, MEM_COMMIT, info.Protect);
             ok(!ptr, "VirtualAlloc should fail\n");
-            ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+            ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
 
             SetLastError(0xdeadbeef);
             size = VirtualQuery((char *)hlib + info.RegionSize, &info, sizeof(info));
-            ok(size == sizeof(info), "VirtualQuery error %d\n", GetLastError());
+            ok(size == sizeof(info), "VirtualQuery error %ld\n", GetLastError());
             if (nt_header.OptionalHeader.SectionAlignment == page_size ||
                 nt_header.OptionalHeader.SectionAlignment == nt_header.OptionalHeader.FileAlignment)
             {
                 ok(info.BaseAddress == (char *)hlib + ALIGN_SIZE(nt_header.OptionalHeader.SizeOfImage, page_size), "got %p != expected %p\n",
                    info.BaseAddress, (char *)hlib + ALIGN_SIZE(nt_header.OptionalHeader.SizeOfImage, page_size));
                 ok(info.AllocationBase == 0, "%p != 0\n", info.AllocationBase);
-                ok(info.AllocationProtect == 0, "%x != 0\n", info.AllocationProtect);
+                ok(info.AllocationProtect == 0, "%lx != 0\n", info.AllocationProtect);
                 /*ok(info.RegionSize == not_practical_value, "%d: %lx != not_practical_value\n", i, info.RegionSize);*/
-                ok(info.State == MEM_FREE, "%x != MEM_FREE\n", info.State);
-                ok(info.Type == 0, "%x != 0\n", info.Type);
-                ok(info.Protect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.Protect);
+                ok(info.State == MEM_FREE, "%lx != MEM_FREE\n", info.State);
+                ok(info.Type == 0, "%lx != 0\n", info.Type);
+                ok(info.Protect == PAGE_NOACCESS, "%lx != PAGE_NOACCESS\n", info.Protect);
             }
             else
             {
-                ok(info.Protect == PAGE_EXECUTE_WRITECOPY, "%x != PAGE_EXECUTE_WRITECOPY\n", info.Protect);
+                ok(info.Protect == PAGE_EXECUTE_WRITECOPY, "%lx != PAGE_EXECUTE_WRITECOPY\n", info.Protect);
                 ok(info.BaseAddress == hlib, "got %p != expected %p\n", info.BaseAddress, hlib);
                 ok(info.AllocationBase == hlib, "%p != %p\n", info.AllocationBase, hlib);
-                ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%x != PAGE_EXECUTE_WRITECOPY\n", info.AllocationProtect);
-                ok(info.RegionSize == ALIGN_SIZE(file_size, page_size), "got %lx != expected %x\n",
+                ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%lx != PAGE_EXECUTE_WRITECOPY\n", info.AllocationProtect);
+                ok(info.RegionSize == ALIGN_SIZE(file_size, page_size), "got %Ix != expected %lx\n",
                    info.RegionSize, ALIGN_SIZE(file_size, page_size));
-                ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
-                ok(info.Protect == PAGE_READONLY, "%x != PAGE_READONLY\n", info.Protect);
-                ok(info.Type == SEC_IMAGE, "%x != SEC_IMAGE\n", info.Type);
+                ok(info.State == MEM_COMMIT, "%lx != MEM_COMMIT\n", info.State);
+                ok(info.Protect == PAGE_READONLY, "%lx != PAGE_READONLY\n", info.Protect);
+                ok(info.Type == SEC_IMAGE, "%lx != SEC_IMAGE\n", info.Type);
             }
 
             /* header: check the zeroing of alignment */
@@ -986,25 +986,25 @@ static void test_Loader(void)
                 SetLastError(0xdeadbeef);
                 size = VirtualQuery((char *)hlib + section.VirtualAddress, &info, sizeof(info));
                 ok(size == sizeof(info),
-                    "VirtualQuery error %d\n", GetLastError());
+                    "VirtualQuery error %ld\n", GetLastError());
                 if (nt_header.OptionalHeader.SectionAlignment < page_size)
                 {
                     ok(info.BaseAddress == hlib, "got %p != expected %p\n", info.BaseAddress, hlib);
-                    ok(info.RegionSize == ALIGN_SIZE(nt_header.OptionalHeader.SizeOfImage, page_size), "got %lx != expected %x\n",
+                    ok(info.RegionSize == ALIGN_SIZE(nt_header.OptionalHeader.SizeOfImage, page_size), "got %Ix != expected %lx\n",
                        info.RegionSize, ALIGN_SIZE(nt_header.OptionalHeader.SizeOfImage, page_size));
-                    ok(info.Protect == PAGE_EXECUTE_WRITECOPY, "%x != PAGE_EXECUTE_WRITECOPY\n", info.Protect);
+                    ok(info.Protect == PAGE_EXECUTE_WRITECOPY, "%lx != PAGE_EXECUTE_WRITECOPY\n", info.Protect);
                 }
                 else
                 {
                     ok(info.BaseAddress == (char *)hlib + section.VirtualAddress, "got %p != expected %p\n", info.BaseAddress, (char *)hlib + section.VirtualAddress);
-                    ok(info.RegionSize == ALIGN_SIZE(section.Misc.VirtualSize, page_size), "got %lx != expected %x\n",
+                    ok(info.RegionSize == ALIGN_SIZE(section.Misc.VirtualSize, page_size), "got %Ix != expected %lx\n",
                        info.RegionSize, ALIGN_SIZE(section.Misc.VirtualSize, page_size));
-                    ok(info.Protect == PAGE_READONLY, "%x != PAGE_READONLY\n", info.Protect);
+                    ok(info.Protect == PAGE_READONLY, "%lx != PAGE_READONLY\n", info.Protect);
                 }
                 ok(info.AllocationBase == hlib, "%p != %p\n", info.AllocationBase, hlib);
-                ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%x != PAGE_EXECUTE_WRITECOPY\n", info.AllocationProtect);
-                ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
-                ok(info.Type == SEC_IMAGE, "%x != SEC_IMAGE\n", info.Type);
+                ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%lx != PAGE_EXECUTE_WRITECOPY\n", info.AllocationProtect);
+                ok(info.State == MEM_COMMIT, "%lx != MEM_COMMIT\n", info.State);
+                ok(info.Type == SEC_IMAGE, "%lx != SEC_IMAGE\n", info.Type);
 
                 if (nt_header.OptionalHeader.SectionAlignment >= page_size)
                     ok(!memcmp((const char *)hlib + section.VirtualAddress + section.PointerToRawData, &nt_header, section.SizeOfRawData), "wrong section data\n");
@@ -1025,32 +1025,32 @@ static void test_Loader(void)
                 ptr = VirtualAlloc((char *)hlib + section.VirtualAddress, page_size, MEM_COMMIT, info.Protect);
                 ok(!ptr, "VirtualAlloc should fail\n");
                 ok(GetLastError() == ERROR_ACCESS_DENIED || GetLastError() == ERROR_INVALID_ADDRESS,
-                   "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+                   "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
             }
 
             SetLastError(0xdeadbeef);
             hlib_as_data_file = LoadLibraryExA(dll_name, 0, LOAD_LIBRARY_AS_DATAFILE);
-            ok(hlib_as_data_file != 0, "LoadLibraryEx error %u\n", GetLastError());
+            ok(hlib_as_data_file != 0, "LoadLibraryEx error %lu\n", GetLastError());
             ok(hlib_as_data_file == hlib, "hlib_as_file and hlib are different\n");
 
             SetLastError(0xdeadbeef);
             ret = FreeLibrary(hlib);
-            ok(ret, "FreeLibrary error %d\n", GetLastError());
+            ok(ret, "FreeLibrary error %ld\n", GetLastError());
 
             SetLastError(0xdeadbeef);
             hlib = GetModuleHandleA(dll_name);
-            ok(hlib != 0, "GetModuleHandle error %u\n", GetLastError());
+            ok(hlib != 0, "GetModuleHandle error %lu\n", GetLastError());
 
             SetLastError(0xdeadbeef);
             ret = FreeLibrary(hlib_as_data_file);
-            ok(ret, "FreeLibrary error %d\n", GetLastError());
+            ok(ret, "FreeLibrary error %ld\n", GetLastError());
 
             hlib = GetModuleHandleA(dll_name);
             ok(!hlib, "GetModuleHandle should fail\n");
 
             SetLastError(0xdeadbeef);
             hlib_as_data_file = LoadLibraryExA(dll_name, 0, LOAD_LIBRARY_AS_DATAFILE);
-            ok(hlib_as_data_file != 0, "LoadLibraryEx error %u\n", GetLastError());
+            ok(hlib_as_data_file != 0, "LoadLibraryEx error %lu\n", GetLastError());
             ok(((ULONG_PTR)hlib_as_data_file & 3) == 1, "hlib_as_data_file got %p\n", hlib_as_data_file);
 
             hlib = GetModuleHandleA(dll_name);
@@ -1058,12 +1058,12 @@ static void test_Loader(void)
 
             SetLastError(0xdeadbeef);
             h = CreateFileA( dll_name, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
-            ok( h != INVALID_HANDLE_VALUE, "open failed err %u\n", GetLastError() );
+            ok( h != INVALID_HANDLE_VALUE, "open failed err %lu\n", GetLastError() );
             CloseHandle( h );
 
             SetLastError(0xdeadbeef);
             ret = FreeLibrary(hlib_as_data_file);
-            ok(ret, "FreeLibrary error %d\n", GetLastError());
+            ok(ret, "FreeLibrary error %ld\n", GetLastError());
 
             SetLastError(0xdeadbeef);
             hlib_as_data_file = LoadLibraryExA(dll_name, 0, LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE);
@@ -1075,22 +1075,22 @@ static void test_Loader(void)
             }
             else
             {
-                ok(hlib_as_data_file != 0, "LoadLibraryEx error %u\n", GetLastError());
+                ok(hlib_as_data_file != 0, "LoadLibraryEx error %lu\n", GetLastError());
 
                 SetLastError(0xdeadbeef);
                 h = CreateFileA( dll_name, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
                 ok( h == INVALID_HANDLE_VALUE, "open succeeded\n" );
-                ok( GetLastError() == ERROR_SHARING_VIOLATION, "wrong error %u\n", GetLastError() );
+                ok( GetLastError() == ERROR_SHARING_VIOLATION, "wrong error %lu\n", GetLastError() );
                 CloseHandle( h );
 
                 SetLastError(0xdeadbeef);
                 h = CreateFileA( dll_name, GENERIC_READ | DELETE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
-                ok( h != INVALID_HANDLE_VALUE, "open failed err %u\n", GetLastError() );
+                ok( h != INVALID_HANDLE_VALUE, "open failed err %lu\n", GetLastError() );
                 CloseHandle( h );
 
                 SetLastError(0xdeadbeef);
                 ret = FreeLibrary(hlib_as_data_file);
-                ok(ret, "FreeLibrary error %d\n", GetLastError());
+                ok(ret, "FreeLibrary error %ld\n", GetLastError());
             }
 
             SetLastError(0xdeadbeef);
@@ -1103,7 +1103,7 @@ static void test_Loader(void)
             }
             else
             {
-                ok(hlib_as_data_file != 0, "LoadLibraryEx error %u\n", GetLastError());
+                ok(hlib_as_data_file != 0, "LoadLibraryEx error %lu\n", GetLastError());
                 ok(((ULONG_PTR)hlib_as_data_file & 3) == 2, "hlib_as_data_file got %p\n",
                    hlib_as_data_file);
 
@@ -1112,12 +1112,12 @@ static void test_Loader(void)
 
                 SetLastError(0xdeadbeef);
                 ret = FreeLibrary(hlib_as_data_file);
-                ok(ret, "FreeLibrary error %d\n", GetLastError());
+                ok(ret, "FreeLibrary error %ld\n", GetLastError());
             }
 
             SetLastError(0xdeadbeef);
             ret = DeleteFileA(dll_name);
-            ok(ret, "DeleteFile error %d\n", GetLastError());
+            ok(ret, "DeleteFile error %ld\n", GetLastError());
 
             nt_header.OptionalHeader.AddressOfEntryPoint = 0x12345678;
             file_size = create_test_dll( &dos_header, td[i].size_of_dos_header, &nt_header, dll_name );
@@ -1142,12 +1142,12 @@ static void test_Loader(void)
             {
                 error_match = td[i].errors[error_index] == GetLastError();
             }
-            ok(error_match, "unexpected error %d\n", GetLastError());
+            ok(error_match, "unexpected error %ld\n", GetLastError());
         }
 
         SetLastError(0xdeadbeef);
         ret = DeleteFileA(dll_name);
-        ok(ret, "DeleteFile error %d\n", GetLastError());
+        ok(ret, "DeleteFile error %ld\n", GetLastError());
         winetest_pop_context();
     }
 
@@ -1171,26 +1171,26 @@ static void test_Loader(void)
 
     nt_header.OptionalHeader.AddressOfEntryPoint = 0x1234;
     status = map_image_section( &nt_header, &section, section_data, __LINE__ );
-    ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+    ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
     nt_header.OptionalHeader.DllCharacteristics = IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE;
     status = map_image_section( &nt_header, &section, section_data, __LINE__ );
-    ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+    ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
     nt_header.OptionalHeader.SizeOfCode = 0x1000;
     status = map_image_section( &nt_header, &section, section_data, __LINE__ );
-    ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+    ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
     nt_header.OptionalHeader.SizeOfCode = 0;
     nt_header.OptionalHeader.DllCharacteristics = IMAGE_DLLCHARACTERISTICS_NX_COMPAT;
 
     dos_header.e_magic = 0;
     status = map_image_section( &nt_header, &section, section_data, __LINE__ );
-    ok( status == STATUS_INVALID_IMAGE_NOT_MZ, "NtCreateSection error %08x\n", status );
+    ok( status == STATUS_INVALID_IMAGE_NOT_MZ, "NtCreateSection error %08lx\n", status );
 
     dos_header.e_magic = IMAGE_DOS_SIGNATURE;
     nt_header.Signature = IMAGE_OS2_SIGNATURE;
     status = map_image_section( &nt_header, &section, section_data, __LINE__ );
-    ok( status == STATUS_INVALID_IMAGE_NE_FORMAT, "NtCreateSection error %08x\n", status );
+    ok( status == STATUS_INVALID_IMAGE_NE_FORMAT, "NtCreateSection error %08lx\n", status );
     for (i = 0; i < 16; i++)
     {
         ((IMAGE_OS2_HEADER *)&nt_header)->ne_exetyp = i;
@@ -1198,13 +1198,13 @@ static void test_Loader(void)
         switch (i)
         {
         case 2:
-            ok( status == STATUS_INVALID_IMAGE_WIN_16, "NtCreateSection %u error %08x\n", i, status );
+            ok( status == STATUS_INVALID_IMAGE_WIN_16, "NtCreateSection %u error %08lx\n", i, status );
             break;
         case 5:
-            ok( status == STATUS_INVALID_IMAGE_PROTECT, "NtCreateSection %u error %08x\n", i, status );
+            ok( status == STATUS_INVALID_IMAGE_PROTECT, "NtCreateSection %u error %08lx\n", i, status );
             break;
         default:
-            ok( status == STATUS_INVALID_IMAGE_NE_FORMAT, "NtCreateSection %u error %08x\n", i, status );
+            ok( status == STATUS_INVALID_IMAGE_NE_FORMAT, "NtCreateSection %u error %08lx\n", i, status );
             break;
         }
     }
@@ -1212,38 +1212,38 @@ static void test_Loader(void)
 
     dos_header.e_lfanew = 0x98760000;
     status = map_image_section( &nt_header, &section, section_data, __LINE__ );
-    ok( status == STATUS_INVALID_IMAGE_PROTECT, "NtCreateSection error %08x\n", status );
+    ok( status == STATUS_INVALID_IMAGE_PROTECT, "NtCreateSection error %08lx\n", status );
 
     dos_header.e_lfanew = sizeof(dos_header);
     nt_header.Signature = 0xdeadbeef;
     status = map_image_section( &nt_header, &section, section_data, __LINE__ );
-    ok( status == STATUS_INVALID_IMAGE_PROTECT, "NtCreateSection error %08x\n", status );
+    ok( status == STATUS_INVALID_IMAGE_PROTECT, "NtCreateSection error %08lx\n", status );
 
     nt_header.Signature = IMAGE_NT_SIGNATURE;
     nt_header.OptionalHeader.Magic = 0xdead;
     status = map_image_section( &nt_header, &section, section_data, __LINE__ );
-    ok( status == STATUS_INVALID_IMAGE_FORMAT, "NtCreateSection error %08x\n", status );
+    ok( status == STATUS_INVALID_IMAGE_FORMAT, "NtCreateSection error %08lx\n", status );
 
     nt_header.OptionalHeader.Magic = IMAGE_NT_OPTIONAL_HDR_MAGIC;
     nt_header.FileHeader.Machine = 0xdead;
     status = map_image_section( &nt_header, &section, section_data, __LINE__ );
     ok( status == STATUS_INVALID_IMAGE_FORMAT || broken(status == STATUS_SUCCESS), /* win2k */
-        "NtCreateSection error %08x\n", status );
+        "NtCreateSection error %08lx\n", status );
 
     nt_header.FileHeader.Machine = IMAGE_FILE_MACHINE_UNKNOWN;
     status = map_image_section( &nt_header, &section, section_data, __LINE__ );
     ok( status == STATUS_INVALID_IMAGE_FORMAT || broken(status == STATUS_SUCCESS), /* win2k */
-        "NtCreateSection error %08x\n", status );
+        "NtCreateSection error %08lx\n", status );
 
     nt_header.FileHeader.Machine = get_alt_machine( orig_machine );
     status = map_image_section( &nt_header, &section, section_data, __LINE__ );
     ok( status == STATUS_INVALID_IMAGE_FORMAT || broken(status == STATUS_SUCCESS), /* win2k */
-        "NtCreateSection error %08x\n", status );
+        "NtCreateSection error %08lx\n", status );
 
     nt_header.FileHeader.Machine = get_alt_bitness_machine( orig_machine );
     status = map_image_section( &nt_header, &section, section_data, __LINE__ );
     ok( status == STATUS_INVALID_IMAGE_FORMAT || broken(status == STATUS_SUCCESS), /* win2k */
-                  "NtCreateSection error %08x\n", status );
+                  "NtCreateSection error %08lx\n", status );
 
     nt_header.FileHeader.Machine = orig_machine;
     nt_header.OptionalHeader.NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES;
@@ -1258,33 +1258,33 @@ static void test_Loader(void)
     cor_header.Flags = COMIMAGE_FLAGS_ILONLY;
     U(cor_header).EntryPointToken = 0xbeef;
     status = map_image_section( &nt_header, &section, &cor_header, __LINE__ );
-    ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+    ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
     cor_header.MinorRuntimeVersion = 5;
     status = map_image_section( &nt_header, &section, &cor_header, __LINE__ );
-    ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+    ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
     cor_header.MajorRuntimeVersion = 3;
     cor_header.MinorRuntimeVersion = 0;
     status = map_image_section( &nt_header, &section, &cor_header, __LINE__ );
-    ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+    ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
     cor_header.Flags = COMIMAGE_FLAGS_ILONLY | COMIMAGE_FLAGS_32BITREQUIRED;
     status = map_image_section( &nt_header, &section, &cor_header, __LINE__ );
-    ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+    ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
     cor_header.Flags = COMIMAGE_FLAGS_ILONLY | COMIMAGE_FLAGS_32BITPREFERRED;
     status = map_image_section( &nt_header, &section, &cor_header, __LINE__ );
-    ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+    ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
     cor_header.Flags = 0;
     status = map_image_section( &nt_header, &section, &cor_header, __LINE__ );
-    ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+    ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
     nt_header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress = 1;
     nt_header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size = 1;
     status = map_image_section( &nt_header, &section, &cor_header, __LINE__ );
-    ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+    ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
     if (nt_header.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
     {
@@ -1315,7 +1315,7 @@ static void test_Loader(void)
 
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, section_data, __LINE__ );
         ok( status == (is_wow64 ? STATUS_INVALID_IMAGE_FORMAT : STATUS_INVALID_IMAGE_WIN_64),
-            "NtCreateSection error %08x\n", status );
+            "NtCreateSection error %08lx\n", status );
 
         switch (orig_machine)
         {
@@ -1324,26 +1324,26 @@ static void test_Loader(void)
         }
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, section_data, __LINE__ );
         ok( status == (is_wow64 ? STATUS_INVALID_IMAGE_FORMAT : STATUS_INVALID_IMAGE_WIN_64),
-            "NtCreateSection error %08x\n", status );
+            "NtCreateSection error %08lx\n", status );
 
         nt64.FileHeader.Machine = get_alt_bitness_machine( orig_machine );
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, section_data, __LINE__ );
         ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64),
-            "NtCreateSection error %08x\n", status );
+            "NtCreateSection error %08lx\n", status );
 
         nt64.OptionalHeader.SizeOfCode = 0;
         nt64.OptionalHeader.AddressOfEntryPoint = 0x1000;
         section.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, section_data, __LINE__ );
         ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64),
-            "NtCreateSection error %08x\n", status );
+            "NtCreateSection error %08lx\n", status );
 
         nt64.OptionalHeader.SizeOfCode = 0;
         nt64.OptionalHeader.AddressOfEntryPoint = 0;
         section.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, section_data, __LINE__ );
         ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64),
-            "NtCreateSection error %08x\n", status );
+            "NtCreateSection error %08lx\n", status );
 
         nt64.OptionalHeader.SizeOfCode = 0x1000;
         nt64.OptionalHeader.AddressOfEntryPoint = 0;
@@ -1351,14 +1351,14 @@ static void test_Loader(void)
         section.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, section_data, __LINE__ );
         ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64),
-            "NtCreateSection error %08x\n", status );
+            "NtCreateSection error %08lx\n", status );
 
         nt64.OptionalHeader.SizeOfCode = 0;
         nt64.OptionalHeader.AddressOfEntryPoint = 0;
         section.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, section_data, __LINE__ );
         ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64),
-            "NtCreateSection error %08x\n", status );
+            "NtCreateSection error %08lx\n", status );
 
         nt64.OptionalHeader.NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES;
         nt64.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress = page_size;
@@ -1368,38 +1368,38 @@ static void test_Loader(void)
         cor_header.Flags = COMIMAGE_FLAGS_ILONLY;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, &cor_header, __LINE__ );
         ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64),
-            "NtCreateSection error %08x\n", status );
+            "NtCreateSection error %08lx\n", status );
 
         nt64.OptionalHeader.SizeOfCode = 0x1000;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, &cor_header, __LINE__ );
         ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64),
-            "NtCreateSection error %08x\n", status );
+            "NtCreateSection error %08lx\n", status );
 
         cor_header.MinorRuntimeVersion = 5;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, &cor_header, __LINE__ );
         ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64),
-            "NtCreateSection error %08x\n", status );
+            "NtCreateSection error %08lx\n", status );
 
         cor_header.Flags = COMIMAGE_FLAGS_ILONLY | COMIMAGE_FLAGS_32BITREQUIRED;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, &cor_header, __LINE__ );
         ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64),
-            "NtCreateSection error %08x\n", status );
+            "NtCreateSection error %08lx\n", status );
 
         cor_header.Flags = COMIMAGE_FLAGS_ILONLY | COMIMAGE_FLAGS_32BITPREFERRED;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, &cor_header, __LINE__ );
         ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64),
-            "NtCreateSection error %08x\n", status );
+            "NtCreateSection error %08lx\n", status );
 
         cor_header.Flags = 0;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, &cor_header, __LINE__ );
         ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64),
-            "NtCreateSection error %08x\n", status );
+            "NtCreateSection error %08lx\n", status );
 
         nt_header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress = 1;
         nt_header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size = 1;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt64, &section, &cor_header, __LINE__ );
         ok( status == (is_wow64 ? STATUS_SUCCESS : STATUS_INVALID_IMAGE_WIN_64),
-            "NtCreateSection error %08x\n", status );
+            "NtCreateSection error %08lx\n", status );
     }
     else
     {
@@ -1429,7 +1429,7 @@ static void test_Loader(void)
         section.Characteristics = IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_EXECUTE;
 
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, section_data, __LINE__ );
-        ok( status == STATUS_INVALID_IMAGE_FORMAT, "NtCreateSection error %08x\n", status );
+        ok( status == STATUS_INVALID_IMAGE_FORMAT, "NtCreateSection error %08lx\n", status );
 
         switch (orig_machine)
         {
@@ -1438,36 +1438,36 @@ static void test_Loader(void)
         }
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, section_data, __LINE__ );
         ok( status == STATUS_INVALID_IMAGE_FORMAT || broken(!status) /* win8 */,
-            "NtCreateSection error %08x\n", status );
+            "NtCreateSection error %08lx\n", status );
 
         nt32.FileHeader.Machine = get_alt_bitness_machine( orig_machine );
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, section_data, __LINE__ );
-        ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+        ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
         nt32.OptionalHeader.SizeOfCode = 0;
         nt32.OptionalHeader.AddressOfEntryPoint = 0x1000;
         section.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, section_data, __LINE__ );
-        ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+        ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
         nt32.OptionalHeader.SizeOfCode = 0;
         nt32.OptionalHeader.AddressOfEntryPoint = 0;
         section.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, section_data, __LINE__ );
-        ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+        ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
         nt32.OptionalHeader.SizeOfCode = 0x1000;
         nt32.OptionalHeader.AddressOfEntryPoint = 0;
         nt32.OptionalHeader.DllCharacteristics = IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE;
         section.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, section_data, __LINE__ );
-        ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+        ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
         nt32.OptionalHeader.SizeOfCode = 0;
         nt32.OptionalHeader.AddressOfEntryPoint = 0;
         section.Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, section_data, __LINE__ );
-        ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+        ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
         nt32.OptionalHeader.NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES;
         nt32.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress = page_size;
@@ -1476,32 +1476,32 @@ static void test_Loader(void)
         cor_header.MinorRuntimeVersion = 4;
         cor_header.Flags = COMIMAGE_FLAGS_ILONLY;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, &cor_header, __LINE__ );
-        ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+        ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
         nt32.OptionalHeader.SizeOfCode = 0x1000;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, &cor_header, __LINE__ );
-        ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+        ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
         cor_header.MinorRuntimeVersion = 5;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, &cor_header, __LINE__ );
-        ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+        ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
         cor_header.Flags = COMIMAGE_FLAGS_ILONLY | COMIMAGE_FLAGS_32BITREQUIRED;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, &cor_header, __LINE__ );
-        ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+        ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
         cor_header.Flags = COMIMAGE_FLAGS_ILONLY | COMIMAGE_FLAGS_32BITPREFERRED;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, &cor_header, __LINE__ );
-        ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+        ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
         cor_header.Flags = 0;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, &cor_header, __LINE__ );
-        ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+        ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
 
         nt_header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress = 1;
         nt_header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size = 1;
         status = map_image_section( (IMAGE_NT_HEADERS *)&nt32, &section, &cor_header, __LINE__ );
-        ok( status == STATUS_SUCCESS, "NtCreateSection error %08x\n", status );
+        ok( status == STATUS_SUCCESS, "NtCreateSection error %08lx\n", status );
     }
 
     section.Characteristics = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ;
@@ -1528,11 +1528,11 @@ static void test_filenames(void)
     strcpy( long_path, dll_name );
     strcpy( strrchr( long_path, '\\' ), "\\this-is-a-long-name.dll" );
     ret = MoveFileA( dll_name, long_path );
-    ok( ret, "MoveFileA failed err %u\n", GetLastError() );
+    ok( ret, "MoveFileA failed err %lu\n", GetLastError() );
     GetShortPathNameA( long_path, short_path, MAX_PATH );
 
     mod = LoadLibraryA( short_path );
-    ok( mod != NULL, "loading failed err %u\n", GetLastError() );
+    ok( mod != NULL, "loading failed err %lu\n", GetLastError() );
     GetModuleFileNameA( mod, buffer, MAX_PATH );
     ok( !lstrcmpiA( buffer, short_path ), "got wrong path %s / %s\n", buffer, short_path );
     mod2 = GetModuleHandleA( short_path );
@@ -1540,7 +1540,7 @@ static void test_filenames(void)
     mod2 = GetModuleHandleA( long_path );
     ok( mod == mod2, "wrong module %p for %s\n", mod2, long_path );
     mod2 = LoadLibraryA( long_path );
-    ok( mod2 != NULL, "loading failed err %u\n", GetLastError() );
+    ok( mod2 != NULL, "loading failed err %lu\n", GetLastError() );
     ok( mod == mod2, "library loaded twice\n" );
     GetModuleFileNameA( mod2, buffer, MAX_PATH );
     ok( !lstrcmpiA( buffer, short_path ), "got wrong path %s / %s\n", buffer, short_path );
@@ -1548,7 +1548,7 @@ static void test_filenames(void)
     FreeLibrary( mod );
 
     mod = LoadLibraryA( long_path );
-    ok( mod != NULL, "loading failed err %u\n", GetLastError() );
+    ok( mod != NULL, "loading failed err %lu\n", GetLastError() );
     GetModuleFileNameA( mod, buffer, MAX_PATH );
     ok( !lstrcmpiA( buffer, long_path ), "got wrong path %s / %s\n", buffer, long_path );
     mod2 = GetModuleHandleA( short_path );
@@ -1556,7 +1556,7 @@ static void test_filenames(void)
     mod2 = GetModuleHandleA( long_path );
     ok( mod == mod2, "wrong module %p for %s\n", mod2, long_path );
     mod2 = LoadLibraryA( short_path );
-    ok( mod2 != NULL, "loading failed err %u\n", GetLastError() );
+    ok( mod2 != NULL, "loading failed err %lu\n", GetLastError() );
     ok( mod == mod2, "library loaded twice\n" );
     GetModuleFileNameA( mod2, buffer, MAX_PATH );
     ok( !lstrcmpiA( buffer, long_path ), "got wrong path %s / %s\n", buffer, long_path );
@@ -1566,17 +1566,17 @@ static void test_filenames(void)
     strcpy( dll_name, long_path );
     strcpy( strrchr( dll_name, '\\' ), "\\this-is-another-name.dll" );
     ret = CreateHardLinkA( dll_name, long_path, NULL );
-    ok( ret, "CreateHardLinkA failed err %u\n", GetLastError() );
+    ok( ret, "CreateHardLinkA failed err %lu\n", GetLastError() );
     if (ret)
     {
         mod = LoadLibraryA( dll_name );
-        ok( mod != NULL, "loading failed err %u\n", GetLastError() );
+        ok( mod != NULL, "loading failed err %lu\n", GetLastError() );
         GetModuleFileNameA( mod, buffer, MAX_PATH );
         ok( !lstrcmpiA( buffer, dll_name ), "got wrong path %s / %s\n", buffer, dll_name );
         mod2 = GetModuleHandleA( long_path );
         ok( mod == mod2, "wrong module %p for %s\n", mod2, long_path );
         mod2 = LoadLibraryA( long_path );
-        ok( mod2 != NULL, "loading failed err %u\n", GetLastError() );
+        ok( mod2 != NULL, "loading failed err %lu\n", GetLastError() );
         ok( mod == mod2, "library loaded twice\n" );
         GetModuleFileNameA( mod2, buffer, MAX_PATH );
         ok( !lstrcmpiA( buffer, dll_name ), "got wrong path %s / %s\n", buffer, short_path );
@@ -1655,11 +1655,11 @@ static void test_image_mapping(const char *dll_name, DWORD scn_page_access, BOOL
 
     SetLastError(0xdeadbeef);
     hfile = CreateFileA(dll_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     hmap = CreateFileMappingW(hfile, NULL, PAGE_READONLY | SEC_IMAGE, 0, 0, 0);
-    ok(hmap != 0, "CreateFileMapping error %d\n", GetLastError());
+    ok(hmap != 0, "CreateFileMapping error %ld\n", GetLastError());
 
     offset.u.LowPart  = 0;
     offset.u.HighPart = 0;
@@ -1668,41 +1668,41 @@ static void test_image_mapping(const char *dll_name, DWORD scn_page_access, BOOL
     size = 0;
     status = pNtMapViewOfSection(hmap, GetCurrentProcess(), &addr1, 0, 0, &offset,
                                  &size, 1 /* ViewShare */, 0, PAGE_READONLY);
-    ok(status == STATUS_SUCCESS, "NtMapViewOfSection error %x\n", status);
+    ok(status == STATUS_SUCCESS, "NtMapViewOfSection error %lx\n", status);
     ok(addr1 != 0, "mapped address should be valid\n");
 
     SetLastError(0xdeadbeef);
     size = VirtualQuery((char *)addr1 + section.VirtualAddress, &info, sizeof(info));
-    ok(size == sizeof(info), "VirtualQuery error %d\n", GetLastError());
+    ok(size == sizeof(info), "VirtualQuery error %ld\n", GetLastError());
     ok(info.BaseAddress == (char *)addr1 + section.VirtualAddress, "got %p != expected %p\n", info.BaseAddress, (char *)addr1 + section.VirtualAddress);
-    ok(info.RegionSize == page_size, "got %#lx != expected %#x\n", info.RegionSize, page_size);
-    ok(info.Protect == scn_page_access, "got %#x != expected %#x\n", info.Protect, scn_page_access);
+    ok(info.RegionSize == page_size, "got %#Ix != expected %#lx\n", info.RegionSize, page_size);
+    ok(info.Protect == scn_page_access, "got %#lx != expected %#lx\n", info.Protect, scn_page_access);
     ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
-    ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%#x != PAGE_EXECUTE_WRITECOPY\n", info.AllocationProtect);
-    ok(info.State == MEM_COMMIT, "%#x != MEM_COMMIT\n", info.State);
-    ok(info.Type == SEC_IMAGE, "%#x != SEC_IMAGE\n", info.Type);
+    ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%#lx != PAGE_EXECUTE_WRITECOPY\n", info.AllocationProtect);
+    ok(info.State == MEM_COMMIT, "%#lx != MEM_COMMIT\n", info.State);
+    ok(info.Type == SEC_IMAGE, "%#lx != SEC_IMAGE\n", info.Type);
 
     addr2 = NULL;
     size = 0;
     status = pNtMapViewOfSection(hmap, GetCurrentProcess(), &addr2, 0, 0, &offset,
                                  &size, 1 /* ViewShare */, 0, PAGE_READONLY);
-    ok(status == STATUS_IMAGE_NOT_AT_BASE, "expected STATUS_IMAGE_NOT_AT_BASE, got %x\n", status);
+    ok(status == STATUS_IMAGE_NOT_AT_BASE, "expected STATUS_IMAGE_NOT_AT_BASE, got %lx\n", status);
     ok(addr2 != 0, "mapped address should be valid\n");
     ok(addr2 != addr1, "mapped addresses should be different\n");
 
     SetLastError(0xdeadbeef);
     size = VirtualQuery((char *)addr2 + section.VirtualAddress, &info, sizeof(info));
-    ok(size == sizeof(info), "VirtualQuery error %d\n", GetLastError());
+    ok(size == sizeof(info), "VirtualQuery error %ld\n", GetLastError());
     ok(info.BaseAddress == (char *)addr2 + section.VirtualAddress, "got %p != expected %p\n", info.BaseAddress, (char *)addr2 + section.VirtualAddress);
-    ok(info.RegionSize == page_size, "got %#lx != expected %#x\n", info.RegionSize, page_size);
-    ok(info.Protect == scn_page_access, "got %#x != expected %#x\n", info.Protect, scn_page_access);
+    ok(info.RegionSize == page_size, "got %#Ix != expected %#lx\n", info.RegionSize, page_size);
+    ok(info.Protect == scn_page_access, "got %#lx != expected %#lx\n", info.Protect, scn_page_access);
     ok(info.AllocationBase == addr2, "%p != %p\n", info.AllocationBase, addr2);
-    ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%#x != PAGE_EXECUTE_WRITECOPY\n", info.AllocationProtect);
-    ok(info.State == MEM_COMMIT, "%#x != MEM_COMMIT\n", info.State);
-    ok(info.Type == SEC_IMAGE, "%#x != SEC_IMAGE\n", info.Type);
+    ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%#lx != PAGE_EXECUTE_WRITECOPY\n", info.AllocationProtect);
+    ok(info.State == MEM_COMMIT, "%#lx != MEM_COMMIT\n", info.State);
+    ok(info.Type == SEC_IMAGE, "%#lx != SEC_IMAGE\n", info.Type);
 
     status = pNtUnmapViewOfSection(GetCurrentProcess(), addr2);
-    ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection error %x\n", status);
+    ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection error %lx\n", status);
 
     addr2 = MapViewOfFile(hmap, 0, 0, 0, 0);
     ok(addr2 != 0, "mapped address should be valid\n");
@@ -1710,14 +1710,14 @@ static void test_image_mapping(const char *dll_name, DWORD scn_page_access, BOOL
 
     SetLastError(0xdeadbeef);
     size = VirtualQuery((char *)addr2 + section.VirtualAddress, &info, sizeof(info));
-    ok(size == sizeof(info), "VirtualQuery error %d\n", GetLastError());
+    ok(size == sizeof(info), "VirtualQuery error %ld\n", GetLastError());
     ok(info.BaseAddress == (char *)addr2 + section.VirtualAddress, "got %p != expected %p\n", info.BaseAddress, (char *)addr2 + section.VirtualAddress);
-    ok(info.RegionSize == page_size, "got %#lx != expected %#x\n", info.RegionSize, page_size);
-    ok(info.Protect == scn_page_access, "got %#x != expected %#x\n", info.Protect, scn_page_access);
+    ok(info.RegionSize == page_size, "got %#Ix != expected %#lx\n", info.RegionSize, page_size);
+    ok(info.Protect == scn_page_access, "got %#lx != expected %#lx\n", info.Protect, scn_page_access);
     ok(info.AllocationBase == addr2, "%p != %p\n", info.AllocationBase, addr2);
-    ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%#x != PAGE_EXECUTE_WRITECOPY\n", info.AllocationProtect);
-    ok(info.State == MEM_COMMIT, "%#x != MEM_COMMIT\n", info.State);
-    ok(info.Type == SEC_IMAGE, "%#x != SEC_IMAGE\n", info.Type);
+    ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%#lx != PAGE_EXECUTE_WRITECOPY\n", info.AllocationProtect);
+    ok(info.State == MEM_COMMIT, "%#lx != MEM_COMMIT\n", info.State);
+    ok(info.Type == SEC_IMAGE, "%#lx != SEC_IMAGE\n", info.Type);
 
     UnmapViewOfFile(addr2);
 
@@ -1726,21 +1726,21 @@ static void test_image_mapping(const char *dll_name, DWORD scn_page_access, BOOL
     if (is_dll)
     {
         ok(!addr2, "LoadLibrary should fail, is_dll %d\n", is_dll);
-        ok(GetLastError() == ERROR_INVALID_ADDRESS, "expected ERROR_INVALID_ADDRESS, got %d\n", GetLastError());
+        ok(GetLastError() == ERROR_INVALID_ADDRESS, "expected ERROR_INVALID_ADDRESS, got %ld\n", GetLastError());
     }
     else
     {
         BOOL ret;
-        ok(addr2 != 0, "LoadLibrary error %d, is_dll %d\n", GetLastError(), is_dll);
+        ok(addr2 != 0, "LoadLibrary error %ld, is_dll %d\n", GetLastError(), is_dll);
         ok(addr2 != addr1, "mapped addresses should be different\n");
 
         SetLastError(0xdeadbeef);
         ret = FreeLibrary(addr2);
-        ok(ret, "FreeLibrary error %d\n", GetLastError());
+        ok(ret, "FreeLibrary error %ld\n", GetLastError());
     }
 
     status = pNtUnmapViewOfSection(GetCurrentProcess(), addr1);
-    ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection error %x\n", status);
+    ok(status == STATUS_SUCCESS, "NtUnmapViewOfSection error %lx\n", status);
 
     CloseHandle(hmap);
     CloseHandle(hfile);
@@ -1806,7 +1806,7 @@ static void test_VirtualProtect(void *base, void *section)
 
     SetLastError(0xdeadbeef);
     ret = VirtualProtect(section, page_size, PAGE_NOACCESS, &old_prot);
-    ok(ret, "VirtualProtect error %d\n", GetLastError());
+    ok(ret, "VirtualProtect error %ld\n", GetLastError());
 
     orig_prot = old_prot;
 
@@ -1814,48 +1814,48 @@ static void test_VirtualProtect(void *base, void *section)
     {
         SetLastError(0xdeadbeef);
         ret = VirtualQuery(section, &info, sizeof(info));
-        ok(ret, "VirtualQuery failed %d\n", GetLastError());
-        ok(info.BaseAddress == section, "%d: got %p != expected %p\n", i, info.BaseAddress, section);
-        ok(info.RegionSize == page_size, "%d: got %#lx != expected %#x\n", i, info.RegionSize, page_size);
-        ok(info.Protect == PAGE_NOACCESS, "%d: got %#x != expected PAGE_NOACCESS\n", i, info.Protect);
-        ok(info.AllocationBase == base, "%d: %p != %p\n", i, info.AllocationBase, base);
-        ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%d: %#x != PAGE_EXECUTE_WRITECOPY\n", i, info.AllocationProtect);
-        ok(info.State == MEM_COMMIT, "%d: %#x != MEM_COMMIT\n", i, info.State);
-        ok(info.Type == SEC_IMAGE, "%d: %#x != SEC_IMAGE\n", i, info.Type);
+        ok(ret, "VirtualQuery failed %ld\n", GetLastError());
+        ok(info.BaseAddress == section, "%ld: got %p != expected %p\n", i, info.BaseAddress, section);
+        ok(info.RegionSize == page_size, "%ld: got %#Ix != expected %#lx\n", i, info.RegionSize, page_size);
+        ok(info.Protect == PAGE_NOACCESS, "%ld: got %#lx != expected PAGE_NOACCESS\n", i, info.Protect);
+        ok(info.AllocationBase == base, "%ld: %p != %p\n", i, info.AllocationBase, base);
+        ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%ld: %#lx != PAGE_EXECUTE_WRITECOPY\n", i, info.AllocationProtect);
+        ok(info.State == MEM_COMMIT, "%ld: %#lx != MEM_COMMIT\n", i, info.State);
+        ok(info.Type == SEC_IMAGE, "%ld: %#lx != SEC_IMAGE\n", i, info.Type);
 
         old_prot = 0xdeadbeef;
         SetLastError(0xdeadbeef);
         ret = VirtualProtect(section, page_size, td[i].prot_set, &old_prot);
         if (td[i].prot_get)
         {
-            ok(ret, "%d: VirtualProtect error %d, requested prot %#x\n", i, GetLastError(), td[i].prot_set);
-            ok(old_prot == PAGE_NOACCESS, "%d: got %#x != expected PAGE_NOACCESS\n", i, old_prot);
+            ok(ret, "%ld: VirtualProtect error %ld, requested prot %#lx\n", i, GetLastError(), td[i].prot_set);
+            ok(old_prot == PAGE_NOACCESS, "%ld: got %#lx != expected PAGE_NOACCESS\n", i, old_prot);
 
             SetLastError(0xdeadbeef);
             ret = VirtualQuery(section, &info, sizeof(info));
-            ok(ret, "VirtualQuery failed %d\n", GetLastError());
-            ok(info.BaseAddress == section, "%d: got %p != expected %p\n", i, info.BaseAddress, section);
-            ok(info.RegionSize == page_size, "%d: got %#lx != expected %#x\n", i, info.RegionSize, page_size);
-            ok(info.Protect == td[i].prot_get, "%d: got %#x != expected %#x\n", i, info.Protect, td[i].prot_get);
-            ok(info.AllocationBase == base, "%d: %p != %p\n", i, info.AllocationBase, base);
-            ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%d: %#x != PAGE_EXECUTE_WRITECOPY\n", i, info.AllocationProtect);
-            ok(info.State == MEM_COMMIT, "%d: %#x != MEM_COMMIT\n", i, info.State);
-            ok(info.Type == SEC_IMAGE, "%d: %#x != SEC_IMAGE\n", i, info.Type);
+            ok(ret, "VirtualQuery failed %ld\n", GetLastError());
+            ok(info.BaseAddress == section, "%ld: got %p != expected %p\n", i, info.BaseAddress, section);
+            ok(info.RegionSize == page_size, "%ld: got %#Ix != expected %#lx\n", i, info.RegionSize, page_size);
+            ok(info.Protect == td[i].prot_get, "%ld: got %#lx != expected %#lx\n", i, info.Protect, td[i].prot_get);
+            ok(info.AllocationBase == base, "%ld: %p != %p\n", i, info.AllocationBase, base);
+            ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%ld: %#lx != PAGE_EXECUTE_WRITECOPY\n", i, info.AllocationProtect);
+            ok(info.State == MEM_COMMIT, "%ld: %#lx != MEM_COMMIT\n", i, info.State);
+            ok(info.Type == SEC_IMAGE, "%ld: %#lx != SEC_IMAGE\n", i, info.Type);
         }
         else
         {
-            ok(!ret, "%d: VirtualProtect should fail\n", i);
-            ok(GetLastError() == ERROR_INVALID_PARAMETER, "%d: expected ERROR_INVALID_PARAMETER, got %d\n", i, GetLastError());
+            ok(!ret, "%ld: VirtualProtect should fail\n", i);
+            ok(GetLastError() == ERROR_INVALID_PARAMETER, "%ld: expected ERROR_INVALID_PARAMETER, got %ld\n", i, GetLastError());
         }
 
         old_prot = 0xdeadbeef;
         SetLastError(0xdeadbeef);
         ret = VirtualProtect(section, page_size, PAGE_NOACCESS, &old_prot);
-        ok(ret, "%d: VirtualProtect error %d\n", i, GetLastError());
+        ok(ret, "%ld: VirtualProtect error %ld\n", i, GetLastError());
         if (td[i].prot_get)
-            ok(old_prot == td[i].prot_get, "%d: got %#x != expected %#x\n", i, old_prot, td[i].prot_get);
+            ok(old_prot == td[i].prot_get, "%ld: got %#lx != expected %#lx\n", i, old_prot, td[i].prot_get);
         else
-            ok(old_prot == PAGE_NOACCESS, "%d: got %#x != expected PAGE_NOACCESS\n", i, old_prot);
+            ok(old_prot == PAGE_NOACCESS, "%ld: got %#lx != expected PAGE_NOACCESS\n", i, old_prot);
     }
 
     exec_prot = 0;
@@ -1872,11 +1872,11 @@ static void test_VirtualProtect(void *base, void *section)
             ret = VirtualProtect(section, page_size, prot, &old_prot);
             if ((rw_prot && exec_prot) || (!rw_prot && !exec_prot))
             {
-                ok(!ret, "VirtualProtect(%02x) should fail\n", prot);
-                ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+                ok(!ret, "VirtualProtect(%02lx) should fail\n", prot);
+                ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
             }
             else
-                ok(ret, "VirtualProtect(%02x) error %d\n", prot, GetLastError());
+                ok(ret, "VirtualProtect(%02lx) error %ld\n", prot, GetLastError());
 
             rw_prot = 1 << j;
         }
@@ -1886,7 +1886,7 @@ static void test_VirtualProtect(void *base, void *section)
 
     SetLastError(0xdeadbeef);
     ret = VirtualProtect(section, page_size, orig_prot, &old_prot);
-    ok(ret, "VirtualProtect error %d\n", GetLastError());
+    ok(ret, "VirtualProtect error %ld\n", GetLastError());
 }
 
 static void test_section_access(void)
@@ -1959,7 +1959,7 @@ static void test_section_access(void)
 
         SetLastError(0xdeadbeef);
         ret = WriteFile(hfile, &dos_header, sizeof(dos_header), &dummy, NULL);
-        ok(ret, "WriteFile error %d\n", GetLastError());
+        ok(ret, "WriteFile error %ld\n", GetLastError());
 
         nt_header = nt_header_template;
         nt_header.FileHeader.NumberOfSections = 1;
@@ -1982,42 +1982,42 @@ static void test_section_access(void)
 
         SetLastError(0xdeadbeef);
         ret = WriteFile(hfile, &nt_header, sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER), &dummy, NULL);
-        ok(ret, "WriteFile error %d\n", GetLastError());
+        ok(ret, "WriteFile error %ld\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = WriteFile(hfile, &nt_header.OptionalHeader, sizeof(IMAGE_OPTIONAL_HEADER), &dummy, NULL);
-        ok(ret, "WriteFile error %d\n", GetLastError());
+        ok(ret, "WriteFile error %ld\n", GetLastError());
 
         ret = WriteFile(hfile, &section, sizeof(section), &dummy, NULL);
-        ok(ret, "WriteFile error %d\n", GetLastError());
+        ok(ret, "WriteFile error %ld\n", GetLastError());
 
         file_align = nt_header.OptionalHeader.FileAlignment - nt_header.OptionalHeader.SizeOfHeaders;
         assert(file_align < sizeof(filler));
         SetLastError(0xdeadbeef);
         ret = WriteFile(hfile, filler, file_align, &dummy, NULL);
-        ok(ret, "WriteFile error %d\n", GetLastError());
+        ok(ret, "WriteFile error %ld\n", GetLastError());
 
         /* section data */
         SetLastError(0xdeadbeef);
         ret = WriteFile(hfile, section_data, sizeof(section_data), &dummy, NULL);
-        ok(ret, "WriteFile error %d\n", GetLastError());
+        ok(ret, "WriteFile error %ld\n", GetLastError());
 
         CloseHandle(hfile);
 
         SetLastError(0xdeadbeef);
         hlib = LoadLibraryExA(dll_name, NULL, DONT_RESOLVE_DLL_REFERENCES);
-        ok(hlib != 0, "LoadLibrary error %d\n", GetLastError());
+        ok(hlib != 0, "LoadLibrary error %ld\n", GetLastError());
 
         SetLastError(0xdeadbeef);
         size = VirtualQuery((char *)hlib + section.VirtualAddress, &info, sizeof(info));
         ok(size == sizeof(info),
-            "%d: VirtualQuery error %d\n", i, GetLastError());
+            "%d: VirtualQuery error %ld\n", i, GetLastError());
         ok(info.BaseAddress == (char *)hlib + section.VirtualAddress, "%d: got %p != expected %p\n", i, info.BaseAddress, (char *)hlib + section.VirtualAddress);
-        ok(info.RegionSize == page_size, "%d: got %#lx != expected %#x\n", i, info.RegionSize, page_size);
-        ok(info.Protect == td[i].scn_page_access, "%d: got %#x != expected %#x\n", i, info.Protect, td[i].scn_page_access);
+        ok(info.RegionSize == page_size, "%d: got %#Ix != expected %#lx\n", i, info.RegionSize, page_size);
+        ok(info.Protect == td[i].scn_page_access, "%d: got %#lx != expected %#lx\n", i, info.Protect, td[i].scn_page_access);
         ok(info.AllocationBase == hlib, "%d: %p != %p\n", i, info.AllocationBase, hlib);
-        ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%d: %#x != PAGE_EXECUTE_WRITECOPY\n", i, info.AllocationProtect);
-        ok(info.State == MEM_COMMIT, "%d: %#x != MEM_COMMIT\n", i, info.State);
-        ok(info.Type == SEC_IMAGE, "%d: %#x != SEC_IMAGE\n", i, info.Type);
+        ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%d: %#lx != PAGE_EXECUTE_WRITECOPY\n", i, info.AllocationProtect);
+        ok(info.State == MEM_COMMIT, "%d: %#lx != MEM_COMMIT\n", i, info.State);
+        ok(info.Type == SEC_IMAGE, "%d: %#lx != SEC_IMAGE\n", i, info.Type);
         if (info.Protect != PAGE_NOACCESS)
             ok(!memcmp((const char *)info.BaseAddress, section_data, section.SizeOfRawData), "wrong section data\n");
 
@@ -2030,15 +2030,15 @@ static void test_section_access(void)
             *p = 0xfe;
             SetLastError(0xdeadbeef);
             size = VirtualQuery((char *)hlib + section.VirtualAddress, &info, sizeof(info));
-            ok(size == sizeof(info), "%d: VirtualQuery error %d\n", i, GetLastError());
+            ok(size == sizeof(info), "%d: VirtualQuery error %ld\n", i, GetLastError());
             /* FIXME: remove the condition below once Wine is fixed */
             todo_wine_if (info.Protect == PAGE_WRITECOPY || info.Protect == PAGE_EXECUTE_WRITECOPY)
-                ok(info.Protect == td[i].scn_page_access_after_write, "%d: got %#x != expected %#x\n", i, info.Protect, td[i].scn_page_access_after_write);
+                ok(info.Protect == td[i].scn_page_access_after_write, "%d: got %#lx != expected %#lx\n", i, info.Protect, td[i].scn_page_access_after_write);
         }
 
         SetLastError(0xdeadbeef);
         ret = FreeLibrary(hlib);
-        ok(ret, "FreeLibrary error %d\n", GetLastError());
+        ok(ret, "FreeLibrary error %ld\n", GetLastError());
 
         test_image_mapping(dll_name, td[i].scn_page_access, TRUE);
 
@@ -2053,57 +2053,57 @@ static void test_section_access(void)
          * but leave a not deletable temporary file.
          */
         ok(hfile != INVALID_HANDLE_VALUE || broken(hfile == INVALID_HANDLE_VALUE) /* nt4 */,
-            "CreateFile error %d\n", GetLastError());
+            "CreateFile error %ld\n", GetLastError());
         if (hfile == INVALID_HANDLE_VALUE) goto nt4_is_broken;
         SetFilePointer(hfile, sizeof(dos_header), NULL, FILE_BEGIN);
         SetLastError(0xdeadbeef);
         ret = WriteFile(hfile, &nt_header, sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER), &dummy, NULL);
-        ok(ret, "WriteFile error %d\n", GetLastError());
+        ok(ret, "WriteFile error %ld\n", GetLastError());
         CloseHandle(hfile);
 
         memset(&sti, 0, sizeof(sti));
         sti.cb = sizeof(sti);
         SetLastError(0xdeadbeef);
         ret = CreateProcessA(dll_name, NULL, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &sti, &pi);
-        ok(ret, "CreateProcess() error %d\n", GetLastError());
+        ok(ret, "CreateProcess() error %ld\n", GetLastError());
 
         SetLastError(0xdeadbeef);
         size = VirtualQueryEx(pi.hProcess, (char *)hlib + section.VirtualAddress, &info, sizeof(info));
         ok(size == sizeof(info),
-            "%d: VirtualQuery error %d\n", i, GetLastError());
+            "%d: VirtualQuery error %ld\n", i, GetLastError());
         ok(info.BaseAddress == (char *)hlib + section.VirtualAddress, "%d: got %p != expected %p\n", i, info.BaseAddress, (char *)hlib + section.VirtualAddress);
-        ok(info.RegionSize == page_size, "%d: got %#lx != expected %#x\n", i, info.RegionSize, page_size);
-        ok(info.Protect == td[i].scn_page_access, "%d: got %#x != expected %#x\n", i, info.Protect, td[i].scn_page_access);
+        ok(info.RegionSize == page_size, "%d: got %#Ix != expected %#lx\n", i, info.RegionSize, page_size);
+        ok(info.Protect == td[i].scn_page_access, "%d: got %#lx != expected %#lx\n", i, info.Protect, td[i].scn_page_access);
         ok(info.AllocationBase == hlib, "%d: %p != %p\n", i, info.AllocationBase, hlib);
-        ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%d: %#x != PAGE_EXECUTE_WRITECOPY\n", i, info.AllocationProtect);
-        ok(info.State == MEM_COMMIT, "%d: %#x != MEM_COMMIT\n", i, info.State);
-        ok(info.Type == SEC_IMAGE, "%d: %#x != SEC_IMAGE\n", i, info.Type);
+        ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%d: %#lx != PAGE_EXECUTE_WRITECOPY\n", i, info.AllocationProtect);
+        ok(info.State == MEM_COMMIT, "%d: %#lx != MEM_COMMIT\n", i, info.State);
+        ok(info.Type == SEC_IMAGE, "%d: %#lx != SEC_IMAGE\n", i, info.Type);
         if (info.Protect != PAGE_NOACCESS)
         {
             SetLastError(0xdeadbeef);
             ret = ReadProcessMemory(pi.hProcess, info.BaseAddress, buf, section.SizeOfRawData, NULL);
-            ok(ret, "ReadProcessMemory() error %d\n", GetLastError());
+            ok(ret, "ReadProcessMemory() error %ld\n", GetLastError());
             ok(!memcmp(buf, section_data, section.SizeOfRawData), "wrong section data\n");
         }
 
         status = NtQueryInformationProcess(pi.hProcess, ProcessImageInformation,
                 &image_info, sizeof(image_info), NULL );
-        ok(!status, "Got unexpected status %#x.\n", status);
+        ok(!status, "Got unexpected status %#lx.\n", status);
         ok(!(image_info.ImageCharacteristics & IMAGE_FILE_DLL),
                 "Got unexpected characteristics %#x.\n", nt_header.FileHeader.Characteristics);
         status = NtUnmapViewOfSection(pi.hProcess, info.BaseAddress);
-        ok(!status, "Got unexpected status %#x.\n", status);
+        ok(!status, "Got unexpected status %#lx.\n", status);
         status = NtQueryInformationProcess(pi.hProcess, ProcessImageInformation,
                 &image_info, sizeof(image_info), NULL );
-        ok(!status, "Got unexpected status %#x.\n", status);
+        ok(!status, "Got unexpected status %#lx.\n", status);
         ok(!(image_info.ImageCharacteristics & IMAGE_FILE_DLL),
                 "Got unexpected characteristics %#x.\n", nt_header.FileHeader.Characteristics);
 
         SetLastError(0xdeadbeef);
         ret = TerminateProcess(pi.hProcess, 0);
-        ok(ret, "TerminateProcess() error %d\n", GetLastError());
+        ok(ret, "TerminateProcess() error %ld\n", GetLastError());
         ret = WaitForSingleObject(pi.hProcess, 3000);
-        ok(ret == WAIT_OBJECT_0, "WaitForSingleObject failed: %x\n", ret);
+        ok(ret == WAIT_OBJECT_0, "WaitForSingleObject failed: %lx\n", ret);
 
         CloseHandle(pi.hThread);
         CloseHandle(pi.hProcess);
@@ -2113,7 +2113,7 @@ static void test_section_access(void)
 nt4_is_broken:
         SetLastError(0xdeadbeef);
         ret = DeleteFileA(dll_name);
-        ok(ret || broken(!ret) /* nt4 */, "DeleteFile error %d\n", GetLastError());
+        ok(ret || broken(!ret) /* nt4 */, "DeleteFile error %ld\n", GetLastError());
     }
 }
 
@@ -2203,7 +2203,7 @@ static void test_import_resolution(void)
         {
         case 0:  /* normal load */
             mod = LoadLibraryA( dll_name );
-            ok( mod != NULL, "failed to load err %u\n", GetLastError() );
+            ok( mod != NULL, "failed to load err %lu\n", GetLastError() );
             if (!mod) break;
             ptr = (struct imports *)((char *)mod + page_size);
             expect = GetProcAddress( GetModuleHandleA( data.module ), data.function.name );
@@ -2220,7 +2220,7 @@ static void test_import_resolution(void)
             break;
         case 1:  /* load with DONT_RESOLVE_DLL_REFERENCES doesn't resolve imports */
             mod = LoadLibraryExA( dll_name, 0, DONT_RESOLVE_DLL_REFERENCES );
-            ok( mod != NULL, "failed to load err %u\n", GetLastError() );
+            ok( mod != NULL, "failed to load err %lu\n", GetLastError() );
             if (!mod) break;
             ptr = (struct imports *)((char *)mod + page_size);
             ok( ptr->thunks[0].u1.Function == 0xdeadbeef, "thunk resolved to %p for %s.%s\n",
@@ -2237,7 +2237,7 @@ static void test_import_resolution(void)
             break;
         case 2:  /* load without IMAGE_FILE_DLL doesn't resolve imports */
             mod = LoadLibraryA( dll_name );
-            ok( mod != NULL, "failed to load err %u\n", GetLastError() );
+            ok( mod != NULL, "failed to load err %lu\n", GetLastError() );
             if (!mod) break;
             ptr = (struct imports *)((char *)mod + page_size);
             ok( ptr->thunks[0].u1.Function == 0xdeadbeef, "thunk resolved to %p for %s.%s\n",
@@ -2266,7 +2266,7 @@ static DWORD WINAPI mutex_thread_proc(void *param)
     DWORD ret;
 
     ret = WaitForSingleObject(mutex, 0);
-    ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#x\n", ret);
+    ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#lx\n", ret);
 
     SetEvent(param);
 
@@ -2276,7 +2276,7 @@ static DWORD WINAPI mutex_thread_proc(void *param)
     wait_list[3] = heap_lock_event;
     wait_list[4] = cs_lock_event;
 
-    trace("%04x: mutex_thread_proc: starting\n", GetCurrentThreadId());
+    trace("%04lx: mutex_thread_proc: starting\n", GetCurrentThreadId());
     while (1)
     {
         ret = WaitForMultipleObjects(ARRAY_SIZE(wait_list), wait_list, FALSE, 50);
@@ -2284,36 +2284,36 @@ static DWORD WINAPI mutex_thread_proc(void *param)
         else if (ret == WAIT_OBJECT_0 + 1)
         {
             ULONG_PTR loader_lock_magic;
-            trace("%04x: mutex_thread_proc: Entering loader lock\n", GetCurrentThreadId());
+            trace("%04lx: mutex_thread_proc: Entering loader lock\n", GetCurrentThreadId());
             ret = pLdrLockLoaderLock(0, NULL, &loader_lock_magic);
-            ok(!ret, "LdrLockLoaderLock error %#x\n", ret);
+            ok(!ret, "LdrLockLoaderLock error %#lx\n", ret);
             inside_loader_lock++;
             SetEvent(ack_event);
         }
         else if (ret == WAIT_OBJECT_0 + 2)
         {
-            trace("%04x: mutex_thread_proc: Entering PEB lock\n", GetCurrentThreadId());
+            trace("%04lx: mutex_thread_proc: Entering PEB lock\n", GetCurrentThreadId());
             pRtlAcquirePebLock();
             inside_peb_lock++;
             SetEvent(ack_event);
         }
         else if (ret == WAIT_OBJECT_0 + 3)
         {
-            trace("%04x: mutex_thread_proc: Entering heap lock\n", GetCurrentThreadId());
+            trace("%04lx: mutex_thread_proc: Entering heap lock\n", GetCurrentThreadId());
             HeapLock(GetProcessHeap());
             inside_heap_lock++;
             SetEvent(ack_event);
         }
         else if (ret == WAIT_OBJECT_0 + 4)
         {
-            trace("%04x: mutex_thread_proc: Entering CS lock\n", GetCurrentThreadId());
+            trace("%04lx: mutex_thread_proc: Entering CS lock\n", GetCurrentThreadId());
             EnterCriticalSection(&cs_lock);
             inside_cs_lock++;
             SetEvent(ack_event);
         }
     }
 
-    trace("%04x: mutex_thread_proc: exiting\n", GetCurrentThreadId());
+    trace("%04lx: mutex_thread_proc: exiting\n", GetCurrentThreadId());
     return 196;
 }
 
@@ -2322,18 +2322,18 @@ static DWORD WINAPI semaphore_thread_proc(void *param)
     DWORD ret;
 
     ret = WaitForSingleObject(semaphore, 0);
-    ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#x\n", ret);
+    ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#lx\n", ret);
 
     SetEvent(param);
 
     while (1)
     {
         if (winetest_debug > 1)
-            trace("%04x: semaphore_thread_proc: still alive\n", GetCurrentThreadId());
+            trace("%04lx: semaphore_thread_proc: still alive\n", GetCurrentThreadId());
         if (WaitForSingleObject(stop_event, 50) != WAIT_TIMEOUT) break;
     }
 
-    trace("%04x: semaphore_thread_proc: exiting\n", GetCurrentThreadId());
+    trace("%04lx: semaphore_thread_proc: exiting\n", GetCurrentThreadId());
     return 196;
 }
 
@@ -2345,7 +2345,7 @@ static DWORD WINAPI noop_thread_proc(void *param)
         InterlockedIncrement(noop_thread_started);
     }
 
-    trace("%04x: noop_thread_proc: exiting\n", GetCurrentThreadId());
+    trace("%04lx: noop_thread_proc: exiting\n", GetCurrentThreadId());
     return 195;
 }
 
@@ -2394,7 +2394,7 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
         trace("dll: %p, DLL_PROCESS_ATTACH, %p\n", hinst, param);
 
         ret = pRtlDllShutdownInProgress();
-        ok(!ret, "RtlDllShutdownInProgress returned %d\n", ret);
+        ok(!ret, "RtlDllShutdownInProgress returned %ld\n", ret);
 
         /* Set up the FLS slot, if FLS is available */
         if (pFlsGetValue)
@@ -2402,18 +2402,18 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
             void* value;
             BOOL bret;
             ret = pFlsAlloc(&fls_callback);
-            ok(ret != FLS_OUT_OF_INDEXES, "FlsAlloc returned %d\n", ret);
+            ok(ret != FLS_OUT_OF_INDEXES, "FlsAlloc returned %ld\n", ret);
             fls_index = ret;
             SetLastError(0xdeadbeef);
             value = pFlsGetValue(fls_index);
             ok(!value, "FlsGetValue returned %p, expected NULL\n", value);
-            ok(GetLastError() == ERROR_SUCCESS, "FlsGetValue failed with error %u\n", GetLastError());
+            ok(GetLastError() == ERROR_SUCCESS, "FlsGetValue failed with error %lu\n", GetLastError());
             bret = pFlsSetValue(fls_index, (void*) 0x31415);
             ok(bret, "FlsSetValue failed\n");
             fls_count++;
 
             fls_index2 = pFlsAlloc(&fls_callback);
-            ok(fls_index2 != FLS_OUT_OF_INDEXES, "FlsAlloc returned %d\n", ret);
+            ok(fls_index2 != FLS_OUT_OF_INDEXES, "FlsAlloc returned %ld\n", ret);
         }
         ++thread_count;
         break;
@@ -2464,7 +2464,7 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
         if (test_dll_phase == 3)
         {
             ret = pRtlDllShutdownInProgress();
-            ok(ret, "RtlDllShutdownInProgress returned %d\n", ret);
+            ok(ret, "RtlDllShutdownInProgress returned %ld\n", ret);
         }
         else
         {
@@ -2472,7 +2472,7 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
 
             /* FIXME: remove once Wine is fixed */
             todo_wine_if (!(expected_code == STILL_ACTIVE || expected_code == 196))
-                ok(!ret || broken(ret) /* before Vista */, "RtlDllShutdownInProgress returned %d\n", ret);
+                ok(!ret || broken(ret) /* before Vista */, "RtlDllShutdownInProgress returned %ld\n", ret);
         }
 
         /* In the case that the process is terminating, FLS slots should still be accessible, but
@@ -2487,20 +2487,20 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
             value = pFlsGetValue(fls_index);
             ok(broken(value == (void*) 0x31415) || /* Win2k3 */
                 value == NULL, "FlsGetValue returned %p, expected NULL\n", value);
-            ok(GetLastError() == ERROR_SUCCESS, "FlsGetValue failed with error %u\n", GetLastError());
+            ok(GetLastError() == ERROR_SUCCESS, "FlsGetValue failed with error %lu\n", GetLastError());
             ok(broken(fls_callback_count == thread_detach_count) || /* Win2k3 */
                 fls_callback_count == thread_detach_count + 1,
-                "wrong FLS callback count %d, expected %d\n", fls_callback_count, thread_detach_count + 1);
+                "wrong FLS callback count %ld, expected %d\n", fls_callback_count, thread_detach_count + 1);
         }
         if (pFlsFree)
         {
             BOOL ret;
             /* Call FlsFree now and run the remaining callbacks from uncleanly terminated threads */
             ret = pFlsFree(fls_index);
-            ok(ret, "FlsFree failed with error %u\n", GetLastError());
+            ok(ret, "FlsFree failed with error %lu\n", GetLastError());
             fls_index = FLS_OUT_OF_INDEXES;
             ok(fls_callback_count == fls_count,
-                "wrong FLS callback count %d, expected %d\n", fls_callback_count, fls_count);
+                "wrong FLS callback count %ld, expected %d\n", fls_callback_count, fls_count);
         }
 
         ok(attached_thread_count >= 2, "attached thread count should be >= 2\n");
@@ -2513,40 +2513,40 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
             if (expected_code != STILL_ACTIVE)
             {
                 ret = WaitForSingleObject(attached_thread[i], 1000);
-                ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#x\n", ret);
+                ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#lx\n", ret);
             }
             ret = GetExitCodeThread(attached_thread[i], &code);
-            trace("dll: GetExitCodeThread(%u) => %d,%u\n", i, ret, code);
-            ok(ret == 1, "GetExitCodeThread returned %d, expected 1\n", ret);
-            ok(code == expected_code, "expected thread exit code %u, got %u\n", expected_code, code);
+            trace("dll: GetExitCodeThread(%lu) => %ld,%lu\n", i, ret, code);
+            ok(ret == 1, "GetExitCodeThread returned %ld, expected 1\n", ret);
+            ok(code == expected_code, "expected thread exit code %lu, got %lu\n", expected_code, code);
         }
 
         ret = WaitForSingleObject(event, 0);
-        ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
+        ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#lx\n", ret);
 
         ret = WaitForSingleObject(mutex, 0);
         if (expected_code == STILL_ACTIVE)
-            ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
+            ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#lx\n", ret);
         else
-            ok(ret == WAIT_ABANDONED, "expected WAIT_ABANDONED, got %#x\n", ret);
+            ok(ret == WAIT_ABANDONED, "expected WAIT_ABANDONED, got %#lx\n", ret);
 
         /* semaphore is not abandoned on thread termination */
         ret = WaitForSingleObject(semaphore, 0);
-        ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
+        ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#lx\n", ret);
 
         if (expected_code == STILL_ACTIVE)
         {
             ret = WaitForSingleObject(attached_thread[0], 0);
-            ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
+            ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#lx\n", ret);
             ret = WaitForSingleObject(attached_thread[1], 0);
-            ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
+            ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#lx\n", ret);
         }
         else
         {
             ret = WaitForSingleObject(attached_thread[0], 0);
-            ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#x\n", ret);
+            ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#lx\n", ret);
             ret = WaitForSingleObject(attached_thread[1], 0);
-            ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#x\n", ret);
+            ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#lx\n", ret);
         }
 
         /* win7 doesn't allow creating a thread during process shutdown but
@@ -2559,26 +2559,26 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
         {
             ok(!handle || broken(handle != 0) /* before win7 */, "CreateThread should fail\n");
             if (!handle)
-                ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+                ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
             else
             {
                 ret = WaitForSingleObject(handle, 1000);
-                ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
+                ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#lx\n", ret);
                 CloseHandle(handle);
             }
         }
         else
         {
-            ok(handle != 0, "CreateThread error %d\n", GetLastError());
+            ok(handle != 0, "CreateThread error %ld\n", GetLastError());
             ret = WaitForSingleObject(handle, 1000);
-            ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
+            ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#lx\n", ret);
             ok(!noop_thread_started || broken(noop_thread_started) /* XP64 */, "thread shouldn't start yet\n");
             CloseHandle(handle);
         }
 
         SetLastError(0xdeadbeef);
         process = OpenProcess(PROCESS_ALL_ACCESS_NT4, FALSE, GetCurrentProcessId());
-        ok(process != NULL, "OpenProcess error %d\n", GetLastError());
+        ok(process != NULL, "OpenProcess error %ld\n", GetLastError());
 
         noop_thread_started = 0;
         SetLastError(0xdeadbeef);
@@ -2587,26 +2587,26 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
         {
             ok(!handle || broken(handle != 0) /* before win7 */, "CreateRemoteThread should fail\n");
             if (!handle)
-                ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+                ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
             else
             {
                 ret = WaitForSingleObject(handle, 1000);
-                ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
+                ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#lx\n", ret);
                 CloseHandle(handle);
             }
         }
         else
         {
-            ok(handle != 0, "CreateRemoteThread error %d\n", GetLastError());
+            ok(handle != 0, "CreateRemoteThread error %ld\n", GetLastError());
             ret = WaitForSingleObject(handle, 1000);
-            ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
+            ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#lx\n", ret);
             ok(!noop_thread_started || broken(noop_thread_started) /* XP64 */, "thread shouldn't start yet\n");
             CloseHandle(handle);
         }
 
         SetLastError(0xdeadbeef);
         handle = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, NULL);
-        ok(handle != 0, "CreateFileMapping error %d\n", GetLastError());
+        ok(handle != 0, "CreateFileMapping error %ld\n", GetLastError());
 
         offset.u.LowPart = 0;
         offset.u.HighPart = 0;
@@ -2614,9 +2614,9 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
         size = 0;
         ret = pNtMapViewOfSection(handle, process, &addr, 0, 0, &offset,
                                   &size, 1 /* ViewShare */, 0, PAGE_READONLY);
-        ok(ret == STATUS_SUCCESS, "NtMapViewOfSection error %#x\n", ret);
+        ok(ret == STATUS_SUCCESS, "NtMapViewOfSection error %#lx\n", ret);
         ret = pNtUnmapViewOfSection(process, addr);
-        ok(ret == STATUS_SUCCESS, "NtUnmapViewOfSection error %#x\n", ret);
+        ok(ret == STATUS_SUCCESS, "NtUnmapViewOfSection error %#lx\n", ret);
 
         CloseHandle(handle);
         CloseHandle(process);
@@ -2625,10 +2625,10 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
         ok(!handle, "winver.exe shouldn't be loaded yet\n");
         SetLastError(0xdeadbeef);
         handle = LoadLibraryA("winver.exe");
-        ok(handle != 0, "LoadLibrary error %d\n", GetLastError());
+        ok(handle != 0, "LoadLibrary error %ld\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = FreeLibrary(handle);
-        ok(ret, "FreeLibrary error %d\n", GetLastError());
+        ok(ret, "FreeLibrary error %ld\n", GetLastError());
         handle = GetModuleHandleA("winver.exe");
         if (param)
             ok(handle != 0, "winver.exe should not be unloaded\n");
@@ -2639,17 +2639,17 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
         SetLastError(0xdeadbeef);
         ret = WaitForDebugEvent(&de, 0);
         ok(!ret, "WaitForDebugEvent should fail\n");
-        ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
+        ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %ld\n", GetLastError());
 
         SetLastError(0xdeadbeef);
         ret = DebugActiveProcess(GetCurrentProcessId());
         ok(!ret, "DebugActiveProcess should fail\n");
-        ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+        ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
 
         SetLastError(0xdeadbeef);
         ret = WaitForDebugEvent(&de, 0);
         ok(!ret, "WaitForDebugEvent should fail\n");
-        ok(GetLastError() == ERROR_SEM_TIMEOUT, "expected ERROR_SEM_TIMEOUT, got %d\n", GetLastError());
+        ok(GetLastError() == ERROR_SEM_TIMEOUT, "expected ERROR_SEM_TIMEOUT, got %ld\n", GetLastError());
 
         if (test_dll_phase == 2)
         {
@@ -2666,7 +2666,7 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
         ++thread_count;
 
         ret = pRtlDllShutdownInProgress();
-        ok(!ret, "RtlDllShutdownInProgress returned %d\n", ret);
+        ok(!ret, "RtlDllShutdownInProgress returned %ld\n", ret);
 
         if (attached_thread_count < MAX_COUNT)
         {
@@ -2683,7 +2683,7 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
             SetLastError(0xdeadbeef);
             value = pFlsGetValue(fls_index);
             ok(!value, "FlsGetValue returned %p, expected NULL\n", value);
-            ok(GetLastError() == ERROR_SUCCESS, "FlsGetValue failed with error %u\n", GetLastError());
+            ok(GetLastError() == ERROR_SUCCESS, "FlsGetValue failed with error %lu\n", GetLastError());
             ret = pFlsSetValue(fls_index, (void*) 0x31415);
             ok(ret, "FlsSetValue failed\n");
             fls_count++;
@@ -2701,9 +2701,9 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
          * sent on thread exit, but DLL_THREAD_ATTACH is never received.
          */
         if (noop_thread_started)
-            ok(ret, "RtlDllShutdownInProgress returned %d\n", ret);
+            ok(ret, "RtlDllShutdownInProgress returned %ld\n", ret);
         else
-            ok(!ret, "RtlDllShutdownInProgress returned %d\n", ret);
+            ok(!ret, "RtlDllShutdownInProgress returned %ld\n", ret);
 
         /* FLS data should already be destroyed, if FLS is available.
          * Note that this is broken for Win2k3, which runs the callbacks *after* the DLL entry
@@ -2719,7 +2719,7 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
             value = pFlsGetValue(fls_index);
             ok(broken(value == (void*) 0x31415) || /* Win2k3 */
                 !value, "FlsGetValue returned %p, expected NULL\n", value);
-            ok(GetLastError() == ERROR_SUCCESS, "FlsGetValue failed with error %u\n", GetLastError());
+            ok(GetLastError() == ERROR_SUCCESS, "FlsGetValue failed with error %lu\n", GetLastError());
 
             bret = pFlsSetValue(fls_index2, (void*) 0x31415);
             ok(bret, "FlsSetValue failed\n");
@@ -2734,7 +2734,7 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
 
         break;
     default:
-        trace("dll: %p, %d, %p\n", hinst, reason, param);
+        trace("dll: %p, %ld, %p\n", hinst, reason, param);
         break;
     }
 
@@ -2752,7 +2752,7 @@ static void child_process(const char *dll_name, DWORD target_offset)
     struct PROCESS_BASIC_INFORMATION_PRIVATE pbi;
     DWORD_PTR affinity;
 
-    trace("phase %d: writing %p at %#x\n", test_dll_phase, dll_entry_point, target_offset);
+    trace("phase %d: writing %p at %#lx\n", test_dll_phase, dll_entry_point, target_offset);
 
     if (pFlsAlloc)
     {
@@ -2762,36 +2762,36 @@ static void child_process(const char *dll_name, DWORD target_offset)
 
     SetLastError(0xdeadbeef);
     mutex = CreateMutexW(NULL, FALSE, NULL);
-    ok(mutex != 0, "CreateMutex error %d\n", GetLastError());
+    ok(mutex != 0, "CreateMutex error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     semaphore = CreateSemaphoreW(NULL, 1, 1, NULL);
-    ok(semaphore != 0, "CreateSemaphore error %d\n", GetLastError());
+    ok(semaphore != 0, "CreateSemaphore error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     event = CreateEventW(NULL, TRUE, FALSE, NULL);
-    ok(event != 0, "CreateEvent error %d\n", GetLastError());
+    ok(event != 0, "CreateEvent error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     loader_lock_event = CreateEventW(NULL, FALSE, FALSE, NULL);
-    ok(loader_lock_event != 0, "CreateEvent error %d\n", GetLastError());
+    ok(loader_lock_event != 0, "CreateEvent error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     peb_lock_event = CreateEventW(NULL, FALSE, FALSE, NULL);
-    ok(peb_lock_event != 0, "CreateEvent error %d\n", GetLastError());
+    ok(peb_lock_event != 0, "CreateEvent error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     heap_lock_event = CreateEventW(NULL, FALSE, FALSE, NULL);
-    ok(heap_lock_event != 0, "CreateEvent error %d\n", GetLastError());
+    ok(heap_lock_event != 0, "CreateEvent error %ld\n", GetLastError());
 
     InitializeCriticalSection(&cs_lock);
     SetLastError(0xdeadbeef);
     cs_lock_event = CreateEventW(NULL, FALSE, FALSE, NULL);
-    ok(cs_lock_event != 0, "CreateEvent error %d\n", GetLastError());
+    ok(cs_lock_event != 0, "CreateEvent error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ack_event = CreateEventW(NULL, FALSE, FALSE, NULL);
-    ok(ack_event != 0, "CreateEvent error %d\n", GetLastError());
+    ok(ack_event != 0, "CreateEvent error %ld\n", GetLastError());
 
     file = CreateFileA(dll_name, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
     if (file == INVALID_HANDLE_VALUE)
@@ -2803,20 +2803,20 @@ static void child_process(const char *dll_name, DWORD target_offset)
     SetLastError(0xdeadbeef);
     target = dll_entry_point;
     ret = WriteFile(file, &target, sizeof(target), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
     CloseHandle(file);
 
     SetLastError(0xdeadbeef);
     hmod = LoadLibraryA(dll_name);
-    ok(hmod != 0, "LoadLibrary error %d\n", GetLastError());
+    ok(hmod != 0, "LoadLibrary error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     stop_event = CreateEventW(NULL, TRUE, FALSE, NULL);
-    ok(stop_event != 0, "CreateEvent error %d\n", GetLastError());
+    ok(stop_event != 0, "CreateEvent error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     thread = CreateThread(NULL, 0, mutex_thread_proc, event, 0, &dummy);
-    ok(thread != 0, "CreateThread error %d\n", GetLastError());
+    ok(thread != 0, "CreateThread error %ld\n", GetLastError());
     WaitForSingleObject(event, 3000);
     CloseHandle(thread);
 
@@ -2824,7 +2824,7 @@ static void child_process(const char *dll_name, DWORD target_offset)
 
     SetLastError(0xdeadbeef);
     thread = CreateThread(NULL, 0, semaphore_thread_proc, event, 0, &dummy);
-    ok(thread != 0, "CreateThread error %d\n", GetLastError());
+    ok(thread != 0, "CreateThread error %ld\n", GetLastError());
     WaitForSingleObject(event, 3000);
     CloseHandle(thread);
 
@@ -2835,62 +2835,62 @@ static void child_process(const char *dll_name, DWORD target_offset)
     for (i = 0; i < attached_thread_count; i++)
     {
         ret = GetExitCodeThread(attached_thread[i], &code);
-        trace("child: GetExitCodeThread(%u) => %d,%u\n", i, ret, code);
-        ok(ret == 1, "GetExitCodeThread returned %d, expected 1\n", ret);
-        ok(code == STILL_ACTIVE, "expected thread exit code STILL_ACTIVE, got %u\n", code);
+        trace("child: GetExitCodeThread(%lu) => %ld,%lu\n", i, ret, code);
+        ok(ret == 1, "GetExitCodeThread returned %ld, expected 1\n", ret);
+        ok(code == STILL_ACTIVE, "expected thread exit code STILL_ACTIVE, got %lu\n", code);
     }
 
     ret = WaitForSingleObject(attached_thread[0], 0);
-    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
+    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#lx\n", ret);
     ret = WaitForSingleObject(attached_thread[1], 0);
-    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
+    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#lx\n", ret);
 
     ret = WaitForSingleObject(event, 0);
-    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
+    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#lx\n", ret);
     ret = WaitForSingleObject(mutex, 0);
-    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
+    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#lx\n", ret);
     ret = WaitForSingleObject(semaphore, 0);
-    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
+    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#lx\n", ret);
 
     ret = pRtlDllShutdownInProgress();
-    ok(!ret, "RtlDllShutdownInProgress returned %d\n", ret);
+    ok(!ret, "RtlDllShutdownInProgress returned %ld\n", ret);
 
     SetLastError(0xdeadbeef);
     process = OpenProcess(PROCESS_ALL_ACCESS_NT4, FALSE, GetCurrentProcessId());
-    ok(process != NULL, "OpenProcess error %d\n", GetLastError());
+    ok(process != NULL, "OpenProcess error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = TerminateProcess(0, 195);
     ok(!ret, "TerminateProcess(0) should fail\n");
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %ld\n", GetLastError());
 
     Sleep(100);
 
     affinity = 1;
     ret = pNtSetInformationProcess(process, ProcessAffinityMask, &affinity, sizeof(affinity));
-    ok(!ret, "NtSetInformationProcess error %#x\n", ret);
+    ok(!ret, "NtSetInformationProcess error %#lx\n", ret);
 
     switch (test_dll_phase)
     {
     case 0:
         ret = pRtlDllShutdownInProgress();
-        ok(!ret, "RtlDllShutdownInProgress returned %d\n", ret);
+        ok(!ret, "RtlDllShutdownInProgress returned %ld\n", ret);
 
         trace("call NtTerminateProcess(0, 195)\n");
         ret = pNtTerminateProcess(0, 195);
-        ok(!ret, "NtTerminateProcess error %#x\n", ret);
+        ok(!ret, "NtTerminateProcess error %#lx\n", ret);
 
         memset(&pbi, 0, sizeof(pbi));
         ret = pNtQueryInformationProcess(process, ProcessBasicInformation, &pbi, sizeof(pbi), NULL);
-        ok(!ret, "NtQueryInformationProcess error %#x\n", ret);
+        ok(!ret, "NtQueryInformationProcess error %#lx\n", ret);
         ok(pbi.ExitStatus == STILL_ACTIVE || pbi.ExitStatus == 195,
-           "expected STILL_ACTIVE, got %lu\n", pbi.ExitStatus);
+           "expected STILL_ACTIVE, got %Iu\n", pbi.ExitStatus);
         affinity = 1;
         ret = pNtSetInformationProcess(process, ProcessAffinityMask, &affinity, sizeof(affinity));
-        ok(!ret, "NtSetInformationProcess error %#x\n", ret);
+        ok(!ret, "NtSetInformationProcess error %#lx\n", ret);
 
         ret = pRtlDllShutdownInProgress();
-        ok(!ret, "RtlDllShutdownInProgress returned %d\n", ret);
+        ok(!ret, "RtlDllShutdownInProgress returned %ld\n", ret);
 
         hmod = GetModuleHandleA(dll_name);
         ok(hmod != 0, "DLL should not be unloaded\n");
@@ -2899,11 +2899,11 @@ static void child_process(const char *dll_name, DWORD target_offset)
         thread = CreateThread(NULL, 0, noop_thread_proc, &dummy, 0, &ret);
         ok(!thread || broken(thread != 0) /* before win7 */, "CreateThread should fail\n");
         if (!thread)
-            ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+            ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
         else
         {
             ret = WaitForSingleObject(thread, 1000);
-            ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#x\n", ret);
+            ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#lx\n", ret);
             CloseHandle(thread);
         }
 
@@ -2911,34 +2911,34 @@ static void child_process(const char *dll_name, DWORD target_offset)
         pLdrShutdownProcess();
 
         ret = pRtlDllShutdownInProgress();
-        ok(ret, "RtlDllShutdownInProgress returned %d\n", ret);
+        ok(ret, "RtlDllShutdownInProgress returned %ld\n", ret);
 
         hmod = GetModuleHandleA(dll_name);
         ok(hmod != 0, "DLL should not be unloaded\n");
 
         memset(&pbi, 0, sizeof(pbi));
         ret = pNtQueryInformationProcess(process, ProcessBasicInformation, &pbi, sizeof(pbi), NULL);
-        ok(!ret, "NtQueryInformationProcess error %#x\n", ret);
+        ok(!ret, "NtQueryInformationProcess error %#lx\n", ret);
         ok(pbi.ExitStatus == STILL_ACTIVE || pbi.ExitStatus == 195,
-           "expected STILL_ACTIVE, got %lu\n", pbi.ExitStatus);
+           "expected STILL_ACTIVE, got %Iu\n", pbi.ExitStatus);
         affinity = 1;
         ret = pNtSetInformationProcess(process, ProcessAffinityMask, &affinity, sizeof(affinity));
-        ok(!ret, "NtSetInformationProcess error %#x\n", ret);
+        ok(!ret, "NtSetInformationProcess error %#lx\n", ret);
         break;
 
     case 1: /* normal ExitProcess */
         ret = pRtlDllShutdownInProgress();
-        ok(!ret, "RtlDllShutdownInProgress returned %d\n", ret);
+        ok(!ret, "RtlDllShutdownInProgress returned %ld\n", ret);
         break;
 
     case 2: /* ExitProcess will be called by the PROCESS_DETACH handler */
         ret = pRtlDllShutdownInProgress();
-        ok(!ret, "RtlDllShutdownInProgress returned %d\n", ret);
+        ok(!ret, "RtlDllShutdownInProgress returned %ld\n", ret);
 
         trace("call FreeLibrary(%p)\n", hmod);
         SetLastError(0xdeadbeef);
         ret = FreeLibrary(hmod);
-        ok(ret, "FreeLibrary error %d\n", GetLastError());
+        ok(ret, "FreeLibrary error %ld\n", GetLastError());
         hmod = GetModuleHandleA(dll_name);
         ok(!hmod, "DLL should be unloaded\n");
 
@@ -2946,7 +2946,7 @@ static void child_process(const char *dll_name, DWORD target_offset)
             ok(0, "FreeLibrary+ExitProcess should never return\n");
 
         ret = pRtlDllShutdownInProgress();
-        ok(!ret, "RtlDllShutdownInProgress returned %d\n", ret);
+        ok(!ret, "RtlDllShutdownInProgress returned %ld\n", ret);
 
         break;
 
@@ -2964,7 +2964,7 @@ static void child_process(const char *dll_name, DWORD target_offset)
         /* calling NtTerminateProcess should not cause a deadlock */
         trace("call NtTerminateProcess(0, 198)\n");
         ret = pNtTerminateProcess(0, 198);
-        ok(!ret, "NtTerminateProcess error %#x\n", ret);
+        ok(!ret, "NtTerminateProcess error %#lx\n", ret);
 
         *child_failures = winetest_get_failures();
 
@@ -3032,24 +3032,24 @@ static void child_process(const char *dll_name, DWORD target_offset)
     if (expected_code == STILL_ACTIVE)
     {
         ret = WaitForSingleObject(attached_thread[0], 100);
-        ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
+        ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#lx\n", ret);
         ret = WaitForSingleObject(attached_thread[1], 100);
-        ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
+        ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#lx\n", ret);
     }
     else
     {
         ret = WaitForSingleObject(attached_thread[0], 2000);
-        ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#x\n", ret);
+        ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#lx\n", ret);
         ret = WaitForSingleObject(attached_thread[1], 2000);
-        ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#x\n", ret);
+        ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %#lx\n", ret);
     }
 
     for (i = 0; i < attached_thread_count; i++)
     {
         ret = GetExitCodeThread(attached_thread[i], &code);
-        trace("child: GetExitCodeThread(%u) => %d,%u\n", i, ret, code);
-        ok(ret == 1, "GetExitCodeThread returned %d, expected 1\n", ret);
-        ok(code == expected_code, "expected thread exit code %u, got %u\n", expected_code, code);
+        trace("child: GetExitCodeThread(%lu) => %ld,%lu\n", i, ret, code);
+        ok(ret == 1, "GetExitCodeThread returned %ld, expected 1\n", ret);
+        ok(code == expected_code, "expected thread exit code %lu, got %lu\n", expected_code, code);
     }
 
     *child_failures = winetest_get_failures();
@@ -3133,7 +3133,7 @@ static void test_ExitProcess(void)
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(file, &dos_header, sizeof(dos_header), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     nt_header = nt_header_template;
     nt_header.FileHeader.NumberOfSections = 1;
@@ -3147,10 +3147,10 @@ static void test_ExitProcess(void)
     nt_header.OptionalHeader.SizeOfHeaders = sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER);
     SetLastError(0xdeadbeef);
     ret = WriteFile(file, &nt_header, sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = WriteFile(file, &nt_header.OptionalHeader, sizeof(IMAGE_OPTIONAL_HEADER), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     section.SizeOfRawData = sizeof(section_data);
     section.PointerToRawData = nt_header.OptionalHeader.FileAlignment;
@@ -3159,20 +3159,20 @@ static void test_ExitProcess(void)
     section.Characteristics = IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_EXECUTE;
     SetLastError(0xdeadbeef);
     ret = WriteFile(file, &section, sizeof(section), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     file_align = nt_header.OptionalHeader.FileAlignment - nt_header.OptionalHeader.SizeOfHeaders;
     assert(file_align < sizeof(filler));
     SetLastError(0xdeadbeef);
     ret = WriteFile(file, filler, file_align, &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     target_offset = SetFilePointer(file, 0, NULL, FILE_CURRENT) + FIELD_OFFSET(struct section_data, target);
 
     /* section data */
     SetLastError(0xdeadbeef);
     ret = WriteFile(file, &section_data, sizeof(section_data), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     CloseHandle(file);
 
@@ -3180,17 +3180,17 @@ static void test_ExitProcess(void)
 
     /* phase 0 */
     *child_failures = -1;
-    sprintf(cmdline, "\"%s\" loader %s %u 0", argv[0], dll_name, target_offset);
+    sprintf(cmdline, "\"%s\" loader %s %lu 0", argv[0], dll_name, target_offset);
     ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError());
+    ok(ret, "CreateProcess(%s) error %ld\n", cmdline, GetLastError());
     ret = WaitForSingleObject(pi.hProcess, 10000);
     ok(ret == WAIT_OBJECT_0, "child process failed to terminate\n");
     if (ret != WAIT_OBJECT_0) TerminateProcess(pi.hProcess, 0);
     GetExitCodeProcess(pi.hProcess, &ret);
-    ok(ret == 195, "expected exit code 195, got %u\n", ret);
+    ok(ret == 195, "expected exit code 195, got %lu\n", ret);
     if (*child_failures)
     {
-        trace("%d failures in child process\n", *child_failures);
+        trace("%ld failures in child process\n", *child_failures);
         winetest_add_failures(*child_failures);
     }
     CloseHandle(pi.hThread);
@@ -3198,17 +3198,17 @@ static void test_ExitProcess(void)
 
     /* phase 1 */
     *child_failures = -1;
-    sprintf(cmdline, "\"%s\" loader %s %u 1", argv[0], dll_name, target_offset);
+    sprintf(cmdline, "\"%s\" loader %s %lu 1", argv[0], dll_name, target_offset);
     ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError());
+    ok(ret, "CreateProcess(%s) error %ld\n", cmdline, GetLastError());
     ret = WaitForSingleObject(pi.hProcess, 10000);
     ok(ret == WAIT_OBJECT_0, "child process failed to terminate\n");
     if (ret != WAIT_OBJECT_0) TerminateProcess(pi.hProcess, 0);
     GetExitCodeProcess(pi.hProcess, &ret);
-    ok(ret == 195, "expected exit code 195, got %u\n", ret);
+    ok(ret == 195, "expected exit code 195, got %lu\n", ret);
     if (*child_failures)
     {
-        trace("%d failures in child process\n", *child_failures);
+        trace("%ld failures in child process\n", *child_failures);
         winetest_add_failures(*child_failures);
     }
     CloseHandle(pi.hThread);
@@ -3216,17 +3216,17 @@ static void test_ExitProcess(void)
 
     /* phase 2 */
     *child_failures = -1;
-    sprintf(cmdline, "\"%s\" loader %s %u 2", argv[0], dll_name, target_offset);
+    sprintf(cmdline, "\"%s\" loader %s %lu 2", argv[0], dll_name, target_offset);
     ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError());
+    ok(ret, "CreateProcess(%s) error %ld\n", cmdline, GetLastError());
     ret = WaitForSingleObject(pi.hProcess, 10000);
     ok(ret == WAIT_OBJECT_0, "child process failed to terminate\n");
     if (ret != WAIT_OBJECT_0) TerminateProcess(pi.hProcess, 0);
     GetExitCodeProcess(pi.hProcess, &ret);
-    ok(ret == 197, "expected exit code 197, got %u\n", ret);
+    ok(ret == 197, "expected exit code 197, got %lu\n", ret);
     if (*child_failures)
     {
-        trace("%d failures in child process\n", *child_failures);
+        trace("%ld failures in child process\n", *child_failures);
         winetest_add_failures(*child_failures);
     }
     CloseHandle(pi.hThread);
@@ -3234,17 +3234,17 @@ static void test_ExitProcess(void)
 
     /* phase 3 */
     *child_failures = -1;
-    sprintf(cmdline, "\"%s\" loader %s %u 3", argv[0], dll_name, target_offset);
+    sprintf(cmdline, "\"%s\" loader %s %lu 3", argv[0], dll_name, target_offset);
     ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError());
+    ok(ret, "CreateProcess(%s) error %ld\n", cmdline, GetLastError());
     ret = WaitForSingleObject(pi.hProcess, 10000);
     ok(ret == WAIT_OBJECT_0, "child process failed to terminate\n");
     if (ret != WAIT_OBJECT_0) TerminateProcess(pi.hProcess, 0);
     GetExitCodeProcess(pi.hProcess, &ret);
-    ok(ret == 195, "expected exit code 195, got %u\n", ret);
+    ok(ret == 195, "expected exit code 195, got %lu\n", ret);
     if (*child_failures)
     {
-        trace("%d failures in child process\n", *child_failures);
+        trace("%ld failures in child process\n", *child_failures);
         winetest_add_failures(*child_failures);
     }
     CloseHandle(pi.hThread);
@@ -3254,17 +3254,17 @@ static void test_ExitProcess(void)
     if (pLdrLockLoaderLock && pLdrUnlockLoaderLock)
     {
         *child_failures = -1;
-        sprintf(cmdline, "\"%s\" loader %s %u 4", argv[0], dll_name, target_offset);
+        sprintf(cmdline, "\"%s\" loader %s %lu 4", argv[0], dll_name, target_offset);
         ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-        ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError());
+        ok(ret, "CreateProcess(%s) error %ld\n", cmdline, GetLastError());
         ret = WaitForSingleObject(pi.hProcess, 10000);
         ok(ret == WAIT_OBJECT_0, "child process failed to terminate\n");
         if (ret != WAIT_OBJECT_0) TerminateProcess(pi.hProcess, 0);
         GetExitCodeProcess(pi.hProcess, &ret);
-        ok(ret == 198, "expected exit code 198, got %u\n", ret);
+        ok(ret == 198, "expected exit code 198, got %lu\n", ret);
         if (*child_failures)
         {
-            trace("%d failures in child process\n", *child_failures);
+            trace("%ld failures in child process\n", *child_failures);
             winetest_add_failures(*child_failures);
         }
         CloseHandle(pi.hThread);
@@ -3277,9 +3277,9 @@ static void test_ExitProcess(void)
     if (pRtlAcquirePebLock && pRtlReleasePebLock)
     {
         *child_failures = -1;
-        sprintf(cmdline, "\"%s\" loader %s %u 5", argv[0], dll_name, target_offset);
+        sprintf(cmdline, "\"%s\" loader %s %lu 5", argv[0], dll_name, target_offset);
         ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-        ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError());
+        ok(ret, "CreateProcess(%s) error %ld\n", cmdline, GetLastError());
         ret = WaitForSingleObject(pi.hProcess, 5000);
         ok(ret == WAIT_TIMEOUT, "child process should fail to terminate\n");
         if (ret != WAIT_OBJECT_0)
@@ -3290,10 +3290,10 @@ static void test_ExitProcess(void)
         ret = WaitForSingleObject(pi.hProcess, 1000);
         ok(ret == WAIT_OBJECT_0, "child process failed to terminate\n");
         GetExitCodeProcess(pi.hProcess, &ret);
-        ok(ret == 199, "expected exit code 199, got %u\n", ret);
+        ok(ret == 199, "expected exit code 199, got %lu\n", ret);
         if (*child_failures)
         {
-            trace("%d failures in child process\n", *child_failures);
+            trace("%ld failures in child process\n", *child_failures);
             winetest_add_failures(*child_failures);
         }
         CloseHandle(pi.hThread);
@@ -3304,9 +3304,9 @@ static void test_ExitProcess(void)
 
     /* phase 6 */
     *child_failures = -1;
-    sprintf(cmdline, "\"%s\" loader %s %u 6", argv[0], dll_name, target_offset);
+    sprintf(cmdline, "\"%s\" loader %s %lu 6", argv[0], dll_name, target_offset);
     ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError());
+    ok(ret, "CreateProcess(%s) error %ld\n", cmdline, GetLastError());
     ret = WaitForSingleObject(pi.hProcess, 5000);
     todo_wine
     ok(ret == WAIT_TIMEOUT || broken(ret == WAIT_OBJECT_0) /* XP */, "child process should fail to terminate\n");
@@ -3319,10 +3319,10 @@ static void test_ExitProcess(void)
     ok(ret == WAIT_OBJECT_0, "child process failed to terminate\n");
     GetExitCodeProcess(pi.hProcess, &ret);
     todo_wine
-    ok(ret == 201 || broken(ret == 1) /* XP */, "expected exit code 201, got %u\n", ret);
+    ok(ret == 201 || broken(ret == 1) /* XP */, "expected exit code 201, got %lu\n", ret);
     if (*child_failures)
     {
-        trace("%d failures in child process\n", *child_failures);
+        trace("%ld failures in child process\n", *child_failures);
         winetest_add_failures(*child_failures);
     }
     CloseHandle(pi.hThread);
@@ -3330,9 +3330,9 @@ static void test_ExitProcess(void)
 
     /* phase 7 */
     *child_failures = -1;
-    sprintf(cmdline, "\"%s\" loader %s %u 7", argv[0], dll_name, target_offset);
+    sprintf(cmdline, "\"%s\" loader %s %lu 7", argv[0], dll_name, target_offset);
     ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError());
+    ok(ret, "CreateProcess(%s) error %ld\n", cmdline, GetLastError());
     ret = WaitForSingleObject(pi.hProcess, 5000);
     ok(ret == WAIT_OBJECT_0, "child process failed to terminate\n");
     if (ret != WAIT_OBJECT_0)
@@ -3343,10 +3343,10 @@ static void test_ExitProcess(void)
     ret = WaitForSingleObject(pi.hProcess, 1000);
     ok(ret == WAIT_OBJECT_0, "child process failed to terminate\n");
     GetExitCodeProcess(pi.hProcess, &ret);
-    ok(ret == 199, "expected exit code 199, got %u\n", ret);
+    ok(ret == 199, "expected exit code 199, got %lu\n", ret);
     if (*child_failures)
     {
-        trace("%d failures in child process\n", *child_failures);
+        trace("%ld failures in child process\n", *child_failures);
         winetest_add_failures(*child_failures);
     }
     CloseHandle(pi.hThread);
@@ -3355,32 +3355,32 @@ static void test_ExitProcess(void)
     /* test remote process termination */
     SetLastError(0xdeadbeef);
     ret = CreateProcessA(argv[0], NULL, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess(%s) error %d\n", argv[0], GetLastError());
+    ok(ret, "CreateProcess(%s) error %ld\n", argv[0], GetLastError());
 
     SetLastError(0xdeadbeef);
     addr = VirtualAllocEx(pi.hProcess, NULL, 4096, MEM_COMMIT, PAGE_READWRITE);
-    ok(addr != NULL, "VirtualAllocEx error %d\n", GetLastError());
+    ok(addr != NULL, "VirtualAllocEx error %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = VirtualProtectEx(pi.hProcess, addr, 4096, PAGE_READONLY, &old_prot);
-    ok(ret, "VirtualProtectEx error %d\n", GetLastError());
-    ok(old_prot == PAGE_READWRITE, "expected PAGE_READWRITE, got %#x\n", old_prot);
+    ok(ret, "VirtualProtectEx error %ld\n", GetLastError());
+    ok(old_prot == PAGE_READWRITE, "expected PAGE_READWRITE, got %#lx\n", old_prot);
     SetLastError(0xdeadbeef);
     size = VirtualQueryEx(pi.hProcess, NULL, &mbi, sizeof(mbi));
-    ok(size == sizeof(mbi), "VirtualQueryEx error %d\n", GetLastError());
+    ok(size == sizeof(mbi), "VirtualQueryEx error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = ReadProcessMemory(pi.hProcess, addr, buf, 4, &size);
-    ok(ret, "ReadProcessMemory error %d\n", GetLastError());
-    ok(size == 4, "expected 4, got %lu\n", size);
+    ok(ret, "ReadProcessMemory error %ld\n", GetLastError());
+    ok(size == 4, "expected 4, got %Iu\n", size);
 
     SetLastError(0xdeadbeef);
     hmap = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, NULL);
-    ok(hmap != 0, "CreateFileMapping error %d\n", GetLastError());
+    ok(hmap != 0, "CreateFileMapping error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = DuplicateHandle(GetCurrentProcess(), hmap, pi.hProcess, &hmap_dup,
                           0, FALSE, DUPLICATE_SAME_ACCESS);
-    ok(ret, "DuplicateHandle error %d\n", GetLastError());
+    ok(ret, "DuplicateHandle error %ld\n", GetLastError());
 
     offset.u.LowPart = 0;
     offset.u.HighPart = 0;
@@ -3388,57 +3388,57 @@ static void test_ExitProcess(void)
     size = 0;
     ret = pNtMapViewOfSection(hmap, pi.hProcess, &addr, 0, 0, &offset,
                               &size, 1 /* ViewShare */, 0, PAGE_READONLY);
-    ok(!ret, "NtMapViewOfSection error %#x\n", ret);
+    ok(!ret, "NtMapViewOfSection error %#lx\n", ret);
     ret = pNtUnmapViewOfSection(pi.hProcess, addr);
-    ok(!ret, "NtUnmapViewOfSection error %#x\n", ret);
+    ok(!ret, "NtUnmapViewOfSection error %#lx\n", ret);
 
     SetLastError(0xdeadbeef);
     thread = CreateRemoteThread(pi.hProcess, NULL, 0, (void *)0xdeadbeef, NULL, CREATE_SUSPENDED, &ret);
-    ok(thread != 0, "CreateRemoteThread error %d\n", GetLastError());
+    ok(thread != 0, "CreateRemoteThread error %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     ctx.ContextFlags = CONTEXT_INTEGER;
     ret = GetThreadContext(thread, &ctx);
-    ok(ret, "GetThreadContext error %d\n", GetLastError());
+    ok(ret, "GetThreadContext error %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     ctx.ContextFlags = CONTEXT_INTEGER;
     ret = SetThreadContext(thread, &ctx);
-    ok(ret, "SetThreadContext error %d\n", GetLastError());
+    ok(ret, "SetThreadContext error %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = SetThreadPriority(thread, 0);
-    ok(ret, "SetThreadPriority error %d\n", GetLastError());
+    ok(ret, "SetThreadPriority error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = TerminateThread(thread, 199);
-    ok(ret, "TerminateThread error %d\n", GetLastError());
+    ok(ret, "TerminateThread error %ld\n", GetLastError());
     /* Calling GetExitCodeThread() without waiting for thread termination
      * leads to different results due to a race condition.
      */
     ret = WaitForSingleObject(thread, 1000);
-    ok(ret == WAIT_OBJECT_0, "WaitForSingleObject failed: %x\n", ret);
+    ok(ret == WAIT_OBJECT_0, "WaitForSingleObject failed: %lx\n", ret);
     GetExitCodeThread(thread, &ret);
-    ok(ret == 199, "expected exit code 199, got %u\n", ret);
+    ok(ret == 199, "expected exit code 199, got %lu\n", ret);
 
     SetLastError(0xdeadbeef);
     ret = TerminateProcess(pi.hProcess, 198);
-    ok(ret, "TerminateProcess error %d\n", GetLastError());
+    ok(ret, "TerminateProcess error %ld\n", GetLastError());
     /* Checking process state without waiting for process termination
      * leads to different results due to a race condition.
      */
     ret = WaitForSingleObject(pi.hProcess, 1000);
-    ok(ret == WAIT_OBJECT_0, "WaitForSingleObject failed: %x\n", ret);
+    ok(ret == WAIT_OBJECT_0, "WaitForSingleObject failed: %lx\n", ret);
 
     SetLastError(0xdeadbeef);
     process = OpenProcess(PROCESS_ALL_ACCESS_NT4, FALSE, pi.dwProcessId);
-    ok(process != NULL, "OpenProcess error %d\n", GetLastError());
+    ok(process != NULL, "OpenProcess error %ld\n", GetLastError());
     CloseHandle(process);
 
     memset(&pbi, 0, sizeof(pbi));
     ret = pNtQueryInformationProcess(pi.hProcess, ProcessBasicInformation, &pbi, sizeof(pbi), NULL);
-    ok(!ret, "NtQueryInformationProcess error %#x\n", ret);
-    ok(pbi.ExitStatus == 198, "expected 198, got %lu\n", pbi.ExitStatus);
+    ok(!ret, "NtQueryInformationProcess error %#lx\n", ret);
+    ok(pbi.ExitStatus == 198, "expected 198, got %Iu\n", pbi.ExitStatus);
     affinity = 1;
     ret = pNtSetInformationProcess(pi.hProcess, ProcessAffinityMask, &affinity, sizeof(affinity));
-    ok(ret == STATUS_PROCESS_IS_TERMINATING, "expected STATUS_PROCESS_IS_TERMINATING, got %#x\n", ret);
+    ok(ret == STATUS_PROCESS_IS_TERMINATING, "expected STATUS_PROCESS_IS_TERMINATING, got %#lx\n", ret);
 
     SetLastError(0xdeadbeef);
     ctx.ContextFlags = CONTEXT_INTEGER;
@@ -3449,7 +3449,7 @@ static void test_ExitProcess(void)
            GetLastError() == ERROR_GEN_FAILURE /* win7 64-bit */ ||
            GetLastError() == ERROR_INVALID_FUNCTION /* vista 64-bit */ ||
            GetLastError() == ERROR_ACCESS_DENIED /* Win10 32-bit */,
-           "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+           "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     ctx.ContextFlags = CONTEXT_INTEGER;
     ret = SetThreadContext(thread, &ctx);
@@ -3458,10 +3458,10 @@ static void test_ExitProcess(void)
         ok(GetLastError() == ERROR_ACCESS_DENIED ||
            GetLastError() == ERROR_GEN_FAILURE /* win7 64-bit */ ||
            GetLastError() == ERROR_INVALID_FUNCTION /* vista 64-bit */,
-           "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+           "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = SetThreadPriority(thread, 0);
-    ok(ret, "SetThreadPriority error %d\n", GetLastError());
+    ok(ret, "SetThreadPriority error %ld\n", GetLastError());
     CloseHandle(thread);
 
     SetLastError(0xdeadbeef);
@@ -3473,7 +3473,7 @@ static void test_ExitProcess(void)
            GetLastError() == ERROR_GEN_FAILURE /* win7 64-bit */ ||
            GetLastError() == ERROR_INVALID_FUNCTION /* vista 64-bit */ ||
            GetLastError() == ERROR_ACCESS_DENIED /* Win10 32-bit */,
-           "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+           "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     ctx.ContextFlags = CONTEXT_INTEGER;
     ret = SetThreadContext(pi.hThread, &ctx);
@@ -3482,30 +3482,30 @@ static void test_ExitProcess(void)
         ok(GetLastError() == ERROR_ACCESS_DENIED ||
            GetLastError() == ERROR_GEN_FAILURE /* win7 64-bit */ ||
            GetLastError() == ERROR_INVALID_FUNCTION /* vista 64-bit */,
-           "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+           "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = VirtualProtectEx(pi.hProcess, addr, 4096, PAGE_READWRITE, &old_prot);
     ok(!ret, "VirtualProtectEx should fail\n");
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     size = 0;
     ret = ReadProcessMemory(pi.hProcess, addr, buf, 4, &size);
     ok(!ret, "ReadProcessMemory should fail\n");
     ok(GetLastError() == ERROR_PARTIAL_COPY || GetLastError() == ERROR_ACCESS_DENIED,
-       "expected ERROR_PARTIAL_COPY, got %d\n", GetLastError());
-    ok(!size, "expected 0, got %lu\n", size);
+       "expected ERROR_PARTIAL_COPY, got %ld\n", GetLastError());
+    ok(!size, "expected 0, got %Iu\n", size);
     SetLastError(0xdeadbeef);
     ret = VirtualFreeEx(pi.hProcess, addr, 0, MEM_RELEASE);
     ok(!ret, "VirtualFreeEx should fail\n");
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     addr = VirtualAllocEx(pi.hProcess, NULL, 4096, MEM_COMMIT, PAGE_READWRITE);
     ok(!addr, "VirtualAllocEx should fail\n");
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     size = VirtualQueryEx(pi.hProcess, NULL, &mbi, sizeof(mbi));
     ok(!size, "VirtualQueryEx should fail\n");
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
 
     /* CloseHandle() call below leads to premature process termination
      * under some Windows versions.
@@ -3521,7 +3521,7 @@ if (0)
     ret = DuplicateHandle(GetCurrentProcess(), hmap, pi.hProcess, &hmap_dup,
                           0, FALSE, DUPLICATE_SAME_ACCESS);
     ok(!ret, "DuplicateHandle should fail\n");
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
 
     offset.u.LowPart = 0;
     offset.u.HighPart = 0;
@@ -3529,27 +3529,27 @@ if (0)
     size = 0;
     ret = pNtMapViewOfSection(hmap, pi.hProcess, &addr, 0, 0, &offset,
                               &size, 1 /* ViewShare */, 0, PAGE_READONLY);
-    ok(ret == STATUS_PROCESS_IS_TERMINATING, "expected STATUS_PROCESS_IS_TERMINATING, got %#x\n", ret);
+    ok(ret == STATUS_PROCESS_IS_TERMINATING, "expected STATUS_PROCESS_IS_TERMINATING, got %#lx\n", ret);
 
     SetLastError(0xdeadbeef);
     thread = CreateRemoteThread(pi.hProcess, NULL, 0, (void *)0xdeadbeef, NULL, CREATE_SUSPENDED, &ret);
     ok(!thread, "CreateRemoteThread should fail\n");
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = DebugActiveProcess(pi.dwProcessId);
     ok(!ret, "DebugActiveProcess should fail\n");
     ok(GetLastError() == ERROR_ACCESS_DENIED /* 64-bit */ || GetLastError() == ERROR_NOT_SUPPORTED /* 32-bit */,
-      "ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+      "ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
 
     GetExitCodeProcess(pi.hProcess, &ret);
     ok(ret == 198 || broken(ret != 198) /* some 32-bit XP version in a VM returns random exit code */,
-       "expected exit code 198, got %u\n", ret);
+       "expected exit code 198, got %lu\n", ret);
     CloseHandle(pi.hThread);
     CloseHandle(pi.hProcess);
 
     ret = DeleteFileA(dll_name);
-    ok(ret, "DeleteFile error %d\n", GetLastError());
+    ok(ret, "DeleteFile error %ld\n", GetLastError());
 #else
     skip("x86 specific ExitProcess test\n");
 #endif
@@ -3557,32 +3557,32 @@ if (0)
 
 static PVOID WINAPI failuredllhook(ULONG ul, DELAYLOAD_INFO* pd)
 {
-    ok(ul == 4, "expected 4, got %u\n", ul);
+    ok(ul == 4, "expected 4, got %lu\n", ul);
     ok(!!pd, "no delayload info supplied\n");
     if (pd)
     {
-        ok(pd->Size == sizeof(*pd), "got %u\n", pd->Size);
+        ok(pd->Size == sizeof(*pd), "got %lu\n", pd->Size);
         ok(!!pd->DelayloadDescriptor, "no DelayloadDescriptor supplied\n");
         if (pd->DelayloadDescriptor)
         {
             ok(pd->DelayloadDescriptor->Attributes.AllAttributes == 1,
-               "expected 1, got %u\n", pd->DelayloadDescriptor->Attributes.AllAttributes);
+               "expected 1, got %lu\n", pd->DelayloadDescriptor->Attributes.AllAttributes);
             ok(pd->DelayloadDescriptor->DllNameRVA == 0x2000,
-               "expected 0x2000, got %x\n", pd->DelayloadDescriptor->DllNameRVA);
+               "expected 0x2000, got %lx\n", pd->DelayloadDescriptor->DllNameRVA);
             ok(pd->DelayloadDescriptor->ModuleHandleRVA == 0x201a,
-               "expected 0x201a, got %x\n", pd->DelayloadDescriptor->ModuleHandleRVA);
+               "expected 0x201a, got %lx\n", pd->DelayloadDescriptor->ModuleHandleRVA);
             ok(pd->DelayloadDescriptor->ImportAddressTableRVA > pd->DelayloadDescriptor->ModuleHandleRVA,
-               "expected %x > %x\n", pd->DelayloadDescriptor->ImportAddressTableRVA,
+               "expected %lx > %lx\n", pd->DelayloadDescriptor->ImportAddressTableRVA,
                pd->DelayloadDescriptor->ModuleHandleRVA);
             ok(pd->DelayloadDescriptor->ImportNameTableRVA > pd->DelayloadDescriptor->ImportAddressTableRVA,
-               "expected %x > %x\n", pd->DelayloadDescriptor->ImportNameTableRVA,
+               "expected %lx > %lx\n", pd->DelayloadDescriptor->ImportNameTableRVA,
                pd->DelayloadDescriptor->ImportAddressTableRVA);
             ok(pd->DelayloadDescriptor->BoundImportAddressTableRVA == 0,
-               "expected 0, got %x\n", pd->DelayloadDescriptor->BoundImportAddressTableRVA);
+               "expected 0, got %lx\n", pd->DelayloadDescriptor->BoundImportAddressTableRVA);
             ok(pd->DelayloadDescriptor->UnloadInformationTableRVA == 0,
-               "expected 0, got %x\n", pd->DelayloadDescriptor->UnloadInformationTableRVA);
+               "expected 0, got %lx\n", pd->DelayloadDescriptor->UnloadInformationTableRVA);
             ok(pd->DelayloadDescriptor->TimeDateStamp == 0,
-               "expected 0, got %x\n", pd->DelayloadDescriptor->TimeDateStamp);
+               "expected 0, got %lx\n", pd->DelayloadDescriptor->TimeDateStamp);
         }
 
         ok(!!pd->ThunkAddress, "no ThunkAddress supplied\n");
@@ -3595,10 +3595,10 @@ static PVOID WINAPI failuredllhook(ULONG ul, DELAYLOAD_INFO* pd)
                "expected \"secur32.dll\", got \"%s\"\n", pd->TargetDllName);
 
         ok(pd->TargetApiDescriptor.ImportDescribedByName == 0,
-           "expected 0, got %x\n", pd->TargetApiDescriptor.ImportDescribedByName);
+           "expected 0, got %lx\n", pd->TargetApiDescriptor.ImportDescribedByName);
         ok(pd->TargetApiDescriptor.Description.Ordinal == 0 ||
            pd->TargetApiDescriptor.Description.Ordinal == 999,
-           "expected 0, got %x\n", pd->TargetApiDescriptor.Description.Ordinal);
+           "expected 0, got %lx\n", pd->TargetApiDescriptor.Description.Ordinal);
 
         ok(!!pd->TargetModuleBase, "no TargetModuleBase supplied\n");
         ok(pd->Unused == NULL, "expected NULL, got %p\n", pd->Unused);
@@ -3666,13 +3666,13 @@ static void test_ResolveDelayLoadedAPI(void)
         SetLastError(0xdeadbeef);
         ok(!pResolveDelayLoadedAPI(NULL, NULL, NULL, NULL, NULL, 0),
            "ResolveDelayLoadedAPI succeeded\n");
-        ok(GetLastError() == 0xdeadbeef, "GetLastError changed to %x\n", GetLastError());
+        ok(GetLastError() == 0xdeadbeef, "GetLastError changed to %lx\n", GetLastError());
 
         cb_count = 0;
         SetLastError(0xdeadbeef);
         ok(!pResolveDelayLoadedAPI(NULL, NULL, failuredllhook, NULL, NULL, 0),
            "ResolveDelayLoadedAPI succeeded\n");
-        ok(GetLastError() == 0xdeadbeef, "GetLastError changed to %x\n", GetLastError());
+        ok(GetLastError() == 0xdeadbeef, "GetLastError changed to %lx\n", GetLastError());
         ok(cb_count == 1, "Wrong callback count: %d\n", cb_count);
     }
 
@@ -3688,7 +3688,7 @@ static void test_ResolveDelayLoadedAPI(void)
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, &dos_header, sizeof(dos_header), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     nt_header = nt_header_template;
     nt_header.FileHeader.NumberOfSections = 2;
@@ -3704,11 +3704,11 @@ static void test_ResolveDelayLoadedAPI(void)
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, &nt_header, sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, &nt_header.OptionalHeader, sizeof(IMAGE_OPTIONAL_HEADER), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     /* sections */
     section.PointerToRawData = nt_header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT].VirtualAddress;
@@ -3718,7 +3718,7 @@ static void test_ResolveDelayLoadedAPI(void)
     section.Characteristics = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ;
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, &section, sizeof(section), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     section.PointerToRawData = 0x2000;
     section.VirtualAddress = 0x2000;
@@ -3730,7 +3730,7 @@ static void test_ResolveDelayLoadedAPI(void)
     section.Characteristics = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE;
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, &section, sizeof(section), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     /* fill up to delay data */
     SetFilePointer( hfile, nt_header.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT].VirtualAddress, NULL, SEEK_SET );
@@ -3747,11 +3747,11 @@ static void test_ResolveDelayLoadedAPI(void)
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, &idd, sizeof(idd), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, filler, sizeof(idd), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     /* fill up to extended delay data */
     SetFilePointer( hfile, idd.DllNameRVA, NULL, SEEK_SET );
@@ -3759,15 +3759,15 @@ static void test_ResolveDelayLoadedAPI(void)
     /* extended delay data */
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, test_dll, sizeof(test_dll), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, &hint, sizeof(hint), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, test_func, sizeof(test_func), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     SetFilePointer( hfile, idd.ImportAddressTableRVA, NULL, SEEK_SET );
 
@@ -3777,13 +3777,13 @@ static void test_ResolveDelayLoadedAPI(void)
         itd32.u1.Function = nt_header.OptionalHeader.ImageBase + 0x1a00 + i * 0x20;
         SetLastError(0xdeadbeef);
         ret = WriteFile(hfile, &itd32, sizeof(itd32), &dummy, NULL);
-        ok(ret, "WriteFile error %d\n", GetLastError());
+        ok(ret, "WriteFile error %ld\n", GetLastError());
     }
 
     itd32.u1.Function = 0;
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, &itd32, sizeof(itd32), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     for (i = 0; i < ARRAY_SIZE(td); i++)
     {
@@ -3793,13 +3793,13 @@ static void test_ResolveDelayLoadedAPI(void)
             itd32.u1.Ordinal = td[i].ordinal;
         SetLastError(0xdeadbeef);
         ret = WriteFile(hfile, &itd32, sizeof(itd32), &dummy, NULL);
-        ok(ret, "WriteFile error %d\n", GetLastError());
+        ok(ret, "WriteFile error %ld\n", GetLastError());
     }
 
     itd32.u1.Ordinal = 0;
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, &itd32, sizeof(itd32), &dummy, NULL);
-    ok(ret, "WriteFile error %d\n", GetLastError());
+    ok(ret, "WriteFile error %ld\n", GetLastError());
 
     /* fill up to eof */
     SetFilePointer( hfile, section.VirtualAddress + section.Misc.VirtualSize, NULL, SEEK_SET );
@@ -3808,7 +3808,7 @@ static void test_ResolveDelayLoadedAPI(void)
 
     SetLastError(0xdeadbeef);
     hlib = LoadLibraryA(dll_name);
-    ok(hlib != NULL, "LoadLibrary error %u\n", GetLastError());
+    ok(hlib != NULL, "LoadLibrary error %lu\n", GetLastError());
     if (!hlib)
     {
         skip("couldn't load %s.\n", dll_name);
@@ -3855,18 +3855,18 @@ static void test_ResolveDelayLoadedAPI(void)
             ret = pResolveDelayLoadedAPI(hlib, delaydir, NULL, failuresyshook, &itda[i], 0);
             if (td[i].succeeds)
             {
-                ok(ret != NULL, "Test %u: ResolveDelayLoadedAPI failed\n", i);
-                ok(ret == load, "Test %u: expected %p, got %p\n", i, load, ret);
-                ok(ret == (void*)itda[i].u1.AddressOfData, "Test %u: expected %p, got %p\n",
+                ok(ret != NULL, "Test %lu: ResolveDelayLoadedAPI failed\n", i);
+                ok(ret == load, "Test %lu: expected %p, got %p\n", i, load, ret);
+                ok(ret == (void*)itda[i].u1.AddressOfData, "Test %lu: expected %p, got %p\n",
                    i, ret, (void*)itda[i].u1.AddressOfData);
-                ok(!cb_count, "Test %u: Wrong callback count: %d\n", i, cb_count);
-                ok(!cb_count_sys, "Test %u: Wrong sys callback count: %d\n", i, cb_count_sys);
+                ok(!cb_count, "Test %lu: Wrong callback count: %d\n", i, cb_count);
+                ok(!cb_count_sys, "Test %lu: Wrong sys callback count: %d\n", i, cb_count_sys);
             }
             else
             {
-                ok(ret == (void*)0x12345678, "Test %u: ResolveDelayLoadedAPI succeeded with %p\n", i, ret);
-                ok(!cb_count, "Test %u: Wrong callback count: %d\n", i, cb_count);
-                ok(cb_count_sys == 1, "Test %u: Wrong sys callback count: %d\n", i, cb_count_sys);
+                ok(ret == (void*)0x12345678, "Test %lu: ResolveDelayLoadedAPI succeeded with %p\n", i, ret);
+                ok(!cb_count, "Test %lu: Wrong callback count: %d\n", i, cb_count);
+                ok(cb_count_sys == 1, "Test %lu: Wrong sys callback count: %d\n", i, cb_count_sys);
             }
 
             /* test with failure dll callback */
@@ -3874,28 +3874,28 @@ static void test_ResolveDelayLoadedAPI(void)
             ret = pResolveDelayLoadedAPI(hlib, delaydir, failuredllhook, failuresyshook, &itda[i], 0);
             if (td[i].succeeds)
             {
-                ok(ret != NULL, "Test %u: ResolveDelayLoadedAPI failed\n", i);
-                ok(ret == load, "Test %u: expected %p, got %p\n", i, load, ret);
-                ok(ret == (void*)itda[i].u1.AddressOfData, "Test %u: expected %p, got %p\n",
+                ok(ret != NULL, "Test %lu: ResolveDelayLoadedAPI failed\n", i);
+                ok(ret == load, "Test %lu: expected %p, got %p\n", i, load, ret);
+                ok(ret == (void*)itda[i].u1.AddressOfData, "Test %lu: expected %p, got %p\n",
                    i, ret, (void*)itda[i].u1.AddressOfData);
-                ok(!cb_count, "Test %u: Wrong callback count: %d\n", i, cb_count);
-                ok(!cb_count_sys, "Test %u: Wrong sys callback count: %d\n", i, cb_count_sys);
+                ok(!cb_count, "Test %lu: Wrong callback count: %d\n", i, cb_count);
+                ok(!cb_count_sys, "Test %lu: Wrong sys callback count: %d\n", i, cb_count_sys);
             }
             else
             {
                 if (ret == (void*)0x12345678)
                 {
                     /* Win10+ sometimes buffers the address of the stub function */
-                    ok(!cb_count, "Test %u: Wrong callback count: %d\n", i, cb_count);
-                    ok(!cb_count_sys, "Test %u: Wrong sys callback count: %d\n", i, cb_count_sys);
+                    ok(!cb_count, "Test %lu: Wrong callback count: %d\n", i, cb_count);
+                    ok(!cb_count_sys, "Test %lu: Wrong sys callback count: %d\n", i, cb_count_sys);
                 }
                 else if (ret == (void*)0xdeadbeef)
                 {
-                    ok(cb_count == 1, "Test %u: Wrong callback count: %d\n", i, cb_count);
-                    ok(!cb_count_sys, "Test %u: Wrong sys callback count: %d\n", i, cb_count_sys);
+                    ok(cb_count == 1, "Test %lu: Wrong callback count: %d\n", i, cb_count);
+                    ok(!cb_count_sys, "Test %lu: Wrong sys callback count: %d\n", i, cb_count_sys);
                 }
                 else
-                    ok(0, "Test %u: ResolveDelayLoadedAPI succeeded with %p\n", i, ret);
+                    ok(0, "Test %lu: ResolveDelayLoadedAPI succeeded with %p\n", i, ret);
             }
         }
         delaydir++;
@@ -3983,26 +3983,26 @@ static void test_dll_file( const char *name )
 
     GetModuleFileNameA( module, path, MAX_PATH );
     file = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
-    ok( file != INVALID_HANDLE_VALUE, "can't open '%s': %u\n", path, GetLastError() );
+    ok( file != INVALID_HANDLE_VALUE, "can't open '%s': %lu\n", path, GetLastError() );
 
     mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 0, NULL );
-    ok( mapping != NULL, "%s: CreateFileMappingW failed err %u\n", name, GetLastError() );
+    ok( mapping != NULL, "%s: CreateFileMappingW failed err %lu\n", name, GetLastError() );
     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 );
-    ok( ptr != NULL, "%s: MapViewOfFile failed err %u\n", name, GetLastError() );
+    ok( ptr != NULL, "%s: MapViewOfFile failed err %lu\n", name, GetLastError() );
     CloseHandle( mapping );
     CloseHandle( file );
 
     nt = pRtlImageNtHeader( module );
     nt_file = pRtlImageNtHeader( ptr );
     ok( nt_file != NULL, "%s: invalid header\n", path );
-#define OK_FIELD(x) ok( nt->x == nt_file->x, "%s:%u: wrong " #x " %x / %x\n", name, i, nt->x, nt_file->x )
-    OK_FIELD( FileHeader.NumberOfSections );
-    OK_FIELD( OptionalHeader.AddressOfEntryPoint );
-    OK_FIELD( OptionalHeader.NumberOfRvaAndSizes );
+#define OK_FIELD(x, f) ok( nt->x == nt_file->x, "%s:%u: wrong " #x " " f " / " f "\n", name, i, nt->x, nt_file->x )
+    OK_FIELD( FileHeader.NumberOfSections, "%x" );
+    OK_FIELD( OptionalHeader.AddressOfEntryPoint, "%lx" );
+    OK_FIELD( OptionalHeader.NumberOfRvaAndSizes, "%lx" );
     for (i = 0; i < nt->OptionalHeader.NumberOfRvaAndSizes; i++)
     {
-        OK_FIELD( OptionalHeader.DataDirectory[i].VirtualAddress );
-        OK_FIELD( OptionalHeader.DataDirectory[i].Size );
+        OK_FIELD( OptionalHeader.DataDirectory[i].VirtualAddress, "%lx" );
+        OK_FIELD( OptionalHeader.DataDirectory[i].Size, "%lx" );
     }
     sec = (IMAGE_SECTION_HEADER *)((char *)&nt->OptionalHeader + nt->FileHeader.SizeOfOptionalHeader);
     sec_file = (IMAGE_SECTION_HEADER *)((char *)&nt_file->OptionalHeader + nt_file->FileHeader.SizeOfOptionalHeader);
@@ -4024,7 +4024,7 @@ static void test_LoadPackagedLibrary(void)
 
     SetLastError( 0xdeadbeef );
     h = pLoadPackagedLibrary(L"kernel32.dll", 0);
-    ok(!h && GetLastError() == APPMODEL_ERROR_NO_PACKAGE, "Got unexpected handle %p, GetLastError() %u.\n",
+    ok(!h && GetLastError() == APPMODEL_ERROR_NO_PACKAGE, "Got unexpected handle %p, GetLastError() %lu.\n",
             h, GetLastError());
 }
 
@@ -4049,7 +4049,7 @@ static void test_Wow64Transition(void)
 
     status = NtQueryVirtualMemory(GetCurrentProcess(), *pWow64Transition,
                                   MemoryMappedFilenameInformation, name, sizeof(buffer), NULL);
-    ok(!status, "got %#x\n", status);
+    ok(!status, "got %#lx\n", status);
     filepart = name->SectionFileName.Buffer + name->SectionFileName.Length / sizeof(WCHAR);
     while (*filepart != '\\') --filepart;
     ok(!wcsnicmp(filepart, L"\\wow64cpu.dll", wcslen(L"\\wow64cpu.dll")), "got file name %s\n",
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c
index 8f48b89334c..ee9aad33312 100644
--- a/dlls/kernel32/tests/locale.c
+++ b/dlls/kernel32/tests/locale.c
@@ -165,20 +165,20 @@ static void expect_str_(int line, int ret, const char *str, const char *expected
 {
   if (ret)
   {
-    ok_(__FILE__, line)(GetLastError() == 0xdeadbeef, "unexpected gle %u\n", GetLastError());
-    ok_(__FILE__, line)(ret == strlen(expected) + 1, "Expected ret %d, got %d\n", strlen(expected) + 1, ret);
+    ok_(__FILE__, line)(GetLastError() == 0xdeadbeef, "unexpected gle %lu\n", GetLastError());
+    ok_(__FILE__, line)(ret == strlen(expected) + 1, "Expected ret %Id, got %d\n", strlen(expected) + 1, ret);
     if (str)
       ok_(__FILE__, line)(strcmp(str, expected) == 0, "Expected '%s', got '%s'\n", expected, str);
   }
   else
-    ok_(__FILE__, line)(0, "expected success, got error %d\n", GetLastError());
+    ok_(__FILE__, line)(0, "expected success, got error %ld\n", GetLastError());
 }
 
 #define expect_err(r,s,e) expect_err_(__LINE__, r, s, e, #e)
 static void expect_err_(int line, int ret, const char *str, DWORD err, const char* err_name)
 {
   ok_(__FILE__, line)(!ret && GetLastError() == err,
-      "Expected %s, got %d and ret=%d\n", err_name, GetLastError(), ret);
+      "Expected %s, got %ld and ret=%d\n", err_name, GetLastError(), ret);
   if (str)
     ok_(__FILE__, line)(strcmp(str, "pristine") == 0, "Expected a pristine buffer, got '%s'\n", str);
 }
@@ -188,20 +188,20 @@ static void expect_wstr_(int line, int ret, const WCHAR *str, const WCHAR *expec
 {
   if (ret)
   {
-    ok_(__FILE__, line)(GetLastError() == 0xdeadbeef, "unexpected gle %u\n", GetLastError());
-    ok_(__FILE__, line)(ret == wcslen(expected) + 1, "Expected ret %d, got %d\n", wcslen(expected) + 1, ret);
+    ok_(__FILE__, line)(GetLastError() == 0xdeadbeef, "unexpected gle %lu\n", GetLastError());
+    ok_(__FILE__, line)(ret == wcslen(expected) + 1, "Expected ret %Id, got %d\n", wcslen(expected) + 1, ret);
     if (str)
         ok_(__FILE__, line)(wcscmp(str, expected) == 0, "Expected %s, got %s\n", wine_dbgstr_w(expected), wine_dbgstr_w(str));
   }
   else
-    ok_(__FILE__, line)(0, "expected success, got error %d\n", GetLastError());
+    ok_(__FILE__, line)(0, "expected success, got error %ld\n", GetLastError());
 }
 
 #define expect_werr(r,s,e) expect_werr_(__LINE__, r, s, e, #e)
 static void expect_werr_(int line, int ret, const WCHAR *str, DWORD err, const char* err_name)
 {
   ok_(__FILE__, line)(!ret && GetLastError() == err,
-      "Expected %s, got %d and ret=%d\n", err_name, GetLastError(), ret);
+      "Expected %s, got %ld and ret=%d\n", err_name, GetLastError(), ret);
   if (str)
       ok_(__FILE__, line)(wcscmp(str, L"pristine") == 0, "Expected a pristine buffer, got %s\n", wine_dbgstr_w(str));
 }
@@ -217,11 +217,11 @@ static void test_GetLocaleInfoA(void)
   char expected[BUFFER_SIZE];
   DWORD val;
 
-  ok(lcid == 0x409, "wrong LCID calculated - %d\n", lcid);
+  ok(lcid == 0x409, "wrong LCID calculated - %ld\n", lcid);
 
   ret = GetLocaleInfoA(lcid, LOCALE_ILANGUAGE|LOCALE_RETURN_NUMBER, (char*)&val, sizeof(val));
   ok(ret, "got %d\n", ret);
-  ok(val == lcid, "got 0x%08x\n", val);
+  ok(val == lcid, "got 0x%08lx\n", val);
 
   /* en and ar use SUBLANG_NEUTRAL, but GetLocaleInfo assume SUBLANG_DEFAULT
      Same is true for zh on pre-Vista, but on Vista and higher GetLocaleInfo
@@ -271,13 +271,13 @@ static void test_GetLocaleInfoA(void)
   memset(buffer, 0, ARRAY_SIZE(buffer));
   ret = GetLocaleInfoA(lcid, NUO|LOCALE_SDAYNAME1, buffer, 3);
   ok( !ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-      "Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
+      "Expected ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
   ok(!strcmp(buffer, "Mon"), "Expected 'Mon', got '%s'\n", buffer);
 
   SetLastError(0xdeadbeef);
   memset(buffer, 0, ARRAY_SIZE(buffer));
   ret = GetLocaleInfoA(lcid, NUO|LOCALE_SDAYNAME1, buffer, 10);
-  ok(ret == 7, "Expected ret == 7, got %d, error %d\n", ret, GetLastError());
+  ok(ret == 7, "Expected ret == 7, got %d, error %ld\n", ret, GetLastError());
   ok(!strcmp(buffer, "Monday"), "Expected 'Monday', got '%s'\n", buffer);
 }
 
@@ -341,8 +341,8 @@ static void test_GetLocaleInfoW(void)
   }
 
   ret = GetLocaleInfoW(lcid_en, LOCALE_ILANGUAGE|LOCALE_RETURN_NUMBER, (WCHAR*)&val, sizeof(val)/sizeof(WCHAR));
-  ok(ret, "got %d\n", ret);
-  ok(val == lcid_en, "got 0x%08x\n", val);
+  ok(ret, "got %ld\n", ret);
+  ok(val == lcid_en, "got 0x%08lx\n", val);
 
   ret = GetLocaleInfoW(lcid_en_neut, LOCALE_SNAME, bufferW, ARRAY_SIZE(bufferW));
   if (ret)
@@ -356,7 +356,7 @@ static void test_GetLocaleInfoW(void)
       ok(!lstrcmpW(bufferW, enW), "got wrong name %s\n", wine_dbgstr_w(bufferW));
 
       ret = GetLocaleInfoW(lcid_en_neut, LOCALE_SCOUNTRY, bufferW, ARRAY_SIZE(bufferW));
-      ok(ret, "got %d\n", ret);
+      ok(ret, "got %ld\n", ret);
       if ((PRIMARYLANGID(LANGIDFROMLCID(GetSystemDefaultLCID())) != LANG_ENGLISH) ||
           (PRIMARYLANGID(LANGIDFROMLCID(GetThreadLocale())) != LANG_ENGLISH))
       {
@@ -366,7 +366,7 @@ static void test_GetLocaleInfoW(void)
           ok(!lstrcmpW(statesW, bufferW), "got wrong name %s\n", wine_dbgstr_w(bufferW));
 
       ret = GetLocaleInfoW(lcid_en_neut, LOCALE_SLANGUAGE, bufferW, ARRAY_SIZE(bufferW));
-      ok(ret, "got %d\n", ret);
+      ok(ret, "got %ld\n", ret);
       if ((PRIMARYLANGID(LANGIDFROMLCID(GetSystemDefaultLCID())) != LANG_ENGLISH) ||
           (PRIMARYLANGID(LANGIDFROMLCID(GetThreadLocale())) != LANG_ENGLISH))
       {
@@ -386,7 +386,7 @@ static void test_GetLocaleInfoW(void)
 
           val = 0;
           GetLocaleInfoW(lcid, LOCALE_ILANGUAGE|LOCALE_RETURN_NUMBER, (WCHAR*)&val, sizeof(val)/sizeof(WCHAR));
-          ok(val == ptr->lcid || (val && broken(val == ptr->lcid_broken)), "%s: got wrong lcid 0x%04x, expected 0x%04x\n",
+          ok(val == ptr->lcid || (val && broken(val == ptr->lcid_broken)), "%s: got wrong lcid 0x%04lx, expected 0x%04lx\n",
              wine_dbgstr_w(ptr->name), val, ptr->lcid);
 
           /* now check LOCALE_SNAME */
@@ -420,16 +420,16 @@ static void test_GetLocaleInfoW(void)
   ok(ret == 0, "LOCALE_RETURN_GENITIVE_NAMES should fail with GetLocaleInfoA\n");
   ok(bufferA[0] == 'a', "Expected buffer to be untouched\n");
   ok(GetLastError() == ERROR_INVALID_FLAGS,
-     "Expected ERROR_INVALID_FLAGS, got %x\n", GetLastError());
+     "Expected ERROR_INVALID_FLAGS, got %lx\n", GetLastError());
 
   bufferW[0] = 'a';
   SetLastError(0xdeadbeef);
   ret = GetLocaleInfoW(lcid_ru, LOCALE_RETURN_GENITIVE_NAMES, bufferW, ARRAY_SIZE(bufferW));
   ok(ret == 0,
-     "LOCALE_RETURN_GENITIVE_NAMES itself doesn't return anything, got %d\n", ret);
+     "LOCALE_RETURN_GENITIVE_NAMES itself doesn't return anything, got %ld\n", ret);
   ok(bufferW[0] == 'a', "Expected buffer to be untouched\n");
   ok(GetLastError() == ERROR_INVALID_FLAGS,
-     "Expected ERROR_INVALID_FLAGS, got %x\n", GetLastError());
+     "Expected ERROR_INVALID_FLAGS, got %lx\n", GetLastError());
 
   /* yes, test empty 13 month entry too */
   for (i = 0; i < 12; i++) {
@@ -437,12 +437,12 @@ static void test_GetLocaleInfoW(void)
       ret = GetLocaleInfoW(lcid_ru, (LOCALE_SMONTHNAME1+i)|LOCALE_RETURN_GENITIVE_NAMES,
                            bufferW, ARRAY_SIZE(bufferW));
       ok(ret, "Expected non zero result\n");
-      ok(ret == lstrlenW(bufferW)+1, "Expected actual length, got %d, length %d\n",
+      ok(ret == lstrlenW(bufferW)+1, "Expected actual length, got %ld, length %d\n",
                                     ret, lstrlenW(bufferW));
       buffer2W[0] = 0;
       ret = GetLocaleInfoW(lcid_ru, LOCALE_SMONTHNAME1+i, buffer2W, ARRAY_SIZE(buffer2W));
       ok(ret, "Expected non zero result\n");
-      ok(ret == lstrlenW(buffer2W)+1, "Expected actual length, got %d, length %d\n",
+      ok(ret == lstrlenW(buffer2W)+1, "Expected actual length, got %ld, length %d\n",
                                     ret, lstrlenW(buffer2W));
 
       ok(lstrcmpW(bufferW, buffer2W) != 0,
@@ -453,12 +453,12 @@ static void test_GetLocaleInfoW(void)
       ret = GetLocaleInfoW(lcid_en, (LOCALE_SMONTHNAME1+i)|LOCALE_RETURN_GENITIVE_NAMES,
                            bufferW, ARRAY_SIZE(bufferW));
       ok(ret, "Expected non zero result\n");
-      ok(ret == lstrlenW(bufferW)+1, "Expected actual length, got %d, length %d\n",
+      ok(ret == lstrlenW(bufferW)+1, "Expected actual length, got %ld, length %d\n",
                                     ret, lstrlenW(bufferW));
       buffer2W[0] = 0;
       ret = GetLocaleInfoW(lcid_en, LOCALE_SMONTHNAME1+i, buffer2W, ARRAY_SIZE(buffer2W));
       ok(ret, "Expected non zero result\n");
-      ok(ret == lstrlenW(buffer2W)+1, "Expected actual length, got %d, length %d\n",
+      ok(ret == lstrlenW(buffer2W)+1, "Expected actual length, got %ld, length %d\n",
                                     ret, lstrlenW(buffer2W));
 
       ok(lstrcmpW(bufferW, buffer2W) == 0,
@@ -885,7 +885,7 @@ static void test_GetDateFormatA(void)
 
   /* DATE_LONGDATE */
   ret = GetDateFormatA(lcid, NUO|DATE_LONGDATE, &curtime, NULL, buffer, ARRAY_SIZE(buffer));
-  ok(ret, "Expected ret != 0, got %d, error %d\n", ret, GetLastError());
+  ok(ret, "Expected ret != 0, got %d, error %ld\n", ret, GetLastError());
   ok(strcmp(buffer, "Saturday, May 04, 2002") == 0 ||
      strcmp(buffer, "Saturday, May 4, 2002") == 0 /* Win 8 */,
      "got an unexpected date string '%s'\n", buffer);
@@ -913,12 +913,12 @@ static void test_GetDateFormatA(void)
   /* month part should be in genitive form */
   strcpy(genitive_month, buffer + 2);
   ret = GetDateFormatA(lcid_ru, 0, &curtime, "MMMM", buffer, ARRAY_SIZE(buffer));
-  ok(ret, "Expected ret != 0, got %d, error %d\n", ret, GetLastError());
+  ok(ret, "Expected ret != 0, got %d, error %ld\n", ret, GetLastError());
   strcpy(month, buffer);
   ok(strcmp(genitive_month, month) != 0, "Expected different month forms\n");
 
   ret = GetDateFormatA(lcid_ru, 0, &curtime, "ddd", buffer, ARRAY_SIZE(buffer));
-  ok(ret, "Expected ret != 0, got %d, error %d\n", ret, GetLastError());
+  ok(ret, "Expected ret != 0, got %d, error %ld\n", ret, GetLastError());
   strcpy(short_day, buffer);
 
   ret = GetDateFormatA(lcid_ru, 0, &curtime, "dd MMMMddd dd", buffer, ARRAY_SIZE(buffer));
@@ -1724,7 +1724,7 @@ static void test_CompareStringA(void)
       ret = CompareStringA(entry->lcid, entry->flags, entry->first, entry->first_len,
           entry->second, entry->second_len);
       ok(ret == entry->ret, "%d: got %d, expected %d\n", i, ret, entry->ret);
-      ok(GetLastError() == (ret ? 0xdeadbeef : entry->le), "%d: got last error %d, expected %d\n",
+      ok(GetLastError() == (ret ? 0xdeadbeef : entry->le), "%d: got last error %ld, expected %ld\n",
           i, GetLastError(), (ret ? 0xdeadbeef : entry->le));
   }
 
@@ -1846,7 +1846,7 @@ static void test_CompareStringA(void)
     SetLastError(0xdeadbeef);
     ret = CompareStringA(lcid, 0, a, sizeof(a), a, sizeof(a));
     ok (GetLastError() == 0xdeadbeef && ret == CSTR_EQUAL,
-        "ret %d, error %d, expected value %d\n", ret, GetLastError(), CSTR_EQUAL);
+        "ret %d, error %ld, expected value %d\n", ret, GetLastError(), CSTR_EQUAL);
 
     ret = CompareStringA(CP_ACP, 0, ABC_EE, 3, ABC_FF, 3);
     ok(ret == CSTR_EQUAL, "expected CSTR_EQUAL, got %d\n", ret);
@@ -1876,11 +1876,11 @@ static void test_CompareStringW(void)
 
     GetSystemInfo(&si);
     buf = VirtualAlloc(NULL, si.dwPageSize * 4, MEM_COMMIT, PAGE_READWRITE);
-    ok(buf != NULL, "VirtualAlloc failed with %u\n", GetLastError());
+    ok(buf != NULL, "VirtualAlloc failed with %lu\n", GetLastError());
     success = VirtualProtect(buf + si.dwPageSize, si.dwPageSize, PAGE_NOACCESS, &old_prot);
-    ok(success, "VirtualProtect failed with %u\n", GetLastError());
+    ok(success, "VirtualProtect failed with %lu\n", GetLastError());
     success = VirtualProtect(buf + 3 * si.dwPageSize, si.dwPageSize, PAGE_NOACCESS, &old_prot);
-    ok(success, "VirtualProtect failed with %u\n", GetLastError());
+    ok(success, "VirtualProtect failed with %lu\n", GetLastError());
 
     str1 = (WCHAR *)(buf + si.dwPageSize - sizeof(WCHAR));
     str2 = (WCHAR *)(buf + 3 * si.dwPageSize - sizeof(WCHAR));
@@ -1892,12 +1892,12 @@ static void test_CompareStringW(void)
     ok(ret == CSTR_LESS_THAN, "expected CSTR_LESS_THAN, got %d\n", ret);
 
     success = VirtualFree(buf, 0, MEM_RELEASE);
-    ok(success, "VirtualFree failed with %u\n", GetLastError());
+    ok(success, "VirtualFree failed with %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = CompareStringW(CP_ACP, SORT_DIGITSASNUMBERS, L"NULL", -1, L"NULL", -1);
     ok(ret == CSTR_EQUAL || broken(!ret && GetLastError() == ERROR_INVALID_FLAGS) /* <Win7 */,
-        "expected CSTR_EQUAL, got %d, last error %d\n", ret, GetLastError());
+        "expected CSTR_EQUAL, got %d, last error %ld\n", ret, GetLastError());
 
     ret = CompareStringW(CP_ACP, 0, ABC_EE, 3, ABC_FF, 3);
     ok(ret == CSTR_EQUAL, "expected CSTR_EQUAL, got %d\n", ret);
@@ -2169,7 +2169,7 @@ static void test_LCMapStringA(void)
     ret = LCMapStringA(LOCALE_USER_DEFAULT, LOCALE_USE_CP_ACP | LCMAP_LOWERCASE,
                        lower_case, -1, buf, sizeof(buf));
     ok(ret == lstrlenA(lower_case) + 1,
-       "ret %d, error %d, expected value %d\n",
+       "ret %d, error %ld, expected value %d\n",
        ret, GetLastError(), lstrlenA(lower_case) + 1);
     ok(!memcmp(buf, lower_case, ret), "LCMapStringA should return %s, but not %s\n", lower_case, buf);
 
@@ -2177,7 +2177,7 @@ static void test_LCMapStringA(void)
                        upper_case, -1, buf, sizeof(buf));
     ok(!ret, "LCMAP_LOWERCASE and LCMAP_UPPERCASE are mutually exclusive\n");
     ok(GetLastError() == ERROR_INVALID_FLAGS,
-       "unexpected error code %d\n", GetLastError());
+       "unexpected error code %ld\n", GetLastError());
 
     /* test invalid flag combinations */
     for (i = 0; i < ARRAY_SIZE(lcmap_invalid_flags); i++) {
@@ -2186,9 +2186,9 @@ static void test_LCMapStringA(void)
         ret = LCMapStringA(LOCALE_USER_DEFAULT, lcmap_invalid_flags[i],
                            lower_case, -1, buf, sizeof(buf));
         ok(GetLastError() == ERROR_INVALID_FLAGS,
-           "LCMapStringA (flag %08x) unexpected error code %d\n",
+           "LCMapStringA (flag %08lx) unexpected error code %ld\n",
            lcmap_invalid_flags[i], GetLastError());
-        ok(!ret, "LCMapStringA (flag %08x) should return 0, got %d\n",
+        ok(!ret, "LCMapStringA (flag %08lx) should return 0, got %d\n",
            lcmap_invalid_flags[i], ret);
     }
 
@@ -2196,7 +2196,7 @@ static void test_LCMapStringA(void)
     ret = LCMapStringA(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE,
                        upper_case, -1, buf, sizeof(buf));
     ok(ret == lstrlenA(upper_case) + 1,
-       "ret %d, error %d, expected value %d\n",
+       "ret %d, error %ld, expected value %d\n",
        ret, GetLastError(), lstrlenA(upper_case) + 1);
     ok(!lstrcmpA(buf, lower_case), "LCMapStringA should return %s, but not %s\n", lower_case, buf);
 
@@ -2204,7 +2204,7 @@ static void test_LCMapStringA(void)
     ret = LCMapStringA(LOCALE_USER_DEFAULT, LCMAP_UPPERCASE,
                        lower_case, -1, buf, sizeof(buf));
     ok(ret == lstrlenA(lower_case) + 1,
-       "ret %d, error %d, expected value %d\n",
+       "ret %d, error %ld, expected value %d\n",
        ret, GetLastError(), lstrlenA(lower_case) + 1);
     ok(!lstrcmpA(buf, upper_case), "LCMapStringA should return %s, but not %s\n", upper_case, buf);
 
@@ -2224,7 +2224,7 @@ static void test_LCMapStringA(void)
     else
     {
         ok(ret == lstrlenA(lower_case) + 1,
-           "ret %d, error %d, expected value %d\n",
+           "ret %d, error %ld, expected value %d\n",
            ret, GetLastError(), lstrlenA(lower_case) + 1);
         ok(!lstrcmpA(buf, upper_case), "LCMapStringA should return %s, but not %s\n", upper_case, buf);
     }
@@ -2236,7 +2236,7 @@ static void test_LCMapStringA(void)
     else
     {
         ok(ret == lstrlenA(upper_case) + 1,
-           "ret %d, error %d, expected value %d\n",
+           "ret %d, error %ld, expected value %d\n",
            ret, GetLastError(), lstrlenA(lower_case) + 1);
         ok(!lstrcmpA(buf, lower_case), "LCMapStringA should return %s, but not %s\n", lower_case, buf);
     }
@@ -2247,7 +2247,7 @@ static void test_LCMapStringA(void)
                        buf, 10, buf, sizeof(buf));
     ok(GetLastError() == ERROR_INVALID_FLAGS /* NT */ ||
        GetLastError() == ERROR_INVALID_PARAMETER /* Win9x */,
-       "unexpected error code %d\n", GetLastError());
+       "unexpected error code %ld\n", GetLastError());
     ok(!ret, "src == dst without LCMAP_UPPERCASE or LCMAP_LOWERCASE must fail\n");
 
     /* test whether '\0' is always appended */
@@ -2321,7 +2321,7 @@ static void test_LCMapStringA(void)
     ret = LCMapStringA(LOCALE_USER_DEFAULT, 0, upper_case, 0, buf, sizeof(buf));
     ok(!ret, "LCMapStringA should fail with srclen = 0\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "unexpected error code %d\n", GetLastError());
+       "unexpected error code %ld\n", GetLastError());
 }
 
 typedef INT (*lcmapstring_wrapper)(DWORD, LPCWSTR, INT, LPWSTR, INT);
@@ -2360,7 +2360,7 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f
     /* LCMAP_LOWERCASE | LCMAP_UPPERCASE makes LCMAP_TITLECASE, so it's valid now. */
     ret = func_ptr(LCMAP_LOWERCASE | LCMAP_UPPERCASE, lower_case, -1, buf, ARRAY_SIZE(buf));
     todo_wine ok(ret == lstrlenW(title_case) + 1 || broken(!ret),
-       "%s ret %d, error %d, expected value %d\n", func_name,
+       "%s ret %d, error %ld, expected value %d\n", func_name,
        ret, GetLastError(), lstrlenW(title_case) + 1);
     todo_wine ok(lstrcmpW(buf, title_case) == 0 || broken(!ret),
        "Expected title case string\n");
@@ -2372,33 +2372,33 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f
         ret = func_ptr(lcmap_invalid_flags[i],
                            lower_case, -1, buf, sizeof(buf));
         ok(GetLastError() == ERROR_INVALID_FLAGS,
-           "%s (flag %08x) unexpected error code %d\n",
+           "%s (flag %08lx) unexpected error code %ld\n",
            func_name, lcmap_invalid_flags[i], GetLastError());
-        ok(!ret, "%s (flag %08x) should return 0, got %d\n",
+        ok(!ret, "%s (flag %08lx) should return 0, got %d\n",
            func_name, lcmap_invalid_flags[i], ret);
     }
 
     /* test LCMAP_LOWERCASE */
     ret = func_ptr(LCMAP_LOWERCASE, upper_case, -1, buf, ARRAY_SIZE(buf));
-    ok(ret == lstrlenW(upper_case) + 1, "%s ret %d, error %d, expected value %d\n", func_name,
+    ok(ret == lstrlenW(upper_case) + 1, "%s ret %d, error %ld, expected value %d\n", func_name,
        ret, GetLastError(), lstrlenW(upper_case) + 1);
     ok(!lstrcmpW(buf, lower_case), "%s string compare mismatch\n", func_name);
 
     /* test LCMAP_UPPERCASE */
     ret = func_ptr(LCMAP_UPPERCASE, lower_case, -1, buf, ARRAY_SIZE(buf));
-    ok(ret == lstrlenW(lower_case) + 1, "%s ret %d, error %d, expected value %d\n", func_name,
+    ok(ret == lstrlenW(lower_case) + 1, "%s ret %d, error %ld, expected value %d\n", func_name,
        ret, GetLastError(), lstrlenW(lower_case) + 1);
     ok(!lstrcmpW(buf, upper_case), "%s string compare mismatch\n", func_name);
 
     /* test LCMAP_HIRAGANA */
     ret = func_ptr(LCMAP_HIRAGANA, japanese_text, -1, buf, ARRAY_SIZE(buf));
-    ok(ret == lstrlenW(hiragana_text) + 1, "%s ret %d, error %d, expected value %d\n", func_name,
+    ok(ret == lstrlenW(hiragana_text) + 1, "%s ret %d, error %ld, expected value %d\n", func_name,
        ret, GetLastError(), lstrlenW(hiragana_text) + 1);
     ok(!lstrcmpW(buf, hiragana_text), "%s string compare mismatch\n", func_name);
 
     buf[0] = 0x30f5; /* KATAKANA LETTER SMALL KA */
     ret = func_ptr(LCMAP_HIRAGANA, buf, 1, buf2, 1);
-    ok(ret == 1, "%s ret %d, error %d, expected value 1\n", func_name,
+    ok(ret == 1, "%s ret %d, error %ld, expected value 1\n", func_name,
        ret, GetLastError());
     /* U+3095: HIRAGANA LETTER SMALL KA was added in Unicode 3.2 */
     ok(buf2[0] == 0x3095 || broken(buf2[0] == 0x30f5 /* Vista and earlier versions */),
@@ -2406,13 +2406,13 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f
 
     /* test LCMAP_KATAKANA | LCMAP_LOWERCASE */
     ret = func_ptr(LCMAP_KATAKANA | LCMAP_LOWERCASE, japanese_text, -1, buf, ARRAY_SIZE(buf));
-    ok(ret == lstrlenW(katakana_text) + 1, "%s ret %d, error %d, expected value %d\n", func_name,
+    ok(ret == lstrlenW(katakana_text) + 1, "%s ret %d, error %ld, expected value %d\n", func_name,
        ret, GetLastError(), lstrlenW(katakana_text) + 1);
     ok(!lstrcmpW(buf, katakana_text), "%s string compare mismatch\n", func_name);
 
     /* test LCMAP_FULLWIDTH */
     ret = func_ptr(LCMAP_FULLWIDTH, halfwidth_text, -1, buf, ARRAY_SIZE(buf));
-    ok(ret == lstrlenW(japanese_text) + 1, "%s ret %d, error %d, expected value %d\n", func_name,
+    ok(ret == lstrlenW(japanese_text) + 1, "%s ret %d, error %ld, expected value %d\n", func_name,
        ret, GetLastError(), lstrlenW(japanese_text) + 1);
     ok(!lstrcmpW(buf, japanese_text), "%s string compare mismatch\n", func_name);
 
@@ -2422,7 +2422,7 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f
     /* test LCMAP_FULLWIDTH | LCMAP_HIRAGANA
        (half-width katakana is converted into full-width hiragana) */
     ret = func_ptr(LCMAP_FULLWIDTH | LCMAP_HIRAGANA, halfwidth_text, -1, buf, ARRAY_SIZE(buf));
-    ok(ret == lstrlenW(hiragana_text) + 1, "%s ret %d, error %d, expected value %d\n", func_name,
+    ok(ret == lstrlenW(hiragana_text) + 1, "%s ret %d, error %ld, expected value %d\n", func_name,
        ret, GetLastError(), lstrlenW(hiragana_text) + 1);
     ok(!lstrcmpW(buf, hiragana_text), "%s string compare mismatch\n", func_name);
 
@@ -2431,7 +2431,7 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f
 
     /* test LCMAP_HALFWIDTH */
     ret = func_ptr(LCMAP_HALFWIDTH, japanese_text, -1, buf, ARRAY_SIZE(buf));
-    ok(ret == lstrlenW(halfwidth_text) + 1, "%s ret %d, error %d, expected value %d\n", func_name,
+    ok(ret == lstrlenW(halfwidth_text) + 1, "%s ret %d, error %ld, expected value %d\n", func_name,
        ret, GetLastError(), lstrlenW(halfwidth_text) + 1);
     ok(!lstrcmpW(buf, halfwidth_text), "%s string compare mismatch\n", func_name);
 
@@ -2441,7 +2441,7 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f
     /* test LCMAP_HALFWIDTH | LCMAP_KATAKANA
        (hiragana character is converted into half-width katakana) */
     ret = func_ptr(LCMAP_HALFWIDTH | LCMAP_KATAKANA, japanese_text, -1, buf, ARRAY_SIZE(buf));
-    ok(ret == lstrlenW(halfwidth_text2) + 1, "%s ret %d, error %d, expected value %d\n", func_name,
+    ok(ret == lstrlenW(halfwidth_text2) + 1, "%s ret %d, error %ld, expected value %d\n", func_name,
        ret, GetLastError(), lstrlenW(halfwidth_text2) + 1);
     ok(!lstrcmpW(buf, halfwidth_text2), "%s string compare mismatch\n", func_name);
 
@@ -2487,13 +2487,13 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f
     /* LCMAP_UPPERCASE or LCMAP_LOWERCASE should accept src == dst */
     lstrcpyW(buf, lower_case);
     ret = func_ptr(LCMAP_UPPERCASE, buf, -1, buf, ARRAY_SIZE(buf));
-    ok(ret == lstrlenW(lower_case) + 1, "%s ret %d, error %d, expected value %d\n", func_name,
+    ok(ret == lstrlenW(lower_case) + 1, "%s ret %d, error %ld, expected value %d\n", func_name,
        ret, GetLastError(), lstrlenW(lower_case) + 1);
     ok(!lstrcmpW(buf, upper_case), "%s string compare mismatch\n", func_name);
 
     lstrcpyW(buf, upper_case);
     ret = func_ptr(LCMAP_LOWERCASE, buf, -1, buf, ARRAY_SIZE(buf));
-    ok(ret == lstrlenW(upper_case) + 1, "%s ret %d, error %d, expected value %d\n", func_name,
+    ok(ret == lstrlenW(upper_case) + 1, "%s ret %d, error %ld, expected value %d\n", func_name,
        ret, GetLastError(), lstrlenW(lower_case) + 1);
     ok(!lstrcmpW(buf, lower_case), "%s string compare mismatch\n", func_name);
 
@@ -2503,7 +2503,7 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f
                        buf, 10, buf, sizeof(buf));
     ok(GetLastError() == ERROR_INVALID_FLAGS /* NT */ ||
        GetLastError() == ERROR_INVALID_PARAMETER /* Win7+ */,
-       "%s unexpected error code %d\n", func_name, GetLastError());
+       "%s unexpected error code %ld\n", func_name, GetLastError());
     ok(!ret, "%s src == dst without LCMAP_UPPERCASE or LCMAP_LOWERCASE must fail\n", func_name);
 
     /* test whether '\0' is always appended */
@@ -2565,7 +2565,7 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f
     ret = func_ptr(0, upper_case, 0, buf, ARRAY_SIZE(buf));
     ok(!ret, "%s func_ptr should fail with srclen = 0\n", func_name);
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "%s unexpected error code %d\n", func_name, GetLastError());
+       "%s unexpected error code %ld\n", func_name, GetLastError());
 }
 
 static INT LCMapStringW_wrapper(DWORD flags, LPCWSTR src, INT srclen, LPWSTR dst, INT dstlen)
@@ -2584,7 +2584,7 @@ static void test_LCMapStringW(void)
     ret = LCMapStringW((LCID)-1, LCMAP_LOWERCASE, upper_case, -1, buf, ARRAY_SIZE(buf));
     todo_wine {
     ok(!ret, "LCMapStringW should fail with bad lcid\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "unexpected error code %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "unexpected error code %ld\n", GetLastError());
     }
 
     test_lcmapstring_unicode(LCMapStringW_wrapper, "LCMapStringW:");
@@ -2613,19 +2613,19 @@ static void test_LCMapStringEx(void)
                          upper_case, -1, buf, ARRAY_SIZE(buf), NULL, NULL, 0);
     todo_wine {
     ok(!ret, "LCMapStringEx should fail with bad locale name\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "unexpected error code %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "unexpected error code %ld\n", GetLastError());
     }
 
     /* test reserved parameters */
     ret = pLCMapStringEx(LOCALE_NAME_USER_DEFAULT, LCMAP_LOWERCASE,
                          upper_case, -1, buf, ARRAY_SIZE(buf), NULL, NULL, 1);
-    ok(ret == lstrlenW(upper_case) + 1, "ret %d, error %d, expected value %d\n",
+    ok(ret == lstrlenW(upper_case) + 1, "ret %d, error %ld, expected value %d\n",
        ret, GetLastError(), lstrlenW(upper_case) + 1);
     ok(!lstrcmpW(buf, lower_case), "string compare mismatch\n");
 
     ret = pLCMapStringEx(LOCALE_NAME_USER_DEFAULT, LCMAP_LOWERCASE,
                          upper_case, -1, buf, ARRAY_SIZE(buf), NULL, (void*)1, 0);
-    ok(ret == lstrlenW(upper_case) + 1, "ret %d, error %d, expected value %d\n",
+    ok(ret == lstrlenW(upper_case) + 1, "ret %d, error %ld, expected value %d\n",
        ret, GetLastError(), lstrlenW(upper_case) + 1);
     ok(!lstrcmpW(buf, lower_case), "string compare mismatch\n");
 
@@ -2689,51 +2689,51 @@ static void test_LocaleNameToLCID(void)
     SetLastError(0xdeadbeef);
     lcid = pLocaleNameToLCID(LOCALE_NAME_USER_DEFAULT, 0);
     ok(lcid == GetUserDefaultLCID() || broken(GetLastError() == ERROR_INVALID_PARAMETER /* Vista */),
-       "Expected lcid == %08x, got %08x, error %d\n", GetUserDefaultLCID(), lcid, GetLastError());
+       "Expected lcid == %08lx, got %08lx, error %ld\n", GetUserDefaultLCID(), lcid, GetLastError());
     ret = pLCIDToLocaleName(lcid, buffer, LOCALE_NAME_MAX_LENGTH, 0);
-    ok(ret > 0, "Expected ret > 0, got %d, error %d\n", ret, GetLastError());
-    trace("%08x, %s\n", lcid, wine_dbgstr_w(buffer));
+    ok(ret > 0, "Expected ret > 0, got %d, error %ld\n", ret, GetLastError());
+    trace("%08lx, %s\n", lcid, wine_dbgstr_w(buffer));
 
     buffer[0] = 0;
     SetLastError(0xdeadbeef);
     lcid = pLocaleNameToLCID(LOCALE_NAME_SYSTEM_DEFAULT, 0);
     ok(!lcid && GetLastError() == ERROR_INVALID_PARAMETER,
-       "Expected lcid == 0, got %08x, error %d\n", lcid, GetLastError());
+       "Expected lcid == 0, got %08lx, error %ld\n", lcid, GetLastError());
     ret = pLCIDToLocaleName(lcid, buffer, LOCALE_NAME_MAX_LENGTH, 0);
-    ok(ret > 0, "Expected ret > 0, got %d, error %d\n", ret, GetLastError());
-    trace("%08x, %s\n", lcid, wine_dbgstr_w(buffer));
+    ok(ret > 0, "Expected ret > 0, got %d, error %ld\n", ret, GetLastError());
+    trace("%08lx, %s\n", lcid, wine_dbgstr_w(buffer));
 
     buffer[0] = 0;
     SetLastError(0xdeadbeef);
     lcid = pLocaleNameToLCID(LOCALE_NAME_INVARIANT, 0);
-    ok(lcid == 0x7F, "Expected lcid = 0x7F, got %08x, error %d\n", lcid, GetLastError());
+    ok(lcid == 0x7F, "Expected lcid = 0x7F, got %08lx, error %ld\n", lcid, GetLastError());
     ret = pLCIDToLocaleName(lcid, buffer, LOCALE_NAME_MAX_LENGTH, 0);
-    ok(ret > 0, "Expected ret > 0, got %d, error %d\n", ret, GetLastError());
-    trace("%08x, %s\n", lcid, wine_dbgstr_w(buffer));
+    ok(ret > 0, "Expected ret > 0, got %d, error %ld\n", ret, GetLastError());
+    trace("%08lx, %s\n", lcid, wine_dbgstr_w(buffer));
 
     /* bad name */
     SetLastError(0xdeadbeef);
     lcid = pLocaleNameToLCID(invalidW, 0);
     ok(!lcid && GetLastError() == ERROR_INVALID_PARAMETER,
-       "Expected lcid == 0, got %08x, error %d\n", lcid, GetLastError());
+       "Expected lcid == 0, got %08lx, error %ld\n", lcid, GetLastError());
 
     /* lower-case */
     lcid = pLocaleNameToLCID(esesW, 0);
-    ok(lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN), SORT_DEFAULT), "Got wrong lcid for es-es: 0x%x\n", lcid);
+    ok(lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN), SORT_DEFAULT), "Got wrong lcid for es-es: 0x%lx\n", lcid);
 
     /* english neutral name */
     lcid = pLocaleNameToLCID(enW, LOCALE_ALLOW_NEUTRAL_NAMES);
     ok(lcid == MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL), SORT_DEFAULT) ||
-       broken(lcid == 0) /* Vista */, "got 0x%04x\n", lcid);
+       broken(lcid == 0) /* Vista */, "got 0x%04lx\n", lcid);
     lcid = pLocaleNameToLCID(enW, 0);
     ok(lcid == MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) ||
-       broken(lcid == 0) /* Vista */, "got 0x%04x\n", lcid);
+       broken(lcid == 0) /* Vista */, "got 0x%04lx\n", lcid);
     if (lcid)
     {
         for (ptr = neutralsublang_names; *ptr->name; ptr++)
         {
             lcid = pLocaleNameToLCID(ptr->name, 0);
-            ok(lcid == ptr->lcid, "%s: got wrong lcid 0x%04x, expected 0x%04x\n",
+            ok(lcid == ptr->lcid, "%s: got wrong lcid 0x%04lx, expected 0x%04lx\n",
                 wine_dbgstr_w(ptr->name), lcid, ptr->lcid);
 
             *buffer = 0;
@@ -2747,7 +2747,7 @@ static void test_LocaleNameToLCID(void)
         /* zh-Hant has LCID 0x7c04, but LocaleNameToLCID actually returns 0x0c04, which is the LCID of zh-HK */
         lcid = pLocaleNameToLCID(zhHantW, 0);
         ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_HONGKONG), SORT_DEFAULT),
-           "%s: got wrong lcid 0x%04x\n", wine_dbgstr_w(zhHantW), lcid);
+           "%s: got wrong lcid 0x%04lx\n", wine_dbgstr_w(zhHantW), lcid);
         ret = pLCIDToLocaleName(lcid, buffer, ARRAY_SIZE(buffer), 0);
         ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(zhHantW), ret);
         ok(!lstrcmpW(zhhkW, buffer), "%s: got wrong locale name %s\n",
@@ -2762,7 +2762,7 @@ static void test_LocaleNameToLCID(void)
         /* zh-hant */
         lcid = pLocaleNameToLCID(zhhantW, 0);
         ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_HONGKONG), SORT_DEFAULT),
-           "%s: got wrong lcid 0x%04x\n", wine_dbgstr_w(zhhantW), lcid);
+           "%s: got wrong lcid 0x%04lx\n", wine_dbgstr_w(zhhantW), lcid);
         ret = pLCIDToLocaleName(lcid, buffer, ARRAY_SIZE(buffer), 0);
         ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(zhhantW), ret);
         ok(!lstrcmpW(zhhkW, buffer), "%s: got wrong locale name %s\n",
@@ -2772,7 +2772,7 @@ static void test_LocaleNameToLCID(void)
         lcid = pLocaleNameToLCID(zhHansW, 0);
         /* check that LocaleNameToLCID actually returns 0x0804 */
         ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE_SIMPLIFIED, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT),
-           "%s: got wrong lcid 0x%04x\n", wine_dbgstr_w(zhHansW), lcid);
+           "%s: got wrong lcid 0x%04lx\n", wine_dbgstr_w(zhHansW), lcid);
         ret = pLCIDToLocaleName(lcid, buffer, ARRAY_SIZE(buffer), 0);
         ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(zhHansW), ret);
         ok(!lstrcmpW(zhcnW, buffer), "%s: got wrong locale name %s\n",
@@ -2786,7 +2786,7 @@ static void test_LocaleNameToLCID(void)
         /* zh-hans */
         lcid = pLocaleNameToLCID(zhhansW, 0);
         ok(lcid == MAKELCID(MAKELANGID(LANG_CHINESE_SIMPLIFIED, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT),
-           "%s: got wrong lcid 0x%04x\n", wine_dbgstr_w(zhhansW), lcid);
+           "%s: got wrong lcid 0x%04lx\n", wine_dbgstr_w(zhhansW), lcid);
         ret = pLCIDToLocaleName(lcid, buffer, ARRAY_SIZE(buffer), 0);
         ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(zhhansW), ret);
         ok(!lstrcmpW(zhcnW, buffer), "%s: got wrong locale name %s\n",
@@ -2796,39 +2796,39 @@ static void test_LocaleNameToLCID(void)
     if (pRtlLocaleNameToLcid)
     {
         status = pRtlLocaleNameToLcid( LOCALE_NAME_USER_DEFAULT, &lcid, 0 );
-        ok( status == STATUS_INVALID_PARAMETER_1, "wrong error %x\n", status );
+        ok( status == STATUS_INVALID_PARAMETER_1, "wrong error %lx\n", status );
         status = pRtlLocaleNameToLcid( LOCALE_NAME_SYSTEM_DEFAULT, &lcid, 0 );
-        ok( status == STATUS_INVALID_PARAMETER_1, "wrong error %x\n", status );
+        ok( status == STATUS_INVALID_PARAMETER_1, "wrong error %lx\n", status );
         status = pRtlLocaleNameToLcid( invalidW, &lcid, 0 );
-        ok( status == STATUS_INVALID_PARAMETER_1, "wrong error %x\n", status );
+        ok( status == STATUS_INVALID_PARAMETER_1, "wrong error %lx\n", status );
 
         lcid = 0;
         status = pRtlLocaleNameToLcid( LOCALE_NAME_INVARIANT, &lcid, 0 );
-        ok( !status, "failed error %x\n", status );
-        ok( lcid == LANG_INVARIANT, "got %08x\n", lcid );
+        ok( !status, "failed error %lx\n", status );
+        ok( lcid == LANG_INVARIANT, "got %08lx\n", lcid );
 
         lcid = 0;
         status = pRtlLocaleNameToLcid( localeW, &lcid, 0 );
-        ok( !status, "failed error %x\n", status );
-        ok( lcid == MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), "got %08x\n", lcid );
+        ok( !status, "failed error %lx\n", status );
+        ok( lcid == MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), "got %08lx\n", lcid );
 
         lcid = 0;
         status = pRtlLocaleNameToLcid( esesW, &lcid, 0 );
-        ok( !status, "failed error %x\n", status );
-        ok( lcid == MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN), "got %08x\n", lcid );
+        ok( !status, "failed error %lx\n", status );
+        ok( lcid == MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN), "got %08lx\n", lcid );
 
         lcid = 0;
         status = pRtlLocaleNameToLcid( enW, &lcid, 0 );
-        ok( status == STATUS_INVALID_PARAMETER_1, "wrong error %x\n", status );
+        ok( status == STATUS_INVALID_PARAMETER_1, "wrong error %lx\n", status );
         status = pRtlLocaleNameToLcid( enW, &lcid, 1 );
-        ok( status == STATUS_INVALID_PARAMETER_1, "wrong error %x\n", status );
+        ok( status == STATUS_INVALID_PARAMETER_1, "wrong error %lx\n", status );
         status = pRtlLocaleNameToLcid( enW, &lcid, 2 );
-        ok( !status, "failed error %x\n", status );
-        ok( lcid == MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL), "got %08x\n", lcid );
+        ok( !status, "failed error %lx\n", status );
+        ok( lcid == MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL), "got %08lx\n", lcid );
         status = pRtlLocaleNameToLcid( L"en-RR", &lcid, 2 );
-        ok( status == STATUS_INVALID_PARAMETER_1, "wrong error %x\n", status );
+        ok( status == STATUS_INVALID_PARAMETER_1, "wrong error %lx\n", status );
         status = pRtlLocaleNameToLcid( L"en-Latn-RR", &lcid, 2 );
-        ok( status == STATUS_INVALID_PARAMETER_1, "wrong error %x\n", status );
+        ok( status == STATUS_INVALID_PARAMETER_1, "wrong error %lx\n", status );
 
         for (ptr = neutralsublang_names; *ptr->name; ptr++)
         {
@@ -2843,13 +2843,13 @@ static void test_LocaleNameToLCID(void)
 
             status = pRtlLocaleNameToLcid( ptr->name, &lcid, 2 );
             ok( !status || broken(ptr->lcid == MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)), /* vista */
-                "%s failed error %x\n", wine_dbgstr_w(ptr->name), status );
-            if (!status) ok( lcid == expect, "%s: got wrong lcid 0x%04x, expected 0x%04x\n",
+                "%s failed error %lx\n", wine_dbgstr_w(ptr->name), status );
+            if (!status) ok( lcid == expect, "%s: got wrong lcid 0x%04lx, expected 0x%04lx\n",
                              wine_dbgstr_w(ptr->name), lcid, expect );
             status = pRtlLocaleNameToLcid( ptr->sname, &lcid, 0 );
             ok( !status || broken(ptr->lcid == MAKELANGID(LANG_SERBIAN, SUBLANG_SERBIAN_SERBIA_LATIN)), /* vista */
-                "%s failed error %x\n", wine_dbgstr_w(ptr->name), status );
-            if (!status) ok( lcid == ptr->lcid, "%s: got wrong lcid 0x%04x, expected 0x%04x\n",
+                "%s failed error %lx\n", wine_dbgstr_w(ptr->name), status );
+            if (!status) ok( lcid == ptr->lcid, "%s: got wrong lcid 0x%04lx, expected 0x%04lx\n",
                              wine_dbgstr_w(ptr->name), lcid, ptr->lcid );
         }
     }
@@ -3087,7 +3087,7 @@ static void test_FoldStringA(void)
   /* MAP_FOLDDIGITS */
   SetLastError(0xdeadbeef);
   ret = FoldStringA(MAP_FOLDDIGITS, digits_src, -1, dst, 256);
-  ok(ret == 4, "Expected ret == 4, got %d, error %d\n", ret, GetLastError());
+  ok(ret == 4, "Expected ret == 4, got %d, error %ld\n", ret, GetLastError());
   ok(strcmp(dst, digits_dst) == 0,
      "MAP_FOLDDIGITS: Expected '%s', got '%s'\n", digits_dst, dst);
   for (i = 1; i < 256; i++)
@@ -3097,7 +3097,7 @@ static void test_FoldStringA(void)
       src[0] = i;
       src[1] = '\0';
       ret = FoldStringA(MAP_FOLDDIGITS, src, -1, dst, 256);
-      ok(ret == 2, "Expected ret == 2, got %d, error %d\n", ret, GetLastError());
+      ok(ret == 2, "Expected ret == 2, got %d, error %ld\n", ret, GetLastError());
       ok(dst[0] == src[0],
          "MAP_FOLDDIGITS: Expected '%s', got '%s'\n", src, dst);
     }
@@ -3106,7 +3106,7 @@ static void test_FoldStringA(void)
     /* MAP_EXPAND_LIGATURES */
     SetLastError(0xdeadbeef);
     ret = FoldStringA(MAP_EXPAND_LIGATURES, ligatures_src, -1, dst, 256);
-    ok(ret == sizeof(ligatures_dst), "Got %d, error %d\n", ret, GetLastError());
+    ok(ret == sizeof(ligatures_dst), "Got %d, error %ld\n", ret, GetLastError());
     ok(strcmp(dst, ligatures_dst) == 0,
        "MAP_EXPAND_LIGATURES: Expected '%s', got '%s'\n", ligatures_dst, dst);
     for (i = 1; i < 256; i++)
@@ -3125,7 +3125,7 @@ static void test_FoldStringA(void)
         }
         else
         {
-          ok(ret == 2, "Expected ret == 2, got %d, error %d\n", ret, GetLastError());
+          ok(ret == 2, "Expected ret == 2, got %d, error %ld\n", ret, GetLastError());
           ok(dst[0] == src[0],
              "MAP_EXPAND_LIGATURES: Expected '%s', got '%s'\n", src, dst);
         }
@@ -3135,9 +3135,9 @@ static void test_FoldStringA(void)
   /* MAP_COMPOSITE */
   SetLastError(0xdeadbeef);
   ret = FoldStringA(MAP_COMPOSITE, composite_src, -1, dst, 256);
-  ok(ret, "Expected ret != 0, got %d, error %d\n", ret, GetLastError());
+  ok(ret, "Expected ret != 0, got %d, error %ld\n", ret, GetLastError());
   ok( GetLastError() == 0xdeadbeef || broken(!GetLastError()), /* vista */
-      "wrong error %u\n", GetLastError());
+      "wrong error %lu\n", GetLastError());
   ok(ret == 121 || ret == 119, "Expected 121 or 119, got %d\n", ret);
   ok(strcmp(dst, composite_dst) == 0 || strcmp(dst, composite_dst_alt) == 0,
      "MAP_COMPOSITE: Mismatch, got '%s'\n", dst);
@@ -3149,7 +3149,7 @@ static void test_FoldStringA(void)
       src[0] = i;
       src[1] = '\0';
       ret = FoldStringA(MAP_COMPOSITE, src, -1, dst, 256);
-      ok(ret == 2, "Expected ret == 2, got %d, error %d\n", ret, GetLastError());
+      ok(ret == 2, "Expected ret == 2, got %d, error %ld\n", ret, GetLastError());
       ok(dst[0] == src[0],
          "0x%02x, 0x%02x,0x%02x,0x%02x,\n", (unsigned char)src[0],
          (unsigned char)dst[0],(unsigned char)dst[1],(unsigned char)dst[2]);
@@ -3169,7 +3169,7 @@ static void test_FoldStringA(void)
       if (foldczone_special[j].src == src[0])
       {
         ok(ret == 2 || ret == lstrlenA(foldczone_special[j].dst) + 1,
-           "Expected ret == 2 or %d, got %d, error %d\n",
+           "Expected ret == 2 or %d, got %d, error %ld\n",
            lstrlenA(foldczone_special[j].dst) + 1, ret, GetLastError());
         ok(src[0] == dst[0] || lstrcmpA(foldczone_special[j].dst, dst) == 0,
            "MAP_FOLDCZONE: string mismatch for 0x%02x\n",
@@ -3179,7 +3179,7 @@ static void test_FoldStringA(void)
     }
     if (! is_special)
     {
-      ok(ret == 2, "Expected ret == 2, got %d, error %d\n", ret, GetLastError());
+      ok(ret == 2, "Expected ret == 2, got %d, error %ld\n", ret, GetLastError());
       ok(src[0] == dst[0],
          "MAP_FOLDCZONE: Expected 0x%02x, got 0x%02x\n",
          (unsigned char)src[0], (unsigned char)dst[0]);
@@ -3192,7 +3192,7 @@ static void test_FoldStringA(void)
     src[0] = i;
     src[1] = '\0';
     ret = FoldStringA(MAP_PRECOMPOSED, src, -1, dst, 256);
-    ok(ret == 2, "Expected ret == 2, got %d, error %d\n", ret, GetLastError());
+    ok(ret == 2, "Expected ret == 2, got %d, error %ld\n", ret, GetLastError());
     ok(src[0] == dst[0],
        "MAP_PRECOMPOSED: Expected 0x%02x, got 0x%02x\n",
        (unsigned char)src[0], (unsigned char)dst[0]);
@@ -3340,32 +3340,32 @@ static void test_FoldStringW(void)
     SetLastError(0xdeadbeef);
     ret = FoldStringW(badFlags[i], src, 256, dst, 256);
     ok(!ret && GetLastError() == ERROR_INVALID_FLAGS,
-       "Expected ERROR_INVALID_FLAGS, got %d\n", GetLastError());
+       "Expected ERROR_INVALID_FLAGS, got %ld\n", GetLastError());
   }
 
   /* src & dst cannot be the same */
   SetLastError(0xdeadbeef);
   ret = FoldStringW(MAP_FOLDCZONE, src, -1, src, 256);
   ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER,
-      "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+      "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
   /* src can't be NULL */
   SetLastError(0xdeadbeef);
   ret = FoldStringW(MAP_FOLDCZONE, NULL, -1, dst, 256);
   ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER,
-      "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+      "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
   /* srclen can't be 0 */
   SetLastError(0xdeadbeef);
   ret = FoldStringW(MAP_FOLDCZONE, src, 0, dst, 256);
   ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER,
-      "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+      "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
   /* dstlen can't be < 0 */
   SetLastError(0xdeadbeef);
   ret = FoldStringW(MAP_FOLDCZONE, src, -1, dst, -1);
   ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER,
-      "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+      "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
   /* Ret includes terminating NUL which is appended if srclen = -1 */
   SetLastError(0xdeadbeef);
@@ -3373,9 +3373,9 @@ static void test_FoldStringW(void)
   src[1] = '\0';
   dst[0] = '\0';
   ret = FoldStringW(MAP_FOLDCZONE, src, -1, dst, 256);
-  ok(ret == 2, "Expected ret == 2, got %d, error %d\n", ret, GetLastError());
+  ok(ret == 2, "Expected ret == 2, got %d, error %ld\n", ret, GetLastError());
   ok(dst[0] == 'A' && dst[1] == '\0',
-     "srclen=-1: Expected ret=2 [%d,%d], got ret=%d [%d,%d], err=%d\n",
+     "srclen=-1: Expected ret=2 [%d,%d], got ret=%d [%d,%d], err=%ld\n",
      'A', '\0', ret, dst[0], dst[1], GetLastError());
 
   /* If size is given, result is not NUL terminated */
@@ -3385,9 +3385,9 @@ static void test_FoldStringW(void)
   dst[0] = 'X';
   dst[1] = 'X';
   ret = FoldStringW(MAP_FOLDCZONE, src, 1, dst, 256);
-  ok(ret == 1, "Expected ret == 1, got %d, error %d\n", ret, GetLastError());
+  ok(ret == 1, "Expected ret == 1, got %d, error %ld\n", ret, GetLastError());
   ok(dst[0] == 'A' && dst[1] == 'X',
-     "srclen=1: Expected ret=1, [%d,%d], got ret=%d,[%d,%d], err=%d\n",
+     "srclen=1: Expected ret=1, [%d,%d], got ret=%d,[%d,%d], err=%ld\n",
      'A','X', ret, dst[0], dst[1], GetLastError());
 
   /* MAP_FOLDDIGITS */
@@ -3400,7 +3400,7 @@ static void test_FoldStringW(void)
       src[0] = ch;
       src[1] = dst[0] = '\0';
       ret = FoldStringW(MAP_FOLDDIGITS, src, -1, dst, 256);
-      ok(ret == 2, "Expected ret == 2, got %d, error %d\n", ret, GetLastError());
+      ok(ret == 2, "Expected ret == 2, got %d, error %ld\n", ret, GetLastError());
 
       ok(dst[0] == ch || wcschr(outOfSequenceDigits, ch) ||
          (ch >= 0xa8e0 && ch <= 0xa8e9),  /* combining Devanagari on Win8 */
@@ -3428,7 +3428,7 @@ static void test_FoldStringW(void)
       src[0] = c;
       src[1] = dst[0] = '\0';
       ret = FoldStringW(MAP_FOLDDIGITS, src, -1, dst, 256);
-      ok(ret == 2, "Expected ret == 2, got %d, error %d\n", ret, GetLastError());
+      ok(ret == 2, "Expected ret == 2, got %d, error %ld\n", ret, GetLastError());
 
       ok((dst[0] == '0' + ch - digitRanges[j] && dst[1] == '\0') ||
          broken( dst[0] == ch ) ||  /* old Windows versions don't have all mappings */
@@ -3446,7 +3446,7 @@ static void test_FoldStringW(void)
   ret = FoldStringW(MAP_FOLDCZONE, foldczone_src, -1, dst, 256);
   ok(ret == ARRAY_SIZE(foldczone_dst)
      || broken(ret == ARRAY_SIZE(foldczone_broken_dst)), /* winxp, win2003 */
-     "Got %d, error %d.\n", ret, GetLastError());
+     "Got %d, error %ld.\n", ret, GetLastError());
   ok(!memcmp(dst, foldczone_dst, sizeof(foldczone_dst))
      || broken(!memcmp(dst, foldczone_broken_dst, sizeof(foldczone_broken_dst))), /* winxp, win2003 */
      "Got unexpected string %s.\n", wine_dbgstr_w(dst));
@@ -3454,7 +3454,7 @@ static void test_FoldStringW(void)
     /* MAP_EXPAND_LIGATURES */
     SetLastError(0xdeadbeef);
     ret = FoldStringW(MAP_EXPAND_LIGATURES, ligatures_src, -1, dst, 256);
-    ok(ret == ARRAY_SIZE(ligatures_dst), "Got %d, error %d\n", ret, GetLastError());
+    ok(ret == ARRAY_SIZE(ligatures_dst), "Got %d, error %ld\n", ret, GetLastError());
     ok(!memcmp(dst, ligatures_dst, sizeof(ligatures_dst)),
        "Got unexpected string %s.\n", wine_dbgstr_w(dst));
 
@@ -3464,7 +3464,7 @@ static void test_FoldStringW(void)
 
 
 #define LCID_OK(l) \
-  ok(lcid == l, "Expected lcid = %08x, got %08x\n", l, lcid)
+  ok(lcid == l, "Expected lcid = %08lx, got %08lx\n", l, lcid)
 #define MKLCID(x,y,z) MAKELCID(MAKELANGID(x, y), z)
 #define LCID_RES(src, res) do { lcid = ConvertDefaultLocale(src); LCID_OK(res); } while (0)
 #define TEST_LCIDLANG(a,b) LCID_RES(MAKELCID(a,b), MAKELCID(a,b))
@@ -3496,12 +3496,12 @@ static void test_ConvertDefaultLocale(void)
   lcid = ConvertDefaultLocale( MKLCID( LANG_JAPANESE, SUBLANG_NEUTRAL, SORT_JAPANESE_UNICODE ));
   ok( lcid == MKLCID( LANG_JAPANESE, SUBLANG_NEUTRAL, SORT_JAPANESE_UNICODE ) ||
       broken( lcid == MKLCID( LANG_JAPANESE, SUBLANG_DEFAULT, SORT_JAPANESE_UNICODE )), /* <= vista */
-          "Expected lcid = %08x got %08x\n",
+          "Expected lcid = %08lx got %08lx\n",
       MKLCID( LANG_JAPANESE, SUBLANG_NEUTRAL, SORT_JAPANESE_UNICODE ), lcid );
   lcid = ConvertDefaultLocale( MKLCID( LANG_IRISH, SUBLANG_NEUTRAL, SORT_JAPANESE_UNICODE ));
   ok( lcid == MKLCID( LANG_IRISH, SUBLANG_NEUTRAL, SORT_JAPANESE_UNICODE ) ||
       broken( lcid == MKLCID( LANG_IRISH, SUBLANG_DEFAULT, SORT_JAPANESE_UNICODE )), /* <= vista */
-          "Expected lcid = %08x got %08x\n",
+          "Expected lcid = %08lx got %08lx\n",
       MKLCID( LANG_IRISH, SUBLANG_NEUTRAL, SORT_JAPANESE_UNICODE ), lcid );
 
   /* SUBLANG_NEUTRAL -> SUBLANG_DEFAULT */
@@ -3515,22 +3515,22 @@ static void test_ConvertDefaultLocale(void)
       ok( lcid == MAKELANGID( nondefault_langs[i].lang, nondefault_langs[i].sublang ) ||
           broken( lcid == MAKELANGID( nondefault_langs[i].lang, SUBLANG_DEFAULT )) ||  /* <= vista */
           broken( lcid == MAKELANGID( nondefault_langs[i].lang, SUBLANG_NEUTRAL )),  /* w7 */
-          "Expected lcid = %08x got %08x\n",
+          "Expected lcid = %08x got %08lx\n",
           MAKELANGID( nondefault_langs[i].lang, nondefault_langs[i].sublang ), lcid );
   }
   lcid = ConvertDefaultLocale( 0x7804 );
   ok( lcid == MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED ) ||
       broken( lcid == 0x7804 ),  /* <= vista */
-      "Expected lcid = %08x got %08x\n", MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED ), lcid );
+      "Expected lcid = %08x got %08lx\n", MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED ), lcid );
   lcid = ConvertDefaultLocale( 0x7c04 );
   ok( lcid == MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_HONGKONG ) ||
       broken( lcid == 0x7c04 ) ||  /* winxp */
       broken( lcid == 0x0404 ),  /* vista */
-      "Expected lcid = %08x got %08x\n", MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_HONGKONG ), lcid );
+      "Expected lcid = %08x got %08lx\n", MAKELANGID( LANG_CHINESE, SUBLANG_CHINESE_HONGKONG ), lcid );
   lcid = ConvertDefaultLocale( LANG_SERBIAN_NEUTRAL );
   ok( lcid == MAKELANGID( LANG_SERBIAN, SUBLANG_SERBIAN_SERBIA_LATIN ) ||
       broken( lcid == MAKELANGID( LANG_SERBIAN, SUBLANG_SERBIAN_LATIN ) ),  /* <= vista */
-      "Expected lcid = %08x got %08x\n", MAKELANGID( LANG_SERBIAN, SUBLANG_SERBIAN_SERBIA_LATIN ), lcid );
+      "Expected lcid = %08x got %08lx\n", MAKELANGID( LANG_SERBIAN, SUBLANG_SERBIAN_SERBIA_LATIN ), lcid );
 
   /* Invariant language is not treated specially */
   TEST_LCID(LANG_INVARIANT, SUBLANG_DEFAULT, SORT_DEFAULT);
@@ -3545,22 +3545,22 @@ static void test_ConvertDefaultLocale(void)
   LCID_RES(LOCALE_NEUTRAL,        GetUserDefaultLCID());
   lcid = ConvertDefaultLocale(LOCALE_INVARIANT);
   ok(lcid == LOCALE_INVARIANT || broken(lcid == 0x47f) /* win2k[3]/winxp */,
-     "Expected lcid = %08x, got %08x\n", LOCALE_INVARIANT, lcid);
+     "Expected lcid = %08lx, got %08lx\n", LOCALE_INVARIANT, lcid);
 }
 
 static BOOL CALLBACK langgrp_procA(LGRPID lgrpid, LPSTR lpszNum, LPSTR lpszName,
                                     DWORD dwFlags, LONG_PTR lParam)
 {
   if (winetest_debug > 1)
-    trace("%08x, %s, %s, %08x, %08lx\n",
+    trace("%08lx, %s, %s, %08lx, %08Ix\n",
           lgrpid, lpszNum, lpszName, dwFlags, lParam);
 
   ok(pIsValidLanguageGroup(lgrpid, dwFlags) == TRUE,
-     "Enumerated grp %d not valid (flags %d)\n", lgrpid, dwFlags);
+     "Enumerated grp %ld not valid (flags %ld)\n", lgrpid, dwFlags);
 
   /* If lParam is one, we are calling with flags defaulted from 0 */
   ok(!lParam || (dwFlags == LGRPID_INSTALLED || dwFlags == LGRPID_SUPPORTED),
-         "Expected dwFlags == LGRPID_INSTALLED || dwFlags == LGRPID_SUPPORTED, got %d\n", dwFlags);
+         "Expected dwFlags == LGRPID_INSTALLED || dwFlags == LGRPID_SUPPORTED, got %ld\n", dwFlags);
 
   return TRUE;
 }
@@ -3584,17 +3584,17 @@ static void test_EnumSystemLanguageGroupsA(void)
     return;
   }
   ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER,
-      "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+      "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
   /* Invalid flags */
   SetLastError(0);
   pEnumSystemLanguageGroupsA(langgrp_procA, LGRPID_INSTALLED|LGRPID_SUPPORTED, 0);
-  ok(GetLastError() == ERROR_INVALID_FLAGS, "Expected ERROR_INVALID_FLAGS, got %d\n", GetLastError());
+  ok(GetLastError() == ERROR_INVALID_FLAGS, "Expected ERROR_INVALID_FLAGS, got %ld\n", GetLastError());
 
   /* No flags - defaults to LGRPID_INSTALLED */
   SetLastError(0xdeadbeef);
   pEnumSystemLanguageGroupsA(langgrp_procA, 0, 1);
-  ok(GetLastError() == 0xdeadbeef, "got error %d\n", GetLastError());
+  ok(GetLastError() == 0xdeadbeef, "got error %ld\n", GetLastError());
 
   pEnumSystemLanguageGroupsA(langgrp_procA, LGRPID_INSTALLED, 0);
   pEnumSystemLanguageGroupsA(langgrp_procA, LGRPID_SUPPORTED, 0);
@@ -3603,7 +3603,7 @@ static void test_EnumSystemLanguageGroupsA(void)
 static BOOL CALLBACK enum_func( LPWSTR name, DWORD flags, LPARAM lparam )
 {
     if (winetest_debug > 1)
-        trace( "%s %x\n", wine_dbgstr_w(name), flags );
+        trace( "%s %lx\n", wine_dbgstr_w(name), flags );
     return TRUE;
 }
 
@@ -3619,26 +3619,26 @@ static void test_EnumSystemLocalesEx(void)
     SetLastError( 0xdeadbeef );
     ret = pEnumSystemLocalesEx( enum_func, LOCALE_ALL, 0, (void *)1 );
     ok( !ret, "should have failed\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
     SetLastError( 0xdeadbeef );
     ret = pEnumSystemLocalesEx( enum_func, 0, 0, NULL );
-    ok( ret, "failed err %u\n", GetLastError() );
+    ok( ret, "failed err %lu\n", GetLastError() );
 }
 
 static BOOL CALLBACK lgrplocale_procA(LGRPID lgrpid, LCID lcid, LPSTR lpszNum,
                                       LONG_PTR lParam)
 {
   if (winetest_debug > 1)
-    trace("%08x, %08x, %s, %08lx\n", lgrpid, lcid, lpszNum, lParam);
+    trace("%08lx, %08lx, %s, %08Ix\n", lgrpid, lcid, lpszNum, lParam);
 
   /* invalid locale enumerated on some platforms */
   if (lcid == 0)
       return TRUE;
 
   ok(pIsValidLanguageGroup(lgrpid, LGRPID_SUPPORTED) == TRUE,
-     "Enumerated grp %d not valid\n", lgrpid);
+     "Enumerated grp %ld not valid\n", lgrpid);
   ok(IsValidLocale(lcid, LCID_SUPPORTED) == TRUE,
-     "Enumerated grp locale %04x not valid\n", lcid);
+     "Enumerated grp locale %04lx not valid\n", lcid);
   return TRUE;
 }
 
@@ -3661,25 +3661,25 @@ static void test_EnumLanguageGroupLocalesA(void)
     return;
   }
   ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER,
-      "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+      "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
   /* lgrpid too small */
   SetLastError(0);
   ret = pEnumLanguageGroupLocalesA(lgrplocale_procA, 0, 0, 0);
   ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER,
-      "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+      "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
   /* lgrpid too big */
   SetLastError(0);
   ret = pEnumLanguageGroupLocalesA(lgrplocale_procA, LGRPID_ARMENIAN + 1, 0, 0);
   ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER,
-      "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+      "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
   /* dwFlags is reserved */
   SetLastError(0);
   ret = pEnumLanguageGroupLocalesA(0, LGRPID_WESTERN_EUROPE, 0x1, 0);
   ok( !ret && GetLastError() == ERROR_INVALID_PARAMETER,
-      "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+      "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
   pEnumLanguageGroupLocalesA(lgrplocale_procA, LGRPID_WESTERN_EUROPE, 0, 0);
 }
@@ -3693,25 +3693,25 @@ static void test_SetLocaleInfoA(void)
   SetLastError(0);
   bRet = SetLocaleInfoA(lcid, LOCALE_SDATE, 0);
   ok( !bRet && GetLastError() == ERROR_INVALID_PARAMETER,
-      "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+      "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
   /* IDATE */
   SetLastError(0);
   bRet = SetLocaleInfoA(lcid, LOCALE_IDATE, "test_SetLocaleInfoA");
   ok(!bRet && GetLastError() == ERROR_INVALID_FLAGS,
-     "Expected ERROR_INVALID_FLAGS, got %d\n", GetLastError());
+     "Expected ERROR_INVALID_FLAGS, got %ld\n", GetLastError());
 
   /* ILDATE */
   SetLastError(0);
   bRet = SetLocaleInfoA(lcid, LOCALE_ILDATE, "test_SetLocaleInfoA");
   ok(!bRet && GetLastError() == ERROR_INVALID_FLAGS,
-     "Expected ERROR_INVALID_FLAGS, got %d\n", GetLastError());
+     "Expected ERROR_INVALID_FLAGS, got %ld\n", GetLastError());
 }
 
 static BOOL CALLBACK luilocale_proc1A(LPSTR value, LONG_PTR lParam)
 {
   if (winetest_debug > 1)
-    trace("%s %08lx\n", value, lParam);
+    trace("%s %08Ix\n", value, lParam);
   return(TRUE);
 }
 
@@ -3743,37 +3743,37 @@ static void test_EnumUILanguageA(void)
     win_skip("EnumUILanguagesA is not implemented\n");
     return;
   }
-  ok(ret, "Expected ret != 0, got %d, error %d\n", ret, GetLastError());
+  ok(ret, "Expected ret != 0, got %d, error %ld\n", ret, GetLastError());
 
   enumCount = 0;
   SetLastError(ERROR_SUCCESS);
   ret = pEnumUILanguagesA(luilocale_proc2A, 0, 0);
-  ok(ret, "Expected ret != 0, got %d, error %d\n", ret, GetLastError());
+  ok(ret, "Expected ret != 0, got %d, error %ld\n", ret, GetLastError());
   ok(enumCount == 1, "enumCount = %u\n", enumCount);
 
   enumCount = 0;
   SetLastError(ERROR_SUCCESS);
   ret = pEnumUILanguagesA(luilocale_proc2A, MUI_LANGUAGE_ID, 0);
   ok(ret || broken(!ret && GetLastError() == ERROR_INVALID_FLAGS), /* winxp */
-     "Expected ret != 0, got %d, error %d\n", ret, GetLastError());
+     "Expected ret != 0, got %d, error %ld\n", ret, GetLastError());
   if (ret) ok(enumCount == 1, "enumCount = %u\n", enumCount);
 
   SetLastError(ERROR_SUCCESS);
   ret = pEnumUILanguagesA(NULL, 0, 0);
   ok(!ret, "Expected return value FALSE, got %u\n", ret);
   ok(GetLastError() == ERROR_INVALID_PARAMETER,
-      "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+      "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
   SetLastError(ERROR_SUCCESS);
   ret = pEnumUILanguagesA(luilocale_proc3A, 0x5a5a5a5a, 0);
   ok(!ret, "Expected return value FALSE, got %u\n", ret);
-  ok(GetLastError() == ERROR_INVALID_FLAGS, "Expected ERROR_INVALID_FLAGS, got %d\n", GetLastError());
+  ok(GetLastError() == ERROR_INVALID_FLAGS, "Expected ERROR_INVALID_FLAGS, got %ld\n", GetLastError());
 
   SetLastError(ERROR_SUCCESS);
   ret = pEnumUILanguagesA(NULL, 0x5a5a5a5a, 0);
   ok(!ret, "Expected return value FALSE, got %u\n", ret);
   ok(GetLastError() == ERROR_INVALID_PARAMETER,
-      "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+      "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 }
 
 static char date_fmt_buf[1024];
@@ -3807,12 +3807,12 @@ static void test_EnumDateFormatsA(void)
     }
     else
     {
-        ok(ret, "EnumDateFormatsA(0) error %d\n", GetLastError());
+        ok(ret, "EnumDateFormatsA(0) error %ld\n", GetLastError());
         trace("EnumDateFormatsA(0): %s\n", date_fmt_buf);
         /* test the 1st enumerated format */
         if ((p = strchr(date_fmt_buf, '\n'))) *p = 0;
         ret = GetLocaleInfoA(lcid, LOCALE_SSHORTDATE, buf, sizeof(buf));
-        ok(ret, "GetLocaleInfoA(LOCALE_SSHORTDATE) error %d\n", GetLastError());
+        ok(ret, "GetLocaleInfoA(LOCALE_SSHORTDATE) error %ld\n", GetLastError());
         ok(!lstrcmpA(date_fmt_buf, buf), "expected \"%s\" got \"%s\"\n", date_fmt_buf, buf);
     }
 
@@ -3825,33 +3825,33 @@ static void test_EnumDateFormatsA(void)
     }
     else
     {
-        ok(ret, "EnumDateFormatsA(LOCALE_USE_CP_ACP) error %d\n", GetLastError());
+        ok(ret, "EnumDateFormatsA(LOCALE_USE_CP_ACP) error %ld\n", GetLastError());
         trace("EnumDateFormatsA(LOCALE_USE_CP_ACP): %s\n", date_fmt_buf);
         /* test the 1st enumerated format */
         if ((p = strchr(date_fmt_buf, '\n'))) *p = 0;
         ret = GetLocaleInfoA(lcid, LOCALE_SSHORTDATE, buf, sizeof(buf));
-        ok(ret, "GetLocaleInfoA(LOCALE_SSHORTDATE) error %d\n", GetLastError());
+        ok(ret, "GetLocaleInfoA(LOCALE_SSHORTDATE) error %ld\n", GetLastError());
         ok(!lstrcmpA(date_fmt_buf, buf), "expected \"%s\" got \"%s\"\n", date_fmt_buf, buf);
     }
 
     date_fmt_buf[0] = 0;
     ret = EnumDateFormatsA(enum_datetime_procA, lcid, DATE_SHORTDATE);
-    ok(ret, "EnumDateFormatsA(DATE_SHORTDATE) error %d\n", GetLastError());
+    ok(ret, "EnumDateFormatsA(DATE_SHORTDATE) error %ld\n", GetLastError());
     trace("EnumDateFormatsA(DATE_SHORTDATE): %s\n", date_fmt_buf);
     /* test the 1st enumerated format */
     if ((p = strchr(date_fmt_buf, '\n'))) *p = 0;
     ret = GetLocaleInfoA(lcid, LOCALE_SSHORTDATE, buf, sizeof(buf));
-    ok(ret, "GetLocaleInfoA(LOCALE_SSHORTDATE) error %d\n", GetLastError());
+    ok(ret, "GetLocaleInfoA(LOCALE_SSHORTDATE) error %ld\n", GetLastError());
     ok(!lstrcmpA(date_fmt_buf, buf), "expected \"%s\" got \"%s\"\n", date_fmt_buf, buf);
 
     date_fmt_buf[0] = 0;
     ret = EnumDateFormatsA(enum_datetime_procA, lcid, DATE_LONGDATE);
-    ok(ret, "EnumDateFormatsA(DATE_LONGDATE) error %d\n", GetLastError());
+    ok(ret, "EnumDateFormatsA(DATE_LONGDATE) error %ld\n", GetLastError());
     trace("EnumDateFormatsA(DATE_LONGDATE): %s\n", date_fmt_buf);
     /* test the 1st enumerated format */
     if ((p = strchr(date_fmt_buf, '\n'))) *p = 0;
     ret = GetLocaleInfoA(lcid, LOCALE_SLONGDATE, buf, sizeof(buf));
-    ok(ret, "GetLocaleInfoA(LOCALE_SLONGDATE) error %d\n", GetLastError());
+    ok(ret, "GetLocaleInfoA(LOCALE_SLONGDATE) error %ld\n", GetLastError());
     ok(!lstrcmpA(date_fmt_buf, buf), "expected \"%s\" got \"%s\"\n", date_fmt_buf, buf);
 
     date_fmt_buf[0] = 0;
@@ -3862,12 +3862,12 @@ static void test_EnumDateFormatsA(void)
         win_skip("DATE_YEARMONTH is only present on W2K and later\n");
         return;
     }
-    ok(ret, "EnumDateFormatsA(DATE_YEARMONTH) error %d\n", GetLastError());
+    ok(ret, "EnumDateFormatsA(DATE_YEARMONTH) error %ld\n", GetLastError());
     trace("EnumDateFormatsA(DATE_YEARMONTH): %s\n", date_fmt_buf);
     /* test the 1st enumerated format */
     if ((p = strchr(date_fmt_buf, '\n'))) *p = 0;
     ret = GetLocaleInfoA(lcid, LOCALE_SYEARMONTH, buf, sizeof(buf));
-    ok(ret, "GetLocaleInfoA(LOCALE_SYEARMONTH) error %d\n", GetLastError());
+    ok(ret, "GetLocaleInfoA(LOCALE_SYEARMONTH) error %ld\n", GetLastError());
     ok(!lstrcmpA(date_fmt_buf, buf) || broken(!buf[0]) /* win9x */,
        "expected \"%s\" got \"%s\"\n", date_fmt_buf, buf);
 }
@@ -3880,22 +3880,22 @@ static void test_EnumTimeFormatsA(void)
 
     date_fmt_buf[0] = 0;
     ret = EnumTimeFormatsA(enum_datetime_procA, lcid, 0);
-    ok(ret, "EnumTimeFormatsA(0) error %d\n", GetLastError());
+    ok(ret, "EnumTimeFormatsA(0) error %ld\n", GetLastError());
     trace("EnumTimeFormatsA(0): %s\n", date_fmt_buf);
     /* test the 1st enumerated format */
     if ((p = strchr(date_fmt_buf, '\n'))) *p = 0;
     ret = GetLocaleInfoA(lcid, LOCALE_STIMEFORMAT, buf, sizeof(buf));
-    ok(ret, "GetLocaleInfoA(LOCALE_STIMEFORMAT) error %d\n", GetLastError());
+    ok(ret, "GetLocaleInfoA(LOCALE_STIMEFORMAT) error %ld\n", GetLastError());
     ok(!lstrcmpA(date_fmt_buf, buf), "expected \"%s\" got \"%s\"\n", date_fmt_buf, buf);
 
     date_fmt_buf[0] = 0;
     ret = EnumTimeFormatsA(enum_datetime_procA, lcid, LOCALE_USE_CP_ACP);
-    ok(ret, "EnumTimeFormatsA(LOCALE_USE_CP_ACP) error %d\n", GetLastError());
+    ok(ret, "EnumTimeFormatsA(LOCALE_USE_CP_ACP) error %ld\n", GetLastError());
     trace("EnumTimeFormatsA(LOCALE_USE_CP_ACP): %s\n", date_fmt_buf);
     /* test the 1st enumerated format */
     if ((p = strchr(date_fmt_buf, '\n'))) *p = 0;
     ret = GetLocaleInfoA(lcid, LOCALE_STIMEFORMAT, buf, sizeof(buf));
-    ok(ret, "GetLocaleInfoA(LOCALE_STIMEFORMAT) error %d\n", GetLastError());
+    ok(ret, "GetLocaleInfoA(LOCALE_STIMEFORMAT) error %ld\n", GetLastError());
     ok(!lstrcmpA(date_fmt_buf, buf), "expected \"%s\" got \"%s\"\n", date_fmt_buf, buf);
 }
 
@@ -3907,17 +3907,17 @@ static void test_EnumTimeFormatsW(void)
 
     date_fmt_bufW[0] = 0;
     ret = EnumTimeFormatsW(enum_datetime_procW, lcid, 0);
-    ok(ret, "EnumTimeFormatsW(0) error %d\n", GetLastError());
+    ok(ret, "EnumTimeFormatsW(0) error %ld\n", GetLastError());
     ret = GetLocaleInfoW(lcid, LOCALE_STIMEFORMAT, bufW, ARRAY_SIZE(bufW));
-    ok(ret, "GetLocaleInfoW(LOCALE_STIMEFORMAT) error %d\n", GetLastError());
+    ok(ret, "GetLocaleInfoW(LOCALE_STIMEFORMAT) error %ld\n", GetLastError());
     ok(!lstrcmpW(date_fmt_bufW, bufW), "expected \"%s\" got \"%s\"\n", wine_dbgstr_w(date_fmt_bufW),
         wine_dbgstr_w(bufW));
 
     date_fmt_bufW[0] = 0;
     ret = EnumTimeFormatsW(enum_datetime_procW, lcid, LOCALE_USE_CP_ACP);
-    ok(ret, "EnumTimeFormatsW(LOCALE_USE_CP_ACP) error %d\n", GetLastError());
+    ok(ret, "EnumTimeFormatsW(LOCALE_USE_CP_ACP) error %ld\n", GetLastError());
     ret = GetLocaleInfoW(lcid, LOCALE_STIMEFORMAT, bufW, ARRAY_SIZE(bufW));
-    ok(ret, "GetLocaleInfoW(LOCALE_STIMEFORMAT) error %d\n", GetLastError());
+    ok(ret, "GetLocaleInfoW(LOCALE_STIMEFORMAT) error %ld\n", GetLastError());
     ok(!lstrcmpW(date_fmt_bufW, bufW), "expected \"%s\" got \"%s\"\n", wine_dbgstr_w(date_fmt_bufW),
         wine_dbgstr_w(bufW));
 
@@ -3929,24 +3929,24 @@ static void test_EnumTimeFormatsW(void)
     else {
         char buf[256];
 
-        ok(ret, "EnumTimeFormatsW(TIME_NOSECONDS) error %d\n", GetLastError());
+        ok(ret, "EnumTimeFormatsW(TIME_NOSECONDS) error %ld\n", GetLastError());
         ret = GetLocaleInfoW(lcid, LOCALE_SSHORTTIME, bufW, ARRAY_SIZE(bufW));
-        ok(ret, "GetLocaleInfoW(LOCALE_SSHORTTIME) error %d\n", GetLastError());
+        ok(ret, "GetLocaleInfoW(LOCALE_SSHORTTIME) error %ld\n", GetLastError());
         ok(!lstrcmpW(date_fmt_bufW, bufW), "expected \"%s\" got \"%s\"\n", wine_dbgstr_w(date_fmt_bufW),
             wine_dbgstr_w(bufW));
 
         /* EnumTimeFormatsA doesn't support this flag */
         ret = EnumTimeFormatsA(enum_datetime_procA, lcid, TIME_NOSECONDS);
-        ok(!ret && GetLastError() == ERROR_INVALID_FLAGS, "EnumTimeFormatsA(TIME_NOSECONDS) ret %d, error %d\n", ret,
+        ok(!ret && GetLastError() == ERROR_INVALID_FLAGS, "EnumTimeFormatsA(TIME_NOSECONDS) ret %d, error %ld\n", ret,
             GetLastError());
 
         ret = EnumTimeFormatsA(NULL, lcid, TIME_NOSECONDS);
-        ok(!ret && GetLastError() == ERROR_INVALID_FLAGS, "EnumTimeFormatsA(TIME_NOSECONDS) ret %d, error %d\n", ret,
+        ok(!ret && GetLastError() == ERROR_INVALID_FLAGS, "EnumTimeFormatsA(TIME_NOSECONDS) ret %d, error %ld\n", ret,
             GetLastError());
 
         /* And it's not supported by GetLocaleInfoA either */
         ret = GetLocaleInfoA(lcid, LOCALE_SSHORTTIME, buf, ARRAY_SIZE(buf));
-        ok(!ret && GetLastError() == ERROR_INVALID_FLAGS, "GetLocaleInfoA(LOCALE_SSHORTTIME) ret %d, error %d\n", ret,
+        ok(!ret && GetLastError() == ERROR_INVALID_FLAGS, "GetLocaleInfoA(LOCALE_SSHORTTIME) ret %d, error %ld\n", ret,
             GetLastError());
     }
 }
@@ -3960,7 +3960,7 @@ static void test_GetCPInfo(void)
     ret = GetCPInfo(CP_SYMBOL, &cpinfo);
     ok(!ret, "GetCPInfo(CP_SYMBOL) should fail\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
+       "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
 
     memset(cpinfo.LeadByte, '-', ARRAY_SIZE(cpinfo.LeadByte));
     SetLastError(0xdeadbeef);
@@ -3973,7 +3973,7 @@ static void test_GetCPInfo(void)
     {
         unsigned int i;
 
-        ok(ret, "GetCPInfo(CP_UTF7) error %u\n", GetLastError());
+        ok(ret, "GetCPInfo(CP_UTF7) error %lu\n", GetLastError());
         ok(cpinfo.DefaultChar[0] == 0x3f, "expected 0x3f, got 0x%x\n", cpinfo.DefaultChar[0]);
         ok(cpinfo.DefaultChar[1] == 0, "expected 0, got 0x%x\n", cpinfo.DefaultChar[1]);
         for (i = 0; i < sizeof(cpinfo.LeadByte); i++)
@@ -3992,7 +3992,7 @@ static void test_GetCPInfo(void)
     {
         unsigned int i;
 
-        ok(ret, "GetCPInfo(CP_UTF8) error %u\n", GetLastError());
+        ok(ret, "GetCPInfo(CP_UTF8) error %lu\n", GetLastError());
         ok(cpinfo.DefaultChar[0] == 0x3f, "expected 0x3f, got 0x%x\n", cpinfo.DefaultChar[0]);
         ok(cpinfo.DefaultChar[1] == 0, "expected 0, got 0x%x\n", cpinfo.DefaultChar[1]);
         for (i = 0; i < sizeof(cpinfo.LeadByte); i++)
@@ -4019,18 +4019,18 @@ static void test_GetCPInfo(void)
             case 9:  /* sortkeys */
             case 13: /* unknown */
                 ok( status == STATUS_INVALID_PARAMETER_1 || status == STATUS_INVALID_PARAMETER_3, /* vista */
-                    "%u: failed %x\n", i, status );
+                    "%u: failed %lx\n", i, status );
                 break;
             case 10:  /* casemap */
                 ok( status == STATUS_INVALID_PARAMETER_1 || status == STATUS_UNSUCCESSFUL,
-                    "%u: failed %x\n", i, status );
+                    "%u: failed %lx\n", i, status );
                 break;
             case 11:  /* codepage */
             case 12:  /* normalization */
-                ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "%u: failed %x\n", i, status );
+                ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "%u: failed %lx\n", i, status );
                 break;
             default:
-                ok( status == STATUS_INVALID_PARAMETER_1, "%u: failed %x\n", i, status );
+                ok( status == STATUS_INVALID_PARAMETER_1, "%u: failed %lx\n", i, status );
                 break;
             }
         }
@@ -4040,15 +4040,15 @@ static void test_GetCPInfo(void)
         status = pNtGetNlsSectionPtr( 10, 0, NULL, &ptr, &size );
         if (status != STATUS_INVALID_PARAMETER_1)
         {
-            ok( !status, "failed %x\n", status );
-            ok( size > 0x1000 && size <= 0x8000 , "wrong size %lx\n", size );
+            ok( !status, "failed %lx\n", status );
+            ok( size > 0x1000 && size <= 0x8000 , "wrong size %Ix\n", size );
             status = pNtGetNlsSectionPtr( 10, 0, NULL, &ptr2, &size );
-            ok( !status, "failed %x\n", status );
+            ok( !status, "failed %lx\n", status );
             ok( ptr != ptr2, "got same pointer\n" );
             ret = UnmapViewOfFile( ptr );
-            ok( ret, "UnmapViewOfFile failed err %u\n", GetLastError() );
+            ok( ret, "UnmapViewOfFile failed err %lu\n", GetLastError() );
             ret = UnmapViewOfFile( ptr2 );
-            ok( ret, "UnmapViewOfFile failed err %u\n", GetLastError() );
+            ok( ret, "UnmapViewOfFile failed err %lu\n", GetLastError() );
         }
 
         /* codepage tables */
@@ -4056,8 +4056,8 @@ static void test_GetCPInfo(void)
         ptr = (void *)0xdeadbeef;
         size = 0xdeadbeef;
         status = pNtGetNlsSectionPtr( 11, 437, NULL, &ptr, &size );
-        ok( !status, "failed %x\n", status );
-        ok( size > 0x10000 && size <= 0x20000, "wrong size %lx\n", size );
+        ok( !status, "failed %lx\n", status );
+        ok( size > 0x10000 && size <= 0x20000, "wrong size %Ix\n", size );
         memset( &table, 0xcc, sizeof(table) );
         if (pRtlInitCodePageTable)
         {
@@ -4068,11 +4068,11 @@ static void test_GetCPInfo(void)
             ok( !table.DBCSCodePage, "wrong dbcs %u\n", table.DBCSCodePage );
         }
         ret = UnmapViewOfFile( ptr );
-        ok( ret, "UnmapViewOfFile failed err %u\n", GetLastError() );
+        ok( ret, "UnmapViewOfFile failed err %lu\n", GetLastError() );
 
         status = pNtGetNlsSectionPtr( 11, 936, NULL, &ptr, &size );
-        ok( !status, "failed %x\n", status );
-        ok( size > 0x30000 && size <= 0x40000, "wrong size %lx\n", size );
+        ok( !status, "failed %lx\n", status );
+        ok( size > 0x30000 && size <= 0x40000, "wrong size %Ix\n", size );
         memset( &table, 0xcc, sizeof(table) );
         if (pRtlInitCodePageTable)
         {
@@ -4099,14 +4099,14 @@ static void test_GetCPInfo(void)
                     memset( wbuf, 0xcc, sizeof(wbuf) );
                     pRtlCustomCPToUnicodeN( &table, wbuf, sizeof(wbuf), &reslen, (char *)buf, i );
                     for (j = 0; j < 4; j++) if (expect[i][j] == 0xcccc) break;
-                    ok( reslen == j * sizeof(WCHAR), "%u: wrong len %u\n", i, reslen );
+                    ok( reslen == j * sizeof(WCHAR), "%lu: wrong len %lu\n", i, reslen );
                     for (j = 0; j < 4; j++)
-                        ok( wbuf[j] == expect[i][j], "%u: char %u got %04x\n", i, j, wbuf[j] );
+                        ok( wbuf[j] == expect[i][j], "%lu: char %lu got %04x\n", i, j, wbuf[j] );
                 }
             }
         }
         ret = UnmapViewOfFile( ptr );
-        ok( ret, "UnmapViewOfFile failed err %u\n", GetLastError() );
+        ok( ret, "UnmapViewOfFile failed err %lu\n", GetLastError() );
 
         /* normalization tables */
 
@@ -4120,14 +4120,14 @@ static void test_GetCPInfo(void)
             case NormalizationKC:
             case NormalizationKD:
             case 13:  /* IDN */
-                ok( !status, "%u: failed %x\n", i, status );
+                ok( !status, "%u: failed %lx\n", i, status );
                 if (status) break;
-                ok( size > 0x8000 && size <= 0x30000 , "wrong size %lx\n", size );
+                ok( size > 0x8000 && size <= 0x30000 , "wrong size %Ix\n", size );
                 ret = UnmapViewOfFile( ptr );
-                ok( ret, "UnmapViewOfFile failed err %u\n", GetLastError() );
+                ok( ret, "UnmapViewOfFile failed err %lu\n", GetLastError() );
                 break;
             default:
-                ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "%u: failed %x\n", i, status );
+                ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "%u: failed %lx\n", i, status );
                 break;
             }
         }
@@ -4210,17 +4210,17 @@ static void test_GetStringTypeW(void)
     SetLastError(0xdeadbeef);
     ret = GetStringTypeW(CT_CTYPE1, NULL, 0, NULL);
     ok(!ret, "got %d\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = GetStringTypeW(CT_CTYPE1, NULL, 0, types);
     ok(!ret, "got %d\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = GetStringTypeW(CT_CTYPE1, NULL, 5, types);
     ok(!ret, "got %d\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %ld\n", GetLastError());
 
     memset(types,0,sizeof(types));
     GetStringTypeW(CT_CTYPE1, blanks, 5, types);
@@ -4359,49 +4359,49 @@ static void test_IdnToNameprepUnicode(void)
 
     ret = pIdnToNameprepUnicode(0, test_data[0].in,
             test_data[0].in_len, NULL, 0);
-    ok(ret == test_data[0].ret, "ret = %d\n", ret);
+    ok(ret == test_data[0].ret, "ret = %ld\n", ret);
 
     SetLastError(0xdeadbeef);
     ret = pIdnToNameprepUnicode(0, test_data[1].in,
             test_data[1].in_len, NULL, 0);
     err = GetLastError();
-    ok(ret == test_data[1].ret, "ret = %d\n", ret);
-    ok(err == ret ? 0xdeadbeef : ERROR_INVALID_NAME, "err = %d\n", err);
+    ok(ret == test_data[1].ret, "ret = %ld\n", ret);
+    ok(err == ret ? 0xdeadbeef : ERROR_INVALID_NAME, "err = %ld\n", err);
 
     SetLastError(0xdeadbeef);
     ret = pIdnToNameprepUnicode(0, test_data[0].in, -1, buf, ARRAY_SIZE(buf));
     err = GetLastError();
-    ok(ret == test_data[0].ret, "ret = %d\n", ret);
-    ok(err == 0xdeadbeef, "err = %d\n", err);
+    ok(ret == test_data[0].ret, "ret = %ld\n", ret);
+    ok(err == 0xdeadbeef, "err = %ld\n", err);
 
     SetLastError(0xdeadbeef);
     ret = pIdnToNameprepUnicode(0, test_data[0].in, -2, buf, ARRAY_SIZE(buf));
     err = GetLastError();
-    ok(ret == 0, "ret = %d\n", ret);
-    ok(err == ERROR_INVALID_PARAMETER, "err = %d\n", err);
+    ok(ret == 0, "ret = %ld\n", ret);
+    ok(err == ERROR_INVALID_PARAMETER, "err = %ld\n", err);
 
     SetLastError(0xdeadbeef);
     ret = pIdnToNameprepUnicode(0, test_data[0].in, 0, buf, ARRAY_SIZE(buf));
     err = GetLastError();
-    ok(ret == 0, "ret = %d\n", ret);
-    ok(err == ERROR_INVALID_NAME, "err = %d\n", err);
+    ok(ret == 0, "ret = %ld\n", ret);
+    ok(err == ERROR_INVALID_NAME, "err = %ld\n", err);
 
     ret = pIdnToNameprepUnicode(IDN_ALLOW_UNASSIGNED|IDN_USE_STD3_ASCII_RULES,
             test_data[0].in, -1, buf, ARRAY_SIZE(buf));
-    ok(ret == test_data[0].ret, "ret = %d\n", ret);
+    ok(ret == test_data[0].ret, "ret = %ld\n", ret);
 
     SetLastError(0xdeadbeef);
     ret = pIdnToNameprepUnicode(0, NULL, 0, NULL, 0);
     err = GetLastError();
-    ok(ret == 0, "ret = %d\n", ret);
-    ok(err == ERROR_INVALID_PARAMETER, "err = %d\n", err);
+    ok(ret == 0, "ret = %ld\n", ret);
+    ok(err == ERROR_INVALID_PARAMETER, "err = %ld\n", err);
 
     SetLastError(0xdeadbeef);
     ret = pIdnToNameprepUnicode(4, NULL, 0, NULL, 0);
     err = GetLastError();
-    ok(ret == 0, "ret = %d\n", ret);
+    ok(ret == 0, "ret = %ld\n", ret);
     ok(err == ERROR_INVALID_FLAGS || err == ERROR_INVALID_PARAMETER /* Win8 */,
-       "err = %d\n", err);
+       "err = %ld\n", err);
 
     for (i=0; i<ARRAY_SIZE(test_data); i++)
     {
@@ -4411,12 +4411,12 @@ static void test_IdnToNameprepUnicode(void)
                 buf, ARRAY_SIZE(buf));
         err = GetLastError();
 
-        ok(ret == test_data[i].ret || broken(ret == test_data[i].broken_ret), "%d: ret = %d\n", i, ret);
+        ok(ret == test_data[i].ret || broken(ret == test_data[i].broken_ret), "%ld: ret = %ld\n", i, ret);
 
         if (ret == test_data[i].ret)
         {
-            ok(err == ret ? 0xdeadbeef : ERROR_INVALID_NAME, "%d: err = %d\n", i, err);
-            ok(!wcsncmp(test_data[i].out, buf, ret), "%d: buf = %s\n", i, wine_dbgstr_wn(buf, ret));
+            ok(err == ret ? 0xdeadbeef : ERROR_INVALID_NAME, "%ld: err = %ld\n", i, err);
+            ok(!wcsncmp(test_data[i].out, buf, ret), "%ld: buf = %s\n", i, wine_dbgstr_wn(buf, ret));
         }
         if (pRtlNormalizeString)
         {
@@ -4425,8 +4425,8 @@ static void test_IdnToNameprepUnicode(void)
             memset( buf, 0xcc, sizeof(buf) );
             status = pRtlNormalizeString( 13, test_data[i].in, test_data[i].in_len, buf, &len );
             ok( status == test_data[i].status || broken(status == test_data[i].broken_status),
-                "%d: failed %x\n", i, status );
-            if (!status) ok( !wcsnicmp(test_data[i].out, buf, len), "%d: buf = %s\n", i, wine_dbgstr_wn(buf, len));
+                "%ld: failed %lx\n", i, status );
+            if (!status) ok( !wcsnicmp(test_data[i].out, buf, len), "%ld: buf = %s\n", i, wine_dbgstr_wn(buf, len));
         }
     }
 }
@@ -4470,9 +4470,9 @@ static void test_IdnToAscii(void)
         SetLastError(0xdeadbeef);
         ret = pIdnToAscii(test_data[i].flags, test_data[i].in, test_data[i].in_len, buf, ARRAY_SIZE(buf));
         err = GetLastError();
-        ok(ret == test_data[i].ret || broken(ret == test_data[i].broken_ret), "%d: ret = %d\n", i, ret);
-        ok(err == ret ? 0xdeadbeef : ERROR_INVALID_NAME, "%d: err = %d\n", i, err);
-        ok(!wcsnicmp(test_data[i].out, buf, ret), "%d: buf = %s\n", i, wine_dbgstr_wn(buf, ret));
+        ok(ret == test_data[i].ret || broken(ret == test_data[i].broken_ret), "%ld: ret = %ld\n", i, ret);
+        ok(err == ret ? 0xdeadbeef : ERROR_INVALID_NAME, "%ld: err = %ld\n", i, err);
+        ok(!wcsnicmp(test_data[i].out, buf, ret), "%ld: buf = %s\n", i, wine_dbgstr_wn(buf, ret));
     }
 }
 
@@ -4513,14 +4513,14 @@ static void test_IdnToUnicode(void)
     for (i=0; i<ARRAY_SIZE(test_data); i++)
     {
         ret = pIdnToUnicode(test_data[i].flags, test_data[i].in, test_data[i].in_len, NULL, 0);
-        ok(ret == test_data[i].ret || broken(ret == test_data[i].broken_ret), "%d: ret = %d\n", i, ret);
+        ok(ret == test_data[i].ret || broken(ret == test_data[i].broken_ret), "%ld: ret = %ld\n", i, ret);
 
         SetLastError(0xdeadbeef);
         ret = pIdnToUnicode(test_data[i].flags, test_data[i].in, test_data[i].in_len, buf, ARRAY_SIZE(buf));
         err = GetLastError();
-        ok(ret == test_data[i].ret || broken(ret == test_data[i].broken_ret), "%d: ret = %d\n", i, ret);
-        ok(err == ret ? 0xdeadbeef : ERROR_INVALID_NAME, "%d: err = %d\n", i, err);
-        ok(!wcsncmp(test_data[i].out, buf, ret), "%d: buf = %s\n", i, wine_dbgstr_wn(buf, ret));
+        ok(ret == test_data[i].ret || broken(ret == test_data[i].broken_ret), "%ld: ret = %ld\n", i, ret);
+        ok(err == ret ? 0xdeadbeef : ERROR_INVALID_NAME, "%ld: err = %ld\n", i, err);
+        ok(!wcsncmp(test_data[i].out, buf, ret), "%ld: buf = %s\n", i, wine_dbgstr_wn(buf, ret));
     }
 }
 
@@ -4657,11 +4657,11 @@ static void test_GetLocaleInfoEx(void)
 
         SetLastError(0xdeadbeef);
         ret = pGetLocaleInfoEx(enW, LOCALE_SNAME, bufferW, 2);
-        ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %d, %d\n", ret, GetLastError());
+        ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %d, %ld\n", ret, GetLastError());
 
         SetLastError(0xdeadbeef);
         ret = pGetLocaleInfoEx(enW, LOCALE_SNAME, NULL, 0);
-        ok(ret == 3 && GetLastError() == 0xdeadbeef, "got %d, %d\n", ret, GetLastError());
+        ok(ret == 3 && GetLastError() == 0xdeadbeef, "got %d, %ld\n", ret, GetLastError());
 
         ret = pGetLocaleInfoEx(enusW, LOCALE_SNAME, bufferW, ARRAY_SIZE(bufferW));
         ok(ret == lstrlenW(bufferW)+1, "got %d\n", ret);
@@ -4700,13 +4700,13 @@ static void test_GetLocaleInfoEx(void)
         bufferW[0] = 0;
         SetLastError(0xdeadbeef);
         ret = pGetLocaleInfoEx(dummyW, LOCALE_SNAME, bufferW, ARRAY_SIZE(bufferW));
-        ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
+        ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %ld\n", ret, GetLastError());
 
         while (*ptr->name)
         {
             val = 0;
             pGetLocaleInfoEx(ptr->name, LOCALE_ILANGUAGE|LOCALE_RETURN_NUMBER, (WCHAR*)&val, sizeof(val)/sizeof(WCHAR));
-            ok(val == ptr->lcid, "%s: got wrong lcid 0x%04x, expected 0x%04x\n", wine_dbgstr_w(ptr->name), val, ptr->lcid);
+            ok(val == ptr->lcid, "%s: got wrong lcid 0x%04lx, expected 0x%04lx\n", wine_dbgstr_w(ptr->name), val, ptr->lcid);
             bufferW[0] = 0;
             ret = pGetLocaleInfoEx(ptr->name, LOCALE_SNAME, bufferW, ARRAY_SIZE(bufferW));
             ok(ret == lstrlenW(bufferW)+1, "%s: got ret value %d\n", wine_dbgstr_w(ptr->name), ret);
@@ -4779,15 +4779,15 @@ static void test_CompareStringOrdinal(void)
     SetLastError(0xdeadbeef);
     ret = pCompareStringOrdinal(NULL, 0, NULL, 0, FALSE);
     ok(!ret, "Got %u, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got %x, expected %x\n", GetLastError(), ERROR_INVALID_PARAMETER);
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got %lx, expected %x\n", GetLastError(), ERROR_INVALID_PARAMETER);
     SetLastError(0xdeadbeef);
     ret = pCompareStringOrdinal(test1, -1, NULL, 0, FALSE);
     ok(!ret, "Got %u, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got %x, expected %x\n", GetLastError(), ERROR_INVALID_PARAMETER);
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got %lx, expected %x\n", GetLastError(), ERROR_INVALID_PARAMETER);
     SetLastError(0xdeadbeef);
     ret = pCompareStringOrdinal(NULL, 0, test1, -1, FALSE);
     ok(!ret, "Got %u, expected 0\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got %x, expected %x\n", GetLastError(), ERROR_INVALID_PARAMETER);
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got %lx, expected %x\n", GetLastError(), ERROR_INVALID_PARAMETER);
 
     /* Check case */
     ret = pCompareStringOrdinal(test1, -1, test1, -1, FALSE);
@@ -4857,7 +4857,7 @@ static void test_GetGeoInfo(void)
     ret = pGetGeoInfoA(344, GEO_ISO2, NULL, 0, 0);
     ok(ret == 0, "got %d\n", ret);
     ok(GetLastError() == ERROR_INVALID_PARAMETER ||
-       broken(GetLastError() == 0xdeadbeef /* Win10 */), "got %d\n", GetLastError());
+       broken(GetLastError() == 0xdeadbeef /* Win10 */), "got %ld\n", GetLastError());
 
     ret = pGetGeoInfoA(203, GEO_ISO2, NULL, 0, 0);
     ok(ret == 3, "got %d\n", ret);
@@ -4886,7 +4886,7 @@ static void test_GetGeoInfo(void)
     ret = pGetGeoInfoA(203, GEO_ISO2, buffA, 2, 0);
     ok(ret == 0, "got %d\n", ret);
     ok(!strcmp(buffA, "RU"), "got %s\n", buffA);
-    ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %ld\n", GetLastError());
 
     /* GEO_NATION returns GEOID in a string form, but only for GEOCLASS_NATION-type IDs */
     ret = pGetGeoInfoA(203, GEO_NATION, buffA, 20, 0); /* GEOCLASS_NATION */
@@ -4951,16 +4951,16 @@ static void test_GetGeoInfo(void)
     SetLastError(0xdeadbeef);
     ret = pGetGeoInfoA(203, GEO_ID + 1, NULL, 0, 0);
     ok(ret == 0, "got %d\n", ret);
-    ok(GetLastError() == ERROR_INVALID_FLAGS, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_FLAGS, "got %ld\n", GetLastError());
 }
 
 static int geoidenum_count;
 static BOOL CALLBACK test_geoid_enumproc(GEOID geoid)
 {
     INT ret = pGetGeoInfoA(geoid, GEO_ISO2, NULL, 0, 0);
-    ok(ret == 3, "got %d for %d\n", ret, geoid);
+    ok(ret == 3, "got %d for %ld\n", ret, geoid);
     /* valid geoid starts at 2 */
-    ok(geoid >= 2, "got geoid %d\n", geoid);
+    ok(geoid >= 2, "got geoid %ld\n", geoid);
 
     return geoidenum_count++ < 5;
 }
@@ -4984,17 +4984,17 @@ static void test_EnumSystemGeoID(void)
     SetLastError(0xdeadbeef);
     ret = pEnumSystemGeoID(GEOCLASS_NATION, 0, NULL);
     ok(!ret, "got %d\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pEnumSystemGeoID(GEOCLASS_NATION+1, 0, test_geoid_enumproc);
     ok(!ret, "got %d\n", ret);
-    ok(GetLastError() == ERROR_INVALID_FLAGS, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_FLAGS, "got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pEnumSystemGeoID(GEOCLASS_NATION+1, 0, NULL);
     ok(!ret, "got %d\n", ret);
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError());
 
     ret = pEnumSystemGeoID(GEOCLASS_NATION, 0, test_geoid_enumproc);
     ok(ret, "got %d\n", ret);
@@ -5176,7 +5176,7 @@ static void test_invariant(void)
     {
         len = strlen(ptr->expect)+1; /* include \0 */
         ok(ret == len || (ptr->expect2 && ret == strlen(ptr->expect2)+1),
-           "For id %d, expected ret == %d, got %d, error %d\n",
+           "For id %d, expected ret == %d, got %d, error %ld\n",
             ptr->id, len, ret, GetLastError());
         ok(!strcmp(buffer, ptr->expect) || (ptr->expect2 && !strcmp(buffer, ptr->expect2)),
            "For id %d, Expected %s, got '%s'\n",
@@ -5202,16 +5202,16 @@ static void test_invariant(void)
 
     ret = GetLocaleInfoA(LOCALE_INVARIANT, NUO|LOCALE_SLANGUAGE, buffer, sizeof(buffer));
     len = lstrlenA(lang) + 1;
-    ok(ret == len, "Expected ret == %d, got %d, error %d\n", len, ret, GetLastError());
+    ok(ret == len, "Expected ret == %d, got %d, error %ld\n", len, ret, GetLastError());
     ok(!strcmp(buffer, lang), "Expected %s, got '%s'\n", lang, buffer);
 
     ret = GetLocaleInfoA(LOCALE_INVARIANT, NUO|LOCALE_SCOUNTRY, buffer, sizeof(buffer));
     len = lstrlenA(cntry) + 1;
-    ok(ret == len, "Expected ret == %d, got %d, error %d\n", len, ret, GetLastError());
+    ok(ret == len, "Expected ret == %d, got %d, error %ld\n", len, ret, GetLastError());
     ok(!strcmp(buffer, cntry), "Expected %s, got '%s'\n", cntry, buffer);
 
     ret = GetLocaleInfoA(LOCALE_INVARIANT, NUO|LOCALE_SSORTNAME, buffer, sizeof(buffer));
-    ok(ret, "Failed err %d\n", GetLastError());
+    ok(ret, "Failed err %ld\n", GetLastError());
     ok(!strcmp(buffer, sortm) || !strcmp(buffer, sortd) || !strcmp(buffer, sortms), "Got '%s'\n", buffer);
   }
 }
@@ -5236,28 +5236,28 @@ static void test_GetSystemPreferredUILanguages(void)
     ret = pGetSystemPreferredUILanguages(0, &count, NULL, &size);
     ok(ret, "Expected GetSystemPreferredUILanguages to succeed\n");
     ok(count, "Expected count > 0\n");
-    ok(size % 6 == 1, "Expected size (%d) %% 6 == 1\n", size);
+    ok(size % 6 == 1, "Expected size (%ld) %% 6 == 1\n", size);
 
     size = 0;
     SetLastError(0xdeadbeef);
     ret = pGetSystemPreferredUILanguages(MUI_FULL_LANGUAGE, &count, NULL, &size);
     ok(!ret, "Expected GetSystemPreferredUILanguages to fail\n");
     ok(ERROR_INVALID_PARAMETER == GetLastError(),
-       "Expected error ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+       "Expected error ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     size = 0;
     SetLastError(0xdeadbeef);
     ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID | MUI_FULL_LANGUAGE, &count, NULL, &size);
     ok(!ret, "Expected GetSystemPreferredUILanguages to fail\n");
     ok(ERROR_INVALID_PARAMETER == GetLastError(),
-       "Expected error ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+       "Expected error ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     size = 0;
     SetLastError(0xdeadbeef);
     ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID | MUI_LANGUAGE_NAME, &count, NULL, &size);
     ok(!ret, "Expected GetSystemPreferredUILanguages to fail\n");
     ok(ERROR_INVALID_PARAMETER == GetLastError(),
-       "Expected error ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+       "Expected error ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     count = 0;
     size = 0;
@@ -5265,7 +5265,7 @@ static void test_GetSystemPreferredUILanguages(void)
     ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID | MUI_MACHINE_LANGUAGE_SETTINGS, &count, NULL, &size);
     ok(ret, "Expected GetSystemPreferredUILanguages to succeed\n");
     ok(count, "Expected count > 0\n");
-    ok(size % 5 == 1, "Expected size (%d) %% 5 == 1\n", size);
+    ok(size % 5 == 1, "Expected size (%ld) %% 5 == 1\n", size);
 
     count = 0;
     size = 0;
@@ -5273,7 +5273,7 @@ static void test_GetSystemPreferredUILanguages(void)
     ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_NAME | MUI_MACHINE_LANGUAGE_SETTINGS, &count, NULL, &size);
     ok(ret, "Expected GetSystemPreferredUILanguages to succeed\n");
     ok(count, "Expected count > 0\n");
-    ok(size % 6 == 1, "Expected size (%d) %% 6 == 1\n", size);
+    ok(size % 6 == 1, "Expected size (%ld) %% 6 == 1\n", size);
 
     /* second parameter
      * ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID, NULL, NULL, &size);
@@ -5286,7 +5286,7 @@ static void test_GetSystemPreferredUILanguages(void)
     ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID, &count, NULL, &size);
     ok(!ret, "Expected GetSystemPreferredUILanguages to fail\n");
     ok(ERROR_INVALID_PARAMETER == GetLastError(),
-       "Expected error ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+       "Expected error ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     /* fourth parameter
      * ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID, &count, NULL, NULL);
@@ -5299,7 +5299,7 @@ static void test_GetSystemPreferredUILanguages(void)
     ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID, &count, NULL, &size_id);
     ok(ret, "Expected GetSystemPreferredUILanguages to succeed\n");
     ok(count, "Expected count > 0\n");
-    ok(size_id  % 5 == 1, "Expected size (%d) %% 5 == 1\n", size_id);
+    ok(size_id  % 5 == 1, "Expected size (%ld) %% 5 == 1\n", size_id);
 
     count = 0;
     size_name = 0;
@@ -5307,7 +5307,7 @@ static void test_GetSystemPreferredUILanguages(void)
     ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_NAME, &count, NULL, &size_name);
     ok(ret, "Expected GetSystemPreferredUILanguages to succeed\n");
     ok(count, "Expected count > 0\n");
-    ok(size_name % 6 == 1, "Expected size (%d) %% 6 == 1\n", size_name);
+    ok(size_name % 6 == 1, "Expected size (%ld) %% 6 == 1\n", size_name);
 
     size_buffer = max(size_id, size_name);
     if(!size_buffer)
@@ -5319,7 +5319,7 @@ static void test_GetSystemPreferredUILanguages(void)
     buffer = HeapAlloc(GetProcessHeap(), 0, size_buffer * sizeof(WCHAR));
     if (!buffer)
     {
-        skip("Failed to allocate memory for %d chars\n", size_buffer);
+        skip("Failed to allocate memory for %ld chars\n", size_buffer);
         return;
     }
 
@@ -5330,7 +5330,7 @@ static void test_GetSystemPreferredUILanguages(void)
     ret = pGetSystemPreferredUILanguages(0, &count, buffer, &size);
     ok(ret, "Expected GetSystemPreferredUILanguages to succeed\n");
     ok(count, "Expected count > 0\n");
-    ok(size % 6 == 1, "Expected size (%d) %% 6 == 1\n", size);
+    ok(size % 6 == 1, "Expected size (%ld) %% 6 == 1\n", size);
     if (ret && size % 6 == 1)
         ok(!buffer[size -2] && !buffer[size -1],
            "Expected last two WCHARs being empty, got 0x%x 0x%x\n",
@@ -5343,7 +5343,7 @@ static void test_GetSystemPreferredUILanguages(void)
     ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID, &count, buffer, &size);
     ok(ret, "Expected GetSystemPreferredUILanguages to succeed\n");
     ok(count, "Expected count > 0\n");
-    ok(size % 5 == 1, "Expected size (%d) %% 5 == 1\n", size);
+    ok(size % 5 == 1, "Expected size (%ld) %% 5 == 1\n", size);
     if (ret && size % 5 == 1)
         ok(!buffer[size -2] && !buffer[size -1],
            "Expected last two WCHARs being empty, got 0x%x 0x%x\n",
@@ -5351,7 +5351,7 @@ static void test_GetSystemPreferredUILanguages(void)
     for (i = 0; buffer[i]; i++)
         ok(('0' <= buffer[i] && buffer[i] <= '9') ||
            ('A' <= buffer[i] && buffer[i] <= 'F'),
-           "MUI_LANGUAGE_ID [%d] is bad in %s\n", i, wine_dbgstr_w(buffer));
+           "MUI_LANGUAGE_ID [%ld] is bad in %s\n", i, wine_dbgstr_w(buffer));
 
     count = 0;
     size = size_buffer;
@@ -5359,7 +5359,7 @@ static void test_GetSystemPreferredUILanguages(void)
     ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_NAME, &count, buffer, &size);
     ok(ret, "Expected GetSystemPreferredUILanguages to succeed\n");
     ok(count, "Expected count > 0\n");
-    ok(size % 6 == 1, "Expected size (%d) %% 6 == 1\n", size);
+    ok(size % 6 == 1, "Expected size (%ld) %% 6 == 1\n", size);
     if (ret && size % 5 == 1)
         ok(!buffer[size -2] && !buffer[size -1],
            "Expected last two WCHARs being empty, got 0x%x 0x%x\n",
@@ -5371,7 +5371,7 @@ static void test_GetSystemPreferredUILanguages(void)
     ret = pGetSystemPreferredUILanguages(MUI_MACHINE_LANGUAGE_SETTINGS, &count, NULL, &size);
     ok(ret, "Expected GetSystemPreferredUILanguages to succeed\n");
     ok(count, "Expected count > 0\n");
-    ok(size % 6 == 1, "Expected size (%d) %% 6 == 1\n", size);
+    ok(size % 6 == 1, "Expected size (%ld) %% 6 == 1\n", size);
     if (ret && size % 6 == 1)
         ok(!buffer[size -2] && !buffer[size -1],
            "Expected last two WCHARs being empty, got 0x%x 0x%x\n",
@@ -5382,9 +5382,9 @@ static void test_GetSystemPreferredUILanguages(void)
     size = size_buffer;
     memset(buffer, 0x5a, size_buffer * sizeof(WCHAR));
     status = pRtlGetSystemPreferredUILanguages(MUI_LANGUAGE_ID, 0, &count, buffer, &size);
-    ok(!status, "got %x\n", status);
+    ok(!status, "got %lx\n", status);
     ok(count, "Expected count > 0\n");
-    ok(size % 5 == 1, "Expected size (%d) %% 5 == 1\n", size);
+    ok(size % 5 == 1, "Expected size (%ld) %% 5 == 1\n", size);
     if (ret && size % 5 == 1)
         ok(!buffer[size -2] && !buffer[size -1],
            "Expected last two WCHARs being empty, got 0x%x 0x%x\n",
@@ -5393,9 +5393,9 @@ static void test_GetSystemPreferredUILanguages(void)
     count = 0;
     size = size_buffer;
     status = pRtlGetSystemPreferredUILanguages(MUI_LANGUAGE_NAME, 0, &count, buffer, &size);
-    ok(!status, "got %x\n", status);
+    ok(!status, "got %lx\n", status);
     ok(count, "Expected count > 0\n");
-    ok(size % 6 == 1, "Expected size (%d) %% 6 == 1\n", size);
+    ok(size % 6 == 1, "Expected size (%ld) %% 6 == 1\n", size);
     if (ret && size % 5 == 1)
         ok(!buffer[size -2] && !buffer[size -1],
            "Expected last two WCHARs being empty, got 0x%x 0x%x\n",
@@ -5404,9 +5404,9 @@ static void test_GetSystemPreferredUILanguages(void)
     count = 0;
     size = 0;
     status = pRtlGetSystemPreferredUILanguages(MUI_MACHINE_LANGUAGE_SETTINGS, 0, &count, NULL, &size);
-    ok(!status, "got %x\n", status);
+    ok(!status, "got %lx\n", status);
     ok(count, "Expected count > 0\n");
-    ok(size % 6 == 1, "Expected size (%d) %% 6 == 1\n", size);
+    ok(size % 6 == 1, "Expected size (%ld) %% 6 == 1\n", size);
     if (ret && size % 6 == 1)
         ok(!buffer[size -2] && !buffer[size -1],
            "Expected last two WCHARs being empty, got 0x%x 0x%x\n",
@@ -5417,16 +5417,16 @@ static void test_GetSystemPreferredUILanguages(void)
     ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID, &count, buffer, &size);
     ok(!ret, "Expected GetSystemPreferredUILanguages to fail\n");
     ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(),
-       "Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
-    ok(size == size_id, "expected %u, got %u\n", size_id, size);
+       "Expected error ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
+    ok(size == size_id, "expected %lu, got %lu\n", size_id, size);
 
     size = 1;
     SetLastError(0xdeadbeef);
     ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID, &count, buffer, &size);
     ok(!ret, "Expected GetSystemPreferredUILanguages to fail\n");
     ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(),
-       "Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
-    ok(size == size_id, "expected %u, got %u\n", size_id, size);
+       "Expected error ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
+    ok(size == size_id, "expected %lu, got %lu\n", size_id, size);
 
     size = size_id -1;
     memset(buffer, 0x5a, size_buffer * sizeof(WCHAR));
@@ -5434,8 +5434,8 @@ static void test_GetSystemPreferredUILanguages(void)
     ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID, &count, buffer, &size);
     ok(!ret, "Expected GetSystemPreferredUILanguages to fail\n");
     ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(),
-       "Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
-    ok(size == size_id, "expected %u, got %u\n", size_id, size);
+       "Expected error ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
+    ok(size == size_id, "expected %lu, got %lu\n", size_id, size);
 
     size = size_id -2;
     memset(buffer, 0x5a, size_buffer * sizeof(WCHAR));
@@ -5443,8 +5443,8 @@ static void test_GetSystemPreferredUILanguages(void)
     ret = pGetSystemPreferredUILanguages(0, &count, buffer, &size);
     ok(!ret, "Expected GetSystemPreferredUILanguages to fail\n");
     ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(),
-       "Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
-    ok(size == size_id + 2 || size == size_id + 1 /* before win10 1809 */, "expected %u, got %u\n", size_id + 2, size);
+       "Expected error ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
+    ok(size == size_id + 2 || size == size_id + 1 /* before win10 1809 */, "expected %lu, got %lu\n", size_id + 2, size);
 
     HeapFree(GetProcessHeap(), 0, buffer);
 }
@@ -5464,19 +5464,19 @@ static void test_GetThreadPreferredUILanguages(void)
 
     size = count = 0;
     ret = pGetThreadPreferredUILanguages(MUI_LANGUAGE_ID|MUI_UI_FALLBACK, &count, NULL, &size);
-    ok(ret, "got %u\n", GetLastError());
+    ok(ret, "got %lu\n", GetLastError());
     ok(count, "expected count > 0\n");
     ok(size, "expected size > 0\n");
 
     count = 0;
     buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size * sizeof(WCHAR));
     ret = pGetThreadPreferredUILanguages(MUI_LANGUAGE_ID|MUI_UI_FALLBACK, &count, buf, &size);
-    ok(ret, "got %u\n", GetLastError());
+    ok(ret, "got %lu\n", GetLastError());
     ok(count, "expected count > 0\n");
 
     size_id = count = 0;
     ret = pGetThreadPreferredUILanguages(MUI_LANGUAGE_ID, &count, NULL, &size_id);
-    ok(ret, "got %u\n", GetLastError());
+    ok(ret, "got %lu\n", GetLastError());
     ok(count, "expected count > 0\n");
     ok(size_id, "expected size > 0\n");
     ok(size_id <= size, "expected size > 0\n");
@@ -5484,7 +5484,7 @@ static void test_GetThreadPreferredUILanguages(void)
     /* ntdll function is the same */
     size_id = count = 0;
     status = pRtlGetThreadPreferredUILanguages(MUI_LANGUAGE_ID, &count, NULL, &size_id);
-    ok(!status, "got %x\n", status);
+    ok(!status, "got %lx\n", status);
     ok(count, "expected count > 0\n");
     ok(size_id, "expected size > 0\n");
     ok(size_id <= size, "expected size > 0\n");
@@ -5494,33 +5494,33 @@ static void test_GetThreadPreferredUILanguages(void)
     ret = pGetThreadPreferredUILanguages(MUI_LANGUAGE_ID, &count, buf, &size);
     ok(!ret, "Expected GetThreadPreferredUILanguages to fail\n");
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-       "Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
-    ok(size == size_id, "expected %u, got %u\n", size_id, size);
+       "Expected error ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
+    ok(size == size_id, "expected %lu, got %lu\n", size_id, size);
 
     size = 1;
     SetLastError(0xdeadbeef);
     ret = pGetThreadPreferredUILanguages(MUI_LANGUAGE_ID, &count, buf, &size);
     ok(!ret, "Expected GetThreadPreferredUILanguages to fail\n");
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-       "Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
-    ok(size == size_id, "expected %u, got %u\n", size_id, size);
+       "Expected error ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
+    ok(size == size_id, "expected %lu, got %lu\n", size_id, size);
 
     size = size_id - 1;
     SetLastError(0xdeadbeef);
     ret = pGetThreadPreferredUILanguages(MUI_LANGUAGE_ID, &count, buf, &size);
     ok(!ret, "Expected GetThreadPreferredUILanguages to fail\n");
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-       "Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
-    ok(size == size_id, "expected %u, got %u\n", size_id, size);
+       "Expected error ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
+    ok(size == size_id, "expected %lu, got %lu\n", size_id, size);
 
     size = size_id - 2;
     SetLastError(0xdeadbeef);
     ret = pGetThreadPreferredUILanguages(0, &count, buf, &size);
     ok(!ret, "Expected GetThreadPreferredUILanguages to fail\n");
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-       "Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
+       "Expected error ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
     todo_wine
-    ok(size == size_id || size == size_id - 1 /* before win10 1809 */, "expected %u, got %u\n", size_id, size);
+    ok(size == size_id || size == size_id - 1 /* before win10 1809 */, "expected %lu, got %lu\n", size_id, size);
 
     HeapFree(GetProcessHeap(), 0, buf);
 }
@@ -5543,28 +5543,28 @@ static void test_GetUserPreferredUILanguages(void)
     ret = pGetUserPreferredUILanguages(MUI_FULL_LANGUAGE, &count, NULL, &size);
     ok(!ret, "Expected GetUserPreferredUILanguages to fail\n");
     ok(ERROR_INVALID_PARAMETER == GetLastError(),
-       "Expected error ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+       "Expected error ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     size = 0;
     SetLastError(0xdeadbeef);
     ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_ID | MUI_FULL_LANGUAGE, &count, NULL, &size);
     ok(!ret, "Expected GetUserPreferredUILanguages to fail\n");
     ok(ERROR_INVALID_PARAMETER == GetLastError(),
-       "Expected error ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+       "Expected error ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     size = 0;
     SetLastError(0xdeadbeef);
     ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_ID | MUI_MACHINE_LANGUAGE_SETTINGS, &count, NULL, &size);
     ok(!ret, "Expected GetUserPreferredUILanguages to fail\n");
     ok(ERROR_INVALID_PARAMETER == GetLastError(),
-       "Expected error ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+       "Expected error ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     size = 1;
     SetLastError(0xdeadbeef);
     ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_ID, &count, NULL, &size);
     ok(!ret, "Expected GetUserPreferredUILanguages to fail\n");
     ok(ERROR_INVALID_PARAMETER == GetLastError(),
-       "Expected error ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+       "Expected error ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     count = 0;
     size_id = 0;
@@ -5572,7 +5572,7 @@ static void test_GetUserPreferredUILanguages(void)
     ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_ID, &count, NULL, &size_id);
     ok(ret, "Expected GetUserPreferredUILanguages to succeed\n");
     ok(count, "Expected count > 0\n");
-    ok(size_id  % 5 == 1, "Expected size (%d) %% 5 == 1\n", size_id);
+    ok(size_id  % 5 == 1, "Expected size (%ld) %% 5 == 1\n", size_id);
 
     count = 0;
     size_name = 0;
@@ -5580,7 +5580,7 @@ static void test_GetUserPreferredUILanguages(void)
     ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &count, NULL, &size_name);
     ok(ret, "Expected GetUserPreferredUILanguages to succeed\n");
     ok(count, "Expected count > 0\n");
-    ok(size_name % 6 == 1, "Expected size (%d) %% 6 == 1\n", size_name);
+    ok(size_name % 6 == 1, "Expected size (%ld) %% 6 == 1\n", size_name);
 
     size_buffer = max(size_id, size_name);
     if(!size_buffer)
@@ -5594,9 +5594,9 @@ static void test_GetUserPreferredUILanguages(void)
     size_id = 0;
     SetLastError(0xdeadbeef);
     status = pRtlGetUserPreferredUILanguages(MUI_LANGUAGE_ID, 0, &count, NULL, &size_id);
-    ok(!status, "got %x\n", status);
+    ok(!status, "got %lx\n", status);
     ok(count, "Expected count > 0\n");
-    ok(size_id  % 5 == 1, "Expected size (%d) %% 5 == 1\n", size_id);
+    ok(size_id  % 5 == 1, "Expected size (%ld) %% 5 == 1\n", size_id);
 
     buffer = HeapAlloc(GetProcessHeap(), 0, size_buffer * sizeof(WCHAR));
 
@@ -5607,7 +5607,7 @@ static void test_GetUserPreferredUILanguages(void)
     ret = pGetUserPreferredUILanguages(0, &count, buffer, &size);
     ok(ret, "Expected GetUserPreferredUILanguages to succeed\n");
     ok(count, "Expected count > 0\n");
-    ok(size % 6 == 1, "Expected size (%d) %% 6 == 1\n", size);
+    ok(size % 6 == 1, "Expected size (%ld) %% 6 == 1\n", size);
     if (ret && size % 6 == 1)
         ok(!buffer[size -2] && !buffer[size -1],
            "Expected last two WCHARs being empty, got 0x%x 0x%x\n",
@@ -5620,7 +5620,7 @@ static void test_GetUserPreferredUILanguages(void)
     ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_ID, &count, buffer, &size);
     ok(ret, "Expected GetUserPreferredUILanguages to succeed\n");
     ok(count, "Expected count > 0\n");
-    ok(size % 5 == 1, "Expected size (%d) %% 5 == 1\n", size);
+    ok(size % 5 == 1, "Expected size (%ld) %% 5 == 1\n", size);
     if (ret && size % 5 == 1)
         ok(!buffer[size -2] && !buffer[size -1],
            "Expected last two WCHARs being empty, got 0x%x 0x%x\n",
@@ -5632,7 +5632,7 @@ static void test_GetUserPreferredUILanguages(void)
     ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &count, buffer, &size);
     ok(ret, "Expected GetUserPreferredUILanguages to succeed\n");
     ok(count, "Expected count > 0\n");
-    ok(size % 6 == 1, "Expected size (%d) %% 6 == 1\n", size);
+    ok(size % 6 == 1, "Expected size (%ld) %% 6 == 1\n", size);
     if (ret && size % 5 == 1)
         ok(!buffer[size -2] && !buffer[size -1],
            "Expected last two WCHARs being empty, got 0x%x 0x%x\n",
@@ -5643,7 +5643,7 @@ static void test_GetUserPreferredUILanguages(void)
     ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_ID, &count, buffer, &size);
     ok(!ret, "Expected GetUserPreferredUILanguages to fail\n");
     ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(),
-       "Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
+       "Expected error ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
 
     size = size_id -1;
     memset(buffer, 0x5a, size_buffer * sizeof(WCHAR));
@@ -5651,7 +5651,7 @@ static void test_GetUserPreferredUILanguages(void)
     ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_ID, &count, buffer, &size);
     ok(!ret, "Expected GetUserPreferredUILanguages to fail\n");
     ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(),
-       "Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
+       "Expected error ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
 
     count = 0;
     size = size_id -2;
@@ -5660,7 +5660,7 @@ static void test_GetUserPreferredUILanguages(void)
     ret = pGetUserPreferredUILanguages(0, &count, buffer, &size);
     ok(!ret, "Expected GetUserPreferredUILanguages to fail\n");
     ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(),
-       "Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
+       "Expected error ERROR_INSUFFICIENT_BUFFER, got %ld\n", GetLastError());
 
     HeapFree(GetProcessHeap(), 0, buffer);
 }
@@ -5717,35 +5717,35 @@ static void test_FindNLSStringEx(void)
                            3, NULL, NULL, NULL, 0);
     ok(res, "Expected failure of FindNLSStringEx. Return value was %d\n", res);
     ok(ERROR_INVALID_PARAMETER == GetLastError(),
-       "Expected ERROR_INVALID_PARAMETER as last error; got %d\n", GetLastError());
+       "Expected ERROR_INVALID_PARAMETER as last error; got %ld\n", GetLastError());
 
     SetLastError( 0xdeadbeef );
     res = pFindNLSStringEx(localeW, FIND_FROMSTART, NULL, 3, fooW, 3,
                            NULL, NULL, NULL, 0);
     ok(res, "Expected failure of FindNLSStringEx. Return value was %d\n", res);
     ok(ERROR_INVALID_PARAMETER == GetLastError(),
-       "Expected ERROR_INVALID_PARAMETER as last error; got %d\n", GetLastError());
+       "Expected ERROR_INVALID_PARAMETER as last error; got %ld\n", GetLastError());
 
     SetLastError( 0xdeadbeef );
     res = pFindNLSStringEx(localeW, FIND_FROMSTART, fooW, -5, fooW, 3,
                            NULL, NULL, NULL, 0);
     ok(res, "Expected failure of FindNLSStringEx. Return value was %d\n", res);
     ok(ERROR_INVALID_PARAMETER == GetLastError(),
-       "Expected ERROR_INVALID_PARAMETER as last error; got %d\n", GetLastError());
+       "Expected ERROR_INVALID_PARAMETER as last error; got %ld\n", GetLastError());
 
     SetLastError( 0xdeadbeef );
     res = pFindNLSStringEx(localeW, FIND_FROMSTART, fooW, 3, NULL, 3,
                            NULL, NULL, NULL, 0);
     ok(res, "Expected failure of FindNLSStringEx. Return value was %d\n", res);
     ok(ERROR_INVALID_PARAMETER == GetLastError(),
-       "Expected ERROR_INVALID_PARAMETER as last error; got %d\n", GetLastError());
+       "Expected ERROR_INVALID_PARAMETER as last error; got %ld\n", GetLastError());
 
     SetLastError( 0xdeadbeef );
     res = pFindNLSStringEx(localeW, FIND_FROMSTART, fooW, 3, fooW, -5,
                            NULL, NULL, NULL, 0);
     ok(res, "Expected failure of FindNLSStringEx. Return value was %d\n", res);
     ok(ERROR_INVALID_PARAMETER == GetLastError(),
-       "Expected ERROR_INVALID_PARAMETER as last error; got %d\n", GetLastError());
+       "Expected ERROR_INVALID_PARAMETER as last error; got %ld\n", GetLastError());
 
     for (ptest = test_arr; ptest->src != NULL; ptest++)
     {
@@ -5840,7 +5840,7 @@ static void test_FindStringOrdinal(void)
                                  tests[i].ignore_case);
         err = GetLastError();
         ok(ret == tests[i].ret, "Item %d expected %d, got %d\n", i, tests[i].ret, ret);
-        ok(err == tests[i].err, "Item %d expected %#x, got %#x\n", i, tests[i].err, err);
+        ok(err == tests[i].err, "Item %d expected %#lx, got %#lx\n", i, tests[i].err, err);
     }
 }
 
@@ -6070,11 +6070,11 @@ static void test_NormalizeString(void)
             dstlen = pNormalizeString( norm_forms[i], ptest->str, -1, NULL, 0 );
             ok( dstlen > lstrlenW(ptest->str), "%s:%d: wrong len %d / %d\n",
                 wine_dbgstr_w(ptest->str), i, dstlen, lstrlenW(ptest->str) );
-            ok(GetLastError() == ERROR_SUCCESS, "%s:%d: got error %u\n",
+            ok(GetLastError() == ERROR_SUCCESS, "%s:%d: got error %lu\n",
                wine_dbgstr_w(ptest->str), i, GetLastError());
             SetLastError(0xdeadbeef);
             dstlen = pNormalizeString( norm_forms[i], ptest->str, -1, dst, dstlen );
-            ok(GetLastError() == ERROR_SUCCESS, "%s:%d: got error %u\n",
+            ok(GetLastError() == ERROR_SUCCESS, "%s:%d: got error %lu\n",
                wine_dbgstr_w(ptest->str), i, GetLastError());
             ok(dstlen == lstrlenW( dst )+1, "%s:%d: Copied length differed: was %d, should be %d\n",
                wine_dbgstr_w(ptest->str), i, dstlen, lstrlenW( dst )+1);
@@ -6095,12 +6095,12 @@ static void test_NormalizeString(void)
             {
                 dstlen = 0;
                 status = pRtlNormalizeString( norm_forms[i], ptest->str, lstrlenW(ptest->str), NULL, &dstlen );
-                ok( !status, "%s:%d: failed %x\n", wine_dbgstr_w(ptest->str), i, status );
+                ok( !status, "%s:%d: failed %lx\n", wine_dbgstr_w(ptest->str), i, status );
                 ok( dstlen > lstrlenW(ptest->str), "%s:%d: wrong len %d / %d\n",
                     wine_dbgstr_w(ptest->str), i, dstlen, lstrlenW(ptest->str) );
                 memset(dst, 0, sizeof(dst));
                 status = pRtlNormalizeString( norm_forms[i], ptest->str, lstrlenW(ptest->str), dst, &dstlen );
-                ok( !status, "%s:%d: failed %x\n", wine_dbgstr_w(ptest->str), i, status );
+                ok( !status, "%s:%d: failed %lx\n", wine_dbgstr_w(ptest->str), i, status );
                 ok(dstlen == lstrlenW( dst ), "%s:%d: Copied length differed: was %d, should be %d\n",
                    wine_dbgstr_w(ptest->str), i, dstlen, lstrlenW( dst ));
                 str_cmp = wcsncmp( ptest->expected[i], dst, dstlen );
@@ -6108,14 +6108,14 @@ static void test_NormalizeString(void)
                     wine_dbgstr_w(dst), wine_dbgstr_w(ptest->expected[i]) );
                 ret = FALSE;
                 status = pRtlIsNormalizedString( norm_forms[i], ptest->str, -1, &ret );
-                ok( !status, "%s:%d: failed %x\n", wine_dbgstr_w(ptest->str), i, status );
+                ok( !status, "%s:%d: failed %lx\n", wine_dbgstr_w(ptest->str), i, status );
                 if (!wcscmp( ptest->str, dst ))
                     ok( ret, "%s:%d: not normalized\n", wine_dbgstr_w(ptest->str), i );
                 else
                     ok( !ret, "%s:%d: normalized (dst %s)\n", wine_dbgstr_w(ptest->str), i, wine_dbgstr_w(dst) );
                 ret = FALSE;
                 status = pRtlIsNormalizedString( norm_forms[i], dst, dstlen, &ret );
-                ok( !status, "%s:%d: failed %x\n", wine_dbgstr_w(ptest->str), i, status );
+                ok( !status, "%s:%d: failed %lx\n", wine_dbgstr_w(ptest->str), i, status );
                 ok( ret, "%s:%d: not normalized\n", wine_dbgstr_w(ptest->str), i );
             }
         }
@@ -6127,32 +6127,32 @@ static void test_NormalizeString(void)
     SetLastError(0xdeadbeef);
     dstlen = pNormalizeString( NormalizationD, part0_str1, -1, dst, 1 );
     ok( dstlen <= 0, "wrong len %d\n", dstlen );
-    ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     dstlen = pNormalizeString( NormalizationC, part0_str2, -1, dst, 1 );
     ok( dstlen <= 0, "wrong len %d\n", dstlen );
-    ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     dstlen = pNormalizeString( NormalizationC, part0_str2, -1, NULL, 0 );
     ok( dstlen == 12, "wrong len %d\n", dstlen );
-    ok(GetLastError() == ERROR_SUCCESS, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_SUCCESS, "got error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     dstlen = pNormalizeString( NormalizationC, part0_str2, -1, dst, 3 );
     ok( dstlen == 3, "wrong len %d\n", dstlen );
-    ok(GetLastError() == ERROR_SUCCESS, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_SUCCESS, "got error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     dstlen = pNormalizeString( NormalizationC, part0_str2, 0, NULL, 0 );
     ok( dstlen == 0, "wrong len %d\n", dstlen );
-    ok(GetLastError() == ERROR_SUCCESS, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_SUCCESS, "got error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     dstlen = pNormalizeString( NormalizationC, part0_str2, 0, dst, 3 );
     ok( dstlen == 0, "wrong len %d\n", dstlen );
-    ok(GetLastError() == ERROR_SUCCESS, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_SUCCESS, "got error %lu\n", GetLastError());
 
     /* size estimations */
 
@@ -6169,7 +6169,7 @@ static void test_NormalizeString(void)
             {
                 dstlen = 0;
                 status = pRtlNormalizeString( norm_forms[i], dst, j, NULL, &dstlen );
-                ok( !status, "%d: failed %x\n", i, status );
+                ok( !status, "%d: failed %lx\n", i, status );
                 ok( dstlen == expect, "%d: %d -> wrong len %d\n", i, j, dstlen );
             }
         }
@@ -6184,28 +6184,28 @@ static void test_NormalizeString(void)
         if (i == 0 || i == 2)
         {
             ok( dstlen == srclen, "%d: wrong len %d\n", i, dstlen );
-            ok(GetLastError() == ERROR_SUCCESS, "got error %u\n", GetLastError());
+            ok(GetLastError() == ERROR_SUCCESS, "got error %lu\n", GetLastError());
         }
         else
         {
             ok( dstlen < -expect, "%d: wrong len %d\n", i, dstlen );
-            ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got error %u\n", GetLastError());
+            ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got error %lu\n", GetLastError());
         }
         if (pRtlNormalizeString)
         {
             dstlen = 0;
             status = pRtlNormalizeString( norm_forms[i], composite_src, srclen, NULL, &dstlen );
-            ok( !status, "%d: failed %x\n", i, status );
+            ok( !status, "%d: failed %lx\n", i, status );
             ok( dstlen == expect, "%d: wrong len %d\n", i, dstlen );
             status = pRtlNormalizeString( norm_forms[i], composite_src, srclen, dst, &dstlen );
             if (i == 0 || i == 2)
             {
-                ok( !status, "%d: failed %x\n", i, status );
+                ok( !status, "%d: failed %lx\n", i, status );
                 ok( dstlen == srclen, "%d: wrong len %d\n", i, dstlen );
             }
             else
             {
-                ok( status == STATUS_BUFFER_TOO_SMALL, "%d: failed %x\n", i, status );
+                ok( status == STATUS_BUFFER_TOO_SMALL, "%d: failed %lx\n", i, status );
                 ok( dstlen > expect, "%d: wrong len %d\n", i, dstlen );
             }
         }
@@ -6225,11 +6225,11 @@ static void test_NormalizeString(void)
         case NormalizationKD:
         case 13:  /* Idn */
             ok( dstlen > 0, "%d: wrong len %d\n", i, dstlen );
-            ok( GetLastError() == ERROR_SUCCESS, "%d: got error %u\n", i, GetLastError());
+            ok( GetLastError() == ERROR_SUCCESS, "%d: got error %lu\n", i, GetLastError());
             break;
         default:
             ok( dstlen <= 0, "%d: wrong len %d\n", i, dstlen );
-            ok( GetLastError() == ERROR_INVALID_PARAMETER, "%d: got error %u\n", i, GetLastError());
+            ok( GetLastError() == ERROR_INVALID_PARAMETER, "%d: got error %lu\n", i, GetLastError());
             break;
         }
         if (pRtlNormalizeString)
@@ -6239,17 +6239,17 @@ static void test_NormalizeString(void)
             switch (i)
             {
             case 0:
-                ok( status == STATUS_INVALID_PARAMETER, "%d: failed %x\n", i, status );
+                ok( status == STATUS_INVALID_PARAMETER, "%d: failed %lx\n", i, status );
                 break;
             case NormalizationC:
             case NormalizationD:
             case NormalizationKC:
             case NormalizationKD:
             case 13:  /* Idn */
-                ok( status == STATUS_SUCCESS, "%d: failed %x\n", i, status );
+                ok( status == STATUS_SUCCESS, "%d: failed %lx\n", i, status );
                 break;
             default:
-                ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "%d: failed %x\n", i, status );
+                ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "%d: failed %lx\n", i, status );
                 break;
             }
         }
@@ -6264,38 +6264,38 @@ static void test_NormalizeString(void)
         SetLastError( 0xdeadbeef );
         dstlen = pNormalizeString( norm_forms[i], L"AB\xd800Z", -1, dst, ARRAY_SIZE(dst) );
         ok( dstlen == -3, "%d: wrong len %d\n", i, dstlen );
-        ok( GetLastError() == ERROR_NO_UNICODE_TRANSLATION, "%d: wrong error %d\n", i, GetLastError() );
+        ok( GetLastError() == ERROR_NO_UNICODE_TRANSLATION, "%d: wrong error %ld\n", i, GetLastError() );
         dstlen = pNormalizeString( norm_forms[i], L"ABCD\xdc12Z", -1, NULL, 0 );
         ok( dstlen == (i < 2 ? 21 : 64), "%d: wrong len %d\n", i, dstlen );
         SetLastError( 0xdeadbeef );
         dstlen = pNormalizeString( norm_forms[i], L"ABCD\xdc12Z", -1, dst, ARRAY_SIZE(dst) );
         ok( dstlen == -4, "%d: wrong len %d\n", i, dstlen );
-        ok( GetLastError() == ERROR_NO_UNICODE_TRANSLATION, "%d: wrong error %d\n", i, GetLastError() );
+        ok( GetLastError() == ERROR_NO_UNICODE_TRANSLATION, "%d: wrong error %ld\n", i, GetLastError() );
         SetLastError( 0xdeadbeef );
         dstlen = pNormalizeString( norm_forms[i], L"ABCD\xdc12Z", -1, dst, 2 );
         todo_wine
         ok( dstlen == (i < 2 ? -18 : -74), "%d: wrong len %d\n", i, dstlen );
         todo_wine_if (i == 0 || i == 2)
-        ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "%d: wrong error %d\n", i, GetLastError() );
+        ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "%d: wrong error %ld\n", i, GetLastError() );
         if (pRtlNormalizeString)
         {
             dstlen = 0;
             status = pRtlNormalizeString( norm_forms[i], L"AB\xd800Z", -1, NULL, &dstlen );
-            ok( !status, "%d: failed %x\n", i, status );
+            ok( !status, "%d: failed %lx\n", i, status );
             ok( dstlen == (i < 2 ? 15 : 64), "%d: wrong len %d\n", i, dstlen );
             dstlen = ARRAY_SIZE(dst);
             status = pRtlNormalizeString( norm_forms[i], L"AB\xd800Z", -1, dst, &dstlen );
-            ok( status == STATUS_NO_UNICODE_TRANSLATION, "%d: failed %x\n", i, status );
+            ok( status == STATUS_NO_UNICODE_TRANSLATION, "%d: failed %lx\n", i, status );
             ok( dstlen == 3, "%d: wrong len %d\n", i, dstlen );
             dstlen = 1;
             status = pRtlNormalizeString( norm_forms[i], L"AB\xd800Z", -1, dst, &dstlen );
             todo_wine_if( i == 0 || i == 2)
-            ok( status == STATUS_BUFFER_TOO_SMALL, "%d: failed %x\n", i, status );
+            ok( status == STATUS_BUFFER_TOO_SMALL, "%d: failed %lx\n", i, status );
             todo_wine_if( i != 3)
             ok( dstlen == (i < 2 ? 14 : 73), "%d: wrong len %d\n", i, dstlen );
             dstlen = 2;
             status = pRtlNormalizeString( norm_forms[i], L"AB\xd800Z", -1, dst, &dstlen );
-            ok( status == STATUS_NO_UNICODE_TRANSLATION, "%d: failed %x\n", i, status );
+            ok( status == STATUS_NO_UNICODE_TRANSLATION, "%d: failed %lx\n", i, status );
             ok( dstlen == 3, "%d: wrong len %d\n", i, dstlen );
         }
     }
@@ -6343,14 +6343,14 @@ static void test_NormalizeString(void)
 
                 ret = FALSE;
                 status = pRtlIsNormalizedString( norm_forms[i], srcW, -1, &ret );
-                ok( !status, "line %u form %u: RtlIsNormalizedString failed %x\n", line, i, status );
+                ok( !status, "line %u form %u: RtlIsNormalizedString failed %lx\n", line, i, status );
                 if (!wcscmp( srcW, dstW ))
                     ok( ret, "line %u form %u: source not normalized %s\n", line, i, wine_dbgstr_w(srcW) );
                 else
                     ok( !ret, "line %u form %u: source normalized %s\n", line, i, wine_dbgstr_w(srcW) );
                 ret = FALSE;
                 status = pRtlIsNormalizedString( norm_forms[i], dstW, -1, &ret );
-                ok( !status, "line %u form %u: RtlIsNormalizedString failed %x\n", line, i, status );
+                ok( !status, "line %u form %u: RtlIsNormalizedString failed %lx\n", line, i, status );
                 ok( ret, "line %u form %u: dest not normalized %s\n", line, i, wine_dbgstr_w(dstW) );
 
                 for (j = 0; j < 4; j++)
@@ -6383,10 +6383,10 @@ static void test_NormalizeString(void)
                     ok( dstlen <= 0, "char %04x form %u: wrong result %d %s expected error\n",
                         ch, i, dstlen, wine_dbgstr_w( dstW ));
                     ok( GetLastError() == ERROR_NO_UNICODE_TRANSLATION,
-                        "char %04x form %u: error %u\n", str[0], i, GetLastError() );
+                        "char %04x form %u: error %lu\n", str[0], i, GetLastError() );
                     status = pRtlIsNormalizedString( norm_forms[i], str, -1, &ret );
                     ok( status == STATUS_NO_UNICODE_TRANSLATION,
-                        "char %04x form %u: failed %x\n", ch, i, status );
+                        "char %04x form %u: failed %lx\n", ch, i, status );
                 }
                 else
                 {
@@ -6395,7 +6395,7 @@ static void test_NormalizeString(void)
                         ch, i, wine_dbgstr_w( dstW ));
                     ret = FALSE;
                     status = pRtlIsNormalizedString( norm_forms[i], str, -1, &ret );
-                    ok( !status, "char %04x form %u: failed %x\n", ch, i, status );
+                    ok( !status, "char %04x form %u: failed %lx\n", ch, i, status );
                     ok( ret, "char %04x form %u: not normalized\n", ch, i );
                 }
             }
@@ -6604,7 +6604,7 @@ static void test_NLSVersion(void)
     info.dwNLSVersionInfoSize = offsetof( NLSVERSIONINFO, dwEffectiveId );
     ret = pGetNLSVersion( COMPARE_STRING, MAKELANGID( LANG_FRENCH, SUBLANG_FRENCH_CANADIAN ),
                           (NLSVERSIONINFO *)&info );
-    ok( ret, "GetNLSVersion failed err %u\n", GetLastError() );
+    ok( ret, "GetNLSVersion failed err %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     memset( &info, 0xcc, sizeof(info) );
@@ -6612,11 +6612,11 @@ static void test_NLSVersion(void)
     ret = pGetNLSVersion( COMPARE_STRING, MAKELANGID( LANG_FRENCH, SUBLANG_FRENCH_CANADIAN ),
                           (NLSVERSIONINFO *)&info );
     ok( ret || GetLastError() == ERROR_INSUFFICIENT_BUFFER /* < Vista */,
-        "GetNLSVersion failed err %u\n", GetLastError() );
+        "GetNLSVersion failed err %lu\n", GetLastError() );
     if (ret)
     {
         ok( info.dwEffectiveId == MAKELANGID( LANG_FRENCH, SUBLANG_FRENCH_CANADIAN ),
-            "wrong id %x\n", info.dwEffectiveId );
+            "wrong id %lx\n", info.dwEffectiveId );
         ok( IsEqualIID( &info.guidCustomVersion, &guid_fr ) ||
             broken( IsEqualIID( &info.guidCustomVersion, &guid_null )),  /* <= win7 */
             "wrong guid %s\n", debugstr_guid(&info.guidCustomVersion) );
@@ -6626,7 +6626,7 @@ static void test_NLSVersion(void)
     info.dwNLSVersionInfoSize = 8;
     ret = pGetNLSVersion( COMPARE_STRING, LOCALE_USER_DEFAULT, (NLSVERSIONINFO *)&info );
     ok( !ret, "GetNLSVersion succeeded\n" );
-    ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     info.dwNLSVersionInfoSize = sizeof(info);
@@ -6634,13 +6634,13 @@ static void test_NLSVersion(void)
     ok( !ret, "GetNLSVersion succeeded\n" );
     ok( GetLastError() == ERROR_INVALID_FLAGS ||
         broken( GetLastError() == ERROR_INSUFFICIENT_BUFFER ), /* win2003 */
-        "wrong error %u\n", GetLastError() );
+        "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     info.dwNLSVersionInfoSize = sizeof(info);
     ret = pGetNLSVersion( COMPARE_STRING, 0xdeadbeef, (NLSVERSIONINFO *)&info );
     ok( !ret, "GetNLSVersion succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     if (pGetNLSVersionEx)
     {
@@ -6648,13 +6648,13 @@ static void test_NLSVersion(void)
         memset( &info, 0xcc, sizeof(info) );
         info.dwNLSVersionInfoSize = sizeof(info);
         ret = pGetNLSVersionEx( COMPARE_STRING, L"ja-JP", &info );
-        ok( ret, "GetNLSVersionEx failed err %u\n", GetLastError() );
+        ok( ret, "GetNLSVersionEx failed err %lu\n", GetLastError() );
         ok( info.dwEffectiveId == MAKELANGID( LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN ),
-            "wrong id %x\n", info.dwEffectiveId );
+            "wrong id %lx\n", info.dwEffectiveId );
         ok( IsEqualIID( &info.guidCustomVersion, &guid_ja ) ||
             broken( IsEqualIID( &info.guidCustomVersion, &guid_null )),  /* <= win7 */
             "wrong guid %s\n", debugstr_guid(&info.guidCustomVersion) );
-        trace( "version %08x %08x %08x %s\n", info.dwNLSVersion, info.dwDefinedVersion, info.dwEffectiveId,
+        trace( "version %08lx %08lx %08lx %s\n", info.dwNLSVersion, info.dwDefinedVersion, info.dwEffectiveId,
                debugstr_guid(&info.guidCustomVersion) );
 
         SetLastError( 0xdeadbeef );
@@ -6665,7 +6665,7 @@ static void test_NLSVersion(void)
         if (ret)
         {
             ok( info.dwEffectiveId == MAKELANGID( LANG_FRENCH, SUBLANG_DEFAULT ),
-                "wrong id %x\n", info.dwEffectiveId );
+                "wrong id %lx\n", info.dwEffectiveId );
             ok( IsEqualIID( &info.guidCustomVersion, &guid_fr ) ||
                 broken( IsEqualIID( &info.guidCustomVersion, &guid_null )),  /* <= win7 */
                 "wrong guid %s\n", debugstr_guid(&info.guidCustomVersion) );
@@ -6675,36 +6675,36 @@ static void test_NLSVersion(void)
         info.dwNLSVersionInfoSize = sizeof(info) - 1;
         ret = pGetNLSVersionEx( COMPARE_STRING, L"en-US", &info );
         ok( !ret, "GetNLSVersionEx succeeded\n" );
-        ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         memset( &info, 0xcc, sizeof(info) );
         info.dwNLSVersionInfoSize = offsetof( NLSVERSIONINFO, dwEffectiveId );
         ret = pGetNLSVersionEx( COMPARE_STRING, L"en-US", &info );
-        ok( ret, "GetNLSVersionEx failed err %u\n", GetLastError() );
-        ok( info.dwEffectiveId == 0xcccccccc, "wrong id %x\n", info.dwEffectiveId );
+        ok( ret, "GetNLSVersionEx failed err %lu\n", GetLastError() );
+        ok( info.dwEffectiveId == 0xcccccccc, "wrong id %lx\n", info.dwEffectiveId );
 
         SetLastError( 0xdeadbeef );
         info.dwNLSVersionInfoSize = sizeof(info);
         ret = pGetNLSVersionEx( 2, L"en-US", &info );
         ok( !ret, "GetNLSVersionEx succeeded\n" );
-        ok( GetLastError() == ERROR_INVALID_FLAGS, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_INVALID_FLAGS, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         info.dwNLSVersionInfoSize = sizeof(info);
         ret = pGetNLSVersionEx( COMPARE_STRING, L"foobar", &info );
         ok( !ret, "GetNLSVersionEx succeeded\n" );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         memset( &info, 0xcc, sizeof(info) );
         info.dwNLSVersionInfoSize = sizeof(info);
         ret = pGetNLSVersionEx( COMPARE_STRING, L"zz-XX", &info );
-        if (!ret) ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        if (!ret) ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
         ok( !ret == !pIsValidLocaleName(L"zz-XX"), "GetNLSVersionEx doesn't match IsValidLocaleName\n" );
         if (ret)
         {
-            ok( info.dwEffectiveId == LOCALE_CUSTOM_UNSPECIFIED, "wrong id %x\n", info.dwEffectiveId );
+            ok( info.dwEffectiveId == LOCALE_CUSTOM_UNSPECIFIED, "wrong id %lx\n", info.dwEffectiveId );
             ok( IsEqualIID( &info.guidCustomVersion, &guid_def ),
                 "wrong guid %s\n", debugstr_guid(&info.guidCustomVersion) );
         }
@@ -6713,15 +6713,15 @@ static void test_NLSVersion(void)
         memset( &info, 0xcc, sizeof(info) );
         info.dwNLSVersionInfoSize = sizeof(info);
         ret = pGetNLSVersionEx( COMPARE_STRING, LOCALE_NAME_INVARIANT, &info );
-        ok( ret, "GetNLSVersionEx failed err %u\n", GetLastError() );
+        ok( ret, "GetNLSVersionEx failed err %lu\n", GetLastError() );
         if (ret)
         {
-            ok( info.dwEffectiveId == LOCALE_INVARIANT, "wrong id %x\n", info.dwEffectiveId );
+            ok( info.dwEffectiveId == LOCALE_INVARIANT, "wrong id %lx\n", info.dwEffectiveId );
             ok( IsEqualIID( &info.guidCustomVersion, &guid_def ) ||
                 broken( IsEqualIID( &info.guidCustomVersion, &guid_null )),  /* <= win7 */
                 "wrong guid %s\n", debugstr_guid(&info.guidCustomVersion) );
         }
-        else ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        else ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
     }
     else win_skip( "GetNLSVersionEx not available\n" );
 
@@ -6733,73 +6733,73 @@ static void test_NLSVersion(void)
         SetLastError( 0xdeadbeef );
         info.dwNLSVersionInfoSize = sizeof(info);
         ret = pIsValidNLSVersion( COMPARE_STRING, L"ja-JP", &info );
-        ok( ret, "IsValidNLSVersion failed err %u\n", GetLastError() );
-        ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() );
+        ok( ret, "IsValidNLSVersion failed err %lu\n", GetLastError() );
+        ok( GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         info.dwNLSVersionInfoSize = offsetof( NLSVERSIONINFO, dwEffectiveId );
         ret = pIsValidNLSVersion( COMPARE_STRING, L"en-US", &info );
-        ok( ret, "IsValidNLSVersion failed err %u\n", GetLastError() );
-        ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() );
+        ok( ret, "IsValidNLSVersion failed err %lu\n", GetLastError() );
+        ok( GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         info.dwNLSVersionInfoSize = sizeof(info);
         ret = pIsValidNLSVersion( 2, L"en-US", &info );
         ok( !ret, "IsValidNLSVersion succeeded\n" );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         info.dwNLSVersionInfoSize = sizeof(info);
         ret = pIsValidNLSVersion( COMPARE_STRING, L"foobar", &info );
         ok( !ret, "IsValidNLSVersion succeeded\n" );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         memset( &info, 0xcc, sizeof(info) );
         info.dwNLSVersionInfoSize = sizeof(info);
         ret = pIsValidNLSVersion( COMPARE_STRING, L"en-US", &info );
         ok( !ret, "IsValidNLSVersion succeeded\n" );
-        ok( GetLastError() == ERROR_SUCCESS, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_SUCCESS, "wrong error %lu\n", GetLastError() );
 
         info.dwNLSVersionInfoSize = sizeof(info);
         pGetNLSVersion( COMPARE_STRING, LOCALE_USER_DEFAULT, (NLSVERSIONINFO *)&info );
         info.dwNLSVersion++;
         SetLastError( 0xdeadbeef );
         ret = pIsValidNLSVersion( COMPARE_STRING, L"en-US", &info );
-        ok( ret, "IsValidNLSVersion failed err %u\n", GetLastError() );
-        ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() );
+        ok( ret, "IsValidNLSVersion failed err %lu\n", GetLastError() );
+        ok( GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError() );
 
         info.dwNLSVersion += 0x100;
         SetLastError( 0xdeadbeef );
         ret = pIsValidNLSVersion( COMPARE_STRING, L"en-US", &info );
         ok( !ret, "IsValidNLSVersion succeeded\n" );
-        ok( GetLastError() == 0, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == 0, "wrong error %lu\n", GetLastError() );
 
         info.dwNLSVersion -= 0x800;
         SetLastError( 0xdeadbeef );
         ret = pIsValidNLSVersion( COMPARE_STRING, L"en-US", &info );
         ok( !ret, "IsValidNLSVersion succeeded\n" );
-        ok( GetLastError() == 0, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == 0, "wrong error %lu\n", GetLastError() );
 
         info.dwNLSVersion += 0x700;
         info.dwDefinedVersion += 0x100;
         SetLastError( 0xdeadbeef );
         ret = pIsValidNLSVersion( COMPARE_STRING, L"en-US", &info );
-        ok( ret, "IsValidNLSVersion failed err %u\n", GetLastError() );
-        ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() );
+        ok( ret, "IsValidNLSVersion failed err %lu\n", GetLastError() );
+        ok( GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError() );
 
         info.dwDefinedVersion -= 0x100;
         info.guidCustomVersion.Data1 = 0x123;
         SetLastError( 0xdeadbeef );
         ret = pIsValidNLSVersion( COMPARE_STRING, L"en-US", &info );
         ok( !ret, "IsValidNLSVersion succeeded\n" );
-        ok( GetLastError() == 0, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == 0, "wrong error %lu\n", GetLastError() );
 
         info.guidCustomVersion = guid_null;
         SetLastError( 0xdeadbeef );
         ret = pIsValidNLSVersion( COMPARE_STRING, L"en-US", &info );
-        ok( ret, "IsValidNLSVersion failed err %u\n", GetLastError() );
-        ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() );
+        ok( ret, "IsValidNLSVersion failed err %lu\n", GetLastError() );
+        ok( GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError() );
     }
     else win_skip( "IsValidNLSVersion not available\n" );
 }
@@ -6822,7 +6822,7 @@ static void test_geo_name(void)
     }
 
     status = RegOpenKeyExA(HKEY_CURRENT_USER, "Control Panel\\International\\Geo", 0, KEY_READ | KEY_WRITE, &key);
-    ok(status == ERROR_SUCCESS, "Got unexpected status %#x.\n", status);
+    ok(status == ERROR_SUCCESS, "Got unexpected status %#lx.\n", status);
 
     size = sizeof(reg_name);
     if (!RegQueryValueExW(key, L"Name", NULL, &type, (BYTE *)reg_name, &size))
@@ -6837,7 +6837,7 @@ static void test_geo_name(void)
         if (have_name)
         {
             status = RegSetValueExW(key, L"Name", 0, REG_SZ, (BYTE *)reg_name, (lstrlenW(reg_name) + 1) * sizeof(*reg_name));
-            ok(status == ERROR_SUCCESS, "Got unexpected status %#x.\n", status);
+            ok(status == ERROR_SUCCESS, "Got unexpected status %#lx.\n", status);
         }
         else
         {
@@ -6856,136 +6856,136 @@ static void test_geo_name(void)
 
     SetLastError(0xdeadbeef);
     ret = pGetUserDefaultGeoName(NULL, 0);
-    ok((ret == 3 || ret == 4) && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %u.\n", ret, GetLastError());
+    ok((ret == 3 || ret == 4) && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %lu.\n", ret, GetLastError());
     name_size = ret;
 
     SetLastError(0xdeadbeef);
     ret = pGetUserDefaultGeoName(buf, 0);
-    ok(ret >= 3 && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret >= 3 && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %lu.\n", ret, GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetUserDefaultGeoName(buf, 2);
-    ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got unexpected ret %u, GetLastError() %u.\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got unexpected ret %u, GetLastError() %lu.\n", ret, GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetUserDefaultGeoName(NULL, 1);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected ret %u, GetLastError() %u.\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected ret %u, GetLastError() %lu.\n", ret, GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetUserDefaultGeoName(NULL, name_size);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected ret %u, GetLastError() %u.\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected ret %u, GetLastError() %lu.\n", ret, GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetUserDefaultGeoName(buf, name_size);
-    ok(ret == name_size && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret == name_size && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %lu.\n", ret, GetLastError());
     ok(!lstrcmpW(buf, L"QQ"), "Got unexpected name %s.\n", wine_dbgstr_w(buf));
 
     SetLastError(0xdeadbeef);
     bret = pSetUserGeoName(NULL);
-    ok(!bret && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected bret %#x, GetLastError() %u.\n", bret, GetLastError());
+    ok(!bret && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected bret %#x, GetLastError() %lu.\n", bret, GetLastError());
 
     lstrcpyW(set_name, L"QQ");
     SetLastError(0xdeadbeef);
     bret = pSetUserGeoName(set_name);
-    ok(!bret && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected bret %#x, GetLastError() %u.\n", bret, GetLastError());
+    ok(!bret && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected bret %#x, GetLastError() %lu.\n", bret, GetLastError());
 
     lstrcpyW(set_name, L"Xx");
     SetLastError(0xdeadbeef);
     bret = pSetUserGeoName(set_name);
     ok((bret && GetLastError() == 0xdeadbeef) || broken(bret && GetLastError() == 0),
-            "Got unexpected bret %#x, GetLastError() %u.\n", bret, GetLastError());
+            "Got unexpected bret %#x, GetLastError() %lu.\n", bret, GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetUserDefaultGeoName(buf, ARRAY_SIZE(buf));
-    ok(ret == 4 && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret == 4 && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %lu.\n", ret, GetLastError());
     ok(!lstrcmpW(buf, L"001"), "Got unexpected name %s.\n", wine_dbgstr_w(buf));
     geoid = GetUserGeoID(GEOCLASS_REGION);
-    ok(geoid == 39070, "Got unexpected geoid %u.\n", geoid);
+    ok(geoid == 39070, "Got unexpected geoid %lu.\n", geoid);
     size = sizeof(buf);
     status = RegQueryValueExW(key, L"Name", NULL, &type, (BYTE *)buf, &size);
-    ok(status == ERROR_SUCCESS, "Got unexpected status %#x.\n", status);
-    ok(type == REG_SZ, "Got unexpected type %#x.\n", type);
+    ok(status == ERROR_SUCCESS, "Got unexpected status %#lx.\n", status);
+    ok(type == REG_SZ, "Got unexpected type %#lx.\n", type);
     ok(!lstrcmpW(buf, L"001"), "Got unexpected name %s.\n", wine_dbgstr_w(buf));
 
     lstrcpyW(set_name, L"ar");
     SetLastError(0xdeadbeef);
     bret = pSetUserGeoName(set_name);
     ok((bret && GetLastError() == 0xdeadbeef) || broken(bret && GetLastError() == 0),
-            "Got unexpected bret %#x, GetLastError() %u.\n", bret, GetLastError());
+            "Got unexpected bret %#x, GetLastError() %lu.\n", bret, GetLastError());
     ret = pGetUserDefaultGeoName(buf, ARRAY_SIZE(buf));
     ok((ret == 3 && GetLastError() == 0xdeadbeef) || broken(ret == 3 && GetLastError() == 0),
-            "Got unexpected ret %u, GetLastError() %u.\n", ret, GetLastError());
+            "Got unexpected ret %u, GetLastError() %lu.\n", ret, GetLastError());
     ok(!lstrcmpW(buf, L"AR"), "Got unexpected name %s.\n", wine_dbgstr_w(buf));
     geoid = GetUserGeoID(GEOCLASS_NATION);
-    ok(geoid == 11, "Got unexpected geoid %u.\n", geoid);
+    ok(geoid == 11, "Got unexpected geoid %lu.\n", geoid);
 
     lstrcpyW(set_name, L"150");
     SetLastError(0xdeadbeef);
     bret = pSetUserGeoName(set_name);
     ok((bret && GetLastError() == 0xdeadbeef) || broken(bret && GetLastError() == 0),
-            "Got unexpected bret %#x, GetLastError() %u.\n", bret, GetLastError());
+            "Got unexpected bret %#x, GetLastError() %lu.\n", bret, GetLastError());
     ret = pGetUserDefaultGeoName(buf, ARRAY_SIZE(buf));
     ok((ret == 4 && GetLastError() == 0xdeadbeef) || broken(ret == 4 && GetLastError() == 0),
-            "Got unexpected ret %u, GetLastError() %u.\n", ret, GetLastError());
+            "Got unexpected ret %u, GetLastError() %lu.\n", ret, GetLastError());
     ok(!lstrcmpW(buf, L"150"), "Got unexpected name %s.\n", wine_dbgstr_w(buf));
     geoid = GetUserGeoID(GEOCLASS_NATION);
-    ok(geoid == 11, "Got unexpected geoid %u.\n", geoid);
+    ok(geoid == 11, "Got unexpected geoid %lu.\n", geoid);
 
     lstrcpyW(set_name, L"150a");
     SetLastError(0xdeadbeef);
     bret = pSetUserGeoName(set_name);
-    ok(!bret && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected bret %#x, GetLastError() %u.\n", bret, GetLastError());
+    ok(!bret && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected bret %#x, GetLastError() %lu.\n", bret, GetLastError());
 
     bret = SetUserGeoID(21242);
-    ok(bret, "Got unexpected bret %#x, GetLastError() %u.\n", bret, GetLastError());
+    ok(bret, "Got unexpected bret %#x, GetLastError() %lu.\n", bret, GetLastError());
     SetLastError(0xdeadbeef);
     ret = pGetUserDefaultGeoName(buf, ARRAY_SIZE(buf));
-    ok(ret == 3 && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret == 3 && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %lu.\n", ret, GetLastError());
     ok(!lstrcmpW(buf, L"XX"), "Got unexpected name %s.\n", wine_dbgstr_w(buf));
 
     bret = SetUserGeoID(42483);
-    ok(bret, "Got unexpected bret %#x, GetLastError() %u.\n", bret, GetLastError());
+    ok(bret, "Got unexpected bret %#x, GetLastError() %lu.\n", bret, GetLastError());
     SetLastError(0xdeadbeef);
     ret = pGetUserDefaultGeoName(buf, ARRAY_SIZE(buf));
-    ok(ret == 4 && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret == 4 && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %lu.\n", ret, GetLastError());
     ok(!lstrcmpW(buf, L"011"), "Got unexpected name %s.\n", wine_dbgstr_w(buf));
 
     bret = SetUserGeoID(333);
-    ok(bret, "Got unexpected bret %#x, GetLastError() %u.\n", bret, GetLastError());
+    ok(bret, "Got unexpected bret %#x, GetLastError() %lu.\n", bret, GetLastError());
     SetLastError(0xdeadbeef);
     ret = pGetUserDefaultGeoName(buf, ARRAY_SIZE(buf));
-    ok(ret == 3 && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret == 3 && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %lu.\n", ret, GetLastError());
     ok(!lstrcmpW(buf, L"AN"), "Got unexpected name %s.\n", wine_dbgstr_w(buf));
 
     RegDeleteValueW(key, L"Name");
     RegDeleteValueW(key, L"Region");
     lstrcpyW(buf, L"124");
     status = RegSetValueExW(key, L"Nation", 0, REG_SZ, (BYTE *)buf, (lstrlenW(buf) + 1) * sizeof(*buf));
-    ok(status == ERROR_SUCCESS, "Got unexpected status %#x.\n", status);
+    ok(status == ERROR_SUCCESS, "Got unexpected status %#lx.\n", status);
     SetLastError(0xdeadbeef);
     ret = pGetUserDefaultGeoName(buf, ARRAY_SIZE(buf));
-    ok(ret == 3 && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret == 3 && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %lu.\n", ret, GetLastError());
     ok(!lstrcmpW(buf, L"JM"), "Got unexpected name %s.\n", wine_dbgstr_w(buf));
 
     lstrcpyW(buf, L"333");
     status = RegSetValueExW(key, L"Region", 0, REG_SZ, (BYTE *)buf, (lstrlenW(buf) + 1) * sizeof(*buf));
-    ok(status == ERROR_SUCCESS, "Got unexpected status %#x.\n", status);
+    ok(status == ERROR_SUCCESS, "Got unexpected status %#lx.\n", status);
     SetLastError(0xdeadbeef);
     ret = pGetUserDefaultGeoName(buf, ARRAY_SIZE(buf));
-    ok(ret == 3 && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret == 3 && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %lu.\n", ret, GetLastError());
     ok(!lstrcmpW(buf, L"JM"), "Got unexpected name %s.\n", wine_dbgstr_w(buf));
 
     RegDeleteValueW(key, L"Nation");
     SetLastError(0xdeadbeef);
     ret = pGetUserDefaultGeoName(buf, ARRAY_SIZE(buf));
-    ok(ret == 4 && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret == 4 && GetLastError() == 0xdeadbeef, "Got unexpected ret %u, GetLastError() %lu.\n", ret, GetLastError());
     ok(!lstrcmpW(buf, L"001"), "Got unexpected name %s.\n", wine_dbgstr_w(buf));
 
     /* Restore user geo data. */
     if (have_name)
     {
         status = RegSetValueExW(key, L"Name", 0, REG_SZ, (BYTE *)reg_name, (lstrlenW(reg_name) + 1) * sizeof(*reg_name));
-        ok(status == ERROR_SUCCESS, "Got unexpected status %#x.\n", status);
+        ok(status == ERROR_SUCCESS, "Got unexpected status %#lx.\n", status);
     }
     else
     {
@@ -6994,7 +6994,7 @@ static void test_geo_name(void)
     if (have_nation)
     {
         status = RegSetValueExW(key, L"Nation", 0, REG_SZ, (BYTE *)nation, (lstrlenW(nation) + 1) * sizeof(*nation));
-        ok(status == ERROR_SUCCESS, "Got unexpected status %#x.\n", status);
+        ok(status == ERROR_SUCCESS, "Got unexpected status %#lx.\n", status);
     }
     else
     {
@@ -7003,7 +7003,7 @@ static void test_geo_name(void)
     if (have_region)
     {
         status = RegSetValueExW(key, L"Region", 0, REG_SZ, (BYTE *)region, (lstrlenW(region) + 1) * sizeof(*region));
-        ok(status == ERROR_SUCCESS, "Got unexpected status %#x.\n", status);
+        ok(status == ERROR_SUCCESS, "Got unexpected status %#lx.\n", status);
     }
     else
     {
@@ -7053,7 +7053,7 @@ static void test_EnumCalendarInfoA(void)
 
     ret = EnumCalendarInfoA( calinfo_procA, LOCALE_USER_DEFAULT, ENUM_ALL_CALENDARS,
                              CAL_RETURN_NUMBER | CAL_ICALINTVALUE );
-    ok( ret, "EnumCalendarInfoA for user default locale failed: %u\n", GetLastError() );
+    ok( ret, "EnumCalendarInfoA for user default locale failed: %lu\n", GetLastError() );
 
     for (i = 0; i < ARRAY_SIZE( locales_with_optional_calendars ); i++)
     {
@@ -7061,7 +7061,7 @@ static void test_EnumCalendarInfoA(void)
         ret = EnumCalendarInfoA( calinfo_procA, lcid, ENUM_ALL_CALENDARS,
                                  CAL_RETURN_NUMBER | CAL_ICALINTVALUE );
         ok( ret || broken( GetLastError() == ERROR_INVALID_FLAGS ) /* no locale */,
-            "EnumCalendarInfoA for LCID %#06x failed: %u\n", lcid, GetLastError() );
+            "EnumCalendarInfoA for LCID %#06lx failed: %lu\n", lcid, GetLastError() );
     }
 }
 
@@ -7078,7 +7078,7 @@ static void test_EnumCalendarInfoW(void)
 
     ret = EnumCalendarInfoW( calinfo_procW, LOCALE_USER_DEFAULT, ENUM_ALL_CALENDARS,
                              CAL_RETURN_NUMBER | CAL_ICALINTVALUE );
-    ok( ret, "EnumCalendarInfoW for user default locale failed: %u\n", GetLastError() );
+    ok( ret, "EnumCalendarInfoW for user default locale failed: %lu\n", GetLastError() );
 
     for (i = 0; i < ARRAY_SIZE( locales_with_optional_calendars ); i++)
     {
@@ -7086,7 +7086,7 @@ static void test_EnumCalendarInfoW(void)
         ret = EnumCalendarInfoW( calinfo_procW, lcid, ENUM_ALL_CALENDARS,
                                  CAL_RETURN_NUMBER | CAL_ICALINTVALUE );
         ok( ret || broken( GetLastError() == ERROR_INVALID_FLAGS ) /* no locale */,
-            "EnumCalendarInfoW for LCID %#06x failed: %u\n", lcid, GetLastError() );
+            "EnumCalendarInfoW for LCID %#06lx failed: %lu\n", lcid, GetLastError() );
     }
 }
 
@@ -7104,7 +7104,7 @@ static void test_EnumCalendarInfoExA(void)
 
     ret = EnumCalendarInfoExA( calinfoex_procA, LOCALE_USER_DEFAULT, ENUM_ALL_CALENDARS,
                                CAL_RETURN_NUMBER | CAL_ICALINTVALUE );
-    ok( ret, "EnumCalendarInfoExA for user default locale failed: %u\n", GetLastError() );
+    ok( ret, "EnumCalendarInfoExA for user default locale failed: %lu\n", GetLastError() );
 
     for (i = 0; i < ARRAY_SIZE( locales_with_optional_calendars ); i++)
     {
@@ -7112,7 +7112,7 @@ static void test_EnumCalendarInfoExA(void)
         ret = EnumCalendarInfoExA( calinfoex_procA, lcid, ENUM_ALL_CALENDARS,
                                    CAL_RETURN_NUMBER | CAL_ICALINTVALUE );
         ok( ret || broken( GetLastError() == ERROR_INVALID_FLAGS ) /* no locale */,
-            "EnumCalendarInfoExA for LCID %#06x failed: %u\n", lcid, GetLastError() );
+            "EnumCalendarInfoExA for LCID %#06lx failed: %lu\n", lcid, GetLastError() );
     }
 }
 
@@ -7130,7 +7130,7 @@ static void test_EnumCalendarInfoExW(void)
 
     ret = EnumCalendarInfoExW( calinfoex_procW, LOCALE_USER_DEFAULT, ENUM_ALL_CALENDARS,
                                CAL_RETURN_NUMBER | CAL_ICALINTVALUE );
-    ok( ret, "EnumCalendarInfoExW for user default locale failed: %u\n", GetLastError() );
+    ok( ret, "EnumCalendarInfoExW for user default locale failed: %lu\n", GetLastError() );
 
     for (i = 0; i < ARRAY_SIZE( locales_with_optional_calendars ); i++)
     {
@@ -7138,7 +7138,7 @@ static void test_EnumCalendarInfoExW(void)
         ret = EnumCalendarInfoExW( calinfoex_procW, lcid, ENUM_ALL_CALENDARS,
                                    CAL_RETURN_NUMBER | CAL_ICALINTVALUE );
         ok( ret || broken( GetLastError() == ERROR_INVALID_FLAGS ) /* no locale */,
-            "EnumCalendarInfoExW for LCID %#06x failed: %u\n", lcid, GetLastError() );
+            "EnumCalendarInfoExW for LCID %#06lx failed: %lu\n", lcid, GetLastError() );
     }
 }
 
diff --git a/dlls/kernel32/tests/mailslot.c b/dlls/kernel32/tests/mailslot.c
index 7e488566dbb..a23aad96995 100644
--- a/dlls/kernel32/tests/mailslot.c
+++ b/dlls/kernel32/tests/mailslot.c
@@ -81,38 +81,38 @@ static int mailslot_test(void)
     SetLastError(0xdeadbeef);
     ret = ReadFile(INVALID_HANDLE_VALUE, buffer, 0, &count, NULL);
     ok(!ret, "ReadFile should fail\n");
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n", GetLastError());
-    ok(count == 0, "expected 0, got %u\n", count);
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "wrong error %lu\n", GetLastError());
+    ok(count == 0, "expected 0, got %lu\n", count);
 
     count = 0xdeadbeef;
     SetLastError(0xdeadbeef);
     ret = ReadFile(hSlot, buffer, 0, &count, NULL);
     ok(!ret, "ReadFile should fail\n");
     todo_wine
-    ok(GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %u\n", GetLastError());
-    ok(count == 0, "expected 0, got %u\n", count);
+    ok(GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %lu\n", GetLastError());
+    ok(count == 0, "expected 0, got %lu\n", count);
 
     count = 0;
     memset(buffer, 0, sizeof buffer);
     ret = ReadFile( hSlot, buffer, sizeof buffer, &count, NULL);
     ok( !ret, "slot read\n");
-    if (!ret) ok( GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %u\n", GetLastError() );
-    else ok( count == 0, "wrong count %u\n", count );
+    if (!ret) ok( GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %lu\n", GetLastError() );
+    else ok( count == 0, "wrong count %lu\n", count );
     ok( !WriteFile( hSlot, buffer, sizeof buffer, &count, NULL),
             "slot write\n");
-    ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %lu\n", GetLastError() );
 
     /* now try and open the client, but with the wrong sharing mode */
     hWriter = CreateFileA(szmspath, GENERIC_WRITE,
                              0, NULL, OPEN_EXISTING, 0, NULL);
     ok( hWriter != INVALID_HANDLE_VALUE /* vista */ || GetLastError() == ERROR_SHARING_VIOLATION,
-        "error should be ERROR_SHARING_VIOLATION got %p / %u\n", hWriter, GetLastError());
+        "error should be ERROR_SHARING_VIOLATION got %p / %lu\n", hWriter, GetLastError());
     if (hWriter != INVALID_HANDLE_VALUE) CloseHandle( hWriter );
 
     /* now open the client with the correct sharing mode */
     hWriter = CreateFileA(szmspath, GENERIC_READ|GENERIC_WRITE,
                              FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
-    ok( hWriter != INVALID_HANDLE_VALUE, "existing mailslot err %u\n", GetLastError());
+    ok( hWriter != INVALID_HANDLE_VALUE, "existing mailslot err %lu\n", GetLastError());
 
     /*
      * opening a client should make no difference to
@@ -120,11 +120,11 @@ static int mailslot_test(void)
      */
     ret = ReadFile( hSlot, buffer, sizeof buffer/2, &count, NULL);
     ok( !ret, "slot read\n");
-    if (!ret) ok( GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %u\n", GetLastError() );
-    else ok( count == 0, "wrong count %u\n", count );
+    if (!ret) ok( GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %lu\n", GetLastError() );
+    else ok( count == 0, "wrong count %lu\n", count );
     ok( !WriteFile( hSlot, buffer, sizeof buffer/2, &count, NULL),
             "slot write\n");
-    ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %lu\n", GetLastError() );
 
     /*
      * we can't read from this client, 
@@ -133,13 +133,13 @@ static int mailslot_test(void)
     ok( !ReadFile( hWriter, buffer, sizeof buffer/2, &count, NULL),
             "can read client\n");
     ok( GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ACCESS_DENIED,
-            "wrong error %u\n", GetLastError() );
+            "wrong error %lu\n", GetLastError() );
     ok( WriteFile( hWriter, buffer, sizeof buffer/2, &count, NULL),
             "can't write client\n");
     ok( !ReadFile( hWriter, buffer, sizeof buffer/2, &count, NULL),
             "can read client\n");
     ok( GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_ACCESS_DENIED,
-            "wrong error %u\n", GetLastError() );
+            "wrong error %lu\n", GetLastError() );
 
     /*
      * seeing as there's something in the slot,
@@ -152,8 +152,8 @@ static int mailslot_test(void)
     /* but not again */
     ret = ReadFile( hSlot, buffer, sizeof buffer, &count, NULL);
     ok( !ret, "slot read\n");
-    if (!ret) ok( GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %u\n", GetLastError() );
-    else ok( count == 0, "wrong count %u\n", count );
+    if (!ret) ok( GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %lu\n", GetLastError() );
+    else ok( count == 0, "wrong count %lu\n", count );
 
     /* now try open another writer... should fail */
     hWriter2 = CreateFileA(szmspath, GENERIC_READ|GENERIC_WRITE,
@@ -214,8 +214,8 @@ static int mailslot_test(void)
     /* check there's still no data */
     ret = ReadFile( hSlot, buffer, sizeof buffer, &count, NULL);
     ok( !ret, "slot read\n");
-    if (!ret) ok( GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %u\n", GetLastError() );
-    else ok( count == 0, "wrong count %u\n", count );
+    if (!ret) ok( GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %lu\n", GetLastError() );
+    else ok( count == 0, "wrong count %lu\n", count );
 
     /* write two messages */
     buffer[0] = 'a';
@@ -250,7 +250,7 @@ static int mailslot_test(void)
         "getmailslotinfo failed\n");
     ok( dwNext == 1, "dwNext incorrect\n");
     todo_wine
-        ok( dwMsgCount == 3, "dwMsgCount incorrect %u\n", dwMsgCount);
+        ok( dwMsgCount == 3, "dwMsgCount incorrect %lu\n", dwMsgCount);
 
     buffer[0]=buffer[1]=0;
 
@@ -269,7 +269,7 @@ static int mailslot_test(void)
         "getmailslotinfo failed\n");
     ok( dwNext == 2, "dwNext incorrect\n");
     todo_wine {
-        ok( dwMsgCount == 2, "dwMsgCount incorrect %u\n", dwMsgCount);
+        ok( dwMsgCount == 2, "dwMsgCount incorrect %lu\n", dwMsgCount);
     }
 
     /* read the second message */
@@ -282,9 +282,9 @@ static int mailslot_test(void)
     dwNext = dwMsgCount = 0;
     ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
         "getmailslotinfo failed\n");
-    ok( dwNext == 0, "dwNext incorrect %u\n", dwNext);
+    ok( dwNext == 0, "dwNext incorrect %lu\n", dwNext);
     todo_wine {
-        ok( dwMsgCount == 1, "dwMsgCount incorrect %u\n", dwMsgCount);
+        ok( dwMsgCount == 1, "dwMsgCount incorrect %lu\n", dwMsgCount);
     }
 
     /* read the 3rd (zero length) message */
@@ -307,8 +307,8 @@ static int mailslot_test(void)
     /* check that reads fail */
     ret = ReadFile( hSlot, buffer, sizeof buffer, &count, NULL);
     ok( !ret, "3rd slot read succeeded\n");
-    if (!ret) ok( GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %u\n", GetLastError() );
-    else ok( count == 0, "wrong count %u\n", count );
+    if (!ret) ok( GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %lu\n", GetLastError() );
+    else ok( count == 0, "wrong count %lu\n", count );
 
     /* finally close the mailslot and its client */
     ok( CloseHandle( hWriter2 ), "closing 2nd client\n");
@@ -322,9 +322,9 @@ static int mailslot_test(void)
     memset(buffer, 0, sizeof buffer);
     dwTimeout = GetTickCount();
     ok( !ReadFile( hSlot, buffer, sizeof buffer, &count, NULL), "slot read\n");
-    ok( GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %lu\n", GetLastError() );
     dwTimeout = GetTickCount() - dwTimeout;
-    ok( dwTimeout >= 900, "timeout too short %u\n", dwTimeout );
+    ok( dwTimeout >= 900, "timeout too short %lu\n", dwTimeout );
     ok( CloseHandle( hSlot ), "closing the mailslot\n");
 
     return 0;
diff --git a/dlls/kernel32/tests/module.c b/dlls/kernel32/tests/module.c
index 6d44b50e122..9efbdba336d 100644
--- a/dlls/kernel32/tests/module.c
+++ b/dlls/kernel32/tests/module.c
@@ -134,7 +134,7 @@ static void create_test_dll( const char *name )
     DWORD dummy;
     HANDLE handle = CreateFileA( name, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, 0 );
 
-    ok( handle != INVALID_HANDLE_VALUE, "failed to create file err %u\n", GetLastError() );
+    ok( handle != INVALID_HANDLE_VALUE, "failed to create file err %lu\n", GetLastError() );
     WriteFile( handle, &dll_image, sizeof(dll_image), &dummy, NULL );
     SetFilePointer( handle, dll_image.nt.OptionalHeader.SizeOfImage, NULL, FILE_BEGIN );
     SetEndOfFile( handle );
@@ -156,7 +156,7 @@ static void testGetModuleFileName(const char* name)
     len1A = GetModuleFileNameA(hMod, bufA, sizeof(bufA));
     ok(GetLastError() == ERROR_SUCCESS ||
        broken(GetLastError() == 0xdeadbeef), /* <= XP SP3 */
-       "LastError was not reset: %u\n", GetLastError());
+       "LastError was not reset: %lu\n", GetLastError());
     ok(len1A > 0, "Getting module filename for handle %p\n", hMod);
 
     if (is_unicode_enabled)
@@ -166,15 +166,15 @@ static void testGetModuleFileName(const char* name)
         len1W = GetModuleFileNameW(hMod, bufW, ARRAY_SIZE(bufW));
         ok(GetLastError() == ERROR_SUCCESS ||
            broken(GetLastError() == 0xdeadbeef), /* <= XP SP3 */
-           "LastError was not reset: %u\n", GetLastError());
+           "LastError was not reset: %lu\n", GetLastError());
         ok(len1W > 0, "Getting module filename for handle %p\n", hMod);
     }
 
-    ok(len1A == strlen(bufA), "Unexpected length of GetModuleFilenameA (%d/%d)\n", len1A, lstrlenA(bufA));
+    ok(len1A == strlen(bufA), "Unexpected length of GetModuleFilenameA (%ld/%d)\n", len1A, lstrlenA(bufA));
 
     if (is_unicode_enabled)
     {
-        ok(len1W == lstrlenW(bufW), "Unexpected length of GetModuleFilenameW (%d/%d)\n", len1W, lstrlenW(bufW));
+        ok(len1W == lstrlenW(bufW), "Unexpected length of GetModuleFilenameW (%ld/%d)\n", len1W, lstrlenW(bufW));
         ok(cmpStrAW(bufA, bufW, len1A, len1W), "Comparing GetModuleFilenameAW results\n");
     }
 
@@ -189,11 +189,11 @@ static void testGetModuleFileName(const char* name)
         len2W = GetModuleFileNameW(hMod, bufW, len1W / 2);
         ok(len2W > 0, "Getting module filename for handle %p\n", hMod);
         ok(cmpStrAW(bufA, bufW, len2A, len2W), "Comparing GetModuleFilenameAW results with buffer too small\n" );
-        ok(len1W / 2 == len2W, "Correct length in GetModuleFilenameW with buffer too small (%d/%d)\n", len1W / 2, len2W);
+        ok(len1W / 2 == len2W, "Correct length in GetModuleFilenameW with buffer too small (%ld/%ld)\n", len1W / 2, len2W);
     }
 
     ok(len1A / 2 == len2A,
-       "Correct length in GetModuleFilenameA with buffer too small (%d/%d)\n", len1A / 2, len2A);
+       "Correct length in GetModuleFilenameA with buffer too small (%ld/%ld)\n", len1A / 2, len2A);
 
     len1A = GetModuleFileNameA(hMod, bufA, 0x10000);
     ok(len1A > 0, "Getting module filename for handle %p\n", hMod);
@@ -228,16 +228,16 @@ static void testLoadLibraryA(void)
     SetLastError(0xdeadbeef);
     hModule = LoadLibraryA("kernel32.dll");
     ok( hModule != NULL, "kernel32.dll should be loadable\n");
-    ok( GetLastError() == 0xdeadbeef, "GetLastError should be 0xdeadbeef but is %d\n", GetLastError());
+    ok( GetLastError() == 0xdeadbeef, "GetLastError should be 0xdeadbeef but is %ld\n", GetLastError());
 
     fp = GetProcAddress(hModule, "CreateFileA");
     ok( fp != NULL, "CreateFileA should be there\n");
-    ok( GetLastError() == 0xdeadbeef, "GetLastError should be 0xdeadbeef but is %d\n", GetLastError());
+    ok( GetLastError() == 0xdeadbeef, "GetLastError should be 0xdeadbeef but is %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     hModule1 = LoadLibraryA("kernel32   ");
     ok( hModule1 != NULL, "\"kernel32   \" should be loadable\n" );
-    ok( GetLastError() == 0xdeadbeef, "GetLastError should be 0xdeadbeef but is %d\n", GetLastError() );
+    ok( GetLastError() == 0xdeadbeef, "GetLastError should be 0xdeadbeef but is %ld\n", GetLastError() );
     ok( hModule == hModule1, "Loaded wrong module\n" );
     FreeLibrary(hModule1);
     FreeLibrary(hModule);
@@ -302,7 +302,7 @@ static void testLoadLibraryA_Wrong(void)
     SetLastError(0xdeadbeef);
     hModule = LoadLibraryA("non_ex_pv.dll");
     ok( !hModule, "non_ex_pv.dll should be not loadable\n");
-    ok( GetLastError() == ERROR_MOD_NOT_FOUND, "Expected ERROR_MOD_NOT_FOUND, got %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_MOD_NOT_FOUND, "Expected ERROR_MOD_NOT_FOUND, got %ld\n", GetLastError() );
 
     /* Just in case */
     FreeLibrary(hModule);
@@ -315,12 +315,12 @@ static void testGetProcAddress_Wrong(void)
     SetLastError(0xdeadbeef);
     fp = GetProcAddress(NULL, "non_ex_call");
     ok( !fp, "non_ex_call should not be found\n");
-    ok( GetLastError() == ERROR_PROC_NOT_FOUND, "Expected ERROR_PROC_NOT_FOUND, got %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_PROC_NOT_FOUND, "Expected ERROR_PROC_NOT_FOUND, got %ld\n", GetLastError() );
 
     SetLastError(0xdeadbeef);
     fp = GetProcAddress((HMODULE)0xdeadbeef, "non_ex_call");
     ok( !fp, "non_ex_call should not be found\n");
-    ok( GetLastError() == ERROR_MOD_NOT_FOUND, "Expected ERROR_MOD_NOT_FOUND, got %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_MOD_NOT_FOUND, "Expected ERROR_MOD_NOT_FOUND, got %ld\n", GetLastError() );
 }
 
 static void testLoadLibraryEx(void)
@@ -341,7 +341,7 @@ static void testLoadLibraryEx(void)
     ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
     ok(GetLastError() == ERROR_MOD_NOT_FOUND ||
        GetLastError() == ERROR_INVALID_PARAMETER,
-       "Expected ERROR_MOD_NOT_FOUND or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+       "Expected ERROR_MOD_NOT_FOUND or ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     /* empty lpFileName */
     SetLastError(0xdeadbeef);
@@ -349,7 +349,7 @@ static void testLoadLibraryEx(void)
     ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
     ok(GetLastError() == ERROR_MOD_NOT_FOUND ||
        GetLastError() == ERROR_INVALID_PARAMETER /* win8 */,
-       "Expected ERROR_MOD_NOT_FOUND or ERROR_DLL_NOT_FOUND, got %d\n", GetLastError());
+       "Expected ERROR_MOD_NOT_FOUND or ERROR_DLL_NOT_FOUND, got %ld\n", GetLastError());
 
     /* hFile is non-NULL */
     SetLastError(0xdeadbeef);
@@ -357,21 +357,21 @@ static void testLoadLibraryEx(void)
     ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
     ok(GetLastError() == ERROR_SHARING_VIOLATION ||
        GetLastError() == ERROR_INVALID_PARAMETER, /* win2k3 */
-       "Unexpected last error, got %d\n", GetLastError());
+       "Unexpected last error, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     hmodule = LoadLibraryExA("testfile.dll", (HANDLE)0xdeadbeef, 0);
     ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
     ok(GetLastError() == ERROR_SHARING_VIOLATION ||
        GetLastError() == ERROR_INVALID_PARAMETER, /* win2k3 */
-       "Unexpected last error, got %d\n", GetLastError());
+       "Unexpected last error, got %ld\n", GetLastError());
 
     /* try to open a file that is locked */
     SetLastError(0xdeadbeef);
     hmodule = LoadLibraryExA("testfile.dll", NULL, 0);
     ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
     ok(GetLastError() == ERROR_SHARING_VIOLATION,
-       "Expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
+       "Expected ERROR_SHARING_VIOLATION, got %ld\n", GetLastError());
 
     /* lpFileName does not matter */
     if (is_unicode_enabled)
@@ -381,7 +381,7 @@ static void testLoadLibraryEx(void)
         ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
         ok(GetLastError() == ERROR_MOD_NOT_FOUND ||
            GetLastError() == ERROR_INVALID_PARAMETER, /* win2k3 */
-           "Expected ERROR_MOD_NOT_FOUND or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+           "Expected ERROR_MOD_NOT_FOUND or ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
     }
 
     CloseHandle(hfile);
@@ -390,7 +390,7 @@ static void testLoadLibraryEx(void)
     SetLastError(0xdeadbeef);
     hmodule = LoadLibraryExA("testfile.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
     ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
-    ok(GetLastError() == ERROR_FILE_INVALID, "Expected ERROR_FILE_INVALID, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_INVALID, "Expected ERROR_FILE_INVALID, got %ld\n", GetLastError());
 
     DeleteFileA("testfile.dll");
 
@@ -405,13 +405,13 @@ static void testLoadLibraryEx(void)
     ok(hmodule != 0, "Expected valid module handle\n");
     ok(GetLastError() == 0xdeadbeef ||
        GetLastError() == ERROR_SUCCESS,
-       "Expected 0xdeadbeef or ERROR_SUCCESS, got %d\n", GetLastError());
+       "Expected 0xdeadbeef or ERROR_SUCCESS, got %ld\n", GetLastError());
 
     /* try invalid file handle */
     SetLastError(0xdeadbeef);
     hmodule = LoadLibraryExA(path, (HANDLE)0xdeadbeef, 0);
     if (!hmodule)  /* succeeds on xp and older */
-        ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
+        ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError());
 
     FreeLibrary(hmodule);
 
@@ -419,7 +419,7 @@ static void testLoadLibraryEx(void)
     SetLastError(0xdeadbeef);
     hmodule = LoadLibraryExA("kernel32.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
     ok(hmodule != 0, "Expected valid module handle\n");
-    ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %ld\n", GetLastError());
 
     FreeLibrary(hmodule);
 
@@ -433,7 +433,7 @@ static void testLoadLibraryEx(void)
     hmodule = LoadLibraryExA(path, NULL, LOAD_LIBRARY_AS_DATAFILE);
     ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
     ok(GetLastError() == ERROR_FILE_NOT_FOUND,
-       "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+       "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
 
     /* Free the loaded dll when it's the first time this dll is loaded
        in process - First time should pass, second fail */
@@ -444,14 +444,14 @@ static void testLoadLibraryEx(void)
     SetLastError(0xdeadbeef);
     ret = FreeLibrary( (HMODULE)((ULONG_PTR)hmodule + 0x1230));
     ok(!ret, "Free succeeded on wrong handle\n");
-    ok(GetLastError() == ERROR_BAD_EXE_FORMAT, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_BAD_EXE_FORMAT, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = FreeLibrary(hmodule);
-    ok(ret, "Expected to be able to free the module, failed with %d\n", GetLastError());
+    ok(ret, "Expected to be able to free the module, failed with %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = FreeLibrary(hmodule);
-    ok(!ret, "Unexpected ability to free the module, failed with %d\n", GetLastError());
+    ok(!ret, "Unexpected ability to free the module, failed with %ld\n", GetLastError());
 
     /* load with full path, name without extension */
     GetSystemDirectoryA(path, MAX_PATH);
@@ -499,13 +499,13 @@ static void test_LoadLibraryEx_search_flags(void)
     GetTempFileNameA( path, "tmp", 0, buf );
     DeleteFileA( buf );
     ret = CreateDirectoryA( buf, NULL );
-    ok( ret, "CreateDirectory failed err %u\n", GetLastError() );
+    ok( ret, "CreateDirectory failed err %lu\n", GetLastError() );
     p = buf + strlen( buf );
     for (i = 1; i <= 6; i++)
     {
         sprintf( p, "\\%u", i );
         ret = CreateDirectoryA( buf, NULL );
-        ok( ret, "CreateDirectory failed err %u\n", GetLastError() );
+        ok( ret, "CreateDirectory failed err %lu\n", GetLastError() );
         if (i >= 5) continue;  /* dirs 5 and 6 are left empty */
         sprintf( p, "\\%u\\winetestdll.dll", i );
         create_test_dll( buf );
@@ -517,13 +517,13 @@ static void test_LoadLibraryEx_search_flags(void)
 
     SetLastError( 0xdeadbeef );
     mod = LoadLibraryA( "1\\winetestdll.dll" );
-    ok( mod != NULL, "LoadLibrary failed err %u\n", GetLastError() );
+    ok( mod != NULL, "LoadLibrary failed err %lu\n", GetLastError() );
     FreeLibrary( mod );
 
     SetLastError( 0xdeadbeef );
     sprintf( path, "%c:1\\winetestdll.dll", buf[0] );
     mod = LoadLibraryA( path );
-    ok( mod != NULL, "LoadLibrary failed err %u\n", GetLastError() );
+    ok( mod != NULL, "LoadLibrary failed err %lu\n", GetLastError() );
     FreeLibrary( mod );
 
     if (pAddDllDirectory)
@@ -531,11 +531,11 @@ static void test_LoadLibraryEx_search_flags(void)
         SetLastError( 0xdeadbeef );
         mod = LoadLibraryExA( "1\\winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_SYSTEM32 );
         ok( !mod, "LoadLibrary succeeded\n" );
-        ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         mod = LoadLibraryExA( path, 0, LOAD_LIBRARY_SEARCH_SYSTEM32 );
-        ok( mod != NULL, "LoadLibrary failed err %u\n", GetLastError() );
+        ok( mod != NULL, "LoadLibrary failed err %lu\n", GetLastError() );
         FreeLibrary( mod );
     }
 
@@ -544,21 +544,21 @@ static void test_LoadLibraryEx_search_flags(void)
 
     SetLastError( 0xdeadbeef );
     mod = LoadLibraryA( "winetestdll.dll" );
-    ok( mod != NULL, "LoadLibrary failed err %u\n", GetLastError() );
+    ok( mod != NULL, "LoadLibrary failed err %lu\n", GetLastError() );
     FreeLibrary( mod );
 
     SetLastError( 0xdeadbeef );
     sprintf( path, "%c:winetestdll.dll", buf[0] );
     mod = LoadLibraryA( path );
     ok( mod != NULL || broken(!mod), /* win10 disallows this but allows c:1\\winetestdll.dll */
-        "LoadLibrary failed err %u\n", GetLastError() );
-    if (!mod) ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
+        "LoadLibrary failed err %lu\n", GetLastError() );
+    if (!mod) ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %lu\n", GetLastError() );
     else FreeLibrary( mod );
 
     SetLastError( 0xdeadbeef );
     sprintf( path, "%s\\winetestdll.dll", buf + 2 );
     mod = LoadLibraryA( path );
-    ok( mod != NULL, "LoadLibrary failed err %u\n", GetLastError() );
+    ok( mod != NULL, "LoadLibrary failed err %lu\n", GetLastError() );
     FreeLibrary( mod );
 
     if (pAddDllDirectory)
@@ -566,43 +566,43 @@ static void test_LoadLibraryEx_search_flags(void)
         SetLastError( 0xdeadbeef );
         mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_SYSTEM32 );
         ok( !mod, "LoadLibrary succeeded\n" );
-        ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         mod = LoadLibraryExA( path, 0, LOAD_LIBRARY_SEARCH_SYSTEM32 );
-        ok( mod != NULL, "LoadLibrary failed err %u\n", GetLastError() );
+        ok( mod != NULL, "LoadLibrary failed err %lu\n", GetLastError() );
         FreeLibrary( mod );
 
         SetLastError( 0xdeadbeef );
         sprintf( path, "%s\\winetestdll.dll", buf + 2 );
         mod = LoadLibraryExA( path, 0, LOAD_LIBRARY_SEARCH_SYSTEM32 );
-        ok( mod != NULL, "LoadLibrary failed err %u\n", GetLastError() );
+        ok( mod != NULL, "LoadLibrary failed err %lu\n", GetLastError() );
         FreeLibrary( mod );
 
         SetLastError( 0xdeadbeef );
         mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_WITH_ALTERED_SEARCH_PATH );
         ok( !mod, "LoadLibrary succeeded\n" );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_WITH_ALTERED_SEARCH_PATH );
         ok( !mod, "LoadLibrary succeeded\n" );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_SYSTEM32 | LOAD_WITH_ALTERED_SEARCH_PATH );
         ok( !mod, "LoadLibrary succeeded\n" );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_WITH_ALTERED_SEARCH_PATH );
         ok( !mod, "LoadLibrary succeeded\n" );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_USER_DIRS | LOAD_WITH_ALTERED_SEARCH_PATH );
         ok( !mod, "LoadLibrary succeeded\n" );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
     }
 
     SetCurrentDirectoryA( curdir );
@@ -612,7 +612,7 @@ static void test_LoadLibraryEx_search_flags(void)
     SetLastError( 0xdeadbeef );
     mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
     ok( !mod, "LoadLibrary succeeded\n" );
-    ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %lu\n", GetLastError() );
 
     if (0)  /* crashes on win10 */
     {
@@ -620,38 +620,38 @@ static void test_LoadLibraryEx_search_flags(void)
     mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_USER_DIRS );
     ok( !mod, "LoadLibrary succeeded\n" );
     ok( GetLastError() == ERROR_MOD_NOT_FOUND || broken(GetLastError() == ERROR_NOT_ENOUGH_MEMORY),
-        "wrong error %u\n", GetLastError() );
+        "wrong error %lu\n", GetLastError() );
     }
 
     SetLastError( 0xdeadbeef );
     mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_SYSTEM32 );
     ok( !mod, "LoadLibrary succeeded\n" );
-    ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
     ok( !mod, "LoadLibrary succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32 );
     ok( !mod, "LoadLibrary succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     mod = LoadLibraryExA( "foo\\winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
     ok( !mod, "LoadLibrary succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     mod = LoadLibraryExA( "\\windows\\winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
     ok( !mod, "LoadLibrary succeeded\n" );
-    ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     mod = LoadLibraryA( "1\\winetestdll.dll" );
     ok( !mod, "LoadLibrary succeeded\n" );
-    ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %lu\n", GetLastError() );
 
     for (j = 0; j < ARRAY_SIZE(tests); j++)
     {
@@ -673,7 +673,7 @@ static void test_LoadLibraryEx_search_flags(void)
         mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_USER_DIRS );
         if (tests[j].expect)
         {
-            ok( mod != NULL, "%u: LoadLibrary failed err %u\n", j, GetLastError() );
+            ok( mod != NULL, "%u: LoadLibrary failed err %lu\n", j, GetLastError() );
             GetModuleFileNameA( mod, path, MAX_PATH );
             sprintf( p, "\\%u\\winetestdll.dll", tests[j].expect );
             ok( !lstrcmpiA( path, buf ), "%u: wrong module %s expected %s\n", j, path, buf );
@@ -682,7 +682,7 @@ static void test_LoadLibraryEx_search_flags(void)
         {
             ok( !mod, "%u: LoadLibrary succeeded\n", j );
             ok( GetLastError() == ERROR_MOD_NOT_FOUND || broken(GetLastError() == ERROR_NOT_ENOUGH_MEMORY),
-                "%u: wrong error %u\n", j, GetLastError() );
+                "%u: wrong error %lu\n", j, GetLastError() );
         }
         FreeLibrary( mod );
 
@@ -705,12 +705,12 @@ static void test_LoadLibraryEx_search_flags(void)
 
             FreeLibrary(mod);
             mod = LoadLibraryExA( apiset_dll, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
-            ok( !!mod, "Got NULL module, error %u.\n", GetLastError() );
+            ok( !!mod, "Got NULL module, error %lu.\n", GetLastError() );
             ok( !!GetModuleHandleA( apiset_dll ), "Got NULL handle.\n" );
             shcore = GetModuleHandleA( "shcore.dll" );
             ok( mod == shcore, "wrong module %p/%p\n", mod, shcore );
             ret = FreeLibrary( mod );
-            ok( ret, "FreeLibrary failed, error %u.\n", GetLastError() );
+            ok( ret, "FreeLibrary failed, error %lu.\n", GetLastError() );
             shcore = GetModuleHandleA( "shcore.dll" );
             ok( !shcore, "shcore not unloaded\n" );
 
@@ -718,12 +718,12 @@ static void test_LoadLibraryEx_search_flags(void)
             strcpy( buffer, apiset_dll );
             buffer[strlen(buffer) - 4] = 0;
             mod = LoadLibraryExA( buffer, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
-            ok( !!mod, "Got NULL module, error %u.\n", GetLastError() );
+            ok( !!mod, "Got NULL module, error %lu.\n", GetLastError() );
             ok( !!GetModuleHandleA( apiset_dll ), "Got NULL handle.\n" );
             shcore = GetModuleHandleA( "shcore.dll" );
             ok( mod == shcore, "wrong module %p/%p\n", mod, shcore );
             ret = FreeLibrary( mod );
-            ok( ret, "FreeLibrary failed, error %u.\n", GetLastError() );
+            ok( ret, "FreeLibrary failed, error %lu.\n", GetLastError() );
             shcore = GetModuleHandleA( "shcore.dll" );
             ok( !shcore, "shcore not unloaded\n" );
 
@@ -731,14 +731,14 @@ static void test_LoadLibraryEx_search_flags(void)
             strcpy( buffer, apiset_dll );
             buffer[strlen(buffer) - 5] = '9';
             mod = LoadLibraryExA( buffer, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
-            ok( !!mod || broken(!mod) /* win8 */, "Got NULL module, error %u.\n", GetLastError() );
+            ok( !!mod || broken(!mod) /* win8 */, "Got NULL module, error %lu.\n", GetLastError() );
             if (mod)
             {
                 ok( !!GetModuleHandleA( apiset_dll ), "Got NULL handle.\n" );
                 shcore = GetModuleHandleA( "shcore.dll" );
                 ok( mod == shcore, "wrong module %p/%p\n", mod, shcore );
                 ret = FreeLibrary( mod );
-                ok( ret, "FreeLibrary failed, error %u.\n", GetLastError() );
+                ok( ret, "FreeLibrary failed, error %lu.\n", GetLastError() );
             }
             shcore = GetModuleHandleA( "shcore.dll" );
             ok( !shcore, "shcore not unloaded\n" );
@@ -750,11 +750,11 @@ static void test_LoadLibraryEx_search_flags(void)
             SetLastError( 0xdeadbeef );
             mod = LoadLibraryExA( buffer, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
             ok( !mod, "Loaded %s\n", debugstr_a(buffer) );
-            ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
+            ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %lu\n", GetLastError() );
             SetLastError( 0xdeadbeef );
             mod = LoadLibraryA( buffer );
             ok( !mod, "Loaded %s\n", debugstr_a(buffer) );
-            ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
+            ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %lu\n", GetLastError() );
         }
         else
         {
@@ -765,20 +765,20 @@ static void test_LoadLibraryEx_search_flags(void)
         mod = GetModuleHandleA( "rasapi32.dll" );
         ok( !mod, "rasapi32 already loaded\n" );
         mod = LoadLibraryA( "rasapi32.dll" );
-        ok( !!mod, "rasapi32 not found %u\n", GetLastError() );
+        ok( !!mod, "rasapi32 not found %lu\n", GetLastError() );
         FreeLibrary( mod );
         SetLastError( 0xdeadbeef );
         mod = LoadLibraryExA( "rasapi32.dll", NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
         ok( !mod, "rasapi32 loaded\n" );
-        ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %lu\n", GetLastError() );
         SetLastError( 0xdeadbeef );
         mod = LoadLibraryExA( "ext-ms-win-ras-rasapi32-l1-1-0.dll", NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
         todo_wine /* rasapi32 doesn't have interesting dependencies on wine */
         ok( !mod, "rasapi32 loaded\n" );
         if (mod) FreeLibrary( mod );
-        else ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
+        else ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %lu\n", GetLastError() );
         mod = LoadLibraryA( "ext-ms-win-ras-rasapi32-l1-1-0.dll" );
-        ok( !!mod || broken(!mod) /* win7 */, "rasapi32 not found %u\n", GetLastError() );
+        ok( !!mod || broken(!mod) /* win7 */, "rasapi32 not found %lu\n", GetLastError() );
         if (mod) FreeLibrary( mod );
         mod = GetModuleHandleA( "rasapi32.dll" );
         ok( !mod, "rasapi32 still loaded\n" );
@@ -832,24 +832,24 @@ static void testGetDllDirectory(void)
 
         /* no buffer, determine length */
         ret = pGetDllDirectoryA(0, NULL);
-        ok(ret == length + 1, "Expected %u, got %u\n", length + 1, ret);
+        ok(ret == length + 1, "Expected %lu, got %lu\n", length + 1, ret);
 
         ret = pGetDllDirectoryW(0, NULL);
-        ok(ret == length + 1, "Expected %u, got %u\n", length + 1, ret);
+        ok(ret == length + 1, "Expected %lu, got %lu\n", length + 1, ret);
 
         /* buffer of exactly the right size */
         bufferA[length] = 'A';
         bufferA[length + 1] = 'A';
         ret = pGetDllDirectoryA(length + 1, bufferA);
         ok(ret == length || broken(ret + 1 == length) /* win8 */,
-           "i=%d, Expected %u(+1), got %u\n", i, length, ret);
+           "i=%d, Expected %lu(+1), got %lu\n", i, length, ret);
         ok(bufferA[length + 1] == 'A', "i=%d, Buffer overflow\n", i);
         ok(strcmp(bufferA, dll_directories[i]) == 0, "i=%d, Wrong path returned: '%s'\n", i, bufferA);
 
         bufferW[length] = 'A';
         bufferW[length + 1] = 'A';
         ret = pGetDllDirectoryW(length + 1, bufferW);
-        ok(ret == length, "i=%d, Expected %u, got %u\n", i, length, ret);
+        ok(ret == length, "i=%d, Expected %lu, got %lu\n", i, length, ret);
         ok(bufferW[length + 1] == 'A', "i=%d, Buffer overflow\n", i);
         ok(cmpStrAW(dll_directories[i], bufferW, length, length),
            "i=%d, Wrong path returned: %s\n", i, wine_dbgstr_w(bufferW));
@@ -858,24 +858,24 @@ static void testGetDllDirectory(void)
          * on the Windows version and whether the A or W API is called. */
         bufferA[0] = 'A';
         ret = pGetDllDirectoryA(0, bufferA);
-        ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
+        ok(ret == length + 1, "i=%d, Expected %lu, got %lu\n", i, length + 1, ret);
 
         bufferW[0] = 'A';
         ret = pGetDllDirectoryW(0, bufferW);
-        ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
+        ok(ret == length + 1, "i=%d, Expected %lu, got %lu\n", i, length + 1, ret);
         ok(bufferW[0] == 'A' || broken(bufferW[0] == 0), /* XP, 2003 */
            "i=%d, Buffer overflow\n", i);
 
         /* buffer just one too short */
         bufferA[0] = 'A';
         ret = pGetDllDirectoryA(length, bufferA);
-        ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
+        ok(ret == length + 1, "i=%d, Expected %lu, got %lu\n", i, length + 1, ret);
         if (length != 0)
             ok(bufferA[0] == 0, "i=%d, Buffer not null terminated\n", i);
 
         bufferW[0] = 'A';
         ret = pGetDllDirectoryW(length, bufferW);
-        ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
+        ok(ret == length + 1, "i=%d, Expected %lu, got %lu\n", i, length + 1, ret);
         if (length != 0)
             ok(bufferW[0] == 0, "i=%d, Buffer overflow\n", i);
 
@@ -884,10 +884,10 @@ static void testGetDllDirectory(void)
             /* crashes on win8 */
             /* no buffer, but too short length */
             ret = pGetDllDirectoryA(length, NULL);
-            ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
+            ok(ret == length + 1, "i=%d, Expected %lu, got %lu\n", i, length + 1, ret);
 
             ret = pGetDllDirectoryW(length, NULL);
-            ok(ret == length + 1, "i=%d, Expected %u, got %u\n", i, length + 1, ret);
+            ok(ret == length + 1, "i=%d, Expected %lu, got %lu\n", i, length + 1, ret);
         }
 
         if (pLdrGetDllDirectory)
@@ -897,7 +897,7 @@ static void testGetDllDirectory(void)
             str.Buffer = bufferW;
             str.MaximumLength = sizeof(bufferW);
             status = pLdrGetDllDirectory( &str );
-            ok( !status, "LdrGetDllDirectory failed %x\n", status );
+            ok( !status, "LdrGetDllDirectory failed %lx\n", status );
             ok( cmpStrAW( dll_directories[i], bufferW, strlen(dll_directories[i]),
                           str.Length / sizeof(WCHAR) ), "%u: got %s instead of %s\n",
                 i, wine_dbgstr_w(bufferW), dll_directories[i] );
@@ -906,11 +906,11 @@ static void testGetDllDirectory(void)
                 memset( bufferW, 0xcc, sizeof(bufferW) );
                 str.MaximumLength = (strlen( dll_directories[i] ) - 1) * sizeof(WCHAR);
                 status = pLdrGetDllDirectory( &str );
-                ok( status == STATUS_BUFFER_TOO_SMALL, "%u: LdrGetDllDirectory failed %x\n", i, status );
+                ok( status == STATUS_BUFFER_TOO_SMALL, "%u: LdrGetDllDirectory failed %lx\n", i, status );
                 ok( bufferW[0] == 0 && bufferW[1] == 0xcccc,
                     "%u: buffer %x %x\n", i, bufferW[0], bufferW[1] );
                 length = (strlen( dll_directories[i] ) + 1) * sizeof(WCHAR);
-                ok( str.Length == length, "%u: wrong len %u / %u\n", i, str.Length, length );
+                ok( str.Length == length, "%u: wrong len %u / %lu\n", i, str.Length, length );
             }
         }
     }
@@ -963,18 +963,18 @@ static void testGetModuleHandleEx(void)
     ret = GetModuleHandleExA( 0, NULL, NULL );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
+    ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
 
     SetLastError( 0xdeadbeef );
     ret = GetModuleHandleExA( 0, "kernel32", NULL );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
+    ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
 
     SetLastError( 0xdeadbeef );
     mod = (HMODULE)0xdeadbeef;
     ret = GetModuleHandleExA( 0, "kernel32", &mod );
-    ok( ret, "unexpected failure %u\n", GetLastError() );
+    ok( ret, "unexpected failure %lu\n", GetLastError() );
     ok( mod != (HMODULE)0xdeadbeef, "got %p\n", mod );
     FreeLibrary( mod );
 
@@ -983,25 +983,25 @@ static void testGetModuleHandleEx(void)
     ret = GetModuleHandleExA( 0, "nosuchmod", &mod );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
+    ok( error == ERROR_MOD_NOT_FOUND, "got %lu\n", error );
     ok( mod == NULL, "got %p\n", mod );
 
     SetLastError( 0xdeadbeef );
     ret = GetModuleHandleExW( 0, NULL, NULL );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
+    ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
 
     SetLastError( 0xdeadbeef );
     ret = GetModuleHandleExW( 0, kernel32W, NULL );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
+    ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
 
     SetLastError( 0xdeadbeef );
     mod = (HMODULE)0xdeadbeef;
     ret = GetModuleHandleExW( 0, kernel32W, &mod );
-    ok( ret, "unexpected failure %u\n", GetLastError() );
+    ok( ret, "unexpected failure %lu\n", GetLastError() );
     ok( mod != (HMODULE)0xdeadbeef, "got %p\n", mod );
     FreeLibrary( mod );
 
@@ -1010,25 +1010,25 @@ static void testGetModuleHandleEx(void)
     ret = GetModuleHandleExW( 0, nosuchmodW, &mod );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
+    ok( error == ERROR_MOD_NOT_FOUND, "got %lu\n", error );
     ok( mod == NULL, "got %p\n", mod );
 
     SetLastError( 0xdeadbeef );
     ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, NULL );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
+    ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
 
     SetLastError( 0xdeadbeef );
     ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "kernel32", NULL );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
+    ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
 
     SetLastError( 0xdeadbeef );
     mod = (HMODULE)0xdeadbeef;
     ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "kernel32", &mod );
-    ok( ret, "unexpected failure %u\n", GetLastError() );
+    ok( ret, "unexpected failure %lu\n", GetLastError() );
     ok( mod != (HMODULE)0xdeadbeef, "got %p\n", mod );
 
     SetLastError( 0xdeadbeef );
@@ -1036,25 +1036,25 @@ static void testGetModuleHandleEx(void)
     ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "nosuchmod", &mod );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
+    ok( error == ERROR_MOD_NOT_FOUND, "got %lu\n", error );
     ok( mod == NULL, "got %p\n", mod );
 
     SetLastError( 0xdeadbeef );
     ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, NULL );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
+    ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
 
     SetLastError( 0xdeadbeef );
     ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, kernel32W, NULL );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
+    ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
 
     SetLastError( 0xdeadbeef );
     mod = (HMODULE)0xdeadbeef;
     ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, kernel32W, &mod );
-    ok( ret, "unexpected failure %u\n", GetLastError() );
+    ok( ret, "unexpected failure %lu\n", GetLastError() );
     ok( mod != (HMODULE)0xdeadbeef, "got %p\n", mod );
 
     SetLastError( 0xdeadbeef );
@@ -1062,7 +1062,7 @@ static void testGetModuleHandleEx(void)
     ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, nosuchmodW, &mod );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
+    ok( error == ERROR_MOD_NOT_FOUND, "got %lu\n", error );
     ok( mod == NULL, "got %p\n", mod );
 
     mod_kernel32 = LoadLibraryA( "kernel32" );
@@ -1071,18 +1071,18 @@ static void testGetModuleHandleEx(void)
     ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, NULL, NULL );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
+    ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
 
     SetLastError( 0xdeadbeef );
     ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)mod_kernel32, NULL );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
+    ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
 
     SetLastError( 0xdeadbeef );
     mod = (HMODULE)0xdeadbeef;
     ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)mod_kernel32, &mod );
-    ok( ret, "unexpected failure %u\n", GetLastError() );
+    ok( ret, "unexpected failure %lu\n", GetLastError() );
     ok( mod == mod_kernel32, "got %p\n", mod );
     FreeLibrary( mod );
 
@@ -1091,25 +1091,25 @@ static void testGetModuleHandleEx(void)
     ret = GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)0xbeefdead, &mod );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
+    ok( error == ERROR_MOD_NOT_FOUND, "got %lu\n", error );
     ok( mod == NULL, "got %p\n", mod );
 
     SetLastError( 0xdeadbeef );
     ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, NULL, NULL );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
+    ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
 
     SetLastError( 0xdeadbeef );
     ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)mod_kernel32, NULL );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
+    ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
 
     SetLastError( 0xdeadbeef );
     mod = (HMODULE)0xdeadbeef;
     ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)mod_kernel32, &mod );
-    ok( ret, "unexpected failure %u\n", GetLastError() );
+    ok( ret, "unexpected failure %lu\n", GetLastError() );
     ok( mod == mod_kernel32, "got %p\n", mod );
     FreeLibrary( mod );
 
@@ -1118,7 +1118,7 @@ static void testGetModuleHandleEx(void)
     ret = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)0xbeefdead, &mod );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
+    ok( error == ERROR_MOD_NOT_FOUND, "got %lu\n", error );
     ok( mod == NULL, "got %p\n", mod );
 
     SetLastError( 0xdeadbeef );
@@ -1127,7 +1127,7 @@ static void testGetModuleHandleEx(void)
                               | GET_MODULE_HANDLE_EX_FLAG_PIN, (LPCWSTR)mod_kernel32, &mod );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
+    ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
     ok( mod == NULL, "got %p\n", mod );
 
     SetLastError( 0xdeadbeef );
@@ -1135,7 +1135,7 @@ static void testGetModuleHandleEx(void)
     ret = GetModuleHandleExW( 8, kernel32W, &mod );
     error = GetLastError();
     ok( !ret, "unexpected success\n" );
-    ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
+    ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
     ok( mod == NULL, "got %p\n", mod );
 
     FreeLibrary( mod_kernel32 );
@@ -1180,32 +1180,32 @@ static void test_AddDllDirectory(void)
     buf[0] = '\0';
     GetTempPathW(ARRAY_SIZE(path), path );
     ret = GetTempFileNameW( path, tmpW, 0, buf );
-    ok( ret, "GetTempFileName failed err %u\n", GetLastError() );
+    ok( ret, "GetTempFileName failed err %lu\n", GetLastError() );
     SetLastError( 0xdeadbeef );
     cookie = pAddDllDirectory( buf );
-    ok( cookie != NULL, "AddDllDirectory failed err %u\n", GetLastError() );
+    ok( cookie != NULL, "AddDllDirectory failed err %lu\n", GetLastError() );
     SetLastError( 0xdeadbeef );
     ret = pRemoveDllDirectory( cookie );
-    ok( ret, "RemoveDllDirectory failed err %u\n", GetLastError() );
+    ok( ret, "RemoveDllDirectory failed err %lu\n", GetLastError() );
 
     DeleteFileW( buf );
     SetLastError( 0xdeadbeef );
     cookie = pAddDllDirectory( buf );
     ok( !cookie, "AddDllDirectory succeeded\n" );
-    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %lu\n", GetLastError() );
     cookie = pAddDllDirectory( dotW );
     ok( !cookie, "AddDllDirectory succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
     cookie = pAddDllDirectory( rootW );
-    ok( cookie != NULL, "AddDllDirectory failed err %u\n", GetLastError() );
+    ok( cookie != NULL, "AddDllDirectory failed err %lu\n", GetLastError() );
     SetLastError( 0xdeadbeef );
     ret = pRemoveDllDirectory( cookie );
-    ok( ret, "RemoveDllDirectory failed err %u\n", GetLastError() );
+    ok( ret, "RemoveDllDirectory failed err %lu\n", GetLastError() );
     GetWindowsDirectoryW( buf, MAX_PATH );
     lstrcpyW( buf + 2, tmpW );
     cookie = pAddDllDirectory( buf );
     ok( !cookie, "AddDllDirectory succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 }
 
 static void test_SetDefaultDllDirectories(void)
@@ -1223,12 +1223,12 @@ static void test_SetDefaultDllDirectories(void)
     ok( mod != NULL, "loading authz failed\n" );
     FreeLibrary( mod );
     ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_USER_DIRS );
-    ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
+    ok( ret, "SetDefaultDllDirectories failed err %lu\n", GetLastError() );
     mod = LoadLibraryA( "authz.dll" );
     ok( !mod, "loading authz succeeded\n" );
     FreeLibrary( mod );
     ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_SYSTEM32 );
-    ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
+    ok( ret, "SetDefaultDllDirectories failed err %lu\n", GetLastError() );
     mod = LoadLibraryA( "authz.dll" );
     ok( mod != NULL, "loading authz failed\n" );
     FreeLibrary( mod );
@@ -1236,12 +1236,12 @@ static void test_SetDefaultDllDirectories(void)
     ok( !mod, "loading authz succeeded\n" );
     FreeLibrary( mod );
     ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
-    ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
+    ok( ret, "SetDefaultDllDirectories failed err %lu\n", GetLastError() );
     mod = LoadLibraryA( "authz.dll" );
     ok( !mod, "loading authz succeeded\n" );
     FreeLibrary( mod );
     ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DEFAULT_DIRS );
-    ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
+    ok( ret, "SetDefaultDllDirectories failed err %lu\n", GetLastError() );
     mod = LoadLibraryA( "authz.dll" );
     ok( mod != NULL, "loading authz failed\n" );
     FreeLibrary( mod );
@@ -1249,27 +1249,27 @@ static void test_SetDefaultDllDirectories(void)
     SetLastError( 0xdeadbeef );
     ret = pSetDefaultDllDirectories( 0 );
     ok( !ret, "SetDefaultDllDirectories succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     ret = pSetDefaultDllDirectories( 3 );
     ok( !ret, "SetDefaultDllDirectories succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_APPLICATION_DIR | 0x8000 );
     ok( !ret, "SetDefaultDllDirectories succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
     ok( !ret || broken(ret) /* win7 */, "SetDefaultDllDirectories succeeded\n" );
-    if (!ret) ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    if (!ret) ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_USER_DIRS );
     ok( !ret || broken(ret) /* win7 */, "SetDefaultDllDirectories succeeded\n" );
-    if (!ret) ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    if (!ret) ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     /* restore some sane defaults */
     pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DEFAULT_DIRS );
@@ -1284,13 +1284,13 @@ static void check_refcount( HMODULE mod, unsigned int refcount )
     {
         ret = FreeLibrary( mod );
         ok( ret || broken( refcount == ~0u && GetLastError() == ERROR_MOD_NOT_FOUND && i == 2 ) /* Win8 */,
-            "Refcount test failed, i %u, error %u.\n", i, GetLastError() );
+            "Refcount test failed, i %u, error %lu.\n", i, GetLastError() );
         if (!ret) return;
     }
     if (refcount != ~0u)
     {
         ret = FreeLibrary( mod );
-        ok( !ret && GetLastError() == ERROR_MOD_NOT_FOUND, "Refcount test failed, ret %d, error %u.\n",
+        ok( !ret && GetLastError() == ERROR_MOD_NOT_FOUND, "Refcount test failed, ret %d, error %lu.\n",
                 ret, GetLastError() );
     }
 }
@@ -1310,13 +1310,13 @@ static void test_LdrGetDllHandleEx(void)
 
     RtlInitUnicodeString( &name, L"unknown.dll" );
     status = pLdrGetDllHandleEx( 0, NULL, NULL, &name, &mod );
-    ok( status == STATUS_DLL_NOT_FOUND, "Got unexpected status %#x.\n", status );
+    ok( status == STATUS_DLL_NOT_FOUND, "Got unexpected status %#lx.\n", status );
 
     RtlInitUnicodeString( &name, L"authz.dll" );
     loaded_mod = LoadLibraryW( name.Buffer );
     ok( !!loaded_mod, "Failed to load module.\n" );
     status = pLdrGetDllHandleEx( 0, NULL, NULL, &name, &mod );
-    ok( !status, "Got unexpected status %#x.\n", status );
+    ok( !status, "Got unexpected status %#lx.\n", status );
     ok( mod == loaded_mod, "got %p\n", mod );
     winetest_push_context( "Flags 0" );
     check_refcount( loaded_mod, 2 );
@@ -1326,7 +1326,7 @@ static void test_LdrGetDllHandleEx(void)
     ok( !!loaded_mod, "Failed to load module.\n" );
     status = pLdrGetDllHandleEx( LDR_GET_DLL_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL,
                                  NULL, &name, &mod );
-    ok( !status, "Got unexpected status %#x.\n", status );
+    ok( !status, "Got unexpected status %#lx.\n", status );
     ok( mod == loaded_mod, "got %p\n", mod );
     winetest_push_context( "LDR_GET_DLL_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT" );
     check_refcount( loaded_mod, 1 );
@@ -1335,7 +1335,7 @@ static void test_LdrGetDllHandleEx(void)
     loaded_mod = LoadLibraryW( name.Buffer );
     ok( !!loaded_mod, "Failed to load module.\n" );
     status = pLdrGetDllHandle( NULL, ~0u, &name, &mod );
-    ok( !status, "Got unexpected status %#x.\n", status );
+    ok( !status, "Got unexpected status %#lx.\n", status );
     ok( mod == loaded_mod, "got %p\n", mod );
     winetest_push_context( "LdrGetDllHandle" );
     check_refcount( loaded_mod, 1 );
@@ -1344,7 +1344,7 @@ static void test_LdrGetDllHandleEx(void)
     loaded_mod = LoadLibraryW( name.Buffer );
     ok( !!loaded_mod, "Failed to load module.\n" );
     status = pLdrGetDllHandleEx( 4, NULL, NULL, (void *)&name, &mod );
-    ok( !status, "Got unexpected status %#x.\n", status );
+    ok( !status, "Got unexpected status %#lx.\n", status );
     ok( mod == loaded_mod, "got %p\n", mod );
     winetest_push_context( "Flag 4" );
     check_refcount( loaded_mod, 2 );
@@ -1355,7 +1355,7 @@ static void test_LdrGetDllHandleEx(void)
         loaded_mod = LoadLibraryW( name.Buffer );
         ok( !!loaded_mod, "Failed to load module.\n" );
         status = pLdrGetDllHandleEx( 1 << i, NULL, NULL, &name, &mod );
-        ok( status == STATUS_INVALID_PARAMETER, "Got unexpected status %#x.\n", status );
+        ok( status == STATUS_INVALID_PARAMETER, "Got unexpected status %#lx.\n", status );
         winetest_push_context( "Invalid flags, i %u", i );
         check_refcount( loaded_mod, 1 );
         winetest_pop_context();
@@ -1363,13 +1363,13 @@ static void test_LdrGetDllHandleEx(void)
 
     status = pLdrGetDllHandleEx( LDR_GET_DLL_HANDLE_EX_FLAG_PIN | LDR_GET_DLL_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
                                  NULL, NULL, &name, &mod );
-    ok( status == STATUS_INVALID_PARAMETER, "Got unexpected status %#x.\n", status );
+    ok( status == STATUS_INVALID_PARAMETER, "Got unexpected status %#lx.\n", status );
 
     loaded_mod = LoadLibraryW( name.Buffer );
     ok( !!loaded_mod, "Failed to load module.\n" );
     status = pLdrGetDllHandleEx( LDR_GET_DLL_HANDLE_EX_FLAG_PIN, NULL,
                                  NULL, &name, &mod );
-    ok( !status, "Got unexpected status %#x.\n", status );
+    ok( !status, "Got unexpected status %#lx.\n", status );
     ok( mod == loaded_mod, "got %p\n", mod );
     winetest_push_context( "LDR_GET_DLL_HANDLE_EX_FLAG_PIN" );
     check_refcount( loaded_mod, ~0u );
@@ -1398,7 +1398,7 @@ static void test_LdrGetDllFullName(void)
     memset( path_buffer, 0x23, sizeof(path_buffer) );
 
     status = pLdrGetDllFullName( ntdll, &path );
-    ok( status == STATUS_BUFFER_TOO_SMALL, "Got unexpected status %#x.\n", status );
+    ok( status == STATUS_BUFFER_TOO_SMALL, "Got unexpected status %#lx.\n", status );
     ok( path.Length == 0, "Expected length 0, got %d.\n", path.Length );
     ok( path_buffer[0] == 0x2323, "Expected 0x2323, got 0x%x.\n", path_buffer[0] );
 
@@ -1406,7 +1406,7 @@ static void test_LdrGetDllFullName(void)
     path.MaximumLength = 5; /* odd numbers produce partially copied characters */
 
     status = pLdrGetDllFullName( ntdll, &path );
-    ok( status == STATUS_BUFFER_TOO_SMALL, "Got unexpected status %#x.\n", status );
+    ok( status == STATUS_BUFFER_TOO_SMALL, "Got unexpected status %#lx.\n", status );
     ok( path.Length == path.MaximumLength, "Expected length %u, got %u.\n", path.MaximumLength, path.Length );
     expected_terminator = 0x2300 | (expected_path[path.MaximumLength / sizeof(WCHAR)] & 0xFF);
     ok( path_buffer[path.MaximumLength / sizeof(WCHAR)] == expected_terminator,
@@ -1421,12 +1421,12 @@ static void test_LdrGetDllFullName(void)
     path.MaximumLength = sizeof(path_buffer);
 
     status = pLdrGetDllFullName( ntdll, &path );
-    ok( status == STATUS_SUCCESS, "Got unexpected status %#x.\n", status );
+    ok( status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status );
     ok( !lstrcmpiW(path_buffer, expected_path), "Expected %s, got %s\n",
             wine_dbgstr_w(expected_path), wine_dbgstr_w(path_buffer) );
 
     status = pLdrGetDllFullName( NULL, &path );
-    ok( status == STATUS_SUCCESS, "Got unexpected status %#x.\n", status );
+    ok( status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status );
     GetModuleFileNameW( NULL, expected_path, ARRAY_SIZE(expected_path) );
     ok( !lstrcmpiW(path_buffer, expected_path), "Expected %s, got %s.\n",
             wine_dbgstr_w(expected_path), wine_dbgstr_w(path_buffer) );
@@ -1478,14 +1478,14 @@ static void test_apisets(void)
         winetest_push_context( "%u:%s", i, tests[i].name );
         present = 0xff;
         status = pApiSetQueryApiSetPresence( &name, &present );
-        ok( status == STATUS_SUCCESS, "wrong ret %x\n", status );
+        ok( status == STATUS_SUCCESS, "wrong ret %lx\n", status );
         ok( present == tests[i].present || broken(!present && tests[i].broken) /* win8 */,
             "wrong present %u\n", present );
         if (pApiSetQueryApiSetPresenceEx)
         {
             present = in_schema = 0xff;
             status = pApiSetQueryApiSetPresenceEx( &name, &in_schema, &present );
-            ok( status == tests[i].status, "wrong ret %x\n", status );
+            ok( status == tests[i].status, "wrong ret %lx\n", status );
             if (!status)
             {
                 ok( in_schema == tests[i].in_schema, "wrong in_schema %u\n", in_schema );
@@ -1532,7 +1532,7 @@ static void test_ddag_node(void)
     ok( !!hexe, "Got NULL exe handle.\n" );
 
     status = LdrFindEntryForAddress( hexe, &mod );
-    ok( !status, "Got unexpected status %#x.\n", status );
+    ok( !status, "Got unexpected status %#lx.\n", status );
 
     if (!(node = mod->DdagNode))
     {
@@ -1561,7 +1561,7 @@ static void test_ddag_node(void)
         win_skip( "Empty dependencies list.\n" );
         return;
     }
-    todo_wine ok( node->LoadCount == -1, "Got unexpected LoadCount %d.\n", node->LoadCount );
+    todo_wine ok( node->LoadCount == -1, "Got unexpected LoadCount %ld.\n", node->LoadCount );
 
     prev_node = NULL;
     se = node->Dependencies.Tail;
@@ -1601,7 +1601,7 @@ static void test_ddag_node(void)
         ok( dep2 == dep, "Dependency not found in incoming deps list.\n" );
 
         todo_wine ok( dep_node->LoadCount > 0 || broken(!dep_node->LoadCount) /* Win8 */,
-                "Got unexpected LoadCount %d.\n", dep_node->LoadCount );
+                "Got unexpected LoadCount %ld.\n", dep_node->LoadCount );
 
         winetest_pop_context();
         prev_node = dep_node;
diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c
index db376eef24a..3c57e81f4c6 100644
--- a/dlls/kernel32/tests/path.c
+++ b/dlls/kernel32/tests/path.c
@@ -265,25 +265,25 @@ static void test_FunnyChars(CHAR *curdir,CHAR *curdir_short,CHAR *filename, INT
       ok((passfail.shortlen==0 &&
           (passfail.shorterror==ERROR_FILE_NOT_FOUND || passfail.shorterror==ERROR_PATH_NOT_FOUND || !passfail.shorterror)) ||
          (passfail.shortlen==strlen(tmpstr1) && lstrcmpiA(tmpstr,tmpstr1)==0),
-         "%s: GetShortPathNameA error: len=%d error=%d tmpstr=[%s]\n",
+         "%s: GetShortPathNameA error: len=%ld error=%ld tmpstr=[%s]\n",
          errstr,passfail.shortlen,passfail.shorterror,tmpstr);
   } else {
       ok(passfail.shortlen==0 &&
          (passfail.shorterror==ERROR_INVALID_NAME || passfail.shorterror==ERROR_FILE_NOT_FOUND || !passfail.shorterror),
-         "%s: GetShortPathA should have failed len=%d, error=%d\n",
+         "%s: GetShortPathA should have failed len=%ld, error=%ld\n",
          errstr,passfail.shortlen,passfail.shorterror);
   }
 
     ok(!passfail.longlen, "GetLongPathNameA passed when it shouldn't have\n");
     if (valid)
     {
-        ok(passfail.longerror == ERROR_FILE_NOT_FOUND, "%s: GetLongPathA unexpected error %d.\n", errstr,
+        ok(passfail.longerror == ERROR_FILE_NOT_FOUND, "%s: GetLongPathA unexpected error %ld.\n", errstr,
                 passfail.longerror);
     }
     else
     {
         ok(passfail.longerror == ERROR_INVALID_NAME || passfail.longerror == ERROR_FILE_NOT_FOUND,
-                "%s: GetLongPathA unexpected error %d.\n", errstr, passfail.longerror);
+                "%s: GetLongPathA unexpected error %ld.\n", errstr, passfail.longerror);
     }
 }
 
@@ -350,7 +350,7 @@ static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive)
      "GetTempPathA returned a path that did not end in '\\'\n");
   lstrcpyA(tmpstr,"aaaaaaaa");
   len1=GetTempPathA(len,tmpstr);
-  ok(len1==len+1,"GetTempPathA should return string length %d instead of %d\n",len+1,len1);
+  ok(len1==len+1,"GetTempPathA should return string length %ld instead of %ld\n",len+1,len1);
 
 /* Test GetTmpFileNameA */
   ok((id=GetTempFileNameA(tmppath,"path",0,newdir)),"GetTempFileNameA failed\n");
@@ -376,7 +376,7 @@ static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive)
     sprintf(invalid_dir, "%s\\%s",tmppath,"non_existent_dir_1jwj3y32nb3");
     SetLastError(0xdeadbeef);
     ok(!GetTempFileNameA(invalid_dir,"tfn",unique,newdir),"GetTempFileNameA should have failed\n");
-    ok(GetLastError()==ERROR_DIRECTORY,"got %u, expected ERROR_DIRECTORY\n", GetLastError());
+    ok(GetLastError()==ERROR_DIRECTORY,"got %lu, expected ERROR_DIRECTORY\n", GetLastError());
 
     /* Check return value for unique !=0 */
     if(unique) {
@@ -416,12 +416,12 @@ static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive)
   bRes = CreateDirectoryA(tmpstr,NULL);
   ok(!bRes && (GetLastError() == ERROR_ACCESS_DENIED  ||
                GetLastError() == ERROR_ALREADY_EXISTS),
-     "CreateDirectoryA(\"%s\" should have failed (%d)\n", tmpstr, GetLastError());
+     "CreateDirectoryA(\"%s\" should have failed (%ld)\n", tmpstr, GetLastError());
   sprintf(tmpstr,"%c:\\", *curDrive);
   bRes = CreateDirectoryA(tmpstr,NULL);
   ok(!bRes && (GetLastError() == ERROR_ACCESS_DENIED  ||
                GetLastError() == ERROR_ALREADY_EXISTS),
-     "CreateDirectoryA(\"%s\" should have failed (%d)\n", tmpstr, GetLastError());
+     "CreateDirectoryA(\"%s\" should have failed (%ld)\n", tmpstr, GetLastError());
   sprintf(tmpstr,"%s\\%s\\%s",newdir,SHORTDIR,SHORTFILE);
   hndl=CreateFileA(tmpstr,GENERIC_WRITE,0,NULL,
                    CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
@@ -460,7 +460,7 @@ static void test_CurrentDirectoryA(CHAR *origdir, CHAR *newdir)
 */
   lstrcpyA(tmpstr,"aaaaaaa");
   len1=GetCurrentDirectoryA(len,tmpstr);
-  ok(len1==len+1, "GetCurrentDirectoryA returned %d instead of %d\n",len1,len+1);
+  ok(len1==len+1, "GetCurrentDirectoryA returned %ld instead of %ld\n",len1,len+1);
   ok(lstrcmpiA(tmpstr,"aaaaaaa")==0,
      "GetCurrentDirectoryA should not have modified the buffer\n");
 
@@ -468,27 +468,27 @@ static void test_CurrentDirectoryA(CHAR *origdir, CHAR *newdir)
   SetLastError( 0xdeadbeef );
   strcpy( buffer, "foo" );
   len = GetCurrentDirectoryA( 32767, buffer );
-  ok( len != 0 && len < MAX_PATH, "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() );
+  ok( len != 0 && len < MAX_PATH, "GetCurrentDirectoryA failed %lu err %lu\n", len, GetLastError() );
   if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer );
   SetLastError( 0xdeadbeef );
   strcpy( buffer, "foo" );
   len = GetCurrentDirectoryA( 32768, buffer );
-  ok( len != 0 && len < MAX_PATH, "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() );
+  ok( len != 0 && len < MAX_PATH, "GetCurrentDirectoryA failed %lu err %lu\n", len, GetLastError() );
   if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer );
   SetLastError( 0xdeadbeef );
   strcpy( buffer, "foo" );
   len = GetCurrentDirectoryA( 65535, buffer );
-  ok( (len != 0 && len < MAX_PATH) || broken(!len), /* nt4, win2k, xp */ "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() );
+  ok( (len != 0 && len < MAX_PATH) || broken(!len), /* nt4, win2k, xp */ "GetCurrentDirectoryA failed %lu err %lu\n", len, GetLastError() );
   if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer );
   SetLastError( 0xdeadbeef );
   strcpy( buffer, "foo" );
   len = GetCurrentDirectoryA( 65536, buffer );
-  ok( (len != 0 && len < MAX_PATH), "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() );
+  ok( (len != 0 && len < MAX_PATH), "GetCurrentDirectoryA failed %lu err %lu\n", len, GetLastError() );
   if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer );
   SetLastError( 0xdeadbeef );
   strcpy( buffer, "foo" );
   len = GetCurrentDirectoryA( 2 * 65536, buffer );
-  ok( (len != 0 && len < MAX_PATH), "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() );
+  ok( (len != 0 && len < MAX_PATH), "GetCurrentDirectoryA failed %lu err %lu\n", len, GetLastError() );
   if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer );
   HeapFree( GetProcessHeap(), 0, buffer );
 
@@ -574,14 +574,14 @@ static void test_ShortPathCase(const char *tmpdir, const char *dirname,
     sprintf(buf,"%s\\%s\\%s",tmpdir,dirname,filename);
     GetShortPathNameA(buf,shortbuf,sizeof(shortbuf));
     hndl = CreateFileA(shortbuf,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
-    ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed (%d)\n",GetLastError());
+    ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed (%ld)\n",GetLastError());
     CloseHandle(hndl);
     /* Now for the real test */
     for(i=0;i<strlen(shortbuf);i++)
         if (i % 2)
             shortbuf[i] = tolower(shortbuf[i]);
     hndl = CreateFileA(shortbuf,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
-    ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed (%d)\n",GetLastError());
+    ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed (%ld)\n",GetLastError());
     CloseHandle(hndl);
 }
 
@@ -614,12 +614,12 @@ static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive)
   rc1 = GetLongPathNameA(tmpstr, NULL, 0);
   rc2 = GetLongPathNameA(curdir, NULL, 0);
   ok((rc1-strlen(tmpstr))==(rc2-strlen(curdir)),
-     "GetLongPathNameA: wrong return code, %d instead of %d\n",
+     "GetLongPathNameA: wrong return code, %ld instead of %d\n",
      rc1, lstrlenA(tmpstr)+1);
 
   sprintf(dir,"%c:",curDrive);
   rc1= GetLongPathNameA(dir, tmpstr, sizeof(tmpstr));
-  ok(!strcmp(dir,tmpstr), "GetLongPathNameA: returned '%s' instead of '%s' (rc=%d)\n",
+  ok(!strcmp(dir,tmpstr), "GetLongPathNameA: returned '%s' instead of '%s' (rc=%ld)\n",
        tmpstr, dir, rc1);
 
 /* Check the cases where both file and directory exist first */
@@ -649,11 +649,11 @@ static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive)
       (passfail.shorterror==ERROR_PATH_NOT_FOUND ||
        passfail.shorterror==ERROR_FILE_NOT_FOUND)) ||
      (passfail.shortlen==strlen(tmpstr1) && lstrcmpiA(tmpstr,tmpstr1)==0),
-     "GetShortPathNameA error: len=%d error=%d tmpstr=[%s]\n",
+     "GetShortPathNameA error: len=%ld error=%ld tmpstr=[%s]\n",
      passfail.shortlen,passfail.shorterror,tmpstr);
 
   ok(!passfail.longlen, "GetLongPathNameA passed when it shouldn't have\n");
-  ok(passfail.longerror == ERROR_FILE_NOT_FOUND, "Unexpected error %d.\n", passfail.longerror);
+  ok(passfail.longerror == ERROR_FILE_NOT_FOUND, "Unexpected error %ld.\n", passfail.longerror);
 
 /* Now try a 8.3 directory, long file name */
   test_ValidPathA(curdir,SHORTDIR,NONFILE_LONG,tmpstr,&passfail,"test6");
@@ -663,7 +663,7 @@ static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive)
      !passfail.shorterror,
      "GetShortPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
   ok(!passfail.longlen, "GetLongPathNameA passed when it shouldn't have\n");
-  ok(passfail.longerror == ERROR_FILE_NOT_FOUND, "Unexpected error %d.\n", passfail.longerror);
+  ok(passfail.longerror == ERROR_FILE_NOT_FOUND, "Unexpected error %ld.\n", passfail.longerror);
 
 /* Next is a long directory, 8.3 file */
   test_ValidPathA(curdir,LONGDIR,NONFILE_SHORT,tmpstr,&passfail,"test7");
@@ -674,10 +674,10 @@ static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive)
       (passfail.shorterror==ERROR_PATH_NOT_FOUND ||
        passfail.shorterror==ERROR_FILE_NOT_FOUND)) ||
      (passfail.shortlen==strlen(tmpstr1) && lstrcmpiA(tmpstr,tmpstr1)==0),
-     "GetShortPathNameA error: len=%d error=%d tmpstr=[%s]\n",
+     "GetShortPathNameA error: len=%ld error=%ld tmpstr=[%s]\n",
      passfail.shortlen,passfail.shorterror,tmpstr);
   ok(!passfail.longlen, "GetLongPathNameA passed when it shouldn't have\n");
-  ok(passfail.longerror == ERROR_FILE_NOT_FOUND, "Unexpected error %d.\n", passfail.longerror);
+  ok(passfail.longerror == ERROR_FILE_NOT_FOUND, "Unexpected error %ld.\n", passfail.longerror);
 
 /*Lastly a long directory, long file */
   test_ValidPathA(curdir,LONGDIR,NONFILE_LONG,tmpstr,&passfail,"test8");
@@ -687,7 +687,7 @@ static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive)
      !passfail.shorterror,
      "GetShortPathA should have returned 'ERROR_FILE_NOT_FOUND'\n");
   ok(!passfail.longlen, "GetLongPathNameA passed when it shouldn't have\n");
-  ok(passfail.longerror == ERROR_FILE_NOT_FOUND, "Unexpected error %d.\n", passfail.longerror);
+  ok(passfail.longerror == ERROR_FILE_NOT_FOUND, "Unexpected error %ld.\n", passfail.longerror);
 
 /* Now try again with directories that don't exist */
 /* 8.3 directory, 8.3 filename */
@@ -697,11 +697,11 @@ static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive)
       (passfail.shorterror==ERROR_PATH_NOT_FOUND ||
        passfail.shorterror==ERROR_FILE_NOT_FOUND)) ||
      (passfail.shortlen==strlen(tmpstr1) && lstrcmpiA(tmpstr,tmpstr1)==0),
-     "GetShortPathNameA error: len=%d error=%d tmpstr=[%s]\n",
+     "GetShortPathNameA error: len=%ld error=%ld tmpstr=[%s]\n",
      passfail.shortlen,passfail.shorterror,tmpstr);
   ok(!passfail.longlen, "GetLongPathNameA passed when it shouldn't have\n");
   ok(passfail.longerror == ERROR_PATH_NOT_FOUND || passfail.longerror == ERROR_FILE_NOT_FOUND,
-     "Unexpected error %d.\n", passfail.longerror);
+     "Unexpected error %ld.\n", passfail.longerror);
 
 /* Now try a 8.3 directory, long file name */
   test_ValidPathA(curdir,NONDIR_SHORT,LONGFILE,tmpstr,&passfail,"test10");
@@ -709,11 +709,11 @@ static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive)
   ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
      passfail.shorterror==ERROR_FILE_NOT_FOUND ||
      !passfail.shorterror,
-     "GetShortPathA returned %d and not 'ERROR_PATH_NOT_FOUND'\n",
+     "GetShortPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
       passfail.shorterror);
   ok(!passfail.longlen, "GetLongPathNameA passed when it shouldn't have\n");
   ok(passfail.longerror == ERROR_PATH_NOT_FOUND || passfail.longerror == ERROR_FILE_NOT_FOUND,
-     "Unexpected error %d.\n", passfail.longerror);
+     "Unexpected error %ld.\n", passfail.longerror);
 
 /* Next is a long directory, 8.3 file */
   test_ValidPathA(curdir,NONDIR_LONG,SHORTFILE,tmpstr,&passfail,"test11");
@@ -721,11 +721,11 @@ static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive)
   ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
      passfail.shorterror==ERROR_FILE_NOT_FOUND ||
      !passfail.shorterror,
-     "GetShortPathA returned %d and not 'ERROR_PATH_NOT_FOUND'\n",
+     "GetShortPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
       passfail.shorterror);
   ok(!passfail.longlen, "GetLongPathNameA passed when it shouldn't have\n");
   ok(passfail.longerror == ERROR_PATH_NOT_FOUND || passfail.longerror == ERROR_FILE_NOT_FOUND,
-     "Unexpected error %d.\n", passfail.longerror);
+     "Unexpected error %ld.\n", passfail.longerror);
 
 /*Lastly a long directory, long file */
   test_ValidPathA(curdir,NONDIR_LONG,LONGFILE,tmpstr,&passfail,"test12");
@@ -733,11 +733,11 @@ static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive)
   ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
      passfail.shorterror==ERROR_FILE_NOT_FOUND ||
      !passfail.shorterror,
-     "GetShortPathA returned %d and not 'ERROR_PATH_NOT_FOUND'\n",
+     "GetShortPathA returned %ld and not 'ERROR_PATH_NOT_FOUND'\n",
       passfail.shorterror);
   ok(!passfail.longlen, "GetLongPathNameA passed when it shouldn't have\n");
   ok(passfail.longerror == ERROR_PATH_NOT_FOUND || passfail.longerror == ERROR_FILE_NOT_FOUND,
-     "Unexpected error %d.\n", passfail.longerror);
+     "Unexpected error %ld.\n", passfail.longerror);
 
 /* Next try directories ending with '\\' */
 /* Existing Directories */
@@ -753,10 +753,10 @@ static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive)
       (passfail.shorterror==ERROR_PATH_NOT_FOUND ||
        passfail.shorterror==ERROR_FILE_NOT_FOUND)) ||
      (passfail.shortlen==strlen(tmpstr2) && lstrcmpiA(tmpstr1,tmpstr2)==0),
-     "GetShortPathNameA error: len=%d error=%d tmpstr=[%s]\n",
+     "GetShortPathNameA error: len=%ld error=%ld tmpstr=[%s]\n",
      passfail.shortlen,passfail.shorterror,tmpstr);
   ok(!passfail.longlen, "GetLongPathNameA passed when it shouldn't have\n");
-  ok(passfail.longerror == ERROR_FILE_NOT_FOUND, "Unexpected error %d.\n", passfail.longerror);
+  ok(passfail.longerror == ERROR_FILE_NOT_FOUND, "Unexpected error %ld.\n", passfail.longerror);
 
   sprintf(tmpstr,"%s\\",NONDIR_LONG);
   test_ValidPathA(curdir,"",tmpstr,tmpstr1,&passfail,"test16");
@@ -764,10 +764,10 @@ static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive)
   ok(passfail.shorterror==ERROR_PATH_NOT_FOUND ||
      passfail.shorterror==ERROR_FILE_NOT_FOUND ||
      !passfail.shorterror,
-     "GetShortPathA returned %d and not 'ERROR_FILE_NOT_FOUND'\n",
+     "GetShortPathA returned %ld and not 'ERROR_FILE_NOT_FOUND'\n",
       passfail.shorterror);
   ok(!passfail.longlen, "GetLongPathNameA passed when it shouldn't have\n");
-  ok(passfail.longerror == ERROR_FILE_NOT_FOUND, "Unexpected error %d.\n", passfail.longerror);
+  ok(passfail.longerror == ERROR_FILE_NOT_FOUND, "Unexpected error %ld.\n", passfail.longerror);
 
 /* Test GetFullPathNameA with drive letters */
   if( curDrive != NOT_A_VALID_DRIVE) {
@@ -946,10 +946,10 @@ static void test_GetTempPathA(char* tmp_dir)
      * of len_with_null.
      */
     len = GetTempPathA(1, buf);
-    ok(len >= len_with_null, "Expected >= %u, got %u\n", len_with_null, len);
+    ok(len >= len_with_null, "Expected >= %lu, got %lu\n", len_with_null, len);
 
     len = GetTempPathA(0, NULL);
-    ok(len >= len_with_null, "Expected >= %u, got %u\n", len_with_null, len);
+    ok(len >= len_with_null, "Expected >= %lu, got %lu\n", len_with_null, len);
 
     /* The call above gave us the buffer size that Windows thinks is needed
      * so the next call should work
@@ -966,15 +966,15 @@ static void test_GetTempPathA(char* tmp_dir)
     /* The rest of the buffer remains untouched */
     slen = len + 1;
     for(len++; len < sizeof(buf); len++)
-        ok(buf[len] == 'a', "expected 'a' at [%d], got 0x%x\n", len, buf[len]);
+        ok(buf[len] == 'a', "expected 'a' at [%ld], got 0x%x\n", len, buf[len]);
 
     /* When the buffer is not long enough it remains untouched */
     memset(buf, 'a', sizeof(buf));
     len = GetTempPathA(slen / 2, buf);
     ok(len == slen || broken(len == slen + 1) /* read the big comment above */ ,
-       "expected %d, got %d\n", slen, len);
+       "expected %ld, got %ld\n", slen, len);
     for(len = 0; len < ARRAY_SIZE(buf); len++)
-        ok(buf[len] == 'a', "expected 'a' at [%d], got 0x%x\n", len, buf[len]);
+        ok(buf[len] == 'a', "expected 'a' at [%ld], got 0x%x\n", len, buf[len]);
 }
 
 static void test_GetTempPathW(char* tmp_dir)
@@ -1004,10 +1004,10 @@ static void test_GetTempPathW(char* tmp_dir)
     lstrcpyW(buf, fooW);
     len = GetTempPathW(1, buf);
     ok(buf[0] == 0, "unicode version should truncate the buffer to zero size\n");
-    ok(len >= len_with_null, "Expected >= %u, got %u\n", len_with_null, len);
+    ok(len >= len_with_null, "Expected >= %lu, got %lu\n", len_with_null, len);
 
     len = GetTempPathW(0, NULL);
-    ok(len >= len_with_null, "Expected >= %u, got %u\n", len_with_null, len);
+    ok(len >= len_with_null, "Expected >= %lu, got %lu\n", len_with_null, len);
 
     lstrcpyW(buf, fooW);
     len = GetTempPathW(len, buf);
@@ -1022,14 +1022,14 @@ static void test_GetTempPathW(char* tmp_dir)
     /* The rest of the buffer must be zeroed */
     slen = len + 1;
     for(len++; len < ARRAY_SIZE(buf); len++)
-        ok(buf[len] == '\0', "expected NULL at [%d], got 0x%x\n", len, buf[len]);
+        ok(buf[len] == '\0', "expected NULL at [%ld], got 0x%x\n", len, buf[len]);
 
     /* When the buffer is not long enough the length passed is zeroed */
     for(len = 0; len < ARRAY_SIZE(buf); len++)
         buf[len] = 'a';
     len = GetTempPathW(slen / 2, buf);
     ok(len == slen || broken(len == slen + 1) /* read the big comment above */ ,
-       "expected %d, got %d\n", slen, len);
+       "expected %ld, got %ld\n", slen, len);
 
     {
         /* In Windows 8 when TMP var points to a drive only (like C:) instead of a
@@ -1045,9 +1045,9 @@ static void test_GetTempPathW(char* tmp_dir)
     }
 
     for(len = 0; len < slen / 2; len++)
-        ok(buf[len] == '\0', "expected NULL at [%d], got 0x%x\n", len, buf[len]);
+        ok(buf[len] == '\0', "expected NULL at [%ld], got 0x%x\n", len, buf[len]);
     for(; len < ARRAY_SIZE(buf); len++)
-        ok(buf[len] == 'a', "expected 'a' at [%d], got 0x%x\n", len, buf[len]);
+        ok(buf[len] == 'a', "expected 'a' at [%ld], got 0x%x\n", len, buf[len]);
 
     /* bogus application from bug 38220 passes the count value in sizeof(buffer)
      * instead the correct count of WCHAR, this test catches this case. */
@@ -1069,11 +1069,11 @@ static void test_GetTempPathW(char* tmp_dir)
      * to simplify testing we will test only until XP.
      */
     for(; len < 32767; len++)
-        ok(long_buf[len] == '\0', "expected NULL at [%d], got 0x%x\n", len, long_buf[len]);
+        ok(long_buf[len] == '\0', "expected NULL at [%ld], got 0x%x\n", len, long_buf[len]);
     /* we will know skip the test that is in the middle of the OS difference by
      * incrementing len and then resume the test for the untouched part. */
     for(len++; len < slen; len++)
-        ok(long_buf[len] == 0xcc, "expected 0xcc at [%d], got 0x%x\n", len, long_buf[len]);
+        ok(long_buf[len] == 0xcc, "expected 0xcc at [%ld], got 0x%x\n", len, long_buf[len]);
 
     HeapFree(GetProcessHeap(), 0, long_buf);
 }
@@ -1150,7 +1150,7 @@ static void test_GetLongPathNameA(void)
     SetLastError(0xdeadbeef);
     length = GetLongPathNameA(tempfile, temppath, MAX_PATH);
     ok(!length, "GetLongPathNameA should fail\n");
-    ok(GetLastError() == ERROR_INVALID_NAME, "wrong error %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_NAME, "wrong error %ld\n", GetLastError());
 
     strcpy(name, "longfilename.longext");
 
@@ -1174,13 +1174,13 @@ static void test_GetLongPathNameA(void)
 
     SetLastError(0xdeadbeef);
     length = GetLongPathNameA(temppath2, NULL, 0);
-    ok(length == explength, "Wrong length %d, expected %d\n", length, explength);
+    ok(length == explength, "Wrong length %ld, expected %ld\n", length, explength);
 
     length = GetLongPathNameA(temppath2, NULL, MAX_PATH);
-    ok(length == explength, "Wrong length %d, expected %d\n", length, explength);
+    ok(length == explength, "Wrong length %ld, expected %ld\n", length, explength);
 
     length = GetLongPathNameA(temppath2, temppath, 4);
-    ok(length == explength, "Wrong length %d, expected %d\n", length, explength);
+    ok(length == explength, "Wrong length %ld, expected %ld\n", length, explength);
     ok(temppath[0] == 0, "Buffer should not have been touched\n");
 
     /* Now an UNC path with the computername */
@@ -1217,17 +1217,17 @@ static void test_GetLongPathNameA(void)
     }
     explength = lstrlenA(longpath) + 1;
     todo_wine
-    ok(length == explength, "Wrong length %d, expected %d\n", length, explength);
+    ok(length == explength, "Wrong length %ld, expected %ld\n", length, explength);
 
     length = GetLongPathNameA(unc_short, NULL, MAX_PATH);
     todo_wine
-    ok(length == explength, "Wrong length %d, expected %d\n", length, explength);
+    ok(length == explength, "Wrong length %ld, expected %ld\n", length, explength);
 
     memset(unc_long, 0, MAX_PATH);
     length = GetLongPathNameA(unc_short, unc_long, lstrlenA(unc_short));
     /* length will include terminating '0' on failure */
     todo_wine
-    ok(length == explength, "Wrong length %d, expected %d\n", length, explength);
+    ok(length == explength, "Wrong length %ld, expected %ld\n", length, explength);
     ok(unc_long[0] == 0, "Buffer should not have been touched\n");
 
     memset(unc_long, 0, MAX_PATH);
@@ -1236,7 +1236,7 @@ static void test_GetLongPathNameA(void)
     explength--;
     todo_wine
     {
-    ok(length == explength, "Wrong length %d, expected %d\n", length, explength);
+    ok(length == explength, "Wrong length %ld, expected %ld\n", length, explength);
     ok(!lstrcmpiA(unc_long, longpath), "Expected (%s), got (%s)\n", longpath, unc_long);
     }
 
@@ -1258,14 +1258,14 @@ static void test_GetLongPathNameW(void)
 
     SetLastError(0xdeadbeef); 
     length = GetLongPathNameW(NULL,NULL,0);
-    ok(0==length,"GetLongPathNameW returned %d but expected 0\n",length);
-    ok(GetLastError()==ERROR_INVALID_PARAMETER,"GetLastError returned %d but expected ERROR_INVALID_PARAMETER\n",GetLastError());
+    ok(0==length,"GetLongPathNameW returned %ld but expected 0\n",length);
+    ok(GetLastError()==ERROR_INVALID_PARAMETER,"GetLastError returned %ld but expected ERROR_INVALID_PARAMETER\n",GetLastError());
 
     SetLastError(0xdeadbeef); 
     empty[0]=0;
     length = GetLongPathNameW(empty,NULL,0);
-    ok(0==length,"GetLongPathNameW returned %d but expected 0\n",length);
-    ok(GetLastError()==ERROR_PATH_NOT_FOUND,"GetLastError returned %d but expected ERROR_PATH_NOT_FOUND\n",GetLastError());
+    ok(0==length,"GetLongPathNameW returned %ld but expected 0\n",length);
+    ok(GetLastError()==ERROR_PATH_NOT_FOUND,"GetLastError returned %ld but expected ERROR_PATH_NOT_FOUND\n",GetLastError());
 
     /* Create a long path name. The path needs to exist for these tests to
      * succeed so we need the "\\?\" prefix when creating directories and
@@ -1282,7 +1282,7 @@ static void test_GetLongPathNameW(void)
     lstrcatW(shortpath, name);
     lstrcpyW(dirpath, shortpath);
     ret = CreateDirectoryW(shortpath, NULL);
-    ok(ret, "Could not create the temporary directory : %d\n", GetLastError());
+    ok(ret, "Could not create the temporary directory : %ld\n", GetLastError());
     lstrcatW(shortpath, backslash);
     lstrcatW(shortpath, name);
 
@@ -1291,24 +1291,24 @@ static void test_GetLongPathNameW(void)
     /* No prefix */
     SetLastError(0xdeadbeef);
     length = GetLongPathNameW(shortpath + 4, NULL, 0);
-    ok(length == 0, "Expected 0, got %d\n", length);
+    ok(length == 0, "Expected 0, got %ld\n", length);
     todo_wine
     ok(GetLastError() == ERROR_PATH_NOT_FOUND,
-       "Expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError());
+       "Expected ERROR_PATH_NOT_FOUND, got %ld\n", GetLastError());
     /* With prefix */
     SetLastError(0xdeadbeef);
     length = GetLongPathNameW(shortpath, NULL, 0);
     todo_wine
     {
-    ok(length == 0, "Expected 0, got %d\n", length);
+    ok(length == 0, "Expected 0, got %ld\n", length);
     ok(GetLastError() == ERROR_FILE_NOT_FOUND,
-       "Expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError());
+       "Expected ERROR_PATH_NOT_FOUND, got %ld\n", GetLastError());
     }
 
     file = CreateFileW(shortpath, GENERIC_READ|GENERIC_WRITE, 0, NULL,
                        CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
     ok(file != INVALID_HANDLE_VALUE,
-       "Could not create the temporary file : %d.\n", GetLastError());
+       "Could not create the temporary file : %ld.\n", GetLastError());
     CloseHandle(file);
 
     /* Path exists */
@@ -1318,14 +1318,14 @@ static void test_GetLongPathNameW(void)
     length = GetLongPathNameW(shortpath + 4, NULL, 0);
     todo_wine
     {
-    ok(length == 0, "Expected 0, got %d\n", length);
-    ok(GetLastError() == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError());
+    ok(length == 0, "Expected 0, got %ld\n", length);
+    ok(GetLastError() == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %ld\n", GetLastError());
     }
     /* With prefix */
     expanded = 4 + (GetLongPathNameW(tempdir, NULL, 0) - 1) + lstrlenW(name) + 1 + lstrlenW(name) + 1;
     SetLastError(0xdeadbeef);
     length = GetLongPathNameW(shortpath, NULL, 0);
-    ok(length == expanded, "Expected %d, got %d\n", expanded, length);
+    ok(length == expanded, "Expected %ld, got %ld\n", expanded, length);
 
     /* NULL buffer with length crashes on Windows */
     if (0)
@@ -1355,7 +1355,7 @@ static void test_GetShortPathNameW(void)
     lstrcatW( path, test_path );
     lstrcatW( path, backSlash );
     ret = CreateDirectoryW( path, NULL );
-    ok( ret, "Directory was not created. LastError = %d\n", GetLastError() );
+    ok( ret, "Directory was not created. LastError = %ld\n", GetLastError() );
 
     /* Starting a main part of test */
 
@@ -1382,7 +1382,7 @@ static void test_GetShortPathNameW(void)
     SetLastError(0xdeadbeef);
     length = GetShortPathNameW( short_path, path, 0 );
     ok(!length, "GetShortPathNameW should fail\n");
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
 
     file = CreateFileW( short_path, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
     ok( file != INVALID_HANDLE_VALUE, "File was not created.\n" );
@@ -1397,13 +1397,13 @@ static void test_GetShortPathNameW(void)
     CloseHandle( file );
 
     length = GetShortPathNameW( path, short_path, ARRAY_SIZE( short_path ));
-    ok( length, "GetShortPathNameW failed: %u.\n", GetLastError() );
+    ok( length, "GetShortPathNameW failed: %lu.\n", GetLastError() );
 
     lstrcpyW(ptr, wildW);
     SetLastError(0xdeadbeef);
     length = GetShortPathNameW( path, short_path, ARRAY_SIZE( short_path ) );
     ok(!length, "GetShortPathNameW should fail\n");
-    ok(GetLastError() == ERROR_INVALID_NAME, "wrong error %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_NAME, "wrong error %ld\n", GetLastError());
 
     lstrcpyW(ptr, a_bcdeW);
     ret = DeleteFileW( path );
@@ -1424,7 +1424,7 @@ static void test_GetSystemDirectory(void)
     SetLastError(0xdeadbeef);
     res = GetSystemDirectoryA(NULL, 0);
     /* res includes the terminating Zero */
-    ok(res > 0, "returned %d with %d (expected '>0')\n", res, GetLastError());
+    ok(res > 0, "returned %ld with %ld (expected '>0')\n", res, GetLastError());
 
     total = res;
 
@@ -1434,7 +1434,7 @@ static void test_GetSystemDirectory(void)
 
     SetLastError(0xdeadbeef);
     res = GetSystemDirectoryA(NULL, total-1);
-    ok( res == total, "returned %u with %u (expected '%u')\n",
+    ok( res == total, "returned %lu with %lu (expected '%lu')\n",
         res, GetLastError(), total );
 
     if (total > MAX_PATH) return;
@@ -1444,7 +1444,7 @@ static void test_GetSystemDirectory(void)
     res = GetSystemDirectoryA(buffer, total);
     /* res does not include the terminating Zero */
     ok( (res == (total-1)) && (buffer[0]),
-        "returned %d with %d and '%s' (expected '%d' and a string)\n",
+        "returned %ld with %ld and '%s' (expected '%ld' and a string)\n",
         res, GetLastError(), buffer, total-1);
 
     buffer[0] = '\0';
@@ -1452,7 +1452,7 @@ static void test_GetSystemDirectory(void)
     res = GetSystemDirectoryA(buffer, total + 1);
     /* res does not include the terminating Zero */
     ok( (res == (total-1)) && (buffer[0]),
-        "returned %d with %d and '%s' (expected '%d' and a string)\n",
+        "returned %ld with %ld and '%s' (expected '%ld' and a string)\n",
         res, GetLastError(), buffer, total-1);
 
     memset(buffer, '#', total + 1);
@@ -1460,7 +1460,7 @@ static void test_GetSystemDirectory(void)
     SetLastError(0xdeadbeef);
     res = GetSystemDirectoryA(buffer, total-1);
     /* res includes the terminating Zero) */
-    ok( res == total, "returned %d with %d and '%s' (expected '%d')\n",
+    ok( res == total, "returned %ld with %ld and '%s' (expected '%ld')\n",
         res, GetLastError(), buffer, total);
 
     memset(buffer, '#', total + 1);
@@ -1468,7 +1468,7 @@ static void test_GetSystemDirectory(void)
     SetLastError(0xdeadbeef);
     res = GetSystemDirectoryA(buffer, total-2);
     /* res includes the terminating Zero) */
-    ok( res == total, "returned %d with %d and '%s' (expected '%d')\n",
+    ok( res == total, "returned %ld with %ld and '%s' (expected '%ld')\n",
         res, GetLastError(), buffer, total);
 }
 
@@ -1481,7 +1481,7 @@ static void test_GetWindowsDirectory(void)
     SetLastError(0xdeadbeef);
     res = GetWindowsDirectoryA(NULL, 0);
     /* res includes the terminating Zero */
-    ok(res > 0, "returned %d with %d (expected '>0')\n", res, GetLastError());
+    ok(res > 0, "returned %ld with %ld (expected '>0')\n", res, GetLastError());
 
     total = res;
     /* this crashes on XP */
@@ -1490,7 +1490,7 @@ static void test_GetWindowsDirectory(void)
 
     SetLastError(0xdeadbeef);
     res = GetWindowsDirectoryA(NULL, total-1);
-    ok( res == total, "returned %u with %u (expected '%u')\n",
+    ok( res == total, "returned %lu with %lu (expected '%lu')\n",
         res, GetLastError(), total );
 
     if (total > MAX_PATH) return;
@@ -1500,7 +1500,7 @@ static void test_GetWindowsDirectory(void)
     res = GetWindowsDirectoryA(buffer, total);
     /* res does not include the terminating Zero */
     ok( (res == (total-1)) && (buffer[0]),
-        "returned %d with %d and '%s' (expected '%d' and a string)\n",
+        "returned %ld with %ld and '%s' (expected '%ld' and a string)\n",
         res, GetLastError(), buffer, total-1);
 
     buffer[0] = '\0';
@@ -1508,7 +1508,7 @@ static void test_GetWindowsDirectory(void)
     res = GetWindowsDirectoryA(buffer, total + 1);
     /* res does not include the terminating Zero */
     ok( (res == (total-1)) && (buffer[0]),
-        "returned %d with %d and '%s' (expected '%d' and a string)\n",
+        "returned %ld with %ld and '%s' (expected '%ld' and a string)\n",
         res, GetLastError(), buffer, total-1);
 
     memset(buffer, '#', total + 1);
@@ -1516,7 +1516,7 @@ static void test_GetWindowsDirectory(void)
     SetLastError(0xdeadbeef);
     res = GetWindowsDirectoryA(buffer, total-1);
     /* res includes the terminating Zero) */
-    ok( res == total, "returned %d with %d and '%s' (expected '%d')\n",
+    ok( res == total, "returned %ld with %ld and '%s' (expected '%ld')\n",
         res, GetLastError(), buffer, total);
 
     memset(buffer, '#', total + 1);
@@ -1524,7 +1524,7 @@ static void test_GetWindowsDirectory(void)
     SetLastError(0xdeadbeef);
     res = GetWindowsDirectoryA(buffer, total-2);
     /* res includes the terminating Zero) */
-    ok( res == total, "returned %d with %d and '%s' (expected '%d')\n",
+    ok( res == total, "returned %ld with %ld and '%s' (expected '%ld')\n",
         res, GetLastError(), buffer, total);
 }
 
@@ -1592,7 +1592,7 @@ static void test_drive_letter_case(void)
     memset(buf, 0, sizeof(buf));
     SetLastError(0xdeadbeef);
     ret = GetWindowsDirectoryA(buf, sizeof(buf));
-    ok(ret, "GetWindowsDirectory error %u\n", GetLastError());
+    ok(ret, "GetWindowsDirectory error %lu\n", GetLastError());
     ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
     ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]);
     ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]);
@@ -1601,7 +1601,7 @@ static void test_drive_letter_case(void)
     buf[2] = '/';
     SetLastError(0xdeadbeef);
     ret = GetFullPathNameA(buf + 2, sizeof(buf), buf, NULL);
-    ok(ret, "GetFullPathName error %u\n", GetLastError());
+    ok(ret, "GetFullPathName error %lu\n", GetLastError());
     ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
     ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]);
     ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]);
@@ -1609,7 +1609,7 @@ static void test_drive_letter_case(void)
     memset(buf, 0, sizeof(buf));
     SetLastError(0xdeadbeef);
     ret = GetSystemDirectoryA(buf, sizeof(buf));
-    ok(ret, "GetSystemDirectory error %u\n", GetLastError());
+    ok(ret, "GetSystemDirectory error %lu\n", GetLastError());
     ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
     ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]);
     ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]);
@@ -1617,7 +1617,7 @@ static void test_drive_letter_case(void)
     memset(buf, 0, sizeof(buf));
     SetLastError(0xdeadbeef);
     ret = GetCurrentDirectoryA(sizeof(buf), buf);
-    ok(ret, "GetCurrentDirectory error %u\n", GetLastError());
+    ok(ret, "GetCurrentDirectory error %lu\n", GetLastError());
     ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
     ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]);
     ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]);
@@ -1626,7 +1626,7 @@ static void test_drive_letter_case(void)
     memset(buf, 0, sizeof(buf));
     SetLastError(0xdeadbeef);
     ret = GetTempPathA(sizeof(buf), buf);
-    ok(ret, "GetTempPath error %u\n", GetLastError());
+    ok(ret, "GetTempPath error %lu\n", GetLastError());
     ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
     if (buf[0])
     {
@@ -1637,7 +1637,7 @@ static void test_drive_letter_case(void)
     memset(buf, 0, sizeof(buf));
     SetLastError(0xdeadbeef);
     ret = GetFullPathNameA(".", sizeof(buf), buf, NULL);
-    ok(ret, "GetFullPathName error %u\n", GetLastError());
+    ok(ret, "GetFullPathName error %lu\n", GetLastError());
     ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
     ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]);
     ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]);
@@ -1645,7 +1645,7 @@ static void test_drive_letter_case(void)
     /* re-use the buffer returned by GetFullPathName */
     SetLastError(0xdeadbeef);
     ret = GetShortPathNameA(buf, buf, sizeof(buf));
-    ok(ret, "GetShortPathName error %u\n", GetLastError());
+    ok(ret, "GetShortPathName error %lu\n", GetLastError());
     ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
     ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]);
     ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]);
@@ -1653,7 +1653,7 @@ static void test_drive_letter_case(void)
     /* re-use the buffer returned by GetShortPathName */
     SetLastError(0xdeadbeef);
     ret = GetLongPathNameA(buf, buf, sizeof(buf));
-    ok(ret, "GetLongPathNameA error %u\n", GetLastError());
+    ok(ret, "GetLongPathNameA error %lu\n", GetLastError());
     ok(ret < sizeof(buf), "buffer should be %u bytes\n", ret);
     ok(buf[1] == ':', "expected buf[1] == ':' got %c\n", buf[1]);
     ok(is_upper_case_letter(buf[0]), "expected buf[0] upper case letter got %c\n", buf[0]);
@@ -1690,7 +1690,7 @@ static void create_manifest_file(const char *filename, const char *manifest)
     lstrcatW(manifest_path, path);
 
     file = CreateFileW(manifest_path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
-    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %lu\n", GetLastError());
     WriteFile(file, manifest, strlen(manifest), &size, NULL);
     CloseHandle(file);
 }
@@ -1719,10 +1719,10 @@ static HANDLE test_create(const char *file)
     actctx.lpSource = manifest_path;
 
     handle = CreateActCtxW(&actctx);
-    ok(handle != INVALID_HANDLE_VALUE, "failed to create context, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "failed to create context, error %lu\n", GetLastError());
 
-    ok(actctx.cbSize == sizeof(actctx), "cbSize=%d\n", actctx.cbSize);
-    ok(actctx.dwFlags == 0, "dwFlags=%d\n", actctx.dwFlags);
+    ok(actctx.cbSize == sizeof(actctx), "cbSize=%ld\n", actctx.cbSize);
+    ok(actctx.dwFlags == 0, "dwFlags=%ld\n", actctx.dwFlags);
     ok(actctx.lpSource == manifest_path, "lpSource=%p\n", actctx.lpSource);
     ok(actctx.wProcessorArchitecture == 0, "wProcessorArchitecture=%d\n", actctx.wProcessorArchitecture);
     ok(actctx.wLangId == 0, "wLangId=%d\n", actctx.wLangId);
@@ -1752,16 +1752,16 @@ static void test_SearchPathA(void)
     /* NULL filename */
     SetLastError(0xdeadbeef);
     ret = SearchPathA(pathA, NULL, NULL, ARRAY_SIZE(buffA), buffA, &ptrA);
-    ok(ret == 0, "Expected failure, got %d\n", ret);
+    ok(ret == 0, "Expected failure, got %ld\n", ret);
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-      "Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError());
+      "Expected ERROR_INVALID_PARAMETER, got %lx\n", GetLastError());
 
     /* empty filename */
     SetLastError(0xdeadbeef);
     ret = SearchPathA(pathA, fileA, NULL, ARRAY_SIZE(buffA), buffA, &ptrA);
-    ok(ret == 0, "Expected failure, got %d\n", ret);
+    ok(ret == 0, "Expected failure, got %ld\n", ret);
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-      "Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError());
+      "Expected ERROR_INVALID_PARAMETER, got %lx\n", GetLastError());
 
     GetTempPathA(ARRAY_SIZE(pathA), pathA);
     strcpy(path2A, pathA);
@@ -1773,15 +1773,15 @@ static void test_SearchPathA(void)
 
     buffA[0] = 0;
     ret = SearchPathA(pathA, "testfile.ext", NULL, ARRAY_SIZE(buffA), buffA, NULL);
-    ok(!ret, "Unexpected return value %u.\n", ret);
+    ok(!ret, "Unexpected return value %lu.\n", ret);
 
     buffA[0] = 0;
     ret = SearchPathA(pathA, "testfile.ext", ".ext2", ARRAY_SIZE(buffA), buffA, NULL);
-    ok(!ret, "Unexpected return value %u.\n", ret);
+    ok(!ret, "Unexpected return value %lu.\n", ret);
 
     buffA[0] = 0;
     ret = SearchPathA(pathA, "testfile.ext.ext2", NULL, ARRAY_SIZE(buffA), buffA, NULL);
-    ok(ret && ret == strlen(path2A), "got %d\n", ret);
+    ok(ret && ret == strlen(path2A), "got %ld\n", ret);
 
     DeleteFileA(path2A);
 
@@ -1796,42 +1796,42 @@ static void test_SearchPathA(void)
 
     /* search fails without active context */
     ret = SearchPathA(NULL, testdepA, NULL, ARRAY_SIZE(buffA), buffA, NULL);
-    ok(ret == 0, "got %d\n", ret);
+    ok(ret == 0, "got %ld\n", ret);
 
     ret = SearchPathA(NULL, kernel32A, NULL, ARRAY_SIZE(path2A), path2A, NULL);
-    ok(ret && ret == strlen(path2A), "got %d\n", ret);
+    ok(ret && ret == strlen(path2A), "got %ld\n", ret);
 
     ret = ActivateActCtx(handle, &cookie);
-    ok(ret, "failed to activate context, %u\n", GetLastError());
+    ok(ret, "failed to activate context, %lu\n", GetLastError());
 
     /* works when activated */
     ret = SearchPathA(NULL, testdepA, NULL, ARRAY_SIZE(buffA), buffA, NULL);
-    ok(ret && ret == strlen(buffA), "got %d\n", ret);
+    ok(ret && ret == strlen(buffA), "got %ld\n", ret);
 
     ret = SearchPathA(NULL, "testdep.dll", ".ext", ARRAY_SIZE(buffA), buffA, NULL);
-    ok(ret && ret == strlen(buffA), "got %d\n", ret);
+    ok(ret && ret == strlen(buffA), "got %ld\n", ret);
 
     ret = SearchPathA(NULL, "testdep", ".dll", ARRAY_SIZE(buffA), buffA, NULL);
-    ok(ret && ret == strlen(buffA), "got %d\n", ret);
+    ok(ret && ret == strlen(buffA), "got %ld\n", ret);
 
     ret = SearchPathA(NULL, "testdep", ".ext", ARRAY_SIZE(buffA), buffA, NULL);
-    ok(!ret, "got %d\n", ret);
+    ok(!ret, "got %ld\n", ret);
 
     /* name contains path */
     ret = SearchPathA(NULL, testdeprelA, NULL, ARRAY_SIZE(buffA), buffA, NULL);
-    ok(!ret, "got %d\n", ret);
+    ok(!ret, "got %ld\n", ret);
 
     /* fails with specified path that doesn't contain this file */
     ret = SearchPathA(pathA, testdepA, NULL, ARRAY_SIZE(buffA), buffA, NULL);
-    ok(!ret, "got %d\n", ret);
+    ok(!ret, "got %ld\n", ret);
 
     /* path is redirected for wellknown names too */
     ret = SearchPathA(NULL, kernel32A, NULL, ARRAY_SIZE(buffA), buffA, NULL);
-    ok(ret && ret == strlen(buffA), "got %d\n", ret);
+    ok(ret && ret == strlen(buffA), "got %ld\n", ret);
     ok(strcmp(buffA, path2A), "got wrong path %s, %s\n", buffA, path2A);
 
     ret = DeactivateActCtx(0, cookie);
-    ok(ret, "failed to deactivate context, %u\n", GetLastError());
+    ok(ret, "failed to deactivate context, %lu\n", GetLastError());
     ReleaseActCtx(handle);
 
     /* test the search path priority of the working directory */
@@ -1840,17 +1840,17 @@ static void test_SearchPathA(void)
     ok(ret, "failed to obtain working directory.\n");
     sprintf(pathA, "%s\\%s", tmpdirA, kernel32A);
     ret = SearchPathA(NULL, kernel32A, NULL, ARRAY_SIZE(path2A), path2A, NULL);
-    ok(ret && ret == strlen(path2A), "got %d\n", ret);
+    ok(ret && ret == strlen(path2A), "got %ld\n", ret);
     bret = CopyFileA(path2A, pathA, FALSE);
-    ok(bret != 0, "failed to copy test executable to temp directory, %u\n", GetLastError());
+    ok(bret != 0, "failed to copy test executable to temp directory, %lu\n", GetLastError());
     GetModuleFileNameA( GetModuleHandleA(0), path3A, sizeof(path3A) );
     strcpy( strrchr( path3A, '\\' ) + 1, kernel32A );
     bret = CopyFileA(path2A, path3A, FALSE);
-    ok(bret != 0, "failed to copy test executable to launch directory, %u\n", GetLastError());
+    ok(bret != 0, "failed to copy test executable to launch directory, %lu\n", GetLastError());
     bret = SetCurrentDirectoryA(tmpdirA);
     ok(bret, "failed to change working directory\n");
     ret = SearchPathA(NULL, kernel32A, ".exe", sizeof(buffA), buffA, NULL);
-    ok(ret && ret == strlen(buffA), "got %d\n", ret);
+    ok(ret && ret == strlen(buffA), "got %ld\n", ret);
     ok(strcmp(buffA, path3A) == 0, "expected %s, got %s\n", path3A, buffA);
     bret = SetCurrentDirectoryA(curdirA);
     ok(bret, "failed to reset working directory\n");
@@ -1880,18 +1880,18 @@ static void test_SearchPathW(void)
 
     /* NULL filename */
     ret = SearchPathW(pathW, NULL, NULL, ARRAY_SIZE(buffW), buffW, &ptrW);
-    ok(ret == 0, "Expected failure, got %d\n", ret);
+    ok(ret == 0, "Expected failure, got %ld\n", ret);
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-      "Expected ERROR_INVALID_PARAMETER, got %#x\n", GetLastError());
+      "Expected ERROR_INVALID_PARAMETER, got %#lx\n", GetLastError());
 
     GetWindowsDirectoryW(pathW, ARRAY_SIZE(pathW));
 
     /* empty filename */
     SetLastError(0xdeadbeef);
     ret = SearchPathW(pathW, fileW, NULL, ARRAY_SIZE(buffW), buffW, &ptrW);
-    ok(ret == 0, "Expected failure, got %d\n", ret);
+    ok(ret == 0, "Expected failure, got %ld\n", ret);
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-      "Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError());
+      "Expected ERROR_INVALID_PARAMETER, got %lx\n", GetLastError());
 
     GetTempPathW(ARRAY_SIZE(pathW), pathW);
     lstrcpyW(path2W, pathW);
@@ -1903,15 +1903,15 @@ static void test_SearchPathW(void)
 
     buffW[0] = 0;
     ret = SearchPathW(pathW, fileextW, NULL, ARRAY_SIZE(buffW), buffW, NULL);
-    ok(!ret, "Unexpected return value %u.\n", ret);
+    ok(!ret, "Unexpected return value %lu.\n", ret);
 
     buffW[0] = 0;
     ret = SearchPathW(pathW, fileextW, ext2W, ARRAY_SIZE(buffW), buffW, NULL);
-    ok(!ret, "Unexpected return value %u.\n", ret);
+    ok(!ret, "Unexpected return value %lu.\n", ret);
 
     buffW[0] = 0;
     ret = SearchPathW(pathW, fileext2W, NULL, ARRAY_SIZE(buffW), buffW, NULL);
-    ok(ret && ret == lstrlenW(path2W), "got %d\n", ret);
+    ok(ret && ret == lstrlenW(path2W), "got %ld\n", ret);
 
     DeleteFileW(path2W);
 
@@ -1926,53 +1926,53 @@ static void test_SearchPathW(void)
 
     /* search fails without active context */
     ret = SearchPathW(NULL, testdepW, NULL, ARRAY_SIZE(buffW), buffW, NULL);
-    ok(ret == 0, "got %d\n", ret);
+    ok(ret == 0, "got %ld\n", ret);
 
     ret = SearchPathW(NULL, kernel32dllW, NULL, ARRAY_SIZE(path2W), path2W, NULL);
-    ok(ret && ret == lstrlenW(path2W), "got %d\n", ret);
+    ok(ret && ret == lstrlenW(path2W), "got %ld\n", ret);
 
     /* full path, name without 'dll' extension */
     GetSystemDirectoryW(pathW, ARRAY_SIZE(pathW));
     ret = SearchPathW(pathW, kernel32W, NULL, ARRAY_SIZE(path2W), path2W, NULL);
-    ok(ret == 0, "got %d\n", ret);
+    ok(ret == 0, "got %ld\n", ret);
 
     GetWindowsDirectoryW(pathW, ARRAY_SIZE(pathW));
 
     ret = ActivateActCtx(handle, &cookie);
-    ok(ret, "failed to activate context, %u\n", GetLastError());
+    ok(ret, "failed to activate context, %lu\n", GetLastError());
 
     /* works when activated */
     ret = SearchPathW(NULL, testdepW, NULL, ARRAY_SIZE(buffW), buffW, NULL);
-    ok(ret && ret == lstrlenW(buffW), "got %d\n", ret);
+    ok(ret && ret == lstrlenW(buffW), "got %ld\n", ret);
 
     ret = SearchPathW(NULL, testdepW, extW, ARRAY_SIZE(buffW), buffW, NULL);
-    ok(ret && ret == lstrlenW(buffW), "got %d\n", ret);
+    ok(ret && ret == lstrlenW(buffW), "got %ld\n", ret);
 
     ret = SearchPathW(NULL, testdep1W, dllW, ARRAY_SIZE(buffW), buffW, NULL);
-    ok(ret && ret == lstrlenW(buffW), "got %d\n", ret);
+    ok(ret && ret == lstrlenW(buffW), "got %ld\n", ret);
 
     ret = SearchPathW(NULL, testdep1W, extW, ARRAY_SIZE(buffW), buffW, NULL);
-    ok(!ret, "got %d\n", ret);
+    ok(!ret, "got %ld\n", ret);
 
     /* name contains path */
     ret = SearchPathW(NULL, testdeprelW, NULL, ARRAY_SIZE(buffW), buffW, NULL);
-    ok(!ret, "got %d\n", ret);
+    ok(!ret, "got %ld\n", ret);
 
     /* fails with specified path that doesn't contain this file */
     ret = SearchPathW(pathW, testdepW, NULL, ARRAY_SIZE(buffW), buffW, NULL);
-    ok(!ret, "got %d\n", ret);
+    ok(!ret, "got %ld\n", ret);
 
     /* path is redirected for wellknown names too, meaning it takes precedence over normal search order */
     ret = SearchPathW(NULL, kernel32dllW, NULL, ARRAY_SIZE(buffW), buffW, NULL);
-    ok(ret && ret == lstrlenW(buffW), "got %d\n", ret);
+    ok(ret && ret == lstrlenW(buffW), "got %ld\n", ret);
     ok(lstrcmpW(buffW, path2W), "got wrong path %s, %s\n", wine_dbgstr_w(buffW), wine_dbgstr_w(path2W));
 
     /* path is built using on manifest file name */
     ret = SearchPathW(NULL, ole32W, NULL, ARRAY_SIZE(buffW), buffW, NULL);
-    ok(ret && ret == lstrlenW(buffW), "got %d\n", ret);
+    ok(ret && ret == lstrlenW(buffW), "got %ld\n", ret);
 
     ret = DeactivateActCtx(0, cookie);
-    ok(ret, "failed to deactivate context, %u\n", GetLastError());
+    ok(ret, "failed to deactivate context, %lu\n", GetLastError());
     ReleaseActCtx(handle);
 }
 
@@ -2010,12 +2010,12 @@ static void test_GetFullPathNameA(void)
                                invalid_parameters[i].len,
                                invalid_parameters[i].buffer,
                                invalid_parameters[i].lastpart);
-        ok(!ret, "[%d] Expected GetFullPathNameA to return 0, got %u\n", i, ret);
+        ok(!ret, "[%d] Expected GetFullPathNameA to return 0, got %lu\n", i, ret);
         ok(!strcmp(output, "deadbeef"), "[%d] Expected the output buffer to be unchanged, got \"%s\"\n", i, output);
         ok(filepart == (char *)0xdeadbeef, "[%d] Expected output file part pointer to be untouched, got %p\n", i, filepart);
         ok(GetLastError() == 0xdeadbeef ||
            GetLastError() == ERROR_INVALID_NAME, /* Win7 */
-           "[%d] Expected GetLastError() to return 0xdeadbeef, got %u\n",
+           "[%d] Expected GetLastError() to return 0xdeadbeef, got %lu\n",
            i, GetLastError());
     }
 
@@ -2034,7 +2034,7 @@ static void test_GetFullPathNameA(void)
         for (i = 0; i < ARRAY_SIZE(testset); i++) {
             ret = GetFullPathNameA(testset[i].input, sizeof(output),
                                    output, &filepart);
-            ok(ret, "[%d] GetFullPathName error %u\n", i, GetLastError());
+            ok(ret, "[%d] GetFullPathName error %lu\n", i, GetLastError());
             ok(!lstrcmpA(filepart, testset[i].expected),
                "[%d] expected %s got %s\n", i, testset[i].expected, filepart);
         }
@@ -2080,14 +2080,14 @@ static void test_GetFullPathNameW(void)
                                invalid_parameters[i].len,
                                invalid_parameters[i].buffer,
                                invalid_parameters[i].lastpart);
-        ok(!ret, "[%d] Expected GetFullPathNameW to return 0, got %u\n", i, ret);
+        ok(!ret, "[%d] Expected GetFullPathNameW to return 0, got %lu\n", i, ret);
         ok(!lstrcmpW(output, deadbeefW), "[%d] Expected the output buffer to be unchanged, got %s\n", i, wine_dbgstr_w(output));
         ok(filepart == (WCHAR *)0xdeadbeef ||
            (invalid_parameters[i].win7_expect && filepart == NULL),
            "[%d] Expected output file part pointer to be untouched, got %p\n", i, filepart);
         ok(GetLastError() == 0xdeadbeef ||
            GetLastError() == ERROR_INVALID_NAME, /* Win7 */
-           "[%d] Expected GetLastError() to return 0xdeadbeef, got %u\n",
+           "[%d] Expected GetLastError() to return 0xdeadbeef, got %lu\n",
            i, GetLastError());
     }
 }
@@ -2124,65 +2124,65 @@ static void test_relative_path(void)
     GetCurrentDirectoryW(MAX_PATH, curdir);
     GetTempPathA(MAX_PATH, path);
     ret = SetCurrentDirectoryA(path);
-    ok(ret, "SetCurrentDirectory error %d\n", GetLastError());
+    ok(ret, "SetCurrentDirectory error %ld\n", GetLastError());
 
     ret = CreateDirectoryA("foo", NULL);
-    ok(ret, "CreateDirectory error %d\n", GetLastError());
+    ok(ret, "CreateDirectory error %ld\n", GetLastError());
     file = CreateFileA("foo\\file", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
     ok(file != INVALID_HANDLE_VALUE, "failed to create temp file\n");
     CloseHandle(file);
     ret = CreateDirectoryA("bar", NULL);
-    ok(ret, "CreateDirectory error %d\n", GetLastError());
+    ok(ret, "CreateDirectory error %ld\n", GetLastError());
     ret = SetCurrentDirectoryA("bar");
-    ok(ret, "SetCurrentDirectory error %d\n", GetLastError());
+    ok(ret, "SetCurrentDirectory error %ld\n", GetLastError());
 
     ret = GetFileAttributesA("..\\foo\\file");
-    ok(ret != INVALID_FILE_ATTRIBUTES, "GetFileAttributes error %d\n", GetLastError());
+    ok(ret != INVALID_FILE_ATTRIBUTES, "GetFileAttributes error %ld\n", GetLastError());
 
     strcpy(buf, "deadbeef");
     ret = GetLongPathNameA(".", buf, MAX_PATH);
-    ok(ret, "GetLongPathName error %d\n", GetLastError());
+    ok(ret, "GetLongPathName error %ld\n", GetLastError());
     ok(!strcmp(buf, "."), "expected ., got %s\n", buf);
     strcpy(buf, "deadbeef");
     ret = GetShortPathNameA(".", buf, MAX_PATH);
-    ok(ret, "GetShortPathName error %d\n", GetLastError());
+    ok(ret, "GetShortPathName error %ld\n", GetLastError());
     ok(!strcmp(buf, "."), "expected ., got %s\n", buf);
 
     strcpy(buf, "deadbeef");
     ret = GetLongPathNameA("..", buf, MAX_PATH);
-    ok(ret, "GetLongPathName error %d\n", GetLastError());
+    ok(ret, "GetLongPathName error %ld\n", GetLastError());
     ok(!strcmp(buf, ".."), "expected .., got %s\n", buf);
     strcpy(buf, "deadbeef");
     ret = GetShortPathNameA("..", buf, MAX_PATH);
-    ok(ret, "GetShortPathName error %d\n", GetLastError());
+    ok(ret, "GetShortPathName error %ld\n", GetLastError());
     ok(!strcmp(buf, ".."), "expected .., got %s\n", buf);
 
     strcpy(buf, "deadbeef");
     ret = GetLongPathNameA("..\\foo\\file", buf, MAX_PATH);
-    ok(ret, "GetLongPathName error %d\n", GetLastError());
+    ok(ret, "GetLongPathName error %ld\n", GetLastError());
     ok(!strcmp(buf, "..\\foo\\file"), "expected ..\\foo\\file, got %s\n", buf);
     strcpy(buf, "deadbeef");
     ret = GetShortPathNameA("..\\foo\\file", buf, MAX_PATH);
-    ok(ret, "GetShortPathName error %d\n", GetLastError());
+    ok(ret, "GetShortPathName error %ld\n", GetLastError());
     ok(!strcmp(buf, "..\\foo\\file"), "expected ..\\foo\\file, got %s\n", buf);
 
     strcpy(buf, "deadbeef");
     ret = GetLongPathNameA(".\\..\\foo\\file", buf, MAX_PATH);
-    ok(ret, "GetLongPathName error %d\n", GetLastError());
+    ok(ret, "GetLongPathName error %ld\n", GetLastError());
     ok(!strcmp(buf, ".\\..\\foo\\file"), "expected .\\..\\foo\\file, got %s\n", buf);
     strcpy(buf, "deadbeef");
     ret = GetShortPathNameA(".\\..\\foo\\file", buf, MAX_PATH);
-    ok(ret, "GetShortPathName error %d\n", GetLastError());
+    ok(ret, "GetShortPathName error %ld\n", GetLastError());
     ok(!strcmp(buf, ".\\..\\foo\\file"), "expected .\\..\\foo\\file, got %s\n", buf);
 
     /* test double delimiters */
     strcpy(buf, "deadbeef");
     ret = GetLongPathNameA("..\\\\foo\\file", buf, MAX_PATH);
-    ok(ret, "GetLongPathName error %d\n", GetLastError());
+    ok(ret, "GetLongPathName error %ld\n", GetLastError());
     ok(!strcmp(buf, "..\\\\foo\\file"), "expected ..\\\\foo\\file, got %s\n", buf);
     strcpy(buf, "deadbeef");
     ret = GetShortPathNameA("..\\\\foo\\file", buf, MAX_PATH);
-    ok(ret, "GetShortPathName error %d\n", GetLastError());
+    ok(ret, "GetShortPathName error %ld\n", GetLastError());
     ok(!strcmp(buf, "..\\\\foo\\file"), "expected ..\\\\foo\\file, got %s\n", buf);
 
     SetCurrentDirectoryA("..");
@@ -2289,43 +2289,43 @@ static void test_SetSearchPathMode(void)
     SetLastError( 0xdeadbeef );
     ret = pSetSearchPathMode( 0 );
     ok( !ret, "SetSearchPathMode succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     ret = pSetSearchPathMode( 0x80 );
     ok( !ret, "SetSearchPathMode succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     ret = pSetSearchPathMode( BASE_SEARCH_PATH_PERMANENT );
     ok( !ret, "SetSearchPathMode succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     ret = SearchPathA( NULL, "kernel32.dll", NULL, MAX_PATH, buf, NULL );
-    ok( ret, "SearchPathA failed err %u\n", GetLastError() );
+    ok( ret, "SearchPathA failed err %lu\n", GetLastError() );
     GetCurrentDirectoryA( MAX_PATH, expect );
     strcat( expect, "\\kernel32.dll" );
     ok( !lstrcmpiA( buf, expect ), "found %s expected %s\n", buf, expect );
 
     SetLastError( 0xdeadbeef );
     ret = pSetSearchPathMode( BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE );
-    ok( ret, "SetSearchPathMode failed err %u\n", GetLastError() );
+    ok( ret, "SetSearchPathMode failed err %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     ret = SearchPathA( NULL, "kernel32.dll", NULL, MAX_PATH, buf, NULL );
-    ok( ret, "SearchPathA failed err %u\n", GetLastError() );
+    ok( ret, "SearchPathA failed err %lu\n", GetLastError() );
     GetSystemDirectoryA( expect, MAX_PATH );
     strcat( expect, "\\kernel32.dll" );
     ok( !lstrcmpiA( buf, expect ), "found %s expected %s\n", buf, expect );
 
     SetLastError( 0xdeadbeef );
     ret = pSetSearchPathMode( BASE_SEARCH_PATH_DISABLE_SAFE_SEARCHMODE );
-    ok( ret, "SetSearchPathMode failed err %u\n", GetLastError() );
+    ok( ret, "SetSearchPathMode failed err %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     ret = SearchPathA( NULL, "kernel32.dll", NULL, MAX_PATH, buf, NULL );
-    ok( ret, "SearchPathA failed err %u\n", GetLastError() );
+    ok( ret, "SearchPathA failed err %lu\n", GetLastError() );
     GetCurrentDirectoryA( MAX_PATH, expect );
     strcat( expect, "\\kernel32.dll" );
     ok( !lstrcmpiA( buf, expect ), "found %s expected %s\n", buf, expect );
@@ -2333,29 +2333,29 @@ static void test_SetSearchPathMode(void)
     SetLastError( 0xdeadbeef );
     ret = pSetSearchPathMode( BASE_SEARCH_PATH_DISABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT );
     ok( !ret, "SetSearchPathMode succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     ret = pSetSearchPathMode( BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT );
-    ok( ret, "SetSearchPathMode failed err %u\n", GetLastError() );
+    ok( ret, "SetSearchPathMode failed err %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     ret = pSetSearchPathMode( BASE_SEARCH_PATH_DISABLE_SAFE_SEARCHMODE );
     ok( !ret, "SetSearchPathMode succeeded\n" );
-    ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     ret = pSetSearchPathMode( BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE );
     ok( !ret, "SetSearchPathMode succeeded\n" );
-    ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     ret = pSetSearchPathMode( BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT );
-    ok( ret, "SetSearchPathMode failed err %u\n", GetLastError() );
+    ok( ret, "SetSearchPathMode failed err %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     ret = SearchPathA( NULL, "kernel32.dll", NULL, MAX_PATH, buf, NULL );
-    ok( ret, "SearchPathA failed err %u\n", GetLastError() );
+    ok( ret, "SearchPathA failed err %lu\n", GetLastError() );
     GetSystemDirectoryA( expect, MAX_PATH );
     strcat( expect, "\\kernel32.dll" );
     ok( !lstrcmpiA( buf, expect ), "found %s expected %s\n", buf, expect );
@@ -2434,7 +2434,7 @@ static void test_RtlGetSearchPath(void)
     build_search_path( buffer, ARRAY_SIZE(buffer), NULL, NULL, TRUE );
     path = (WCHAR *)0xdeadbeef;
     ret = pRtlGetSearchPath( &path );
-    ok( !ret, "RtlGetSearchPath failed %x\n", ret );
+    ok( !ret, "RtlGetSearchPath failed %lx\n", ret );
     ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
     pRtlReleasePath( path );
 
@@ -2442,7 +2442,7 @@ static void test_RtlGetSearchPath(void)
     build_search_path( buffer, ARRAY_SIZE(buffer), NULL, NULL, TRUE );
     path = (WCHAR *)0xdeadbeef;
     ret = pRtlGetSearchPath( &path );
-    ok( !ret, "RtlGetSearchPath failed %x\n", ret );
+    ok( !ret, "RtlGetSearchPath failed %lx\n", ret );
     ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
     pRtlReleasePath( path );
 
@@ -2452,7 +2452,7 @@ static void test_RtlGetSearchPath(void)
         build_search_path( buffer, ARRAY_SIZE(buffer), NULL, NULL, TRUE );
         path = (WCHAR *)0xdeadbeef;
         ret = pRtlGetSearchPath( &path );
-        ok( !ret, "RtlGetSearchPath failed %x\n", ret );
+        ok( !ret, "RtlGetSearchPath failed %lx\n", ret );
         ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
         pRtlReleasePath( path );
         pSetDllDirectoryW( NULL );
@@ -2483,14 +2483,14 @@ static void test_RtlGetExePath(void)
     build_search_path( buffer, ARRAY_SIZE(buffer), NULL, NULL, FALSE );
     path = (WCHAR *)0xdeadbeef;
     ret = pRtlGetExePath( fooW, &path );
-    ok( !ret, "RtlGetExePath failed %x\n", ret );
+    ok( !ret, "RtlGetExePath failed %lx\n", ret );
     ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
     pRtlReleasePath( path );
 
     build_search_path( buffer, ARRAY_SIZE(buffer), NULL, NULL, FALSE );
     path = (WCHAR *)0xdeadbeef;
     ret = pRtlGetExePath( fooW + 1, &path );
-    ok( !ret, "RtlGetExePath failed %x\n", ret );
+    ok( !ret, "RtlGetExePath failed %lx\n", ret );
     ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
     pRtlReleasePath( path );
 
@@ -2499,14 +2499,14 @@ static void test_RtlGetExePath(void)
     build_search_path( buffer, ARRAY_SIZE(buffer), NULL, NULL, FALSE );
     path = (WCHAR *)0xdeadbeef;
     ret = pRtlGetExePath( fooW, &path );
-    ok( !ret, "RtlGetExePath failed %x\n", ret );
+    ok( !ret, "RtlGetExePath failed %lx\n", ret );
     ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
     pRtlReleasePath( path );
 
     build_search_path( buffer, ARRAY_SIZE(buffer), NULL, emptyW, TRUE );
     path = (WCHAR *)0xdeadbeef;
     ret = pRtlGetExePath( fooW + 1, &path );
-    ok( !ret, "RtlGetExePath failed %x\n", ret );
+    ok( !ret, "RtlGetExePath failed %lx\n", ret );
     ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
     pRtlReleasePath( path );
 
@@ -2514,7 +2514,7 @@ static void test_RtlGetExePath(void)
     build_search_path( buffer, ARRAY_SIZE(buffer), NULL, NULL, FALSE );
     path = (WCHAR *)0xdeadbeef;
     ret = pRtlGetExePath( fooW, &path );
-    ok( !ret, "RtlGetExePath failed %x\n", ret );
+    ok( !ret, "RtlGetExePath failed %lx\n", ret );
     ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
     pRtlReleasePath( path );
 
@@ -2524,7 +2524,7 @@ static void test_RtlGetExePath(void)
         build_search_path( buffer, ARRAY_SIZE(buffer), NULL, NULL, FALSE );
         path = (WCHAR *)0xdeadbeef;
         ret = pRtlGetExePath( fooW, &path );
-        ok( !ret, "RtlGetExePath failed %x\n", ret );
+        ok( !ret, "RtlGetExePath failed %lx\n", ret );
         ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
         pRtlReleasePath( path );
         pSetDllDirectoryW( NULL );
@@ -2553,7 +2553,7 @@ static void test_LdrGetDllPath(void)
 
     path = unknown_ptr = (WCHAR *)0xdeadbeef;
     ret = pLdrGetDllPath( 0, 0, &path, &unknown_ptr );
-    ok( !ret, "LdrGetDllPath failed %x\n", ret );
+    ok( !ret, "LdrGetDllPath failed %lx\n", ret );
     ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
     ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
     pRtlReleasePath( path );
@@ -2561,7 +2561,7 @@ static void test_LdrGetDllPath(void)
     SetEnvironmentVariableA( "PATH", "foo" );
     build_search_path( buffer, ARRAY_SIZE(buffer), NULL, NULL, TRUE );
     ret = pLdrGetDllPath( 0, 0, &path, &unknown_ptr );
-    ok( !ret, "LdrGetDllPath failed %x\n", ret );
+    ok( !ret, "LdrGetDllPath failed %lx\n", ret );
     ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
     ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
     pRtlReleasePath( path );
@@ -2571,7 +2571,7 @@ static void test_LdrGetDllPath(void)
         ok( pSetDllDirectoryW( dlldir ), "SetDllDirectoryW failed\n" );
         build_search_path( buffer, ARRAY_SIZE(buffer), NULL, dlldir, TRUE );
         ret = pLdrGetDllPath( 0, 0, &path, &unknown_ptr );
-        ok( !ret, "LdrGetDllPath failed %x\n", ret );
+        ok( !ret, "LdrGetDllPath failed %lx\n", ret );
         ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
         ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
         pRtlReleasePath( path );
@@ -2579,14 +2579,14 @@ static void test_LdrGetDllPath(void)
     }
 
     ret = pLdrGetDllPath( 0, LOAD_LIBRARY_SEARCH_SYSTEM32, &path, &unknown_ptr );
-    ok( !ret, "LdrGetDllPath failed %x\n", ret );
+    ok( !ret, "LdrGetDllPath failed %lx\n", ret );
     ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
     GetSystemDirectoryW( buffer, ARRAY_SIZE(buffer) );
     ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
     pRtlReleasePath( path );
 
     ret = pLdrGetDllPath( 0, LOAD_LIBRARY_SEARCH_APPLICATION_DIR, &path, &unknown_ptr );
-    ok( !ret, "LdrGetDllPath failed %x\n", ret );
+    ok( !ret, "LdrGetDllPath failed %lx\n", ret );
     ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
     GetModuleFileNameW( NULL, buffer, ARRAY_SIZE(buffer) );
     if ((p = wcsrchr( buffer, '\\' ))) *p = 0;
@@ -2594,7 +2594,7 @@ static void test_LdrGetDllPath(void)
     pRtlReleasePath( path );
 
     ret = pLdrGetDllPath( fooW, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR, &path, &unknown_ptr );
-    ok( ret == STATUS_INVALID_PARAMETER, "LdrGetDllPath failed %x\n", ret );
+    ok( ret == STATUS_INVALID_PARAMETER, "LdrGetDllPath failed %lx\n", ret );
 
     lstrcpyW( buffer, L"\\\\?\\" );
     lstrcatW( buffer, dlldir );
@@ -2602,48 +2602,48 @@ static void test_LdrGetDllPath(void)
     *p++ = '\\';
     lstrcpyW( p, fooW );
     ret = pLdrGetDllPath( buffer, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR, &path, &unknown_ptr );
-    ok( !ret, "LdrGetDllPath failed %x\n", ret );
+    ok( !ret, "LdrGetDllPath failed %lx\n", ret );
     ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
     ok( !memcmp( path, L"\\\\?\\", 4 * sizeof(WCHAR) ) && path_equal( path + 4, dlldir ),
         "got %s expected \\\\?\\%s\n", wine_dbgstr_w(path), wine_dbgstr_w(dlldir));
     pRtlReleasePath( path );
 
     ret = pLdrGetDllPath( L"\\\\?\\c:\\test.dll", LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR, &path, &unknown_ptr );
-    ok( !ret, "LdrGetDllPath failed %x\n", ret );
+    ok( !ret, "LdrGetDllPath failed %lx\n", ret );
     ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
     ok( !lstrcmpW( path, L"\\\\?\\c:" ), "got %s expected \\\\?\\c:\n", wine_dbgstr_w(path));
     pRtlReleasePath( path );
 
     ret = pLdrGetDllPath( fooW, LOAD_WITH_ALTERED_SEARCH_PATH, &path, &unknown_ptr );
-    ok( !ret, "LdrGetDllPath failed %x\n", ret );
+    ok( !ret, "LdrGetDllPath failed %lx\n", ret );
     ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
     build_search_path( buffer, ARRAY_SIZE(buffer), NULL, NULL, TRUE );
     ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
     pRtlReleasePath( path );
 
     ret = pLdrGetDllPath( L"temp/foo", LOAD_WITH_ALTERED_SEARCH_PATH, &path, &unknown_ptr );
-    ok( !ret, "LdrGetDllPath failed %x\n", ret );
+    ok( !ret, "LdrGetDllPath failed %lx\n", ret );
     ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
     build_search_path( buffer, ARRAY_SIZE(buffer), NULL, NULL, TRUE );
     ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
     pRtlReleasePath( path );
 
     ret = pLdrGetDllPath( L".\\foo\\foobar", LOAD_WITH_ALTERED_SEARCH_PATH, &path, &unknown_ptr );
-    ok( !ret, "LdrGetDllPath failed %x\n", ret );
+    ok( !ret, "LdrGetDllPath failed %lx\n", ret );
     ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
     build_search_path( buffer, ARRAY_SIZE(buffer), L".\\foo\\foobar", NULL, TRUE );
     ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
     pRtlReleasePath( path );
 
     ret = pLdrGetDllPath( L"temp\\foo", LOAD_WITH_ALTERED_SEARCH_PATH, &path, &unknown_ptr );
-    ok( !ret, "LdrGetDllPath failed %x\n", ret );
+    ok( !ret, "LdrGetDllPath failed %lx\n", ret );
     ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
     build_search_path( buffer, ARRAY_SIZE(buffer), L"temp\\foo", NULL, TRUE );
     ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
     pRtlReleasePath( path );
 
     ret = pLdrGetDllPath( L"c:\\temp\\foo", LOAD_WITH_ALTERED_SEARCH_PATH, &path, &unknown_ptr );
-    ok( !ret, "LdrGetDllPath failed %x\n", ret );
+    ok( !ret, "LdrGetDllPath failed %lx\n", ret );
     ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
     build_search_path( buffer, ARRAY_SIZE(buffer), L"c:\\temp\\foo", NULL, TRUE );
     ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
@@ -2651,7 +2651,7 @@ static void test_LdrGetDllPath(void)
 
     lstrcpyW( buffer, fooW );
     ret = pLdrGetDllPath( buffer, LOAD_WITH_ALTERED_SEARCH_PATH | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR, &path, &unknown_ptr );
-    ok( ret == STATUS_INVALID_PARAMETER, "got %x expected %x\n", ret, STATUS_INVALID_PARAMETER );
+    ok( ret == STATUS_INVALID_PARAMETER, "got %lx expected %lx\n", ret, STATUS_INVALID_PARAMETER );
     ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
     pRtlReleasePath( path );
 
@@ -2660,7 +2660,7 @@ static void test_LdrGetDllPath(void)
     *p++ = '\\';
     lstrcpyW( p, fooW );
     ret = pLdrGetDllPath( buffer, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR, &path, &unknown_ptr );
-    ok( !ret, "LdrGetDllPath failed %x\n", ret );
+    ok( !ret, "LdrGetDllPath failed %lx\n", ret );
     ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
     ok( path_equal( path, dlldir ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(dlldir));
     pRtlReleasePath( path );
@@ -2670,7 +2670,7 @@ static void test_LdrGetDllPath(void)
         DLL_DIRECTORY_COOKIE cookie = pAddDllDirectory( dlldir );
         ok( !!cookie, "AddDllDirectory failed\n" );
         ret = pLdrGetDllPath( 0, LOAD_LIBRARY_SEARCH_USER_DIRS, &path, &unknown_ptr );
-        ok( !ret, "LdrGetDllPath failed %x\n", ret );
+        ok( !ret, "LdrGetDllPath failed %lx\n", ret );
         ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
         ok( path_equal( path, dlldir ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(dlldir));
         pRtlReleasePath( path );
@@ -2681,7 +2681,7 @@ static void test_LdrGetDllPath(void)
     {
         pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_SYSTEM32 );
         ret = pLdrGetDllPath( 0, 0, &path, &unknown_ptr );
-        ok( !ret, "LdrGetDllPath failed %x\n", ret );
+        ok( !ret, "LdrGetDllPath failed %lx\n", ret );
         ok( !unknown_ptr, "unknown ptr %p\n", unknown_ptr );
         GetSystemDirectoryW( buffer, ARRAY_SIZE(buffer) );
         ok( path_equal( path, buffer ), "got %s expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(buffer));
diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c
index 053e103bf14..7fa3c313d47 100644
--- a/dlls/kernel32/tests/pipe.c
+++ b/dlls/kernel32/tests/pipe.c
@@ -107,9 +107,9 @@ static BOOL RpcReadFile(HANDLE hFile, LPVOID buffer, DWORD bytesToRead, LPDWORD
     rpcargs.args[4] = (ULONG_PTR)overlapped;
 
     thread = CreateThread(NULL, 0, rpcThreadMain, (void *)&rpcargs, 0, &threadId);
-    ok(thread != NULL, "CreateThread failed. %d\n", GetLastError());
+    ok(thread != NULL, "CreateThread failed. %ld\n", GetLastError());
     ret = WaitForSingleObject(thread, INFINITE);
-    ok(ret == WAIT_OBJECT_0, "WaitForSingleObject failed with %d.\n", GetLastError());
+    ok(ret == WAIT_OBJECT_0, "WaitForSingleObject failed with %ld.\n", GetLastError());
     CloseHandle(thread);
 
     SetLastError(rpcargs.lastError);
@@ -120,14 +120,14 @@ static BOOL RpcReadFile(HANDLE hFile, LPVOID buffer, DWORD bytesToRead, LPDWORD
 static void _test_not_signaled(unsigned line, HANDLE handle)
 {
     DWORD res = WaitForSingleObject(handle, 0);
-    ok_(__FILE__,line)(res == WAIT_TIMEOUT, "WaitForSingleObject returned %u (%u)\n", res, GetLastError());
+    ok_(__FILE__,line)(res == WAIT_TIMEOUT, "WaitForSingleObject returned %lu (%lu)\n", res, GetLastError());
 }
 
 #define test_signaled(h) _test_signaled(__LINE__,h)
 static void _test_signaled(unsigned line, HANDLE handle)
 {
     DWORD res = WaitForSingleObject(handle, 0);
-    ok_(__FILE__,line)(res == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", res);
+    ok_(__FILE__,line)(res == WAIT_OBJECT_0, "WaitForSingleObject returned %lu\n", res);
 }
 
 #define test_pipe_info(a,b,c,d,e) _test_pipe_info(__LINE__,a,b,c,d,e)
@@ -138,10 +138,10 @@ static void _test_pipe_info(unsigned line, HANDLE pipe, DWORD ex_flags, DWORD ex
 
     res = GetNamedPipeInfo(pipe, &flags, &out_buf_size, &in_buf_size, &max_instances);
     ok_(__FILE__,line)(res, "GetNamedPipeInfo failed: %x\n", res);
-    ok_(__FILE__,line)(flags == ex_flags, "flags = %x, expected %x\n", flags, ex_flags);
-    ok_(__FILE__,line)(out_buf_size == ex_out_buf_size, "out_buf_size = %x, expected %u\n", out_buf_size, ex_out_buf_size);
-    ok_(__FILE__,line)(in_buf_size == ex_in_buf_size, "in_buf_size = %x, expected %u\n", in_buf_size, ex_in_buf_size);
-    ok_(__FILE__,line)(max_instances == ex_max_instances, "max_instances = %x, expected %u\n", max_instances, ex_max_instances);
+    ok_(__FILE__,line)(flags == ex_flags, "flags = %lx, expected %lx\n", flags, ex_flags);
+    ok_(__FILE__,line)(out_buf_size == ex_out_buf_size, "out_buf_size = %lx, expected %lu\n", out_buf_size, ex_out_buf_size);
+    ok_(__FILE__,line)(in_buf_size == ex_in_buf_size, "in_buf_size = %lx, expected %lu\n", in_buf_size, ex_in_buf_size);
+    ok_(__FILE__,line)(max_instances == ex_max_instances, "max_instances = %lx, expected %lu\n", max_instances, ex_max_instances);
 }
 
 #define test_file_access(a,b) _test_file_access(__LINE__,a,b)
@@ -153,8 +153,8 @@ static void _test_file_access(unsigned line, HANDLE handle, DWORD expected_acces
 
     memset(&info, 0x11, sizeof(info));
     status = NtQueryInformationFile(handle, &io, &info, sizeof(info), FileAccessInformation);
-    ok_(__FILE__,line)(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
-    ok_(__FILE__,line)(info.AccessFlags == expected_access, "got access %08x expected %08x\n",
+    ok_(__FILE__,line)(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08lx\n", status);
+    ok_(__FILE__,line)(info.AccessFlags == expected_access, "got access %08lx expected %08lx\n",
                        info.AccessFlags, expected_access);
 }
 
@@ -180,7 +180,7 @@ static void test_CreateNamedPipe(int pipemode)
     /* Wait for nonexistent pipe */
     ret = WaitNamedPipeA(PIPENAME, 2000);
     ok(ret == 0, "WaitNamedPipe returned %d for nonexistent pipe\n", ret);
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %lu\n", GetLastError());
 
     /* Bad parameter checks */
     hnp = CreateNamedPipeA("not a named pipe", PIPE_ACCESS_DUPLEX, pipemode | PIPE_WAIT,
@@ -232,24 +232,24 @@ static void test_CreateNamedPipe(int pipemode)
                      | FILE_APPEND_DATA | FILE_WRITE_DATA | FILE_READ_DATA);
 
     ret = PeekNamedPipe(hnp, NULL, 0, NULL, &readden, NULL);
-    ok(!ret && GetLastError() == ERROR_BAD_PIPE, "PeekNamedPipe returned %x (%u)\n",
+    ok(!ret && GetLastError() == ERROR_BAD_PIPE, "PeekNamedPipe returned %x (%lu)\n",
        ret, GetLastError());
 
     ret = WaitNamedPipeA(PIPENAME, 2000);
-    ok(ret, "WaitNamedPipe failed (%d)\n", GetLastError());
+    ok(ret, "WaitNamedPipe failed (%ld)\n", GetLastError());
 
     hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
-    ok(hFile != INVALID_HANDLE_VALUE, "CreateFile failed (%d)\n", GetLastError());
+    ok(hFile != INVALID_HANDLE_VALUE, "CreateFile failed (%ld)\n", GetLastError());
 
     ok(!WaitNamedPipeA(PIPENAME, 100), "WaitNamedPipe succeeded\n");
 
-    ok(GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %lu\n", GetLastError());
 
     /* Test ConnectNamedPipe() in both directions */
     ok(!ConnectNamedPipe(hnp, NULL), "ConnectNamedPipe(server) succeeded\n");
-    ok(GetLastError() == ERROR_PIPE_CONNECTED, "expected ERROR_PIPE_CONNECTED, got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_PIPE_CONNECTED, "expected ERROR_PIPE_CONNECTED, got %lu\n", GetLastError());
     ok(!ConnectNamedPipe(hFile, NULL), "ConnectNamedPipe(client) succeeded\n");
-    ok(GetLastError() == ERROR_INVALID_FUNCTION, "expected ERROR_INVALID_FUNCTION, got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_FUNCTION, "expected ERROR_INVALID_FUNCTION, got %lu\n", GetLastError());
 
     /* don't try to do i/o if one side couldn't be opened, as it hangs */
     if (hFile != INVALID_HANDLE_VALUE) {
@@ -260,14 +260,14 @@ static void test_CreateNamedPipe(int pipemode)
         ok(WriteFile(hnp, obuf, sizeof(obuf), &written, NULL), "WriteFile\n");
         ok(written == sizeof(obuf), "write file len\n");
         ok(ReadFile(hFile, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
-        ok(readden == sizeof(obuf), "read got %d bytes\n", readden);
+        ok(readden == sizeof(obuf), "read got %ld bytes\n", readden);
         ok(memcmp(obuf, ibuf, written) == 0, "content check\n");
 
         memset(ibuf, 0, sizeof(ibuf));
         ok(WriteFile(hFile, obuf2, sizeof(obuf2), &written, NULL), "WriteFile\n");
         ok(written == sizeof(obuf2), "write file len\n");
         ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
-        ok(readden == sizeof(obuf2), "read got %d bytes\n", readden);
+        ok(readden == sizeof(obuf2), "read got %ld bytes\n", readden);
         ok(memcmp(obuf2, ibuf, written) == 0, "content check\n");
 
         /* Now the same again, but with an additional call to PeekNamedPipe */
@@ -275,32 +275,32 @@ static void test_CreateNamedPipe(int pipemode)
         ok(WriteFile(hnp, obuf, sizeof(obuf), &written, NULL), "WriteFile\n");
         ok(written == sizeof(obuf), "write file len 1\n");
         ok(PeekNamedPipe(hFile, NULL, 0, NULL, &avail, &left), "Peek\n");
-        ok(avail == sizeof(obuf), "peek 1 got %d bytes\n", avail);
+        ok(avail == sizeof(obuf), "peek 1 got %ld bytes\n", avail);
         if (pipemode == PIPE_TYPE_BYTE)
-            ok(left == 0, "peek 1 got %d bytes left\n", left);
+            ok(left == 0, "peek 1 got %ld bytes left\n", left);
         else
-            ok(left == sizeof(obuf), "peek 1 got %d bytes left\n", left);
+            ok(left == sizeof(obuf), "peek 1 got %ld bytes left\n", left);
         ok(ReadFile(hFile, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
-        ok(readden == sizeof(obuf), "read 1 got %d bytes\n", readden);
+        ok(readden == sizeof(obuf), "read 1 got %ld bytes\n", readden);
         ok(memcmp(obuf, ibuf, written) == 0, "content 1 check\n");
 
         memset(ibuf, 0, sizeof(ibuf));
         ok(WriteFile(hFile, obuf2, sizeof(obuf2), &written, NULL), "WriteFile\n");
         ok(written == sizeof(obuf2), "write file len 2\n");
         ok(PeekNamedPipe(hnp, NULL, 0, NULL, &avail, &left), "Peek\n");
-        ok(avail == sizeof(obuf2), "peek 2 got %d bytes\n", avail);
+        ok(avail == sizeof(obuf2), "peek 2 got %ld bytes\n", avail);
         if (pipemode == PIPE_TYPE_BYTE)
-            ok(left == 0, "peek 2 got %d bytes left\n", left);
+            ok(left == 0, "peek 2 got %ld bytes left\n", left);
         else
-            ok(left == sizeof(obuf2), "peek 2 got %d bytes left\n", left);
+            ok(left == sizeof(obuf2), "peek 2 got %ld bytes left\n", left);
         ok(PeekNamedPipe(hnp, (LPVOID)1, 0, NULL, &avail, &left), "Peek\n");
-        ok(avail == sizeof(obuf2), "peek 2 got %d bytes\n", avail);
+        ok(avail == sizeof(obuf2), "peek 2 got %ld bytes\n", avail);
         if (pipemode == PIPE_TYPE_BYTE)
-            ok(left == 0, "peek 2 got %d bytes left\n", left);
+            ok(left == 0, "peek 2 got %ld bytes left\n", left);
         else
-            ok(left == sizeof(obuf2), "peek 2 got %d bytes left\n", left);
+            ok(left == sizeof(obuf2), "peek 2 got %ld bytes left\n", left);
         ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
-        ok(readden == sizeof(obuf2), "read 2 got %d bytes\n", readden);
+        ok(readden == sizeof(obuf2), "read 2 got %ld bytes\n", readden);
         ok(memcmp(obuf2, ibuf, written) == 0, "content 2 check\n");
 
         /* Test how ReadFile behaves when the buffer is not big enough for the whole message */
@@ -308,39 +308,39 @@ static void test_CreateNamedPipe(int pipemode)
         ok(WriteFile(hnp, obuf2, sizeof(obuf2), &written, NULL), "WriteFile\n");
         ok(written == sizeof(obuf2), "write file len\n");
         ok(PeekNamedPipe(hFile, ibuf, 4, &readden, &avail, &left), "Peek\n");
-        ok(readden == 4, "peek got %d bytes\n", readden);
-        ok(avail == sizeof(obuf2), "peek got %d bytes available\n", avail);
+        ok(readden == 4, "peek got %ld bytes\n", readden);
+        ok(avail == sizeof(obuf2), "peek got %ld bytes available\n", avail);
         if (pipemode == PIPE_TYPE_BYTE)
-            ok(left == -4, "peek got %d bytes left\n", left);
+            ok(left == -4, "peek got %ld bytes left\n", left);
         else
-            ok(left == sizeof(obuf2)-4, "peek got %d bytes left\n", left);
+            ok(left == sizeof(obuf2)-4, "peek got %ld bytes left\n", left);
         ok(ReadFile(hFile, ibuf, 4, &readden, NULL), "ReadFile\n");
-        ok(readden == 4, "read got %d bytes\n", readden);
+        ok(readden == 4, "read got %ld bytes\n", readden);
         ok(ReadFile(hFile, ibuf + 4, sizeof(ibuf) - 4, &readden, NULL), "ReadFile\n");
-        ok(readden == sizeof(obuf2) - 4, "read got %d bytes\n", readden);
+        ok(readden == sizeof(obuf2) - 4, "read got %ld bytes\n", readden);
         ok(memcmp(obuf2, ibuf, written) == 0, "content check\n");
 
         memset(ibuf, 0, sizeof(ibuf));
         ok(WriteFile(hFile, obuf, sizeof(obuf), &written, NULL), "WriteFile\n");
         ok(written == sizeof(obuf), "write file len\n");
         ok(PeekNamedPipe(hnp, ibuf, 4, &readden, &avail, &left), "Peek\n");
-        ok(readden == 4, "peek got %d bytes\n", readden);
-        ok(avail == sizeof(obuf), "peek got %d bytes available\n", avail);
+        ok(readden == 4, "peek got %ld bytes\n", readden);
+        ok(avail == sizeof(obuf), "peek got %ld bytes available\n", avail);
         if (pipemode == PIPE_TYPE_BYTE)
         {
-            ok(left == -4, "peek got %d bytes left\n", left);
+            ok(left == -4, "peek got %ld bytes left\n", left);
             ok(ReadFile(hnp, ibuf, 4, &readden, NULL), "ReadFile\n");
         }
         else
         {
-            ok(left == sizeof(obuf)-4, "peek got %d bytes left\n", left);
+            ok(left == sizeof(obuf)-4, "peek got %ld bytes left\n", left);
             SetLastError(0xdeadbeef);
             ok(!ReadFile(hnp, ibuf, 4, &readden, NULL), "ReadFile\n");
             ok(GetLastError() == ERROR_MORE_DATA, "wrong error\n");
         }
-        ok(readden == 4, "read got %d bytes\n", readden);
+        ok(readden == 4, "read got %ld bytes\n", readden);
         ok(ReadFile(hnp, ibuf + 4, sizeof(ibuf) - 4, &readden, NULL), "ReadFile\n");
-        ok(readden == sizeof(obuf) - 4, "read got %d bytes\n", readden);
+        ok(readden == sizeof(obuf) - 4, "read got %ld bytes\n", readden);
         ok(memcmp(obuf, ibuf, written) == 0, "content check\n");
 
         /* Similar to above, but use a read buffer size small enough to read in three parts */
@@ -350,7 +350,7 @@ static void test_CreateNamedPipe(int pipemode)
         if (pipemode == PIPE_TYPE_BYTE)
         {
             ok(ReadFile(hnp, ibuf, 4, &readden, NULL), "ReadFile\n");
-            ok(readden == 4, "read got %d bytes\n", readden);
+            ok(readden == 4, "read got %ld bytes\n", readden);
             ok(ReadFile(hnp, ibuf + 4, 4, &readden, NULL), "ReadFile\n");
         }
         else
@@ -358,14 +358,14 @@ static void test_CreateNamedPipe(int pipemode)
             SetLastError(0xdeadbeef);
             ok(!ReadFile(hnp, ibuf, 4, &readden, NULL), "ReadFile\n");
             ok(GetLastError() == ERROR_MORE_DATA, "wrong error\n");
-            ok(readden == 4, "read got %d bytes\n", readden);
+            ok(readden == 4, "read got %ld bytes\n", readden);
             SetLastError(0xdeadbeef);
             ok(!ReadFile(hnp, ibuf + 4, 4, &readden, NULL), "ReadFile\n");
             ok(GetLastError() == ERROR_MORE_DATA, "wrong error\n");
         }
-        ok(readden == 4, "read got %d bytes\n", readden);
+        ok(readden == 4, "read got %ld bytes\n", readden);
         ok(ReadFile(hnp, ibuf + 8, sizeof(ibuf) - 8, &readden, NULL), "ReadFile\n");
-        ok(readden == sizeof(obuf2) - 8, "read got %d bytes\n", readden);
+        ok(readden == sizeof(obuf2) - 8, "read got %ld bytes\n", readden);
         ok(memcmp(obuf2, ibuf, written) == 0, "content check\n");
 
         /* Test reading of multiple writes */
@@ -375,23 +375,23 @@ static void test_CreateNamedPipe(int pipemode)
         ok(WriteFile(hnp, obuf2, sizeof(obuf2), &written, NULL), " WriteFile3b\n");
         ok(written == sizeof(obuf2), "write file len 3b\n");
         ok(PeekNamedPipe(hFile, ibuf, 4, &readden, &avail, &left), "Peek3\n");
-        ok(readden == 4, "peek3 got %d bytes\n", readden);
+        ok(readden == 4, "peek3 got %ld bytes\n", readden);
         if (pipemode == PIPE_TYPE_BYTE)
-            ok(left == -4, "peek3 got %d bytes left\n", left);
+            ok(left == -4, "peek3 got %ld bytes left\n", left);
         else
-            ok(left == sizeof(obuf)-4, "peek3 got %d bytes left\n", left);
-        ok(avail == sizeof(obuf) + sizeof(obuf2), "peek3 got %d bytes available\n", avail);
+            ok(left == sizeof(obuf)-4, "peek3 got %ld bytes left\n", left);
+        ok(avail == sizeof(obuf) + sizeof(obuf2), "peek3 got %ld bytes available\n", avail);
         ok(PeekNamedPipe(hFile, ibuf, sizeof(ibuf), &readden, &avail, &left), "Peek3\n");
         if (pipemode == PIPE_TYPE_BYTE) {
-            ok(readden == sizeof(obuf) + sizeof(obuf2), "peek3 got %d bytes\n", readden);
-            ok(left == (DWORD) -(sizeof(obuf) + sizeof(obuf2)), "peek3 got %d bytes left\n", left);
+            ok(readden == sizeof(obuf) + sizeof(obuf2), "peek3 got %ld bytes\n", readden);
+            ok(left == (DWORD) -(sizeof(obuf) + sizeof(obuf2)), "peek3 got %ld bytes left\n", left);
         }
         else
         {
-            ok(readden == sizeof(obuf), "peek3 got %d bytes\n", readden);
-            ok(left == 0, "peek3 got %d bytes left\n", left);
+            ok(readden == sizeof(obuf), "peek3 got %ld bytes\n", readden);
+            ok(left == 0, "peek3 got %ld bytes left\n", left);
         }
-        ok(avail == sizeof(obuf) + sizeof(obuf2), "peek3 got %d bytes available\n", avail);
+        ok(avail == sizeof(obuf) + sizeof(obuf2), "peek3 got %ld bytes available\n", avail);
         pbuf = ibuf;
         ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "pipe content 3a check\n");
         if (pipemode == PIPE_TYPE_BYTE && readden >= sizeof(obuf)+sizeof(obuf2)) {
@@ -399,7 +399,7 @@ static void test_CreateNamedPipe(int pipemode)
             ok(memcmp(obuf2, pbuf, sizeof(obuf2)) == 0, "pipe content 3b check\n");
         }
         ok(ReadFile(hFile, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
-        ok(readden == sizeof(obuf) + sizeof(obuf2), "read 3 got %d bytes\n", readden);
+        ok(readden == sizeof(obuf) + sizeof(obuf2), "read 3 got %ld bytes\n", readden);
         pbuf = ibuf;
         ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 3a check\n");
         pbuf += sizeof(obuf);
@@ -412,23 +412,23 @@ static void test_CreateNamedPipe(int pipemode)
         ok(WriteFile(hFile, obuf2, sizeof(obuf2), &written, NULL), " WriteFile4b\n");
         ok(written == sizeof(obuf2), "write file len 4b\n");
         ok(PeekNamedPipe(hnp, ibuf, 4, &readden, &avail, &left), "Peek3\n");
-        ok(readden == 4, "peek3 got %d bytes\n", readden);
+        ok(readden == 4, "peek3 got %ld bytes\n", readden);
         if (pipemode == PIPE_TYPE_BYTE)
-            ok(left == -4, "peek3 got %d bytes left\n", left);
+            ok(left == -4, "peek3 got %ld bytes left\n", left);
         else
-            ok(left == sizeof(obuf)-4, "peek3 got %d bytes left\n", left);
-        ok(avail == sizeof(obuf) + sizeof(obuf2), "peek3 got %d bytes available\n", avail);
+            ok(left == sizeof(obuf)-4, "peek3 got %ld bytes left\n", left);
+        ok(avail == sizeof(obuf) + sizeof(obuf2), "peek3 got %ld bytes available\n", avail);
         ok(PeekNamedPipe(hnp, ibuf, sizeof(ibuf), &readden, &avail, &left), "Peek4\n");
         if (pipemode == PIPE_TYPE_BYTE) {
-            ok(readden == sizeof(obuf) + sizeof(obuf2), "peek4 got %d bytes\n", readden);
-            ok(left == (DWORD) -(sizeof(obuf) + sizeof(obuf2)), "peek4 got %d bytes left\n", left);
+            ok(readden == sizeof(obuf) + sizeof(obuf2), "peek4 got %ld bytes\n", readden);
+            ok(left == (DWORD) -(sizeof(obuf) + sizeof(obuf2)), "peek4 got %ld bytes left\n", left);
         }
         else
         {
-            ok(readden == sizeof(obuf), "peek4 got %d bytes\n", readden);
-            ok(left == 0, "peek4 got %d bytes left\n", left);
+            ok(readden == sizeof(obuf), "peek4 got %ld bytes\n", readden);
+            ok(left == 0, "peek4 got %ld bytes left\n", left);
         }
-        ok(avail == sizeof(obuf) + sizeof(obuf2), "peek4 got %d bytes available\n", avail);
+        ok(avail == sizeof(obuf) + sizeof(obuf2), "peek4 got %ld bytes available\n", avail);
         pbuf = ibuf;
         ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "pipe content 4a check\n");
         if (pipemode == PIPE_TYPE_BYTE && readden >= sizeof(obuf)+sizeof(obuf2)) {
@@ -437,10 +437,10 @@ static void test_CreateNamedPipe(int pipemode)
         }
         ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
         if (pipemode == PIPE_TYPE_BYTE) {
-            ok(readden == sizeof(obuf) + sizeof(obuf2), "read 4 got %d bytes\n", readden);
+            ok(readden == sizeof(obuf) + sizeof(obuf2), "read 4 got %ld bytes\n", readden);
         }
         else {
-            ok(readden == sizeof(obuf), "read 4 got %d bytes\n", readden);
+            ok(readden == sizeof(obuf), "read 4 got %ld bytes\n", readden);
         }
         pbuf = ibuf;
         ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 4a check\n");
@@ -465,13 +465,13 @@ static void test_CreateNamedPipe(int pipemode)
             ok(WriteFile(hnp, obuf2, sizeof(obuf2), &written, NULL), " WriteFile5b\n");
             ok(written == sizeof(obuf2), "write file len 3b\n");
             ok(PeekNamedPipe(hFile, ibuf, sizeof(ibuf), &readden, &avail, &left), "Peek5\n");
-            ok(readden == sizeof(obuf), "peek5 got %d bytes\n", readden);
-            ok(avail == sizeof(obuf) + sizeof(obuf2), "peek5 got %d bytes available\n", avail);
-            ok(left == 0, "peek5 got %d bytes left\n", left);
+            ok(readden == sizeof(obuf), "peek5 got %ld bytes\n", readden);
+            ok(avail == sizeof(obuf) + sizeof(obuf2), "peek5 got %ld bytes available\n", avail);
+            ok(left == 0, "peek5 got %ld bytes left\n", left);
             pbuf = ibuf;
             ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 5a check\n");
             ok(ReadFile(hFile, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
-            ok(readden == sizeof(obuf), "read 5 got %d bytes\n", readden);
+            ok(readden == sizeof(obuf), "read 5 got %ld bytes\n", readden);
             pbuf = ibuf;
             ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 5a check\n");
             if (readden <= sizeof(obuf))
@@ -480,11 +480,11 @@ static void test_CreateNamedPipe(int pipemode)
             /* Multiple writes in the reverse direction */
             /* the write of obuf2 from write4 should still be in the buffer */
             ok(PeekNamedPipe(hnp, ibuf, sizeof(ibuf), &readden, &avail, NULL), "Peek6a\n");
-            ok(readden == sizeof(obuf2), "peek6a got %d bytes\n", readden);
-            ok(avail == sizeof(obuf2), "peek6a got %d bytes available\n", avail);
+            ok(readden == sizeof(obuf2), "peek6a got %ld bytes\n", readden);
+            ok(avail == sizeof(obuf2), "peek6a got %ld bytes available\n", avail);
             if (avail > 0) {
                 ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
-                ok(readden == sizeof(obuf2), "read 6a got %d bytes\n", readden);
+                ok(readden == sizeof(obuf2), "read 6a got %ld bytes\n", readden);
                 pbuf = ibuf;
                 ok(memcmp(obuf2, pbuf, sizeof(obuf2)) == 0, "content 6a check\n");
             }
@@ -494,13 +494,13 @@ static void test_CreateNamedPipe(int pipemode)
             ok(WriteFile(hFile, obuf2, sizeof(obuf2), &written, NULL), " WriteFile6b\n");
             ok(written == sizeof(obuf2), "write file len 6b\n");
             ok(PeekNamedPipe(hnp, ibuf, sizeof(ibuf), &readden, &avail, NULL), "Peek6\n");
-            ok(readden == sizeof(obuf), "peek6 got %d bytes\n", readden);
+            ok(readden == sizeof(obuf), "peek6 got %ld bytes\n", readden);
 
-            ok(avail == sizeof(obuf) + sizeof(obuf2), "peek6b got %d bytes available\n", avail);
+            ok(avail == sizeof(obuf) + sizeof(obuf2), "peek6b got %ld bytes available\n", avail);
             pbuf = ibuf;
             ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 6a check\n");
             ok(ReadFile(hnp, ibuf, sizeof(ibuf), &readden, NULL), "ReadFile\n");
-            ok(readden == sizeof(obuf), "read 6b got %d bytes\n", readden);
+            ok(readden == sizeof(obuf), "read 6b got %ld bytes\n", readden);
             pbuf = ibuf;
             ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 6a check\n");
             if (readden <= sizeof(obuf))
@@ -513,9 +513,9 @@ static void test_CreateNamedPipe(int pipemode)
             SetLastError(0xdeadbeef);
             ok(!ReadFile(hFile, ibuf, 4, &readden, NULL), "ReadFile 7\n");
             ok(GetLastError() == ERROR_MORE_DATA, "wrong error 7\n");
-            ok(readden == 4, "read got %d bytes 7\n", readden);
+            ok(readden == 4, "read got %ld bytes 7\n", readden);
             ok(ReadFile(hFile, ibuf + 4, sizeof(ibuf) - 4, &readden, NULL), "ReadFile 7\n");
-            ok(readden == sizeof(obuf2) - 4, "read got %d bytes 7\n", readden);
+            ok(readden == sizeof(obuf2) - 4, "read got %ld bytes 7\n", readden);
             ok(memcmp(obuf2, ibuf, written) == 0, "content check 7\n");
 
             memset(ibuf, 0, sizeof(ibuf));
@@ -524,9 +524,9 @@ static void test_CreateNamedPipe(int pipemode)
             SetLastError(0xdeadbeef);
             ok(!ReadFile(hnp, ibuf, 4, &readden, NULL), "ReadFile 8\n");
             ok(GetLastError() == ERROR_MORE_DATA, "wrong error 8\n");
-            ok(readden == 4, "read got %d bytes 8\n", readden);
+            ok(readden == 4, "read got %ld bytes 8\n", readden);
             ok(ReadFile(hnp, ibuf + 4, sizeof(ibuf) - 4, &readden, NULL), "ReadFile 8\n");
-            ok(readden == sizeof(obuf) - 4, "read got %d bytes 8\n", readden);
+            ok(readden == sizeof(obuf) - 4, "read got %ld bytes 8\n", readden);
             ok(memcmp(obuf, ibuf, written) == 0, "content check 8\n");
 
             /* The following test shows that when doing a partial read of a message, the rest
@@ -541,15 +541,15 @@ static void test_CreateNamedPipe(int pipemode)
             SetLastError(0xdeadbeef);
             ok(!ReadFile(hFile, ibuf, 4, &readden, NULL), "ReadFile 9\n");
             ok(GetLastError() == ERROR_MORE_DATA, "wrong error 9\n");
-            ok(readden == 4, "read got %d bytes 9\n", readden);
+            ok(readden == 4, "read got %ld bytes 9\n", readden);
             SetLastError(0xdeadbeef);
             ret = RpcReadFile(hFile, ibuf + 4, 4, &readden, NULL);
             ok(!ret, "RpcReadFile 9\n");
             ok(GetLastError() == ERROR_MORE_DATA, "wrong error 9\n");
-            ok(readden == 4, "read got %d bytes 9\n", readden);
+            ok(readden == 4, "read got %ld bytes 9\n", readden);
             ret = RpcReadFile(hFile, ibuf + 8, sizeof(ibuf), &readden, NULL);
             ok(ret, "RpcReadFile 9\n");
-            ok(readden == sizeof(obuf) - 8, "read got %d bytes 9\n", readden);
+            ok(readden == sizeof(obuf) - 8, "read got %ld bytes 9\n", readden);
             ok(memcmp(obuf, ibuf, sizeof(obuf)) == 0, "content check 9\n");
             if (readden <= sizeof(obuf) - 8) /* blocks forever if second part was already received */
             {
@@ -558,14 +558,14 @@ static void test_CreateNamedPipe(int pipemode)
                 ret = RpcReadFile(hFile, ibuf, 4, &readden, NULL);
                 ok(!ret, "RpcReadFile 9\n");
                 ok(GetLastError() == ERROR_MORE_DATA, "wrong error 9\n");
-                ok(readden == 4, "read got %d bytes 9\n", readden);
+                ok(readden == 4, "read got %ld bytes 9\n", readden);
                 SetLastError(0xdeadbeef);
                 ok(!ReadFile(hFile, ibuf + 4, 4, &readden, NULL), "ReadFile 9\n");
                 ok(GetLastError() == ERROR_MORE_DATA, "wrong error 9\n");
-                ok(readden == 4, "read got %d bytes 9\n", readden);
+                ok(readden == 4, "read got %ld bytes 9\n", readden);
                 ret = RpcReadFile(hFile, ibuf + 8, sizeof(ibuf), &readden, NULL);
                 ok(ret, "RpcReadFile 9\n");
-                ok(readden == sizeof(obuf2) - 8, "read got %d bytes 9\n", readden);
+                ok(readden == sizeof(obuf2) - 8, "read got %ld bytes 9\n", readden);
                 ok(memcmp(obuf2, ibuf, sizeof(obuf2)) == 0, "content check 9\n");
             }
 
@@ -578,15 +578,15 @@ static void test_CreateNamedPipe(int pipemode)
             SetLastError(0xdeadbeef);
             ok(!ReadFile(hnp, ibuf, 4, &readden, NULL), "ReadFile 10\n");
             ok(GetLastError() == ERROR_MORE_DATA, "wrong error 10\n");
-            ok(readden == 4, "read got %d bytes 10\n", readden);
+            ok(readden == 4, "read got %ld bytes 10\n", readden);
             SetLastError(0xdeadbeef);
             ret = RpcReadFile(hnp, ibuf + 4, 4, &readden, NULL);
             ok(!ret, "RpcReadFile 10\n");
             ok(GetLastError() == ERROR_MORE_DATA, "wrong error 10\n");
-            ok(readden == 4, "read got %d bytes 10\n", readden);
+            ok(readden == 4, "read got %ld bytes 10\n", readden);
             ret = RpcReadFile(hnp, ibuf + 8, sizeof(ibuf), &readden, NULL);
             ok(ret, "RpcReadFile 10\n");
-            ok(readden == sizeof(obuf2) - 8, "read got %d bytes 10\n", readden);
+            ok(readden == sizeof(obuf2) - 8, "read got %ld bytes 10\n", readden);
             ok(memcmp(obuf2, ibuf, sizeof(obuf2)) == 0, "content check 10\n");
             if (readden <= sizeof(obuf2) - 8) /* blocks forever if second part was already received */
             {
@@ -595,14 +595,14 @@ static void test_CreateNamedPipe(int pipemode)
                 ret = RpcReadFile(hnp, ibuf, 4, &readden, NULL);
                 ok(!ret, "RpcReadFile 10\n");
                 ok(GetLastError() == ERROR_MORE_DATA, "wrong error 10\n");
-                ok(readden == 4, "read got %d bytes 10\n", readden);
+                ok(readden == 4, "read got %ld bytes 10\n", readden);
                 SetLastError(0xdeadbeef);
                 ok(!ReadFile(hnp, ibuf + 4, 4, &readden, NULL), "ReadFile 10\n");
                 ok(GetLastError() == ERROR_MORE_DATA, "wrong error 10\n");
-                ok(readden == 4, "read got %d bytes 10\n", readden);
+                ok(readden == 4, "read got %ld bytes 10\n", readden);
                 ret = RpcReadFile(hnp, ibuf + 8, sizeof(ibuf), &readden, NULL);
                 ok(ret, "RpcReadFile 10\n");
-                ok(readden == sizeof(obuf) - 8, "read got %d bytes 10\n", readden);
+                ok(readden == sizeof(obuf) - 8, "read got %ld bytes 10\n", readden);
                 ok(memcmp(obuf, ibuf, sizeof(obuf)) == 0, "content check 10\n");
             }
 
@@ -667,7 +667,7 @@ static void test_CreateNamedPipe(int pipemode)
                      | FILE_WRITE_PROPERTIES | FILE_APPEND_DATA | FILE_WRITE_DATA);
 
     hFile = CreateFileA(PIPENAME, 0, 0, NULL, OPEN_EXISTING, 0, 0);
-    ok(hFile != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
+    ok(hFile != INVALID_HANDLE_VALUE, "CreateFile failed: %lu\n", GetLastError());
     test_file_access(hFile, SYNCHRONIZE | FILE_READ_ATTRIBUTES);
     CloseHandle(hFile);
 
@@ -675,9 +675,9 @@ static void test_CreateNamedPipe(int pipemode)
 
     hnp = CreateNamedPipeA("\\\\.\\pipe\\a<>*?|\"/b", PIPE_ACCESS_DUPLEX,
             PIPE_TYPE_BYTE, 1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
-    ok(hnp != INVALID_HANDLE_VALUE, "failed to create pipe, error %u\n", GetLastError());
+    ok(hnp != INVALID_HANDLE_VALUE, "failed to create pipe, error %lu\n", GetLastError());
     hFile = CreateFileA("\\\\.\\pipe\\a<>*?|\"/b", 0, 0, NULL, OPEN_EXISTING, 0, 0);
-    ok(hFile != INVALID_HANDLE_VALUE, "failed to open pipe, error %u\n", GetLastError());
+    ok(hFile != INVALID_HANDLE_VALUE, "failed to open pipe, error %lu\n", GetLastError());
     CloseHandle(hFile);
     CloseHandle(hnp);
 
@@ -781,43 +781,43 @@ static void test_ReadFile(void)
     server = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX,
                               PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
                               1, 1024, 1024, NMPWAIT_WAIT_FOREVER, NULL);
-    ok(server != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %u\n", GetLastError());
+    ok(server != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %lu\n", GetLastError());
 
     client = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                          OPEN_EXISTING, 0, 0);
-    ok(client != INVALID_HANDLE_VALUE, "CreateFile failed with %u\n", GetLastError());
+    ok(client != INVALID_HANDLE_VALUE, "CreateFile failed with %lu\n", GetLastError());
 
     ok(WriteFile(client, buf, sizeof(buf), &size, NULL), "WriteFile\n");
 
     res = ReadFile(server, buf, 1, &size, NULL);
-    ok(!res && GetLastError() == ERROR_MORE_DATA, "ReadFile returned %x(%u)\n", res, GetLastError());
-    ok(size == 1, "size = %u\n", size);
+    ok(!res && GetLastError() == ERROR_MORE_DATA, "ReadFile returned %x(%lu)\n", res, GetLastError());
+    ok(size == 1, "size = %lu\n", size);
 
     /* pass both overlapped and ret read */
     memset(&overlapped, 0, sizeof(overlapped));
     res = ReadFile(server, buf, 1, &size, &overlapped);
-    ok(!res && GetLastError() == ERROR_MORE_DATA, "ReadFile returned %x(%u)\n", res, GetLastError());
-    ok(size == 0, "size = %u\n", size);
-    ok((NTSTATUS)overlapped.Internal == STATUS_BUFFER_OVERFLOW, "Internal = %lx\n", overlapped.Internal);
-    ok(overlapped.InternalHigh == 1, "InternalHigh = %lx\n", overlapped.InternalHigh);
+    ok(!res && GetLastError() == ERROR_MORE_DATA, "ReadFile returned %x(%lu)\n", res, GetLastError());
+    ok(size == 0, "size = %lu\n", size);
+    ok((NTSTATUS)overlapped.Internal == STATUS_BUFFER_OVERFLOW, "Internal = %Ix\n", overlapped.Internal);
+    ok(overlapped.InternalHigh == 1, "InternalHigh = %Ix\n", overlapped.InternalHigh);
 
     DisconnectNamedPipe(server);
 
     memset(&overlapped, 0, sizeof(overlapped));
     overlapped.InternalHigh = 0xdeadbeef;
     res = ReadFile(server, buf, 1, &size, &overlapped);
-    ok(!res && GetLastError() == ERROR_PIPE_NOT_CONNECTED, "ReadFile returned %x(%u)\n", res, GetLastError());
-    ok(size == 0, "size = %u\n", size);
-    ok(overlapped.Internal == STATUS_PENDING, "Internal = %lx\n", overlapped.Internal);
-    ok(overlapped.InternalHigh == 0xdeadbeef, "InternalHigh = %lx\n", overlapped.InternalHigh);
+    ok(!res && GetLastError() == ERROR_PIPE_NOT_CONNECTED, "ReadFile returned %x(%lu)\n", res, GetLastError());
+    ok(size == 0, "size = %lu\n", size);
+    ok(overlapped.Internal == STATUS_PENDING, "Internal = %Ix\n", overlapped.Internal);
+    ok(overlapped.InternalHigh == 0xdeadbeef, "InternalHigh = %Ix\n", overlapped.InternalHigh);
 
     memset(&overlapped, 0, sizeof(overlapped));
     overlapped.InternalHigh = 0xdeadbeef;
     res = WriteFile(server, buf, 1, &size, &overlapped);
-    ok(!res && GetLastError() == ERROR_PIPE_NOT_CONNECTED, "ReadFile returned %x(%u)\n", res, GetLastError());
-    ok(size == 0, "size = %u\n", size);
-    ok(overlapped.Internal == STATUS_PENDING, "Internal = %lx\n", overlapped.Internal);
-    ok(overlapped.InternalHigh == 0xdeadbeef, "InternalHigh = %lx\n", overlapped.InternalHigh);
+    ok(!res && GetLastError() == ERROR_PIPE_NOT_CONNECTED, "ReadFile returned %x(%lu)\n", res, GetLastError());
+    ok(size == 0, "size = %lu\n", size);
+    ok(overlapped.Internal == STATUS_PENDING, "Internal = %Ix\n", overlapped.Internal);
+    ok(overlapped.InternalHigh == 0xdeadbeef, "InternalHigh = %Ix\n", overlapped.InternalHigh);
 
     CloseHandle(server);
     CloseHandle(client);
@@ -919,7 +919,7 @@ static DWORD CALLBACK serverThreadMain2(LPVOID arg)
         {
             if (winetest_debug > 1) trace("Queueing an user APC\n"); /* verify the pipe is non alerable */
             ret = QueueUserAPC(&user_apc, GetCurrentThread(), 0);
-            ok(ret, "QueueUserAPC failed: %d\n", GetLastError());
+            ok(ret, "QueueUserAPC failed: %ld\n", GetLastError());
         }
 
         /* Wait for client to connect */
@@ -1010,7 +1010,7 @@ static DWORD CALLBACK serverThreadMain3(LPVOID arg)
             if (winetest_debug > 1) trace("Server calling non-overlapped ConnectNamedPipe on overlapped pipe...\n");
             success = ConnectNamedPipe(hnp, NULL);
             err = GetLastError();
-            ok(success || (err == ERROR_PIPE_CONNECTED), "ConnectNamedPipe failed: %d\n", err);
+            ok(success || (err == ERROR_PIPE_CONNECTED), "ConnectNamedPipe failed: %ld\n", err);
             if (winetest_debug > 1) trace("ConnectNamedPipe operation complete.\n");
         } else {
             if (winetest_debug > 1) trace("Server calling overlapped ConnectNamedPipe...\n");
@@ -1025,7 +1025,7 @@ static DWORD CALLBACK serverThreadMain3(LPVOID arg)
                     do {
                         ret = WaitForSingleObjectEx(hEvent, INFINITE, TRUE);
                     } while (ret == WAIT_IO_COMPLETION);
-                    ok(ret == 0, "wait ConnectNamedPipe returned %x\n", ret);
+                    ok(ret == 0, "wait ConnectNamedPipe returned %lx\n", ret);
                 }
                 success = GetOverlappedResult(hnp, &oOverlap, &dummy, letGORwait);
                 if (!letGORwait && !letWFSOEwait && !success) {
@@ -1053,7 +1053,7 @@ static DWORD CALLBACK serverThreadMain3(LPVOID arg)
                 do {
                     ret = WaitForSingleObjectEx(hEvent, INFINITE, TRUE);
                 } while (ret == WAIT_IO_COMPLETION);
-                ok(ret == 0, "wait ReadFile returned %x\n", ret);
+                ok(ret == 0, "wait ReadFile returned %lx\n", ret);
             }
             success = GetOverlappedResult(hnp, &oOverlap, &readden, letGORwait);
             if (!letGORwait && !letWFSOEwait && !success) {
@@ -1077,7 +1077,7 @@ static DWORD CALLBACK serverThreadMain3(LPVOID arg)
                 do {
                     ret = WaitForSingleObjectEx(hEvent, INFINITE, TRUE);
                 } while (ret == WAIT_IO_COMPLETION);
-                ok(ret == 0, "wait WriteFile returned %x\n", ret);
+                ok(ret == 0, "wait WriteFile returned %lx\n", ret);
             }
             success = GetOverlappedResult(hnp, &oOverlap, &written, letGORwait);
             if (!letGORwait && !letWFSOEwait && !success) {
@@ -1115,7 +1115,7 @@ static DWORD CALLBACK serverThreadMain4(LPVOID arg)
     ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
 
     hcompletion = CreateIoCompletionPort(hnp, NULL, 12345, 1);
-    ok(hcompletion != NULL, "CreateIoCompletionPort failed, error=%i\n", GetLastError());
+    ok(hcompletion != NULL, "CreateIoCompletionPort failed, error=%li\n", GetLastError());
 
     for (i = 0; i < NB_SERVER_LOOPS; i++) {
         char buf[512];
@@ -1139,17 +1139,17 @@ static DWORD CALLBACK serverThreadMain4(LPVOID arg)
         success = ConnectNamedPipe(hnp, &oConnect);
         err = GetLastError();
         ok(!success && (err == ERROR_IO_PENDING || err == ERROR_PIPE_CONNECTED),
-           "overlapped ConnectNamedPipe got %u err %u\n", success, err );
+           "overlapped ConnectNamedPipe got %u err %lu\n", success, err );
         if (!success && err == ERROR_IO_PENDING) {
             if (winetest_debug > 1) trace("ConnectNamedPipe GetQueuedCompletionStatus\n");
             success = GetQueuedCompletionStatus(hcompletion, &dummy, &compkey, &oResult, 0);
             if (!success)
             {
                 ok( GetLastError() == WAIT_TIMEOUT,
-                    "ConnectNamedPipe GetQueuedCompletionStatus wrong error %u\n", GetLastError());
+                    "ConnectNamedPipe GetQueuedCompletionStatus wrong error %lu\n", GetLastError());
                 success = GetQueuedCompletionStatus(hcompletion, &dummy, &compkey, &oResult, 10000);
             }
-            ok(success, "ConnectNamedPipe GetQueuedCompletionStatus failed, errno=%i\n", GetLastError());
+            ok(success, "ConnectNamedPipe GetQueuedCompletionStatus failed, errno=%li\n", GetLastError());
             if (success)
             {
                 ok(compkey == 12345, "got completion key %i instead of 12345\n", (int)compkey);
@@ -1165,10 +1165,10 @@ static DWORD CALLBACK serverThreadMain4(LPVOID arg)
         success = ReadFile(hnp, buf, sizeof(buf), &readden, &oRead);
         if (winetest_debug > 1) trace("Server ReadFile returned...\n");
         err = GetLastError();
-        ok(success || err == ERROR_IO_PENDING, "overlapped ReadFile, err=%i\n", err);
+        ok(success || err == ERROR_IO_PENDING, "overlapped ReadFile, err=%li\n", err);
         success = GetQueuedCompletionStatus(hcompletion, &readden, &compkey,
             &oResult, 10000);
-        ok(success, "ReadFile GetQueuedCompletionStatus failed, errno=%i\n", GetLastError());
+        ok(success, "ReadFile GetQueuedCompletionStatus failed, errno=%li\n", GetLastError());
         if (success)
         {
             ok(compkey == 12345, "got completion key %i instead of 12345\n", (int)compkey);
@@ -1180,10 +1180,10 @@ static DWORD CALLBACK serverThreadMain4(LPVOID arg)
         success = WriteFile(hnp, buf, readden, &written, &oWrite);
         if (winetest_debug > 1) trace("Server WriteFile returned...\n");
         err = GetLastError();
-        ok(success || err == ERROR_IO_PENDING, "overlapped WriteFile failed, err=%u\n", err);
+        ok(success || err == ERROR_IO_PENDING, "overlapped WriteFile failed, err=%lu\n", err);
         success = GetQueuedCompletionStatus(hcompletion, &written, &compkey,
             &oResult, 10000);
-        ok(success, "WriteFile GetQueuedCompletionStatus failed, errno=%i\n", GetLastError());
+        ok(success, "WriteFile GetQueuedCompletionStatus failed, errno=%li\n", GetLastError());
         if (success)
         {
             ok(compkey == 12345, "got completion key %i instead of 12345\n", (int)compkey);
@@ -1202,7 +1202,7 @@ static DWORD CALLBACK serverThreadMain4(LPVOID arg)
         success = WriteFile(hnp, buf, readden, &written, &oWrite);
         err = GetLastError();
         ok(!success && err == ERROR_NO_DATA,
-            "overlapped WriteFile on disconnected pipe returned %u, err=%i\n", success, err);
+            "overlapped WriteFile on disconnected pipe returned %u, err=%li\n", success, err);
 
         /* No completion status is queued on immediate error. */
         SetLastError(ERROR_SUCCESS);
@@ -1211,7 +1211,7 @@ static DWORD CALLBACK serverThreadMain4(LPVOID arg)
             &oResult, 0);
         err = GetLastError();
         ok(!success && err == WAIT_TIMEOUT && !oResult,
-           "WriteFile GetQueuedCompletionStatus returned %u, err=%i, oResult %p\n",
+           "WriteFile GetQueuedCompletionStatus returned %u, err=%li, oResult %p\n",
            success, err, oResult);
 
         if (winetest_debug > 1) trace("Server reading from disconnected pipe...\n");
@@ -1220,7 +1220,7 @@ static DWORD CALLBACK serverThreadMain4(LPVOID arg)
         if (winetest_debug > 1) trace("Server ReadFile from disconnected pipe returned...\n");
         err = GetLastError();
         ok(!success && err == ERROR_BROKEN_PIPE,
-            "overlapped ReadFile on disconnected pipe returned %u, err=%i\n", success, err);
+            "overlapped ReadFile on disconnected pipe returned %u, err=%li\n", success, err);
 
         SetLastError(ERROR_SUCCESS);
         oResult = (OVERLAPPED *)0xdeadbeef;
@@ -1228,19 +1228,19 @@ static DWORD CALLBACK serverThreadMain4(LPVOID arg)
             &oResult, 0);
         err = GetLastError();
         ok(!success && err == WAIT_TIMEOUT && !oResult,
-           "ReadFile GetQueuedCompletionStatus returned %u, err=%i, oResult %p\n",
+           "ReadFile GetQueuedCompletionStatus returned %u, err=%li, oResult %p\n",
            success, err, oResult);
 
         /* finish this connection, wait for next one */
         ok(FlushFileBuffers(hnp), "FlushFileBuffers\n");
         success = DisconnectNamedPipe(hnp);
-        ok(success, "DisconnectNamedPipe failed, err %u\n", GetLastError());
+        ok(success, "DisconnectNamedPipe failed, err %lu\n", GetLastError());
     }
 
     ret = CloseHandle(hnp);
-    ok(ret, "CloseHandle named pipe failed, err=%i\n", GetLastError());
+    ok(ret, "CloseHandle named pipe failed, err=%li\n", GetLastError());
     ret = CloseHandle(hcompletion);
-    ok(ret, "CloseHandle completion failed, err=%i\n", GetLastError());
+    ok(ret, "CloseHandle completion failed, err=%li\n", GetLastError());
 
     return 0;
 }
@@ -1296,7 +1296,7 @@ static DWORD CALLBACK serverThreadMain5(LPVOID arg)
         if (winetest_debug > 1) trace("Server calling ConnectNamedPipe...\n");
         success = ConnectNamedPipe(hnp, NULL);
         err = GetLastError();
-        ok(success || (err == ERROR_PIPE_CONNECTED), "ConnectNamedPipe failed: %d\n", err);
+        ok(success || (err == ERROR_PIPE_CONNECTED), "ConnectNamedPipe failed: %ld\n", err);
         if (winetest_debug > 1) trace("ConnectNamedPipe operation complete.\n");
 
         /* Echo bytes once */
@@ -1307,7 +1307,7 @@ static DWORD CALLBACK serverThreadMain5(LPVOID arg)
         ResetEvent(hEvent);
         success = ReadFileEx(hnp, buf, sizeof(buf), &oOverlap, completion_routine);
         if (winetest_debug > 1) trace("Server ReadFileEx returned...\n");
-        ok(success, "ReadFileEx failed, err=%i\n", GetLastError());
+        ok(success, "ReadFileEx failed, err=%li\n", GetLastError());
         ok(completion_called == 0, "completion routine called before ReadFileEx return\n");
         if (winetest_debug > 1) trace("ReadFileEx returned.\n");
         if (success) {
@@ -1315,10 +1315,10 @@ static DWORD CALLBACK serverThreadMain5(LPVOID arg)
             do {
                 ret = WaitForSingleObjectEx(hEvent, INFINITE, TRUE);
             } while (ret == WAIT_IO_COMPLETION);
-            ok(ret == 0, "wait ReadFileEx returned %x\n", ret);
+            ok(ret == 0, "wait ReadFileEx returned %lx\n", ret);
         }
         ok(completion_called == 1, "completion routine called %i times\n", completion_called);
-        ok(completion_errorcode == ERROR_SUCCESS, "completion routine got error %d\n", completion_errorcode);
+        ok(completion_errorcode == ERROR_SUCCESS, "completion routine got error %ld\n", completion_errorcode);
         ok(completion_num_bytes != 0, "read 0 bytes\n");
         ok(completion_lpoverlapped == &oOverlap, "got wrong overlapped pointer %p\n", completion_lpoverlapped);
         readden = completion_num_bytes;
@@ -1329,7 +1329,7 @@ static DWORD CALLBACK serverThreadMain5(LPVOID arg)
         ResetEvent(hEvent);
         success = WriteFileEx(hnp, buf, readden, &oOverlap, completion_routine);
         if (winetest_debug > 1) trace("Server WriteFileEx returned...\n");
-        ok(success, "WriteFileEx failed, err=%i\n", GetLastError());
+        ok(success, "WriteFileEx failed, err=%li\n", GetLastError());
         ok(completion_called == 0, "completion routine called before ReadFileEx return\n");
         if (winetest_debug > 1) trace("overlapped WriteFile returned.\n");
         if (success) {
@@ -1337,12 +1337,12 @@ static DWORD CALLBACK serverThreadMain5(LPVOID arg)
             do {
                 ret = WaitForSingleObjectEx(hEvent, INFINITE, TRUE);
             } while (ret == WAIT_IO_COMPLETION);
-            ok(ret == 0, "wait WriteFileEx returned %x\n", ret);
+            ok(ret == 0, "wait WriteFileEx returned %lx\n", ret);
         }
         if (winetest_debug > 1) trace("Server done writing.\n");
         ok(completion_called == 1, "completion routine called %i times\n", completion_called);
-        ok(completion_errorcode == ERROR_SUCCESS, "completion routine got error %d\n", completion_errorcode);
-        ok(completion_num_bytes == readden, "read %i bytes wrote %i\n", readden, completion_num_bytes);
+        ok(completion_errorcode == ERROR_SUCCESS, "completion routine got error %ld\n", completion_errorcode);
+        ok(completion_num_bytes == readden, "read %li bytes wrote %li\n", readden, completion_num_bytes);
         ok(completion_lpoverlapped == &oOverlap, "got wrong overlapped pointer %p\n", completion_lpoverlapped);
 
         /* finish this connection, wait for next one */
@@ -1414,7 +1414,7 @@ static void test_NamedPipe_2(void)
     alarm_event = CreateEventW( NULL, TRUE, FALSE, NULL );
     SetLastError(0xdeadbeef);
     alarmThread = CreateThread(NULL, 0, alarmThreadMain, (void *) 20000, 0, &alarmThreadId);
-    ok(alarmThread != NULL, "CreateThread failed: %d\n", GetLastError());
+    ok(alarmThread != NULL, "CreateThread failed: %ld\n", GetLastError());
 
     /* The servers we're about to exercise do try to clean up carefully,
      * but to reduce the chance of a test failure due to a pipe handle
@@ -1424,31 +1424,31 @@ static void test_NamedPipe_2(void)
     /* Try server #1 */
     SetLastError(0xdeadbeef);
     serverThread = CreateThread(NULL, 0, serverThreadMain1, (void *)8, 0, &serverThreadId);
-    ok(serverThread != NULL, "CreateThread failed: %d\n", GetLastError());
+    ok(serverThread != NULL, "CreateThread failed: %ld\n", GetLastError());
     exerciseServer(PIPENAME "serverThreadMain1", serverThread);
 
     /* Try server #2 */
     SetLastError(0xdeadbeef);
     serverThread = CreateThread(NULL, 0, serverThreadMain2, 0, 0, &serverThreadId);
-    ok(serverThread != NULL, "CreateThread failed: %d\n", GetLastError());
+    ok(serverThread != NULL, "CreateThread failed: %ld\n", GetLastError());
     exerciseServer(PIPENAME "serverThreadMain2", serverThread);
 
     /* Try server #3 */
     SetLastError(0xdeadbeef);
     serverThread = CreateThread(NULL, 0, serverThreadMain3, 0, 0, &serverThreadId);
-    ok(serverThread != NULL, "CreateThread failed: %d\n", GetLastError());
+    ok(serverThread != NULL, "CreateThread failed: %ld\n", GetLastError());
     exerciseServer(PIPENAME "serverThreadMain3", serverThread);
 
     /* Try server #4 */
     SetLastError(0xdeadbeef);
     serverThread = CreateThread(NULL, 0, serverThreadMain4, 0, 0, &serverThreadId);
-    ok(serverThread != NULL, "CreateThread failed: %d\n", GetLastError());
+    ok(serverThread != NULL, "CreateThread failed: %ld\n", GetLastError());
     exerciseServer(PIPENAME "serverThreadMain4", serverThread);
 
     /* Try server #5 */
     SetLastError(0xdeadbeef);
     serverThread = CreateThread(NULL, 0, serverThreadMain5, 0, 0, &serverThreadId);
-    ok(serverThread != NULL, "CreateThread failed: %d\n", GetLastError());
+    ok(serverThread != NULL, "CreateThread failed: %ld\n", GetLastError());
     exerciseServer(PIPENAME "serverThreadMain5", serverThread);
 
     ok(SetEvent( alarm_event ), "SetEvent\n");
@@ -1512,13 +1512,13 @@ static int test_DisconnectNamedPipe(void)
         ok(!DisconnectNamedPipe(hnp) && GetLastError() == ERROR_PIPE_NOT_CONNECTED,
            "DisconnectNamedPipe worked twice\n");
         ret = WaitForSingleObject(hFile, 0);
-        ok(ret == WAIT_TIMEOUT, "WaitForSingleObject returned %X\n", ret);
+        ok(ret == WAIT_TIMEOUT, "WaitForSingleObject returned %lX\n", ret);
 
         ret = PeekNamedPipe(hFile, NULL, 0, NULL, &readden, NULL);
-        ok(!ret && GetLastError() == ERROR_PIPE_NOT_CONNECTED, "PeekNamedPipe returned %x (%u)\n",
+        ok(!ret && GetLastError() == ERROR_PIPE_NOT_CONNECTED, "PeekNamedPipe returned %lx (%lu)\n",
            ret, GetLastError());
         ret = PeekNamedPipe(hnp, NULL, 0, NULL, &readden, NULL);
-        ok(!ret && GetLastError() == ERROR_BAD_PIPE, "PeekNamedPipe returned %x (%u)\n",
+        ok(!ret && GetLastError() == ERROR_BAD_PIPE, "PeekNamedPipe returned %lx (%lu)\n",
            ret, GetLastError());
         ok(CloseHandle(hFile), "CloseHandle\n");
     }
@@ -1553,20 +1553,20 @@ static void test_CreatePipe(void)
                      | FILE_WRITE_DATA);
 
     ok(WriteFile(pipewrite,PIPENAME,sizeof(PIPENAME), &written, NULL), "Write to anonymous pipe failed\n");
-    ok(written == sizeof(PIPENAME), "Write to anonymous pipe wrote %d bytes\n", written);
+    ok(written == sizeof(PIPENAME), "Write to anonymous pipe wrote %ld bytes\n", written);
     ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL), "Read from non empty pipe failed\n");
-    ok(read == sizeof(PIPENAME), "Read from  anonymous pipe got %d bytes\n", read);
+    ok(read == sizeof(PIPENAME), "Read from  anonymous pipe got %ld bytes\n", read);
     ok(CloseHandle(pipewrite), "CloseHandle for the write pipe failed\n");
     ok(CloseHandle(piperead), "CloseHandle for the read pipe failed\n");
 
     /* Now write another chunk*/
     ok(CreatePipe(&piperead, &pipewrite, &pipe_attr, 0) != 0, "CreatePipe failed\n");
     ok(WriteFile(pipewrite,PIPENAME,sizeof(PIPENAME), &written, NULL), "Write to anonymous pipe failed\n");
-    ok(written == sizeof(PIPENAME), "Write to anonymous pipe wrote %d bytes\n", written);
+    ok(written == sizeof(PIPENAME), "Write to anonymous pipe wrote %ld bytes\n", written);
     /* and close the write end, read should still succeed*/
     ok(CloseHandle(pipewrite), "CloseHandle for the Write Pipe failed\n");
     ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL), "Read from broken pipe with pending data failed\n");
-    ok(read == sizeof(PIPENAME), "Read from anonymous pipe got %d bytes\n", read);
+    ok(read == sizeof(PIPENAME), "Read from anonymous pipe got %ld bytes\n", read);
     /* But now we need to get informed that the pipe is closed */
     ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL) == 0, "Broken pipe not detected\n");
     ok(CloseHandle(piperead), "CloseHandle for the read pipe failed\n");
@@ -1577,13 +1577,13 @@ static void test_CreatePipe(void)
     for (i = 0; i < size; i++) buffer[i] = i;
     ok(CreatePipe(&piperead, &pipewrite, &pipe_attr, (size + 24)) != 0, "CreatePipe failed\n");
     ok(WriteFile(pipewrite, buffer, size, &written, NULL), "Write to anonymous pipe failed\n");
-    ok(written == size, "Write to anonymous pipe wrote %d bytes\n", written);
+    ok(written == size, "Write to anonymous pipe wrote %ld bytes\n", written);
     /* and close the write end, read should still succeed*/
     ok(CloseHandle(pipewrite), "CloseHandle for the Write Pipe failed\n");
     memset( buffer, 0, size );
     ok(ReadFile(piperead, buffer, size, &read, NULL), "Read from broken pipe with pending data failed\n");
-    ok(read == size, "Read from anonymous pipe got %d bytes\n", read);
-    for (i = 0; i < size; i++) ok( buffer[i] == (BYTE)i, "invalid data %x at %x\n", buffer[i], i );
+    ok(read == size, "Read from anonymous pipe got %ld bytes\n", read);
+    for (i = 0; i < size; i++) ok( buffer[i] == (BYTE)i, "invalid data %x at %lx\n", buffer[i], i );
     /* But now we need to get informed that the pipe is closed */
     ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL) == 0, "Broken pipe not detected\n");
     ok(CloseHandle(piperead), "CloseHandle for the read pipe failed\n");
@@ -1610,107 +1610,107 @@ static void test_CloseHandle(void)
     hpipe = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX,
                              PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
                              1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
-    ok(hpipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %u\n", GetLastError());
+    ok(hpipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %lu\n", GetLastError());
 
     hfile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile failed with %u\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile failed with %lu\n", GetLastError());
 
     numbytes = 0xdeadbeef;
     ret = WriteFile(hpipe, testdata, sizeof(testdata), &numbytes, NULL);
-    ok(ret, "WriteFile failed with %u\n", GetLastError());
-    ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
+    ok(ret, "WriteFile failed with %lu\n", GetLastError());
+    ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %lu\n", numbytes);
 
     numbytes = 0xdeadbeef;
     ret = PeekNamedPipe(hfile, NULL, 0, NULL, &numbytes, NULL);
-    ok(ret, "PeekNamedPipe failed with %u\n", GetLastError());
-    ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
+    ok(ret, "PeekNamedPipe failed with %lu\n", GetLastError());
+    ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %lu\n", numbytes);
 
     ret = CloseHandle(hpipe);
-    ok(ret, "CloseHandle failed with %u\n", GetLastError());
+    ok(ret, "CloseHandle failed with %lu\n", GetLastError());
 
     numbytes = 0xdeadbeef;
     memset(buffer, 0, sizeof(buffer));
     ret = ReadFile(hfile, buffer, 0, &numbytes, NULL);
-    ok(ret, "ReadFile failed with %u\n", GetLastError());
-    ok(numbytes == 0, "expected 0, got %u\n", numbytes);
+    ok(ret, "ReadFile failed with %lu\n", GetLastError());
+    ok(numbytes == 0, "expected 0, got %lu\n", numbytes);
 
     numbytes = 0xdeadbeef;
     ret = PeekNamedPipe(hfile, NULL, 0, NULL, &numbytes, NULL);
-    ok(ret, "PeekNamedPipe failed with %u\n", GetLastError());
-    ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
+    ok(ret, "PeekNamedPipe failed with %lu\n", GetLastError());
+    ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %lu\n", numbytes);
 
     numbytes = 0xdeadbeef;
     memset(buffer, 0, sizeof(buffer));
     ret = ReadFile(hfile, buffer, sizeof(buffer), &numbytes, NULL);
-    ok(ret, "ReadFile failed with %u\n", GetLastError());
-    ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
+    ok(ret, "ReadFile failed with %lu\n", GetLastError());
+    ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %lu\n", numbytes);
 
     ret = GetNamedPipeHandleStateA(hfile, &state, NULL, NULL, NULL, NULL, 0);
-    ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError());
+    ok(ret, "GetNamedPipeHandleState failed with %lu\n", GetLastError());
     state = PIPE_READMODE_MESSAGE | PIPE_WAIT;
     ret = SetNamedPipeHandleState(hfile, &state, NULL, NULL);
-    ok(ret, "SetNamedPipeHandleState failed with %u\n", GetLastError());
+    ok(ret, "SetNamedPipeHandleState failed with %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = ReadFile(hfile, buffer, 0, &numbytes, NULL);
     ok(!ret, "ReadFile unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %lu\n", GetLastError());
 
     numbytes = 0xdeadbeef;
     ret = PeekNamedPipe(hfile, NULL, 0, NULL, &numbytes, NULL);
-    ok(!ret && GetLastError() == ERROR_BROKEN_PIPE, "PeekNamedPipe returned %x (%u)\n",
+    ok(!ret && GetLastError() == ERROR_BROKEN_PIPE, "PeekNamedPipe returned %x (%lu)\n",
        ret, GetLastError());
-    ok(numbytes == 0xdeadbeef, "numbytes = %u\n", numbytes);
+    ok(numbytes == 0xdeadbeef, "numbytes = %lu\n", numbytes);
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, testdata, sizeof(testdata), &numbytes, NULL);
     ok(!ret, "WriteFile unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_NO_DATA, "expected ERROR_NO_DATA, got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_NO_DATA, "expected ERROR_NO_DATA, got %lu\n", GetLastError());
 
     CloseHandle(hfile);
 
     hpipe = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX,
                              PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
                              1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
-    ok(hpipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %u\n", GetLastError());
+    ok(hpipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %lu\n", GetLastError());
 
     hfile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile failed with %u\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile failed with %lu\n", GetLastError());
 
     numbytes = 0xdeadbeef;
     ret = WriteFile(hpipe, testdata, 0, &numbytes, NULL);
-    ok(ret, "WriteFile failed with %u\n", GetLastError());
-    ok(numbytes == 0, "expected 0, got %u\n", numbytes);
+    ok(ret, "WriteFile failed with %lu\n", GetLastError());
+    ok(numbytes == 0, "expected 0, got %lu\n", numbytes);
 
     ret = CloseHandle(hpipe);
-    ok(ret, "CloseHandle failed with %u\n", GetLastError());
+    ok(ret, "CloseHandle failed with %lu\n", GetLastError());
 
     numbytes = 0xdeadbeef;
     memset(buffer, 0, sizeof(buffer));
     ret = ReadFile(hfile, buffer, sizeof(buffer), &numbytes, NULL);
-    ok(ret, "ReadFile failed with %u\n", GetLastError());
-    ok(numbytes == 0, "expected 0, got %u\n", numbytes);
+    ok(ret, "ReadFile failed with %lu\n", GetLastError());
+    ok(numbytes == 0, "expected 0, got %lu\n", numbytes);
 
     SetLastError(0xdeadbeef);
     ret = ReadFile(hfile, buffer, 0, &numbytes, NULL);
     ok(!ret, "ReadFile unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %lu\n", GetLastError());
 
     ret = GetNamedPipeHandleStateA(hfile, &state, NULL, NULL, NULL, NULL, 0);
-    ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError());
+    ok(ret, "GetNamedPipeHandleState failed with %lu\n", GetLastError());
     state = PIPE_READMODE_MESSAGE | PIPE_WAIT;
     ret = SetNamedPipeHandleState(hfile, &state, NULL, NULL);
-    ok(ret, "SetNamedPipeHandleState failed with %u\n", GetLastError());
+    ok(ret, "SetNamedPipeHandleState failed with %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = ReadFile(hfile, buffer, 0, &numbytes, NULL);
     ok(!ret, "ReadFile unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(hfile, testdata, sizeof(testdata), &numbytes, NULL);
     ok(!ret, "WriteFile unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_NO_DATA, "expected ERROR_NO_DATA, got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_NO_DATA, "expected ERROR_NO_DATA, got %lu\n", GetLastError());
 
     CloseHandle(hfile);
 
@@ -1719,108 +1719,108 @@ static void test_CloseHandle(void)
     hpipe = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX,
                              PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
                              1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
-    ok(hpipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %u\n", GetLastError());
+    ok(hpipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %lu\n", GetLastError());
 
     hfile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile failed with %u\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile failed with %lu\n", GetLastError());
 
     numbytes = 0xdeadbeef;
     ret = WriteFile(hfile, testdata, sizeof(testdata), &numbytes, NULL);
-    ok(ret, "WriteFile failed with %u\n", GetLastError());
-    ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
+    ok(ret, "WriteFile failed with %lu\n", GetLastError());
+    ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %lu\n", numbytes);
 
     numbytes = 0xdeadbeef;
     ret = PeekNamedPipe(hpipe, NULL, 0, NULL, &numbytes, NULL);
-    ok(ret, "PeekNamedPipe failed with %u\n", GetLastError());
-    ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
+    ok(ret, "PeekNamedPipe failed with %lu\n", GetLastError());
+    ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %lu\n", numbytes);
 
     ret = CloseHandle(hfile);
-    ok(ret, "CloseHandle failed with %u\n", GetLastError());
+    ok(ret, "CloseHandle failed with %lu\n", GetLastError());
 
     numbytes = 0xdeadbeef;
     memset(buffer, 0, sizeof(buffer));
     ret = ReadFile(hpipe, buffer, 0, &numbytes, NULL);
     ok(ret || GetLastError() == ERROR_MORE_DATA /* >= Win 8 */,
-                 "ReadFile failed with %u\n", GetLastError());
-    ok(numbytes == 0, "expected 0, got %u\n", numbytes);
+                 "ReadFile failed with %lu\n", GetLastError());
+    ok(numbytes == 0, "expected 0, got %lu\n", numbytes);
 
     numbytes = 0xdeadbeef;
     ret = PeekNamedPipe(hpipe, NULL, 0, NULL, &numbytes, NULL);
-    ok(ret, "PeekNamedPipe failed with %u\n", GetLastError());
-    ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
+    ok(ret, "PeekNamedPipe failed with %lu\n", GetLastError());
+    ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %lu\n", numbytes);
 
     numbytes = 0xdeadbeef;
     memset(buffer, 0, sizeof(buffer));
     ret = ReadFile(hpipe, buffer, sizeof(buffer), &numbytes, NULL);
-    ok(ret, "ReadFile failed with %u\n", GetLastError());
-    ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes);
+    ok(ret, "ReadFile failed with %lu\n", GetLastError());
+    ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %lu\n", numbytes);
 
     ret = GetNamedPipeHandleStateA(hpipe, &state, NULL, NULL, NULL, NULL, 0);
-    ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError());
+    ok(ret, "GetNamedPipeHandleState failed with %lu\n", GetLastError());
     state = PIPE_READMODE_MESSAGE | PIPE_WAIT;
     ret = SetNamedPipeHandleState(hpipe, &state, NULL, NULL);
-    ok(ret, "SetNamedPipeHandleState failed with %u\n", GetLastError());
+    ok(ret, "SetNamedPipeHandleState failed with %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = ReadFile(hpipe, buffer, 0, &numbytes, NULL);
     ok(!ret, "ReadFile unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %lu\n", GetLastError());
 
     numbytes = 0xdeadbeef;
     ret = PeekNamedPipe(hpipe, NULL, 0, NULL, &numbytes, NULL);
-    ok(!ret && GetLastError() == ERROR_BROKEN_PIPE, "PeekNamedPipe returned %x (%u)\n",
+    ok(!ret && GetLastError() == ERROR_BROKEN_PIPE, "PeekNamedPipe returned %x (%lu)\n",
        ret, GetLastError());
-    ok(numbytes == 0xdeadbeef, "numbytes = %u\n", numbytes);
+    ok(numbytes == 0xdeadbeef, "numbytes = %lu\n", numbytes);
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(hpipe, testdata, sizeof(testdata), &numbytes, NULL);
     ok(!ret, "WriteFile unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_NO_DATA, "expected ERROR_NO_DATA, got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_NO_DATA, "expected ERROR_NO_DATA, got %lu\n", GetLastError());
 
     CloseHandle(hpipe);
 
     hpipe = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX,
                              PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
                              1, 1024, 1024, NMPWAIT_USE_DEFAULT_WAIT, NULL);
-    ok(hpipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %u\n", GetLastError());
+    ok(hpipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %lu\n", GetLastError());
 
     hfile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile failed with %u\n", GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile failed with %lu\n", GetLastError());
 
     numbytes = 0xdeadbeef;
     ret = WriteFile(hfile, testdata, 0, &numbytes, NULL);
-    ok(ret, "WriteFile failed with %u\n", GetLastError());
-    ok(numbytes == 0, "expected 0, got %u\n", numbytes);
+    ok(ret, "WriteFile failed with %lu\n", GetLastError());
+    ok(numbytes == 0, "expected 0, got %lu\n", numbytes);
 
     ret = CloseHandle(hfile);
-    ok(ret, "CloseHandle failed with %u\n", GetLastError());
+    ok(ret, "CloseHandle failed with %lu\n", GetLastError());
 
     numbytes = 0xdeadbeef;
     memset(buffer, 0, sizeof(buffer));
     ret = ReadFile(hpipe, buffer, sizeof(buffer), &numbytes, NULL);
-    ok(ret, "ReadFile failed with %u\n", GetLastError());
-    ok(numbytes == 0, "expected 0, got %u\n", numbytes);
+    ok(ret, "ReadFile failed with %lu\n", GetLastError());
+    ok(numbytes == 0, "expected 0, got %lu\n", numbytes);
 
     SetLastError(0xdeadbeef);
     ret = ReadFile(hpipe, buffer, 0, &numbytes, NULL);
     ok(!ret, "ReadFile unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %lu\n", GetLastError());
 
     ret = GetNamedPipeHandleStateA(hpipe, &state, NULL, NULL, NULL, NULL, 0);
-    ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError());
+    ok(ret, "GetNamedPipeHandleState failed with %lu\n", GetLastError());
     state = PIPE_READMODE_MESSAGE | PIPE_WAIT;
     ret = SetNamedPipeHandleState(hpipe, &state, NULL, NULL);
-    ok(ret, "SetNamedPipeHandleState failed with %u\n", GetLastError());
+    ok(ret, "SetNamedPipeHandleState failed with %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = ReadFile(hpipe, buffer, 0, &numbytes, NULL);
     ok(!ret, "ReadFile unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_BROKEN_PIPE, "expected ERROR_BROKEN_PIPE, got %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WriteFile(hpipe, testdata, sizeof(testdata), &numbytes, NULL);
     ok(!ret, "WriteFile unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_NO_DATA, "expected ERROR_NO_DATA, got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_NO_DATA, "expected ERROR_NO_DATA, got %lu\n", GetLastError());
 
     CloseHandle(hpipe);
 }
@@ -1851,10 +1851,10 @@ static DWORD CALLBACK named_pipe_client_func(LPVOID p)
             /* modify the token so we can tell if the pipe impersonation
              * token reverts to the process token */
             ret = AdjustTokenPrivileges(params->token, TRUE, NULL, 0, NULL, NULL);
-            ok(ret, "AdjustTokenPrivileges failed with error %d\n", GetLastError());
+            ok(ret, "AdjustTokenPrivileges failed with error %ld\n", GetLastError());
         }
         ret = SetThreadToken(NULL, params->token);
-        ok(ret, "SetThreadToken failed with error %d\n", GetLastError());
+        ok(ret, "SetThreadToken failed with error %ld\n", GetLastError());
     }
     else
     {
@@ -1862,40 +1862,40 @@ static DWORD CALLBACK named_pipe_client_func(LPVOID p)
         HANDLE process_token;
 
         ret = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY|TOKEN_ADJUST_PRIVILEGES, &process_token);
-        ok(ret, "OpenProcessToken failed with error %d\n", GetLastError());
+        ok(ret, "OpenProcessToken failed with error %ld\n", GetLastError());
 
         ret = GetTokenInformation(process_token, TokenPrivileges, NULL, 0, &Size);
-        ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetTokenInformation(TokenPrivileges) failed with %d\n", GetLastError());
+        ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetTokenInformation(TokenPrivileges) failed with %ld\n", GetLastError());
         Privileges = HeapAlloc(GetProcessHeap(), 0, Size);
         ret = GetTokenInformation(process_token, TokenPrivileges, Privileges, Size, &Size);
-        ok(ret, "GetTokenInformation(TokenPrivileges) failed with %d\n", GetLastError());
+        ok(ret, "GetTokenInformation(TokenPrivileges) failed with %ld\n", GetLastError());
 
         ret = AdjustTokenPrivileges(process_token, TRUE, NULL, 0, NULL, NULL);
-        ok(ret, "AdjustTokenPrivileges failed with error %d\n", GetLastError());
+        ok(ret, "AdjustTokenPrivileges failed with error %ld\n", GetLastError());
 
         CloseHandle(process_token);
     }
 
     pipe = CreateFileA(PIPE_NAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, params->security_flags, NULL);
-    ok(pipe != INVALID_HANDLE_VALUE, "CreateFile for pipe failed with error %d\n", GetLastError());
+    ok(pipe != INVALID_HANDLE_VALUE, "CreateFile for pipe failed with error %ld\n", GetLastError());
 
     ret = WriteFile(pipe, message, sizeof(message), &bytes_written, NULL);
-    ok(ret, "WriteFile failed with error %d\n", GetLastError());
+    ok(ret, "WriteFile failed with error %ld\n", GetLastError());
 
     ret = ReadFile(pipe, &dummy, sizeof(dummy), &bytes_read, NULL);
-    ok(ret, "ReadFile failed with error %d\n", GetLastError());
+    ok(ret, "ReadFile failed with error %ld\n", GetLastError());
 
     if (params->token)
     {
         if (params->revert)
         {
             ret = RevertToSelf();
-            ok(ret, "RevertToSelf failed with error %d\n", GetLastError());
+            ok(ret, "RevertToSelf failed with error %ld\n", GetLastError());
         }
         else
         {
             ret = AdjustTokenPrivileges(params->token, TRUE, NULL, 0, NULL, NULL);
-            ok(ret, "AdjustTokenPrivileges failed with error %d\n", GetLastError());
+            ok(ret, "AdjustTokenPrivileges failed with error %ld\n", GetLastError());
         }
     }
     else
@@ -1903,10 +1903,10 @@ static DWORD CALLBACK named_pipe_client_func(LPVOID p)
         HANDLE process_token;
 
         ret = OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &process_token);
-        ok(ret, "OpenProcessToken failed with error %d\n", GetLastError());
+        ok(ret, "OpenProcessToken failed with error %ld\n", GetLastError());
 
         ret = AdjustTokenPrivileges(process_token, FALSE, Privileges, 0, NULL, NULL);
-        ok(ret, "AdjustTokenPrivileges failed with error %d\n", GetLastError());
+        ok(ret, "AdjustTokenPrivileges failed with error %ld\n", GetLastError());
 
         HeapFree(GetProcessHeap(), 0, Privileges);
 
@@ -1914,10 +1914,10 @@ static DWORD CALLBACK named_pipe_client_func(LPVOID p)
     }
 
     ret = WriteFile(pipe, message, sizeof(message), &bytes_written, NULL);
-    ok(ret, "WriteFile failed with error %d\n", GetLastError());
+    ok(ret, "WriteFile failed with error %ld\n", GetLastError());
 
     ret = ReadFile(pipe, &dummy, sizeof(dummy), &bytes_read, NULL);
-    ok(ret, "ReadFile failed with error %d\n", GetLastError());
+    ok(ret, "ReadFile failed with error %ld\n", GetLastError());
 
     CloseHandle(pipe);
 
@@ -1931,10 +1931,10 @@ static HANDLE make_impersonation_token(DWORD Access, SECURITY_IMPERSONATION_LEVE
     BOOL ret;
 
     ret = OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE, &ProcessToken);
-    ok(ret, "OpenProcessToken failed with error %d\n", GetLastError());
+    ok(ret, "OpenProcessToken failed with error %ld\n", GetLastError());
 
     ret = pDuplicateTokenEx(ProcessToken, Access, NULL, ImpersonationLevel, TokenImpersonation, &Token);
-    ok(ret, "DuplicateToken failed with error %d\n", GetLastError());
+    ok(ret, "DuplicateToken failed with error %ld\n", GetLastError());
 
     CloseHandle(ProcessToken);
 
@@ -1958,37 +1958,37 @@ static void test_ImpersonateNamedPipeClient(HANDLE hClientToken, DWORD security_
     DWORD size;
 
     hPipeServer = CreateNamedPipeA(PIPE_NAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, 1, 100, 100, NMPWAIT_USE_DEFAULT_WAIT, NULL);
-    ok(hPipeServer != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with error %d\n", GetLastError());
+    ok(hPipeServer != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with error %ld\n", GetLastError());
 
     params.security_flags = security_flags;
     params.token = hClientToken;
     params.revert = revert;
     hThread = CreateThread(NULL, 0, named_pipe_client_func, &params, 0, &dwTid);
-    ok(hThread != NULL, "CreateThread failed with error %d\n", GetLastError());
+    ok(hThread != NULL, "CreateThread failed with error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = ImpersonateNamedPipeClient(hPipeServer);
     error = GetLastError();
     ok(ret /* win2k3 */ || (error == ERROR_CANNOT_IMPERSONATE),
-       "ImpersonateNamedPipeClient should have failed with ERROR_CANNOT_IMPERSONATE instead of %d\n", GetLastError());
+       "ImpersonateNamedPipeClient should have failed with ERROR_CANNOT_IMPERSONATE instead of %ld\n", GetLastError());
 
     ret = ConnectNamedPipe(hPipeServer, NULL);
-    ok(ret || (GetLastError() == ERROR_PIPE_CONNECTED), "ConnectNamedPipe failed with error %d\n", GetLastError());
+    ok(ret || (GetLastError() == ERROR_PIPE_CONNECTED), "ConnectNamedPipe failed with error %ld\n", GetLastError());
 
     ret = ReadFile(hPipeServer, buffer, sizeof(buffer), &dwBytesRead, NULL);
-    ok(ret, "ReadFile failed with error %d\n", GetLastError());
+    ok(ret, "ReadFile failed with error %ld\n", GetLastError());
 
     ret = ImpersonateNamedPipeClient(hPipeServer);
-    ok(ret, "ImpersonateNamedPipeClient failed with error %d\n", GetLastError());
+    ok(ret, "ImpersonateNamedPipeClient failed with error %ld\n", GetLastError());
 
     ret = OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, FALSE, &hToken);
-    ok(ret, "OpenThreadToken failed with error %d\n", GetLastError());
+    ok(ret, "OpenThreadToken failed with error %ld\n", GetLastError());
 
     (*test_func)(0, hToken);
 
     ImpersonationLevel = 0xdeadbeef; /* to avoid false positives */
     ret = GetTokenInformation(hToken, TokenImpersonationLevel, &ImpersonationLevel, sizeof(ImpersonationLevel), &size);
-    ok(ret, "GetTokenInformation(TokenImpersonationLevel) failed with error %d\n", GetLastError());
+    ok(ret, "GetTokenInformation(TokenImpersonationLevel) failed with error %ld\n", GetLastError());
     ok(ImpersonationLevel == SecurityImpersonation, "ImpersonationLevel should have been SecurityImpersonation(%d) instead of %d\n", SecurityImpersonation, ImpersonationLevel);
 
     CloseHandle(hToken);
@@ -1996,16 +1996,16 @@ static void test_ImpersonateNamedPipeClient(HANDLE hClientToken, DWORD security_
     RevertToSelf();
 
     ret = WriteFile(hPipeServer, &dummy, sizeof(dummy), &dwBytesWritten, NULL);
-    ok(ret, "WriteFile failed with error %d\n", GetLastError());
+    ok(ret, "WriteFile failed with error %ld\n", GetLastError());
 
     ret = ReadFile(hPipeServer, buffer, sizeof(buffer), &dwBytesRead, NULL);
-    ok(ret, "ReadFile failed with error %d\n", GetLastError());
+    ok(ret, "ReadFile failed with error %ld\n", GetLastError());
 
     ret = ImpersonateNamedPipeClient(hPipeServer);
-    ok(ret, "ImpersonateNamedPipeClient failed with error %d\n", GetLastError());
+    ok(ret, "ImpersonateNamedPipeClient failed with error %ld\n", GetLastError());
 
     ret = OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, FALSE, &hToken);
-    ok(ret, "OpenThreadToken failed with error %d\n", GetLastError());
+    ok(ret, "OpenThreadToken failed with error %ld\n", GetLastError());
 
     (*test_func)(1, hToken);
 
@@ -2014,12 +2014,12 @@ static void test_ImpersonateNamedPipeClient(HANDLE hClientToken, DWORD security_
     RevertToSelf();
 
     ret = WriteFile(hPipeServer, &dummy, sizeof(dummy), &dwBytesWritten, NULL);
-    ok(ret, "WriteFile failed with error %d\n", GetLastError());
+    ok(ret, "WriteFile failed with error %ld\n", GetLastError());
 
     WaitForSingleObject(hThread, INFINITE);
 
     ret = ImpersonateNamedPipeClient(hPipeServer);
-    ok(ret, "ImpersonateNamedPipeClient failed with error %d\n", GetLastError());
+    ok(ret, "ImpersonateNamedPipeClient failed with error %ld\n", GetLastError());
 
     RevertToSelf();
 
@@ -2085,7 +2085,7 @@ static void test_no_sqos_no_token(int call_index, HANDLE hToken)
     case 0:
         priv_count = get_privilege_count(hToken);
         todo_wine
-        ok(priv_count == 0, "privilege count should have been 0 instead of %d\n", priv_count);
+        ok(priv_count == 0, "privilege count should have been 0 instead of %ld\n", priv_count);
         break;
     case 1:
         priv_count = get_privilege_count(hToken);
@@ -2167,7 +2167,7 @@ static void test_no_sqos_revert(int call_index, HANDLE hToken)
     case 0:
         priv_count = get_privilege_count(hToken);
         todo_wine
-        ok(priv_count == 0, "privilege count should have been 0 instead of %d\n", priv_count);
+        ok(priv_count == 0, "privilege count should have been 0 instead of %ld\n", priv_count);
         break;
     case 1:
         priv_count = get_privilege_count(hToken);
@@ -2344,7 +2344,7 @@ static void test_overlapped(void)
     Sleep(1);
 
     ret = WriteFile(pipe, "x", 1, &num, NULL);
-    ok(ret, "WriteFile failed with error %d\n", GetLastError());
+    ok(ret, "WriteFile failed with error %ld\n", GetLastError());
 
     WaitForSingleObject(thread, INFINITE);
     CloseHandle(pipe);
@@ -2360,29 +2360,29 @@ static void test_overlapped_error(void)
     BOOL ret;
 
     event = CreateEventA(NULL, TRUE, FALSE, NULL);
-    ok(event != NULL, "CreateEventA failed with %u\n", GetLastError());
+    ok(event != NULL, "CreateEventA failed with %lu\n", GetLastError());
 
     pipe = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
                             PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
                             1, 1024, 1024, NMPWAIT_WAIT_FOREVER, NULL);
-    ok(pipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %u\n", GetLastError());
+    ok(pipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %lu\n", GetLastError());
 
     memset(&overlapped, 0, sizeof(overlapped));
     overlapped.hEvent = event;
     ret = ConnectNamedPipe(pipe, &overlapped);
     err = GetLastError();
     ok(ret == FALSE, "ConnectNamedPipe succeeded\n");
-    ok(err == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", err);
+    ok(err == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %lu\n", err);
 
     file = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                        OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
-    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed with %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed with %lu\n", GetLastError());
 
     numbytes = 0xdeadbeef;
     ret = GetOverlappedResult(pipe, &overlapped, &numbytes, TRUE);
     ok(ret == TRUE, "GetOverlappedResult failed\n");
-    ok(numbytes == 0, "expected 0, got %u\n", numbytes);
-    ok(overlapped.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08lx\n", overlapped.Internal);
+    ok(numbytes == 0, "expected 0, got %lu\n", numbytes);
+    ok(overlapped.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08Ix\n", overlapped.Internal);
 
     CloseHandle(file);
     CloseHandle(pipe);
@@ -2390,19 +2390,19 @@ static void test_overlapped_error(void)
     pipe = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
                             PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
                             1, 1024, 1024, NMPWAIT_WAIT_FOREVER, NULL);
-    ok(pipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %u\n", GetLastError());
+    ok(pipe != INVALID_HANDLE_VALUE, "CreateNamedPipe failed with %lu\n", GetLastError());
 
     file = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                        OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
-    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed with %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed with %lu\n", GetLastError());
 
     memset(&overlapped, 0, sizeof(overlapped));
     overlapped.hEvent = event;
     ret = ConnectNamedPipe(pipe, &overlapped);
     err = GetLastError();
     ok(ret == FALSE, "ConnectNamedPipe succeeded\n");
-    ok(err == ERROR_PIPE_CONNECTED, "expected ERROR_PIPE_CONNECTED, got %u\n", err);
-    ok(overlapped.Internal == STATUS_PENDING, "expected STATUS_PENDING, got %08lx\n", overlapped.Internal);
+    ok(err == ERROR_PIPE_CONNECTED, "expected ERROR_PIPE_CONNECTED, got %lu\n", err);
+    ok(overlapped.Internal == STATUS_PENDING, "expected STATUS_PENDING, got %08Ix\n", overlapped.Internal);
 
     CloseHandle(file);
     CloseHandle(pipe);
@@ -2426,14 +2426,14 @@ static void test_NamedPipeHandleState(void)
         /* lpSecurityAttrib */ NULL);
     ok(server != INVALID_HANDLE_VALUE, "cf failed\n");
     ret = GetNamedPipeHandleStateA(server, NULL, NULL, NULL, NULL, NULL, 0);
-    ok(ret, "GetNamedPipeHandleState failed: %d\n", GetLastError());
+    ok(ret, "GetNamedPipeHandleState failed: %ld\n", GetLastError());
     ret = GetNamedPipeHandleStateA(server, &state, &instances, NULL, NULL, NULL,
         0);
-    ok(ret, "GetNamedPipeHandleState failed: %d\n", GetLastError());
+    ok(ret, "GetNamedPipeHandleState failed: %ld\n", GetLastError());
     if (ret)
     {
-        ok(state == 0, "unexpected state %08x\n", state);
-        ok(instances == 1, "expected 1 instances, got %d\n", instances);
+        ok(state == 0, "unexpected state %08lx\n", state);
+        ok(instances == 1, "expected 1 instances, got %ld\n", instances);
     }
     /* Some parameters have no meaning, and therefore can't be retrieved,
      * on a local pipe.
@@ -2443,13 +2443,13 @@ static void test_NamedPipeHandleState(void)
         &collectDataTimeout, userName, ARRAY_SIZE(userName));
     todo_wine
     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-       "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+       "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
     /* A byte-mode pipe server can't be changed to message mode. */
     state = PIPE_READMODE_MESSAGE;
     SetLastError(0xdeadbeef);
     ret = SetNamedPipeHandleState(server, &state, NULL, NULL);
     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-       "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+       "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     client = CreateFileA(PIPENAME, GENERIC_READ|GENERIC_WRITE, 0, NULL,
         OPEN_EXISTING, 0, NULL);
@@ -2457,13 +2457,13 @@ static void test_NamedPipeHandleState(void)
 
     state = PIPE_READMODE_BYTE;
     ret = SetNamedPipeHandleState(client, &state, NULL, NULL);
-    ok(ret, "SetNamedPipeHandleState failed: %d\n", GetLastError());
+    ok(ret, "SetNamedPipeHandleState failed: %ld\n", GetLastError());
     /* A byte-mode pipe client can't be changed to message mode, either. */
     state = PIPE_READMODE_MESSAGE;
     SetLastError(0xdeadbeef);
     ret = SetNamedPipeHandleState(server, &state, NULL, NULL);
     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-       "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+       "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     CloseHandle(client);
     CloseHandle(server);
@@ -2477,21 +2477,21 @@ static void test_NamedPipeHandleState(void)
         /* lpSecurityAttrib */ NULL);
     ok(server != INVALID_HANDLE_VALUE, "cf failed\n");
     ret = GetNamedPipeHandleStateA(server, NULL, NULL, NULL, NULL, NULL, 0);
-    ok(ret, "GetNamedPipeHandleState failed: %d\n", GetLastError());
+    ok(ret, "GetNamedPipeHandleState failed: %ld\n", GetLastError());
     ret = GetNamedPipeHandleStateA(server, &state, &instances, NULL, NULL, NULL,
         0);
-    ok(ret, "GetNamedPipeHandleState failed: %d\n", GetLastError());
+    ok(ret, "GetNamedPipeHandleState failed: %ld\n", GetLastError());
     if (ret)
     {
-        ok(state == 0, "unexpected state %08x\n", state);
-        ok(instances == 1, "expected 1 instances, got %d\n", instances);
+        ok(state == 0, "unexpected state %08lx\n", state);
+        ok(instances == 1, "expected 1 instances, got %ld\n", instances);
     }
     /* In contrast to byte-mode pipes, a message-mode pipe server can be
      * changed to byte mode.
      */
     state = PIPE_READMODE_BYTE;
     ret = SetNamedPipeHandleState(server, &state, NULL, NULL);
-    ok(ret, "SetNamedPipeHandleState failed: %d\n", GetLastError());
+    ok(ret, "SetNamedPipeHandleState failed: %ld\n", GetLastError());
 
     client = CreateFileA(PIPENAME, GENERIC_READ|GENERIC_WRITE, 0, NULL,
         OPEN_EXISTING, 0, NULL);
@@ -2499,12 +2499,12 @@ static void test_NamedPipeHandleState(void)
 
     state = PIPE_READMODE_MESSAGE;
     ret = SetNamedPipeHandleState(client, &state, NULL, NULL);
-    ok(ret, "SetNamedPipeHandleState failed: %d\n", GetLastError());
+    ok(ret, "SetNamedPipeHandleState failed: %ld\n", GetLastError());
     /* A message-mode pipe client can also be changed to byte mode.
      */
     state = PIPE_READMODE_BYTE;
     ret = SetNamedPipeHandleState(client, &state, NULL, NULL);
-    ok(ret, "SetNamedPipeHandleState failed: %d\n", GetLastError());
+    ok(ret, "SetNamedPipeHandleState failed: %ld\n", GetLastError());
 
     CloseHandle(client);
     CloseHandle(server);
@@ -2596,37 +2596,37 @@ static void test_readfileex_pending(void)
     ret = ConnectNamedPipe(server, &overlapped);
     err = GetLastError();
     ok(ret == FALSE, "ConnectNamedPipe succeeded\n");
-    ok(err == ERROR_IO_PENDING, "ConnectNamedPipe set error %i\n", err);
+    ok(err == ERROR_IO_PENDING, "ConnectNamedPipe set error %li\n", err);
 
     wait = WaitForSingleObject(event, 0);
-    ok(wait == WAIT_TIMEOUT, "WaitForSingleObject returned %x\n", wait);
+    ok(wait == WAIT_TIMEOUT, "WaitForSingleObject returned %lx\n", wait);
 
     client = CreateFileA(PIPENAME, GENERIC_READ|GENERIC_WRITE, 0, NULL,
         OPEN_EXISTING, 0, NULL);
     ok(client != INVALID_HANDLE_VALUE, "cf failed\n");
 
     wait = WaitForSingleObject(event, 0);
-    ok(wait == WAIT_OBJECT_0, "WaitForSingleObject returned %x\n", wait);
+    ok(wait == WAIT_OBJECT_0, "WaitForSingleObject returned %lx\n", wait);
 
     /* Start a read that can't complete immediately. */
     completion_called = 0;
     ResetEvent(event);
     ret = ReadFileEx(server, read_buf, sizeof(read_buf), &overlapped, completion_routine);
-    ok(ret == TRUE, "ReadFileEx failed, err=%i\n", GetLastError());
+    ok(ret == TRUE, "ReadFileEx failed, err=%li\n", GetLastError());
     ok(completion_called == 0, "completion routine called before ReadFileEx returned\n");
 
     ret = WriteFile(client, test_string, strlen(test_string), &num_bytes, NULL);
     ok(ret == TRUE, "WriteFile failed\n");
-    ok(num_bytes == strlen(test_string), "only %i bytes written\n", num_bytes);
+    ok(num_bytes == strlen(test_string), "only %li bytes written\n", num_bytes);
 
     ok(completion_called == 0, "completion routine called during WriteFile\n");
 
     wait = WaitForSingleObjectEx(event, 0, TRUE);
-    ok(wait == WAIT_IO_COMPLETION || wait == WAIT_OBJECT_0, "WaitForSingleObjectEx returned %x\n", wait);
+    ok(wait == WAIT_IO_COMPLETION || wait == WAIT_OBJECT_0, "WaitForSingleObjectEx returned %lx\n", wait);
 
     ok(completion_called == 1, "completion not called after writing pipe\n");
-    ok(completion_errorcode == 0, "completion called with error %x\n", completion_errorcode);
-    ok(completion_num_bytes == strlen(test_string), "ReadFileEx returned only %d bytes\n", completion_num_bytes);
+    ok(completion_errorcode == 0, "completion called with error %lx\n", completion_errorcode);
+    ok(completion_num_bytes == strlen(test_string), "ReadFileEx returned only %ld bytes\n", completion_num_bytes);
     ok(completion_lpoverlapped == &overlapped, "completion called with wrong overlapped pointer\n");
     ok(!memcmp(test_string, read_buf, strlen(test_string)), "ReadFileEx read wrong bytes\n");
 
@@ -2647,16 +2647,16 @@ static void test_readfileex_pending(void)
             /* write couldn't complete immediately, presumably the pipe is full */
             break;
 
-        ok(wait == WAIT_IO_COMPLETION || wait == WAIT_OBJECT_0, "WaitForSingleObject returned %x\n", wait);
+        ok(wait == WAIT_IO_COMPLETION || wait == WAIT_OBJECT_0, "WaitForSingleObject returned %lx\n", wait);
 
-        ok(ret == TRUE, "WriteFileEx failed, err=%i\n", err);
-        ok(completion_errorcode == 0, "completion called with error %x\n", completion_errorcode);
+        ok(ret == TRUE, "WriteFileEx failed, err=%li\n", err);
+        ok(completion_errorcode == 0, "completion called with error %lx\n", completion_errorcode);
         ok(completion_lpoverlapped == &overlapped, "completion called with wrong overlapped pointer\n");
     }
 
-    ok(ret == TRUE, "WriteFileEx failed, err=%i\n", err);
+    ok(ret == TRUE, "WriteFileEx failed, err=%li\n", err);
     ok(completion_called == 0, "completion routine called but wait timed out\n");
-    ok(completion_errorcode == 0, "completion called with error %x\n", completion_errorcode);
+    ok(completion_errorcode == 0, "completion called with error %lx\n", completion_errorcode);
     ok(completion_lpoverlapped == &overlapped, "completion called with wrong overlapped pointer\n");
 
     /* free up some space in the pipe */
@@ -2669,20 +2669,20 @@ static void test_readfileex_pending(void)
 
         wait = WaitForSingleObjectEx(event, 0, TRUE);
         ok(wait == WAIT_IO_COMPLETION || wait == WAIT_OBJECT_0 || wait == WAIT_TIMEOUT,
-           "WaitForSingleObject returned %x\n", wait);
+           "WaitForSingleObject returned %lx\n", wait);
         if (wait != WAIT_TIMEOUT) break;
     }
 
     ok(completion_called == 1, "completion routine not called\n");
-    ok(completion_errorcode == 0, "completion called with error %x\n", completion_errorcode);
+    ok(completion_errorcode == 0, "completion called with error %lx\n", completion_errorcode);
     ok(completion_lpoverlapped == &overlapped, "completion called with wrong overlapped pointer\n");
 
     num_bytes = 0xdeadbeef;
     SetLastError(0xdeadbeef);
     ret = ReadFile(INVALID_HANDLE_VALUE, read_buf, 0, &num_bytes, NULL);
     ok(!ret, "ReadFile should fail\n");
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n", GetLastError());
-    ok(num_bytes == 0, "expected 0, got %u\n", num_bytes);
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "wrong error %lu\n", GetLastError());
+    ok(num_bytes == 0, "expected 0, got %lu\n", num_bytes);
 
     S(U(overlapped)).Offset = 0;
     S(U(overlapped)).OffsetHigh = 0;
@@ -2693,31 +2693,31 @@ static void test_readfileex_pending(void)
     SetLastError(0xdeadbeef);
     ret = ReadFile(server, read_buf, 0, &num_bytes, &overlapped);
     ok(!ret, "ReadFile should fail\n");
-    ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %d\n", GetLastError());
-    ok(num_bytes == 0, "bytes %u\n", num_bytes);
-    ok((NTSTATUS)overlapped.Internal == STATUS_PENDING, "expected STATUS_PENDING, got %#lx\n", overlapped.Internal);
-    ok(overlapped.InternalHigh == -1, "expected -1, got %lu\n", overlapped.InternalHigh);
+    ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %ld\n", GetLastError());
+    ok(num_bytes == 0, "bytes %lu\n", num_bytes);
+    ok((NTSTATUS)overlapped.Internal == STATUS_PENDING, "expected STATUS_PENDING, got %#Ix\n", overlapped.Internal);
+    ok(overlapped.InternalHigh == -1, "expected -1, got %Iu\n", overlapped.InternalHigh);
 
     wait = WaitForSingleObject(event, 100);
-    ok(wait == WAIT_TIMEOUT, "WaitForSingleObject returned %x\n", wait);
+    ok(wait == WAIT_TIMEOUT, "WaitForSingleObject returned %lx\n", wait);
 
     num_bytes = 0xdeadbeef;
     ret = WriteFile(client, test_string, 1, &num_bytes, NULL);
     ok(ret, "WriteFile failed\n");
-    ok(num_bytes == 1, "bytes %u\n", num_bytes);
+    ok(num_bytes == 1, "bytes %lu\n", num_bytes);
 
     wait = WaitForSingleObject(event, 100);
-    ok(wait == WAIT_OBJECT_0, "WaitForSingleObject returned %x\n", wait);
+    ok(wait == WAIT_OBJECT_0, "WaitForSingleObject returned %lx\n", wait);
 
-    ok(num_bytes == 1, "bytes %u\n", num_bytes);
-    ok((NTSTATUS)overlapped.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", overlapped.Internal);
-    ok(overlapped.InternalHigh == 0, "expected 0, got %lu\n", overlapped.InternalHigh);
+    ok(num_bytes == 1, "bytes %lu\n", num_bytes);
+    ok((NTSTATUS)overlapped.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#Ix\n", overlapped.Internal);
+    ok(overlapped.InternalHigh == 0, "expected 0, got %Iu\n", overlapped.InternalHigh);
 
     /* read the pending byte and clear the pipe */
     num_bytes = 0xdeadbeef;
     ret = ReadFile(server, read_buf, 1, &num_bytes, &overlapped);
     ok(ret, "ReadFile failed\n");
-    ok(num_bytes == 1, "bytes %u\n", num_bytes);
+    ok(num_bytes == 1, "bytes %lu\n", num_bytes);
 
     CloseHandle(client);
     CloseHandle(server);
@@ -2735,28 +2735,28 @@ static void _test_peek_pipe(unsigned line, HANDLE pipe, DWORD expected_read, DWO
     BOOL r;
 
     r = PeekNamedPipe(pipe, buf, sizeof(buf), &bytes_read, &avail, &left);
-    ok_(__FILE__,line)(r, "PeekNamedPipe failed: %u\n", GetLastError());
-    ok_(__FILE__,line)(bytes_read == expected_read, "bytes_read = %u, expected %u\n", bytes_read, expected_read);
-    ok_(__FILE__,line)(avail == expected_avail, "avail = %u, expected %u\n", avail, expected_avail);
-    ok_(__FILE__,line)(left == expected_message_length - expected_read, "left = %d, expected %d\n",
+    ok_(__FILE__,line)(r, "PeekNamedPipe failed: %lu\n", GetLastError());
+    ok_(__FILE__,line)(bytes_read == expected_read, "bytes_read = %lu, expected %lu\n", bytes_read, expected_read);
+    ok_(__FILE__,line)(avail == expected_avail, "avail = %lu, expected %lu\n", avail, expected_avail);
+    ok_(__FILE__,line)(left == expected_message_length - expected_read, "left = %ld, expected %ld\n",
                        left, expected_message_length - expected_read);
 
     status = NtFsControlFile(pipe, 0, NULL, NULL, &io, FSCTL_PIPE_PEEK, NULL, 0, buf, sizeof(buf));
-    ok_(__FILE__,line)(!status || status == STATUS_PENDING, "NtFsControlFile(FSCTL_PIPE_PEEK) failed: %x\n", status);
+    ok_(__FILE__,line)(!status || status == STATUS_PENDING, "NtFsControlFile(FSCTL_PIPE_PEEK) failed: %lx\n", status);
     ok_(__FILE__,line)(io.Information == FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[expected_read]),
-                       "io.Information = %lu\n", io.Information);
-    ok_(__FILE__,line)(peek_buf->ReadDataAvailable == expected_avail, "ReadDataAvailable = %u, expected %u\n",
+                       "io.Information = %Iu\n", io.Information);
+    ok_(__FILE__,line)(peek_buf->ReadDataAvailable == expected_avail, "ReadDataAvailable = %lu, expected %lu\n",
                        peek_buf->ReadDataAvailable, expected_avail);
-    ok_(__FILE__,line)(peek_buf->MessageLength == expected_message_length, "MessageLength = %u, expected %u\n",
+    ok_(__FILE__,line)(peek_buf->MessageLength == expected_message_length, "MessageLength = %lu, expected %lu\n",
                        peek_buf->MessageLength, expected_message_length);
 
     if (expected_read)
     {
         r = PeekNamedPipe(pipe, buf, 1, &bytes_read, &avail, &left);
-        ok_(__FILE__,line)(r, "PeekNamedPipe failed: %u\n", GetLastError());
-        ok_(__FILE__,line)(bytes_read == 1, "bytes_read = %u, expected %u\n", bytes_read, expected_read);
-        ok_(__FILE__,line)(avail == expected_avail, "avail = %u, expected %u\n", avail, expected_avail);
-        ok_(__FILE__,line)(left == expected_message_length-1, "left = %d, expected %d\n", left, expected_message_length-1);
+        ok_(__FILE__,line)(r, "PeekNamedPipe failed: %lu\n", GetLastError());
+        ok_(__FILE__,line)(bytes_read == 1, "bytes_read = %lu, expected %lu\n", bytes_read, expected_read);
+        ok_(__FILE__,line)(avail == expected_avail, "avail = %lu, expected %lu\n", avail, expected_avail);
+        ok_(__FILE__,line)(left == expected_message_length-1, "left = %ld, expected %ld\n", left, expected_message_length-1);
     }
 }
 
@@ -2771,22 +2771,22 @@ static void _overlapped_read_sync(unsigned line, HANDLE reader, void *buf, DWORD
     overlapped.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
     res = ReadFile(reader, buf, buf_size, &read_bytes, &overlapped);
     if (partial_read)
-        ok_(__FILE__,line)(!res && GetLastError() == ERROR_MORE_DATA, "ReadFile returned: %x (%u)\n", res, GetLastError());
+        ok_(__FILE__,line)(!res && GetLastError() == ERROR_MORE_DATA, "ReadFile returned: %x (%lu)\n", res, GetLastError());
     else
-        ok_(__FILE__,line)(res, "ReadFile failed: %u\n", GetLastError());
+        ok_(__FILE__,line)(res, "ReadFile failed: %lu\n", GetLastError());
     if(partial_read)
-        ok_(__FILE__,line)(!read_bytes, "read_bytes %u expected 0\n", read_bytes);
+        ok_(__FILE__,line)(!read_bytes, "read_bytes %lu expected 0\n", read_bytes);
     else
-        ok_(__FILE__,line)(read_bytes == expected_result, "read_bytes %u expected %u\n", read_bytes, expected_result);
+        ok_(__FILE__,line)(read_bytes == expected_result, "read_bytes %lu expected %lu\n", read_bytes, expected_result);
 
     read_bytes = 0xdeadbeef;
     res = GetOverlappedResult(reader, &overlapped, &read_bytes, FALSE);
     if (partial_read)
         ok_(__FILE__,line)(!res && GetLastError() == ERROR_MORE_DATA,
-                           "GetOverlappedResult returned: %x (%u)\n", res, GetLastError());
+                           "GetOverlappedResult returned: %x (%lu)\n", res, GetLastError());
     else
-        ok_(__FILE__,line)(res, "GetOverlappedResult failed: %u\n", GetLastError());
-    ok_(__FILE__,line)(read_bytes == expected_result, "read_bytes %u expected %u\n", read_bytes, expected_result);
+        ok_(__FILE__,line)(res, "GetOverlappedResult failed: %lu\n", GetLastError());
+    ok_(__FILE__,line)(read_bytes == expected_result, "read_bytes %lu expected %lu\n", read_bytes, expected_result);
     CloseHandle(overlapped.hEvent);
 }
 
@@ -2799,8 +2799,8 @@ static void _overlapped_read_async(unsigned line, HANDLE reader, void *buf, DWOR
     memset(overlapped, 0, sizeof(*overlapped));
     overlapped->hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
     res = ReadFile(reader, buf, buf_size, &read_bytes, overlapped);
-    ok_(__FILE__,line)(!res && GetLastError() == ERROR_IO_PENDING, "ReadFile returned %x(%u)\n", res, GetLastError());
-    ok_(__FILE__,line)(!read_bytes, "read_bytes %u expected 0\n", read_bytes);
+    ok_(__FILE__,line)(!res && GetLastError() == ERROR_IO_PENDING, "ReadFile returned %x(%lu)\n", res, GetLastError());
+    ok_(__FILE__,line)(!read_bytes, "read_bytes %lu expected 0\n", read_bytes);
 
     _test_not_signaled(line, overlapped->hEvent);
 }
@@ -2815,13 +2815,13 @@ static void _overlapped_write_sync(unsigned line, HANDLE writer, void *buf, DWOR
     memset(&overlapped, 0, sizeof(overlapped));
     overlapped.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
     res = WriteFile(writer, buf, size, &written_bytes, &overlapped);
-    ok_(__FILE__,line)(res, "WriteFile returned %x(%u)\n", res, GetLastError());
-    ok_(__FILE__,line)(written_bytes == size, "WriteFile returned written_bytes = %u\n", written_bytes);
+    ok_(__FILE__,line)(res, "WriteFile returned %x(%lu)\n", res, GetLastError());
+    ok_(__FILE__,line)(written_bytes == size, "WriteFile returned written_bytes = %lu\n", written_bytes);
 
     written_bytes = 0xdeadbeef;
     res = GetOverlappedResult(writer, &overlapped, &written_bytes, FALSE);
-    ok_(__FILE__,line)(res, "GetOverlappedResult failed: %u\n", GetLastError());
-    ok_(__FILE__,line)(written_bytes == size, "GetOverlappedResult returned written_bytes %u expected %u\n", written_bytes, size);
+    ok_(__FILE__,line)(res, "GetOverlappedResult failed: %lu\n", GetLastError());
+    ok_(__FILE__,line)(written_bytes == size, "GetOverlappedResult returned written_bytes %lu expected %lu\n", written_bytes, size);
 
     CloseHandle(overlapped.hEvent);
 }
@@ -2835,8 +2835,8 @@ static void _overlapped_write_async(unsigned line, HANDLE writer, void *buf, DWO
     memset(overlapped, 0, sizeof(*overlapped));
     overlapped->hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
     res = WriteFile(writer, buf, size, &written_bytes, overlapped);
-    ok_(__FILE__,line)(!res && GetLastError() == ERROR_IO_PENDING, "WriteFile returned %x(%u)\n", res, GetLastError());
-    ok_(__FILE__,line)(!written_bytes, "written_bytes = %u\n", written_bytes);
+    ok_(__FILE__,line)(!res && GetLastError() == ERROR_IO_PENDING, "WriteFile returned %x(%lu)\n", res, GetLastError());
+    ok_(__FILE__,line)(!written_bytes, "written_bytes = %lu\n", written_bytes);
 
     _test_not_signaled(line, overlapped->hEvent);
 }
@@ -2847,7 +2847,7 @@ static void _test_flush_sync(unsigned line, HANDLE pipe)
     BOOL res;
 
     res = FlushFileBuffers(pipe);
-    ok_(__FILE__,line)(res, "FlushFileBuffers failed: %u\n", GetLastError());
+    ok_(__FILE__,line)(res, "FlushFileBuffers failed: %lu\n", GetLastError());
 }
 
 static DWORD expected_flush_error;
@@ -2859,13 +2859,13 @@ static DWORD CALLBACK flush_proc(HANDLE pipe)
     res = FlushFileBuffers(pipe);
     if (expected_flush_error == ERROR_SUCCESS)
     {
-        ok(res, "FlushFileBuffers failed: %u\n", GetLastError());
+        ok(res, "FlushFileBuffers failed: %lu\n", GetLastError());
     }
     else
     {
         ok(!res, "FlushFileBuffers should have failed\n");
         ok(GetLastError() == expected_flush_error,
-           "FlushFileBuffers set error %u, expected %u\n", GetLastError(), expected_flush_error);
+           "FlushFileBuffers set error %lu, expected %lu\n", GetLastError(), expected_flush_error);
     }
     return 0;
 }
@@ -2878,7 +2878,7 @@ static HANDLE _test_flush_async(unsigned line, HANDLE pipe, DWORD error)
 
     expected_flush_error = error;
     thread = CreateThread(NULL, 0, flush_proc, pipe, 0, &tid);
-    ok_(__FILE__,line)(thread != NULL, "CreateThread failed: %u\n", GetLastError());
+    ok_(__FILE__,line)(thread != NULL, "CreateThread failed: %lu\n", GetLastError());
 
     Sleep(50);
     _test_not_signaled(line, thread);
@@ -2889,7 +2889,7 @@ static HANDLE _test_flush_async(unsigned line, HANDLE pipe, DWORD error)
 static void _test_flush_done(unsigned line, HANDLE thread)
 {
     DWORD res = WaitForSingleObject(thread, 1000);
-    ok_(__FILE__,line)(res == WAIT_OBJECT_0, "WaitForSingleObject returned %u (%u)\n", res, GetLastError());
+    ok_(__FILE__,line)(res == WAIT_OBJECT_0, "WaitForSingleObject returned %lu (%lu)\n", res, GetLastError());
     CloseHandle(thread);
 }
 
@@ -2903,10 +2903,10 @@ static void _test_overlapped_result(unsigned line, HANDLE handle, OVERLAPPED *ov
 
     res = GetOverlappedResult(handle, overlapped, &result, FALSE);
     if (partial_read)
-        ok_(__FILE__,line)(!res && GetLastError() == ERROR_MORE_DATA, "GetOverlappedResult returned: %x (%u)\n", res, GetLastError());
+        ok_(__FILE__,line)(!res && GetLastError() == ERROR_MORE_DATA, "GetOverlappedResult returned: %x (%lu)\n", res, GetLastError());
     else
-        ok_(__FILE__,line)(res, "GetOverlappedResult failed: %u\n", GetLastError());
-    ok_(__FILE__,line)(result == expected_result, "read_bytes = %u, expected %u\n", result, expected_result);
+        ok_(__FILE__,line)(res, "GetOverlappedResult failed: %lu\n", GetLastError());
+    ok_(__FILE__,line)(result == expected_result, "read_bytes = %lu, expected %lu\n", result, expected_result);
     CloseHandle(overlapped->hEvent);
 }
 
@@ -2919,9 +2919,9 @@ static void _test_overlapped_failure(unsigned line, HANDLE handle, OVERLAPPED *o
     _test_signaled(line, overlapped->hEvent);
 
     res = GetOverlappedResult(handle, overlapped, &result, FALSE);
-    ok_(__FILE__,line)(!res && GetLastError() == error, "GetOverlappedResult returned: %x (%u), expected error %u\n",
+    ok_(__FILE__,line)(!res && GetLastError() == error, "GetOverlappedResult returned: %x (%lu), expected error %lu\n",
                        res, GetLastError(), error);
-    ok_(__FILE__,line)(!result, "result = %u\n", result);
+    ok_(__FILE__,line)(!result, "result = %lu\n", result);
     CloseHandle(overlapped->hEvent);
 }
 
@@ -2931,7 +2931,7 @@ static void _cancel_overlapped(unsigned line, HANDLE handle, OVERLAPPED *overlap
     BOOL res;
 
     res = pCancelIoEx(handle, overlapped);
-    ok_(__FILE__,line)(res, "CancelIoEx failed: %u\n", GetLastError());
+    ok_(__FILE__,line)(res, "CancelIoEx failed: %lu\n", GetLastError());
 
     _test_overlapped_failure(line, handle, overlapped, ERROR_OPERATION_ABORTED);
 }
@@ -3079,11 +3079,11 @@ static void test_blocking_rw(HANDLE writer, HANDLE reader, DWORD buf_size, BOOL
     SetLastError(0xdeadbeef);
     overlapped_read_async(reader, read_buf, 1, &read_overlapped2);
     res = pCancelIoEx(reader, &read_overlapped2);
-    ok(res, "CancelIoEx failed with error %d\n", GetLastError());
+    ok(res, "CancelIoEx failed with error %ld\n", GetLastError());
     res = pCancelIoEx(reader, &read_overlapped2);
     ok(!res, "CancelIOEx succeeded unexpectedly\n");
     ok(GetLastError() == ERROR_NOT_FOUND,
-        "In CancelIoEx failure, expected ERROR_NOT_FOUND, got %d\n", GetLastError());
+        "In CancelIoEx failure, expected ERROR_NOT_FOUND, got %ld\n", GetLastError());
     test_overlapped_failure(reader, &read_overlapped2, ERROR_OPERATION_ABORTED);
 
     /* make two async writes, cancel the first one and make sure that we read from the second one */
@@ -3129,7 +3129,7 @@ static void _overlapped_transact(unsigned line, HANDLE caller, void *write_buf,
     overlapped->hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
     res = TransactNamedPipe(caller, write_buf, write_size, read_buf, read_size, NULL, overlapped);
     ok_(__FILE__,line)(!res && GetLastError() == ERROR_IO_PENDING,
-       "TransactNamedPipe returned: %x(%u)\n", res, GetLastError());
+       "TransactNamedPipe returned: %x(%lu)\n", res, GetLastError());
 }
 
 #define overlapped_transact_failure(a,b,c,d,e,f) _overlapped_transact_failure(__LINE__,a,b,c,d,e,f)
@@ -3151,7 +3151,7 @@ static void _overlapped_transact_failure(unsigned line, HANDLE caller, void *wri
     else
     {
         ok_(__FILE__,line)(GetLastError() == expected_error,
-                           "TransactNamedPipe returned error %u, expected %u\n",
+                           "TransactNamedPipe returned error %lu, expected %lu\n",
                            GetLastError(), expected_error);
         CloseHandle(overlapped.hEvent);
     }
@@ -3177,9 +3177,9 @@ static HANDLE create_writepipe_process(HANDLE pipe)
     BOOL res;
 
     winetest_get_mainargs(&argv);
-    sprintf(buf, "\"%s\" pipe writepipe %lx", argv[0], (UINT_PTR)pipe);
+    sprintf(buf, "\"%s\" pipe writepipe %Ix", argv[0], (UINT_PTR)pipe);
     res = CreateProcessA(NULL, buf, NULL, NULL, TRUE, 0L, NULL, NULL, &si, &info);
-    ok(res, "CreateProcess failed: %u\n", GetLastError());
+    ok(res, "CreateProcess failed: %lu\n", GetLastError());
     CloseHandle(info.hThread);
 
     return info.hProcess;
@@ -3194,21 +3194,21 @@ static void create_overlapped_pipe(DWORD mode, HANDLE *client, HANDLE *server)
 
     *server = CreateNamedPipeA(PIPENAME, FILE_FLAG_OVERLAPPED | PIPE_ACCESS_DUPLEX,
                                PIPE_WAIT | mode, 1, 5000, 6000, NMPWAIT_USE_DEFAULT_WAIT, NULL);
-    ok(*server != INVALID_HANDLE_VALUE, "CreateNamedPipe failed: %u\n", GetLastError());
+    ok(*server != INVALID_HANDLE_VALUE, "CreateNamedPipe failed: %lu\n", GetLastError());
     test_signaled(*server);
 
     memset(&overlapped, 0, sizeof(overlapped));
     overlapped.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
     res = ConnectNamedPipe(*server, &overlapped);
-    ok(!res && GetLastError() == ERROR_IO_PENDING, "WriteFile returned %x(%u)\n", res, GetLastError());
+    ok(!res && GetLastError() == ERROR_IO_PENDING, "WriteFile returned %x(%lu)\n", res, GetLastError());
     test_not_signaled(*server);
     test_not_signaled(overlapped.hEvent);
 
     *client = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, &sec_attr, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
-    ok(*client != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
+    ok(*client != INVALID_HANDLE_VALUE, "CreateFile failed: %lu\n", GetLastError());
 
     res = SetNamedPipeHandleState(*client, &read_mode, NULL, NULL);
-    ok(res, "SetNamedPipeHandleState failed: %u\n", GetLastError());
+    ok(res, "SetNamedPipeHandleState failed: %lu\n", GetLastError());
 
     test_signaled(*client);
     test_not_signaled(*server);
@@ -3265,7 +3265,7 @@ static void test_overlapped_transport(BOOL msg_mode, BOOL msg_read_mode)
     overlapped_write_async(server, buf, 7000, &overlapped2);
     flush = test_flush_async(client, ERROR_PIPE_NOT_CONNECTED);
     res = DisconnectNamedPipe(server);
-    ok(res, "DisconnectNamedPipe failed: %u\n", GetLastError());
+    ok(res, "DisconnectNamedPipe failed: %lu\n", GetLastError());
     test_overlapped_failure(client, &overlapped, ERROR_PIPE_NOT_CONNECTED);
     test_overlapped_failure(client, &overlapped2, ERROR_PIPE_NOT_CONNECTED);
     test_flush_done(flush);
@@ -3278,10 +3278,10 @@ static void test_overlapped_transport(BOOL msg_mode, BOOL msg_read_mode)
     /* successfully read part of write that is pending in child process */
     res = ReadFile(server, buf, 10, &read_bytes, NULL);
     if(!msg_read_mode)
-        ok(res, "ReadFile failed: %u\n", GetLastError());
+        ok(res, "ReadFile failed: %lu\n", GetLastError());
     else
-        ok(!res && GetLastError() == ERROR_MORE_DATA, "ReadFile returned: %x %u\n", res, GetLastError());
-    ok(read_bytes == 10, "read_bytes = %u\n", read_bytes);
+        ok(!res && GetLastError() == ERROR_MORE_DATA, "ReadFile returned: %x %lu\n", res, GetLastError());
+    ok(read_bytes == 10, "read_bytes = %lu\n", read_bytes);
     TerminateProcess(process, 0);
     wait_child_process(process);
     /* after terminating process, there is no pending write and pipe buffer is empty */
@@ -3399,9 +3399,9 @@ static HANDLE create_overlapped_server( OVERLAPPED *overlapped )
 
     pipe = CreateNamedPipeA(PIPENAME, FILE_FLAG_OVERLAPPED | PIPE_ACCESS_DUPLEX, PIPE_READMODE_BYTE | PIPE_WAIT,
                             1, 5000, 6000, NMPWAIT_USE_DEFAULT_WAIT, NULL);
-    ok(pipe != INVALID_HANDLE_VALUE, "got %u\n", GetLastError());
+    ok(pipe != INVALID_HANDLE_VALUE, "got %lu\n", GetLastError());
     ret = ConnectNamedPipe(pipe, overlapped);
-    ok(!ret && GetLastError() == ERROR_IO_PENDING, "got %u\n", GetLastError());
+    ok(!ret && GetLastError() == ERROR_IO_PENDING, "got %lu\n", GetLastError());
     return pipe;
 }
 
@@ -3413,17 +3413,17 @@ static void child_process_check_pid(DWORD server_pid)
     BOOL ret;
 
     pipe = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
-    ok(pipe != INVALID_HANDLE_VALUE, "got %u\n", GetLastError());
+    ok(pipe != INVALID_HANDLE_VALUE, "got %lu\n", GetLastError());
 
     pid = 0;
     ret = pGetNamedPipeClientProcessId(pipe, &pid);
-    ok(ret, "got %u\n", GetLastError());
-    ok(pid == current, "got %04x\n", pid);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(pid == current, "got %04lx\n", pid);
 
     pid = 0;
     ret = pGetNamedPipeServerProcessId(pipe, &pid);
-    ok(ret, "got %u\n", GetLastError());
-    ok(pid == server_pid, "got %04x expected %04x\n", pid, server_pid);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(pid == server_pid, "got %04lx expected %04lx\n", pid, server_pid);
     CloseHandle(pipe);
 }
 
@@ -3435,9 +3435,9 @@ static HANDLE create_check_id_process(const char *verb, DWORD id)
     BOOL ret;
 
     winetest_get_mainargs(&argv);
-    sprintf(buf, "\"%s\" pipe %s %x", argv[0], verb, id);
+    sprintf(buf, "\"%s\" pipe %s %lx", argv[0], verb, id);
     ret = CreateProcessA(NULL, buf, NULL, NULL, TRUE, 0, NULL, NULL, &si, &info);
-    ok(ret, "got %u\n", GetLastError());
+    ok(ret, "got %lu\n", GetLastError());
     CloseHandle(info.hThread);
     return info.hProcess;
 }
@@ -3461,44 +3461,44 @@ static void test_namedpipe_process_id(void)
     SetLastError(0xdeadbeef);
     ret = pGetNamedPipeClientProcessId(server, NULL);
     ok(!ret, "success\n");
-    todo_wine ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %lu\n", GetLastError());
 
     pid = 0;
     ret = pGetNamedPipeClientProcessId(server, &pid);
-    ok(ret, "got %u\n", GetLastError());
-    ok(pid == current, "got %04x expected %04x\n", pid, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(pid == current, "got %04lx expected %04lx\n", pid, current);
 
     pid = 0;
     ret = pGetNamedPipeClientProcessId(client, &pid);
-    ok(ret, "got %u\n", GetLastError());
-    ok(pid == current, "got %04x expected %04x\n", pid, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(pid == current, "got %04lx expected %04lx\n", pid, current);
 
     SetLastError(0xdeadbeef);
     ret = pGetNamedPipeServerProcessId(server, NULL);
     ok(!ret, "success\n");
-    todo_wine ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %lu\n", GetLastError());
 
     pid = 0;
     ret = pGetNamedPipeServerProcessId(client, &pid);
-    ok(ret, "got %u\n", GetLastError());
-    ok(pid == current, "got %04x expected %04x\n", pid, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(pid == current, "got %04lx expected %04lx\n", pid, current);
 
     pid = 0;
     ret = pGetNamedPipeServerProcessId(server, &pid);
-    ok(ret, "got %u\n", GetLastError());
-    ok(pid == current, "got %04x expected %04x\n", pid, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(pid == current, "got %04lx expected %04lx\n", pid, current);
 
     /* closed client handle */
     CloseHandle(client);
     pid = 0;
     ret = pGetNamedPipeClientProcessId(server, &pid);
-    ok(ret, "got %u\n", GetLastError());
-    ok(pid == current, "got %04x expected %04x\n", pid, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(pid == current, "got %04lx expected %04lx\n", pid, current);
 
     pid = 0;
     ret = pGetNamedPipeServerProcessId(server, &pid);
-    ok(ret, "got %u\n", GetLastError());
-    ok(pid == current, "got %04x expected %04x\n", pid, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(pid == current, "got %04lx expected %04lx\n", pid, current);
     CloseHandle(server);
 
     /* disconnected server */
@@ -3508,22 +3508,22 @@ static void test_namedpipe_process_id(void)
     SetLastError(0xdeadbeef);
     ret = pGetNamedPipeClientProcessId(server, &pid);
     todo_wine ok(!ret, "success\n");
-    todo_wine ok(GetLastError() == ERROR_NOT_FOUND, "got %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_NOT_FOUND, "got %lu\n", GetLastError());
 
     pid = 0;
     ret = pGetNamedPipeServerProcessId(server, &pid);
-    ok(ret, "got %u\n", GetLastError());
-    ok(pid == current, "got %04x expected %04x\n", pid, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(pid == current, "got %04lx expected %04lx\n", pid, current);
 
     SetLastError(0xdeadbeef);
     ret = pGetNamedPipeClientProcessId(client, &pid);
     todo_wine ok(!ret, "success\n");
-    todo_wine ok(GetLastError() == ERROR_PIPE_NOT_CONNECTED, "got %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_PIPE_NOT_CONNECTED, "got %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetNamedPipeServerProcessId(client, &pid);
     todo_wine ok(!ret, "success\n");
-    todo_wine ok(GetLastError() == ERROR_PIPE_NOT_CONNECTED, "got %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_PIPE_NOT_CONNECTED, "got %lu\n", GetLastError());
     CloseHandle(client);
     CloseHandle(server);
 
@@ -3533,20 +3533,20 @@ static void test_namedpipe_process_id(void)
 
     pid = 0;
     ret = pGetNamedPipeClientProcessId(client, &pid);
-    ok(ret, "got %u\n", GetLastError());
-    ok(pid == current, "got %04x expected %04x\n", pid, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(pid == current, "got %04lx expected %04lx\n", pid, current);
 
     pid = 0;
     ret = pGetNamedPipeServerProcessId(client, &pid);
-    ok(ret, "got %u\n", GetLastError());
-    ok(pid == current, "got %04x expected %04x\n", pid, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(pid == current, "got %04lx expected %04lx\n", pid, current);
     CloseHandle(client);
 
     /* different process */
     memset(&overlapped, 0, sizeof(overlapped));
     overlapped.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
     server = create_overlapped_server( &overlapped );
-    ok(server != INVALID_HANDLE_VALUE, "got %u\n", GetLastError());
+    ok(server != INVALID_HANDLE_VALUE, "got %lu\n", GetLastError());
 
     process = create_check_id_process("checkpid", GetProcessId(GetCurrentProcess()));
     wait_child_process(process);
@@ -3566,17 +3566,17 @@ static void child_process_check_session_id(DWORD server_id)
     ProcessIdToSessionId(GetProcessId(GetCurrentProcess()), &current);
 
     pipe = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
-    ok(pipe != INVALID_HANDLE_VALUE, "got %u\n", GetLastError());
+    ok(pipe != INVALID_HANDLE_VALUE, "got %lu\n", GetLastError());
 
     id = 0;
     ret = pGetNamedPipeClientSessionId(pipe, &id);
-    ok(ret, "got %u\n", GetLastError());
-    ok(id == current, "got %04x\n", id);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(id == current, "got %04lx\n", id);
 
     id = 0;
     ret = pGetNamedPipeServerSessionId(pipe, &id);
-    ok(ret, "got %u\n", GetLastError());
-    ok(id == server_id, "got %04x expected %04x\n", id, server_id);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(id == server_id, "got %04lx expected %04lx\n", id, server_id);
     CloseHandle(pipe);
 }
 
@@ -3607,41 +3607,41 @@ static void test_namedpipe_session_id(void)
 
     id = 0;
     ret = pGetNamedPipeClientSessionId(server, &id);
-    ok(ret, "got %u\n", GetLastError());
-    ok(id == current, "got %u expected %u\n", id, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(id == current, "got %lu expected %lu\n", id, current);
 
     id = 0;
     ret = pGetNamedPipeClientSessionId(client, &id);
-    ok(ret, "got %u\n", GetLastError());
-    ok(id == current, "got %u expected %u\n", id, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(id == current, "got %lu expected %lu\n", id, current);
 
     SetLastError(0xdeadbeef);
     ret = pGetNamedPipeServerSessionId(server, NULL);
     ok(!ret, "success\n");
-    todo_wine ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %lu\n", GetLastError());
 
     id = 0;
     ret = pGetNamedPipeServerSessionId(client, &id);
-    ok(ret, "got %u\n", GetLastError());
-    ok(id == current, "got %u expected %u\n", id, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(id == current, "got %lu expected %lu\n", id, current);
 
     id = 0;
     ret = pGetNamedPipeServerSessionId(server, &id);
-    ok(ret, "got %u\n", GetLastError());
-    ok(id == current, "got %u expected %u\n", id, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(id == current, "got %lu expected %lu\n", id, current);
 
     /* closed client handle */
     CloseHandle(client);
 
     id = 0;
     ret = pGetNamedPipeClientSessionId(server, &id);
-    ok(ret, "got %u\n", GetLastError());
-    ok(id == current, "got %04x expected %04x\n", id, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(id == current, "got %04lx expected %04lx\n", id, current);
 
     id = 0;
     ret = pGetNamedPipeServerSessionId(server, &id);
-    ok(ret, "got %u\n", GetLastError());
-    ok(id == current, "got %04x expected %04x\n", id, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(id == current, "got %04lx expected %04lx\n", id, current);
     CloseHandle(server);
 
     /* disconnected server */
@@ -3651,22 +3651,22 @@ static void test_namedpipe_session_id(void)
     SetLastError(0xdeadbeef);
     ret = pGetNamedPipeClientSessionId(server, &id);
     todo_wine ok(!ret, "success\n");
-    todo_wine ok(GetLastError() == ERROR_NOT_FOUND, "got %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_NOT_FOUND, "got %lu\n", GetLastError());
 
     id = 0;
     ret = pGetNamedPipeServerSessionId(server, &id);
-    ok(ret, "got %u\n", GetLastError());
-    ok(id == current, "got %04x expected %04x\n", id, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(id == current, "got %04lx expected %04lx\n", id, current);
 
     SetLastError(0xdeadbeef);
     ret = pGetNamedPipeClientSessionId(client, &id);
     todo_wine ok(!ret, "success\n");
-    todo_wine ok(GetLastError() == ERROR_PIPE_NOT_CONNECTED, "got %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_PIPE_NOT_CONNECTED, "got %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetNamedPipeServerSessionId(client, &id);
     todo_wine ok(!ret, "success\n");
-    todo_wine ok(GetLastError() == ERROR_PIPE_NOT_CONNECTED, "got %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_PIPE_NOT_CONNECTED, "got %lu\n", GetLastError());
     CloseHandle(client);
     CloseHandle(server);
 
@@ -3676,20 +3676,20 @@ static void test_namedpipe_session_id(void)
 
     id = 0;
     ret = pGetNamedPipeClientSessionId(client, &id);
-    ok(ret, "got %u\n", GetLastError());
-    ok(id == current, "got %04x expected %04x\n", id, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(id == current, "got %04lx expected %04lx\n", id, current);
 
     id = 0;
     ret = pGetNamedPipeServerSessionId(client, &id);
-    ok(ret, "got %u\n", GetLastError());
-    ok(id == current, "got %04x expected %04x\n", id, current);
+    ok(ret, "got %lu\n", GetLastError());
+    ok(id == current, "got %04lx expected %04lx\n", id, current);
     CloseHandle(client);
 
     /* different process */
     memset(&overlapped, 0, sizeof(overlapped));
     overlapped.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
     server = create_overlapped_server( &overlapped );
-    ok(server != INVALID_HANDLE_VALUE, "got %u\n", GetLastError());
+    ok(server != INVALID_HANDLE_VALUE, "got %lu\n", GetLastError());
 
     process = create_check_id_process("checksessionid", current);
     wait_child_process(process);
@@ -3728,12 +3728,12 @@ static void test_multiple_instances(void)
     memset(&ov, 0, sizeof(ov));
     ret = ConnectNamedPipe(server[2], &ov);
     ok(ret == FALSE, "got %d\n", ret);
-    ok(GetLastError() == ERROR_IO_PENDING, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_IO_PENDING, "got %ld\n", GetLastError());
 
     memset(&ov, 0, sizeof(ov));
     ret = ConnectNamedPipe(server[0], &ov);
     ok(ret == FALSE, "got %d\n", ret);
-    ok(GetLastError() == ERROR_PIPE_CONNECTED, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_PIPE_CONNECTED, "got %ld\n", GetLastError());
 
     CloseHandle(client);
 
@@ -3745,12 +3745,12 @@ static void test_multiple_instances(void)
     memset(&ov, 0, sizeof(ov));
     ret = ConnectNamedPipe(server[2], &ov);
     ok(ret == FALSE, "got %d\n", ret);
-    ok(GetLastError() == ERROR_IO_PENDING, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_IO_PENDING, "got %ld\n", GetLastError());
 
     memset(&ov, 0, sizeof(ov));
     ret = ConnectNamedPipe(server[1], &ov);
     ok(ret == FALSE, "got %d\n", ret);
-    ok(GetLastError() == ERROR_PIPE_CONNECTED, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_PIPE_CONNECTED, "got %ld\n", GetLastError());
 
     CloseHandle(client);
 
@@ -3762,7 +3762,7 @@ static void test_multiple_instances(void)
     memset(&ov, 0, sizeof(ov));
     ret = ConnectNamedPipe(server[2], &ov);
     ok(ret == FALSE, "got %d\n", ret);
-    ok(GetLastError() == ERROR_PIPE_CONNECTED, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_PIPE_CONNECTED, "got %ld\n", GetLastError());
 
     CloseHandle(client);
 
@@ -3776,12 +3776,12 @@ static void test_multiple_instances(void)
     memset(&ov, 0, sizeof(ov));
     ret = ConnectNamedPipe(server[2], &ov);
     ok(ret == FALSE, "got %d\n", ret);
-    ok(GetLastError() == ERROR_IO_PENDING, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_IO_PENDING, "got %ld\n", GetLastError());
 
     memset(&ov, 0, sizeof(ov));
     ret = ConnectNamedPipe(server[0], &ov);
     ok(ret == FALSE, "got %d\n", ret);
-    ok(GetLastError() == ERROR_IO_PENDING, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_IO_PENDING, "got %ld\n", GetLastError());
 
     /* server[3] is connected next */
 
@@ -3791,7 +3791,7 @@ static void test_multiple_instances(void)
     memset(&ov, 0, sizeof(ov));
     ret = ConnectNamedPipe(server[3], &ov);
     ok(ret == FALSE, "got %d\n", ret);
-    ok(GetLastError() == ERROR_PIPE_CONNECTED, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_PIPE_CONNECTED, "got %ld\n", GetLastError());
 
     CloseHandle(client);
 
@@ -3803,12 +3803,12 @@ static void test_multiple_instances(void)
     memset(&ov, 0, sizeof(ov));
     ret = ConnectNamedPipe(server[2], &ov);
     ok(ret == FALSE, "got %d\n", ret);
-    ok(GetLastError() == ERROR_PIPE_CONNECTED, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_PIPE_CONNECTED, "got %ld\n", GetLastError());
 
     memset(&ov, 0, sizeof(ov));
     ret = ConnectNamedPipe(server[0], &ov);
     ok(ret == FALSE, "got %d\n", ret);
-    ok(GetLastError() == ERROR_IO_PENDING, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_IO_PENDING, "got %ld\n", GetLastError());
 
     CloseHandle(client);
 
@@ -3820,14 +3820,14 @@ static void test_multiple_instances(void)
     memset(&ov, 0, sizeof(ov));
     ret = ConnectNamedPipe(server[0], &ov);
     ok(ret == FALSE, "got %d\n", ret);
-    ok(GetLastError() == ERROR_PIPE_CONNECTED, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_PIPE_CONNECTED, "got %ld\n", GetLastError());
 
     CloseHandle(client);
 
     /* No more listening pipes available */
     DisconnectNamedPipe(server[0]);
     client = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
-    ok(client == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PIPE_BUSY, "got %p(%u)\n", client, GetLastError());
+    ok(client == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PIPE_BUSY, "got %p(%lu)\n", client, GetLastError());
 
     for (i = 0; i < ARRAY_SIZE(server); i++)
     {
@@ -3840,7 +3840,7 @@ static DWORD WINAPI wait_pipe_proc(void *arg)
 {
     BOOL ret;
     ret = WaitNamedPipeA(PIPENAME, 1000);
-    ok(ret, "WaitNamedPipe failed (%u)\n", GetLastError());
+    ok(ret, "WaitNamedPipe failed (%lu)\n", GetLastError());
     return 0;
 }
 
@@ -3850,10 +3850,10 @@ static HANDLE async_wait_pipe(void)
     BOOL ret;
 
     thread = CreateThread(NULL, 0, wait_pipe_proc, NULL, 0, NULL);
-    ok(thread != NULL, "CreateThread failed: %u\n", GetLastError());
+    ok(thread != NULL, "CreateThread failed: %lu\n", GetLastError());
 
     ret = WaitNamedPipeA(PIPENAME, 1);
-    ok(!ret && GetLastError() == ERROR_SEM_TIMEOUT, "WaitNamedPipe failed %x(%u)\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_SEM_TIMEOUT, "WaitNamedPipe failed %x(%lu)\n", ret, GetLastError());
 
     return thread;
 }
@@ -3866,7 +3866,7 @@ static void test_wait_pipe(void)
     BOOL ret;
 
     ret = WaitNamedPipeA(PIPENAME, 0);
-    ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "WaitNamedPipe failed %x(%u)\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "WaitNamedPipe failed %x(%lu)\n", ret, GetLastError());
 
     server[0] = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
                                  PIPE_READMODE_BYTE | PIPE_WAIT, ARRAY_SIZE(server), 1024, 1024,
@@ -3874,7 +3874,7 @@ static void test_wait_pipe(void)
     ok(server[0] != INVALID_HANDLE_VALUE, "got invalid handle\n");
 
     ret = WaitNamedPipeA(PIPENAME, 1);
-    ok(ret, "WaitNamedPipe failed (%u)\n", GetLastError());
+    ok(ret, "WaitNamedPipe failed (%lu)\n", GetLastError());
 
     client = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
     ok(client != INVALID_HANDLE_VALUE, "got invalid handle\n");
@@ -3887,14 +3887,14 @@ static void test_wait_pipe(void)
     ok(server[1] != INVALID_HANDLE_VALUE, "got invalid handle\n");
 
     res = WaitForSingleObject(wait, 100);
-    ok(res == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", res);
+    ok(res == WAIT_OBJECT_0, "WaitForSingleObject returned %lu\n", res);
 
     CloseHandle(wait);
     CloseHandle(server[1]);
 
     CloseHandle(client);
     ret = DisconnectNamedPipe(server[0]);
-    ok(ret, "DisconnectNamedPipe failed (%u)\n", GetLastError());
+    ok(ret, "DisconnectNamedPipe failed (%lu)\n", GetLastError());
 
     /* Putting pipe server into waiting listening state wakes waiters */
     wait = async_wait_pipe();
@@ -3902,14 +3902,14 @@ static void test_wait_pipe(void)
     ov.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
     ret = ConnectNamedPipe(server[0], &ov);
     ok(ret == FALSE, "got %d\n", ret);
-    ok(GetLastError() == ERROR_IO_PENDING, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_IO_PENDING, "got %ld\n", GetLastError());
 
     res = WaitForSingleObject(wait, 100);
-    ok(res == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", res);
+    ok(res == WAIT_OBJECT_0, "WaitForSingleObject returned %lu\n", res);
     CloseHandle(server[0]);
 
     res = WaitForSingleObject(ov.hEvent, 0);
-    ok(res == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", res);
+    ok(res == WAIT_OBJECT_0, "WaitForSingleObject returned %lu\n", res);
     CloseHandle(ov.hEvent);
 }
 
@@ -3936,7 +3936,7 @@ static void test_nowait(DWORD pipe_type)
     ol.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
     SetLastError(0xdeadbeef);
     ok(ReadFile(piperead, readbuf, sizeof(readbuf), &read, &ol) == FALSE, "ReadFile should fail\n");
-    ok(GetLastError() == ERROR_NO_DATA, "got %d should be ERROR_NO_DATA\n", GetLastError());
+    ok(GetLastError() == ERROR_NO_DATA, "got %ld should be ERROR_NO_DATA\n", GetLastError());
     if (GetLastError() == ERROR_IO_PENDING)
         CancelIo(piperead);
 
@@ -3979,63 +3979,63 @@ static void test_nowait(DWORD pipe_type)
     /* overlapped read of 32768, non-blocking write of 512 */
     SetLastError(0xdeadbeef);
     ok(ReadFile(piperead, readbuf, sizeof(readbuf), &read, &ol2) == FALSE, "ReadFile should fail\n");
-    ok(GetLastError() == ERROR_IO_PENDING, "got %d should be ERROR_IO_PENDING\n", GetLastError());
+    ok(GetLastError() == ERROR_IO_PENDING, "got %ld should be ERROR_IO_PENDING\n", GetLastError());
     ok(WriteFile(pipewrite, teststring, sizeof(teststring), &write, &ol), "WriteFile should succeed\n");
-    ok(write == sizeof(teststring), "got %d\n", write);
+    ok(write == sizeof(teststring), "got %ld\n", write);
     ok(GetOverlappedResult(piperead, &ol2, &read, FALSE), "GetOverlappedResult should succeed\n");
-    ok(read == sizeof(teststring), "got %d\n", read);
+    ok(read == sizeof(teststring), "got %ld\n", read);
     if (GetOverlappedResult(piperead, &ol2, &read, FALSE) == FALSE)
         CancelIo(piperead);
 
     /* overlapped read of 32768, non-blocking write of 513 */
     SetLastError(0xdeadbeef);
     ok(ReadFile(piperead, readbuf, sizeof(readbuf), &read, &ol2) == FALSE, "ReadFile should fail\n");
-    ok(GetLastError() == ERROR_IO_PENDING, "got %d should be ERROR_IO_PENDING\n", GetLastError());
+    ok(GetLastError() == ERROR_IO_PENDING, "got %ld should be ERROR_IO_PENDING\n", GetLastError());
     ok(WriteFile(pipewrite, readbuf, 513, &write, &ol), "WriteFile should succeed\n");
-    ok(write == 513, "got %d, write should be %d\n", write, 513);
+    ok(write == 513, "got %ld, write should be %d\n", write, 513);
     ok(GetOverlappedResult(piperead, &ol2, &read, FALSE), "GetOverlappedResult should succeed\n");
-    ok(read == 513, "got %d, read should be %d\n", read, 513);
+    ok(read == 513, "got %ld, read should be %d\n", read, 513);
     if (GetOverlappedResult(piperead, &ol2, &read, FALSE) == FALSE)
         CancelIo(piperead);
 
     /* overlapped read of 1 byte, non-blocking write of 513 bytes */
     SetLastError(0xdeadbeef);
     ok(ReadFile(piperead, readbuf, 1, &read, &ol2) == FALSE, "ReadFile should fail\n");
-    ok(GetLastError() == ERROR_IO_PENDING, "got %d should be ERROR_IO_PENDING\n", GetLastError());
+    ok(GetLastError() == ERROR_IO_PENDING, "got %ld should be ERROR_IO_PENDING\n", GetLastError());
     ok(WriteFile(pipewrite, readbuf, 513, &write, &ol), "WriteFile should succeed\n");
-    ok(write == 513, "got %d, write should be %d\n", write, 513);
+    ok(write == 513, "got %ld, write should be %d\n", write, 513);
     ok(GetOverlappedResult(piperead, &ol2, &read, FALSE), "GetOverlappedResult should succeed\n");
-    ok(read == 1, "got %d, read should be %d\n", read, 1);
+    ok(read == 1, "got %ld, read should be %d\n", read, 1);
     if (GetOverlappedResult(piperead, &ol2, &read, FALSE) == FALSE)
         CancelIo(piperead);
     /* read the remaining 512 bytes */
     SetLastError(0xdeadbeef);
     ok(ReadFile(piperead, readbuf, sizeof(readbuf), &read, &ol2), "ReadFile should succeed\n");
-    ok(read == 512, "got %d, write should be %d\n", write, 512);
+    ok(read == 512, "got %ld, write should be %d\n", write, 512);
     if (GetOverlappedResult(piperead, &ol2, &read, FALSE) == FALSE)
         CancelIo(piperead);
 
     /* overlapped read of 1 byte, non-blocking write of 514 bytes */
     SetLastError(0xdeadbeef);
     ok(ReadFile(piperead, readbuf, 1, &read, &ol2) == FALSE, "ReadFile should fail\n");
-    ok(GetLastError() == ERROR_IO_PENDING, "got %d should be ERROR_IO_PENDING\n", GetLastError());
+    ok(GetLastError() == ERROR_IO_PENDING, "got %ld should be ERROR_IO_PENDING\n", GetLastError());
     ok(WriteFile(pipewrite, readbuf, 514, &write, &ol), "WriteFile should succeed\n");
     if (pipe_type == PIPE_TYPE_MESSAGE)
     {
         todo_wine
-        ok(write == 0, "got %d\n", write);
+        ok(write == 0, "got %ld\n", write);
         todo_wine
         ok(!GetOverlappedResult(piperead, &ol2, &read, FALSE), "GetOverlappedResult should fail\n");
         todo_wine
-        ok(GetLastError() == ERROR_IO_INCOMPLETE, "got %d should be ERROR_IO_PENDING\n", GetLastError());
+        ok(GetLastError() == ERROR_IO_INCOMPLETE, "got %ld should be ERROR_IO_PENDING\n", GetLastError());
         todo_wine
-        ok(read == 0, "got %d, read should be %d\n", read, 1);
+        ok(read == 0, "got %ld, read should be %d\n", read, 1);
     }
     else
     {
-        ok(write == 1, "got %d\n", write);
+        ok(write == 1, "got %ld\n", write);
         ok(GetOverlappedResult(piperead, &ol2, &read, FALSE), "GetOverlappedResult should fail\n");
-        ok(read == 1, "got %d, read should be %d\n", read, 1);
+        ok(read == 1, "got %ld, read should be %d\n", read, 1);
     }
     if (GetOverlappedResult(piperead, &ol2, &read, FALSE) == FALSE)
         CancelIo(piperead);
@@ -4066,7 +4066,7 @@ static void test_nowait(DWORD pipe_type)
     ol.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
     SetLastError(0xdeadbeef);
     ok(ConnectNamedPipe(pipewrite, &ol) == FALSE, "ConnectNamedPipe should fail\n");
-    ok(GetLastError() == ERROR_PIPE_LISTENING, "got %d should be ERROR_PIPE_LISTENING\n", GetLastError());
+    ok(GetLastError() == ERROR_PIPE_LISTENING, "got %ld should be ERROR_PIPE_LISTENING\n", GetLastError());
     if (GetLastError() == ERROR_IO_PENDING)
         CancelIo(pipewrite);
 
@@ -4076,7 +4076,7 @@ static void test_nowait(DWORD pipe_type)
     ok(CloseHandle(file), "CloseHandle failed\n");
     SetLastError(0xdeadbeef);
     ok(ConnectNamedPipe(pipewrite,&ol) == FALSE, "ConnectNamedPipe should fail\n");
-    ok(GetLastError() == ERROR_NO_DATA, "got %d should be ERROR_NO_DATA\n", GetLastError());
+    ok(GetLastError() == ERROR_NO_DATA, "got %ld should be ERROR_NO_DATA\n", GetLastError());
     if (GetLastError() == ERROR_IO_PENDING)
         CancelIo(pipewrite);
 
@@ -4084,7 +4084,7 @@ static void test_nowait(DWORD pipe_type)
     ok(DisconnectNamedPipe(pipewrite) == TRUE, "DisconnectNamedPipe should succeed\n");
     SetLastError(0xdeadbeef);
     ok(ConnectNamedPipe(pipewrite,&ol) == FALSE, "ConnectNamedPipe should fail\n");
-    ok(GetLastError() == ERROR_PIPE_LISTENING, "got %d should be ERROR_PIPE_LISTENING\n", GetLastError());
+    ok(GetLastError() == ERROR_PIPE_LISTENING, "got %ld should be ERROR_PIPE_LISTENING\n", GetLastError());
     if (GetLastError() == ERROR_IO_PENDING)
         CancelIo(pipewrite);
     ok(CloseHandle(ol.hEvent), "CloseHandle for the event failed\n");
@@ -4115,25 +4115,25 @@ static void test_GetOverlappedResultEx(void)
     SetLastError(0xdeadbeef);
     ret = pGetOverlappedResultEx(client, &ovl, &ret_size, 0, FALSE);
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_IO_INCOMPLETE, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_IO_INCOMPLETE, "wrong error %lu\n", GetLastError());
     ok(!user_apc_ran, "APC should not have run\n");
 
     SetLastError(0xdeadbeef);
     ret = pGetOverlappedResultEx(client, &ovl, &ret_size, 0, TRUE);
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_IO_INCOMPLETE, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_IO_INCOMPLETE, "wrong error %lu\n", GetLastError());
     ok(!user_apc_ran, "APC should not have run\n");
 
     SetLastError(0xdeadbeef);
     ret = pGetOverlappedResultEx(client, &ovl, &ret_size, 10, FALSE);
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == WAIT_TIMEOUT, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == WAIT_TIMEOUT, "wrong error %lu\n", GetLastError());
     ok(!user_apc_ran, "APC should not have run\n");
 
     SetLastError(0xdeadbeef);
     ret = pGetOverlappedResultEx(client, &ovl, &ret_size, 10, TRUE);
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == WAIT_IO_COMPLETION, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == WAIT_IO_COMPLETION, "wrong error %lu\n", GetLastError());
     ok(user_apc_ran, "APC should have run\n");
 
     CloseHandle(ovl.hEvent);
@@ -4154,13 +4154,13 @@ static void child_process_exit_process_async(DWORD parent_pid, HANDLE parent_pip
 
     ret = DuplicateHandle(parent, parent_pipe, GetCurrentProcess(), &pipe, 0,
             FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     overlapped.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
 
     ret = ReadFile(pipe, buffer, sizeof(buffer), NULL, &overlapped);
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_IO_PENDING, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_IO_PENDING, "got error %lu\n", GetLastError());
 
     /* exit without closing the pipe handle */
 }
@@ -4182,9 +4182,9 @@ static void test_exit_process_async(void)
     create_overlapped_pipe(PIPE_TYPE_BYTE, &client, &server);
     port = CreateIoCompletionPort(client, NULL, 123, 0);
 
-    sprintf(cmdline, "%s pipe exit_process_async %x %p", argv[0], GetCurrentProcessId(), client);
+    sprintf(cmdline, "%s pipe exit_process_async %lx %p", argv[0], GetCurrentProcessId(), client);
     ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ret = WaitForSingleObject(pi.hProcess, 1000);
     ok(!ret, "wait timed out\n");
     CloseHandle(pi.hThread);
@@ -4194,8 +4194,8 @@ static void test_exit_process_async(void)
     size = 0xdeadbeef;
     ret = GetQueuedCompletionStatus(port, &size, &key, &overlapped, 1000);
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_OPERATION_ABORTED, "got error %u\n", GetLastError());
-    ok(!size, "got size %u\n", size);
+    ok(GetLastError() == ERROR_OPERATION_ABORTED, "got error %lu\n", GetLastError());
+    ok(!size, "got size %lu\n", size);
     ok(key == 123, "got key %Iu\n", key);
 
     CloseHandle(port);
@@ -4225,14 +4225,14 @@ START_TEST(pipe)
         if (!strcmp(argv[2], "writepipe"))
         {
             ULONG handle;
-            sscanf(argv[3], "%x", &handle);
+            sscanf(argv[3], "%lx", &handle);
             child_process_write_pipe(ULongToHandle(handle));
             return;
         }
         if (!strcmp(argv[2], "checkpid"))
         {
             DWORD pid = GetProcessId(GetCurrentProcess());
-            sscanf(argv[3], "%x", &pid);
+            sscanf(argv[3], "%lx", &pid);
             child_process_check_pid(pid);
             return;
         }
@@ -4240,7 +4240,7 @@ START_TEST(pipe)
         {
             DWORD id;
             ProcessIdToSessionId(GetProcessId(GetCurrentProcess()), &id);
-            sscanf(argv[3], "%x", &id);
+            sscanf(argv[3], "%lx", &id);
             child_process_check_session_id(id);
             return;
         }
@@ -4248,7 +4248,7 @@ START_TEST(pipe)
         {
             HANDLE handle;
             DWORD pid;
-            sscanf(argv[3], "%x", &pid);
+            sscanf(argv[3], "%lx", &pid);
             sscanf(argv[4], "%p", &handle);
             child_process_exit_process_async(pid, handle);
             return;
diff --git a/dlls/kernel32/tests/power.c b/dlls/kernel32/tests/power.c
index af488849e21..900362a4a45 100644
--- a/dlls/kernel32/tests/power.c
+++ b/dlls/kernel32/tests/power.c
@@ -53,14 +53,14 @@ void test_GetSystemPowerStatus(void)
            "expected %u%%-charged battery to have capacity flags 0x%02x, got 0x%02x\n",
            ps.BatteryLifePercent, expected_capacity_flags, capacity_flags);
         ok(ps.BatteryLifeTime <= ps.BatteryFullLifeTime,
-           "expected BatteryLifeTime %u to be less than or equal to BatteryFullLifeTime %u\n",
+           "expected BatteryLifeTime %lu to be less than or equal to BatteryFullLifeTime %lu\n",
            ps.BatteryLifeTime, ps.BatteryFullLifeTime);
         if (ps.BatteryFlag & BATTERY_FLAG_CHARGING)
         {
             ok(ps.BatteryLifeTime == BATTERY_LIFE_UNKNOWN,
-               "expected BatteryLifeTime to be -1 when charging, got %u\n", ps.BatteryLifeTime);
+               "expected BatteryLifeTime to be -1 when charging, got %lu\n", ps.BatteryLifeTime);
             ok(ps.BatteryFullLifeTime == BATTERY_LIFE_UNKNOWN,
-               "expected BatteryFullLifeTime to be -1 when charging, got %u\n", ps.BatteryFullLifeTime);
+               "expected BatteryFullLifeTime to be -1 when charging, got %lu\n", ps.BatteryFullLifeTime);
         }
     }
     else
@@ -71,9 +71,9 @@ void test_GetSystemPowerStatus(void)
         ok(ps.BatteryLifePercent == BATTERY_PERCENTAGE_UNKNOWN,
            "expected BatteryLifePercent to be -1, got %u\n", ps.BatteryLifePercent);
         ok(ps.BatteryLifeTime == BATTERY_LIFE_UNKNOWN,
-           "expected BatteryLifeTime to be -1, got %u\n", ps.BatteryLifeTime);
+           "expected BatteryLifeTime to be -1, got %lu\n", ps.BatteryLifeTime);
         ok(ps.BatteryFullLifeTime == BATTERY_LIFE_UNKNOWN,
-           "expected BatteryFullLifeTime to be -1, got %u\n", ps.BatteryFullLifeTime);
+           "expected BatteryFullLifeTime to be -1, got %lu\n", ps.BatteryFullLifeTime);
     }
 }
 
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c
index a4af5bb57ff..46f5cc41532 100644
--- a/dlls/kernel32/tests/process.c
+++ b/dlls/kernel32/tests/process.c
@@ -47,7 +47,7 @@
     do { \
       int value = (actual); \
       ok((expected) == value, "Expected " #actual " to be %d (" #expected ") is %d\n", \
-          (expected), value); \
+         (int)(expected), value);                                       \
     } while (0)
 #define expect_eq_s(expected, actual) \
     do { \
@@ -343,11 +343,11 @@ static void     doChild(const char* file, const char* option)
     /* output of startup info (Ansi) */
     GetStartupInfoA(&siA);
     childPrintf(hFile,
-                "[StartupInfoA]\ncb=%08u\nlpDesktop=%s\nlpTitle=%s\n"
-                "dwX=%u\ndwY=%u\ndwXSize=%u\ndwYSize=%u\n"
-                "dwXCountChars=%u\ndwYCountChars=%u\ndwFillAttribute=%u\n"
-                "dwFlags=%u\nwShowWindow=%u\n"
-                "hStdInput=%lu\nhStdOutput=%lu\nhStdError=%lu\n\n",
+                "[StartupInfoA]\ncb=%08lu\nlpDesktop=%s\nlpTitle=%s\n"
+                "dwX=%lu\ndwY=%lu\ndwXSize=%lu\ndwYSize=%lu\n"
+                "dwXCountChars=%lu\ndwYCountChars=%lu\ndwFillAttribute=%lu\n"
+                "dwFlags=%lu\nwShowWindow=%u\n"
+                "hStdInput=%Iu\nhStdOutput=%Iu\nhStdError=%Iu\n\n",
                 siA.cb, encodeA(siA.lpDesktop), encodeA(siA.lpTitle),
                 siA.dwX, siA.dwY, siA.dwXSize, siA.dwYSize,
                 siA.dwXCountChars, siA.dwYCountChars, siA.dwFillAttribute,
@@ -355,7 +355,7 @@ static void     doChild(const char* file, const char* option)
                 (DWORD_PTR)siA.hStdInput, (DWORD_PTR)siA.hStdOutput, (DWORD_PTR)siA.hStdError);
 
     /* check the console handles in the TEB */
-    childPrintf(hFile, "[TEB]\nhStdInput=%lu\nhStdOutput=%lu\nhStdError=%lu\n\n",
+    childPrintf(hFile, "[TEB]\nhStdInput=%Iu\nhStdOutput=%Iu\nhStdError=%Iu\n\n",
                 (DWORD_PTR)params->hStdInput, (DWORD_PTR)params->hStdOutput,
                 (DWORD_PTR)params->hStdError);
 
@@ -365,11 +365,11 @@ static void     doChild(const char* file, const char* option)
     memset(&siW, 0, sizeof(siW));
     GetStartupInfoW(&siW);
     childPrintf(hFile,
-                "[StartupInfoW]\ncb=%08u\nlpDesktop=%s\nlpTitle=%s\n"
-                "dwX=%u\ndwY=%u\ndwXSize=%u\ndwYSize=%u\n"
-                "dwXCountChars=%u\ndwYCountChars=%u\ndwFillAttribute=%u\n"
-                "dwFlags=%u\nwShowWindow=%u\n"
-                "hStdInput=%lu\nhStdOutput=%lu\nhStdError=%lu\n\n",
+                "[StartupInfoW]\ncb=%08lu\nlpDesktop=%s\nlpTitle=%s\n"
+                "dwX=%lu\ndwY=%lu\ndwXSize=%lu\ndwYSize=%lu\n"
+                "dwXCountChars=%lu\ndwYCountChars=%lu\ndwFillAttribute=%lu\n"
+                "dwFlags=%lu\nwShowWindow=%u\n"
+                "hStdInput=%Iu\nhStdOutput=%Iu\nhStdError=%Iu\n\n",
                 siW.cb, encodeW(siW.lpDesktop), encodeW(siW.lpTitle),
                 siW.dwX, siW.dwY, siW.dwXSize, siW.dwYSize,
                 siW.dwXCountChars, siW.dwYCountChars, siW.dwFillAttribute,
@@ -387,7 +387,7 @@ static void     doChild(const char* file, const char* option)
 
     /* output toolhelp information */
     snapshot = pCreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
-    ok(snapshot != INVALID_HANDLE_VALUE, "CreateToolhelp32Snapshot failed %u\n", GetLastError());
+    ok(snapshot != INVALID_HANDLE_VALUE, "CreateToolhelp32Snapshot failed %lu\n", GetLastError());
     memset(&pe, 0, sizeof(pe));
     pe.dwSize = sizeof(pe);
     if (pProcess32First(snapshot, &pe))
@@ -398,9 +398,9 @@ static void     doChild(const char* file, const char* option)
     CloseHandle(snapshot);
     ok(pe.th32ProcessID == GetCurrentProcessId(), "failed to find current process in snapshot\n");
     childPrintf(hFile,
-                "[Toolhelp]\ncntUsage=%u\nth32DefaultHeapID=%lu\n"
-                "th32ModuleID=%u\ncntThreads=%u\nth32ParentProcessID=%u\n"
-                "pcPriClassBase=%u\ndwFlags=%u\nszExeFile=%s\n\n",
+                "[Toolhelp]\ncntUsage=%lu\nth32DefaultHeapID=%Iu\n"
+                "th32ModuleID=%lu\ncntThreads=%lu\nth32ParentProcessID=%lu\n"
+                "pcPriClassBase=%lu\ndwFlags=%lu\nszExeFile=%s\n\n",
                 pe.cntUsage, pe.th32DefaultHeapID, pe.th32ModuleID,
                 pe.cntThreads, pe.th32ParentProcessID, pe.pcPriClassBase,
                 pe.dwFlags, encodeA(pe.szExeFile));
@@ -471,9 +471,9 @@ static void     doChild(const char* file, const char* option)
         childPrintf(hFile, "InputCP=%d\nOutputCP=%d\n",
                     GetConsoleCP(), GetConsoleOutputCP());
         if (GetConsoleMode(hConIn, &modeIn))
-            childPrintf(hFile, "InputMode=%u\n", modeIn);
+            childPrintf(hFile, "InputMode=%lu\n", modeIn);
         if (GetConsoleMode(hConOut, &modeOut))
-            childPrintf(hFile, "OutputMode=%u\n", modeOut);
+            childPrintf(hFile, "OutputMode=%lu\n", modeOut);
 
         /* now that we have written all relevant information, let's change it */
         SetLastError(0xdeadbeef);
@@ -489,13 +489,13 @@ static void     doChild(const char* file, const char* option)
         }
 
         ret = SetConsoleMode(hConIn, modeIn ^ 1);
-        ok( ret, "Setting mode (%d)\n", GetLastError());
+        ok( ret, "Setting mode (%ld)\n", GetLastError());
         ret = SetConsoleMode(hConOut, modeOut ^ 1);
-        ok( ret, "Setting mode (%d)\n", GetLastError());
+        ok( ret, "Setting mode (%ld)\n", GetLastError());
         sbi.dwCursorPosition.X ^= 1;
         sbi.dwCursorPosition.Y ^= 1;
         ret = SetConsoleCursorPosition(hConOut, sbi.dwCursorPosition);
-        ok( ret, "Setting cursor position (%d)\n", GetLastError());
+        ok( ret, "Setting cursor position (%ld)\n", GetLastError());
     }
     if (option && strcmp(option, "stdhandle") == 0)
     {
@@ -896,25 +896,25 @@ static void test_CommandLine(void)
     memset(&info, 0xa, sizeof(info));
     ok(!CreateProcessA(buffer, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess unexpectedly succeeded\n");
     /* Check that the effective STARTUPINFOA parameters are not modified */
-    ok(startup.cb == sizeof(startup), "unexpected cb %d\n", startup.cb);
+    ok(startup.cb == sizeof(startup), "unexpected cb %ld\n", startup.cb);
     ok(startup.lpDesktop == NULL, "lpDesktop is not NULL\n");
     ok(startup.lpTitle == NULL, "lpTitle is not NULL\n");
-    ok(startup.dwFlags == STARTF_USESHOWWINDOW, "unexpected dwFlags %04x\n", startup.dwFlags);
+    ok(startup.dwFlags == STARTF_USESHOWWINDOW, "unexpected dwFlags %04lx\n", startup.dwFlags);
     ok(startup.wShowWindow == SW_SHOWNORMAL, "unexpected wShowWindow %d\n", startup.wShowWindow);
     ok(!info.hProcess, "unexpected hProcess %p\n", info.hProcess);
     ok(!info.hThread, "unexpected hThread %p\n", info.hThread);
-    ok(!info.dwProcessId, "unexpected dwProcessId %04x\n", info.dwProcessId);
-    ok(!info.dwThreadId, "unexpected dwThreadId %04x\n", info.dwThreadId);
+    ok(!info.dwProcessId, "unexpected dwProcessId %04lx\n", info.dwProcessId);
+    ok(!info.dwThreadId, "unexpected dwThreadId %04lx\n", info.dwThreadId);
 
     /* the basics; not getting confused by the leading and trailing " */
     get_file_name(resfile);
     sprintf(buffer, "\"%s\" process dump \"%s\" \"C:\\Program Files\\my nice app.exe\"", selfname, resfile);
     ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
     /* Check that the effective STARTUPINFOA parameters are not modified */
-    ok(startup.cb == sizeof(startup), "unexpected cb %d\n", startup.cb);
+    ok(startup.cb == sizeof(startup), "unexpected cb %ld\n", startup.cb);
     ok(startup.lpDesktop == NULL, "lpDesktop is not NULL\n");
     ok(startup.lpTitle == NULL, "lpTitle is not NULL\n");
-    ok(startup.dwFlags == STARTF_USESHOWWINDOW, "unexpected dwFlags %04x\n", startup.dwFlags);
+    ok(startup.dwFlags == STARTF_USESHOWWINDOW, "unexpected dwFlags %04lx\n", startup.dwFlags);
     ok(startup.wShowWindow == SW_SHOWNORMAL, "unexpected wShowWindow %d\n", startup.wShowWindow);
     wait_and_close_child_process(&info);
 
@@ -955,7 +955,7 @@ static void test_CommandLine(void)
     sprintf(buffer, "./%s process dump \"%s\" \"\"\"\"", exename, resfile);
     SetLastError(0xdeadbeef);
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
-    ok(ret, "CreateProcess (%s) failed : %d\n", buffer, GetLastError());
+    ok(ret, "CreateProcess (%s) failed : %ld\n", buffer, GetLastError());
     wait_and_close_child_process(&info);
 
     reload_child_info(resfile);
@@ -972,7 +972,7 @@ static void test_CommandLine(void)
     sprintf(buffer, ".\\%s process dump \"%s\"", exename, resfile);
     SetLastError(0xdeadbeef);
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
-    ok(ret, "CreateProcess (%s) failed : %d\n", buffer, GetLastError());
+    ok(ret, "CreateProcess (%s) failed : %ld\n", buffer, GetLastError());
     wait_and_close_child_process(&info);
 
     reload_child_info(resfile);
@@ -988,7 +988,7 @@ static void test_CommandLine(void)
     else sprintf(buffer, "./%s process dump \"%s\"", exename, resfile);
     SetLastError(0xdeadbeef);
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
-    ok(ret, "CreateProcess (%s) failed : %d\n", buffer, GetLastError());
+    ok(ret, "CreateProcess (%s) failed : %ld\n", buffer, GetLastError());
     wait_and_close_child_process(&info);
 
     reload_child_info(resfile);
@@ -1010,7 +1010,7 @@ static void test_CommandLine(void)
     sprintf(buffer2, "dummy process dump \"%s\"", resfile);
     SetLastError(0xdeadbeef);
     ret = CreateProcessA(buffer, buffer2, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
-    ok(ret, "CreateProcess (%s) failed : %d\n", buffer, GetLastError());
+    ok(ret, "CreateProcess (%s) failed : %ld\n", buffer, GetLastError());
     wait_and_close_child_process(&info);
 
     reload_child_info(resfile);
@@ -1028,7 +1028,7 @@ static void test_CommandLine(void)
         ret = CreateProcessA(NULL, NULL, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
         ok(!ret, "CreateProcessA unexpectedly succeeded\n");
         ok(GetLastError() == ERROR_INVALID_PARAMETER,
-           "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+           "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
     }
 
     buffer[0] = '\0';
@@ -1040,7 +1040,7 @@ static void test_CommandLine(void)
     ok(GetLastError() == ERROR_PATH_NOT_FOUND ||
        broken(GetLastError() == ERROR_FILE_NOT_FOUND) /* Win9x/WinME */ ||
        broken(GetLastError() == ERROR_ACCESS_DENIED) /* Win98 */,
-       "Expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError());
+       "Expected ERROR_PATH_NOT_FOUND, got %ld\n", GetLastError());
 
     buffer2[0] = '\0';
 
@@ -1051,7 +1051,7 @@ static void test_CommandLine(void)
     ok(GetLastError() == ERROR_PATH_NOT_FOUND ||
        broken(GetLastError() == ERROR_FILE_NOT_FOUND) /* Win9x/WinME */ ||
        broken(GetLastError() == ERROR_ACCESS_DENIED) /* Win98 */,
-       "Expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError());
+       "Expected ERROR_PATH_NOT_FOUND, got %ld\n", GetLastError());
 
     /* Test empty command line parameter. */
     SetLastError(0xdeadbeef);
@@ -1061,7 +1061,7 @@ static void test_CommandLine(void)
        GetLastError() == ERROR_PATH_NOT_FOUND /* NT4 */ ||
        GetLastError() == ERROR_BAD_PATHNAME /* Win98 */ ||
        GetLastError() == ERROR_INVALID_PARAMETER /* Win7 */,
-       "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+       "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
 
     strcpy(buffer, "doesnotexist.exe");
     strcpy(buffer2, "does not exist.exe");
@@ -1070,23 +1070,23 @@ static void test_CommandLine(void)
     SetLastError(0xdeadbeef);
     ret = CreateProcessA(buffer, NULL, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
     ok(!ret, "CreateProcessA unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = CreateProcessA(buffer2, NULL, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
     ok(!ret, "CreateProcessA unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
 
     /* Test nonexistent command line parameter. */
     SetLastError(0xdeadbeef);
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
     ok(!ret, "CreateProcessA unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = CreateProcessA(NULL, buffer2, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
     ok(!ret, "CreateProcessA unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
 
     /* Test whether GetCommandLineW reads directly from TEB or from a cached address */
     cmdline = GetCommandLineW();
@@ -1135,7 +1135,7 @@ static void test_Directory(void)
     memset(&info, 0, sizeof(info));
     ok(!CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0L,
                        NULL, "non\\existent\\directory", &startup, &info), "CreateProcess\n");
-    ok(GetLastError() == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %ld\n", GetLastError());
     ok(!TerminateProcess(info.hProcess, 0), "Child process should not exist\n");
 }
 
@@ -1178,7 +1178,7 @@ static void test_Toolhelp(void)
     wait_child_process(info.hProcess);
 
     process = OpenProcess(PROCESS_ALL_ACCESS_NT4, FALSE, info.dwProcessId);
-    ok(process != NULL, "OpenProcess failed %u\n", GetLastError());
+    ok(process != NULL, "OpenProcess failed %lu\n", GetLastError());
     CloseHandle(process);
 
     CloseHandle(info.hProcess);
@@ -1188,7 +1188,7 @@ static void test_Toolhelp(void)
     {
         SetLastError(0xdeadbeef);
         process = OpenProcess(PROCESS_ALL_ACCESS_NT4, FALSE, info.dwProcessId);
-        ok(process || GetLastError() == ERROR_INVALID_PARAMETER, "OpenProcess failed %u\n", GetLastError());
+        ok(process || GetLastError() == ERROR_INVALID_PARAMETER, "OpenProcess failed %lu\n", GetLastError());
         if (!process) break;
         CloseHandle(process);
         Sleep(100);
@@ -1202,7 +1202,7 @@ static void test_Toolhelp(void)
     DeleteFileA(resfile);
 
     snapshot = pCreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
-    ok(snapshot != INVALID_HANDLE_VALUE, "CreateToolhelp32Snapshot failed %u\n", GetLastError());
+    ok(snapshot != INVALID_HANDLE_VALUE, "CreateToolhelp32Snapshot failed %lu\n", GetLastError());
     memset(&pe, 0, sizeof(pe));
     pe.dwSize = sizeof(pe);
     if (pProcess32First(snapshot, &pe))
@@ -1212,14 +1212,14 @@ static void test_Toolhelp(void)
     }
     CloseHandle(snapshot);
     ok(pe.th32ProcessID == nested_pid, "failed to find nested child process\n");
-    ok(pe.th32ParentProcessID == info.dwProcessId, "nested child process has parent %u instead of %u\n", pe.th32ParentProcessID, info.dwProcessId);
+    ok(pe.th32ParentProcessID == info.dwProcessId, "nested child process has parent %lu instead of %lu\n", pe.th32ParentProcessID, info.dwProcessId);
     ok(stricmp(pe.szExeFile, exename) == 0, "nested executable is %s instead of %s\n", pe.szExeFile, exename);
 
     process = OpenProcess(PROCESS_ALL_ACCESS_NT4, FALSE, pe.th32ProcessID);
-    ok(process != NULL, "OpenProcess failed %u\n", GetLastError());
+    ok(process != NULL, "OpenProcess failed %lu\n", GetLastError());
 
     snapshot = pCreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
-    ok(snapshot != INVALID_HANDLE_VALUE, "CreateToolhelp32Snapshot failed %u\n", GetLastError());
+    ok(snapshot != INVALID_HANDLE_VALUE, "CreateToolhelp32Snapshot failed %lu\n", GetLastError());
     memset(&te, 0, sizeof(te));
     te.dwSize = sizeof(te);
     if (pThread32First(snapshot, &te))
@@ -1231,9 +1231,9 @@ static void test_Toolhelp(void)
     ok(te.th32OwnerProcessID == pe.th32ProcessID, "failed to find suspended thread\n");
 
     thread = OpenThread(THREAD_ALL_ACCESS_NT4, FALSE, te.th32ThreadID);
-    ok(thread != NULL, "OpenThread failed %u\n", GetLastError());
+    ok(thread != NULL, "OpenThread failed %lu\n", GetLastError());
     ret = ResumeThread(thread);
-    ok(ret == 1, "expected 1, got %u\n", ret);
+    ok(ret == 1, "expected 1, got %lu\n", ret);
     CloseHandle(thread);
 
     wait_child_process(process);
@@ -1475,7 +1475,7 @@ static  void    test_DebuggingFlag(void)
         if (!dbg)
         {
             ok(de.dwDebugEventCode == CREATE_PROCESS_DEBUG_EVENT,
-               "first event: %d\n", de.dwDebugEventCode);
+               "first event: %ld\n", de.dwDebugEventCode);
             processbase = de.u.CreateProcessInfo.lpBaseOfImage;
         }
         if (de.dwDebugEventCode != EXCEPTION_DEBUG_EVENT) dbg++;
@@ -1581,7 +1581,7 @@ static void test_Console(void)
     ok(!SetConsoleCP(0), "Shouldn't succeed\n");
     ok(GetLastError()==ERROR_INVALID_PARAMETER ||
        broken(GetLastError() == ERROR_CALL_NOT_IMPLEMENTED), /* win9x */
-       "GetLastError: expecting %u got %u\n",
+       "GetLastError: expecting %u got %lu\n",
        ERROR_INVALID_PARAMETER, GetLastError());
     if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
         run_tests = FALSE;
@@ -1591,7 +1591,7 @@ static void test_Console(void)
     ok(!SetConsoleOutputCP(0), "Shouldn't succeed\n");
     ok(GetLastError()==ERROR_INVALID_PARAMETER ||
        broken(GetLastError() == ERROR_CALL_NOT_IMPLEMENTED), /* win9x */
-       "GetLastError: expecting %u got %u\n",
+       "GetLastError: expecting %u got %lu\n",
        ERROR_INVALID_PARAMETER, GetLastError());
 
     SetConsoleCP(cpIn);
@@ -1636,8 +1636,8 @@ static void test_Console(void)
 
     if (run_tests)
     {
-        ok(cpInC == 1252, "Wrong console CP (expected 1252 got %d/%d)\n", cpInC, cpIn);
-        ok(cpOutC == 1252, "Wrong console-SB CP (expected 1252 got %d/%d)\n", cpOutC, cpOut);
+        ok(cpInC == 1252, "Wrong console CP (expected 1252 got %ld/%ld)\n", cpInC, cpIn);
+        ok(cpOutC == 1252, "Wrong console-SB CP (expected 1252 got %ld/%ld)\n", cpOutC, cpOut);
     }
     else
         win_skip("Setting the codepage is not implemented\n");
@@ -1676,7 +1676,7 @@ static void test_Console(void)
 
     msg_len = strlen(msg) + 1;
     ok(WriteFile(hParentOut, msg, msg_len, &w, NULL), "Writing to child\n");
-    ok(w == msg_len, "Should have written %u bytes, actually wrote %u\n", msg_len, w);
+    ok(w == msg_len, "Should have written %u bytes, actually wrote %lu\n", msg_len, w);
     memset(buffer, 0, sizeof(buffer));
     ok(ReadFile(hParentIn, buffer, sizeof(buffer), &w, NULL), "Reading from child\n");
     ok(strcmp(buffer, msg) == 0, "Should have received '%s'\n", msg);
@@ -1731,7 +1731,7 @@ static void test_OpenProcess(void)
 
     /* without PROCESS_VM_OPERATION */
     hproc = OpenProcess(PROCESS_ALL_ACCESS_NT4 & ~PROCESS_VM_OPERATION, FALSE, GetCurrentProcessId());
-    ok(hproc != NULL, "OpenProcess error %d\n", GetLastError());
+    ok(hproc != NULL, "OpenProcess error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     addr1 = VirtualAllocEx(hproc, 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
@@ -1742,35 +1742,35 @@ static void test_OpenProcess(void)
         win_skip("VirtualAllocEx not implemented\n");
         return;
     }
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %d\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %ld\n", GetLastError());
 
     read_bytes = 0xdeadbeef;
     SetLastError(0xdeadbeef);
     ret = ReadProcessMemory(hproc, test_OpenProcess, &dummy, sizeof(dummy), &read_bytes);
-    ok(ret, "ReadProcessMemory error %d\n", GetLastError());
-    ok(read_bytes == sizeof(dummy), "wrong read bytes %ld\n", read_bytes);
+    ok(ret, "ReadProcessMemory error %ld\n", GetLastError());
+    ok(read_bytes == sizeof(dummy), "wrong read bytes %Id\n", read_bytes);
 
     CloseHandle(hproc);
 
     hproc = OpenProcess(PROCESS_VM_OPERATION, FALSE, GetCurrentProcessId());
-    ok(hproc != NULL, "OpenProcess error %d\n", GetLastError());
+    ok(hproc != NULL, "OpenProcess error %ld\n", GetLastError());
 
     addr1 = VirtualAllocEx(hproc, 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
-    ok(addr1 != NULL, "VirtualAllocEx error %d\n", GetLastError());
+    ok(addr1 != NULL, "VirtualAllocEx error %ld\n", GetLastError());
 
     /* without PROCESS_QUERY_INFORMATION */
     SetLastError(0xdeadbeef);
     ok(!VirtualQueryEx(hproc, addr1, &info, sizeof(info)),
        "VirtualQueryEx without PROCESS_QUERY_INFORMATION rights should fail\n");
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %d\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %ld\n", GetLastError());
 
     /* without PROCESS_VM_READ */
     read_bytes = 0xdeadbeef;
     SetLastError(0xdeadbeef);
     ok(!ReadProcessMemory(hproc, addr1, &dummy, sizeof(dummy), &read_bytes),
        "ReadProcessMemory without PROCESS_VM_READ rights should fail\n");
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %d\n", GetLastError());
-    ok(read_bytes == 0, "wrong read bytes %ld\n", read_bytes);
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %ld\n", GetLastError());
+    ok(read_bytes == 0, "wrong read bytes %Id\n", read_bytes);
 
     CloseHandle(hproc);
 
@@ -1778,23 +1778,23 @@ static void test_OpenProcess(void)
 
     memset(&info, 0xcc, sizeof(info));
     read_bytes = VirtualQueryEx(hproc, addr1, &info, sizeof(info));
-    ok(read_bytes == sizeof(info), "VirtualQueryEx error %d\n", GetLastError());
+    ok(read_bytes == sizeof(info), "VirtualQueryEx error %ld\n", GetLastError());
 
     ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
     ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
-    ok(info.AllocationProtect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.AllocationProtect);
-    ok(info.RegionSize == 0x10000, "%lx != 0x10000\n", info.RegionSize);
-    ok(info.State == MEM_RESERVE, "%x != MEM_RESERVE\n", info.State);
+    ok(info.AllocationProtect == PAGE_NOACCESS, "%lx != PAGE_NOACCESS\n", info.AllocationProtect);
+    ok(info.RegionSize == 0x10000, "%Ix != 0x10000\n", info.RegionSize);
+    ok(info.State == MEM_RESERVE, "%lx != MEM_RESERVE\n", info.State);
     /* NT reports Protect == 0 for a not committed memory block */
     ok(info.Protect == 0 /* NT */ ||
        info.Protect == PAGE_NOACCESS, /* Win9x */
-        "%x != PAGE_NOACCESS\n", info.Protect);
-    ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
+        "%lx != PAGE_NOACCESS\n", info.Protect);
+    ok(info.Type == MEM_PRIVATE, "%lx != MEM_PRIVATE\n", info.Type);
 
     SetLastError(0xdeadbeef);
     ok(!VirtualFreeEx(hproc, addr1, 0, MEM_RELEASE),
        "VirtualFreeEx without PROCESS_VM_OPERATION rights should fail\n");
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %d\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %ld\n", GetLastError());
 
     CloseHandle(hproc);
 
@@ -1806,22 +1806,22 @@ static void test_OpenProcess(void)
         read_bytes = VirtualQueryEx(hproc, addr1, &info, sizeof(info));
         if (read_bytes) /* win8 */
         {
-            ok(read_bytes == sizeof(info), "VirtualQueryEx error %d\n", GetLastError());
+            ok(read_bytes == sizeof(info), "VirtualQueryEx error %ld\n", GetLastError());
             ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
             ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
-            ok(info.AllocationProtect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.AllocationProtect);
-            ok(info.RegionSize == 0x10000, "%lx != 0x10000\n", info.RegionSize);
-            ok(info.State == MEM_RESERVE, "%x != MEM_RESERVE\n", info.State);
-            ok(info.Protect == 0, "%x != PAGE_NOACCESS\n", info.Protect);
-            ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
+            ok(info.AllocationProtect == PAGE_NOACCESS, "%lx != PAGE_NOACCESS\n", info.AllocationProtect);
+            ok(info.RegionSize == 0x10000, "%Ix != 0x10000\n", info.RegionSize);
+            ok(info.State == MEM_RESERVE, "%lx != MEM_RESERVE\n", info.State);
+            ok(info.Protect == 0, "%lx != PAGE_NOACCESS\n", info.Protect);
+            ok(info.Type == MEM_PRIVATE, "%lx != MEM_PRIVATE\n", info.Type);
         }
         else /* before win8 */
-            ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %d\n", GetLastError());
+            ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %ld\n", GetLastError());
 
         SetLastError(0xdeadbeef);
         ok(!VirtualFreeEx(hproc, addr1, 0, MEM_RELEASE),
            "VirtualFreeEx without PROCESS_VM_OPERATION rights should fail\n");
-        ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %d\n", GetLastError());
+        ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %ld\n", GetLastError());
 
         CloseHandle(hproc);
     }
@@ -1838,11 +1838,11 @@ static void test_GetProcessVersion(void)
 
     SetLastError(0xdeadbeef);
     ret = GetProcessVersion(0);
-    ok(ret, "GetProcessVersion error %u\n", GetLastError());
+    ok(ret, "GetProcessVersion error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = GetProcessVersion(GetCurrentProcessId());
-    ok(ret, "GetProcessVersion error %u\n", GetLastError());
+    ok(ret, "GetProcessVersion error %lu\n", GetLastError());
 
     memset(&si, 0, sizeof(si));
     si.cb = sizeof(si);
@@ -1850,15 +1850,15 @@ static void test_GetProcessVersion(void)
     si.wShowWindow = SW_HIDE;
     SetLastError(0xdeadbeef);
     ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess error %u\n", GetLastError());
+    ok(ret, "CreateProcess error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = GetProcessVersion(pi.dwProcessId);
-    ok(ret, "GetProcessVersion error %u\n", GetLastError());
+    ok(ret, "GetProcessVersion error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = TerminateProcess(pi.hProcess, 0);
-    ok(ret, "TerminateProcess error %u\n", GetLastError());
+    ok(ret, "TerminateProcess error %lu\n", GetLastError());
 
     CloseHandle(pi.hProcess);
     CloseHandle(pi.hThread);
@@ -1880,7 +1880,7 @@ static void test_GetProcessImageFileNameA(void)
     SetLastError(0xdeadbeef);
     rc = pK32GetProcessImageFileNameA(GetCurrentProcess(), NULL, 0);
     ok(!rc && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-       "K32GetProcessImageFileNameA(no buffer): returned %u, le=%u\n", rc, GetLastError());
+       "K32GetProcessImageFileNameA(no buffer): returned %lu, le=%lu\n", rc, GetLastError());
 
     *process = '\0';
     rc = pK32GetProcessImageFileNameA(GetCurrentProcess(), process, sizeof(process));
@@ -1920,7 +1920,7 @@ static void test_QueryFullProcessImageNameA(void)
     *module = '\0';
     SetLastError(0); /* old Windows don't reset it on success */
     size = GetModuleFileNameA(NULL, module, sizeof(module));
-    ok(size && GetLastError() != ERROR_INSUFFICIENT_BUFFER, "GetModuleFileName failed: %u le=%u\n", size, GetLastError());
+    ok(size && GetLastError() != ERROR_INSUFFICIENT_BUFFER, "GetModuleFileName failed: %lu le=%lu\n", size, GetLastError());
 
     /* get the buffer length without \0 terminator */
     length = sizeof(buf);
@@ -2059,9 +2059,9 @@ static void test_QueryFullProcessImageNameW(void)
     module_name[2] = '\0';
     *device = '\0';
     size = QueryDosDeviceW(module_name, device, ARRAY_SIZE(device));
-    ok(size, "QueryDosDeviceW failed: le=%u\n", GetLastError());
+    ok(size, "QueryDosDeviceW failed: le=%lu\n", GetLastError());
     len = lstrlenW(device);
-    ok(size >= len+2, "expected %d to be greater than %d+2 = strlen(%s)\n", size, len, wine_dbgstr_w(device));
+    ok(size >= len+2, "expected %ld to be greater than %ld+2 = strlen(%s)\n", size, len, wine_dbgstr_w(device));
 
     if (size >= lstrlenW(buf))
     {
@@ -2089,25 +2089,25 @@ static void test_Handles(void)
         handle == (HANDLE)(ULONG_PTR)0x7fffffff /* win9x */,
         "invalid current process handle %p\n", handle );
     ret = GetExitCodeProcess( handle, &code );
-    ok( ret, "GetExitCodeProcess failed err %u\n", GetLastError() );
+    ok( ret, "GetExitCodeProcess failed err %lu\n", GetLastError() );
 #ifdef _WIN64
     /* truncated handle */
     SetLastError( 0xdeadbeef );
     handle = (HANDLE)((ULONG_PTR)handle & ~0u);
     ret = GetExitCodeProcess( handle, &code );
     ok( !ret, "GetExitCodeProcess succeeded for %p\n", handle );
-    ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %lu\n", GetLastError() );
     /* sign-extended handle */
     SetLastError( 0xdeadbeef );
     handle = (HANDLE)((LONG_PTR)(int)(ULONG_PTR)handle);
     ret = GetExitCodeProcess( handle, &code );
-    ok( ret, "GetExitCodeProcess failed err %u\n", GetLastError() );
+    ok( ret, "GetExitCodeProcess failed err %lu\n", GetLastError() );
     /* invalid high-word */
     SetLastError( 0xdeadbeef );
     handle = (HANDLE)(((ULONG_PTR)handle & ~0u) + ((ULONG_PTR)1 << 32));
     ret = GetExitCodeProcess( handle, &code );
     ok( !ret, "GetExitCodeProcess succeeded for %p\n", handle );
-    ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %lu\n", GetLastError() );
 #endif
 
     handle = GetStdHandle( STD_ERROR_HANDLE );
@@ -2215,7 +2215,7 @@ static void test_IsWow64Process2(void)
         SetLastError(0xdeadbeef);
         machine = native_machine = 0xdead;
         ret = pIsWow64Process2(pi.hProcess, &machine, &native_machine);
-        ok(ret, "IsWow64Process2 error %u\n", GetLastError());
+        ok(ret, "IsWow64Process2 error %lu\n", GetLastError());
 
 #if defined(__i386__) || defined(__x86_64__)
         ok(machine == IMAGE_FILE_MACHINE_I386, "got %#x\n", machine);
@@ -2236,16 +2236,16 @@ static void test_IsWow64Process2(void)
     si.cb = sizeof(si);
     SetLastError(0xdeadbeef);
     ret = CreateProcessA(cmdline, NULL, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess error %u\n", GetLastError());
+    ok(ret, "CreateProcess error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pIsWow64Process(pi.hProcess, &is_wow64);
-    ok(ret, "IsWow64Process error %u\n", GetLastError());
+    ok(ret, "IsWow64Process error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     machine = native_machine = 0xdead;
     ret = pIsWow64Process2(pi.hProcess, &machine, &native_machine);
-    ok(ret, "IsWow64Process2 error %u\n", GetLastError());
+    ok(ret, "IsWow64Process2 error %lu\n", GetLastError());
 
     ok(machine == IMAGE_FILE_MACHINE_UNKNOWN, "got %#x\n", machine);
     ok(native_machine == expect_native, "got %#x\n", native_machine);
@@ -2253,7 +2253,7 @@ static void test_IsWow64Process2(void)
     SetLastError(0xdeadbeef);
     machine = 0xdead;
     ret = pIsWow64Process2(pi.hProcess, &machine, NULL);
-    ok(ret, "IsWow64Process2 error %u\n", GetLastError());
+    ok(ret, "IsWow64Process2 error %lu\n", GetLastError());
     ok(machine == IMAGE_FILE_MACHINE_UNKNOWN, "got %#x\n", machine);
 
     ret = TerminateProcess(pi.hProcess, 0);
@@ -2264,12 +2264,12 @@ static void test_IsWow64Process2(void)
 
     SetLastError(0xdeadbeef);
     ret = pIsWow64Process(GetCurrentProcess(), &is_wow64);
-    ok(ret, "IsWow64Process error %u\n", GetLastError());
+    ok(ret, "IsWow64Process error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     machine = native_machine = 0xdead;
     ret = pIsWow64Process2(GetCurrentProcess(), &machine, &native_machine);
-    ok(ret, "IsWow64Process2 error %u\n", GetLastError());
+    ok(ret, "IsWow64Process2 error %lu\n", GetLastError());
 
     if (is_wow64)
     {
@@ -2285,7 +2285,7 @@ static void test_IsWow64Process2(void)
     SetLastError(0xdeadbeef);
     machine = 0xdead;
     ret = pIsWow64Process2(GetCurrentProcess(), &machine, NULL);
-    ok(ret, "IsWow64Process2 error %u\n", GetLastError());
+    ok(ret, "IsWow64Process2 error %lu\n", GetLastError());
     if (is_wow64)
         ok(machine == IMAGE_FILE_MACHINE_I386, "got %#x\n", machine);
     else
@@ -2315,7 +2315,7 @@ static void test_SystemInfo(void)
                "Expected PROCESSOR_ARCHITECTURE_AMD64, got %d\n",
                S(U(nsi)).wProcessorArchitecture);
             ok(nsi.dwProcessorType == PROCESSOR_AMD_X8664,
-               "Expected PROCESSOR_AMD_X8664, got %d\n",
+               "Expected PROCESSOR_AMD_X8664, got %ld\n",
                nsi.dwProcessorType);
         }
     }
@@ -2325,7 +2325,7 @@ static void test_SystemInfo(void)
            "Expected no difference for wProcessorArchitecture, got %d and %d\n",
            S(U(si)).wProcessorArchitecture, S(U(nsi)).wProcessorArchitecture);
         ok(si.dwProcessorType == nsi.dwProcessorType,
-           "Expected no difference for dwProcessorType, got %d and %d\n",
+           "Expected no difference for dwProcessorType, got %ld and %ld\n",
            si.dwProcessorType, nsi.dwProcessorType);
     }
 }
@@ -2343,7 +2343,7 @@ static void test_ProcessorCount(void)
     active = pGetActiveProcessorCount(ALL_PROCESSOR_GROUPS);
     maximum = pGetMaximumProcessorCount(ALL_PROCESSOR_GROUPS);
     ok(active <= maximum,
-       "Number of active processors %i is greater than maximum number of processors %i\n",
+       "Number of active processors %li is greater than maximum number of processors %li\n",
        active, maximum);
 }
 
@@ -2387,26 +2387,26 @@ static void test_TerminateProcess(void)
     si.cb = sizeof(si);
     SetLastError(0xdeadbeef);
     ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess error %u\n", GetLastError());
+    ok(ret, "CreateProcess error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     thread = CreateRemoteThread(pi.hProcess, NULL, 0, (void *)0xdeadbeef, NULL, CREATE_SUSPENDED, &ret);
-    ok(thread != 0, "CreateRemoteThread error %d\n", GetLastError());
+    ok(thread != 0, "CreateRemoteThread error %ld\n", GetLastError());
 
     /* create a not closed thread handle duplicate in the target process */
     SetLastError(0xdeadbeef);
     ret = DuplicateHandle(GetCurrentProcess(), thread, pi.hProcess, &dummy,
                           0, FALSE, DUPLICATE_SAME_ACCESS);
-    ok(ret, "DuplicateHandle error %u\n", GetLastError());
+    ok(ret, "DuplicateHandle error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = TerminateThread(thread, 0);
-    ok(ret, "TerminateThread error %u\n", GetLastError());
+    ok(ret, "TerminateThread error %lu\n", GetLastError());
     CloseHandle(thread);
 
     SetLastError(0xdeadbeef);
     ret = TerminateProcess(pi.hProcess, 0);
-    ok(ret, "TerminateProcess error %u\n", GetLastError());
+    ok(ret, "TerminateProcess error %lu\n", GetLastError());
 
     CloseHandle(pi.hProcess);
     CloseHandle(pi.hThread);
@@ -2422,20 +2422,20 @@ static void test_DuplicateHandle(void)
     r = DuplicateHandle(GetCurrentProcess(), GetCurrentProcess(),
             GetCurrentProcess(), &out, 0, FALSE,
             DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
-    ok(r, "DuplicateHandle error %u\n", GetLastError());
+    ok(r, "DuplicateHandle error %lu\n", GetLastError());
     r = GetHandleInformation(out, &info);
-    ok(r, "GetHandleInformation error %u\n", GetLastError());
-    ok(info == 0, "info = %x\n", info);
+    ok(r, "GetHandleInformation error %lu\n", GetLastError());
+    ok(info == 0, "info = %lx\n", info);
     ok(out != GetCurrentProcess(), "out = GetCurrentProcess()\n");
     CloseHandle(out);
 
     r = DuplicateHandle(GetCurrentProcess(), GetCurrentProcess(),
             GetCurrentProcess(), &out, 0, TRUE,
             DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
-    ok(r, "DuplicateHandle error %u\n", GetLastError());
+    ok(r, "DuplicateHandle error %lu\n", GetLastError());
     r = GetHandleInformation(out, &info);
-    ok(r, "GetHandleInformation error %u\n", GetLastError());
-    ok(info == HANDLE_FLAG_INHERIT, "info = %x\n", info);
+    ok(r, "GetHandleInformation error %lu\n", GetLastError());
+    ok(info == HANDLE_FLAG_INHERIT, "info = %lx\n", info);
     ok(out != GetCurrentProcess(), "out = GetCurrentProcess()\n");
     CloseHandle(out);
 
@@ -2450,31 +2450,31 @@ static void test_DuplicateHandle(void)
 
     r = DuplicateHandle(GetCurrentProcess(), f, GetCurrentProcess(), &out,
             0, FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
-    ok(r, "DuplicateHandle error %u\n", GetLastError());
+    ok(r, "DuplicateHandle error %lu\n", GetLastError());
     ok(f == out, "f != out\n");
     r = GetHandleInformation(out, &info);
-    ok(r, "GetHandleInformation error %u\n", GetLastError());
-    ok(info == 0, "info = %x\n", info);
+    ok(r, "GetHandleInformation error %lu\n", GetLastError());
+    ok(info == 0, "info = %lx\n", info);
 
     r = DuplicateHandle(GetCurrentProcess(), f, GetCurrentProcess(), &out,
             0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
-    ok(r, "DuplicateHandle error %u\n", GetLastError());
+    ok(r, "DuplicateHandle error %lu\n", GetLastError());
     ok(f == out, "f != out\n");
     r = GetHandleInformation(out, &info);
-    ok(r, "GetHandleInformation error %u\n", GetLastError());
-    ok(info == HANDLE_FLAG_INHERIT, "info = %x\n", info);
+    ok(r, "GetHandleInformation error %lu\n", GetLastError());
+    ok(info == HANDLE_FLAG_INHERIT, "info = %lx\n", info);
 
     r = SetHandleInformation(f, HANDLE_FLAG_PROTECT_FROM_CLOSE, HANDLE_FLAG_PROTECT_FROM_CLOSE);
-    ok(r, "SetHandleInformation error %u\n", GetLastError());
+    ok(r, "SetHandleInformation error %lu\n", GetLastError());
     r = DuplicateHandle(GetCurrentProcess(), f, GetCurrentProcess(), &out,
                 0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
-    ok(r, "DuplicateHandle error %u\n", GetLastError());
+    ok(r, "DuplicateHandle error %lu\n", GetLastError());
     ok(f != out, "f == out\n");
     r = GetHandleInformation(out, &info);
-    ok(r, "GetHandleInformation error %u\n", GetLastError());
-    ok(info == HANDLE_FLAG_INHERIT, "info = %x\n", info);
+    ok(r, "GetHandleInformation error %lu\n", GetLastError());
+    ok(info == HANDLE_FLAG_INHERIT, "info = %lx\n", info);
     r = SetHandleInformation(f, HANDLE_FLAG_PROTECT_FROM_CLOSE, 0);
-    ok(r, "SetHandleInformation error %u\n", GetLastError());
+    ok(r, "SetHandleInformation error %lu\n", GetLastError());
 
     /* Test if DuplicateHandle allocates first free handle */
     if (f > out)
@@ -2489,7 +2489,7 @@ static void test_DuplicateHandle(void)
     CloseHandle(fmin);
     r = DuplicateHandle(GetCurrentProcess(), f, GetCurrentProcess(), &out,
             0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
-    ok(r, "DuplicateHandle error %u\n", GetLastError());
+    ok(r, "DuplicateHandle error %lu\n", GetLastError());
     ok(f == out, "f != out\n");
     CloseHandle(out);
     DeleteFileA(file_name);
@@ -2504,7 +2504,7 @@ static void test_DuplicateHandle(void)
 
     r = DuplicateHandle(GetCurrentProcess(), f, GetCurrentProcess(), &out,
             0, FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
-    ok(r, "DuplicateHandle error %u\n", GetLastError());
+    ok(r, "DuplicateHandle error %lu\n", GetLastError());
     todo_wine ok(f != out, "f == out\n");
     CloseHandle(out);
 }
@@ -2519,10 +2519,10 @@ static void _test_completion(int line, HANDLE port, DWORD ekey, ULONG_PTR evalue
 
     ret = GetQueuedCompletionStatus(port, &key, &value, &overlapped, wait);
 
-    ok_(__FILE__, line)(ret, "GetQueuedCompletionStatus: %x\n", GetLastError());
+    ok_(__FILE__, line)(ret, "GetQueuedCompletionStatus: %lx\n", GetLastError());
     if (ret)
     {
-        ok_(__FILE__, line)(key == ekey, "unexpected key %x\n", key);
+        ok_(__FILE__, line)(key == ekey, "unexpected key %lx\n", key);
         ok_(__FILE__, line)(value == evalue, "unexpected value %p\n", (void *)value);
         ok_(__FILE__, line)(overlapped == (LPOVERLAPPED)eoverlapped, "unexpected overlapped %p\n", overlapped);
     }
@@ -2538,7 +2538,7 @@ static void _create_process(int line, const char *command, LPPROCESS_INFORMATION
     sprintf(buffer, "\"%s\" process %s", selfname, command);
 
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, pi);
-    ok_(__FILE__, line)(ret, "CreateProcess error %u\n", GetLastError());
+    ok_(__FILE__, line)(ret, "CreateProcess error %lu\n", GetLastError());
 }
 
 
@@ -2555,39 +2555,39 @@ static void test_IsProcessInJob(void)
     }
 
     job = pCreateJobObjectW(NULL, NULL);
-    ok(job != NULL, "CreateJobObject error %u\n", GetLastError());
+    ok(job != NULL, "CreateJobObject error %lu\n", GetLastError());
 
     job2 = pCreateJobObjectW(NULL, NULL);
-    ok(job2 != NULL, "CreateJobObject error %u\n", GetLastError());
+    ok(job2 != NULL, "CreateJobObject error %lu\n", GetLastError());
 
     create_process("wait", &pi);
 
     out = TRUE;
     ret = pIsProcessInJob(pi.hProcess, job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(!out, "IsProcessInJob returned out=%u\n", out);
 
     out = TRUE;
     ret = pIsProcessInJob(pi.hProcess, job2, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(!out, "IsProcessInJob returned out=%u\n", out);
 
     ret = pAssignProcessToJobObject(job, pi.hProcess);
-    ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+    ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
 
     out = FALSE;
     ret = pIsProcessInJob(pi.hProcess, job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     out = TRUE;
     ret = pIsProcessInJob(pi.hProcess, job2, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(!out, "IsProcessInJob returned out=%u\n", out);
 
     out = FALSE;
     ret = pIsProcessInJob(pi.hProcess, NULL, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     TerminateProcess(pi.hProcess, 0);
@@ -2595,7 +2595,7 @@ static void test_IsProcessInJob(void)
 
     out = FALSE;
     ret = pIsProcessInJob(pi.hProcess, job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     CloseHandle(pi.hProcess);
@@ -2612,25 +2612,25 @@ static void test_TerminateJobObject(void)
     DWORD dwret;
 
     job = pCreateJobObjectW(NULL, NULL);
-    ok(job != NULL, "CreateJobObject error %u\n", GetLastError());
+    ok(job != NULL, "CreateJobObject error %lu\n", GetLastError());
 
     create_process("wait", &pi);
 
     ret = pAssignProcessToJobObject(job, pi.hProcess);
-    ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+    ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
 
     ret = pTerminateJobObject(job, 123);
-    ok(ret, "TerminateJobObject error %u\n", GetLastError());
+    ok(ret, "TerminateJobObject error %lu\n", GetLastError());
 
     /* not wait_child_process() because of the exit code */
     dwret = WaitForSingleObject(pi.hProcess, 1000);
-    ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", dwret);
+    ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %lu\n", dwret);
     if (dwret == WAIT_TIMEOUT) TerminateProcess(pi.hProcess, 0);
 
     ret = GetExitCodeProcess(pi.hProcess, &dwret);
-    ok(ret, "GetExitCodeProcess error %u\n", GetLastError());
+    ok(ret, "GetExitCodeProcess error %lu\n", GetLastError());
     ok(dwret == 123 || broken(dwret == 0) /* randomly fails on Win 2000 / XP */,
-       "wrong exitcode %u\n", dwret);
+       "wrong exitcode %lu\n", dwret);
 
     CloseHandle(pi.hProcess);
     CloseHandle(pi.hThread);
@@ -2664,27 +2664,27 @@ static void test_QueryInformationJobObject(void)
     BOOL ret;
 
     job = pCreateJobObjectW(NULL, NULL);
-    ok(job != NULL, "CreateJobObject error %u\n", GetLastError());
+    ok(job != NULL, "CreateJobObject error %lu\n", GetLastError());
 
     /* Only active processes are returned */
-    sprintf(buffer, "sync kernel32-process-%x", GetCurrentProcessId());
+    sprintf(buffer, "sync kernel32-process-%lx", GetCurrentProcessId());
     sem = CreateSemaphoreA(NULL, 0, 1, buffer + 5);
-    ok(sem != NULL, "CreateSemaphoreA failed le=%u\n", GetLastError());
+    ok(sem != NULL, "CreateSemaphoreA failed le=%lu\n", GetLastError());
     create_process(buffer, &pi[0]);
 
     ret = pAssignProcessToJobObject(job, pi[0].hProcess);
-    ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+    ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
 
     ReleaseSemaphore(sem, 1, NULL);
     wait_and_close_child_process(&pi[0]);
 
     create_process("wait", &pi[0]);
     ret = pAssignProcessToJobObject(job, pi[0].hProcess);
-    ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+    ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
 
     create_process("wait", &pi[1]);
     ret = pAssignProcessToJobObject(job, pi[1].hProcess);
-    ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+    ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = QueryInformationJobObject(job, JobObjectBasicProcessIdList, pid_list,
@@ -2708,7 +2708,7 @@ static void test_QueryInformationJobObject(void)
 
     memset(buf, 0, sizeof(buf));
     ret = pQueryInformationJobObject(job, JobObjectBasicProcessIdList, pid_list, sizeof(buf), &ret_len);
-    ok(ret, "QueryInformationJobObject error %u\n", GetLastError());
+    ok(ret, "QueryInformationJobObject error %lu\n", GetLastError());
     if(ret)
     {
         if (pid_list->NumberOfAssignedProcesses == 3) /* Win 8 */
@@ -2718,7 +2718,7 @@ static void test_QueryInformationJobObject(void)
             ULONG_PTR *list = pid_list->ProcessIdList;
 
             ok(ret_len == FIELD_OFFSET(JOBOBJECT_BASIC_PROCESS_ID_LIST, ProcessIdList[2]),
-               "QueryInformationJobObject returned ret_len=%u\n", ret_len);
+               "QueryInformationJobObject returned ret_len=%lu\n", ret_len);
 
             expect_eq_d(2, pid_list->NumberOfAssignedProcesses);
             expect_eq_d(2, pid_list->NumberOfProcessIdsInList);
@@ -2737,8 +2737,8 @@ static void test_QueryInformationJobObject(void)
     memset(basic_limit_info, 0x11, sizeof(*basic_limit_info));
     ret = pQueryInformationJobObject(job, JobObjectBasicLimitInformation, basic_limit_info,
                                      sizeof(*basic_limit_info), &ret_len);
-    ok(ret, "QueryInformationJobObject error %u\n", GetLastError());
-    ok(ret_len == sizeof(*basic_limit_info), "QueryInformationJobObject returned ret_len=%u\n", ret_len);
+    ok(ret, "QueryInformationJobObject error %lu\n", GetLastError());
+    ok(ret_len == sizeof(*basic_limit_info), "QueryInformationJobObject returned ret_len=%lu\n", ret_len);
     expect_eq_d(0, basic_limit_info->LimitFlags);
 
     /* test JobObjectExtendedLimitInformation */
@@ -2751,15 +2751,15 @@ static void test_QueryInformationJobObject(void)
     memset(&ext_limit_info, 0x11, sizeof(ext_limit_info));
     ret = pQueryInformationJobObject(job, JobObjectExtendedLimitInformation, &ext_limit_info,
                                      sizeof(ext_limit_info), &ret_len);
-    ok(ret, "QueryInformationJobObject error %u\n", GetLastError());
-    ok(ret_len == sizeof(ext_limit_info), "QueryInformationJobObject returned ret_len=%u\n", ret_len);
+    ok(ret, "QueryInformationJobObject error %lu\n", GetLastError());
+    ok(ret_len == sizeof(ext_limit_info), "QueryInformationJobObject returned ret_len=%lu\n", ret_len);
     expect_eq_d(0, basic_limit_info->LimitFlags);
 
     /* test JobObjectBasicAccountingInformation */
     ret = pQueryInformationJobObject(job, JobObjectBasicAccountingInformation, &basic_accounting_info,
                                      sizeof(basic_accounting_info), &ret_len);
-    ok(ret, "QueryInformationJobObject error %u\n", GetLastError());
-    ok(ret_len == sizeof(basic_accounting_info), "QueryInformationJobObject returned ret_len=%u\n", ret_len);
+    ok(ret, "QueryInformationJobObject error %lu\n", GetLastError());
+    ok(ret_len == sizeof(basic_accounting_info), "QueryInformationJobObject returned ret_len=%lu\n", ret_len);
     expect_eq_d(3, basic_accounting_info.TotalProcesses);
     expect_eq_d(2, basic_accounting_info.ActiveProcesses);
 
@@ -2782,24 +2782,24 @@ static void test_CompletionPort(void)
     BOOL ret;
 
     job = pCreateJobObjectW(NULL, NULL);
-    ok(job != NULL, "CreateJobObject error %u\n", GetLastError());
+    ok(job != NULL, "CreateJobObject error %lu\n", GetLastError());
 
     create_process("wait", &pi2);
     ret = pAssignProcessToJobObject(job, pi2.hProcess);
-    ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+    ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
 
     port = pCreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1);
-    ok(port != NULL, "CreateIoCompletionPort error %u\n", GetLastError());
+    ok(port != NULL, "CreateIoCompletionPort error %lu\n", GetLastError());
 
     port_info.CompletionKey = job;
     port_info.CompletionPort = port;
     ret = pSetInformationJobObject(job, JobObjectAssociateCompletionPortInformation, &port_info, sizeof(port_info));
-    ok(ret, "SetInformationJobObject error %u\n", GetLastError());
+    ok(ret, "SetInformationJobObject error %lu\n", GetLastError());
 
     create_process("wait", &pi);
 
     ret = pAssignProcessToJobObject(job, pi.hProcess);
-    ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+    ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
 
     test_completion(port, JOB_OBJECT_MSG_NEW_PROCESS, (DWORD_PTR)job, pi2.dwProcessId, 0);
     test_completion(port, JOB_OBJECT_MSG_NEW_PROCESS, (DWORD_PTR)job, pi.dwProcessId, 0);
@@ -2831,7 +2831,7 @@ static void test_KillOnJobClose(void)
     BOOL ret;
 
     job = pCreateJobObjectW(NULL, NULL);
-    ok(job != NULL, "CreateJobObject error %u\n", GetLastError());
+    ok(job != NULL, "CreateJobObject error %lu\n", GetLastError());
 
     limit_info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
     ret = pSetInformationJobObject(job, JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info));
@@ -2840,18 +2840,18 @@ static void test_KillOnJobClose(void)
         win_skip("Kill on job close limit not available\n");
         return;
     }
-    ok(ret, "SetInformationJobObject error %u\n", GetLastError());
+    ok(ret, "SetInformationJobObject error %lu\n", GetLastError());
 
     create_process("wait", &pi);
 
     ret = pAssignProcessToJobObject(job, pi.hProcess);
-    ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+    ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
 
     CloseHandle(job);
 
     /* not wait_child_process() for the kill */
     dwret = WaitForSingleObject(pi.hProcess, 1000);
-    ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", dwret);
+    ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %lu\n", dwret);
     if (dwret == WAIT_TIMEOUT) TerminateProcess(pi.hProcess, 0);
 
     CloseHandle(pi.hProcess);
@@ -2868,25 +2868,25 @@ static void test_WaitForJobObject(void)
 
     /* test waiting for a job object when the process is killed */
     job = pCreateJobObjectW(NULL, NULL);
-    ok(job != NULL, "CreateJobObject error %u\n", GetLastError());
+    ok(job != NULL, "CreateJobObject error %lu\n", GetLastError());
 
     dwret = WaitForSingleObject(job, 100);
-    ok(dwret == WAIT_TIMEOUT, "WaitForSingleObject returned %u\n", dwret);
+    ok(dwret == WAIT_TIMEOUT, "WaitForSingleObject returned %lu\n", dwret);
 
     create_process("wait", &pi);
 
     ret = pAssignProcessToJobObject(job, pi.hProcess);
-    ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+    ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
 
     dwret = WaitForSingleObject(job, 100);
-    ok(dwret == WAIT_TIMEOUT, "WaitForSingleObject returned %u\n", dwret);
+    ok(dwret == WAIT_TIMEOUT, "WaitForSingleObject returned %lu\n", dwret);
 
     ret = pTerminateJobObject(job, 123);
-    ok(ret, "TerminateJobObject error %u\n", GetLastError());
+    ok(ret, "TerminateJobObject error %lu\n", GetLastError());
 
     dwret = WaitForSingleObject(job, 500);
     ok(dwret == WAIT_OBJECT_0 || broken(dwret == WAIT_TIMEOUT),
-       "WaitForSingleObject returned %u\n", dwret);
+       "WaitForSingleObject returned %lu\n", dwret);
 
     if (dwret == WAIT_TIMEOUT) /* Win 2000/XP */
     {
@@ -2899,7 +2899,7 @@ static void test_WaitForJobObject(void)
 
     /* the object is not reset immediately */
     dwret = WaitForSingleObject(job, 100);
-    ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", dwret);
+    ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %lu\n", dwret);
 
     CloseHandle(pi.hProcess);
     CloseHandle(pi.hThread);
@@ -2908,13 +2908,13 @@ static void test_WaitForJobObject(void)
     create_process("wait", &pi);
 
     ret = pAssignProcessToJobObject(job, pi.hProcess);
-    ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+    ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
 
     dwret = WaitForSingleObject(job, 100);
-    ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", dwret);
+    ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %lu\n", dwret);
 
     ret = pTerminateJobObject(job, 123);
-    ok(ret, "TerminateJobObject error %u\n", GetLastError());
+    ok(ret, "TerminateJobObject error %lu\n", GetLastError());
 
     CloseHandle(pi.hProcess);
     CloseHandle(pi.hThread);
@@ -2923,22 +2923,22 @@ static void test_WaitForJobObject(void)
 
     /* repeat the test, but this time the process terminates properly */
     job = pCreateJobObjectW(NULL, NULL);
-    ok(job != NULL, "CreateJobObject error %u\n", GetLastError());
+    ok(job != NULL, "CreateJobObject error %lu\n", GetLastError());
 
     dwret = WaitForSingleObject(job, 100);
-    ok(dwret == WAIT_TIMEOUT, "WaitForSingleObject returned %u\n", dwret);
+    ok(dwret == WAIT_TIMEOUT, "WaitForSingleObject returned %lu\n", dwret);
 
-    sprintf(buffer, "sync kernel32-process-%x", GetCurrentProcessId());
+    sprintf(buffer, "sync kernel32-process-%lx", GetCurrentProcessId());
     sem = CreateSemaphoreA(NULL, 0, 1, buffer + 5);
-    ok(sem != NULL, "CreateSemaphoreA failed le=%u\n", GetLastError());
+    ok(sem != NULL, "CreateSemaphoreA failed le=%lu\n", GetLastError());
     create_process(buffer, &pi);
 
     ret = pAssignProcessToJobObject(job, pi.hProcess);
-    ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+    ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
     ReleaseSemaphore(sem, 1, NULL);
 
     dwret = WaitForSingleObject(job, 100);
-    ok(dwret == WAIT_TIMEOUT, "WaitForSingleObject returned %u\n", dwret);
+    ok(dwret == WAIT_TIMEOUT, "WaitForSingleObject returned %lu\n", dwret);
 
     wait_and_close_child_process(&pi);
     CloseHandle(job);
@@ -2951,10 +2951,10 @@ static HANDLE test_AddSelfToJob(void)
     BOOL ret;
 
     job = pCreateJobObjectW(NULL, NULL);
-    ok(job != NULL, "CreateJobObject error %u\n", GetLastError());
+    ok(job != NULL, "CreateJobObject error %lu\n", GetLastError());
 
     ret = pAssignProcessToJobObject(job, GetCurrentProcess());
-    ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+    ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
 
     return job;
 }
@@ -2974,7 +2974,7 @@ static void test_jobInheritance(HANDLE job)
 
     out = FALSE;
     ret = pIsProcessInJob(pi.hProcess, job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     wait_and_close_child_process(&pi);
@@ -2996,11 +2996,11 @@ static void test_BreakawayOk(HANDLE parent_job)
     }
 
     job = pCreateJobObjectW(NULL, NULL);
-    ok(!!job, "CreateJobObjectW error %u\n", GetLastError());
+    ok(!!job, "CreateJobObjectW error %lu\n", GetLastError());
 
     ret = pAssignProcessToJobObject(job, GetCurrentProcess());
     ok(ret || broken(!ret && GetLastError() == ERROR_ACCESS_DENIED) /* before Win 8. */,
-            "AssignProcessToJobObject error %u\n", GetLastError());
+            "AssignProcessToJobObject error %lu\n", GetLastError());
     nested_jobs = ret;
     if (!ret)
         win_skip("Nested jobs are not supported.\n");
@@ -3020,18 +3020,18 @@ static void test_BreakawayOk(HANDLE parent_job)
     {
         limit_info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_BREAKAWAY_OK;
         ret = pSetInformationJobObject(job, JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info));
-        ok(ret, "SetInformationJobObject error %u\n", GetLastError());
+        ok(ret, "SetInformationJobObject error %lu\n", GetLastError());
 
         sprintf(buffer, "\"%s\" process exit", selfname);
         ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &si, &pi);
-        ok(ret, "CreateProcessA error %u\n", GetLastError());
+        ok(ret, "CreateProcessA error %lu\n", GetLastError());
 
         ret = pIsProcessInJob(pi.hProcess, job, &out);
-        ok(ret, "IsProcessInJob error %u\n", GetLastError());
+        ok(ret, "IsProcessInJob error %lu\n", GetLastError());
         ok(!out, "IsProcessInJob returned out=%u\n", out);
 
         ret = pIsProcessInJob(pi.hProcess, parent_job, &out);
-        ok(ret, "IsProcessInJob error %u\n", GetLastError());
+        ok(ret, "IsProcessInJob error %lu\n", GetLastError());
         ok(out, "IsProcessInJob returned out=%u\n", out);
 
         TerminateProcess(pi.hProcess, 0);
@@ -3040,30 +3040,30 @@ static void test_BreakawayOk(HANDLE parent_job)
 
     limit_info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_BREAKAWAY_OK;
     ret = pSetInformationJobObject(parent_job, JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info));
-    ok(ret, "SetInformationJobObject error %u\n", GetLastError());
+    ok(ret, "SetInformationJobObject error %lu\n", GetLastError());
 
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcessA error %u\n", GetLastError());
+    ok(ret, "CreateProcessA error %lu\n", GetLastError());
 
     ret = pIsProcessInJob(pi.hProcess, job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(!out, "IsProcessInJob returned out=%u\n", out);
 
     ret = pIsProcessInJob(pi.hProcess, parent_job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(!out, "IsProcessInJob returned out=%u\n", out);
 
     wait_and_close_child_process(&pi);
 
     limit_info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK;
     ret = pSetInformationJobObject(job, JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info));
-    ok(ret, "SetInformationJobObject error %u\n", GetLastError());
+    ok(ret, "SetInformationJobObject error %lu\n", GetLastError());
 
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-    ok(ret, "CreateProcess error %u\n", GetLastError());
+    ok(ret, "CreateProcess error %lu\n", GetLastError());
 
     ret = pIsProcessInJob(pi.hProcess, job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(!out, "IsProcessInJob returned out=%u\n", out);
 
     wait_and_close_child_process(&pi);
@@ -3071,7 +3071,7 @@ static void test_BreakawayOk(HANDLE parent_job)
     /* unset breakaway ok */
     limit_info.BasicLimitInformation.LimitFlags = 0;
     ret = pSetInformationJobObject(job, JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info));
-    ok(ret, "SetInformationJobObject error %u\n", GetLastError());
+    ok(ret, "SetInformationJobObject error %lu\n", GetLastError());
 }
 
 static void test_StartupNoConsole(void)
@@ -3202,7 +3202,7 @@ static BOOL are_imports_resolved(HANDLE process_handle, PVOID module_base, IMAGE
     ret = ReadProcessMemory(process_handle,
                             (char *)module_base + nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress,
                             &iid, sizeof(iid), NULL);
-    ok(ret, "Failed to read remote module IID (%d)\n", GetLastError());
+    ok(ret, "Failed to read remote module IID (%ld)\n", GetLastError());
 
     /* Validate the IID is present and not a bound import, and that we have
        an OriginalFirstThunk to compare with */
@@ -3214,13 +3214,13 @@ static BOOL are_imports_resolved(HANDLE process_handle, PVOID module_base, IMAGE
     /* Read a single IAT entry from the FirstThunk */
     ret = ReadProcessMemory(process_handle, (char *)module_base + iid.FirstThunk,
                             &iat_entry_value, sizeof(iat_entry_value), NULL);
-    ok(ret, "Failed to read IAT entry from FirstThunk (%d)\n", GetLastError());
+    ok(ret, "Failed to read IAT entry from FirstThunk (%ld)\n", GetLastError());
     ok(iat_entry_value, "IAT entry in FirstThunk is NULL\n");
 
     /* Read a single IAT entry from the OriginalFirstThunk */
     ret = ReadProcessMemory(process_handle, (char *)module_base + iid.OriginalFirstThunk,
                             &orig_iat_entry_value, sizeof(orig_iat_entry_value), NULL);
-    ok(ret, "Failed to read IAT entry from OriginalFirstThunk (%d)\n", GetLastError());
+    ok(ret, "Failed to read IAT entry from OriginalFirstThunk (%ld)\n", GetLastError());
     ok(orig_iat_entry_value, "IAT entry in OriginalFirstThunk is NULL\n");
 
     return iat_entry_value != orig_iat_entry_value;
@@ -3242,7 +3242,7 @@ static void test_SuspendProcessNewThread(void)
 
     si.cb = sizeof(si);
     ret = CreateProcessA(NULL, selfname, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi);
-    ok(ret, "Failed to create process (%d)\n", GetLastError());
+    ok(ret, "Failed to create process (%ld)\n", GetLastError());
 
     exe_base = get_process_exe(pi.hProcess, &nt_header);
     ok(exe_base != NULL, "Could not find EXE in remote process\n");
@@ -3253,58 +3253,58 @@ static void test_SuspendProcessNewThread(void)
     thread_handle = CreateRemoteThread(pi.hProcess, NULL, 0,
                                        (LPTHREAD_START_ROUTINE)exit_thread_ptr,
                                        (PVOID)(ULONG_PTR)0x1234, CREATE_SUSPENDED, NULL);
-    ok(thread_handle != NULL, "Could not create remote thread (%d)\n", GetLastError());
+    ok(thread_handle != NULL, "Could not create remote thread (%ld)\n", GetLastError());
 
     ret = are_imports_resolved(pi.hProcess, exe_base, &nt_header);
     ok(!ret, "IAT entry resolved prematurely\n");
 
     ctx.ContextFlags = CONTEXT_ALL;
     ret = GetThreadContext( thread_handle, &ctx );
-    ok( ret, "Failed retrieving remote thread context (%d)\n", GetLastError() );
-    ok( ctx.ContextFlags == CONTEXT_ALL, "wrong flags %x\n", ctx.ContextFlags );
+    ok( ret, "Failed retrieving remote thread context (%ld)\n", GetLastError() );
+    ok( ctx.ContextFlags == CONTEXT_ALL, "wrong flags %lx\n", ctx.ContextFlags );
 #ifdef __x86_64__
-    ok( !ctx.Rax, "rax is not zero %lx\n", ctx.Rax );
-    ok( !ctx.Rbx, "rbx is not zero %lx\n", ctx.Rbx );
-    ok( ctx.Rcx == (ULONG_PTR)exit_thread_ptr, "wrong rcx %lx/%p\n", ctx.Rcx, exit_thread_ptr );
-    ok( ctx.Rdx == 0x1234, "wrong rdx %lx\n", ctx.Rdx );
-    ok( !ctx.Rsi, "rsi is not zero %lx\n", ctx.Rsi );
-    ok( !ctx.Rdi, "rdi is not zero %lx\n", ctx.Rdi );
-    ok( !ctx.Rbp, "rbp is not zero %lx\n", ctx.Rbp );
-    ok( !ctx.R8, "r8 is not zero %lx\n", ctx.R8 );
-    ok( !ctx.R9, "r9 is not zero %lx\n", ctx.R9 );
-    ok( !ctx.R10, "r10 is not zero %lx\n", ctx.R10 );
-    ok( !ctx.R11, "r11 is not zero %lx\n", ctx.R11 );
-    ok( !ctx.R12, "r12 is not zero %lx\n", ctx.R12 );
-    ok( !ctx.R13, "r13 is not zero %lx\n", ctx.R13 );
-    ok( !ctx.R14, "r14 is not zero %lx\n", ctx.R14 );
-    ok( !ctx.R15, "r15 is not zero %lx\n", ctx.R15 );
-    ok( !((ctx.Rsp + 0x28) & 0xfff), "rsp is not at top of stack page %lx\n", ctx.Rsp );
-    ok( ctx.EFlags == 0x200, "wrong flags %08x\n", ctx.EFlags );
-    ok( ctx.MxCsr == 0x1f80, "wrong mxcsr %08x\n", ctx.MxCsr );
+    ok( !ctx.Rax, "rax is not zero %Ix\n", ctx.Rax );
+    ok( !ctx.Rbx, "rbx is not zero %Ix\n", ctx.Rbx );
+    ok( ctx.Rcx == (ULONG_PTR)exit_thread_ptr, "wrong rcx %Ix/%p\n", ctx.Rcx, exit_thread_ptr );
+    ok( ctx.Rdx == 0x1234, "wrong rdx %Ix\n", ctx.Rdx );
+    ok( !ctx.Rsi, "rsi is not zero %Ix\n", ctx.Rsi );
+    ok( !ctx.Rdi, "rdi is not zero %Ix\n", ctx.Rdi );
+    ok( !ctx.Rbp, "rbp is not zero %Ix\n", ctx.Rbp );
+    ok( !ctx.R8, "r8 is not zero %Ix\n", ctx.R8 );
+    ok( !ctx.R9, "r9 is not zero %Ix\n", ctx.R9 );
+    ok( !ctx.R10, "r10 is not zero %Ix\n", ctx.R10 );
+    ok( !ctx.R11, "r11 is not zero %Ix\n", ctx.R11 );
+    ok( !ctx.R12, "r12 is not zero %Ix\n", ctx.R12 );
+    ok( !ctx.R13, "r13 is not zero %Ix\n", ctx.R13 );
+    ok( !ctx.R14, "r14 is not zero %Ix\n", ctx.R14 );
+    ok( !ctx.R15, "r15 is not zero %Ix\n", ctx.R15 );
+    ok( !((ctx.Rsp + 0x28) & 0xfff), "rsp is not at top of stack page %Ix\n", ctx.Rsp );
+    ok( ctx.EFlags == 0x200, "wrong flags %08lx\n", ctx.EFlags );
+    ok( ctx.MxCsr == 0x1f80, "wrong mxcsr %08lx\n", ctx.MxCsr );
     ok( ctx.FltSave.ControlWord == 0x27f, "wrong control %08x\n", ctx.FltSave.ControlWord );
 #else
-    ok( !ctx.Ebp || broken(ctx.Ebp), /* winxp */ "ebp is not zero %08x\n", ctx.Ebp );
+    ok( !ctx.Ebp || broken(ctx.Ebp), /* winxp */ "ebp is not zero %08lx\n", ctx.Ebp );
     if (!ctx.Ebp)  /* winxp is completely different */
     {
-        ok( !ctx.Ecx, "ecx is not zero %08x\n", ctx.Ecx );
-        ok( !ctx.Edx, "edx is not zero %08x\n", ctx.Edx );
-        ok( !ctx.Esi, "esi is not zero %08x\n", ctx.Esi );
-        ok( !ctx.Edi, "edi is not zero %08x\n", ctx.Edi );
+        ok( !ctx.Ecx, "ecx is not zero %08lx\n", ctx.Ecx );
+        ok( !ctx.Edx, "edx is not zero %08lx\n", ctx.Edx );
+        ok( !ctx.Esi, "esi is not zero %08lx\n", ctx.Esi );
+        ok( !ctx.Edi, "edi is not zero %08lx\n", ctx.Edi );
     }
-    ok( ctx.Eax == (ULONG_PTR)exit_thread_ptr, "wrong eax %08x/%p\n", ctx.Eax, exit_thread_ptr );
-    ok( ctx.Ebx == 0x1234, "wrong ebx %08x\n", ctx.Ebx );
+    ok( ctx.Eax == (ULONG_PTR)exit_thread_ptr, "wrong eax %08lx/%p\n", ctx.Eax, exit_thread_ptr );
+    ok( ctx.Ebx == 0x1234, "wrong ebx %08lx\n", ctx.Ebx );
     ok( !((ctx.Esp + 0x10) & 0xfff) || broken( !((ctx.Esp + 4) & 0xfff) ), /* winxp, w2k3 */
-        "esp is not at top of stack page or properly aligned: %08x\n", ctx.Esp );
-    ok( (ctx.EFlags & ~2) == 0x200, "wrong flags %08x\n", ctx.EFlags );
-    ok( (WORD)ctx.FloatSave.ControlWord == 0x27f, "wrong control %08x\n", ctx.FloatSave.ControlWord );
+        "esp is not at top of stack page or properly aligned: %08lx\n", ctx.Esp );
+    ok( (ctx.EFlags & ~2) == 0x200, "wrong flags %08lx\n", ctx.EFlags );
+    ok( (WORD)ctx.FloatSave.ControlWord == 0x27f, "wrong control %08lx\n", ctx.FloatSave.ControlWord );
     ok( *(WORD *)ctx.ExtendedRegisters == 0x27f, "wrong control %08x\n", *(WORD *)ctx.ExtendedRegisters );
 #endif
 
     ResumeThread( thread_handle );
     dret = WaitForSingleObject(thread_handle, 60000);
-    ok(dret == WAIT_OBJECT_0, "Waiting for remote thread failed (%d)\n", GetLastError());
+    ok(dret == WAIT_OBJECT_0, "Waiting for remote thread failed (%ld)\n", GetLastError());
     ret = GetExitCodeThread(thread_handle, &exit_code);
-    ok(ret, "Failed to retrieve remote thread exit code (%d)\n", GetLastError());
+    ok(ret, "Failed to retrieve remote thread exit code (%ld)\n", GetLastError());
     ok(exit_code == 0x1234, "Invalid remote thread exit code\n");
 
     ret = are_imports_resolved(pi.hProcess, exe_base, &nt_header);
@@ -3383,7 +3383,7 @@ static void test_SuspendProcessState(void)
 
     si.cb = sizeof(si);
     ret = CreateProcessA(NULL, selfname, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi);
-    ok(ret, "Failed to create process (%d)\n", GetLastError());
+    ok(ret, "Failed to create process (%ld)\n", GetLastError());
 
     exe_base = get_process_exe(pi.hProcess, &nt_header);
     /* Make sure we found the EXE in the new process */
@@ -3395,16 +3395,16 @@ static void test_SuspendProcessState(void)
     server_pipe_handle = CreateNamedPipeA(pipe_name, PIPE_ACCESS_DUPLEX | FILE_FLAG_WRITE_THROUGH,
                                         PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, 1, 0x20000, 0x20000,
                                         0, NULL);
-    ok(server_pipe_handle != INVALID_HANDLE_VALUE, "Failed to create communication pipe (%d)\n", GetLastError());
+    ok(server_pipe_handle != INVALID_HANDLE_VALUE, "Failed to create communication pipe (%ld)\n", GetLastError());
 
     /* Set up the remote process environment */
     ctx.ContextFlags = CONTEXT_ALL;
     ret = GetThreadContext(pi.hThread, &ctx);
-    ok(ret, "Failed retrieving remote thread context (%d)\n", GetLastError());
-    ok( ctx.ContextFlags == CONTEXT_ALL, "wrong flags %x\n", ctx.ContextFlags );
+    ok(ret, "Failed retrieving remote thread context (%ld)\n", GetLastError());
+    ok( ctx.ContextFlags == CONTEXT_ALL, "wrong flags %lx\n", ctx.ContextFlags );
 
     remote_pipe_params = VirtualAllocEx(pi.hProcess, NULL, sizeof(pipe_params), MEM_COMMIT, PAGE_READWRITE);
-    ok(remote_pipe_params != NULL, "Failed allocating memory in remote process (%d)\n", GetLastError());
+    ok(remote_pipe_params != NULL, "Failed allocating memory in remote process (%ld)\n", GetLastError());
 
     pipe_params.pipe_write_buf = pipe_write_magic;
     pipe_params.pipe_read_buf = 0;
@@ -3413,25 +3413,25 @@ static void test_SuspendProcessState(void)
 
     ret = WriteProcessMemory(pi.hProcess, remote_pipe_params,
                              &pipe_params, sizeof(pipe_params), NULL);
-    ok(ret, "Failed to write to remote process memory (%d)\n", GetLastError());
+    ok(ret, "Failed to write to remote process memory (%ld)\n", GetLastError());
 
 #ifdef __x86_64__
-    ok( !ctx.Rax, "rax is not zero %lx\n", ctx.Rax );
-    ok( !ctx.Rbx, "rbx is not zero %lx\n", ctx.Rbx );
-    ok( !ctx.Rsi, "rsi is not zero %lx\n", ctx.Rsi );
-    ok( !ctx.Rdi, "rdi is not zero %lx\n", ctx.Rdi );
-    ok( !ctx.Rbp, "rbp is not zero %lx\n", ctx.Rbp );
-    ok( !ctx.R8, "r8 is not zero %lx\n", ctx.R8 );
-    ok( !ctx.R9, "r9 is not zero %lx\n", ctx.R9 );
-    ok( !ctx.R10, "r10 is not zero %lx\n", ctx.R10 );
-    ok( !ctx.R11, "r11 is not zero %lx\n", ctx.R11 );
-    ok( !ctx.R12, "r12 is not zero %lx\n", ctx.R12 );
-    ok( !ctx.R13, "r13 is not zero %lx\n", ctx.R13 );
-    ok( !ctx.R14, "r14 is not zero %lx\n", ctx.R14 );
-    ok( !ctx.R15, "r15 is not zero %lx\n", ctx.R15 );
-    ok( !((ctx.Rsp + 0x28) & 0xfff), "rsp is not at top of stack page %lx\n", ctx.Rsp );
-    ok( ctx.EFlags == 0x200, "wrong flags %08x\n", ctx.EFlags );
-    ok( ctx.MxCsr == 0x1f80, "wrong mxcsr %08x\n", ctx.MxCsr );
+    ok( !ctx.Rax, "rax is not zero %Ix\n", ctx.Rax );
+    ok( !ctx.Rbx, "rbx is not zero %Ix\n", ctx.Rbx );
+    ok( !ctx.Rsi, "rsi is not zero %Ix\n", ctx.Rsi );
+    ok( !ctx.Rdi, "rdi is not zero %Ix\n", ctx.Rdi );
+    ok( !ctx.Rbp, "rbp is not zero %Ix\n", ctx.Rbp );
+    ok( !ctx.R8, "r8 is not zero %Ix\n", ctx.R8 );
+    ok( !ctx.R9, "r9 is not zero %Ix\n", ctx.R9 );
+    ok( !ctx.R10, "r10 is not zero %Ix\n", ctx.R10 );
+    ok( !ctx.R11, "r11 is not zero %Ix\n", ctx.R11 );
+    ok( !ctx.R12, "r12 is not zero %Ix\n", ctx.R12 );
+    ok( !ctx.R13, "r13 is not zero %Ix\n", ctx.R13 );
+    ok( !ctx.R14, "r14 is not zero %Ix\n", ctx.R14 );
+    ok( !ctx.R15, "r15 is not zero %Ix\n", ctx.R15 );
+    ok( !((ctx.Rsp + 0x28) & 0xfff), "rsp is not at top of stack page %Ix\n", ctx.Rsp );
+    ok( ctx.EFlags == 0x200, "wrong flags %08lx\n", ctx.EFlags );
+    ok( ctx.MxCsr == 0x1f80, "wrong mxcsr %08lx\n", ctx.MxCsr );
     ok( ctx.FltSave.ControlWord == 0x27f, "wrong control %08x\n", ctx.FltSave.ControlWord );
     start_ptr = (void *)ctx.Rip;
     entry_ptr = (void *)ctx.Rcx;
@@ -3449,20 +3449,20 @@ static void test_SuspendProcessState(void)
     ctx.Rip = (ULONG_PTR)call_named_pipe_a;
     ctx.Rsp -= sizeof(rop_chain);
     ret = WriteProcessMemory(pi.hProcess, (void *)ctx.Rsp, &rop_chain, sizeof(rop_chain), NULL);
-    ok(ret, "Failed to write to remote process thread stack (%d)\n", GetLastError());
+    ok(ret, "Failed to write to remote process thread stack (%ld)\n", GetLastError());
 #else
-    ok( !ctx.Ebp || broken(ctx.Ebp), /* winxp */ "ebp is not zero %08x\n", ctx.Ebp );
+    ok( !ctx.Ebp || broken(ctx.Ebp), /* winxp */ "ebp is not zero %08lx\n", ctx.Ebp );
     if (!ctx.Ebp)  /* winxp is completely different */
     {
-        ok( !ctx.Ecx, "ecx is not zero %08x\n", ctx.Ecx );
-        ok( !ctx.Edx, "edx is not zero %08x\n", ctx.Edx );
-        ok( !ctx.Esi, "esi is not zero %08x\n", ctx.Esi );
-        ok( !ctx.Edi, "edi is not zero %08x\n", ctx.Edi );
+        ok( !ctx.Ecx, "ecx is not zero %08lx\n", ctx.Ecx );
+        ok( !ctx.Edx, "edx is not zero %08lx\n", ctx.Edx );
+        ok( !ctx.Esi, "esi is not zero %08lx\n", ctx.Esi );
+        ok( !ctx.Edi, "edi is not zero %08lx\n", ctx.Edi );
     }
     ok( !((ctx.Esp + 0x10) & 0xfff) || broken( !((ctx.Esp + 4) & 0xfff) ), /* winxp, w2k3 */
-        "esp is not at top of stack page or properly aligned: %08x\n", ctx.Esp );
-    ok( (ctx.EFlags & ~2) == 0x200, "wrong flags %08x\n", ctx.EFlags );
-    ok( (WORD)ctx.FloatSave.ControlWord == 0x27f, "wrong control %08x\n", ctx.FloatSave.ControlWord );
+        "esp is not at top of stack page or properly aligned: %08lx\n", ctx.Esp );
+    ok( (ctx.EFlags & ~2) == 0x200, "wrong flags %08lx\n", ctx.EFlags );
+    ok( (WORD)ctx.FloatSave.ControlWord == 0x27f, "wrong control %08lx\n", ctx.FloatSave.ControlWord );
     ok( *(WORD *)ctx.ExtendedRegisters == 0x27f, "wrong control %08x\n", *(WORD *)ctx.ExtendedRegisters );
     start_ptr = (void *)ctx.Eip;
     entry_ptr = (void *)ctx.Eax;
@@ -3481,11 +3481,11 @@ static void test_SuspendProcessState(void)
     ctx.Eip = (ULONG_PTR)call_named_pipe_a;
     ctx.Esp -= sizeof(rop_chain);
     ret = WriteProcessMemory(pi.hProcess, (void *)ctx.Esp, &rop_chain, sizeof(rop_chain), NULL);
-    ok(ret, "Failed to write to remote process thread stack (%d)\n", GetLastError());
+    ok(ret, "Failed to write to remote process thread stack (%ld)\n", GetLastError());
 #endif
 
     ret = ReadProcessMemory( pi.hProcess, peb_ptr, &child_peb, sizeof(child_peb), NULL );
-    ok( ret, "Failed to read PEB (%u)\n", GetLastError() );
+    ok( ret, "Failed to read PEB (%lu)\n", GetLastError() );
     ok( child_peb.ImageBaseAddress == exe_base, "wrong base %p/%p\n",
         child_peb.ImageBaseAddress, exe_base );
     user_thread_start = GetProcAddress( GetModuleHandleA("ntdll.dll"), "RtlUserThreadStart" );
@@ -3504,19 +3504,19 @@ static void test_SuspendProcessState(void)
     ok( !child_peb.ProcessHeap, "ProcessHeap set %p\n", child_peb.ProcessHeap );
     ok( !child_peb.CSDVersion.Buffer, "CSDVersion set %s\n", debugstr_w(child_peb.CSDVersion.Buffer) );
 
-    ok( child_peb.OSMajorVersion == peb->OSMajorVersion, "OSMajorVersion not set %u\n", child_peb.OSMajorVersion );
-    ok( child_peb.OSPlatformId == peb->OSPlatformId, "OSPlatformId not set %u\n", child_peb.OSPlatformId );
-    ok( child_peb.SessionId == peb->SessionId, "SessionId not set %u\n", child_peb.SessionId );
+    ok( child_peb.OSMajorVersion == peb->OSMajorVersion, "OSMajorVersion not set %lu\n", child_peb.OSMajorVersion );
+    ok( child_peb.OSPlatformId == peb->OSPlatformId, "OSPlatformId not set %lu\n", child_peb.OSPlatformId );
+    ok( child_peb.SessionId == peb->SessionId, "SessionId not set %lu\n", child_peb.SessionId );
     ok( child_peb.CriticalSectionTimeout.QuadPart, "CriticalSectionTimeout not set %s\n",
         wine_dbgstr_longlong(child_peb.CriticalSectionTimeout.QuadPart) );
     ok( child_peb.HeapSegmentReserve == peb->HeapSegmentReserve,
-        "HeapSegmentReserve not set %lu\n", child_peb.HeapSegmentReserve );
+        "HeapSegmentReserve not set %Iu\n", child_peb.HeapSegmentReserve );
     ok( child_peb.HeapSegmentCommit == peb->HeapSegmentCommit,
-        "HeapSegmentCommit not set %lu\n", child_peb.HeapSegmentCommit );
+        "HeapSegmentCommit not set %Iu\n", child_peb.HeapSegmentCommit );
     ok( child_peb.HeapDeCommitTotalFreeThreshold == peb->HeapDeCommitTotalFreeThreshold,
-        "HeapDeCommitTotalFreeThreshold not set %lu\n", child_peb.HeapDeCommitTotalFreeThreshold );
+        "HeapDeCommitTotalFreeThreshold not set %Iu\n", child_peb.HeapDeCommitTotalFreeThreshold );
     ok( child_peb.HeapDeCommitFreeBlockThreshold == peb->HeapDeCommitFreeBlockThreshold,
-        "HeapDeCommitFreeBlockThreshold not set %lu\n", child_peb.HeapDeCommitFreeBlockThreshold );
+        "HeapDeCommitFreeBlockThreshold not set %Iu\n", child_peb.HeapDeCommitFreeBlockThreshold );
 
     if (pNtQueryInformationThread)
     {
@@ -3524,25 +3524,25 @@ static void test_SuspendProcessState(void)
         THREAD_BASIC_INFORMATION info;
         NTSTATUS status = pNtQueryInformationThread( pi.hThread, ThreadBasicInformation,
                                                      &info, sizeof(info), NULL );
-        ok( !status, "NtQueryInformationProcess failed %x\n", status );
+        ok( !status, "NtQueryInformationProcess failed %lx\n", status );
         ret = ReadProcessMemory( pi.hProcess, info.TebBaseAddress, &child_teb, sizeof(child_teb), NULL );
-        ok( ret, "Failed to read TEB (%u)\n", GetLastError() );
+        ok( ret, "Failed to read TEB (%lu)\n", GetLastError() );
 
         ok( child_teb.Peb == peb_ptr, "wrong Peb %p / %p\n", child_teb.Peb, peb_ptr );
-        ok( PtrToUlong(child_teb.ClientId.UniqueProcess) == pi.dwProcessId, "wrong pid %x / %x\n",
+        ok( PtrToUlong(child_teb.ClientId.UniqueProcess) == pi.dwProcessId, "wrong pid %lx / %lx\n",
             PtrToUlong(child_teb.ClientId.UniqueProcess), pi.dwProcessId );
-        ok( PtrToUlong(child_teb.ClientId.UniqueThread) == pi.dwThreadId, "wrong tid %x / %x\n",
+        ok( PtrToUlong(child_teb.ClientId.UniqueThread) == pi.dwThreadId, "wrong tid %lx / %lx\n",
             PtrToUlong(child_teb.ClientId.UniqueThread), pi.dwThreadId );
-        ok( PtrToUlong(child_teb.RealClientId.UniqueProcess) == pi.dwProcessId, "wrong real pid %x / %x\n",
+        ok( PtrToUlong(child_teb.RealClientId.UniqueProcess) == pi.dwProcessId, "wrong real pid %lx / %lx\n",
             PtrToUlong(child_teb.RealClientId.UniqueProcess), pi.dwProcessId );
-        ok( PtrToUlong(child_teb.RealClientId.UniqueThread) == pi.dwThreadId, "wrong real tid %x / %x\n",
+        ok( PtrToUlong(child_teb.RealClientId.UniqueThread) == pi.dwThreadId, "wrong real tid %lx / %lx\n",
             PtrToUlong(child_teb.RealClientId.UniqueThread), pi.dwThreadId );
         ok( child_teb.StaticUnicodeString.MaximumLength == sizeof(child_teb.StaticUnicodeBuffer),
             "StaticUnicodeString.MaximumLength wrong %x\n", child_teb.StaticUnicodeString.MaximumLength );
         ok( (char *)child_teb.StaticUnicodeString.Buffer == (char *)info.TebBaseAddress + offsetof(TEB, StaticUnicodeBuffer),
             "StaticUnicodeString.Buffer wrong %p\n", child_teb.StaticUnicodeString.Buffer );
 
-        ok( !child_teb.CurrentLocale, "CurrentLocale set %x\n", child_teb.CurrentLocale );
+        ok( !child_teb.CurrentLocale, "CurrentLocale set %lx\n", child_teb.CurrentLocale );
         ok( !child_teb.TlsLinks.Flink, "TlsLinks.Flink set %p\n", child_teb.TlsLinks.Flink );
         ok( !child_teb.TlsLinks.Blink, "TlsLinks.Blink set %p\n", child_teb.TlsLinks.Blink );
         ok( !child_teb.TlsExpansionSlots, "TlsExpansionSlots set %p\n", child_teb.TlsExpansionSlots );
@@ -3550,7 +3550,7 @@ static void test_SuspendProcessState(void)
     }
 
     ret = SetThreadContext(pi.hThread, &ctx);
-    ok(ret, "Failed to set remote thread context (%d)\n", GetLastError());
+    ok(ret, "Failed to set remote thread context (%ld)\n", GetLastError());
 
     ResumeThread(pi.hThread);
 
@@ -3558,7 +3558,7 @@ static void test_SuspendProcessState(void)
     ok(pipe_connected, "Pipe did not connect\n");
 
     ret = ReadFile(server_pipe_handle, &pipe_magic, sizeof(pipe_magic), &numb, NULL);
-    ok(ret, "Failed to read buffer from pipe (%d)\n", GetLastError());
+    ok(ret, "Failed to read buffer from pipe (%ld)\n", GetLastError());
 
     ok(pipe_magic == pipe_write_magic, "Did not get the correct magic from the remote process\n");
 
@@ -3570,7 +3570,7 @@ static void test_SuspendProcessState(void)
     ok(ret, "EXE IAT is not resolved\n");
 
     ret = WriteFile(server_pipe_handle, &pipe_magic, sizeof(pipe_magic), &numb, NULL);
-    ok(ret, "Failed to write the magic back to the pipe (%d)\n", GetLastError());
+    ok(ret, "Failed to write the magic back to the pipe (%ld)\n", GetLastError());
     CloseHandle(server_pipe_handle);
 
     /* Avoid wait_child_process() because the exit code results from a race
@@ -3672,7 +3672,7 @@ static void test_GetNumaProcessorNode(void)
         {
             ok(!ret, "GetNumaProcessorNode returned TRUE for processor %d\n", i);
             ok(node == 0xFF || broken(node == 0xAA) /* WinXP */, "expected node 0xFF, got %x\n", node);
-            ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+            ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
         }
     }
 }
@@ -3683,11 +3683,11 @@ static void test_session_info(void)
     BOOL r;
 
     r = ProcessIdToSessionId(GetCurrentProcessId(), &session_id);
-    ok(r, "ProcessIdToSessionId failed: %u\n", GetLastError());
-    trace("session_id = %x\n", session_id);
+    ok(r, "ProcessIdToSessionId failed: %lu\n", GetLastError());
+    trace("session_id = %lx\n", session_id);
 
     active_session = pWTSGetActiveConsoleSessionId();
-    trace("active_session = %x\n", active_session);
+    trace("active_session = %lx\n", active_session);
 }
 
 static void test_process_info(HANDLE hproc)
@@ -3805,46 +3805,46 @@ static void test_process_info(HANDLE hproc)
         case ProcessImageInformation:
         case ProcessPagePriority:
         case ProcessImageFileNameWin32:
-            ok(status == STATUS_SUCCESS, "for info %u expected STATUS_SUCCESS, got %08x (ret_len %u)\n", i, status, ret_len);
+            ok(status == STATUS_SUCCESS, "for info %lu expected STATUS_SUCCESS, got %08lx (ret_len %lu)\n", i, status, ret_len);
             break;
 
         case ProcessAffinityMask:
         case ProcessBreakOnTermination:
             ok(status == STATUS_ACCESS_DENIED /* before win8 */ || status == STATUS_SUCCESS /* win8 is less strict */,
-               "for info %u expected STATUS_SUCCESS, got %08x (ret_len %u)\n", i, status, ret_len);
+               "for info %lu expected STATUS_SUCCESS, got %08lx (ret_len %lu)\n", i, status, ret_len);
             break;
 
         case ProcessDebugObjectHandle:
             ok(status == STATUS_ACCESS_DENIED || status == STATUS_PORT_NOT_SET,
-               "for info %u expected STATUS_ACCESS_DENIED, got %08x (ret_len %u)\n", i, status, ret_len);
+               "for info %lu expected STATUS_ACCESS_DENIED, got %08lx (ret_len %lu)\n", i, status, ret_len);
             break;
         case ProcessCookie:
             if (is_current)
                 ok(status == STATUS_SUCCESS || status == STATUS_INVALID_PARAMETER /* before win8 */,
-                   "for info %u got %08x (ret_len %u)\n", i, status, ret_len);
+                   "for info %lu got %08lx (ret_len %lu)\n", i, status, ret_len);
             else
                 ok(status == STATUS_INVALID_PARAMETER /* before win8 */ || status == STATUS_ACCESS_DENIED,
-                   "for info %u got %08x (ret_len %u)\n", i, status, ret_len);
+                   "for info %lu got %08lx (ret_len %lu)\n", i, status, ret_len);
             break;
         case ProcessExecuteFlags:
         case ProcessDebugPort:
         case ProcessDebugFlags:
             if (is_current)
                 ok(status == STATUS_SUCCESS || status == STATUS_INVALID_PARAMETER,
-                    "for info %u, got %08x (ret_len %u)\n", i, status, ret_len);
+                    "for info %lu, got %08lx (ret_len %lu)\n", i, status, ret_len);
             else
                 todo_wine
                 ok(status == STATUS_ACCESS_DENIED,
-                    "for info %u expected STATUS_ACCESS_DENIED, got %08x (ret_len %u)\n", i, status, ret_len);
+                    "for info %lu expected STATUS_ACCESS_DENIED, got %08lx (ret_len %lu)\n", i, status, ret_len);
             break;
 
         default:
             if (is_current)
                 ok(status == STATUS_SUCCESS || status == STATUS_UNSUCCESSFUL || status == STATUS_INVALID_PARAMETER,
-                    "for info %u, got %08x (ret_len %u)\n", i, status, ret_len);
+                    "for info %lu, got %08lx (ret_len %lu)\n", i, status, ret_len);
             else
                 ok(status == STATUS_ACCESS_DENIED,
-                    "for info %u expected STATUS_ACCESS_DENIED, got %08x (ret_len %u)\n", i, status, ret_len);
+                    "for info %lu expected STATUS_ACCESS_DENIED, got %08lx (ret_len %lu)\n", i, status, ret_len);
             break;
         }
     }
@@ -3863,22 +3863,22 @@ static void test_GetLogicalProcessorInformationEx(void)
     }
 
     ret = pGetLogicalProcessorInformationEx(RelationAll, NULL, NULL);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %ld\n", ret, GetLastError());
 
     len = 0;
     ret = pGetLogicalProcessorInformationEx(RelationProcessorCore, NULL, &len);
-    ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %d, error %d\n", ret, GetLastError());
-    ok(len > 0, "got %u\n", len);
+    ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %d, error %ld\n", ret, GetLastError());
+    ok(len > 0, "got %lu\n", len);
 
     len = 0;
     ret = pGetLogicalProcessorInformationEx(RelationAll, NULL, &len);
-    ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %d, error %d\n", ret, GetLastError());
-    ok(len > 0, "got %u\n", len);
+    ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %d, error %ld\n", ret, GetLastError());
+    ok(len > 0, "got %lu\n", len);
 
     info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
     ret = pGetLogicalProcessorInformationEx(RelationAll, info, &len);
-    ok(ret, "got %d, error %d\n", ret, GetLastError());
-    ok(info->Size > 0, "got %u\n", info->Size);
+    ok(ret, "got %d, error %ld\n", ret, GetLastError());
+    ok(info->Size > 0, "got %lu\n", info->Size);
     HeapFree(GetProcessHeap(), 0, info);
 }
 
@@ -3910,32 +3910,32 @@ static void test_GetSystemCpuSetInformation(void)
     size = 0xdeadbeef;
     SetLastError(0xdeadbeef);
     ret = pGetSystemCpuSetInformation(NULL, size, &size, process, 0);
-    ok(!ret && GetLastError() == ERROR_NOACCESS, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
-    ok(!size, "Got unexpected size %u.\n", size);
+    ok(!ret && GetLastError() == ERROR_NOACCESS, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
+    ok(!size, "Got unexpected size %lu.\n", size);
 
     size = 0xdeadbeef;
     SetLastError(0xdeadbeef);
     ret = pGetSystemCpuSetInformation(NULL, 0, &size, (HANDLE)0xdeadbeef, 0);
-    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
-    ok(!size, "Got unexpected size %u.\n", size);
+    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
+    ok(!size, "Got unexpected size %lu.\n", size);
 
     size = 0xdeadbeef;
     SetLastError(0xdeadbeef);
     ret = pGetSystemCpuSetInformation(NULL, 0, &size, process, 0);
-    ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
-    ok(size == expected_size, "Got unexpected size %u.\n", size);
+    ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
+    ok(size == expected_size, "Got unexpected size %lu.\n", size);
 
     info = heap_alloc(size);
     info_nt = heap_alloc(size);
 
     status = pNtQuerySystemInformationEx(SystemCpuSetInformation, &process, sizeof(process), info_nt, expected_size, NULL);
-    ok(!status, "Got unexpected status %#x.\n", status);
+    ok(!status, "Got unexpected status %#lx.\n", status);
 
     size = 0xdeadbeef;
     SetLastError(0xdeadbeef);
     ret = pGetSystemCpuSetInformation(info, expected_size, &size, process, 0);
-    ok(ret && GetLastError() == 0xdeadbeef, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
-    ok(size == expected_size, "Got unexpected size %u.\n", size);
+    ok(ret && GetLastError() == 0xdeadbeef, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
+    ok(size == expected_size, "Got unexpected size %lu.\n", size);
 
     ok(!memcmp(info, info_nt, expected_size), "Info does not match NtQuerySystemInformationEx().\n");
 
@@ -3953,7 +3953,7 @@ static void test_largepages(void)
     }
     size = pGetLargePageMinimum();
 
-    ok((size == 0) || (size == 2*1024*1024) || (size == 4*1024*1024), "GetLargePageMinimum reports %ld size\n", size);
+    ok((size == 0) || (size == 2*1024*1024) || (size == 4*1024*1024), "GetLargePageMinimum reports %Id size\n", size);
 }
 
 struct proc_thread_attr
@@ -3994,16 +3994,16 @@ static void test_ProcThreadAttributeList(void)
         ok(!ret, "got %d\n", ret);
         if(i >= 4 && GetLastError() == ERROR_INVALID_PARAMETER) /* Vista only allows a maximium of 3 slots */
             break;
-        ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %d\n", GetLastError());
-        ok(size == needed, "%d: got %ld expect %ld\n", i, size, needed);
+        ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %ld\n", GetLastError());
+        ok(size == needed, "%d: got %Id expect %Id\n", i, size, needed);
 
         memset(&list, 0xcc, sizeof(list));
         ret = pInitializeProcThreadAttributeList(&list, i, 0, &size);
         ok(ret, "got %d\n", ret);
-        ok(list.mask == 0, "%d: got %08x\n", i, list.mask);
-        ok(list.size == i, "%d: got %08x\n", i, list.size);
-        ok(list.count == 0, "%d: got %08x\n", i, list.count);
-        ok(list.unk == 0, "%d: got %08lx\n", i, list.unk);
+        ok(list.mask == 0, "%d: got %08lx\n", i, list.mask);
+        ok(list.size == i, "%d: got %08lx\n", i, list.size);
+        ok(list.count == 0, "%d: got %08lx\n", i, list.count);
+        ok(list.unk == 0, "%d: got %08Ix\n", i, list.unk);
     }
 
     memset(handles, 0, sizeof(handles));
@@ -4015,15 +4015,15 @@ static void test_ProcThreadAttributeList(void)
 
     ret = pUpdateProcThreadAttribute(&list, 0, 0xcafe, handles, sizeof(PROCESSOR_NUMBER), NULL, NULL);
     ok(!ret, "got %d\n", ret);
-    ok(GetLastError() == ERROR_NOT_SUPPORTED, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_NOT_SUPPORTED, "got %ld\n", GetLastError());
 
     ret = pUpdateProcThreadAttribute(&list, 0, PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, handles, sizeof(handles[0]) / 2, NULL, NULL);
     ok(!ret, "got %d\n", ret);
-    ok(GetLastError() == ERROR_BAD_LENGTH, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_BAD_LENGTH, "got %ld\n", GetLastError());
 
     ret = pUpdateProcThreadAttribute(&list, 0, PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, handles, sizeof(handles[0]) * 2, NULL, NULL);
     ok(!ret, "got %d\n", ret);
-    ok(GetLastError() == ERROR_BAD_LENGTH, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_BAD_LENGTH, "got %ld\n", GetLastError());
 
     ret = pUpdateProcThreadAttribute(&list, 0, PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, handles, sizeof(handles[0]), NULL, NULL);
     ok(ret, "got %d\n", ret);
@@ -4036,11 +4036,11 @@ static void test_ProcThreadAttributeList(void)
 
     ret = pUpdateProcThreadAttribute(&list, 0, PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, handles, sizeof(handles[0]), NULL, NULL);
     ok(!ret, "got %d\n", ret);
-    ok(GetLastError() == ERROR_OBJECT_NAME_EXISTS, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_OBJECT_NAME_EXISTS, "got %ld\n", GetLastError());
 
     ret = pUpdateProcThreadAttribute(&list, 0, PROC_THREAD_ATTRIBUTE_HANDLE_LIST, handles, sizeof(handles) - 1, NULL, NULL);
     ok(!ret, "got %d\n", ret);
-    ok(GetLastError() == ERROR_BAD_LENGTH, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_BAD_LENGTH, "got %ld\n", GetLastError());
 
     ret = pUpdateProcThreadAttribute(&list, 0, PROC_THREAD_ATTRIBUTE_HANDLE_LIST, handles, sizeof(handles), NULL, NULL);
     ok(ret, "got %d\n", ret);
@@ -4053,10 +4053,10 @@ static void test_ProcThreadAttributeList(void)
 
     ret = pUpdateProcThreadAttribute(&list, 0, PROC_THREAD_ATTRIBUTE_HANDLE_LIST, handles, sizeof(handles), NULL, NULL);
     ok(!ret, "got %d\n", ret);
-    ok(GetLastError() == ERROR_OBJECT_NAME_EXISTS, "got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_OBJECT_NAME_EXISTS, "got %ld\n", GetLastError());
 
     ret = pUpdateProcThreadAttribute(&list, 0, PROC_THREAD_ATTRIBUTE_IDEAL_PROCESSOR, handles, sizeof(PROCESSOR_NUMBER), NULL, NULL);
-    ok(ret || GetLastError() == ERROR_NOT_SUPPORTED, "got %d gle %d\n", ret, GetLastError());
+    ok(ret || GetLastError() == ERROR_NOT_SUPPORTED, "got %d gle %ld\n", ret, GetLastError());
 
     if (ret)
     {
@@ -4068,7 +4068,7 @@ static void test_ProcThreadAttributeList(void)
     }
 
     ret = pUpdateProcThreadAttribute(&list, 0, PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE, handles, sizeof(handles[0]), NULL, NULL);
-    ok(ret || broken(GetLastError() == ERROR_NOT_SUPPORTED), "got %d gle %d\n", ret, GetLastError());
+    ok(ret || broken(GetLastError() == ERROR_NOT_SUPPORTED), "got %d gle %ld\n", ret, GetLastError());
 
     if (ret)
     {
@@ -4127,7 +4127,7 @@ static void test_parent_process_attribute(unsigned int level, HANDLE read_pipe)
     if (!level)
     {
         ret = CreatePipe(&read_pipe, &write_pipe, &sa, 0);
-        ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+        ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
         parent_data.parent = OpenProcess(PROCESS_CREATE_PROCESS | PROCESS_QUERY_INFORMATION, TRUE, GetCurrentProcessId());
         parent_data.parent_id = GetCurrentProcessId();
@@ -4135,19 +4135,19 @@ static void test_parent_process_attribute(unsigned int level, HANDLE read_pipe)
     else
     {
         status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), &pbi_size);
-        ok(status == STATUS_SUCCESS, "Got unexpected status %#x.\n", status);
+        ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status);
         parent_id = pbi.InheritedFromUniqueProcessId;
 
         memset(&parent_data, 0, sizeof(parent_data));
         ret = ReadFile(read_pipe, &parent_data, sizeof(parent_data), &size, NULL);
         ok((level == 2 && ret) || (level == 1 && !ret && GetLastError() == ERROR_INVALID_HANDLE),
-                "Got unexpected ret %#x, level %u, GetLastError() %u.\n",
+                "Got unexpected ret %#x, level %u, GetLastError() %lu.\n",
                 ret, level, GetLastError());
     }
 
     if (level == 2)
     {
-        ok(parent_id == parent_data.parent_id, "Got parent id %u, parent_data.parent_id %u.\n",
+        ok(parent_id == parent_data.parent_id, "Got parent id %lu, parent_data.parent_id %lu.\n",
                 parent_id, parent_data.parent_id);
         return;
     }
@@ -4162,7 +4162,7 @@ static void test_parent_process_attribute(unsigned int level, HANDLE read_pipe)
 
         ret = pInitializeProcThreadAttributeList(NULL, 1, 0, &size);
         ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-                "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+                "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
         sprintf(buffer, "\"%s\" process parent %u %p", selfname, 255, read_pipe);
 
@@ -4175,14 +4175,14 @@ static void test_parent_process_attribute(unsigned int level, HANDLE read_pipe)
 #endif
         si.lpAttributeList = heap_alloc(size);
         ret = pInitializeProcThreadAttributeList(si.lpAttributeList, 1, 0, &size);
-        ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+        ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
         handle = OpenProcess(PROCESS_CREATE_PROCESS, TRUE, GetCurrentProcessId());
         ret = pUpdateProcThreadAttribute(si.lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_PARENT_PROCESS,
                 &handle, sizeof(handle), NULL, NULL);
-        ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+        ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
         ret = CreateProcessA(NULL, buffer, NULL, NULL, TRUE, EXTENDED_STARTUPINFO_PRESENT,
                 NULL, NULL, (STARTUPINFOA *)&si, &info);
-        ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+        ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
         wait_and_close_child_process(&info);
         CloseHandle(handle);
         pDeleteProcThreadAttributeList(si.lpAttributeList);
@@ -4190,44 +4190,44 @@ static void test_parent_process_attribute(unsigned int level, HANDLE read_pipe)
 
         si.lpAttributeList = heap_alloc(size);
         ret = pInitializeProcThreadAttributeList(si.lpAttributeList, 1, 0, &size);
-        ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+        ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
         handle = (HANDLE)0xdeadbeef;
         ret = pUpdateProcThreadAttribute(si.lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_PARENT_PROCESS,
                 &handle, sizeof(handle), NULL, NULL);
-        ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+        ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
         ret = CreateProcessA(NULL, buffer, NULL, NULL, TRUE, EXTENDED_STARTUPINFO_PRESENT,
                 NULL, NULL, (STARTUPINFOA *)&si, &info);
-        ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected ret %#x, GetLastError() %u.\n",
+        ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected ret %#x, GetLastError() %lu.\n",
                 ret, GetLastError());
         pDeleteProcThreadAttributeList(si.lpAttributeList);
         heap_free(si.lpAttributeList);
 
         si.lpAttributeList = heap_alloc(size);
         ret = pInitializeProcThreadAttributeList(si.lpAttributeList, 1, 0, &size);
-        ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+        ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
         handle = NULL;
         ret = pUpdateProcThreadAttribute(si.lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_PARENT_PROCESS,
                 &handle, sizeof(handle), NULL, NULL);
-        ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+        ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
         ret = CreateProcessA(NULL, buffer, NULL, NULL, TRUE, EXTENDED_STARTUPINFO_PRESENT,
                 NULL, NULL, (STARTUPINFOA *)&si, &info);
-        ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected ret %#x, GetLastError() %u.\n",
+        ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected ret %#x, GetLastError() %lu.\n",
                 ret, GetLastError());
         pDeleteProcThreadAttributeList(si.lpAttributeList);
         heap_free(si.lpAttributeList);
 
         si.lpAttributeList = heap_alloc(size);
         ret = pInitializeProcThreadAttributeList(si.lpAttributeList, 1, 0, &size);
-        ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+        ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
         handle = GetCurrentProcess();
         ret = pUpdateProcThreadAttribute(si.lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_PARENT_PROCESS,
                 &handle, sizeof(handle), NULL, NULL);
-        ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+        ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
         ret = CreateProcessA(NULL, buffer, NULL, NULL, TRUE, EXTENDED_STARTUPINFO_PRESENT,
                 NULL, NULL, (STARTUPINFOA *)&si, &info);
         /* Broken on Vista / w7 / w10. */
         ok(ret || broken(!ret && GetLastError() == ERROR_INVALID_HANDLE),
-                "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+                "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
         if (ret)
             wait_and_close_child_process(&info);
         pDeleteProcThreadAttributeList(si.lpAttributeList);
@@ -4235,19 +4235,19 @@ static void test_parent_process_attribute(unsigned int level, HANDLE read_pipe)
 
         si.lpAttributeList = heap_alloc(size);
         ret = pInitializeProcThreadAttributeList(si.lpAttributeList, 1, 0, &size);
-        ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+        ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
         parent = OpenProcess(PROCESS_CREATE_PROCESS, FALSE, parent_id);
 
         ret = pUpdateProcThreadAttribute(si.lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_PARENT_PROCESS,
                 &parent, sizeof(parent), NULL, NULL);
-        ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+        ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
     }
 
     sprintf(buffer, "\"%s\" process parent %u %p", selfname, level + 1, read_pipe);
     ret = CreateProcessA(NULL, buffer, NULL, NULL, level == 1, level == 1 ? EXTENDED_STARTUPINFO_PRESENT : 0,
             NULL, NULL, (STARTUPINFOA *)&si, &info);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
     if (level)
     {
@@ -4286,25 +4286,25 @@ static void test_handle_list_attribute(BOOL child, HANDLE handle1, HANDLE handle
 
         flags = 0;
         ret = GetHandleInformation(handle1, &flags);
-        ok(ret, "Failed to get handle info, error %d.\n", GetLastError());
-        ok(flags == HANDLE_FLAG_INHERIT, "Unexpected flags %#x.\n", flags);
+        ok(ret, "Failed to get handle info, error %ld.\n", GetLastError());
+        ok(flags == HANDLE_FLAG_INHERIT, "Unexpected flags %#lx.\n", flags);
         CloseHandle(handle1);
 
         ret = GetHandleInformation(handle2, &flags);
-        ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Unexpected return value, error %d.\n", GetLastError());
+        ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Unexpected return value, error %ld.\n", GetLastError());
 
         return;
     }
 
     ret = pInitializeProcThreadAttributeList(NULL, 1, 0, &size);
     ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-            "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+            "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
     memset(&si, 0, sizeof(si));
     si.StartupInfo.cb = sizeof(si);
     si.lpAttributeList = heap_alloc(size);
     ret = pInitializeProcThreadAttributeList(si.lpAttributeList, 1, 0, &size);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
     memset(&sa, 0, sizeof(sa));
     sa.nLength = sizeof(sa);
@@ -4315,12 +4315,12 @@ static void test_handle_list_attribute(BOOL child, HANDLE handle1, HANDLE handle
 
     ret = pUpdateProcThreadAttribute(si.lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_HANDLE_LIST, &pipe[0],
             sizeof(pipe[0]), NULL, NULL);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
     sprintf(buffer, "\"%s\" process handlelist %p %p", selfname, pipe[0], pipe[1]);
     ret = CreateProcessA(NULL, buffer, NULL, NULL, TRUE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL,
             (STARTUPINFOA *)&si, &info);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
     wait_and_close_child_process(&info);
 
@@ -4348,23 +4348,23 @@ static void test_dead_process(void)
 
     memset( data, 0, sizeof(data) );
     status = NtQueryInformationProcess( pi.hProcess, ProcessImageFileName, data, sizeof(data), NULL);
-    ok( !status, "ProcessImageFileName failed %x\n", status );
+    ok( !status, "ProcessImageFileName failed %lx\n", status );
     ok( ((UNICODE_STRING *)data)->Length, "ProcessImageFileName not set\n" );
     ok( ((UNICODE_STRING *)data)->Buffer[0] == '\\', "ProcessImageFileName not set\n" );
 
     memset( prio, 0xcc, sizeof(*prio) );
     status = NtQueryInformationProcess( pi.hProcess, ProcessPriorityClass, prio, sizeof(*prio), NULL);
-    ok( !status, "ProcessPriorityClass failed %x\n", status );
+    ok( !status, "ProcessPriorityClass failed %lx\n", status );
     ok( prio->PriorityClass != 0xcc, "ProcessPriorityClass not set\n" );
 
     memset( &basic, 0xcc, sizeof(basic) );
     status = NtQueryInformationProcess( pi.hProcess, ProcessBasicInformation, &basic, sizeof(basic), NULL);
-    ok( !status, "ProcessBasicInformation failed %x\n", status );
+    ok( !status, "ProcessBasicInformation failed %lx\n", status );
     ok( basic.ExitStatus == 0, "ProcessBasicInformation info modified\n" );
 
     memset( &image, 0xcc, sizeof(image) );
     status = NtQueryInformationProcess( pi.hProcess, ProcessImageInformation, &image, sizeof(image), NULL);
-    ok( status == STATUS_PROCESS_IS_TERMINATING, "ProcessImageInformation wrong error %x\n", status );
+    ok( status == STATUS_PROCESS_IS_TERMINATING, "ProcessImageInformation wrong error %lx\n", status );
     ok( image.Machine == 0xcccc, "ProcessImageInformation info modified\n" );
 
     while ((status = NtQuerySystemInformation(SystemProcessInformation, buffer, size, &size)) == STATUS_INFO_LENGTH_MISMATCH)
@@ -4372,7 +4372,7 @@ static void test_dead_process(void)
         free(buffer);
         buffer = malloc(size);
     }
-    ok(status == STATUS_SUCCESS, "got %#x\n", status);
+    ok(status == STATUS_SUCCESS, "got %#lx\n", status);
     found = FALSE;
     do
     {
@@ -4404,54 +4404,54 @@ static void test_nested_jobs_child(unsigned int index)
     sprintf(job_name, "test_nested_jobs_%u", index);
     job = pOpenJobObjectA(JOB_OBJECT_ASSIGN_PROCESS | JOB_OBJECT_SET_ATTRIBUTES | JOB_OBJECT_QUERY
             | JOB_OBJECT_TERMINATE, FALSE, job_name);
-    ok(!!job, "OpenJobObjectA error %u\n", GetLastError());
+    ok(!!job, "OpenJobObjectA error %lu\n", GetLastError());
 
     sprintf(job_name, "test_nested_jobs_%u", !index);
     job_other = pOpenJobObjectA(JOB_OBJECT_ASSIGN_PROCESS | JOB_OBJECT_SET_ATTRIBUTES | JOB_OBJECT_QUERY
             | JOB_OBJECT_TERMINATE, FALSE, job_name);
-    ok(!!job_other, "OpenJobObjectA error %u\n", GetLastError());
+    ok(!!job_other, "OpenJobObjectA error %lu\n", GetLastError());
 
     job_parent = pCreateJobObjectW(NULL, NULL);
-    ok(!!job_parent, "CreateJobObjectA error %u\n", GetLastError());
+    ok(!!job_parent, "CreateJobObjectA error %lu\n", GetLastError());
 
     ret = pAssignProcessToJobObject(job_parent, GetCurrentProcess());
-    ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+    ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
 
     create_process("wait", &pi);
 
     ret = pAssignProcessToJobObject(job_parent, pi.hProcess);
     ok(ret || broken(!ret && GetLastError() == ERROR_ACCESS_DENIED) /* Supported since Windows 8. */,
-            "AssignProcessToJobObject error %u\n", GetLastError());
+            "AssignProcessToJobObject error %lu\n", GetLastError());
     if (!ret)
     {
         win_skip("Nested jobs are not supported.\n");
         goto done;
     }
     ret = pAssignProcessToJobObject(job, pi.hProcess);
-    ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+    ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
 
     out = FALSE;
     ret = pIsProcessInJob(pi.hProcess, NULL, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     out = FALSE;
     ret = pIsProcessInJob(pi.hProcess, job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     out = TRUE;
     ret = pIsProcessInJob(GetCurrentProcess(), job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(!out, "IsProcessInJob returned out=%u\n", out);
 
     out = FALSE;
     ret = pIsProcessInJob(pi.hProcess, job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     ret = pAssignProcessToJobObject(job, GetCurrentProcess());
-    ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+    ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
 
     TerminateProcess(pi.hProcess, 0);
     wait_child_process(pi.hProcess);
@@ -4461,26 +4461,26 @@ static void test_nested_jobs_child(unsigned int index)
     dead_pid = pi.dwProcessId;
 
     port = pCreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1);
-    ok(!!port, "CreateIoCompletionPort error %u\n", GetLastError());
+    ok(!!port, "CreateIoCompletionPort error %lu\n", GetLastError());
 
     port_info.CompletionPort = port;
     port_info.CompletionKey = job;
     ret = pSetInformationJobObject(job, JobObjectAssociateCompletionPortInformation, &port_info, sizeof(port_info));
-    ok(ret, "SetInformationJobObject error %u\n", GetLastError());
+    ok(ret, "SetInformationJobObject error %lu\n", GetLastError());
     port_info.CompletionKey = job_parent;
     ret = pSetInformationJobObject(job_parent, JobObjectAssociateCompletionPortInformation,
             &port_info, sizeof(port_info));
-    ok(ret, "SetInformationJobObject error %u\n", GetLastError());
+    ok(ret, "SetInformationJobObject error %lu\n", GetLastError());
 
     create_process("wait", &pi);
     out = FALSE;
     ret = pIsProcessInJob(pi.hProcess, job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     out = FALSE;
     ret = pIsProcessInJob(pi.hProcess, job_parent, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     /* The first already dead child process still shows up randomly. */
@@ -4489,20 +4489,20 @@ static void test_nested_jobs_child(unsigned int index)
         ret = GetQueuedCompletionStatus(port, &key, &value, &overlapped, 0);
     } while (ret && (ULONG_PTR)overlapped == dead_pid);
 
-    ok(ret, "GetQueuedCompletionStatus: %x\n", GetLastError());
-    ok(key == JOB_OBJECT_MSG_NEW_PROCESS, "unexpected key %x\n", key);
+    ok(ret, "GetQueuedCompletionStatus: %lx\n", GetLastError());
+    ok(key == JOB_OBJECT_MSG_NEW_PROCESS, "unexpected key %lx\n", key);
     ok((HANDLE)value == job, "unexpected value %p\n", (void *)value);
-    ok((ULONG_PTR)overlapped == GetCurrentProcessId(), "unexpected pid %#x\n", (DWORD)(DWORD_PTR)overlapped);
+    ok((ULONG_PTR)overlapped == GetCurrentProcessId(), "unexpected pid %#lx\n", (DWORD)(DWORD_PTR)overlapped);
 
     do
     {
         ret = GetQueuedCompletionStatus(port, &key, &value, &overlapped, 0);
     } while (ret && (ULONG_PTR)overlapped == dead_pid);
 
-    ok(ret, "GetQueuedCompletionStatus: %x\n", GetLastError());
-    ok(key == JOB_OBJECT_MSG_NEW_PROCESS, "unexpected key %x\n", key);
+    ok(ret, "GetQueuedCompletionStatus: %lx\n", GetLastError());
+    ok(key == JOB_OBJECT_MSG_NEW_PROCESS, "unexpected key %lx\n", key);
     ok((HANDLE)value == job_parent, "unexpected value %p\n", (void *)value);
-    ok((ULONG_PTR)overlapped == GetCurrentProcessId(), "unexpected pid %#x\n", (DWORD)(DWORD_PTR)overlapped);
+    ok((ULONG_PTR)overlapped == GetCurrentProcessId(), "unexpected pid %#lx\n", (DWORD)(DWORD_PTR)overlapped);
 
     test_completion(port, JOB_OBJECT_MSG_NEW_PROCESS, (DWORD_PTR)job, pi.dwProcessId, 0);
     test_completion(port, JOB_OBJECT_MSG_NEW_PROCESS, (DWORD_PTR)job_parent, pi.dwProcessId, 0);
@@ -4514,7 +4514,7 @@ static void test_nested_jobs_child(unsigned int index)
     {
         ret = pAssignProcessToJobObject(job_other, GetCurrentProcess());
         ok(!ret, "AssignProcessToJobObject succeeded\n");
-        ok(GetLastError() == ERROR_ACCESS_DENIED, "Got unexpected error %u.\n", GetLastError());
+        ok(GetLastError() == ERROR_ACCESS_DENIED, "Got unexpected error %lu.\n", GetLastError());
     }
 
     CloseHandle(port);
@@ -4546,9 +4546,9 @@ static void test_nested_jobs(void)
     }
 
     job1 = pCreateJobObjectW(NULL, NULL);
-    ok(!!job1, "CreateJobObjectW failed, error %u.\n", GetLastError());
+    ok(!!job1, "CreateJobObjectW failed, error %lu.\n", GetLastError());
     job2 = pCreateJobObjectW(NULL, NULL);
-    ok(!!job2, "CreateJobObjectW failed, error %u.\n", GetLastError());
+    ok(!!job2, "CreateJobObjectW failed, error %lu.\n", GetLastError());
 
     create_succeeded = TRUE;
     sprintf(buffer, "\"%s\" process wait", selfname);
@@ -4560,25 +4560,25 @@ static void test_nested_jobs(void)
             create_succeeded = FALSE;
             break;
         }
-        ok(ret, "CreateProcessA error %u\n", GetLastError());
+        ok(ret, "CreateProcessA error %lu\n", GetLastError());
     }
 
     if (create_succeeded)
     {
         ret = pIsProcessInJob(info[0].hProcess, NULL, &already_in_job);
-        ok(ret, "IsProcessInJob error %u\n", GetLastError());
+        ok(ret, "IsProcessInJob error %lu\n", GetLastError());
 
         if (!already_in_job)
         {
             ret = pAssignProcessToJobObject(job2, info[1].hProcess);
-            ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+            ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
 
             ret = pAssignProcessToJobObject(job1, info[0].hProcess);
-            ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
+            ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
 
             ret = pAssignProcessToJobObject(job2, info[0].hProcess);
             ok(!ret, "AssignProcessToJobObject succeeded\n");
-            ok(GetLastError() == ERROR_ACCESS_DENIED, "Got unexpected error %u.\n", GetLastError());
+            ok(GetLastError() == ERROR_ACCESS_DENIED, "Got unexpected error %lu.\n", GetLastError());
 
             TerminateProcess(info[1].hProcess, 0);
             wait_child_process(info[1].hProcess);
@@ -4587,7 +4587,7 @@ static void test_nested_jobs(void)
 
             ret = pAssignProcessToJobObject(job2, info[0].hProcess);
             ok(!ret, "AssignProcessToJobObject succeeded\n");
-            ok(GetLastError() == ERROR_ACCESS_DENIED, "Got unexpected error %u.\n", GetLastError());
+            ok(GetLastError() == ERROR_ACCESS_DENIED, "Got unexpected error %lu.\n", GetLastError());
         }
 
         TerminateProcess(info[0].hProcess, 0);
@@ -4605,9 +4605,9 @@ static void test_nested_jobs(void)
     CloseHandle(job2);
 
     job1 = pCreateJobObjectW(NULL, L"test_nested_jobs_0");
-    ok(!!job1, "CreateJobObjectW failed, error %u.\n", GetLastError());
+    ok(!!job1, "CreateJobObjectW failed, error %lu.\n", GetLastError());
     job2 = pCreateJobObjectW(NULL, L"test_nested_jobs_1");
-    ok(!!job2, "CreateJobObjectW failed, error %u.\n", GetLastError());
+    ok(!!job2, "CreateJobObjectW failed, error %lu.\n", GetLastError());
 
     sprintf(buffer, "\"%s\" process nested_jobs 0", selfname);
     ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, &info[0]),
@@ -4652,7 +4652,7 @@ static void test_job_list_attribute(HANDLE parent_job)
 
     ret = pInitializeProcThreadAttributeList(NULL, 1, 0, &size);
     ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-            "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+            "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
     attrs = heap_alloc(size);
 
 
@@ -4660,7 +4660,7 @@ static void test_job_list_attribute(HANDLE parent_job)
     jobs[1] = NULL;
 
     ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
     ret = pUpdateProcThreadAttribute(attrs, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST, jobs,
             sizeof(*jobs), NULL, NULL);
     if (!ret && GetLastError() == ERROR_NOT_SUPPORTED)
@@ -4671,23 +4671,23 @@ static void test_job_list_attribute(HANDLE parent_job)
         heap_free(attrs);
         return;
     }
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
     ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
     ret = pUpdateProcThreadAttribute(attrs, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST, jobs,
             3, NULL, NULL);
-    ok(!ret && GetLastError() == ERROR_BAD_LENGTH, "Got unexpected ret %#x, GetLastError() %u.\n",
+    ok(!ret && GetLastError() == ERROR_BAD_LENGTH, "Got unexpected ret %#x, GetLastError() %lu.\n",
             ret, GetLastError());
 
     ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
     ret = pUpdateProcThreadAttribute(attrs, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST, jobs,
             sizeof(*jobs) * 2, NULL, NULL);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
     ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
     ret = pUpdateProcThreadAttribute(attrs, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST, jobs,
             sizeof(*jobs), NULL, NULL);
 
@@ -4698,65 +4698,65 @@ static void test_job_list_attribute(HANDLE parent_job)
 
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL,
             (STARTUPINFOA *)&si, &pi);
-    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected ret %#x, GetLastError() %u.\n",
+    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected ret %#x, GetLastError() %lu.\n",
             ret, GetLastError());
 
     ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
     ret = pUpdateProcThreadAttribute(attrs, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST, jobs + 1,
             sizeof(*jobs), NULL, NULL);
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL,
             (STARTUPINFOA *)&si, &pi);
-    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected ret %#x, GetLastError() %u.\n",
+    ok(!ret && GetLastError() == ERROR_INVALID_HANDLE, "Got unexpected ret %#x, GetLastError() %lu.\n",
             ret, GetLastError());
 
     ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
     ret = pUpdateProcThreadAttribute(attrs, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST, &parent_job,
             sizeof(parent_job), NULL, NULL);
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL,
             (STARTUPINFOA *)&si, &pi);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
     ret = pIsProcessInJob(pi.hProcess, parent_job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     TerminateProcess(pi.hProcess, 0);
     wait_and_close_child_process(&pi);
 
     jobs[0] = pCreateJobObjectW(NULL, NULL);
-    ok(!!jobs[0], "CreateJobObjectA error %u\n", GetLastError());
+    ok(!!jobs[0], "CreateJobObjectA error %lu\n", GetLastError());
     jobs[1] = pCreateJobObjectW(NULL, NULL);
-    ok(!!jobs[1], "CreateJobObjectA error %u\n", GetLastError());
+    ok(!!jobs[1], "CreateJobObjectA error %lu\n", GetLastError());
 
     /* Breakaway works for the inherited job only. */
     limit_info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_BREAKAWAY_OK;
     ret = pSetInformationJobObject(parent_job, JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info));
-    ok(ret, "SetInformationJobObject error %u\n", GetLastError());
+    ok(ret, "SetInformationJobObject error %lu\n", GetLastError());
     limit_info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_BREAKAWAY_OK
             | JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK;
     ret = pSetInformationJobObject(jobs[1], JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info));
-    ok(ret, "SetInformationJobObject error %u\n", GetLastError());
+    ok(ret, "SetInformationJobObject error %lu\n", GetLastError());
 
     ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
     ret = pUpdateProcThreadAttribute(attrs, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST, jobs + 1,
             sizeof(*jobs), NULL, NULL);
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT
             | CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, (STARTUPINFOA *)&si, &pi);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
     ret = pIsProcessInJob(pi.hProcess, parent_job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(!out, "IsProcessInJob returned out=%u\n", out);
 
     ret = pIsProcessInJob(pi.hProcess, jobs[1], &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     ret = pIsProcessInJob(pi.hProcess, jobs[0], &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(!out, "IsProcessInJob returned out=%u\n", out);
 
     TerminateProcess(pi.hProcess, 0);
@@ -4764,26 +4764,26 @@ static void test_job_list_attribute(HANDLE parent_job)
 
     CloseHandle(jobs[1]);
     jobs[1] = pCreateJobObjectW(NULL, NULL);
-    ok(!!jobs[1], "CreateJobObjectA error %u\n", GetLastError());
+    ok(!!jobs[1], "CreateJobObjectA error %lu\n", GetLastError());
 
     ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
     ret = pUpdateProcThreadAttribute(attrs, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST, jobs + 1,
             sizeof(*jobs), NULL, NULL);
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT,
             NULL, NULL, (STARTUPINFOA *)&si, &pi);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
     ret = pIsProcessInJob(pi.hProcess, parent_job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     ret = pIsProcessInJob(pi.hProcess, jobs[1], &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     ret = pIsProcessInJob(pi.hProcess, jobs[0], &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(!out, "IsProcessInJob returned out=%u\n", out);
 
     TerminateProcess(pi.hProcess, 0);
@@ -4791,54 +4791,54 @@ static void test_job_list_attribute(HANDLE parent_job)
 
     ret = pQueryInformationJobObject(jobs[0], JobObjectBasicAccountingInformation, &job_info,
             sizeof(job_info), NULL);
-    ok(ret, "QueryInformationJobObject error %u\n", GetLastError());
-    ok(!job_info.TotalProcesses, "Got unexpected TotalProcesses %u.\n", job_info.TotalProcesses);
-    ok(!job_info.ActiveProcesses, "Got unexpected ActiveProcesses %u.\n", job_info.ActiveProcesses);
+    ok(ret, "QueryInformationJobObject error %lu\n", GetLastError());
+    ok(!job_info.TotalProcesses, "Got unexpected TotalProcesses %lu.\n", job_info.TotalProcesses);
+    ok(!job_info.ActiveProcesses, "Got unexpected ActiveProcesses %lu.\n", job_info.ActiveProcesses);
 
     ret = pQueryInformationJobObject(jobs[1], JobObjectBasicAccountingInformation, &job_info,
             sizeof(job_info), NULL);
-    ok(ret, "QueryInformationJobObject error %u\n", GetLastError());
-    ok(job_info.TotalProcesses == 1, "Got unexpected TotalProcesses %u.\n", job_info.TotalProcesses);
-    ok(!job_info.ActiveProcesses || job_info.ActiveProcesses == 1, "Got unexpected ActiveProcesses %u.\n",
+    ok(ret, "QueryInformationJobObject error %lu\n", GetLastError());
+    ok(job_info.TotalProcesses == 1, "Got unexpected TotalProcesses %lu.\n", job_info.TotalProcesses);
+    ok(!job_info.ActiveProcesses || job_info.ActiveProcesses == 1, "Got unexpected ActiveProcesses %lu.\n",
             job_info.ActiveProcesses);
 
     /* Fails due to the second job already has the parent other than the first job in the list. */
     ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
     ret = pUpdateProcThreadAttribute(attrs, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST, jobs,
             2 * sizeof(*jobs), NULL, NULL);
 
     port = pCreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1);
-    ok(!!port, "CreateIoCompletionPort error %u\n", GetLastError());
+    ok(!!port, "CreateIoCompletionPort error %lu\n", GetLastError());
 
     port_info.CompletionPort = port;
     port_info.CompletionKey = jobs[0];
     ret = pSetInformationJobObject(jobs[0], JobObjectAssociateCompletionPortInformation, &port_info, sizeof(port_info));
-    ok(ret, "SetInformationJobObject error %u\n", GetLastError());
+    ok(ret, "SetInformationJobObject error %lu\n", GetLastError());
 
     ret = GetQueuedCompletionStatus(port, &key, &value, &overlapped, 0);
     ok(!ret, "GetQueuedCompletionStatus succeeded.\n");
 
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL,
             (STARTUPINFOA *)&si, &pi);
-    ok(!ret && GetLastError() == ERROR_ACCESS_DENIED, "Got unexpected ret %#x, GetLastError() %u.\n",
+    ok(!ret && GetLastError() == ERROR_ACCESS_DENIED, "Got unexpected ret %#x, GetLastError() %lu.\n",
             ret, GetLastError());
 
     ret = GetQueuedCompletionStatus(port, &key, &value, &overlapped, 100);
-    ok(ret, "GetQueuedCompletionStatus: %x\n", GetLastError());
-    ok(key == JOB_OBJECT_MSG_NEW_PROCESS, "unexpected key %x\n", key);
+    ok(ret, "GetQueuedCompletionStatus: %lx\n", GetLastError());
+    ok(key == JOB_OBJECT_MSG_NEW_PROCESS, "unexpected key %lx\n", key);
     ok((HANDLE)value == jobs[0], "unexpected value %p\n", (void *)value);
     ok(!!overlapped, "Got zero pid.\n");
 
     ret = GetQueuedCompletionStatus(port, &key, &value, &overlapped, 100);
-    ok(ret, "GetQueuedCompletionStatus: %x\n", GetLastError());
-    ok(key == JOB_OBJECT_MSG_EXIT_PROCESS, "unexpected key %x\n", key);
+    ok(ret, "GetQueuedCompletionStatus: %lx\n", GetLastError());
+    ok(key == JOB_OBJECT_MSG_EXIT_PROCESS, "unexpected key %lx\n", key);
     ok((HANDLE)value == jobs[0], "unexpected value %p\n", (void *)value);
     ok(!!overlapped, "Got zero pid.\n");
 
     ret = GetQueuedCompletionStatus(port, &key, &value, &overlapped, 100);
-    ok(ret, "GetQueuedCompletionStatus: %x\n", GetLastError());
-    ok(key == JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO, "unexpected key %x\n", key);
+    ok(ret, "GetQueuedCompletionStatus: %lx\n", GetLastError());
+    ok(key == JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO, "unexpected key %lx\n", key);
     ok((HANDLE)value == jobs[0], "unexpected value %p\n", (void *)value);
     ok(!overlapped, "Got unexpected overlapped %p.\n", overlapped);
 
@@ -4850,31 +4850,31 @@ static void test_job_list_attribute(HANDLE parent_job)
     /* The first job got updated even though the process creation failed. */
     ret = pQueryInformationJobObject(jobs[0], JobObjectBasicAccountingInformation, &job_info,
             sizeof(job_info), NULL);
-    ok(ret, "QueryInformationJobObject error %u\n", GetLastError());
-    ok(job_info.TotalProcesses == 1, "Got unexpected TotalProcesses %u.\n", job_info.TotalProcesses);
-    ok(!job_info.ActiveProcesses, "Got unexpected ActiveProcesses %u.\n", job_info.ActiveProcesses);
+    ok(ret, "QueryInformationJobObject error %lu\n", GetLastError());
+    ok(job_info.TotalProcesses == 1, "Got unexpected TotalProcesses %lu.\n", job_info.TotalProcesses);
+    ok(!job_info.ActiveProcesses, "Got unexpected ActiveProcesses %lu.\n", job_info.ActiveProcesses);
 
     ret = pQueryInformationJobObject(jobs[1], JobObjectBasicAccountingInformation, &job_info,
             sizeof(job_info), NULL);
-    ok(ret, "QueryInformationJobObject error %u\n", GetLastError());
-    ok(job_info.TotalProcesses == 1, "Got unexpected TotalProcesses %u.\n", job_info.TotalProcesses);
-    ok(!job_info.ActiveProcesses, "Got unexpected ActiveProcesses %u.\n", job_info.ActiveProcesses);
+    ok(ret, "QueryInformationJobObject error %lu\n", GetLastError());
+    ok(job_info.TotalProcesses == 1, "Got unexpected TotalProcesses %lu.\n", job_info.TotalProcesses);
+    ok(!job_info.ActiveProcesses, "Got unexpected ActiveProcesses %lu.\n", job_info.ActiveProcesses);
 
     /* Check that the first job actually got the job_parent as parent. */
     ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
     ret = pUpdateProcThreadAttribute(attrs, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST, jobs,
             sizeof(*jobs), NULL, NULL);
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT
             | CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, (STARTUPINFOA *)&si, &pi);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
     ret = pIsProcessInJob(pi.hProcess, parent_job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     ret = pIsProcessInJob(pi.hProcess, jobs[0], &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     TerminateProcess(pi.hProcess, 0);
@@ -4885,64 +4885,64 @@ static void test_job_list_attribute(HANDLE parent_job)
     jobs[1] = tmp;
 
     ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
     ret = pUpdateProcThreadAttribute(attrs, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST, jobs,
             2 * sizeof(*jobs), NULL, NULL);
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL,
             (STARTUPINFOA *)&si, &pi);
-    ok(!ret && GetLastError() == ERROR_ACCESS_DENIED, "Got unexpected ret %#x, GetLastError() %u.\n",
+    ok(!ret && GetLastError() == ERROR_ACCESS_DENIED, "Got unexpected ret %#x, GetLastError() %lu.\n",
             ret, GetLastError());
 
     CloseHandle(jobs[0]);
     CloseHandle(jobs[1]);
 
     jobs[0] = pCreateJobObjectW(NULL, NULL);
-    ok(!!jobs[0], "CreateJobObjectA error %u\n", GetLastError());
+    ok(!!jobs[0], "CreateJobObjectA error %lu\n", GetLastError());
     jobs[1] = pCreateJobObjectW(NULL, NULL);
-    ok(!!jobs[1], "CreateJobObjectA error %u\n", GetLastError());
+    ok(!!jobs[1], "CreateJobObjectA error %lu\n", GetLastError());
 
     /* Create the job chain successfully and check the job chain. */
     ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
     ret = pUpdateProcThreadAttribute(attrs, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST, jobs,
             2 * sizeof(*jobs), NULL, NULL);
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT,
             NULL, NULL, (STARTUPINFOA *)&si, &pi);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
     ret = pIsProcessInJob(pi.hProcess, parent_job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     ret = pIsProcessInJob(pi.hProcess, jobs[0], &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     ret = pIsProcessInJob(pi.hProcess, jobs[1], &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     TerminateProcess(pi.hProcess, 0);
     wait_and_close_child_process(&pi);
 
     ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
     ret = pUpdateProcThreadAttribute(attrs, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST, jobs + 1,
             sizeof(*jobs), NULL, NULL);
     ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT
             | CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, (STARTUPINFOA *)&si, &pi);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
     ret = pIsProcessInJob(pi.hProcess, parent_job, &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     ret = pIsProcessInJob(pi.hProcess, jobs[0], &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     ret = pIsProcessInJob(pi.hProcess, jobs[1], &out);
-    ok(ret, "IsProcessInJob error %u\n", GetLastError());
+    ok(ret, "IsProcessInJob error %lu\n", GetLastError());
     ok(out, "IsProcessInJob returned out=%u\n", out);
 
     TerminateProcess(pi.hProcess, 0);
@@ -4956,7 +4956,7 @@ static void test_job_list_attribute(HANDLE parent_job)
 
     limit_info.BasicLimitInformation.LimitFlags = 0;
     ret = pSetInformationJobObject(parent_job, JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info));
-    ok(ret, "SetInformationJobObject error %u\n", GetLastError());
+    ok(ret, "SetInformationJobObject error %lu\n", GetLastError());
 }
 
 START_TEST(process)
@@ -4982,11 +4982,11 @@ START_TEST(process)
         else if (!strcmp(myARGV[2], "sync") && myARGC >= 4)
         {
             HANDLE sem = OpenSemaphoreA(SYNCHRONIZE, FALSE, myARGV[3]);
-            ok(sem != 0, "OpenSemaphoreA(%s) failed le=%u\n", myARGV[3], GetLastError());
+            ok(sem != 0, "OpenSemaphoreA(%s) failed le=%lu\n", myARGV[3], GetLastError());
             if (sem)
             {
                 DWORD ret = WaitForSingleObject(sem, 30000);
-                ok(ret == WAIT_OBJECT_0, "WaitForSingleObject(%s) returned %u\n", myARGV[3], ret);
+                ok(ret == WAIT_OBJECT_0, "WaitForSingleObject(%s) returned %lu\n", myARGV[3], ret);
                 CloseHandle(sem);
             }
             return;
@@ -5017,7 +5017,7 @@ START_TEST(process)
              * nested process.
              */
             hFile = CreateFileA(myARGV[3], GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
-            childPrintf(hFile, "[Nested]\nPid=%08u\n", info.dwProcessId);
+            childPrintf(hFile, "[Nested]\nPid=%08lu\n", info.dwProcessId);
             CloseHandle(hFile);
             return;
         }
diff --git a/dlls/kernel32/tests/profile.c b/dlls/kernel32/tests/profile.c
index 94ef0a85467..71d945f81df 100644
--- a/dlls/kernel32/tests/profile.c
+++ b/dlls/kernel32/tests/profile.c
@@ -36,7 +36,7 @@ static void check_profile_string_(int line, const char *section, const char *nam
 {
     char value[200] = {0};
     DWORD ret = GetPrivateProfileStringA(section, name, "default", value, sizeof(value), file);
-    ok_(__FILE__, line)(ret == strlen(expect), "expected len %u, got %u\n", strlen(expect), ret);
+    ok_(__FILE__, line)(ret == strlen(expect), "expected len %Iu, got %lu\n", strlen(expect), ret);
     ok_(__FILE__, line)(!strcmp(value, expect), "expected %s, got %s\n", debugstr_a(expect), debugstr_a(value));
 }
 #define check_profile_string(a, b, c, d) check_profile_string_(__LINE__, a, b, c, d);
@@ -191,7 +191,7 @@ static void test_profile_sections(void)
     ok( ret == 0, "expected return size 0, got %d\n", ret );
     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
         GetLastError() == 0xdeadbeef /* Win98 */,
-        "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+        "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
     if (GetLastError() == 0xdeadbeef) on_win98 = TRUE;
 
     SetLastError(0xdeadbeef);
@@ -199,35 +199,35 @@ static void test_profile_sections(void)
     ok( ret == 0, "expected return size 0, got %d\n", ret );
     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
         GetLastError() == 0xdeadbeef /* Win98 */,
-        "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+        "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     if (!on_win98)
     {
         SetLastError(0xdeadbeef);
         ret = GetPrivateProfileSectionA( "section1", NULL, 0, testfile4 );
         ok( ret == 0, "expected return size 0, got %d\n", ret );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
     }
 
     SetLastError(0xdeadbeef);
     ret = GetPrivateProfileSectionA( NULL, buf, sizeof(buf), testfile4 );
     ok( ret == 0, "expected return size 0, got %d\n", ret );
     ok( GetLastError() == ERROR_INVALID_PARAMETER,
-        "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+        "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = GetPrivateProfileSectionA( "section1", buf, sizeof(buf), NULL );
     ok( ret == 0, "expected return size 0, got %d\n", ret );
     todo_wine
     ok( GetLastError() == ERROR_FILE_NOT_FOUND,
-        "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+        "expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
 
     /* Existing empty section with no keys */
     SetLastError(0xdeadbeef);
     ret=GetPrivateProfileSectionA("section2", buf, sizeof(buf), testfile4);
     ok( ret == 0, "expected return size 0, got %d\n", ret );
     ok( GetLastError() == ERROR_SUCCESS,
-        "expected ERROR_SUCCESS, got %d\n", GetLastError());
+        "expected ERROR_SUCCESS, got %ld\n", GetLastError());
 
     /* Existing section with keys and values*/
     SetLastError(0xdeadbeef);
@@ -238,7 +238,7 @@ static void test_profile_sections(void)
             ret, buf);
     ok( buf[ret-1] == 0 && buf[ret] == 0, "returned buffer not terminated with double-null\n" );
     ok( GetLastError() == ERROR_SUCCESS,
-        "expected ERROR_SUCCESS, got %d\n", GetLastError());
+        "expected ERROR_SUCCESS, got %ld\n", GetLastError());
 
     /* Existing section with no keys but has values */
     SetLastError(0xdeadbeef);
@@ -250,7 +250,7 @@ static void test_profile_sections(void)
             ret, buf);
     ok( buf[ret-1] == 0 && buf[ret] == 0, "returned buffer not terminated with double-null\n" );
     ok( GetLastError() == ERROR_SUCCESS,
-        "expected ERROR_SUCCESS, got %d\n", GetLastError());
+        "expected ERROR_SUCCESS, got %ld\n", GetLastError());
 
     /* Overflow*/
     ret=GetPrivateProfileSectionA("section1", buf, 24, testfile4);
@@ -394,24 +394,24 @@ static void test_profile_existing(void)
         {
             if (!ret)
                 ok( broken(GetLastError() == pe[i].broken_error),
-                    "%d: WritePrivateProfileString failed with error %u\n", i, GetLastError() );
+                    "%d: WritePrivateProfileString failed with error %lu\n", i, GetLastError() );
             CloseHandle(h);
             size = GetPrivateProfileStringA(SECTION, KEY, 0, buffer, MAX_PATH, testfile1);
             if (ret)
-                ok( size == 5, "%d: test failed, number of characters copied: %d instead of 5\n", i, size );
+                ok( size == 5, "%d: test failed, number of characters copied: %ld instead of 5\n", i, size );
             else
-                ok( !size, "%d: test failed, number of characters copied: %d instead of 0\n", i, size );
+                ok( !size, "%d: test failed, number of characters copied: %ld instead of 0\n", i, size );
         }
         else
         {
             DWORD err = GetLastError();
             ok( !ret, "%d: WritePrivateProfileString succeeded\n", i );
             if (!ret)
-                ok( err == pe[i].write_error, "%d: WritePrivateProfileString failed with error %u/%u\n",
+                ok( err == pe[i].write_error, "%d: WritePrivateProfileString failed with error %lu/%lu\n",
                     i, err, pe[i].write_error );
             CloseHandle(h);
             size = GetPrivateProfileStringA(SECTION, KEY, 0, buffer, MAX_PATH, testfile1);
-            ok( !size, "%d: test failed, number of characters copied: %d instead of 0\n", i, size );
+            ok( !size, "%d: test failed, number of characters copied: %ld instead of 0\n", i, size );
         }
 
         ok( DeleteFileA(testfile1), "delete failed\n" );
@@ -430,7 +430,7 @@ static void test_profile_existing(void)
         SetLastError(0xdeadbeef);
         ret = GetPrivateProfileStringA(SECTION, KEY, NULL, buffer, MAX_PATH, testfile2);
         if (!pe[i].read_error)
-            ok( ret, "%d: GetPrivateProfileString failed with error %u\n", i, GetLastError() );
+            ok( ret, "%d: GetPrivateProfileString failed with error %lu\n", i, GetLastError() );
         else
             ok( !ret, "%d: GetPrivateProfileString succeeded\n", i );
         CloseHandle(h);
@@ -448,12 +448,12 @@ static void test_profile_delete_on_close(void)
     h = CreateFileA(testfile, GENERIC_WRITE, FILE_SHARE_READ, NULL,
                     CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
     res = WriteFile( h, contents, sizeof contents - 1, &size, NULL );
-    ok( res, "Cannot write test file: %x\n", GetLastError() );
+    ok( res, "Cannot write test file: %lx\n", GetLastError() );
     ok( size == sizeof contents - 1, "Test file: partial write\n");
 
     SetLastError(0xdeadbeef);
     res = GetPrivateProfileIntA(SECTION, KEY, 0, testfile);
-    ok( res == 123, "Got %d instead of 123\n", res);
+    ok( res == 123, "Got %ld instead of 123\n", res);
 
     /* This also deletes the file */
     CloseHandle(h);
@@ -470,12 +470,12 @@ static void test_profile_refresh(void)
     h = CreateFileA(testfile, GENERIC_WRITE, FILE_SHARE_READ, NULL,
                     CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
     res = WriteFile( h, contents1, sizeof contents1 - 1, &size, NULL );
-    ok( res, "Cannot write test file: %x\n", GetLastError() );
+    ok( res, "Cannot write test file: %lx\n", GetLastError() );
     ok( size == sizeof contents1 - 1, "Test file: partial write\n");
 
     SetLastError(0xdeadbeef);
     res = GetPrivateProfileIntA(SECTION, KEY, 0, testfile);
-    ok( res == 123, "Got %d instead of 123\n", res);
+    ok( res == 123, "Got %ld instead of 123\n", res);
 
     CloseHandle(h);
 
@@ -484,12 +484,12 @@ static void test_profile_refresh(void)
     h = CreateFileA(testfile, GENERIC_WRITE, FILE_SHARE_READ, NULL,
                     CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
     res = WriteFile( h, contents2, sizeof contents2 - 1, &size, NULL );
-    ok( res, "Cannot write test file: %x\n", GetLastError() );
+    ok( res, "Cannot write test file: %lx\n", GetLastError() );
     ok( size == sizeof contents2 - 1, "Test file: partial write\n");
 
     SetLastError(0xdeadbeef);
     res = GetPrivateProfileIntA(SECTION, KEY, 0, testfile);
-    ok( res == 124, "Got %d instead of 124\n", res);
+    ok( res == 124, "Got %ld instead of 124\n", res);
 
     /* This also deletes the file */
     CloseHandle(h);
@@ -497,7 +497,7 @@ static void test_profile_refresh(void)
     /* Cache must be invalidated if file no longer exists and default must be returned */
     SetLastError(0xdeadbeef);
     res = GetPrivateProfileIntA(SECTION, KEY, 421, testfile);
-    ok( res == 421, "Got %d instead of 421\n", res);
+    ok( res == 421, "Got %ld instead of 421\n", res);
 }
 
 static void create_test_file(LPCSTR name, LPCSTR data, DWORD size)
@@ -536,7 +536,7 @@ static void test_profile_directory_readonly(void)
 
     attributes.nLength = sizeof(attributes);
     ret = ConvertStringSecurityDescriptorToSecurityDescriptorA(sddl_string_everyone_readonly, SDDL_REVISION_1, &attributes.lpSecurityDescriptor, NULL);
-    ok(ret == TRUE, "ConvertStringSecurityDescriptorToSecurityDescriptor failed: %d\n", GetLastError());
+    ok(ret == TRUE, "ConvertStringSecurityDescriptorToSecurityDescriptor failed: %ld\n", GetLastError());
 
     GetTempPathA(MAX_PATH, path_folder);
     lstrcatA(path_folder, "wine-test");
@@ -545,7 +545,7 @@ static void test_profile_directory_readonly(void)
     lstrcatA(path_file, "\\tmp.ini");
 
     ret = CreateDirectoryA(path_folder, &attributes);
-    ok(ret == TRUE, "CreateDirectoryA failed: %d\n", GetLastError());
+    ok(ret == TRUE, "CreateDirectoryA failed: %ld\n", GetLastError());
 
     ret = WritePrivateProfileStringA("App", "key", "string", path_file);
     ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
@@ -557,7 +557,7 @@ static void test_profile_directory_readonly(void)
     ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
 
     ret = RemoveDirectoryA(path_folder);
-    ok(ret == TRUE, "RemoveDirectoryA failed: %d\n", GetLastError());
+    ok(ret == TRUE, "RemoveDirectoryA failed: %ld\n", GetLastError());
 
     LocalFree(attributes.lpSecurityDescriptor);
 }
@@ -589,7 +589,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA(NULL, "name1", "default",
                                    buf, MAX_PATH, filename);
-    ok(ret == 18, "Expected 18, got %d\n", ret);
+    ok(ret == 18, "Expected 18, got %ld\n", ret);
     len = lstrlenA("section1") + sizeof(CHAR) + lstrlenA("section2") + 2 * sizeof(CHAR);
 
     ok(!memcmp(buf, "section1\0section2\0", len),
@@ -601,7 +601,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA(emptystr, "name1", "default",
                                    buf, MAX_PATH, filename);
-    ok(ret == 7, "Expected 7, got %d\n", ret);
+    ok(ret == 7, "Expected 7, got %ld\n", ret);
     ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
     ok(emptystr_ok(emptystr), "AppName modified\n");
 
@@ -610,7 +610,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("notasection", "name1", "default",
                                    buf, MAX_PATH, filename);
-    ok(ret == 7, "Expected 7, got %d\n", ret);
+    ok(ret == 7, "Expected 7, got %ld\n", ret);
     ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
 
     /* lpAppName is empty, lpDefault is NULL */
@@ -618,7 +618,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA(emptystr, "name1", NULL,
                                    buf, MAX_PATH, filename);
-    ok(ret == 0, "Expected 0, got %d\n", ret);
+    ok(ret == 0, "Expected 0, got %ld\n", ret);
     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
     ok(emptystr_ok(emptystr), "AppName modified\n");
 
@@ -627,7 +627,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA(emptystr, "name1", "",
                                    buf, MAX_PATH, filename);
-    ok(ret == 0, "Expected 0, got %d\n", ret);
+    ok(ret == 0, "Expected 0, got %ld\n", ret);
     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
     ok(emptystr_ok(emptystr), "AppName modified\n");
 
@@ -638,7 +638,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(def_val, "default  ");
     ret = GetPrivateProfileStringA(emptystr, "name1", def_val,
                                    buf, MAX_PATH, filename);
-    ok(ret == 7, "Expected 7, got %d\n", ret);
+    ok(ret == 7, "Expected 7, got %ld\n", ret);
     ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
     ok(emptystr_ok(emptystr), "AppName modified\n");
 
@@ -649,7 +649,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(def_val, "one two  ");
     ret = GetPrivateProfileStringA(emptystr, "name1", def_val,
                                    buf, MAX_PATH, filename);
-    ok(ret == 7, "Expected 7, got %d\n", ret);
+    ok(ret == 7, "Expected 7, got %ld\n", ret);
     ok(!lstrcmpA(buf, "one two"), "Expected \"one two\", got \"%s\"\n", buf);
     ok(emptystr_ok(emptystr), "AppName modified\n");
 
@@ -658,7 +658,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA(emptystr, "name1", "one two",
                                    buf, MAX_PATH, filename);
-    ok(ret == 7, "Expected 7, got %d\n", ret);
+    ok(ret == 7, "Expected 7, got %ld\n", ret);
     ok(!lstrcmpA(buf, "one two"), "Expected \"one two\", got \"%s\"\n", buf);
     ok(emptystr_ok(emptystr), "AppName modified\n");
 
@@ -667,7 +667,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", NULL, "default",
                                    buf, MAX_PATH, filename);
-    ok(ret == 18, "Expected 18, got %d\n", ret);
+    ok(ret == 18, "Expected 18, got %ld\n", ret);
     ok(!memcmp(buf, "name1\0name2\0name4\0", ret + 1),
        "Expected \"name1\\x00name2\\x00name4\\x00\\x00\", got %s\n",
        debugstr_an(buf, (ret + 2 >= MAX_PATH ? MAX_PATH : ret + 1)));
@@ -677,7 +677,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", emptystr, "default",
                                    buf, MAX_PATH, filename);
-    ok(ret == 7, "Expected 7, got %d\n", ret);
+    ok(ret == 7, "Expected 7, got %ld\n", ret);
     ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
     ok(emptystr_ok(emptystr), "KeyName modified\n");
 
@@ -686,7 +686,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", "notakey", "default",
                                    buf, MAX_PATH, filename);
-    ok(ret == 7, "Expected 7, got %d\n", ret);
+    ok(ret == 7, "Expected 7, got %ld\n", ret);
     ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
 
     /* lpKeyName is empty, lpDefault is NULL */
@@ -694,7 +694,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", emptystr, NULL,
                                    buf, MAX_PATH, filename);
-    ok(ret == 0, "Expected 0, got %d\n", ret);
+    ok(ret == 0, "Expected 0, got %ld\n", ret);
     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
     ok(emptystr_ok(emptystr), "KeyName modified\n");
 
@@ -703,7 +703,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", emptystr, "",
                                    buf, MAX_PATH, filename);
-    ok(ret == 0, "Expected 0, got %d\n", ret);
+    ok(ret == 0, "Expected 0, got %ld\n", ret);
     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
     ok(emptystr_ok(emptystr), "KeyName modified\n");
 
@@ -714,7 +714,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(def_val, "default  ");
     ret = GetPrivateProfileStringA("section1", emptystr, def_val,
                                    buf, MAX_PATH, filename);
-    ok(ret == 7, "Expected 7, got %d\n", ret);
+    ok(ret == 7, "Expected 7, got %ld\n", ret);
     ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
     ok(emptystr_ok(emptystr), "KeyName modified\n");
 
@@ -730,7 +730,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", "name1", "default",
                                    buf, MAX_PATH, NULL);
-    ok(ret == 7, "Expected 7, got %d\n", ret);
+    ok(ret == 7, "Expected 7, got %ld\n", ret);
     ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
 
     /* lpFileName is empty */
@@ -738,7 +738,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", "name1", "default",
                                    buf, MAX_PATH, "");
-    ok(ret == 7, "Expected 7, got %d\n", ret);
+    ok(ret == 7, "Expected 7, got %ld\n", ret);
     ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
 
     /* lpFileName is nonexistent */
@@ -746,7 +746,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", "name1", "default",
                                    buf, MAX_PATH, "nonexistent");
-    ok(ret == 7, "Expected 7, got %d\n", ret);
+    ok(ret == 7, "Expected 7, got %ld\n", ret);
     ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
 
     /* nSize is 0 */
@@ -754,7 +754,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", "name1", "default",
                                    buf, 0, filename);
-    ok(ret == 0, "Expected 0, got %d\n", ret);
+    ok(ret == 0, "Expected 0, got %ld\n", ret);
     ok(!lstrcmpA(buf, "kumquat"), "Expected buf to be unchanged, got \"%s\"\n", buf);
 
     /* nSize is exact size of output */
@@ -762,7 +762,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", "name1", "default",
                                    buf, 4, filename);
-    ok(ret == 3, "Expected 3, got %d\n", ret);
+    ok(ret == 3, "Expected 3, got %ld\n", ret);
     ok(!lstrcmpA(buf, "val"), "Expected \"val\", got \"%s\"\n", buf);
 
     /* nSize has room for NULL terminator */
@@ -770,7 +770,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", "name1", "default",
                                    buf, 5, filename);
-    ok(ret == 4, "Expected 4, got %d\n", ret);
+    ok(ret == 4, "Expected 4, got %ld\n", ret);
     ok(!lstrcmpA(buf, "val1"), "Expected \"val1\", got \"%s\"\n", buf);
 
     /* output is 1 character */
@@ -778,7 +778,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", "name4", "default",
                                    buf, MAX_PATH, filename);
-    ok(ret == 1, "Expected 1, got %d\n", ret);
+    ok(ret == 1, "Expected 1, got %ld\n", ret);
     ok(!lstrcmpA(buf, "a"), "Expected \"a\", got \"%s\"\n", buf);
 
     /* output is 1 character, no room for NULL terminator */
@@ -786,7 +786,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", "name4", "default",
                                    buf, 1, filename);
-    ok(ret == 0, "Expected 0, got %d\n", ret);
+    ok(ret == 0, "Expected 0, got %ld\n", ret);
     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
 
     /* lpAppName is NULL, not enough room for final section name */
@@ -794,7 +794,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA(NULL, "name1", "default",
                                    buf, 16, filename);
-    ok(ret == 14, "Expected 14, got %d\n", ret);
+    ok(ret == 14, "Expected 14, got %ld\n", ret);
     len = lstrlenA("section1") + 2 * sizeof(CHAR);
     todo_wine
     ok(!memcmp(buf, "section1\0secti\0", ret + 2),
@@ -806,7 +806,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", NULL, "default",
                                    buf, 16, filename);
-    ok(ret == 14, "Expected 14, got %d\n", ret);
+    ok(ret == 14, "Expected 14, got %ld\n", ret);
     todo_wine
     ok(!memcmp(buf, "name1\0name2\0na\0", ret + 2),
        "Expected \"name1\\x00name2\\x00na\\x00\\x00\", got %s\n",
@@ -817,7 +817,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", "name2", "default",
                                    buf, MAX_PATH, filename);
-    ok(ret == 4, "Expected 4, got %d\n", ret);
+    ok(ret == 4, "Expected 4, got %ld\n", ret);
     ok(!lstrcmpA(buf, "val2"), "Expected \"val2\", got \"%s\"\n", buf);
 
     /* case does not match */
@@ -825,7 +825,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", "NaMe1", "default",
                                    buf, MAX_PATH, filename);
-    ok(ret == 4, "Expected 4, got %d\n", ret);
+    ok(ret == 4, "Expected 4, got %ld\n", ret);
     ok(!lstrcmpA(buf, "val1"), "Expected \"val1\", got \"%s\"\n", buf);
 
     /* only filename is used */
@@ -833,7 +833,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", "NaMe1", "default",
                                    buf, MAX_PATH, "winetest.ini");
-    ok(ret == 7, "Expected 7, got %d\n", ret);
+    ok(ret == 7, "Expected 7, got %ld\n", ret);
     ok(!lstrcmpA(buf, "default"), "Expected \"default\", got \"%s\"\n", buf);
 
     GetWindowsDirectoryA(windir, MAX_PATH);
@@ -853,7 +853,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", "NaMe1", "default",
                                    buf, MAX_PATH, tempfile);
-    ok(ret == 4, "Expected 4, got %d\n", ret);
+    ok(ret == 4, "Expected 4, got %ld\n", ret);
     ok(!lstrcmpA(buf, "val1"), "Expected \"val1\", got \"%s\"\n", buf);
 
     /* successful case */
@@ -861,7 +861,7 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     lstrcpyA(buf, "kumquat");
     ret = GetPrivateProfileStringA("section1", "name1", "default",
                                    buf, MAX_PATH, filename);
-    ok(ret == 4, "Expected 4, got %d\n", ret);
+    ok(ret == 4, "Expected 4, got %ld\n", ret);
     ok(!lstrcmpA(buf, "val1"), "Expected \"val1\", got \"%s\"\n", buf);
 
  /* Existing section with no keys in an existing file */
@@ -869,12 +869,12 @@ static void test_GetPrivateProfileString(const char *content, const char *descri
     SetLastError(0xdeadbeef);
     ret=GetPrivateProfileStringA("section2", "DoesntExist", "",
                                  buf, MAX_PATH, filename);
-    ok( ret == 0, "expected return size 0, got %d\n", ret );
+    ok( ret == 0, "expected return size 0, got %ld\n", ret );
     ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
     todo_wine
    ok( GetLastError() == 0xdeadbeef ||
        GetLastError() == ERROR_FILE_NOT_FOUND /* Win 7 */,
-       "expected 0xdeadbeef or ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+       "expected 0xdeadbeef or ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
 
 
     DeleteFileA(path);
@@ -929,7 +929,7 @@ static void test_WritePrivateProfileString(void)
     ret = WritePrivateProfileStringA(NULL, "key", "string", path);
     ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
     ok(GetLastError() == ERROR_FILE_NOT_FOUND,
-       "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+       "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
     ok(GetFileAttributesA(path) == INVALID_FILE_ATTRIBUTES,
        "Expected path to not exist\n");
 
@@ -941,7 +941,7 @@ static void test_WritePrivateProfileString(void)
     ret = WritePrivateProfileStringA(NULL, "key", "string", path);
     ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
     ok(GetLastError() == ERROR_FILE_NOT_FOUND,
-       "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+       "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
     ok(check_file_data(path, data), "File doesn't match\n");
     DeleteFileA(path);
 
@@ -1003,7 +1003,7 @@ static void test_WritePrivateProfileString(void)
     ret = WritePrivateProfileStringA("App", "key", "string", "");
     ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
     ok(GetLastError() == ERROR_ACCESS_DENIED,
-       "Expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+       "Expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
 
     /* Relative paths are relative to X:\\%WINDIR% */
     GetWindowsDirectoryA(path, MAX_PATH);
@@ -1019,7 +1019,7 @@ static void test_WritePrivateProfileString(void)
         data = "[App]\r\n"
                "key=string\r\n";
         ret = WritePrivateProfileStringA("App", "key", "string", "win1.tmp");
-        ok(ret == TRUE, "Expected TRUE, got %d, le=%u\n", ret, GetLastError());
+        ok(ret == TRUE, "Expected TRUE, got %d, le=%lu\n", ret, GetLastError());
         ok(check_file_data(path, data), "File doesn't match\n");
         DeleteFileA(path);
     }
@@ -1115,25 +1115,25 @@ static void test_profile_struct(void)
     SetLastError(0xdeadbeef);
     ret = GetPrivateProfileStructA("s", "key", buffer, sizeof(buffer), "./winetest.ini");
     ok(!ret, "expected failure\n");
-    todo_wine ok(GetLastError() == ERROR_BAD_LENGTH, "got error %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_BAD_LENGTH, "got error %lu\n", GetLastError());
 
     ret = WritePrivateProfileStructA("s", "key", (void *)"abacus", sizeof("abacus"), "./winetest.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ok(check_file_data("./winetest.ini", expect_data), "file doesn't match\n");
 
     SetLastError(0xdeadbeef);
     ret = GetPrivateProfileStructA("s", "key", buffer, 6, "./winetest.ini");
     ok(!ret, "expected failure\n");
-    todo_wine ok(GetLastError() == ERROR_BAD_LENGTH, "got error %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_BAD_LENGTH, "got error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = GetPrivateProfileStructA("s", "key", buffer, 8, "./winetest.ini");
     ok(!ret, "expected failure\n");
-    todo_wine ok(GetLastError() == ERROR_BAD_LENGTH, "got error %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_BAD_LENGTH, "got error %lu\n", GetLastError());
 
     memset(buffer, 0xcc, sizeof(buffer));
     ret = GetPrivateProfileStructA("s", "key", buffer, 7, "./winetest.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ok(!strcmp(buffer, "abacus"), "data didn't match\n");
 
     memset(buffer, 0xcc, sizeof(buffer));
@@ -1142,39 +1142,39 @@ static void test_profile_struct(void)
     ok(!strcmp(buffer, "616261637573006F"), "got %s\n", debugstr_a(buffer));
 
     ret = WritePrivateProfileStringA("s", "key", "636163747573006F", "./winetest.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = GetPrivateProfileStructA("s", "key", buffer, 7, "./winetest.ini");
     ok(!ret, "expected failure\n");
-    todo_wine ok(GetLastError() == ERROR_INVALID_DATA, "got error %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_INVALID_DATA, "got error %lu\n", GetLastError());
 
     ret = WritePrivateProfileStringA("s", "key", "6361637475730083", "./winetest.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     memset(buffer, 0xcc, sizeof(buffer));
     ret = GetPrivateProfileStructA("s", "key", buffer, 7, "./winetest.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ok(!strcmp(buffer, "cactus"), "data didn't match\n");
 
     ret = WritePrivateProfileStringA("s", "key", "636163747573008Q", "./winetest.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = GetPrivateProfileStructA("s", "key", buffer, 7, "./winetest.ini");
     ok(!ret, "expected failure\n");
-    todo_wine ok(GetLastError() == ERROR_INVALID_DATA, "got error %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_INVALID_DATA, "got error %lu\n", GetLastError());
 
     ret = WritePrivateProfileStringA("s", "key", "16361637475730083", "./winetest.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = GetPrivateProfileStructA("s", "key", buffer, 7, "./winetest.ini");
     ok(!ret, "expected failure\n");
-    todo_wine ok(GetLastError() == ERROR_BAD_LENGTH, "got error %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_BAD_LENGTH, "got error %lu\n", GetLastError());
 
     ret = DeleteFileA("./winetest.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 }
 
 static void check_registry_value_(int line, HKEY key, const char *value, const char *expect)
@@ -1185,9 +1185,9 @@ static void check_registry_value_(int line, HKEY key, const char *value, const c
 
     memset(buffer, 0xcc, sizeof(buffer));
     ret = RegQueryValueExA(key, value, 0, &type, (BYTE *)buffer, &size);
-    ok_(__FILE__, line)(!ret, "got error %u\n", ret);
+    ok_(__FILE__, line)(!ret, "got error %lu\n", ret);
     ok_(__FILE__, line)(!strcmp(buffer, expect), "expected %s, got %s\n", debugstr_a(expect), debugstr_a(buffer));
-    ok_(__FILE__, line)(type == REG_SZ, "got type %u\n", type);
+    ok_(__FILE__, line)(type == REG_SZ, "got type %lu\n", type);
 }
 #define check_registry_value(a, b, c) check_registry_value_(__LINE__, a, b, c)
 
@@ -1200,7 +1200,7 @@ static void test_registry_mapping(void)
 
     /* impersonate ourselves to prevent registry virtualization */
     ret = ImpersonateSelf(SecurityImpersonation);
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     ret = RegCreateKeyExA(HKEY_LOCAL_MACHINE,
             "Software\\Microsoft\\Windows NT\\CurrentVersion\\IniFileMapping\\winetest_map.ini",
@@ -1210,27 +1210,27 @@ static void test_registry_mapping(void)
         skip("Not enough permissions to write to the IniFileMapping key.\n");
         return;
     }
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
 
     ret = RegSetValueExA(mapping_key, "section1", 0, REG_SZ, (BYTE *)"USR:winetest_map", sizeof("USR:winetest_map"));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = WritePrivateProfileStringA(NULL, NULL, NULL, "winetest_map.ini");
-    todo_wine ok(ret, "got error %u\n", GetLastError());
+    todo_wine ok(ret, "got error %lu\n", GetLastError());
 
     check_profile_string("section1", "name1", "winetest_map.ini", "default");
 
     ret = WritePrivateProfileStringA("section1", "name1", "value1", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     check_profile_string("section1", "name1", "winetest_map.ini", "value1");
     check_profile_string("section1", "name1", "C:/fake/path/winetest_map.ini", "value1");
 
     ret = RegOpenKeyExA(HKEY_CURRENT_USER, "winetest_map", 0, KEY_READ | KEY_WRITE, &mapped_key);
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     check_registry_value(mapped_key, "name1", "value1");
 
     ret = RegSetValueExA(mapped_key, "name2", 0, REG_SZ, (BYTE *)"value2", sizeof("value2"));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
 
     check_profile_string("section1", "name2", "winetest_map.ini", "value2");
 
@@ -1238,40 +1238,40 @@ static void test_registry_mapping(void)
     ok(ret == INVALID_FILE_ATTRIBUTES, "winetest_map.ini should not exist.\n");
 
     ret = WritePrivateProfileStringA("section1", "name2", NULL, "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ret = RegQueryValueExA(mapped_key, "name2", 0, NULL, NULL, NULL);
-    ok(ret == ERROR_FILE_NOT_FOUND, "got error %u\n", ret);
+    ok(ret == ERROR_FILE_NOT_FOUND, "got error %lu\n", ret);
 
     /* Test non-string types. */
 
     ret = RegSetValueExA(mapped_key, "name3", 0, REG_DWORD, (BYTE *)&ivalue, sizeof(ivalue));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     check_profile_string("section1", "name3", "winetest_map.ini", "default");
 
     ret = GetPrivateProfileIntA("section1", "name3", 0, "winetest_map.ini");
-    ok(ret == 0, "got %#x\n", ret);
+    ok(ret == 0, "got %#lx\n", ret);
 
     ret = RegSetValueExA(mapped_key, "name3", 0, REG_BINARY, (BYTE *)"value3", sizeof("value3"));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     check_profile_string("section1", "name3", "winetest_map.ini", "default");
 
     ret = RegSetValueExA(mapped_key, "name3", 0, REG_MULTI_SZ, (BYTE *)"one\0two\0", sizeof("one\0two\0"));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     check_profile_string("section1", "name3", "winetest_map.ini", "default");
 
     ret = RegSetValueExA(mapped_key, "name3", 0, REG_EXPAND_SZ, (BYTE *)"x%SystemRoot%", sizeof("x%SystemRoot%"));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     check_profile_string("section1", "name3", "winetest_map.ini", "default");
 
     /* Test WritePrivateProfileSection(). Unlike with .ini files, it doesn't
      * remove existing entries. */
 
     ret = WritePrivateProfileStringA("section1", "name4", "value4", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ret = WritePrivateProfileStringA("section1", "name5", "value5", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ret = WritePrivateProfileSectionA("section1", "name4=four\0name6=six\0", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     check_profile_string("section1", "name4", "winetest_map.ini", "four");
     check_profile_string("section1", "name5", "winetest_map.ini", "value5");
     check_profile_string("section1", "name6", "winetest_map.ini", "six");
@@ -1281,74 +1281,74 @@ static void test_registry_mapping(void)
     RegCloseKey(mapped_key);
 
     ret = RegCreateKeyExA(HKEY_CURRENT_USER, "winetest_map\\subkey", 0, NULL, 0, 0, NULL, &mapped_key, NULL);
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     RegCloseKey(mapped_key);
 
     ret = WritePrivateProfileStringA("section1", "name1", "value1", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ret = WritePrivateProfileStringA("section1", NULL, NULL, "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     check_profile_string("section1", "name1", "winetest_map.ini", "default");
 
     ret = WritePrivateProfileStringA("section1", "name1", "value1", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ret = WritePrivateProfileSectionA("section1", NULL, "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     check_profile_string("section1", "name1", "winetest_map.ini", "default");
 
     ret = RegDeleteKeyA(HKEY_CURRENT_USER, "winetest_map\\subkey");
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = RegDeleteKeyA(HKEY_CURRENT_USER, "winetest_map");
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
 
     /* Test GetPrivateProfileSectionNames(). */
 
     memset(buffer, 0xcc, sizeof(buffer));
     ret = GetPrivateProfileSectionNamesA(buffer, 5, "winetest_map.ini");
-    ok(ret == 3, "got %u\n", ret);
+    ok(ret == 3, "got %lu\n", ret);
     ok(!memcmp(buffer, "sec\0", 5), "got %s\n", debugstr_an(buffer, ret));
 
     memset(buffer, 0xcc, sizeof(buffer));
     ret = GetPrivateProfileSectionNamesA(buffer, sizeof(buffer), "winetest_map.ini");
-    ok(ret == 9, "got %u\n", ret);
+    ok(ret == 9, "got %lu\n", ret);
     ok(!memcmp(buffer, "section1\0", 10), "got %s\n", debugstr_an(buffer, ret));
 
     ret = WritePrivateProfileStringA("file_section", "name1", "value1", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     memset(buffer, 0xcc, sizeof(buffer));
     ret = GetPrivateProfileSectionNamesA(buffer, 5, "winetest_map.ini");
-    ok(ret == 3, "got %u\n", ret);
+    ok(ret == 3, "got %lu\n", ret);
     ok(!memcmp(buffer, "sec\0", 5), "got %s\n", debugstr_an(buffer, ret));
 
     memset(buffer, 0xcc, sizeof(buffer));
     ret = GetPrivateProfileSectionNamesA(buffer, sizeof(buffer), "winetest_map.ini");
-    ok(ret == 22, "got %u\n", ret);
+    ok(ret == 22, "got %lu\n", ret);
     ok(!memcmp(buffer, "section1\0file_section\0", 23), "got %s\n", debugstr_an(buffer, ret));
 
     ret = DeleteFileA("C:/windows/winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     /* Test the SYS: prefix. */
 
     ret = RegSetValueExA(mapping_key, "section2", 0, REG_SZ, (BYTE *)"SYS:winetest_map", sizeof("SYS:winetest_map"));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = WritePrivateProfileStringA(NULL, NULL, NULL, "winetest_map.ini");
-    todo_wine ok(ret, "got error %u\n", GetLastError());
+    todo_wine ok(ret, "got error %lu\n", GetLastError());
 
     check_profile_string("section2", "name1", "winetest_map.ini", "default");
 
     ret = WritePrivateProfileStringA("section2", "name1", "value1", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     check_profile_string("section2", "name1", "winetest_map.ini", "value1");
 
     ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\winetest_map", 0, KEY_READ | KEY_WRITE, &mapped_key);
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     check_registry_value(mapped_key, "name1", "value1");
 
     ret = RegSetValueExA(mapped_key, "name2", 0, REG_SZ, (BYTE *)"value2", sizeof("value2"));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
 
     check_profile_string("section2", "name2", "winetest_map.ini", "value2");
 
@@ -1356,75 +1356,75 @@ static void test_registry_mapping(void)
     ok(ret == INVALID_FILE_ATTRIBUTES, "winetest_map.ini should not exist.\n");
 
     ret = RegDeleteKeyA(mapped_key, "");
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     RegCloseKey(mapped_key);
 
     /* Try writing directly to the .ini file on disk instead. */
 
     ret = WritePrivateProfileStringA("section3", "name1", "value1", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     check_profile_string("section3", "name1", "winetest_map.ini", "value1");
 
     ret = RegSetValueExA(mapping_key, "section3", 0, REG_SZ, (BYTE *)"USR:winetest_map", sizeof("USR:winetest_map"));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = WritePrivateProfileStringA(NULL, NULL, NULL, "winetest_map.ini");
-    todo_wine ok(ret, "got error %u\n", GetLastError());
+    todo_wine ok(ret, "got error %lu\n", GetLastError());
 
     check_profile_string("section3", "name1", "winetest_map.ini", "default");
 
     ret = RegOpenKeyExA(HKEY_CURRENT_USER, "winetest_section3", 0, KEY_READ | KEY_WRITE, &mapped_key);
-    ok(ret == ERROR_FILE_NOT_FOUND, "got error %u\n", ret);
+    ok(ret == ERROR_FILE_NOT_FOUND, "got error %lu\n", ret);
 
     ret = WritePrivateProfileStringA("section3", "name1", "value2", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     check_profile_string("section3", "name1", "winetest_map.ini", "value2");
 
     ret = RegOpenKeyExA(HKEY_CURRENT_USER, "winetest_map", 0, KEY_READ | KEY_WRITE, &mapped_key);
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
 
     ret = RegDeleteKeyA(mapped_key, "");
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     RegCloseKey(mapped_key);
 
     ret = RegDeleteValueA(mapping_key, "section3");
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = WritePrivateProfileStringA(NULL, NULL, NULL, "winetest_map.ini");
-    todo_wine ok(ret, "got error %u\n", GetLastError());
+    todo_wine ok(ret, "got error %lu\n", GetLastError());
 
     check_profile_string("section3", "name1", "winetest_map.ini", "value1");
 
     ret = DeleteFileA("C:/windows/winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     /* Test default keys. */
 
     ret = WritePrivateProfileStringA("section4", "name1", "value1", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     check_profile_string("section4", "name1", "winetest_map.ini", "value1");
 
     ret = DeleteFileA("C:/windows/winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     ret = RegSetValueExA(mapping_key, NULL, 0, REG_SZ, (BYTE *)"SYS:winetest_default", sizeof("SYS:winetest_default"));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = WritePrivateProfileStringA(NULL, NULL, NULL, "winetest_map.ini");
-    todo_wine ok(ret, "got error %u\n", GetLastError());
+    todo_wine ok(ret, "got error %lu\n", GetLastError());
 
     ret = WritePrivateProfileStringA("section4", "name1", "value1", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\winetest_default\\section4", 0, KEY_READ, &mapped_key);
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     check_registry_value(mapped_key, "name1", "value1");
     RegCloseKey(mapped_key);
 
     ret = RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\winetest_default\\section5",
             0, NULL, 0, KEY_WRITE, NULL, &mapped_key, NULL);
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = RegSetValueExA(mapped_key, "name2", 0, REG_SZ, (BYTE *)"value2", sizeof("value2"));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     RegCloseKey(mapped_key);
 
     check_profile_string("section5", "name2", "winetest_map.ini", "value2");
@@ -1435,157 +1435,157 @@ static void test_registry_mapping(void)
     ret = RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\winetest_default\\Section4");
     ret = RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\winetest_default\\Section5");
     ret = RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\winetest_default");
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = RegDeleteValueA(mapping_key, NULL);
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
 
     /* Test name-specific mapping. */
 
     ret = RegCreateKeyExA(mapping_key, "section6", 0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &mapping_subkey, NULL);
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = RegSetValueExA(mapping_subkey, "name1", 0, REG_SZ, (BYTE *)"USR:winetest_name1", sizeof("USR:winetest_name1"));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = RegSetValueExA(mapping_subkey, "name2", 0, REG_SZ, (BYTE *)"SYS:winetest_name2", sizeof("SYS:winetest_name2"));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = WritePrivateProfileStringA(NULL, NULL, NULL, "winetest_map.ini");
-    todo_wine ok(ret, "got error %u\n", GetLastError());
+    todo_wine ok(ret, "got error %lu\n", GetLastError());
 
     ret = WritePrivateProfileStringA("section6", "name1", "value1", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     check_profile_string("section6", "name1", "winetest_map.ini", "value1");
 
     ret = RegOpenKeyExA(HKEY_CURRENT_USER, "winetest_name1", 0, KEY_READ | KEY_WRITE, &mapped_key);
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     check_registry_value(mapped_key, "name1", "value1");
 
     ret = RegSetValueExA(mapped_key, "name1", 0, REG_SZ, (BYTE *)"one", sizeof("one"));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     check_profile_string("section6", "name1", "winetest_map.ini", "one");
 
     ret = RegDeleteKeyA(mapped_key, "");
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     RegCloseKey(mapped_key);
 
     ret = WritePrivateProfileStringA("section6", "name2", "value2", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\winetest_name2", 0, KEY_READ | KEY_WRITE, &mapped_key);
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     check_registry_value(mapped_key, "name2", "value2");
 
     ret = RegSetValueExA(mapped_key, "name2", 0, REG_SZ, (BYTE *)"two", sizeof("two"));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     check_profile_string("section6", "name2", "winetest_map.ini", "two");
 
     ret = RegDeleteKeyA(mapped_key, "");
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     RegCloseKey(mapped_key);
 
     ret = WritePrivateProfileStringA("section6", "name3", "value3", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     check_profile_string("section6", "name3", "winetest_map.ini", "value3");
     ret = DeleteFileA("C:/windows/winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     /* Test name-specific mapping with Get/WritePrivateProfileSection(). */
 
     ret = WritePrivateProfileStringA("section6", "name2", "value2", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     ret = WritePrivateProfileStringA("section6", "name3", "value3", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     ret = WritePrivateProfileSectionA("section6", "name1=one\0name3=three\0", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     check_profile_string("section6", "name1", "winetest_map.ini", "one");
     check_profile_string("section6", "name2", "winetest_map.ini", "value2");
     check_profile_string("section6", "name3", "winetest_map.ini", "value3");
 
     ret = RegOpenKeyExA(HKEY_CURRENT_USER, "winetest_name1", 0, KEY_READ | KEY_WRITE, &mapped_key);
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = RegDeleteValueA(mapped_key, "name1");
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     RegCloseKey(mapped_key);
 
     memset(buffer, 0xcc, sizeof(buffer));
     ret = GetPrivateProfileSectionA("section6", buffer, 5, "winetest_map.ini");
-    ok(ret == 3, "got %u\n", ret);
+    ok(ret == 3, "got %lu\n", ret);
     ok(!memcmp(buffer, "nam\0", 5), "got %s\n", debugstr_an(buffer, ret));
 
     memset(buffer, 0xcc, sizeof(buffer));
     ret = GetPrivateProfileSectionA("section6", buffer, sizeof(buffer), "winetest_map.ini");
-    ok(ret == 26, "got %u\n", ret);
+    ok(ret == 26, "got %lu\n", ret);
     ok(!memcmp(buffer, "name2=value2\0name3=value3\0", 27), "got %s\n", debugstr_an(buffer, ret));
 
     ret = WritePrivateProfileStringA("section6", NULL, NULL, "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     check_profile_string("section6", "name1", "winetest_map.ini", "default");
     check_profile_string("section6", "name2", "winetest_map.ini", "default");
     check_profile_string("section6", "name3", "winetest_map.ini", "default");
 
     ret = RegDeleteKeyA(HKEY_CURRENT_USER, "winetest_name1");
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\winetest_name2");
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = DeleteFileA("C:/windows/winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     /* Test name-specific mapping with a default value. */
 
     ret = RegSetValueExA(mapping_subkey, NULL, 0, REG_SZ, (BYTE *)"USR:winetest_default", sizeof("USR:winetest_default"));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = WritePrivateProfileStringA(NULL, NULL, NULL, "winetest_map.ini");
-    todo_wine ok(ret, "got error %u\n", GetLastError());
+    todo_wine ok(ret, "got error %lu\n", GetLastError());
 
     ret = WritePrivateProfileStringA("section6", "name2", "value2", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ret = WritePrivateProfileStringA("section6", "name3", "value3", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     ret = RegOpenKeyExA(HKEY_CURRENT_USER, "winetest_default", 0, KEY_READ | KEY_WRITE, &mapped_key);
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     check_registry_value(mapped_key, "name3", "value3");
 
     ret = RegSetValueExA(mapped_key, "name3", 0, REG_SZ, (BYTE *)"three", sizeof("three"));
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     check_profile_string("section6", "name3", "winetest_map.ini", "three");
 
     memset(buffer, 0xcc, sizeof(buffer));
     ret = GetPrivateProfileSectionA("section6", buffer, sizeof(buffer), "winetest_map.ini");
-    ok(ret == 25, "got %u\n", ret);
+    ok(ret == 25, "got %lu\n", ret);
     todo_wine ok(!memcmp(buffer, "name2=value2\0name3=three\0", 26), "got %s\n", debugstr_an(buffer, ret));
 
     ret = WritePrivateProfileSectionA("section6", "name2=duo\0name3=treis\0", "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     check_profile_string("section6", "name2", "winetest_map.ini", "duo");
     check_profile_string("section6", "name3", "winetest_map.ini", "treis");
 
     ret = WritePrivateProfileStringA("section6", NULL, NULL, "winetest_map.ini");
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     check_profile_string("section6", "name2", "winetest_map.ini", "default");
     check_profile_string("section6", "name3", "winetest_map.ini", "default");
 
     ret = RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\winetest_name2");
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = RegDeleteKeyA(HKEY_CURRENT_USER, "winetest_name1");
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     ret = RegDeleteKeyA(mapped_key, "");
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     RegCloseKey(mapped_key);
 
     ret = RegDeleteKeyA(mapping_subkey, "");
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     RegCloseKey(mapping_subkey);
 
     ret = RegDeleteKeyA(mapping_key, "");
-    ok(!ret, "got error %u\n", ret);
+    ok(!ret, "got error %lu\n", ret);
     RegCloseKey(mapping_key);
 
     ret = DeleteFileA("C:/windows/winetest_map.ini");
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %lu\n", GetLastError());
     ret = RevertToSelf();
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 }
 
 START_TEST(profile)
diff --git a/dlls/kernel32/tests/resource.c b/dlls/kernel32/tests/resource.c
index bca0298044f..6c5bc99c0c5 100644
--- a/dlls/kernel32/tests/resource.c
+++ b/dlls/kernel32/tests/resource.c
@@ -332,10 +332,10 @@ static void update_resources_version( void )
                         MAKEINTRESOURCEA(0x4567),
                         0xabcd,
                         foo, sizeof foo );
-    ok( r == TRUE, "UpdateResource failed: %d\n", GetLastError());
+    ok( r == TRUE, "UpdateResource failed: %ld\n", GetLastError());
 
     r = EndUpdateResourceA( res, FALSE );
-    ok( r, "EndUpdateResource failed: %d\n", GetLastError());
+    ok( r, "EndUpdateResource failed: %ld\n", GetLastError());
 }
 
 static void update_resources_bigdata( void )
@@ -352,7 +352,7 @@ static void update_resources_bigdata( void )
                         MAKEINTRESOURCEA(0x5647),
                         0xcdba,
                         foo, sizeof foo );
-    ok( r == TRUE, "UpdateResource failed: %d\n", GetLastError());
+    ok( r == TRUE, "UpdateResource failed: %ld\n", GetLastError());
 
     r = EndUpdateResourceA( res, FALSE );
     ok( r, "EndUpdateResource failed\n");
@@ -367,27 +367,27 @@ static void update_resources_name( void )
     BOOL ret;
 
     res = BeginUpdateResourceA( filename, TRUE );
-    ok( res != NULL, "BeginUpdateResource failed: %u\n", GetLastError() );
+    ok( res != NULL, "BeginUpdateResource failed: %lu\n", GetLastError() );
     if ( !res ) return;
 
     ret = UpdateResourceA( res, res_type, res_name, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), foo, sizeof(foo) );
-    ok( ret == TRUE, "UpdateResource failed: %u\n", GetLastError() );
+    ok( ret == TRUE, "UpdateResource failed: %lu\n", GetLastError() );
 
     ret = EndUpdateResourceA( res, FALSE );
-    ok( ret, "EndUpdateResource failed: %u\n", GetLastError() );
+    ok( ret, "EndUpdateResource failed: %lu\n", GetLastError() );
     if ( !ret ) return;
 
     module = LoadLibraryExA( filename, NULL, LOAD_LIBRARY_AS_DATAFILE );
-    ok( module != NULL, "LoadLibraryEx failed: %u\n", GetLastError() );
+    ok( module != NULL, "LoadLibraryEx failed: %lu\n", GetLastError() );
     if ( !module ) return;
 
     rsrc = FindResourceA( module, res_name, res_type );
     ok( rsrc != NULL ||
         broken( GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND ) /* win2008 */,
-        "FindResource failed: %u\n", GetLastError() );
+        "FindResource failed: %lu\n", GetLastError() );
 
     ret = FreeLibrary(module);
-    ok( ret, "FreeLibrary failed: %u\n", GetLastError() );
+    ok( ret, "FreeLibrary failed: %lu\n", GetLastError() );
 }
 
 static void check_exe( const sec_verify *verify )
@@ -402,7 +402,7 @@ static void check_exe( const sec_verify *verify )
     DWORD length, sec_count = 0;
 
     file = CreateFileA(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
-    ok (file != INVALID_HANDLE_VALUE, "failed to create file (%d)\n", GetLastError());
+    ok (file != INVALID_HANDLE_VALUE, "failed to create file (%ld)\n", GetLastError());
 
     length = GetFileSize( file, NULL );
     ok( length >= verify->length, "file size wrong\n");
@@ -423,11 +423,11 @@ static void check_exe( const sec_verify *verify )
     for(i = 0; i < max_sections; i++)
         if (verify->sect_out[i])
         {
-            ok( !memcmp(&verify->sect_out[i]->Name, &sec[sec_count].Name, 8), "section %d name wrong\n", sec_count);
-            ok( verify->sect_out[i]->VirtualAddress == sec[sec_count].VirtualAddress, "section %d vaddr wrong\n", sec_count);
-            ok( verify->sect_out[i]->SizeOfRawData <= sec[sec_count].SizeOfRawData, "section %d SizeOfRawData wrong (%d vs %d)\n", sec_count, verify->sect_out[i]->SizeOfRawData ,sec[sec_count].SizeOfRawData);
-            ok( verify->sect_out[i]->PointerToRawData == sec[sec_count].PointerToRawData, "section %d PointerToRawData wrong\n", sec_count);
-            ok( verify->sect_out[i]->Characteristics == sec[sec_count].Characteristics , "section %d characteristics wrong\n", sec_count);
+            ok( !memcmp(&verify->sect_out[i]->Name, &sec[sec_count].Name, 8), "section %ld name wrong\n", sec_count);
+            ok( verify->sect_out[i]->VirtualAddress == sec[sec_count].VirtualAddress, "section %ld vaddr wrong\n", sec_count);
+            ok( verify->sect_out[i]->SizeOfRawData <= sec[sec_count].SizeOfRawData, "section %ld SizeOfRawData wrong (%ld vs %ld)\n", sec_count, verify->sect_out[i]->SizeOfRawData ,sec[sec_count].SizeOfRawData);
+            ok( verify->sect_out[i]->PointerToRawData == sec[sec_count].PointerToRawData, "section %ld PointerToRawData wrong\n", sec_count);
+            ok( verify->sect_out[i]->Characteristics == sec[sec_count].Characteristics , "section %ld characteristics wrong\n", sec_count);
             sec_count++;
         }
 
@@ -438,17 +438,17 @@ static void check_exe( const sec_verify *verify )
         dir = (void*) ((BYTE*) dos + sec[verify->rsrc_section].VirtualAddress);
 
         ok( dir->Characteristics == 0, "Characteristics wrong\n");
-        ok( dir->TimeDateStamp == 0, "TimeDateStamp wrong %u\n", dir->TimeDateStamp);
+        ok( dir->TimeDateStamp == 0, "TimeDateStamp wrong %lu\n", dir->TimeDateStamp);
         ok( dir->MajorVersion == 4, "MajorVersion wrong\n");
         ok( dir->MinorVersion == 0, "MinorVersion wrong\n");
 
-        ok( dir->NumberOfNamedEntries == verify->NumberOfNamedEntries, "NumberOfNamedEntries should be %d instead of %d\n",
+        ok( dir->NumberOfNamedEntries == verify->NumberOfNamedEntries, "NumberOfNamedEntries should be %ld instead of %d\n",
                 verify->NumberOfNamedEntries, dir->NumberOfNamedEntries);
-        ok( dir->NumberOfIdEntries == verify->NumberOfIdEntries, "NumberOfIdEntries should be %d instead of %d\n",
+        ok( dir->NumberOfIdEntries == verify->NumberOfIdEntries, "NumberOfIdEntries should be %ld instead of %d\n",
                 verify->NumberOfIdEntries, dir->NumberOfIdEntries);
 
         ok(opt->DataDirectory[IMAGE_FILE_RESOURCE_DIRECTORY].VirtualAddress == sec[verify->rsrc_section].VirtualAddress,
-                "VirtualAddress in optional header should be %d instead of %d\n",
+                "VirtualAddress in optional header should be %ld instead of %ld\n",
                 sec[verify->rsrc_section].VirtualAddress, opt->DataDirectory[IMAGE_FILE_RESOURCE_DIRECTORY].VirtualAddress);
     }
 
@@ -476,24 +476,24 @@ static void test_find_resource(void)
     SetLastError( 0xdeadbeef );
     rsrc = FindResourceW( GetModuleHandleW(NULL), MAKEINTRESOURCEW(1), (LPCWSTR)RT_DIALOG );
     ok( !rsrc, "resource found\n" );
-    ok( GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     rsrc = FindResourceW( GetModuleHandleW(NULL), MAKEINTRESOURCEW(2), (LPCWSTR)RT_MENU );
     ok( !rsrc, "resource found\n" );
-    ok( GetLastError() == ERROR_RESOURCE_NAME_NOT_FOUND, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_RESOURCE_NAME_NOT_FOUND, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     rsrc = FindResourceExW( GetModuleHandleW(NULL), (LPCWSTR)RT_MENU, MAKEINTRESOURCEW(1),
                             MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ) );
     ok( !rsrc, "resource found\n" );
-    ok( GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND, "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     rsrc = FindResourceExW( GetModuleHandleW(NULL), (LPCWSTR)RT_MENU, MAKEINTRESOURCEW(1),
                             MAKELANGID( LANG_FRENCH, SUBLANG_DEFAULT ) );
     ok( !rsrc, "resource found\n" );
-    ok( GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND, "wrong error %lu\n", GetLastError() );
 }
 
 typedef struct
diff --git a/dlls/kernel32/tests/sync.c b/dlls/kernel32/tests/sync.c
index a6ee90b81f3..93cae1c84d5 100644
--- a/dlls/kernel32/tests/sync.c
+++ b/dlls/kernel32/tests/sync.c
@@ -194,35 +194,35 @@ static void test_mutex(void)
     SetLastError(0xdeadbeef);
     hOpened = OpenMutexA(0, FALSE, "WineTestMutex");
     ok(hOpened == NULL, "OpenMutex succeeded\n");
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     hCreated = CreateMutexA(NULL, FALSE, "WineTestMutex");
-    ok(hCreated != NULL, "CreateMutex failed with error %d\n", GetLastError());
+    ok(hCreated != NULL, "CreateMutex failed with error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     hOpened = OpenMutexA(0, FALSE, "WineTestMutex");
     todo_wine
     ok(hOpened == NULL, "OpenMutex succeeded\n");
     todo_wine
-    ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     hOpened = OpenMutexA(GENERIC_EXECUTE, FALSE, "WineTestMutex");
-    ok(hOpened != NULL, "OpenMutex failed with error %d\n", GetLastError());
+    ok(hOpened != NULL, "OpenMutex failed with error %ld\n", GetLastError());
     wait_ret = WaitForSingleObject(hOpened, INFINITE);
-    ok(wait_ret == WAIT_OBJECT_0, "WaitForSingleObject failed with error %d\n", GetLastError());
+    ok(wait_ret == WAIT_OBJECT_0, "WaitForSingleObject failed with error %ld\n", GetLastError());
     CloseHandle(hOpened);
 
     for(i=0; i < 31; i++)
     {
         wait_ret = WaitForSingleObject(hCreated, INFINITE);
-        ok(wait_ret == WAIT_OBJECT_0, "WaitForSingleObject failed with error 0x%08x\n", wait_ret);
+        ok(wait_ret == WAIT_OBJECT_0, "WaitForSingleObject failed with error 0x%08lx\n", wait_ret);
     }
 
     SetLastError(0xdeadbeef);
     hOpened = OpenMutexA(GENERIC_READ | GENERIC_WRITE, FALSE, "WineTestMutex");
-    ok(hOpened != NULL, "OpenMutex failed with error %d\n", GetLastError());
+    ok(hOpened != NULL, "OpenMutex failed with error %ld\n", GetLastError());
     wait_ret = WaitForSingleObject(hOpened, INFINITE);
     ok(wait_ret == WAIT_FAILED, "WaitForSingleObject succeeded\n");
     CloseHandle(hOpened);
@@ -235,60 +235,60 @@ static void test_mutex(void)
         {
             SetLastError(0xdeadbeef);
             ret = ReleaseMutex(hOpened);
-            ok(ret, "ReleaseMutex failed with error %d, access %x\n", GetLastError(), 1 << i);
+            ok(ret, "ReleaseMutex failed with error %ld, access %x\n", GetLastError(), 1 << i);
             CloseHandle(hOpened);
         }
         else
         {
             if ((1 << i) == ACCESS_SYSTEM_SECURITY)
-                todo_wine ok(GetLastError() == ERROR_PRIVILEGE_NOT_HELD, "wrong error %u, access %x\n", GetLastError(), 1 << i);
+                todo_wine ok(GetLastError() == ERROR_PRIVILEGE_NOT_HELD, "wrong error %lu, access %x\n", GetLastError(), 1 << i);
             else
-                todo_wine ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u, , access %x\n", GetLastError(), 1 << i);
+                todo_wine ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %lu, , access %x\n", GetLastError(), 1 << i);
             ReleaseMutex(hCreated);
             failed |=0x1 << i;
         }
     }
 
     todo_wine
-    ok( failed == 0x0de0fffe, "open succeeded when it shouldn't: %x\n", failed);
+    ok( failed == 0x0de0fffe, "open succeeded when it shouldn't: %lx\n", failed);
 
     SetLastError(0xdeadbeef);
     ret = ReleaseMutex(hCreated);
     ok(!ret && (GetLastError() == ERROR_NOT_OWNER),
-        "ReleaseMutex should have failed with ERROR_NOT_OWNER instead of %d\n", GetLastError());
+        "ReleaseMutex should have failed with ERROR_NOT_OWNER instead of %ld\n", GetLastError());
 
     /* test case sensitivity */
 
     SetLastError(0xdeadbeef);
     hOpened = OpenMutexA(READ_CONTROL, FALSE, "WINETESTMUTEX");
     ok(!hOpened, "OpenMutex succeeded\n");
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     hOpened = OpenMutexA(READ_CONTROL, FALSE, "winetestmutex");
     ok(!hOpened, "OpenMutex succeeded\n");
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     hOpened = OpenMutexA(READ_CONTROL, FALSE, NULL);
     ok(!hOpened, "OpenMutex succeeded\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     hOpened = OpenMutexW(READ_CONTROL, FALSE, NULL);
     ok(!hOpened, "OpenMutex succeeded\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     hOpened = CreateMutexA(NULL, FALSE, "WineTestMutex");
-    ok(hOpened != NULL, "CreateMutex failed with error %d\n", GetLastError());
-    ok(GetLastError() == ERROR_ALREADY_EXISTS, "wrong error %u\n", GetLastError());
+    ok(hOpened != NULL, "CreateMutex failed with error %ld\n", GetLastError());
+    ok(GetLastError() == ERROR_ALREADY_EXISTS, "wrong error %lu\n", GetLastError());
     CloseHandle(hOpened);
 
     SetLastError(0xdeadbeef);
     hOpened = CreateMutexA(NULL, FALSE, "WINETESTMUTEX");
-    ok(hOpened != NULL, "CreateMutex failed with error %d\n", GetLastError());
-    ok(GetLastError() == 0, "wrong error %u\n", GetLastError());
+    ok(hOpened != NULL, "CreateMutex failed with error %ld\n", GetLastError());
+    ok(GetLastError() == 0, "wrong error %lu\n", GetLastError());
     CloseHandle(hOpened);
 
     CloseHandle(hCreated);
@@ -476,7 +476,7 @@ static void test_event(void)
 
     /* no sd */
     handle = CreateEventA(NULL, FALSE, FALSE, __FILE__ ": Test Event");
-    ok(handle != NULL, "CreateEventW with blank sd failed with error %d\n", GetLastError());
+    ok(handle != NULL, "CreateEventW with blank sd failed with error %ld\n", GetLastError());
     CloseHandle(handle);
 
     sa.nLength = sizeof(sa);
@@ -487,60 +487,60 @@ static void test_event(void)
 
     /* blank sd */
     handle = CreateEventA(&sa, FALSE, FALSE, __FILE__ ": Test Event");
-    ok(handle != NULL, "CreateEventW with blank sd failed with error %d\n", GetLastError());
+    ok(handle != NULL, "CreateEventW with blank sd failed with error %ld\n", GetLastError());
     CloseHandle(handle);
 
     /* sd with NULL dacl */
     SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
     handle = CreateEventA(&sa, FALSE, FALSE, __FILE__ ": Test Event");
-    ok(handle != NULL, "CreateEventW with blank sd failed with error %d\n", GetLastError());
+    ok(handle != NULL, "CreateEventW with blank sd failed with error %ld\n", GetLastError());
     CloseHandle(handle);
 
     /* sd with empty dacl */
     InitializeAcl(&acl, sizeof(acl), ACL_REVISION);
     SetSecurityDescriptorDacl(&sd, TRUE, &acl, FALSE);
     handle = CreateEventA(&sa, FALSE, FALSE, __FILE__ ": Test Event");
-    ok(handle != NULL, "CreateEventW with blank sd failed with error %d\n", GetLastError());
+    ok(handle != NULL, "CreateEventW with blank sd failed with error %ld\n", GetLastError());
     CloseHandle(handle);
 
     /* test case sensitivity */
 
     SetLastError(0xdeadbeef);
     handle = CreateEventA(NULL, FALSE, FALSE, __FILE__ ": Test Event");
-    ok( handle != NULL, "CreateEvent failed with error %u\n", GetLastError());
-    ok( GetLastError() == 0, "wrong error %u\n", GetLastError());
+    ok( handle != NULL, "CreateEvent failed with error %lu\n", GetLastError());
+    ok( GetLastError() == 0, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     handle2 = CreateEventA(NULL, FALSE, FALSE, __FILE__ ": Test Event");
-    ok( handle2 != NULL, "CreateEvent failed with error %d\n", GetLastError());
-    ok( GetLastError() == ERROR_ALREADY_EXISTS, "wrong error %u\n", GetLastError());
+    ok( handle2 != NULL, "CreateEvent failed with error %ld\n", GetLastError());
+    ok( GetLastError() == ERROR_ALREADY_EXISTS, "wrong error %lu\n", GetLastError());
     CloseHandle( handle2 );
 
     SetLastError(0xdeadbeef);
     handle2 = CreateEventA(NULL, FALSE, FALSE, __FILE__ ": TEST EVENT");
-    ok( handle2 != NULL, "CreateEvent failed with error %d\n", GetLastError());
-    ok( GetLastError() == 0, "wrong error %u\n", GetLastError());
+    ok( handle2 != NULL, "CreateEvent failed with error %ld\n", GetLastError());
+    ok( GetLastError() == 0, "wrong error %lu\n", GetLastError());
     CloseHandle( handle2 );
 
     SetLastError(0xdeadbeef);
     handle2 = OpenEventA( EVENT_ALL_ACCESS, FALSE, __FILE__ ": Test Event");
-    ok( handle2 != NULL, "OpenEvent failed with error %d\n", GetLastError());
+    ok( handle2 != NULL, "OpenEvent failed with error %ld\n", GetLastError());
     CloseHandle( handle2 );
 
     SetLastError(0xdeadbeef);
     handle2 = OpenEventA( EVENT_ALL_ACCESS, FALSE, __FILE__ ": TEST EVENT");
     ok( !handle2, "OpenEvent succeeded\n");
-    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError());
+    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     handle2 = OpenEventA( EVENT_ALL_ACCESS, FALSE, NULL );
     ok( !handle2, "OpenEvent succeeded\n");
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     handle2 = OpenEventW( EVENT_ALL_ACCESS, FALSE, NULL );
     ok( !handle2, "OpenEvent succeeded\n");
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError());
 
     CloseHandle( handle );
 
@@ -553,27 +553,27 @@ static void test_event(void)
     }
     handle = pCreateMemoryResourceNotification( HighMemoryResourceNotification + 1 );
     ok( !handle, "CreateMemoryResourceNotification succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
     ret = pQueryMemoryResourceNotification( handle, &val );
     ok( !ret, "QueryMemoryResourceNotification succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     handle = pCreateMemoryResourceNotification( LowMemoryResourceNotification );
-    ok( handle != 0, "CreateMemoryResourceNotification failed err %u\n", GetLastError() );
+    ok( handle != 0, "CreateMemoryResourceNotification failed err %lu\n", GetLastError() );
     ret = WaitForSingleObject( handle, 10 );
-    ok( ret == WAIT_OBJECT_0 || ret == WAIT_TIMEOUT, "WaitForSingleObject wrong ret %u\n", ret );
+    ok( ret == WAIT_OBJECT_0 || ret == WAIT_TIMEOUT, "WaitForSingleObject wrong ret %lu\n", ret );
 
     val = ~0;
     ret = pQueryMemoryResourceNotification( handle, &val );
-    ok( ret, "QueryMemoryResourceNotification failed err %u\n", GetLastError() );
+    ok( ret, "QueryMemoryResourceNotification failed err %lu\n", GetLastError() );
     ok( val == FALSE || val == TRUE, "wrong value %u\n", val );
     ret = CloseHandle( handle );
-    ok( ret, "CloseHandle failed err %u\n", GetLastError() );
+    ok( ret, "CloseHandle failed err %lu\n", GetLastError() );
 
     handle = CreateEventA(NULL, FALSE, FALSE, __FILE__ ": Test Event");
     val = ~0;
     ret = pQueryMemoryResourceNotification( handle, &val );
-    ok( ret, "QueryMemoryResourceNotification failed err %u\n", GetLastError() );
+    ok( ret, "QueryMemoryResourceNotification failed err %lu\n", GetLastError() );
     ok( val == FALSE || val == TRUE, "wrong value %u\n", val );
     CloseHandle( handle );
 }
@@ -586,40 +586,40 @@ static void test_semaphore(void)
 
     SetLastError(0xdeadbeef);
     handle = CreateSemaphoreA(NULL, 0, 1, __FILE__ ": Test Semaphore");
-    ok(handle != NULL, "CreateSemaphore failed with error %u\n", GetLastError());
-    ok(GetLastError() == 0, "wrong error %u\n", GetLastError());
+    ok(handle != NULL, "CreateSemaphore failed with error %lu\n", GetLastError());
+    ok(GetLastError() == 0, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     handle2 = CreateSemaphoreA(NULL, 0, 1, __FILE__ ": Test Semaphore");
-    ok( handle2 != NULL, "CreateSemaphore failed with error %d\n", GetLastError());
-    ok( GetLastError() == ERROR_ALREADY_EXISTS, "wrong error %u\n", GetLastError());
+    ok( handle2 != NULL, "CreateSemaphore failed with error %ld\n", GetLastError());
+    ok( GetLastError() == ERROR_ALREADY_EXISTS, "wrong error %lu\n", GetLastError());
     CloseHandle( handle2 );
 
     SetLastError(0xdeadbeef);
     handle2 = CreateSemaphoreA(NULL, 0, 1, __FILE__ ": TEST SEMAPHORE");
-    ok( handle2 != NULL, "CreateSemaphore failed with error %d\n", GetLastError());
-    ok( GetLastError() == 0, "wrong error %u\n", GetLastError());
+    ok( handle2 != NULL, "CreateSemaphore failed with error %ld\n", GetLastError());
+    ok( GetLastError() == 0, "wrong error %lu\n", GetLastError());
     CloseHandle( handle2 );
 
     SetLastError(0xdeadbeef);
     handle2 = OpenSemaphoreA( SEMAPHORE_ALL_ACCESS, FALSE, __FILE__ ": Test Semaphore");
-    ok( handle2 != NULL, "OpenSemaphore failed with error %d\n", GetLastError());
+    ok( handle2 != NULL, "OpenSemaphore failed with error %ld\n", GetLastError());
     CloseHandle( handle2 );
 
     SetLastError(0xdeadbeef);
     handle2 = OpenSemaphoreA( SEMAPHORE_ALL_ACCESS, FALSE, __FILE__ ": TEST SEMAPHORE");
     ok( !handle2, "OpenSemaphore succeeded\n");
-    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError());
+    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     handle2 = OpenSemaphoreA( SEMAPHORE_ALL_ACCESS, FALSE, NULL );
     ok( !handle2, "OpenSemaphore succeeded\n");
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     handle2 = OpenSemaphoreW( SEMAPHORE_ALL_ACCESS, FALSE, NULL );
     ok( !handle2, "OpenSemaphore succeeded\n");
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError());
 
     CloseHandle( handle );
 }
@@ -632,40 +632,40 @@ static void test_waitable_timer(void)
 
     SetLastError(0xdeadbeef);
     handle = CreateWaitableTimerA(NULL, FALSE, __FILE__ ": Test WaitableTimer");
-    ok(handle != NULL, "CreateWaitableTimer failed with error %u\n", GetLastError());
-    ok(GetLastError() == 0, "wrong error %u\n", GetLastError());
+    ok(handle != NULL, "CreateWaitableTimer failed with error %lu\n", GetLastError());
+    ok(GetLastError() == 0, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     handle2 = CreateWaitableTimerA(NULL, FALSE, __FILE__ ": Test WaitableTimer");
-    ok( handle2 != NULL, "CreateWaitableTimer failed with error %d\n", GetLastError());
-    ok( GetLastError() == ERROR_ALREADY_EXISTS, "wrong error %u\n", GetLastError());
+    ok( handle2 != NULL, "CreateWaitableTimer failed with error %ld\n", GetLastError());
+    ok( GetLastError() == ERROR_ALREADY_EXISTS, "wrong error %lu\n", GetLastError());
     CloseHandle( handle2 );
 
     SetLastError(0xdeadbeef);
     handle2 = CreateWaitableTimerA(NULL, FALSE, __FILE__ ": TEST WAITABLETIMER");
-    ok( handle2 != NULL, "CreateWaitableTimer failed with error %d\n", GetLastError());
-    ok( GetLastError() == 0, "wrong error %u\n", GetLastError());
+    ok( handle2 != NULL, "CreateWaitableTimer failed with error %ld\n", GetLastError());
+    ok( GetLastError() == 0, "wrong error %lu\n", GetLastError());
     CloseHandle( handle2 );
 
     SetLastError(0xdeadbeef);
     handle2 = OpenWaitableTimerA( TIMER_ALL_ACCESS, FALSE, __FILE__ ": Test WaitableTimer");
-    ok( handle2 != NULL, "OpenWaitableTimer failed with error %d\n", GetLastError());
+    ok( handle2 != NULL, "OpenWaitableTimer failed with error %ld\n", GetLastError());
     CloseHandle( handle2 );
 
     SetLastError(0xdeadbeef);
     handle2 = OpenWaitableTimerA( TIMER_ALL_ACCESS, FALSE, __FILE__ ": TEST WAITABLETIMER");
     ok( !handle2, "OpenWaitableTimer succeeded\n");
-    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError());
+    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     handle2 = OpenWaitableTimerA( TIMER_ALL_ACCESS, FALSE, NULL );
-    ok( !handle2, "OpenWaitableTimer failed with error %d\n", GetLastError());
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
+    ok( !handle2, "OpenWaitableTimer failed with error %ld\n", GetLastError());
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     handle2 = OpenWaitableTimerW( TIMER_ALL_ACCESS, FALSE, NULL );
-    ok( !handle2, "OpenWaitableTimer failed with error %d\n", GetLastError());
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
+    ok( !handle2, "OpenWaitableTimer failed with error %ld\n", GetLastError());
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError());
 
     CloseHandle( handle );
 }
@@ -702,35 +702,35 @@ static void test_iocp_callback(void)
     ok(sem != INVALID_HANDLE_VALUE, "Creating a semaphore failed\n");
 
     ret = GetTempPathA(MAX_PATH, temp_path);
-    ok(ret != 0, "GetTempPathA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempPathA error %ld\n", GetLastError());
     ok(ret < MAX_PATH, "temp path should fit into MAX_PATH\n");
 
     ret = GetTempFileNameA(temp_path, prefix, 0, filename);
-    ok(ret != 0, "GetTempFileNameA error %d\n", GetLastError());
+    ok(ret != 0, "GetTempFileNameA error %ld\n", GetLastError());
 
     hFile = CreateFileA(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                         CREATE_ALWAYS, FILE_FLAG_RANDOM_ACCESS, 0);
-    ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA: error %d\n", GetLastError());
+    ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA: error %ld\n", GetLastError());
 
     retb = p_BindIoCompletionCallback(hFile, iocp_callback, 0);
     ok(retb == FALSE, "BindIoCompletionCallback succeeded on a file that wasn't created with FILE_FLAG_OVERLAPPED\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Last error is %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Last error is %ld\n", GetLastError());
 
     ret = CloseHandle(hFile);
-    ok( ret, "CloseHandle: error %d\n", GetLastError());
+    ok( ret, "CloseHandle: error %ld\n", GetLastError());
     ret = DeleteFileA(filename);
-    ok( ret, "DeleteFileA: error %d\n", GetLastError());
+    ok( ret, "DeleteFileA: error %ld\n", GetLastError());
 
     hFile = CreateFileA(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                         CREATE_ALWAYS, FILE_FLAG_RANDOM_ACCESS | FILE_FLAG_OVERLAPPED, 0);
-    ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA: error %d\n", GetLastError());
+    ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA: error %ld\n", GetLastError());
 
     retb = p_BindIoCompletionCallback(hFile, iocp_callback, 0);
     ok(retb == TRUE, "BindIoCompletionCallback failed\n");
 
     memset(&overlapped, 0, sizeof(overlapped));
     retb = WriteFile(hFile, buffer, 4, &bytesWritten, &overlapped);
-    ok(retb == TRUE || GetLastError() == ERROR_IO_PENDING, "WriteFile failed, lastError = %d\n", GetLastError());
+    ok(retb == TRUE || GetLastError() == ERROR_IO_PENDING, "WriteFile failed, lastError = %ld\n", GetLastError());
 
     ret = WaitForSingleObject(sem, 5000);
     ok(ret == WAIT_OBJECT_0, "Wait for the IO completion callback failed\n");
@@ -738,37 +738,37 @@ static void test_iocp_callback(void)
 
     retb = p_BindIoCompletionCallback(hFile, iocp_callback, 0);
     ok(retb == FALSE, "BindIoCompletionCallback succeeded when setting the same callback on the file again\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Last error is %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Last error is %ld\n", GetLastError());
     retb = p_BindIoCompletionCallback(hFile, NULL, 0);
     ok(retb == FALSE, "BindIoCompletionCallback succeeded when setting the callback to NULL\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Last error is %d\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "Last error is %ld\n", GetLastError());
 
     ret = CloseHandle(hFile);
-    ok( ret, "CloseHandle: error %d\n", GetLastError());
+    ok( ret, "CloseHandle: error %ld\n", GetLastError());
     ret = DeleteFileA(filename);
-    ok( ret, "DeleteFileA: error %d\n", GetLastError());
+    ok( ret, "DeleteFileA: error %ld\n", GetLastError());
 
     /* win2k3 requires the Flags parameter to be zero */
     SetLastError(0xdeadbeef);
     hFile = CreateFileA(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                         CREATE_ALWAYS, FILE_FLAG_RANDOM_ACCESS | FILE_FLAG_OVERLAPPED, 0);
-    ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA: error %d\n", GetLastError());
+    ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA: error %ld\n", GetLastError());
     retb = p_BindIoCompletionCallback(hFile, iocp_callback, 12345);
     if (!retb)
         ok(GetLastError() == ERROR_INVALID_PARAMETER,
-           "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+           "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
     else
         ok(retb == TRUE, "BindIoCompletionCallback failed with Flags != 0\n");
     ret = CloseHandle(hFile);
-    ok( ret, "CloseHandle: error %d\n", GetLastError());
+    ok( ret, "CloseHandle: error %ld\n", GetLastError());
     ret = DeleteFileA(filename);
-    ok( ret, "DeleteFileA: error %d\n", GetLastError());
+    ok( ret, "DeleteFileA: error %ld\n", GetLastError());
 
     retb = p_BindIoCompletionCallback(NULL, iocp_callback, 0);
     ok(retb == FALSE, "BindIoCompletionCallback succeeded on a NULL file\n");
     ok(GetLastError() == ERROR_INVALID_HANDLE ||
        GetLastError() == ERROR_INVALID_PARAMETER, /* vista */
-       "Last error is %d\n", GetLastError());
+       "Last error is %ld\n", GetLastError());
 }
 
 static void CALLBACK timer_queue_cb1(PVOID p, BOOLEAN timedOut)
@@ -888,7 +888,7 @@ static void test_timer_queue(void)
     SetLastError(0xdeadbeef);
     ret = DeleteTimerQueueEx(q, NULL);
     ok(ret /* vista */ || GetLastError() == ERROR_IO_PENDING,
-       "DeleteTimerQueueEx, GetLastError: expected ERROR_IO_PENDING, got %d\n",
+       "DeleteTimerQueueEx, GetLastError: expected ERROR_IO_PENDING, got %ld\n",
        GetLastError());
 
     /* Test synchronous deletion of the queue and running timers. */
@@ -904,7 +904,7 @@ static void test_timer_queue(void)
     ret0 = DeleteTimerQueueTimer(q, t0, NULL);
     ok((!ret0 && GetLastError() == ERROR_IO_PENDING) ||
        broken(ret0), /* Win 2000 & XP & 2003 */
-       "DeleteTimerQueueTimer ret=%d le=%u\n", ret0, GetLastError());
+       "DeleteTimerQueueTimer ret=%d le=%lu\n", ret0, GetLastError());
 
     /* Called once.  */
     t1 = NULL;
@@ -1006,21 +1006,21 @@ static void test_timer_queue(void)
     SetLastError(0xdeadbeef);
     ret = DeleteTimerQueueTimer(q, t1, NULL);
     ok(ret /* vista */ || GetLastError() == ERROR_IO_PENDING,
-       "DeleteTimerQueueTimer, GetLastError: expected ERROR_IO_PENDING, got %d\n",
+       "DeleteTimerQueueTimer, GetLastError: expected ERROR_IO_PENDING, got %ld\n",
        GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = DeleteTimerQueueTimer(q, t2, NULL);
     ok(!ret, "DeleteTimerQueueTimer call was expected to fail\n");
     ok(GetLastError() == ERROR_IO_PENDING,
-       "DeleteTimerQueueTimer, GetLastError: expected ERROR_IO_PENDING, got %d\n",
+       "DeleteTimerQueueTimer, GetLastError: expected ERROR_IO_PENDING, got %ld\n",
        GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = DeleteTimerQueueTimer(q, t3, et1);
     ok(ret, "DeleteTimerQueueTimer call was expected to fail\n");
     ok(GetLastError() == 0xdeadbeef,
-       "DeleteTimerQueueTimer, GetLastError: expected 0xdeadbeef, got %d\n",
+       "DeleteTimerQueueTimer, GetLastError: expected 0xdeadbeef, got %ld\n",
        GetLastError());
     ok(WaitForSingleObject(et1, 250) == WAIT_OBJECT_0,
        "Timer destruction event not triggered\n");
@@ -1029,7 +1029,7 @@ static void test_timer_queue(void)
     ret = DeleteTimerQueueTimer(q, t4, et2);
     ok(!ret, "DeleteTimerQueueTimer call was expected to fail\n");
     ok(GetLastError() == ERROR_IO_PENDING,
-       "DeleteTimerQueueTimer, GetLastError: expected ERROR_IO_PENDING, got %d\n",
+       "DeleteTimerQueueTimer, GetLastError: expected ERROR_IO_PENDING, got %ld\n",
        GetLastError());
     ok(WaitForSingleObject(et2, 1000) == WAIT_OBJECT_0,
        "Timer destruction event not triggered\n");
@@ -1037,7 +1037,7 @@ static void test_timer_queue(void)
     SetLastError(0xdeadbeef);
     ret = DeleteTimerQueueEx(q, e);
     ok(ret /* vista */ || GetLastError() == ERROR_IO_PENDING,
-       "DeleteTimerQueueEx, GetLastError: expected ERROR_IO_PENDING, got %d\n",
+       "DeleteTimerQueueEx, GetLastError: expected ERROR_IO_PENDING, got %ld\n",
        GetLastError());
     ok(WaitForSingleObject(e, 250) == WAIT_OBJECT_0,
        "Queue destruction event not triggered\n");
@@ -1109,7 +1109,7 @@ static void test_timer_queue(void)
     SetLastError(0xdeadbeef);
     ret = DeleteTimerQueueEx(q, NULL);
     ok(ret /* vista */ || GetLastError() == ERROR_IO_PENDING,
-       "DeleteTimerQueueEx, GetLastError: expected ERROR_IO_PENDING, got %d\n",
+       "DeleteTimerQueueEx, GetLastError: expected ERROR_IO_PENDING, got %ld\n",
        GetLastError());
     ok(d1.num_calls == 1, "DeleteTimerQueueTimer\n");
 
@@ -1159,13 +1159,13 @@ static void test_timer_queue(void)
     ret = DeleteTimerQueueEx(NULL, NULL);
     ok(!ret, "DeleteTimerQueueEx call was expected to fail\n");
     ok(GetLastError() == ERROR_INVALID_HANDLE,
-       "DeleteTimerQueueEx, GetLastError: expected ERROR_INVALID_HANDLE, got %d\n",
+       "DeleteTimerQueueEx, GetLastError: expected ERROR_INVALID_HANDLE, got %ld\n",
        GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = DeleteTimerQueueEx(q, NULL);
     ok(ret /* vista */ || GetLastError() == ERROR_IO_PENDING,
-       "DeleteTimerQueueEx, GetLastError: expected ERROR_IO_PENDING, got %d\n",
+       "DeleteTimerQueueEx, GetLastError: expected ERROR_IO_PENDING, got %ld\n",
        GetLastError());
 }
 
@@ -1190,80 +1190,80 @@ static void test_WaitForSingleObject(void)
     /* invalid handle with different values for lower 2 bits */
     SetLastError(0xdeadbeef);
     ret = WaitForSingleObject(invalid, 0);
-    ok(ret == WAIT_FAILED, "expected WAIT_FAILED, got %d\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
+    ok(ret == WAIT_FAILED, "expected WAIT_FAILED, got %ld\n", ret);
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WaitForSingleObject(modify_handle(invalid, 1), 0);
-    ok(ret == WAIT_FAILED, "expected WAIT_FAILED, got %d\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
+    ok(ret == WAIT_FAILED, "expected WAIT_FAILED, got %ld\n", ret);
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WaitForSingleObject(modify_handle(invalid, 2), 0);
-    ok(ret == WAIT_FAILED, "expected WAIT_FAILED, got %d\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
+    ok(ret == WAIT_FAILED, "expected WAIT_FAILED, got %ld\n", ret);
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WaitForSingleObject(modify_handle(invalid, 3), 0);
-    ok(ret == WAIT_FAILED, "expected WAIT_FAILED, got %d\n", ret);
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
+    ok(ret == WAIT_FAILED, "expected WAIT_FAILED, got %ld\n", ret);
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %ld\n", GetLastError());
 
     /* valid handle with different values for lower 2 bits */
     SetLastError(0xdeadbeef);
     ret = WaitForSingleObject(nonsignaled, 0);
-    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %d\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
+    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %ld\n", ret);
+    ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WaitForSingleObject(modify_handle(nonsignaled, 1), 0);
-    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %d\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
+    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %ld\n", ret);
+    ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WaitForSingleObject(modify_handle(nonsignaled, 2), 0);
-    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %d\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
+    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %ld\n", ret);
+    ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WaitForSingleObject(modify_handle(nonsignaled, 3), 0);
-    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %d\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
+    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %ld\n", ret);
+    ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %ld\n", GetLastError());
 
     /* valid handle with different values for lower 2 bits */
     SetLastError(0xdeadbeef);
     ret = WaitForSingleObject(signaled, 0);
-    ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %d\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
+    ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %ld\n", ret);
+    ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WaitForSingleObject(modify_handle(signaled, 1), 0);
-    ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %d\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
+    ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %ld\n", ret);
+    ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WaitForSingleObject(modify_handle(signaled, 2), 0);
-    ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %d\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
+    ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %ld\n", ret);
+    ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = WaitForSingleObject(modify_handle(signaled, 3), 0);
-    ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %d\n", ret);
-    ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
+    ok(ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %ld\n", ret);
+    ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %ld\n", GetLastError());
 
     /* pseudo handles are allowed in WaitForSingleObject and NtWaitForSingleObject */
     ret = WaitForSingleObject(GetCurrentProcess(), 100);
-    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %u\n", ret);
+    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %lu\n", ret);
 
     ret = WaitForSingleObject(GetCurrentThread(), 100);
-    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %u\n", ret);
+    ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %lu\n", ret);
 
     timeout.QuadPart = -1000000;
     status = pNtWaitForSingleObject(GetCurrentProcess(), FALSE, &timeout);
-    ok(status == STATUS_TIMEOUT, "expected STATUS_TIMEOUT, got %08x\n", status);
+    ok(status == STATUS_TIMEOUT, "expected STATUS_TIMEOUT, got %08lx\n", status);
 
     timeout.QuadPart = -1000000;
     status = pNtWaitForSingleObject(GetCurrentThread(), FALSE, &timeout);
-    ok(status == STATUS_TIMEOUT, "expected STATUS_TIMEOUT, got %08x\n", status);
+    ok(status == STATUS_TIMEOUT, "expected STATUS_TIMEOUT, got %08lx\n", status);
 
     CloseHandle(signaled);
     CloseHandle(nonsignaled);
@@ -1287,15 +1287,15 @@ static void test_WaitForMultipleObjects(void)
 
     /* a manual-reset event remains signaled, an auto-reset event is cleared */
     r = WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, FALSE, 0);
-    ok( r == WAIT_OBJECT_0, "should signal lowest handle first, got %d\n", r);
+    ok( r == WAIT_OBJECT_0, "should signal lowest handle first, got %ld\n", r);
     r = WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, FALSE, 0);
-    ok( r == WAIT_OBJECT_0, "should signal handle #0 first, got %d\n", r);
+    ok( r == WAIT_OBJECT_0, "should signal handle #0 first, got %ld\n", r);
     ok(ResetEvent(maxevents[0]), "ResetEvent\n");
     for (i=1; i<MAXIMUM_WAIT_OBJECTS; i++)
     {
         /* the lowest index is checked first and remaining events are untouched */
         r = WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, FALSE, 0);
-        ok( r == WAIT_OBJECT_0+i, "should signal handle #%d first, got %d\n", i, r);
+        ok( r == WAIT_OBJECT_0+i, "should signal handle #%d first, got %ld\n", i, r);
     }
 
     /* run same test with Nt* call */
@@ -1304,15 +1304,15 @@ static void test_WaitForMultipleObjects(void)
 
     /* a manual-reset event remains signaled, an auto-reset event is cleared */
     status = pNtWaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, TRUE, FALSE, NULL);
-    ok(status == STATUS_WAIT_0, "should signal lowest handle first, got %08x\n", status);
+    ok(status == STATUS_WAIT_0, "should signal lowest handle first, got %08lx\n", status);
     status = pNtWaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, TRUE, FALSE, NULL);
-    ok(status == STATUS_WAIT_0, "should signal handle #0 first, got %08x\n", status);
+    ok(status == STATUS_WAIT_0, "should signal handle #0 first, got %08lx\n", status);
     ok(ResetEvent(maxevents[0]), "ResetEvent\n");
     for (i=1; i<MAXIMUM_WAIT_OBJECTS; i++)
     {
         /* the lowest index is checked first and remaining events are untouched */
         status = pNtWaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, TRUE, FALSE, NULL);
-        ok(status == STATUS_WAIT_0 + i, "should signal handle #%d first, got %08x\n", i, status);
+        ok(status == STATUS_WAIT_0 + i, "should signal handle #%d first, got %08lx\n", i, status);
     }
 
     for (i=0; i<MAXIMUM_WAIT_OBJECTS; i++)
@@ -1323,26 +1323,26 @@ static void test_WaitForMultipleObjects(void)
     maxevents[0] = GetCurrentProcess();
     SetLastError(0xdeadbeef);
     r = WaitForMultipleObjects(1, maxevents, FALSE, 100);
-    todo_wine ok(r == WAIT_FAILED, "expected WAIT_FAILED, got %u\n", r);
+    todo_wine ok(r == WAIT_FAILED, "expected WAIT_FAILED, got %lu\n", r);
     todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE,
-                 "expected ERROR_INVALID_HANDLE, got %u\n", GetLastError());
+                 "expected ERROR_INVALID_HANDLE, got %lu\n", GetLastError());
 
     maxevents[0] = GetCurrentThread();
     SetLastError(0xdeadbeef);
     r = WaitForMultipleObjects(1, maxevents, FALSE, 100);
-    todo_wine ok(r == WAIT_FAILED, "expected WAIT_FAILED, got %u\n", r);
+    todo_wine ok(r == WAIT_FAILED, "expected WAIT_FAILED, got %lu\n", r);
     todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE,
-                 "expected ERROR_INVALID_HANDLE, got %u\n", GetLastError());
+                 "expected ERROR_INVALID_HANDLE, got %lu\n", GetLastError());
 
     timeout.QuadPart = -1000000;
     maxevents[0] = GetCurrentProcess();
     status = pNtWaitForMultipleObjects(1, maxevents, TRUE, FALSE, &timeout);
-    todo_wine ok(status == STATUS_INVALID_HANDLE, "expected STATUS_INVALID_HANDLE, got %08x\n", status);
+    todo_wine ok(status == STATUS_INVALID_HANDLE, "expected STATUS_INVALID_HANDLE, got %08lx\n", status);
 
     timeout.QuadPart = -1000000;
     maxevents[0] = GetCurrentThread();
     status = pNtWaitForMultipleObjects(1, maxevents, TRUE, FALSE, &timeout);
-    todo_wine ok(status == STATUS_INVALID_HANDLE, "expected STATUS_INVALID_HANDLE, got %08x\n", status);
+    todo_wine ok(status == STATUS_INVALID_HANDLE, "expected STATUS_INVALID_HANDLE, got %08lx\n", status);
 }
 
 static BOOL g_initcallback_ret, g_initcallback_called;
@@ -1378,7 +1378,7 @@ static void test_initonce(void)
     g_initcallback_ret = TRUE;
     g_initctxt = NULL;
     ret = pInitOnceExecuteOnce(&initonce, initonce_callback, (void*)0xdeadbeef, &g_initctxt);
-    ok(ret, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(ret, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == (void*)0x2, "got %p\n", initonce.Ptr);
     ok(g_initctxt == NULL, "got %p\n", g_initctxt);
     ok(g_initcallback_called, "got %d\n", g_initcallback_called);
@@ -1387,7 +1387,7 @@ static void test_initonce(void)
     g_initctxt = NULL;
     g_initcallback_called = FALSE;
     ret = pInitOnceExecuteOnce(&initonce, initonce_callback, (void*)0xdeadbeef, &g_initctxt);
-    ok(ret, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(ret, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == (void*)0x2, "got %p\n", initonce.Ptr);
     ok(g_initctxt == NULL, "got %p\n", g_initctxt);
     ok(!g_initcallback_called, "got %d\n", g_initcallback_called);
@@ -1397,7 +1397,7 @@ static void test_initonce(void)
     /* 2 lower order bits should never be used, you'll get a crash in result */
     g_initctxt = (void*)0xFFFFFFF0;
     ret = pInitOnceExecuteOnce(&initonce, initonce_callback, (void*)0xdeadbeef, &g_initctxt);
-    ok(ret, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(ret, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == (void*)0xFFFFFFF2, "got %p\n", initonce.Ptr);
     ok(g_initctxt == (void*)0xFFFFFFF0, "got %p\n", g_initctxt);
     ok(g_initcallback_called, "got %d\n", g_initcallback_called);
@@ -1409,7 +1409,7 @@ static void test_initonce(void)
     pInitOnceInitialize(&initonce);
     SetLastError( 0xdeadbeef );
     ret = pInitOnceExecuteOnce(&initonce, initonce_callback, (void*)0xdeadbeef, &g_initctxt);
-    ok(!ret && GetLastError() == 0xdeadbeef, "got wrong ret value %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == 0xdeadbeef, "got wrong ret value %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == NULL, "got %p\n", initonce.Ptr);
     ok(g_initctxt == NULL, "got %p\n", g_initctxt);
     ok(g_initcallback_called, "got %d\n", g_initcallback_called);
@@ -1419,7 +1419,7 @@ static void test_initonce(void)
     g_initctxt = NULL;
     pending = FALSE;
     ret = pInitOnceBeginInitialize(&initonce, 0, &pending, &g_initctxt);
-    ok(ret, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(ret, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(pending, "got %d\n", pending);
     ok(initonce.Ptr == (void*)1, "got %p\n", initonce.Ptr);
     ok(g_initctxt == NULL, "got %p\n", g_initctxt);
@@ -1429,7 +1429,7 @@ static void test_initonce(void)
     pending = 0xf;
     SetLastError( 0xdeadbeef );
     ret = pInitOnceBeginInitialize(&initonce, INIT_ONCE_CHECK_ONLY, &pending, &g_initctxt);
-    ok(!ret && GetLastError() == ERROR_GEN_FAILURE, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_GEN_FAILURE, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(pending == 0xf, "got %d\n", pending);
     ok(initonce.Ptr == (void*)1, "got %p\n", initonce.Ptr);
     ok(g_initctxt == NULL, "got %p\n", g_initctxt);
@@ -1437,91 +1437,91 @@ static void test_initonce(void)
     g_initctxt = (void*)0xdeadbee0;
     SetLastError( 0xdeadbeef );
     ret = pInitOnceComplete(&initonce, INIT_ONCE_INIT_FAILED, g_initctxt);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == (void*)1, "got %p\n", initonce.Ptr);
 
     /* once failed already */
     g_initctxt = (void*)0xdeadbee0;
     ret = pInitOnceComplete(&initonce, 0, g_initctxt);
-    ok(ret, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(ret, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == (void*)0xdeadbee2, "got %p\n", initonce.Ptr);
 
     pInitOnceInitialize(&initonce);
     SetLastError( 0xdeadbeef );
     ret = pInitOnceComplete(&initonce, INIT_ONCE_INIT_FAILED, NULL);
-    ok(!ret && GetLastError() == ERROR_GEN_FAILURE, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_GEN_FAILURE, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == NULL, "got %p\n", initonce.Ptr);
 
     SetLastError( 0xdeadbeef );
     ret = pInitOnceComplete(&initonce, INIT_ONCE_INIT_FAILED | INIT_ONCE_ASYNC, NULL);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == NULL, "got %p\n", initonce.Ptr);
 
     ret = pInitOnceBeginInitialize(&initonce, 0, &pending, &g_initctxt);
-    ok(ret, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(ret, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(pending, "got %d\n", pending);
     ok(initonce.Ptr == (void*)1, "got %p\n", initonce.Ptr);
 
     SetLastError( 0xdeadbeef );
     ret = pInitOnceBeginInitialize(&initonce, INIT_ONCE_ASYNC, &pending, &g_initctxt);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %lu\n", ret, GetLastError());
 
     SetLastError( 0xdeadbeef );
     ret = pInitOnceComplete(&initonce, INIT_ONCE_INIT_FAILED | INIT_ONCE_ASYNC, NULL);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == (void*)1, "got %p\n", initonce.Ptr);
 
     SetLastError( 0xdeadbeef );
     ret = pInitOnceComplete(&initonce, 0, (void *)0xdeadbeef);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == (void*)1, "got %p\n", initonce.Ptr);
 
     ret = pInitOnceComplete(&initonce, INIT_ONCE_INIT_FAILED, NULL);
-    ok(ret, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(ret, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == NULL, "got %p\n", initonce.Ptr);
 
     pInitOnceInitialize(&initonce);
     ret = pInitOnceBeginInitialize(&initonce, INIT_ONCE_ASYNC, &pending, &g_initctxt);
-    ok(ret, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(ret, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(pending, "got %d\n", pending);
     ok(initonce.Ptr == (void*)3, "got %p\n", initonce.Ptr);
 
     SetLastError( 0xdeadbeef );
     ret = pInitOnceBeginInitialize(&initonce, 0, &pending, &g_initctxt);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %lu\n", ret, GetLastError());
 
     ret = pInitOnceBeginInitialize(&initonce, INIT_ONCE_ASYNC, &pending, &g_initctxt);
-    ok(ret, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(ret, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(pending, "got %d\n", pending);
     ok(initonce.Ptr == (void*)3, "got %p\n", initonce.Ptr);
 
     SetLastError( 0xdeadbeef );
     ret = pInitOnceComplete(&initonce, INIT_ONCE_INIT_FAILED, NULL);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == (void*)3, "got %p\n", initonce.Ptr);
 
     SetLastError( 0xdeadbeef );
     ret = pInitOnceComplete(&initonce, INIT_ONCE_INIT_FAILED | INIT_ONCE_ASYNC, NULL);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == (void*)3, "got %p\n", initonce.Ptr);
 
     SetLastError( 0xdeadbeef );
     ret = pInitOnceComplete(&initonce, INIT_ONCE_ASYNC, (void *)0xdeadbeef);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == (void*)3, "got %p\n", initonce.Ptr);
 
     ret = pInitOnceComplete(&initonce, INIT_ONCE_ASYNC, (void *)0xdeadbee0);
-    ok(ret, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(ret, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == (void*)0xdeadbee2, "got %p\n", initonce.Ptr);
 
     SetLastError( 0xdeadbeef );
     ret = pInitOnceComplete(&initonce, INIT_ONCE_INIT_FAILED | INIT_ONCE_ASYNC, NULL);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == (void*)0xdeadbee2, "got %p\n", initonce.Ptr);
 
     pInitOnceInitialize(&initonce);
     ret = pInitOnceBeginInitialize(&initonce, 0, &pending, &g_initctxt);
-    ok(ret, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(ret, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(pending, "got %d\n", pending);
     ok(initonce.Ptr == (void*)1, "got %p\n", initonce.Ptr);
 
@@ -1530,63 +1530,63 @@ static void test_initonce(void)
     pInitOnceInitialize(&initonce);
     SetLastError( 0xdeadbeef );
     ret = pInitOnceBeginInitialize(&initonce, INIT_ONCE_CHECK_ONLY, &pending, &g_initctxt);
-    ok(!ret && GetLastError() == ERROR_GEN_FAILURE, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_GEN_FAILURE, "wrong ret %d err %lu\n", ret, GetLastError());
     SetLastError( 0xdeadbeef );
     ret = pInitOnceBeginInitialize(&initonce, INIT_ONCE_CHECK_ONLY|INIT_ONCE_ASYNC, &pending, &g_initctxt);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %lu\n", ret, GetLastError());
 
     ret = pInitOnceBeginInitialize(&initonce, 0, &pending, &g_initctxt);
-    ok(ret, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(ret, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(pending, "got %d\n", pending);
     ok(initonce.Ptr == (void*)1, "got %p\n", initonce.Ptr);
 
     SetLastError( 0xdeadbeef );
     ret = pInitOnceBeginInitialize(&initonce, INIT_ONCE_CHECK_ONLY, &pending, &g_initctxt);
-    ok(!ret && GetLastError() == ERROR_GEN_FAILURE, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_GEN_FAILURE, "wrong ret %d err %lu\n", ret, GetLastError());
     SetLastError( 0xdeadbeef );
     ret = pInitOnceBeginInitialize(&initonce, INIT_ONCE_CHECK_ONLY|INIT_ONCE_ASYNC, &pending, &g_initctxt);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %lu\n", ret, GetLastError());
 
     ret = pInitOnceComplete(&initonce, 0, (void *)0xdeadbee0);
-    ok(ret, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(ret, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == (void*)0xdeadbee2, "got %p\n", initonce.Ptr);
 
     ret = pInitOnceBeginInitialize(&initonce, INIT_ONCE_CHECK_ONLY, &pending, &g_initctxt);
-    ok(ret, "got wrong ret value %d err %u\n", ret, GetLastError());
+    ok(ret, "got wrong ret value %d err %lu\n", ret, GetLastError());
     ok(!pending, "got %d\n", pending);
     ok(initonce.Ptr == (void*)0xdeadbee2, "got %p\n", initonce.Ptr);
     ok(g_initctxt == (void*)0xdeadbee0, "got %p\n", initonce.Ptr);
 
     SetLastError( 0xdeadbeef );
     ret = pInitOnceBeginInitialize(&initonce, INIT_ONCE_CHECK_ONLY|INIT_ONCE_ASYNC, &pending, &g_initctxt);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %lu\n", ret, GetLastError());
 
     pInitOnceInitialize(&initonce);
     ret = pInitOnceBeginInitialize(&initonce, INIT_ONCE_ASYNC, &pending, &g_initctxt);
-    ok(ret, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(ret, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(pending, "got %d\n", pending);
     ok(initonce.Ptr == (void*)3, "got %p\n", initonce.Ptr);
 
     SetLastError( 0xdeadbeef );
     ret = pInitOnceBeginInitialize(&initonce, INIT_ONCE_CHECK_ONLY, &pending, &g_initctxt);
-    ok(!ret && GetLastError() == ERROR_GEN_FAILURE, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_GEN_FAILURE, "wrong ret %d err %lu\n", ret, GetLastError());
     SetLastError( 0xdeadbeef );
     ret = pInitOnceBeginInitialize(&initonce, INIT_ONCE_CHECK_ONLY|INIT_ONCE_ASYNC, &pending, &g_initctxt);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %lu\n", ret, GetLastError());
 
     ret = pInitOnceComplete(&initonce, INIT_ONCE_ASYNC, (void *)0xdeadbee0);
-    ok(ret, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(ret, "wrong ret %d err %lu\n", ret, GetLastError());
     ok(initonce.Ptr == (void*)0xdeadbee2, "got %p\n", initonce.Ptr);
 
     ret = pInitOnceBeginInitialize(&initonce, INIT_ONCE_CHECK_ONLY, &pending, &g_initctxt);
-    ok(ret, "got wrong ret value %d err %u\n", ret, GetLastError());
+    ok(ret, "got wrong ret value %d err %lu\n", ret, GetLastError());
     ok(!pending, "got %d\n", pending);
     ok(initonce.Ptr == (void*)0xdeadbee2, "got %p\n", initonce.Ptr);
     ok(g_initctxt == (void*)0xdeadbee0, "got %p\n", initonce.Ptr);
 
     SetLastError( 0xdeadbeef );
     ret = pInitOnceBeginInitialize(&initonce, INIT_ONCE_CHECK_ONLY|INIT_ONCE_ASYNC, &pending, &g_initctxt);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "wrong ret %d err %lu\n", ret, GetLastError());
 }
 
 static CONDITION_VARIABLE buffernotempty = CONDITION_VARIABLE_INIT;
@@ -1708,16 +1708,16 @@ static void test_condvars_consumer_producer(void)
     WaitForSingleObject(hc3, 1000);
 
     ok(totalconsumed == totalproduced,
-       "consumed %d != produced %d\n", totalconsumed, totalproduced);
+       "consumed %ld != produced %ld\n", totalconsumed, totalproduced);
     ok (!condvar_sleeperr, "error occurred during SleepConditionVariableCS\n");
 
     /* Checking cnt1 - cnt2 for non-0 would be not good, the case where
      * one consumer does not get anything to do is possible. */
-    trace("produced %d, c1 %d, c2 %d, c3 %d\n", totalproduced, cnt1, cnt2, cnt3);
+    trace("produced %ld, c1 %ld, c2 %ld, c3 %ld\n", totalproduced, cnt1, cnt2, cnt3);
     /* The sleeps of the producer or consumer should not go above 100* produced count,
      * otherwise the implementation does not sleep correctly. But yet again, this is
      * not hard defined. */
-    trace("producer sleep %d, consumer sleep %d\n", condvar_producer_sleepcnt, condvar_consumer_sleepcnt);
+    trace("producer sleep %ld, consumer sleep %ld\n", condvar_producer_sleepcnt, condvar_consumer_sleepcnt);
 }
 
 /* Sample test for some sequence of events happening, sequenced using "condvar_seq" */
@@ -1821,7 +1821,7 @@ static DWORD WINAPI condvar_base_consumer(void *arg)
     ret = pSleepConditionVariableCS(cv, &condvar_crit, 10);
     LeaveCriticalSection (&condvar_crit);
     ok (!ret, "SleepConditionVariableCS should return FALSE on out of band wake\n");
-    ok (GetLastError() == ERROR_TIMEOUT, "SleepConditionVariableCS should return ERROR_TIMEOUT on out of band wake, not %d\n", GetLastError());
+    ok (GetLastError() == ERROR_TIMEOUT, "SleepConditionVariableCS should return ERROR_TIMEOUT on out of band wake, not %ld\n", GetLastError());
 
     condvar_seq = 3;
     while (condvar_seq < 4) Sleep(1);
@@ -1831,7 +1831,7 @@ static DWORD WINAPI condvar_base_consumer(void *arg)
     ret = pSleepConditionVariableCS(cv, &condvar_crit, 10);
     LeaveCriticalSection (&condvar_crit);
     ok (!ret, "SleepConditionVariableCS should return FALSE on out of band wake\n");
-    ok (GetLastError() == ERROR_TIMEOUT, "SleepConditionVariableCS should return ERROR_TIMEOUT on out of band wake, not %d\n", GetLastError());
+    ok (GetLastError() == ERROR_TIMEOUT, "SleepConditionVariableCS should return ERROR_TIMEOUT on out of band wake, not %ld\n", GetLastError());
 
     EnterCriticalSection (&condvar_crit);
     condvar_seq = 5;
@@ -1850,7 +1850,7 @@ static DWORD WINAPI condvar_base_consumer(void *arg)
     ret = pSleepConditionVariableCS(cv, &condvar_crit, 10);
     LeaveCriticalSection (&condvar_crit);
     ok (!ret, "SleepConditionVariableCS should return FALSE on out of band wake\n");
-    ok (GetLastError() == ERROR_TIMEOUT, "SleepConditionVariableCS should return ERROR_TIMEOUT on out of band wake, not %d\n", GetLastError());
+    ok (GetLastError() == ERROR_TIMEOUT, "SleepConditionVariableCS should return ERROR_TIMEOUT on out of band wake, not %ld\n", GetLastError());
 
     EnterCriticalSection (&condvar_crit);
     condvar_seq = 8;
@@ -1916,7 +1916,7 @@ static void test_condvars_base(RTL_CONDITION_VARIABLE *cv)
     LeaveCriticalSection (&condvar_crit);
 
     ok (!ret, "SleepConditionVariableCS should return FALSE on untriggered condvar\n");
-    ok (GetLastError() == ERROR_TIMEOUT, "SleepConditionVariableCS should return ERROR_TIMEOUT on untriggered condvar, not %d\n", GetLastError());
+    ok (GetLastError() == ERROR_TIMEOUT, "SleepConditionVariableCS should return ERROR_TIMEOUT on untriggered condvar, not %ld\n", GetLastError());
 
     if (pInitializeSRWLock)
     {
@@ -1925,14 +1925,14 @@ static void test_condvars_base(RTL_CONDITION_VARIABLE *cv)
         pReleaseSRWLockExclusive(&condvar_srwlock);
 
         ok(!ret, "SleepConditionVariableSRW should return FALSE on untriggered condvar\n");
-        ok(GetLastError() == ERROR_TIMEOUT, "SleepConditionVariableSRW should return ERROR_TIMEOUT on untriggered condvar, not %d\n", GetLastError());
+        ok(GetLastError() == ERROR_TIMEOUT, "SleepConditionVariableSRW should return ERROR_TIMEOUT on untriggered condvar, not %ld\n", GetLastError());
 
         pAcquireSRWLockShared(&condvar_srwlock);
         ret = pSleepConditionVariableSRW(cv, &condvar_srwlock, 10, CONDITION_VARIABLE_LOCKMODE_SHARED);
         pReleaseSRWLockShared(&condvar_srwlock);
 
         ok(!ret, "SleepConditionVariableSRW should return FALSE on untriggered condvar\n");
-        ok(GetLastError() == ERROR_TIMEOUT, "SleepConditionVariableSRW should return ERROR_TIMEOUT on untriggered condvar, not %d\n", GetLastError());
+        ok(GetLastError() == ERROR_TIMEOUT, "SleepConditionVariableSRW should return ERROR_TIMEOUT on untriggered condvar, not %ld\n", GetLastError());
     }
 
     condvar_seq = 0;
@@ -2373,35 +2373,35 @@ static void test_srwlock_base(SRWLOCK *lock)
     WaitForSingleObject(h3, 100);
 
     ok(!srwlock_base_errors.wrong_execution_order,
-            "thread commands were executed in the wrong order (occurred %d times).\n",
+            "thread commands were executed in the wrong order (occurred %ld times).\n",
             srwlock_base_errors.wrong_execution_order);
 
     ok(!srwlock_base_errors.samethread_excl_excl,
-            "AcquireSRWLockExclusive didn't block when called multiple times from the same thread (occurred %d times).\n",
+            "AcquireSRWLockExclusive didn't block when called multiple times from the same thread (occurred %ld times).\n",
             srwlock_base_errors.samethread_excl_excl);
 
     ok(!srwlock_base_errors.samethread_excl_shared,
-            "AcquireSRWLockShared didn't block when the same thread holds an exclusive lock (occurred %d times).\n",
+            "AcquireSRWLockShared didn't block when the same thread holds an exclusive lock (occurred %ld times).\n",
             srwlock_base_errors.samethread_excl_shared);
 
     ok(!srwlock_base_errors.samethread_shared_excl,
-            "AcquireSRWLockExclusive didn't block when the same thread holds a shared lock (occurred %d times).\n",
+            "AcquireSRWLockExclusive didn't block when the same thread holds a shared lock (occurred %ld times).\n",
             srwlock_base_errors.samethread_shared_excl);
 
     ok(!srwlock_base_errors.multithread_excl_excl,
-            "AcquireSRWLockExclusive didn't block when a second thread holds the exclusive lock (occurred %d times).\n",
+            "AcquireSRWLockExclusive didn't block when a second thread holds the exclusive lock (occurred %ld times).\n",
             srwlock_base_errors.multithread_excl_excl);
 
     ok(!srwlock_base_errors.excl_not_preferred,
-            "thread waiting for exclusive access to the SHMLock was not preferred (occurred %d times).\n",
+            "thread waiting for exclusive access to the SHMLock was not preferred (occurred %ld times).\n",
             srwlock_base_errors.excl_not_preferred);
 
     ok(!srwlock_base_errors.trylock_excl,
-            "TryAcquireSRWLockExclusive didn't behave as expected (occurred %d times).\n",
+            "TryAcquireSRWLockExclusive didn't behave as expected (occurred %ld times).\n",
             srwlock_base_errors.trylock_excl);
 
     ok(!srwlock_base_errors.trylock_shared,
-            "TryAcquireSRWLockShared didn't behave as expected (occurred %d times).\n",
+            "TryAcquireSRWLockShared didn't behave as expected (occurred %ld times).\n",
             srwlock_base_errors.trylock_shared);
 
 }
@@ -2480,12 +2480,12 @@ static void test_srwlock_example(void)
     WaitForSingleObject(h2, 1000);
     WaitForSingleObject(h3, 1000);
 
-    ok(!srwlock_inside, "threads didn't terminate properly, srwlock_inside is %d.\n", srwlock_inside);
-    ok(!srwlock_example_errors, "errors occurred while running SRWLock example test (number of errors: %d)\n",
+    ok(!srwlock_inside, "threads didn't terminate properly, srwlock_inside is %ld.\n", srwlock_inside);
+    ok(!srwlock_example_errors, "errors occurred while running SRWLock example test (number of errors: %ld)\n",
             srwlock_example_errors);
 
-    trace("number of shared accesses per thread are c1 %d, c2 %d, c3 %d\n", cnt1, cnt2, cnt3);
-    trace("number of total exclusive accesses is %d\n", srwlock_protected_value);
+    trace("number of shared accesses per thread are c1 %ld, c2 %ld, c3 %ld\n", cnt1, cnt2, cnt3);
+    trace("number of total exclusive accesses is %ld\n", srwlock_protected_value);
 }
 
 static DWORD WINAPI alertable_wait_thread(void *param)
@@ -2497,24 +2497,24 @@ static DWORD WINAPI alertable_wait_thread(void *param)
 
     ReleaseSemaphore(semaphores[0], 1, NULL);
     result = WaitForMultipleObjectsEx(1, &semaphores[1], TRUE, 1000, TRUE);
-    ok(result == WAIT_IO_COMPLETION, "expected WAIT_IO_COMPLETION, got %u\n", result);
+    ok(result == WAIT_IO_COMPLETION, "expected WAIT_IO_COMPLETION, got %lu\n", result);
     result = WaitForMultipleObjectsEx(1, &semaphores[1], TRUE, 200, TRUE);
-    ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", result);
+    ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %lu\n", result);
 
     ReleaseSemaphore(semaphores[0], 1, NULL);
     timeout.QuadPart = -10000000;
     status = pNtWaitForMultipleObjects(1, &semaphores[1], FALSE, TRUE, &timeout);
-    ok(status == STATUS_USER_APC, "expected STATUS_USER_APC, got %08x\n", status);
+    ok(status == STATUS_USER_APC, "expected STATUS_USER_APC, got %08lx\n", status);
     timeout.QuadPart = -2000000;
     status = pNtWaitForMultipleObjects(1, &semaphores[1], FALSE, TRUE, &timeout);
-    ok(status == STATUS_WAIT_0, "expected STATUS_WAIT_0, got %08x\n", status);
+    ok(status == STATUS_WAIT_0, "expected STATUS_WAIT_0, got %08lx\n", status);
 
     ReleaseSemaphore(semaphores[0], 1, NULL);
     timeout.QuadPart = -10000000;
     status = pNtWaitForMultipleObjects(1, &semaphores[1], FALSE, TRUE, &timeout);
-    ok(status == STATUS_USER_APC, "expected STATUS_USER_APC, got %08x\n", status);
+    ok(status == STATUS_USER_APC, "expected STATUS_USER_APC, got %08lx\n", status);
     result = WaitForSingleObject(semaphores[0], 0);
-    ok(result == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %u\n", result);
+    ok(result == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %lu\n", result);
 
     return 0;
 }
@@ -2531,7 +2531,7 @@ static void CALLBACK alertable_wait_apc2(ULONG_PTR userdata)
     DWORD result;
 
     result = WaitForSingleObject(semaphores[0], 1000);
-    ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", result);
+    ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %lu\n", result);
 }
 
 static void test_alertable_wait(void)
@@ -2540,35 +2540,35 @@ static void test_alertable_wait(void)
     DWORD result;
 
     semaphores[0] = CreateSemaphoreW(NULL, 0, 2, NULL);
-    ok(semaphores[0] != NULL, "CreateSemaphore failed with %u\n", GetLastError());
+    ok(semaphores[0] != NULL, "CreateSemaphore failed with %lu\n", GetLastError());
     semaphores[1] = CreateSemaphoreW(NULL, 0, 1, NULL);
-    ok(semaphores[1] != NULL, "CreateSemaphore failed with %u\n", GetLastError());
+    ok(semaphores[1] != NULL, "CreateSemaphore failed with %lu\n", GetLastError());
     thread = CreateThread(NULL, 0, alertable_wait_thread, semaphores, 0, NULL);
-    ok(thread != NULL, "CreateThread failed with %u\n", GetLastError());
+    ok(thread != NULL, "CreateThread failed with %lu\n", GetLastError());
 
     result = WaitForSingleObject(semaphores[0], 1000);
-    ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", result);
+    ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %lu\n", result);
     Sleep(100); /* ensure the thread is blocking in WaitForMultipleObjectsEx */
     result = QueueUserAPC(alertable_wait_apc, thread, (ULONG_PTR)semaphores);
-    ok(result != 0, "QueueUserAPC failed with %u\n", GetLastError());
+    ok(result != 0, "QueueUserAPC failed with %lu\n", GetLastError());
 
     result = WaitForSingleObject(semaphores[0], 1000);
-    ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", result);
+    ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %lu\n", result);
     Sleep(100); /* ensure the thread is blocking in NtWaitForMultipleObjects */
     result = QueueUserAPC(alertable_wait_apc, thread, (ULONG_PTR)semaphores);
-    ok(result != 0, "QueueUserAPC failed with %u\n", GetLastError());
+    ok(result != 0, "QueueUserAPC failed with %lu\n", GetLastError());
 
     result = WaitForSingleObject(semaphores[0], 1000);
-    ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", result);
+    ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %lu\n", result);
     Sleep(100); /* ensure the thread is blocking in NtWaitForMultipleObjects */
     result = QueueUserAPC(alertable_wait_apc2, thread, (ULONG_PTR)semaphores);
-    ok(result != 0, "QueueUserAPC failed with %u\n", GetLastError());
+    ok(result != 0, "QueueUserAPC failed with %lu\n", GetLastError());
     result = QueueUserAPC(alertable_wait_apc2, thread, (ULONG_PTR)semaphores);
-    ok(result != 0, "QueueUserAPC failed with %u\n", GetLastError());
+    ok(result != 0, "QueueUserAPC failed with %lu\n", GetLastError());
     ReleaseSemaphore(semaphores[0], 2, NULL);
 
     result = WaitForSingleObject(thread, 1000);
-    ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", result);
+    ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %lu\n", result);
     CloseHandle(thread);
     CloseHandle(semaphores[0]);
     CloseHandle(semaphores[1]);
@@ -2595,13 +2595,13 @@ static DWORD WINAPI apc_deadlock_thread(void *param)
         size = 0x1000;
         status = pNtAllocateVirtualMemory(pi->hProcess, &base, 0, &size,
                                           MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
-        ok(!status, "expected STATUS_SUCCESS, got %08x\n", status);
+        ok(!status, "expected STATUS_SUCCESS, got %08lx\n", status);
         ok(base != NULL, "expected base != NULL, got %p\n", base);
         SetEvent(info->event);
 
         size = 0;
         status = pNtFreeVirtualMemory(pi->hProcess, &base, &size, MEM_RELEASE);
-        ok(!status, "expected STATUS_SUCCESS, got %08x\n", status);
+        ok(!status, "expected STATUS_SUCCESS, got %08lx\n", status);
         SetEvent(info->event);
     }
 
@@ -2623,44 +2623,44 @@ static void test_apc_deadlock(void)
     winetest_get_mainargs(&argv);
     sprintf(cmdline, "\"%s\" sync apc_deadlock", argv[0]);
     success = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-    ok(success, "CreateProcess failed with %u\n", GetLastError());
+    ok(success, "CreateProcess failed with %lu\n", GetLastError());
 
     event = CreateEventA(NULL, FALSE, FALSE, NULL);
-    ok(event != NULL, "CreateEvent failed with %u\n", GetLastError());
+    ok(event != NULL, "CreateEvent failed with %lu\n", GetLastError());
 
     info.pi = π
     info.event = event;
     info.running = TRUE;
 
     thread = CreateThread(NULL, 0, apc_deadlock_thread, &info, 0, NULL);
-    ok(thread != NULL, "CreateThread failed with %u\n", GetLastError());
+    ok(thread != NULL, "CreateThread failed with %lu\n", GetLastError());
     result = WaitForSingleObject(event, 1000);
-    ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", result);
+    ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %lu\n", result);
 
     for (i = 0; i < 1000 && info.running; i++)
     {
         result = SuspendThread(pi.hThread);
-        ok(result == 0, "expected 0, got %u\n", result);
+        ok(result == 0, "expected 0, got %lu\n", result);
 
         WaitForSingleObject(event, 0); /* reset event */
         result = WaitForSingleObject(event, 1000);
         if (result == WAIT_TIMEOUT)
         {
             todo_wine
-            ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", result);
+            ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %lu\n", result);
             info.running = FALSE;
         }
         else
-            ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", result);
+            ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %lu\n", result);
 
         result = ResumeThread(pi.hThread);
-        ok(result == 1, "expected 1, got %u\n", result);
+        ok(result == 1, "expected 1, got %lu\n", result);
         Sleep(1);
     }
 
     info.running = FALSE;
     result = WaitForSingleObject(thread, 1000);
-    ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", result);
+    ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %lu\n", result);
     CloseHandle(thread);
     CloseHandle(event);
 
@@ -2733,48 +2733,48 @@ static void test_QueueUserAPC(void)
     NTSTATUS status;
 
     thread = CreateThread(NULL, 0, thread_proc, NULL, CREATE_SUSPENDED, &tid);
-    ok(thread != NULL, "CreateThread error %u\n", GetLastError());
+    ok(thread != NULL, "CreateThread error %lu\n", GetLastError());
 
     ret = TerminateThread(thread, 0xdeadbeef);
-    ok(ret, "TerminateThread error %u\n", GetLastError());
+    ok(ret, "TerminateThread error %lu\n", GetLastError());
 
     ret = WaitForSingleObject(thread, 1000);
-    ok(ret == WAIT_OBJECT_0, "got %u\n", ret);
+    ok(ret == WAIT_OBJECT_0, "got %lu\n", ret);
 
     ret = pNtQueueApcThread(thread, call_user_apc, (ULONG_PTR)user_apc, 0, 0);
-    ok(ret == STATUS_UNSUCCESSFUL, "got %#x\n", ret);
+    ok(ret == STATUS_UNSUCCESSFUL, "got %#lx\n", ret);
     ret = pNtQueueApcThread(thread, NULL, 0, 0, 0);
-    ok(ret == STATUS_UNSUCCESSFUL, "got %#x\n", ret);
+    ok(ret == STATUS_UNSUCCESSFUL, "got %#lx\n", ret);
 
     SetLastError(0xdeadbeef);
     ret = QueueUserAPC(user_apc, thread, 0);
     ok(!ret, "QueueUserAPC should fail\n");
-    ok(GetLastError() == ERROR_GEN_FAILURE, "got %u\n", GetLastError());
+    ok(GetLastError() == ERROR_GEN_FAILURE, "got %lu\n", GetLastError());
 
     CloseHandle(thread);
 
     apc_count = 0;
     ret = QueueUserAPC(user_apc, GetCurrentThread(), 0);
-    ok(ret, "QueueUserAPC failed err %u\n", GetLastError());
+    ok(ret, "QueueUserAPC failed err %lu\n", GetLastError());
     ok(!apc_count, "APC count %u\n", apc_count);
     ret = SleepEx( 100, TRUE );
-    ok( ret == WAIT_IO_COMPLETION, "SleepEx returned %u\n", ret);
+    ok( ret == WAIT_IO_COMPLETION, "SleepEx returned %lu\n", ret);
     ok(apc_count == 1, "APC count %u\n", apc_count);
 
     ret = pNtQueueApcThread( GetCurrentThread(), NULL, 0, 0, 0 );
-    ok( !ret, "got %#x\n", ret);
+    ok( !ret, "got %#lx\n", ret);
     ret = SleepEx( 100, TRUE );
-    ok( ret == WAIT_OBJECT_0, "SleepEx returned %u\n", ret);
+    ok( ret == WAIT_OBJECT_0, "SleepEx returned %lu\n", ret);
 
     apc_count = 0;
     ret = QueueUserAPC(user_apc, GetCurrentThread(), 0);
-    ok(ret, "QueueUserAPC failed err %u\n", GetLastError());
+    ok(ret, "QueueUserAPC failed err %lu\n", GetLastError());
     ok(!apc_count, "APC count %u\n", apc_count);
     status = pNtTestAlert();
-    ok(!status, "got %x\n", status);
+    ok(!status, "got %lx\n", status);
     ok(apc_count == 1, "APC count %u\n", apc_count);
     status = pNtTestAlert();
-    ok(!status, "got %x\n", status);
+    ok(!status, "got %lx\n", status);
     ok(apc_count == 1, "APC count %u\n", apc_count);
 }
 
diff --git a/dlls/kernel32/tests/thread.c b/dlls/kernel32/tests/thread.c
index 6ccf7af85f8..aa62ba17e77 100644
--- a/dlls/kernel32/tests/thread.c
+++ b/dlls/kernel32/tests/thread.c
@@ -113,9 +113,9 @@ static HANDLE create_target_process(const char *arg)
     winetest_get_mainargs( &argv );
     sprintf(cmdline, "%s %s %s", argv[0], argv[1], arg);
     ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-    ok(ret, "error: %u\n", GetLastError());
+    ok(ret, "error: %lu\n", GetLastError());
     ret = CloseHandle(pi.hThread);
-    ok(ret, "error %u\n", GetLastError());
+    ok(ret, "error %lu\n", GetLastError());
     return pi.hProcess;
 }
 
@@ -156,7 +156,7 @@ static BOOL sync_threads_and_run_one(DWORD sync_id, DWORD my_id)
   else
   {
     DWORD ret = WaitForSingleObject(start_event, 10000);
-    ok(ret == WAIT_OBJECT_0, "WaitForSingleObject failed %x\n",ret);
+    ok(ret == WAIT_OBJECT_0, "WaitForSingleObject failed %lx\n",ret);
   }
   return sync_id == my_id;
 }
@@ -306,7 +306,7 @@ static DWORD WINAPI thread_actctx_func(void *p)
 
     cur = (void*)0xdeadbeef;
     ret = GetCurrentActCtx(&cur);
-    ok(ret, "thread GetCurrentActCtx failed, %u\n", GetLastError());
+    ok(ret, "thread GetCurrentActCtx failed, %lu\n", GetLastError());
     ok(cur == param->handle, "got %p, expected %p\n", cur, param->handle);
     param->thread_context = cur;
 
@@ -343,13 +343,13 @@ static VOID test_CreateRemoteThread(void)
         skip("child process wasn't mapped at same address, so can't do CreateRemoteThread tests.\n");
         return;
     }
-    ok(ret == WAIT_OBJECT_0 || broken(ret == WAIT_OBJECT_0+1 /* nt4,w2k */), "WaitForAllObjects 2 events %d\n", ret);
+    ok(ret == WAIT_OBJECT_0 || broken(ret == WAIT_OBJECT_0+1 /* nt4,w2k */), "WaitForAllObjects 2 events %ld\n", ret);
 
     hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
-    ok(hEvent != NULL, "Can't create event, err=%u\n", GetLastError());
+    ok(hEvent != NULL, "Can't create event, err=%lu\n", GetLastError());
     ret = DuplicateHandle(GetCurrentProcess(), hEvent, hProcess, &hRemoteEvent,
                           0, FALSE, DUPLICATE_SAME_ACCESS);
-    ok(ret != 0, "DuplicateHandle failed, err=%u\n", GetLastError());
+    ok(ret != 0, "DuplicateHandle failed, err=%lu\n", GetLastError());
 
     /* create suspended remote thread with entry point SetEvent() */
     SetLastError(0xdeadbeef);
@@ -360,51 +360,51 @@ static VOID test_CreateRemoteThread(void)
         win_skip("CreateRemoteThread is not implemented\n");
         goto cleanup;
     }
-    ok(hThread != NULL, "CreateRemoteThread failed, err=%u\n", GetLastError());
+    ok(hThread != NULL, "CreateRemoteThread failed, err=%lu\n", GetLastError());
     ok(tid != 0, "null tid\n");
     ret = SuspendThread(hThread);
-    ok(ret == 1, "ret=%u, err=%u\n", ret, GetLastError());
+    ok(ret == 1, "ret=%lu, err=%lu\n", ret, GetLastError());
     ret = ResumeThread(hThread);
-    ok(ret == 2, "ret=%u, err=%u\n", ret, GetLastError());
+    ok(ret == 2, "ret=%lu, err=%lu\n", ret, GetLastError());
 
     /* thread still suspended, so wait times out */
     ret = WaitForSingleObject(hEvent, 1000);
-    ok(ret == WAIT_TIMEOUT, "wait did not time out, ret=%u\n", ret);
+    ok(ret == WAIT_TIMEOUT, "wait did not time out, ret=%lu\n", ret);
 
     ret = ResumeThread(hThread);
-    ok(ret == 1, "ret=%u, err=%u\n", ret, GetLastError());
+    ok(ret == 1, "ret=%lu, err=%lu\n", ret, GetLastError());
 
     /* wait that doesn't time out */
     ret = WaitForSingleObject(hEvent, 1000);
-    ok(ret == WAIT_OBJECT_0, "object not signaled, ret=%u\n", ret);
+    ok(ret == WAIT_OBJECT_0, "object not signaled, ret=%lu\n", ret);
 
     /* wait for thread end */
     ret = WaitForSingleObject(hThread, 1000);
-    ok(ret == WAIT_OBJECT_0, "waiting for thread failed, ret=%u\n", ret);
+    ok(ret == WAIT_OBJECT_0, "waiting for thread failed, ret=%lu\n", ret);
     CloseHandle(hThread);
 
     /* create and wait for remote thread with entry point CloseHandle() */
     hThread = CreateRemoteThread(hProcess, NULL, 0,
                                  threadFunc_CloseHandle,
                                  hRemoteEvent, 0, &tid);
-    ok(hThread != NULL, "CreateRemoteThread failed, err=%u\n", GetLastError());
+    ok(hThread != NULL, "CreateRemoteThread failed, err=%lu\n", GetLastError());
     ret = WaitForSingleObject(hThread, 1000);
-    ok(ret == WAIT_OBJECT_0, "waiting for thread failed, ret=%u\n", ret);
+    ok(ret == WAIT_OBJECT_0, "waiting for thread failed, ret=%lu\n", ret);
     CloseHandle(hThread);
 
     /* create remote thread with entry point SetEvent() */
     hThread = CreateRemoteThread(hProcess, NULL, 0,
                                  threadFunc_SetEvent,
                                  hRemoteEvent, 0, &tid);
-    ok(hThread != NULL, "CreateRemoteThread failed, err=%u\n", GetLastError());
+    ok(hThread != NULL, "CreateRemoteThread failed, err=%lu\n", GetLastError());
 
     /* closed handle, so wait times out */
     ret = WaitForSingleObject(hEvent, 1000);
-    ok(ret == WAIT_TIMEOUT, "wait did not time out, ret=%u\n", ret);
+    ok(ret == WAIT_TIMEOUT, "wait did not time out, ret=%lu\n", ret);
 
     /* check that remote SetEvent() failed */
     ret = GetExitCodeThread(hThread, &exitcode);
-    ok(ret != 0, "GetExitCodeThread failed, err=%u\n", GetLastError());
+    ok(ret != 0, "GetExitCodeThread failed, err=%lu\n", GetLastError());
     if (ret) ok(exitcode == 0, "SetEvent succeeded, expected to fail\n");
     CloseHandle(hThread);
 
@@ -483,31 +483,31 @@ static VOID test_CreateThread_basic(void)
 
   SetLastError(0xCAFEF00D);
   bRet = TlsFree(tlsIndex);
-  ok(bRet, "TlsFree failed: %08x\n", GetLastError());
+  ok(bRet, "TlsFree failed: %08lx\n", GetLastError());
   ok(GetLastError()==0xCAFEF00D,
-     "GetLastError: expected 0xCAFEF00D, got %08x\n", GetLastError());
+     "GetLastError: expected 0xCAFEF00D, got %08lx\n", GetLastError());
 
   /* Test freeing an already freed TLS index */
   SetLastError(0xCAFEF00D);
   ok(TlsFree(tlsIndex)==0,"TlsFree succeeded\n");
   ok(GetLastError()==ERROR_INVALID_PARAMETER,
-     "GetLastError: expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
+     "GetLastError: expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
 
   /* Test how passing NULL as a pointer to threadid works */
   SetLastError(0xFACEaBAD);
   thread[0] = CreateThread(NULL,0,threadFunc2,NULL,0,&tid);
   GLE = GetLastError();
   if (thread[0]) { /* NT */
-    ok(GLE==0xFACEaBAD, "CreateThread set last error to %d, expected 4207848365\n", GLE);
+    ok(GLE==0xFACEaBAD, "CreateThread set last error to %ld, expected 4207848365\n", GLE);
     ret = WaitForSingleObject(thread[0],100);
     ok(ret==WAIT_OBJECT_0, "threadFunc2 did not exit during 100 ms\n");
     ret = GetExitCodeThread(thread[0],&exitCode);
-    ok(ret!=0, "GetExitCodeThread returned %d (expected nonzero)\n", ret);
-    ok(exitCode==99, "threadFunc2 exited with code: %d (expected 99)\n", exitCode);
+    ok(ret!=0, "GetExitCodeThread returned %ld (expected nonzero)\n", ret);
+    ok(exitCode==99, "threadFunc2 exited with code: %ld (expected 99)\n", exitCode);
     ok(CloseHandle(thread[0])!=0,"Error closing thread handle\n");
   }
   else { /* 9x */
-    ok(GLE==ERROR_INVALID_PARAMETER, "CreateThread set last error to %d, expected 87\n", GLE);
+    ok(GLE==ERROR_INVALID_PARAMETER, "CreateThread set last error to %ld, expected 87\n", GLE);
   }
 }
 
@@ -540,12 +540,12 @@ static VOID test_CreateThread_suspended(void)
   }
 
   suspend_count = SuspendThread(thread);
-  ok(suspend_count == -1, "SuspendThread returned %d, expected -1\n", suspend_count);
+  ok(suspend_count == -1, "SuspendThread returned %ld, expected -1\n", suspend_count);
 
   suspend_count = ResumeThread(thread);
   ok(suspend_count == 0 ||
      broken(suspend_count == -1), /* win9x */
-     "ResumeThread returned %d, expected 0\n", suspend_count);
+     "ResumeThread returned %ld, expected 0\n", suspend_count);
 
   ok(CloseHandle(thread)!=0,"CloseHandle failed\n");
 }
@@ -598,8 +598,8 @@ static VOID test_SuspendThread(void)
   }
   /* Trying to suspend a terminated thread should fail */
   error=SuspendThread(thread);
-  ok(error==~0U, "wrong return code: %d\n", error);
-  ok(GetLastError()==ERROR_ACCESS_DENIED || GetLastError()==ERROR_NO_MORE_ITEMS, "unexpected error code: %d\n", GetLastError());
+  ok(error==~0U, "wrong return code: %ld\n", error);
+  ok(GetLastError()==ERROR_ACCESS_DENIED || GetLastError()==ERROR_NO_MORE_ITEMS, "unexpected error code: %ld\n", GetLastError());
 
   ok(CloseHandle(thread)!=0,"CloseHandle Failed\n");
 }
@@ -730,7 +730,7 @@ static VOID test_thread_priority(void)
    ok(rc == FALSE, "SetThreadPriority passed with a bad argument\n");
    ok(GetLastError() == ERROR_INVALID_PARAMETER ||
       GetLastError() == ERROR_INVALID_PRIORITY /* Win9x */,
-      "SetThreadPriority error %d, expected ERROR_INVALID_PARAMETER or ERROR_INVALID_PRIORITY\n",
+      "SetThreadPriority error %ld, expected ERROR_INVALID_PARAMETER or ERROR_INVALID_PRIORITY\n",
       GetLastError());
    ok(GetThreadPriority(curthread)==min_priority,
       "GetThreadPriority didn't return min_priority\n");
@@ -742,7 +742,7 @@ static VOID test_thread_priority(void)
    ok(rc == FALSE, "SetThreadPriority passed with a bad argument\n");
    ok(GetLastError() == ERROR_INVALID_PARAMETER ||
       GetLastError() == ERROR_INVALID_PRIORITY /* Win9x */,
-      "SetThreadPriority error %d, expected ERROR_INVALID_PARAMETER or ERROR_INVALID_PRIORITY\n",
+      "SetThreadPriority error %ld, expected ERROR_INVALID_PARAMETER or ERROR_INVALID_PRIORITY\n",
       GetLastError());
    ok(GetThreadPriority(curthread)==max_priority,
       "GetThreadPriority didn't return max_priority\n");
@@ -759,7 +759,7 @@ static VOID test_thread_priority(void)
       return;
    }
 
-   ok(rc!=0,"error=%d\n",GetLastError());
+   ok(rc!=0,"error=%ld\n",GetLastError());
 
    if (pOpenThread) {
 /* check that access control is obeyed */
@@ -775,18 +775,18 @@ static VOID test_thread_priority(void)
    }
 
    rc = pSetThreadPriorityBoost(curthread,1);
-   ok( rc != 0, "error=%d\n",GetLastError());
+   ok( rc != 0, "error=%ld\n",GetLastError());
    todo_wine {
      rc=pGetThreadPriorityBoost(curthread,&disabled);
      ok(rc!=0 && disabled==1,
-        "rc=%d error=%d disabled=%d\n",rc,GetLastError(),disabled);
+        "rc=%d error=%ld disabled=%d\n",rc,GetLastError(),disabled);
    }
 
    rc = pSetThreadPriorityBoost(curthread,0);
-   ok( rc != 0, "error=%d\n",GetLastError());
+   ok( rc != 0, "error=%ld\n",GetLastError());
    rc=pGetThreadPriorityBoost(curthread,&disabled);
    ok(rc!=0 && disabled==0,
-      "rc=%d error=%d disabled=%d\n",rc,GetLastError(),disabled);
+      "rc=%d error=%ld disabled=%d\n",rc,GetLastError(),disabled);
 }
 
 /* check the GetThreadTimes function */
@@ -883,7 +883,7 @@ static VOID test_thread_processor(void)
         /* Show that the "all processors" flag is handled in ntdll */
         DWORD_PTR mask = ~0u;
         NTSTATUS status = pNtSetInformationThread(curthread, ThreadAffinityMask, &mask, sizeof(mask));
-        ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS in NtSetInformationThread, got %x\n", status);
+        ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS in NtSetInformationThread, got %lx\n", status);
     }
 
    if (retMask == processMask && sizeof(ULONG_PTR) > sizeof(ULONG))
@@ -914,7 +914,7 @@ static VOID test_thread_processor(void)
                 error=pSetThreadIdealProcessor(curthread,65);
                 ok(error==-1, "SetThreadIdealProcessor succeeded with an illegal processor #\n");
                 ok(GetLastError()==ERROR_INVALID_PARAMETER,
-                   "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+                   "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
             }
             else
             {
@@ -922,7 +922,7 @@ static VOID test_thread_processor(void)
                 error=pSetThreadIdealProcessor(curthread,MAXIMUM_PROCESSORS+1);
                 ok(error==-1, "SetThreadIdealProcessor succeeded with an illegal processor #\n");
                 ok(GetLastError()==ERROR_INVALID_PARAMETER,
-                   "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+                   "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
             }
 
             error=pSetThreadIdealProcessor(curthread,MAXIMUM_PROCESSORS);
@@ -943,14 +943,14 @@ static VOID test_thread_processor(void)
         SetLastError(0xdeadbeef);
         ok(!pGetThreadGroupAffinity(curthread, NULL), "GetThreadGroupAffinity succeeded\n");
         ok(GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == ERROR_NOACCESS), /* Win 7 and 8 */
-           "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+           "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
         ok(affinity.Group == 0, "Expected group 0 got %u\n", affinity.Group);
 
         memset(&affinity_new, 0, sizeof(affinity_new));
         affinity_new.Group = 0;
         affinity_new.Mask  = affinity.Mask;
         ok(pSetThreadGroupAffinity(curthread, &affinity_new, &affinity), "SetThreadGroupAffinity failed\n");
-        ok(affinity_new.Mask == affinity.Mask, "Expected old affinity mask %lx, got %lx\n",
+        ok(affinity_new.Mask == affinity.Mask, "Expected old affinity mask %Ix, got %Ix\n",
            affinity_new.Mask, affinity.Mask);
 
         /* show that the "all processors" flag is not supported for SetThreadGroupAffinity */
@@ -959,31 +959,31 @@ static VOID test_thread_processor(void)
         SetLastError(0xdeadbeef);
         ok(!pSetThreadGroupAffinity(curthread, &affinity_new, NULL), "SetThreadGroupAffinity succeeded\n");
         ok(GetLastError() == ERROR_INVALID_PARAMETER,
-           "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+           "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
         affinity_new.Group = 1; /* assumes that you have less than 64 logical processors */
         affinity_new.Mask  = 0x1;
         SetLastError(0xdeadbeef);
         ok(!pSetThreadGroupAffinity(curthread, &affinity_new, NULL), "SetThreadGroupAffinity succeeded\n");
         ok(GetLastError() == ERROR_INVALID_PARAMETER,
-           "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+           "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
         SetLastError(0xdeadbeef);
         ok(!pSetThreadGroupAffinity(curthread, NULL, NULL), "SetThreadGroupAffinity succeeded\n");
         ok(GetLastError() == ERROR_NOACCESS,
-           "Expected ERROR_NOACCESS, got %d\n", GetLastError());
+           "Expected ERROR_NOACCESS, got %ld\n", GetLastError());
 
         /* show that the access violation was detected in ntdll */
         status = pNtSetInformationThread(curthread, ThreadGroupInformation, NULL, sizeof(affinity_new));
         ok(status == STATUS_ACCESS_VIOLATION,
-           "Expected STATUS_ACCESS_VIOLATION, got %08x\n", status);
+           "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", status);
 
         /* restore original mask */
         affinity_new.Group = 0;
         affinity_new.Mask  = affinity.Mask;
         SetLastError(0xdeadbeef);
         ok(pSetThreadGroupAffinity(curthread, &affinity_new, &affinity), "SetThreadGroupAffinity failed\n");
-        ok(affinity_new.Mask == affinity.Mask, "Expected old affinity mask %lx, got %lx\n",
+        ok(affinity_new.Mask == affinity.Mask, "Expected old affinity mask %Ix, got %Ix\n",
            affinity_new.Mask, affinity.Mask);
     }
     else
@@ -1009,8 +1009,8 @@ static VOID test_GetCurrentThreadStackLimits(void)
     }
 
     pGetCurrentThreadStackLimits(&low, &high);
-    ok(low == (ULONG_PTR)NtCurrentTeb()->DeallocationStack, "expected %p, got %lx\n", NtCurrentTeb()->DeallocationStack, low);
-    ok(high == (ULONG_PTR)NtCurrentTeb()->Tib.StackBase, "expected %p, got %lx\n", NtCurrentTeb()->Tib.StackBase, high);
+    ok(low == (ULONG_PTR)NtCurrentTeb()->DeallocationStack, "expected %p, got %Ix\n", NtCurrentTeb()->DeallocationStack, low);
+    ok(high == (ULONG_PTR)NtCurrentTeb()->Tib.StackBase, "expected %p, got %Ix\n", NtCurrentTeb()->Tib.StackBase, high);
 }
 
 static void test_SetThreadStackGuarantee(void)
@@ -1025,46 +1025,46 @@ static void test_SetThreadStackGuarantee(void)
     }
     size = 0;
     ret = pSetThreadStackGuarantee( &size );
-    ok( ret, "failed err %u\n", GetLastError() );
-    ok( size == 0, "wrong size %u\n", size );
-    ok( NtCurrentTeb()->GuaranteedStackBytes == 0, "wrong teb %u\n",
+    ok( ret, "failed err %lu\n", GetLastError() );
+    ok( size == 0, "wrong size %lu\n", size );
+    ok( NtCurrentTeb()->GuaranteedStackBytes == 0, "wrong teb %lu\n",
         NtCurrentTeb()->GuaranteedStackBytes );
     size = 0xdeadbef;
     ret = pSetThreadStackGuarantee( &size );
     ok( !ret, "succeeded\n" );
     ok( GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_INVALID_ADDRESS,
-        "wrong error %u\n", GetLastError());
-    ok( size == 0, "wrong size %u\n", size );
-    ok( NtCurrentTeb()->GuaranteedStackBytes == 0, "wrong teb %u\n",
+        "wrong error %lu\n", GetLastError());
+    ok( size == 0, "wrong size %lu\n", size );
+    ok( NtCurrentTeb()->GuaranteedStackBytes == 0, "wrong teb %lu\n",
         NtCurrentTeb()->GuaranteedStackBytes );
     size = 200;
     ret = pSetThreadStackGuarantee( &size );
-    ok( ret, "failed err %u\n", GetLastError() );
-    ok( size == 0, "wrong size %u\n", size );
-    ok( NtCurrentTeb()->GuaranteedStackBytes == 4096 * sizeof(void *) / 4, "wrong teb %u\n",
+    ok( ret, "failed err %lu\n", GetLastError() );
+    ok( size == 0, "wrong size %lu\n", size );
+    ok( NtCurrentTeb()->GuaranteedStackBytes == 4096 * sizeof(void *) / 4, "wrong teb %lu\n",
         NtCurrentTeb()->GuaranteedStackBytes );
     size = 5000;
     ret = pSetThreadStackGuarantee( &size );
-    ok( ret, "failed err %u\n", GetLastError() );
-    ok( size == 4096 * sizeof(void *) / 4, "wrong size %u\n", size );
-    ok( NtCurrentTeb()->GuaranteedStackBytes == 8192, "wrong teb %u\n",
+    ok( ret, "failed err %lu\n", GetLastError() );
+    ok( size == 4096 * sizeof(void *) / 4, "wrong size %lu\n", size );
+    ok( NtCurrentTeb()->GuaranteedStackBytes == 8192, "wrong teb %lu\n",
         NtCurrentTeb()->GuaranteedStackBytes );
     size = 2000;
     ret = pSetThreadStackGuarantee( &size );
-    ok( ret, "failed err %u\n", GetLastError() );
-    ok( size == 8192, "wrong size %u\n", size );
-    ok( NtCurrentTeb()->GuaranteedStackBytes == 8192, "wrong teb %u\n",
+    ok( ret, "failed err %lu\n", GetLastError() );
+    ok( size == 8192, "wrong size %lu\n", size );
+    ok( NtCurrentTeb()->GuaranteedStackBytes == 8192, "wrong teb %lu\n",
         NtCurrentTeb()->GuaranteedStackBytes );
     size = 10000;
     ret = pSetThreadStackGuarantee( &size );
-    ok( ret, "failed err %u\n", GetLastError() );
-    ok( size == 8192, "wrong size %u\n", size );
-    ok( NtCurrentTeb()->GuaranteedStackBytes == 12288, "wrong teb %u\n",
+    ok( ret, "failed err %lu\n", GetLastError() );
+    ok( size == 8192, "wrong size %lu\n", size );
+    ok( NtCurrentTeb()->GuaranteedStackBytes == 12288, "wrong teb %lu\n",
         NtCurrentTeb()->GuaranteedStackBytes );
     ret = pSetThreadStackGuarantee( &size );
-    ok( ret, "failed err %u\n", GetLastError() );
-    ok( size == 12288, "wrong size %u\n", size );
-    ok( NtCurrentTeb()->GuaranteedStackBytes == 12288, "wrong teb %u\n",
+    ok( ret, "failed err %lu\n", GetLastError() );
+    ok( size == 12288, "wrong size %lu\n", size );
+    ok( NtCurrentTeb()->GuaranteedStackBytes == 12288, "wrong teb %lu\n",
         NtCurrentTeb()->GuaranteedStackBytes );
 }
 
@@ -1075,17 +1075,17 @@ static VOID test_GetThreadExitCode(void)
     HANDLE thread;
 
     ret = GetExitCodeThread((HANDLE)0x2bad2bad,&exitCode);
-    ok(ret==0, "GetExitCodeThread returned non zero value: %d\n", ret);
+    ok(ret==0, "GetExitCodeThread returned non zero value: %ld\n", ret);
     GLE = GetLastError();
-    ok(GLE==ERROR_INVALID_HANDLE, "GetLastError returned %d (expected 6)\n", GLE);
+    ok(GLE==ERROR_INVALID_HANDLE, "GetLastError returned %ld (expected 6)\n", GLE);
 
     thread = CreateThread(NULL,0,threadFunc2,NULL,0,&threadid);
     ret = WaitForSingleObject(thread,100);
     ok(ret==WAIT_OBJECT_0, "threadFunc2 did not exit during 100 ms\n");
     ret = GetExitCodeThread(thread,&exitCode);
     ok(ret==exitCode || ret==1, 
-       "GetExitCodeThread returned %d (expected 1 or %d)\n", ret, exitCode);
-    ok(exitCode==99, "threadFunc2 exited with code %d (expected 99)\n", exitCode);
+       "GetExitCodeThread returned %ld (expected 1 or %ld)\n", ret, exitCode);
+    ok(exitCode==99, "threadFunc2 exited with code %ld (expected 99)\n", exitCode);
     ok(CloseHandle(thread)!=0,"Error closing thread handle\n");
 }
 
@@ -1120,7 +1120,7 @@ static void test_SetThreadContext(void)
     SetLastError(0xdeadbeef);
     event = CreateEventW( NULL, TRUE, FALSE, NULL );
     thread = CreateThread( NULL, 0, threadFunc6, (void *)2, 0, &threadid );
-    ok( thread != NULL, "CreateThread failed : (%d)\n", GetLastError() );
+    ok( thread != NULL, "CreateThread failed : (%ld)\n", GetLastError() );
     if (!thread)
     {
         trace("Thread creation failed, skipping rest of test\n");
@@ -1133,7 +1133,7 @@ static void test_SetThreadContext(void)
     ctx.ContextFlags = CONTEXT_FULL;
     SetLastError(0xdeadbeef);
     ret = GetThreadContext( thread, &ctx );
-    ok( ret, "GetThreadContext failed : (%u)\n", GetLastError() );
+    ok( ret, "GetThreadContext failed : (%lu)\n", GetLastError() );
 
     if (ret)
     {
@@ -1145,12 +1145,12 @@ static void test_SetThreadContext(void)
         ctx.Eip = (DWORD)set_test_val;
         SetLastError(0xdeadbeef);
         ret = SetThreadContext( thread, &ctx );
-        ok( ret, "SetThreadContext failed : (%d)\n", GetLastError() );
+        ok( ret, "SetThreadContext failed : (%ld)\n", GetLastError() );
     }
 
     SetLastError(0xdeadbeef);
     prevcount = ResumeThread( thread );
-    ok ( prevcount == 1, "Previous suspend count (%d) instead of 1, last error : (%d)\n",
+    ok ( prevcount == 1, "Previous suspend count (%ld) instead of 1, last error : (%ld)\n",
                          prevcount, GetLastError() );
 
     WaitForSingleObject( thread, INFINITE );
@@ -1162,7 +1162,7 @@ static void test_SetThreadContext(void)
     ok( (!ret && ((GetLastError() == ERROR_GEN_FAILURE) || (GetLastError() == ERROR_ACCESS_DENIED))) ||
         (!ret && broken(GetLastError() == ERROR_INVALID_HANDLE)) || /* win2k */
         broken(ret),   /* 32bit application on NT 5.x 64bit */
-        "got %d with %u (expected FALSE with ERROR_GEN_FAILURE or ERROR_ACCESS_DENIED)\n",
+        "got %d with %lu (expected FALSE with ERROR_GEN_FAILURE or ERROR_ACCESS_DENIED)\n",
         ret, GetLastError() );
 
     SetLastError(0xdeadbeef);
@@ -1170,7 +1170,7 @@ static void test_SetThreadContext(void)
     ok( (!ret && ((GetLastError() == ERROR_GEN_FAILURE) || (GetLastError() == ERROR_ACCESS_DENIED))) ||
         (!ret && broken(GetLastError() == ERROR_INVALID_HANDLE)) || /* win2k */
         broken(ret),   /* 32bit application on NT 5.x 64bit */
-        "got %d with %u (expected FALSE with ERROR_GEN_FAILURE or ERROR_ACCESS_DENIED)\n",
+        "got %d with %lu (expected FALSE with ERROR_GEN_FAILURE or ERROR_ACCESS_DENIED)\n",
         ret, GetLastError() );
 
     CloseHandle( thread );
@@ -1182,10 +1182,10 @@ static DWORD WINAPI test_stack( void *arg )
 
     ok( stack == NtCurrentTeb()->Tib.StackBase, "wrong stack %p/%p\n",
         stack, NtCurrentTeb()->Tib.StackBase );
-    ok( !stack[-1], "wrong data %p = %08x\n", stack - 1, stack[-1] );
-    ok( stack[-2] == (DWORD)arg, "wrong data %p = %08x\n", stack - 2, stack[-2] );
-    ok( stack[-3] == (DWORD)test_stack, "wrong data %p = %08x\n", stack - 3, stack[-3] );
-    ok( !stack[-4], "wrong data %p = %08x\n", stack - 4, stack[-4] );
+    ok( !stack[-1], "wrong data %p = %08lx\n", stack - 1, stack[-1] );
+    ok( stack[-2] == (DWORD)arg, "wrong data %p = %08lx\n", stack - 2, stack[-2] );
+    ok( stack[-3] == (DWORD)test_stack, "wrong data %p = %08lx\n", stack - 3, stack[-3] );
+    ok( !stack[-4], "wrong data %p = %08lx\n", stack - 4, stack[-4] );
     return 0;
 }
 
@@ -1198,10 +1198,10 @@ static void test_GetThreadContext(void)
     memset(&ctx, 0xcc, sizeof(ctx));
     ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS;
     ret = GetThreadContext(GetCurrentThread(), &ctx);
-    ok(ret, "GetThreadContext failed: %u\n", GetLastError());
-    ok(ctx.ContextFlags == CONTEXT_DEBUG_REGISTERS, "ContextFlags = %x\n", ctx.ContextFlags);
-    ok(!ctx.Dr0, "Dr0 = %x\n", ctx.Dr0);
-    ok(!ctx.Dr1, "Dr0 = %x\n", ctx.Dr0);
+    ok(ret, "GetThreadContext failed: %lu\n", GetLastError());
+    ok(ctx.ContextFlags == CONTEXT_DEBUG_REGISTERS, "ContextFlags = %lx\n", ctx.ContextFlags);
+    ok(!ctx.Dr0, "Dr0 = %lx\n", ctx.Dr0);
+    ok(!ctx.Dr1, "Dr0 = %lx\n", ctx.Dr0);
 
     thread = CreateThread( NULL, 0, test_stack, (void *)0x1234, 0, NULL );
     WaitForSingleObject( thread, 1000 );
@@ -1219,41 +1219,41 @@ static void test_GetThreadSelectorEntry(void)
     memset(&ctx, 0x11, sizeof(ctx));
     ctx.ContextFlags = CONTEXT_SEGMENTS | CONTEXT_CONTROL;
     ret = GetThreadContext(GetCurrentThread(), &ctx);
-    ok(ret, "GetThreadContext error %u\n", GetLastError());
-    ok(!HIWORD(ctx.SegCs), "expected HIWORD(SegCs) == 0, got %u\n", ctx.SegCs);
-    ok(!HIWORD(ctx.SegDs), "expected HIWORD(SegDs) == 0, got %u\n", ctx.SegDs);
-    ok(!HIWORD(ctx.SegFs), "expected HIWORD(SegFs) == 0, got %u\n", ctx.SegFs);
+    ok(ret, "GetThreadContext error %lu\n", GetLastError());
+    ok(!HIWORD(ctx.SegCs), "expected HIWORD(SegCs) == 0, got %lu\n", ctx.SegCs);
+    ok(!HIWORD(ctx.SegDs), "expected HIWORD(SegDs) == 0, got %lu\n", ctx.SegDs);
+    ok(!HIWORD(ctx.SegFs), "expected HIWORD(SegFs) == 0, got %lu\n", ctx.SegFs);
 
     ret = GetThreadSelectorEntry(GetCurrentThread(), ctx.SegCs, &entry);
-    ok(ret, "GetThreadSelectorEntry(SegCs) error %u\n", GetLastError());
+    ok(ret, "GetThreadSelectorEntry(SegCs) error %lu\n", GetLastError());
     ret = GetThreadSelectorEntry(GetCurrentThread(), ctx.SegDs, &entry);
-    ok(ret, "GetThreadSelectorEntry(SegDs) error %u\n", GetLastError());
+    ok(ret, "GetThreadSelectorEntry(SegDs) error %lu\n", GetLastError());
     ret = GetThreadSelectorEntry(GetCurrentThread(), ctx.SegDs & ~3, &entry);
-    ok(ret, "GetThreadSelectorEntry(SegDs) error %u\n", GetLastError());
+    ok(ret, "GetThreadSelectorEntry(SegDs) error %lu\n", GetLastError());
     ret = GetThreadSelectorEntry(GetCurrentThread(), 0, &entry);
-    ok(ret, "GetThreadSelectorEntry(SegDs) error %u\n", GetLastError());
+    ok(ret, "GetThreadSelectorEntry(SegDs) error %lu\n", GetLastError());
     ret = GetThreadSelectorEntry(GetCurrentThread(), 3, &entry);
-    ok(ret, "GetThreadSelectorEntry(SegDs) error %u\n", GetLastError());
+    ok(ret, "GetThreadSelectorEntry(SegDs) error %lu\n", GetLastError());
     SetLastError( 0xdeadbeef );
     ret = GetThreadSelectorEntry(GetCurrentThread(), 0xdeadbeef, &entry);
     ok(!ret, "GetThreadSelectorEntry(invalid) succeeded\n");
     ok( GetLastError() == ERROR_GEN_FAILURE
-        || GetLastError() == ERROR_INVALID_THREAD_ID /* 32-bit */, "wrong error %u\n", GetLastError() );
+        || GetLastError() == ERROR_INVALID_THREAD_ID /* 32-bit */, "wrong error %lu\n", GetLastError() );
     ret = GetThreadSelectorEntry(GetCurrentThread(), ctx.SegDs + 0x100, &entry);
     ok(!ret, "GetThreadSelectorEntry(invalid) succeeded\n");
     ok( GetLastError() == ERROR_GEN_FAILURE
-        || GetLastError() == ERROR_NOACCESS /* 32-bit */, "wrong error %u\n", GetLastError() );
+        || GetLastError() == ERROR_NOACCESS /* 32-bit */, "wrong error %lu\n", GetLastError() );
 
     memset(&entry, 0x11, sizeof(entry));
     ret = GetThreadSelectorEntry(GetCurrentThread(), ctx.SegFs, &entry);
-    ok(ret, "GetThreadSelectorEntry(SegFs) error %u\n", GetLastError());
+    ok(ret, "GetThreadSelectorEntry(SegFs) error %lu\n", GetLastError());
     entry.HighWord.Bits.Type &= ~1; /* ignore accessed bit */
 
     base  = (void *)((entry.HighWord.Bits.BaseHi << 24) | (entry.HighWord.Bits.BaseMid << 16) | entry.BaseLow);
     limit = (entry.HighWord.Bits.LimitHi << 16) | entry.LimitLow;
 
     ok(base == NtCurrentTeb(),                "expected %p, got %p\n", NtCurrentTeb(), base);
-    ok(limit == 0x0fff || limit == 0x4000,    "expected 0x0fff or 0x4000, got %#x\n", limit);
+    ok(limit == 0x0fff || limit == 0x4000,    "expected 0x0fff or 0x4000, got %#lx\n", limit);
     ok(entry.HighWord.Bits.Type == 0x12,      "expected 0x12, got %#x\n", entry.HighWord.Bits.Type);
     ok(entry.HighWord.Bits.Dpl == 3,          "expected 3, got %u\n", entry.HighWord.Bits.Dpl);
     ok(entry.HighWord.Bits.Pres == 1,         "expected 1, got %u\n", entry.HighWord.Bits.Pres);
@@ -1264,13 +1264,13 @@ static void test_GetThreadSelectorEntry(void)
 
     memset(&entry, 0x11, sizeof(entry));
     ret = GetThreadSelectorEntry(GetCurrentThread(), ctx.SegCs, &entry);
-    ok(ret, "GetThreadSelectorEntry(SegDs) error %u\n", GetLastError());
+    ok(ret, "GetThreadSelectorEntry(SegDs) error %lu\n", GetLastError());
     entry.HighWord.Bits.Type &= ~1; /* ignore accessed bit */
     base  = (void *)((entry.HighWord.Bits.BaseHi << 24) | (entry.HighWord.Bits.BaseMid << 16) | entry.BaseLow);
     limit = (entry.HighWord.Bits.LimitHi << 16) | entry.LimitLow;
 
     ok(base == 0, "got base %p\n", base);
-    ok(limit == ~0u >> 12, "got limit %#x\n", limit);
+    ok(limit == ~0u >> 12, "got limit %#lx\n", limit);
     ok(entry.HighWord.Bits.Type == 0x1a,      "expected 0x12, got %#x\n", entry.HighWord.Bits.Type);
     ok(entry.HighWord.Bits.Dpl == 3,          "expected 3, got %u\n", entry.HighWord.Bits.Dpl);
     ok(entry.HighWord.Bits.Pres == 1,         "expected 1, got %u\n", entry.HighWord.Bits.Pres);
@@ -1281,13 +1281,13 @@ static void test_GetThreadSelectorEntry(void)
 
     memset(&entry, 0x11, sizeof(entry));
     ret = GetThreadSelectorEntry(GetCurrentThread(), ctx.SegDs, &entry);
-    ok(ret, "GetThreadSelectorEntry(SegDs) error %u\n", GetLastError());
+    ok(ret, "GetThreadSelectorEntry(SegDs) error %lu\n", GetLastError());
     entry.HighWord.Bits.Type &= ~1; /* ignore accessed bit */
     base  = (void *)((entry.HighWord.Bits.BaseHi << 24) | (entry.HighWord.Bits.BaseMid << 16) | entry.BaseLow);
     limit = (entry.HighWord.Bits.LimitHi << 16) | entry.LimitLow;
 
     ok(base == 0, "got base %p\n", base);
-    ok(limit == ~0u >> 12, "got limit %#x\n", limit);
+    ok(limit == ~0u >> 12, "got limit %#lx\n", limit);
     ok(entry.HighWord.Bits.Type == 0x12,      "expected 0x12, got %#x\n", entry.HighWord.Bits.Type);
     ok(entry.HighWord.Bits.Dpl == 3,          "expected 3, got %u\n", entry.HighWord.Bits.Dpl);
     ok(entry.HighWord.Bits.Pres == 1,         "expected 1, got %u\n", entry.HighWord.Bits.Pres);
@@ -1327,14 +1327,14 @@ static void test_QueueUserWorkItem(void)
     for (i = 0; i < 100; i++)
     {
         BOOL ret = pQueueUserWorkItem(work_function, (void *)i, WT_EXECUTEDEFAULT);
-        ok(ret, "QueueUserWorkItem failed with error %d\n", GetLastError());
+        ok(ret, "QueueUserWorkItem failed with error %ld\n", GetLastError());
     }
 
     wait_result = WaitForSingleObject(finish_event, 10000);
 
     after = GetTickCount();
-    trace("100 QueueUserWorkItem calls took %dms\n", after - before);
-    ok(wait_result == WAIT_OBJECT_0, "wait failed with error 0x%x\n", wait_result);
+    trace("100 QueueUserWorkItem calls took %ldms\n", after - before);
+    ok(wait_result == WAIT_OBJECT_0, "wait failed with error 0x%lx\n", wait_result);
 
     ok(times_executed == 100, "didn't execute all of the work items\n");
 }
@@ -1352,7 +1352,7 @@ static void CALLBACK wait_complete_function(PVOID p, BOOLEAN TimerOrWaitFired)
     DWORD res;
     ok(!TimerOrWaitFired, "wait shouldn't have timed out\n");
     res = WaitForSingleObject(event, INFINITE);
-    ok(res == WAIT_OBJECT_0, "WaitForSingleObject returned %x\n", res);
+    ok(res == WAIT_OBJECT_0, "WaitForSingleObject returned %lx\n", res);
 }
 
 static void CALLBACK timeout_function(PVOID p, BOOLEAN TimerOrWaitFired)
@@ -1393,7 +1393,7 @@ static void CALLBACK unregister_function(PVOID p, BOOLEAN TimerOrWaitFired)
     BOOL ret;
     ok(wait_handle != INVALID_HANDLE_VALUE, "invalid wait handle\n");
     ret = pUnregisterWait(param->wait_handle);
-    todo_wine ok(ret, "UnregisterWait failed with error %d\n", GetLastError());
+    todo_wine ok(ret, "UnregisterWait failed with error %ld\n", GetLastError());
     SetEvent(param->complete_event);
 }
 
@@ -1420,36 +1420,36 @@ static void test_RegisterWaitForSingleObject(void)
     complete_event = CreateEventW(NULL, FALSE, FALSE, NULL);
 
     ret = pRegisterWaitForSingleObject(&wait_handle, handle, signaled_function, complete_event, INFINITE, WT_EXECUTEONLYONCE);
-    ok(ret, "RegisterWaitForSingleObject failed with error %d\n", GetLastError());
+    ok(ret, "RegisterWaitForSingleObject failed with error %ld\n", GetLastError());
 
     WaitForSingleObject(complete_event, INFINITE);
     /* give worker thread chance to complete */
     Sleep(100);
 
     ret = pUnregisterWait(wait_handle);
-    ok(ret, "UnregisterWait failed with error %d\n", GetLastError());
+    ok(ret, "UnregisterWait failed with error %ld\n", GetLastError());
 
     /* test cancel case */
 
     ResetEvent(handle);
 
     ret = pRegisterWaitForSingleObject(&wait_handle, handle, signaled_function, complete_event, INFINITE, WT_EXECUTEONLYONCE);
-    ok(ret, "RegisterWaitForSingleObject failed with error %d\n", GetLastError());
+    ok(ret, "RegisterWaitForSingleObject failed with error %ld\n", GetLastError());
 
     ret = pUnregisterWait(wait_handle);
-    ok(ret, "UnregisterWait failed with error %d\n", GetLastError());
+    ok(ret, "UnregisterWait failed with error %ld\n", GetLastError());
 
     /* test unregister while running */
 
     SetEvent(handle);
     ret = pRegisterWaitForSingleObject(&wait_handle, handle, wait_complete_function, complete_event, INFINITE, WT_EXECUTEONLYONCE);
-    ok(ret, "RegisterWaitForSingleObject failed with error %d\n", GetLastError());
+    ok(ret, "RegisterWaitForSingleObject failed with error %ld\n", GetLastError());
 
     /* give worker thread chance to start */
     Sleep(50);
     ret = pUnregisterWait(wait_handle);
     ok(!ret, "UnregisterWait succeeded\n");
-    ok(GetLastError() == ERROR_IO_PENDING, "UnregisterWait failed with error %d\n", GetLastError());
+    ok(GetLastError() == ERROR_IO_PENDING, "UnregisterWait failed with error %ld\n", GetLastError());
 
     /* give worker thread chance to complete */
     SetEvent(complete_event);
@@ -1460,33 +1460,33 @@ static void test_RegisterWaitForSingleObject(void)
     ResetEvent(handle);
 
     ret = pRegisterWaitForSingleObject(&wait_handle, handle, timeout_function, complete_event, 0, WT_EXECUTEONLYONCE);
-    ok(ret, "RegisterWaitForSingleObject failed with error %d\n", GetLastError());
+    ok(ret, "RegisterWaitForSingleObject failed with error %ld\n", GetLastError());
 
     WaitForSingleObject(complete_event, INFINITE);
     /* give worker thread chance to complete */
     Sleep(100);
 
     ret = pUnregisterWait(wait_handle);
-    ok(ret, "UnregisterWait failed with error %d\n", GetLastError());
+    ok(ret, "UnregisterWait failed with error %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pUnregisterWait(NULL);
     ok(!ret, "Expected UnregisterWait to fail\n");
     ok(GetLastError() == ERROR_INVALID_HANDLE,
-       "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
+       "Expected ERROR_INVALID_HANDLE, got %ld\n", GetLastError());
 
     /* test WT_EXECUTEINWAITTHREAD */
 
     SetEvent(handle);
     ret = pRegisterWaitForSingleObject(&wait_handle, handle, signaled_function, complete_event, INFINITE, WT_EXECUTEONLYONCE | WT_EXECUTEINWAITTHREAD);
-    ok(ret, "RegisterWaitForSingleObject failed with error %d\n", GetLastError());
+    ok(ret, "RegisterWaitForSingleObject failed with error %ld\n", GetLastError());
 
     WaitForSingleObject(complete_event, INFINITE);
     /* give worker thread chance to complete */
     Sleep(100);
 
     ret = pUnregisterWait(wait_handle);
-    ok(ret, "UnregisterWait failed with error %d\n", GetLastError());
+    ok(ret, "UnregisterWait failed with error %ld\n", GetLastError());
 
     /* the callback execution should be sequentially consistent with the wait handle return,
        even if the event is already set */
@@ -1498,7 +1498,7 @@ static void test_RegisterWaitForSingleObject(void)
         unregister_param.wait_handle = INVALID_HANDLE_VALUE;
 
         ret = pRegisterWaitForSingleObject(&unregister_param.wait_handle, handle, unregister_function, &unregister_param, INFINITE, WT_EXECUTEONLYONCE | WT_EXECUTEINWAITTHREAD);
-        ok(ret, "RegisterWaitForSingleObject failed with error %d\n", GetLastError());
+        ok(ret, "RegisterWaitForSingleObject failed with error %ld\n", GetLastError());
 
         WaitForSingleObject(complete_event, INFINITE);
     }
@@ -1517,20 +1517,20 @@ static void test_RegisterWaitForSingleObject(void)
 
     ret = pRegisterWaitForSingleObject(&wait_handle2, waitthread_trigger_event, signaled_function, waitthread_wait_event,
                                        INFINITE, WT_EXECUTEONLYONCE | WT_EXECUTEINWAITTHREAD);
-    ok(ret, "RegisterWaitForSingleObject failed with error %d\n", GetLastError());
+    ok(ret, "RegisterWaitForSingleObject failed with error %ld\n", GetLastError());
 
     ret = pRegisterWaitForSingleObject(&wait_handle, handle, waitthread_test_function, &param, INFINITE, WT_EXECUTEONLYONCE | WT_EXECUTEINWAITTHREAD);
-    ok(ret, "RegisterWaitForSingleObject failed with error %d\n", GetLastError());
+    ok(ret, "RegisterWaitForSingleObject failed with error %ld\n", GetLastError());
 
     WaitForSingleObject(complete_event, INFINITE);
     /* give worker thread chance to complete */
     Sleep(100);
 
     ret = pUnregisterWait(wait_handle);
-    ok(ret, "UnregisterWait failed with error %d\n", GetLastError());
+    ok(ret, "UnregisterWait failed with error %ld\n", GetLastError());
 
     ret = pUnregisterWait(wait_handle2);
-    ok(ret, "UnregisterWait failed with error %d\n", GetLastError());
+    ok(ret, "UnregisterWait failed with error %ld\n", GetLastError());
 
     CloseHandle(waitthread_wait_event);
     CloseHandle(waitthread_trigger_event);
@@ -1736,7 +1736,7 @@ static void run_LS_tests(void)
   }
 
   ret = WaitForMultipleObjects(2, threads, TRUE, 60000);
-  ok(ret == WAIT_OBJECT_0 || broken(ret == WAIT_OBJECT_0+1 /* nt4,w2k */), "WaitForAllObjects 2 threads %d\n",ret);
+  ok(ret == WAIT_OBJECT_0 || broken(ret == WAIT_OBJECT_0+1 /* nt4,w2k */), "WaitForAllObjects 2 threads %ld\n",ret);
 
   for (i = 0; i < 2; ++i)
     CloseHandle(threads[i]);
@@ -1809,48 +1809,48 @@ static void test_ThreadErrorMode(void)
     ret = pSetThreadErrorMode(0, &mode);
     ok(ret, "SetThreadErrorMode failed\n");
     ok(mode == oldmode,
-       "SetThreadErrorMode returned old mode 0x%x, expected 0x%x\n",
+       "SetThreadErrorMode returned old mode 0x%lx, expected 0x%lx\n",
        mode, oldmode);
     mode = pGetThreadErrorMode();
-    ok(mode == 0, "GetThreadErrorMode returned mode 0x%x, expected 0\n", mode);
+    ok(mode == 0, "GetThreadErrorMode returned mode 0x%lx, expected 0\n", mode);
     rtlmode = pRtlGetThreadErrorMode();
     ok(rtlmode == 0,
-       "RtlGetThreadErrorMode returned mode 0x%x, expected 0\n", mode);
+       "RtlGetThreadErrorMode returned mode 0x%lx, expected 0\n", mode);
 
     ret = pSetThreadErrorMode(SEM_FAILCRITICALERRORS, &mode);
     ok(ret, "SetThreadErrorMode failed\n");
     ok(mode == 0,
-       "SetThreadErrorMode returned old mode 0x%x, expected 0\n", mode);
+       "SetThreadErrorMode returned old mode 0x%lx, expected 0\n", mode);
     mode = pGetThreadErrorMode();
     ok(mode == SEM_FAILCRITICALERRORS,
-       "GetThreadErrorMode returned mode 0x%x, expected SEM_FAILCRITICALERRORS\n",
+       "GetThreadErrorMode returned mode 0x%lx, expected SEM_FAILCRITICALERRORS\n",
        mode);
     rtlmode = pRtlGetThreadErrorMode();
     ok(rtlmode == 0x10,
-       "RtlGetThreadErrorMode returned mode 0x%x, expected 0x10\n", mode);
+       "RtlGetThreadErrorMode returned mode 0x%lx, expected 0x10\n", mode);
 
     ret = pSetThreadErrorMode(SEM_NOGPFAULTERRORBOX, &mode);
     ok(ret, "SetThreadErrorMode failed\n");
     ok(mode == SEM_FAILCRITICALERRORS,
-       "SetThreadErrorMode returned old mode 0x%x, expected SEM_FAILCRITICALERRORS\n",
+       "SetThreadErrorMode returned old mode 0x%lx, expected SEM_FAILCRITICALERRORS\n",
        mode);
     mode = pGetThreadErrorMode();
     ok(mode == SEM_NOGPFAULTERRORBOX,
-       "GetThreadErrorMode returned mode 0x%x, expected SEM_NOGPFAULTERRORBOX\n",
+       "GetThreadErrorMode returned mode 0x%lx, expected SEM_NOGPFAULTERRORBOX\n",
        mode);
     rtlmode = pRtlGetThreadErrorMode();
     ok(rtlmode == 0x20,
-       "RtlGetThreadErrorMode returned mode 0x%x, expected 0x20\n", mode);
+       "RtlGetThreadErrorMode returned mode 0x%lx, expected 0x20\n", mode);
 
     ret = pSetThreadErrorMode(SEM_NOOPENFILEERRORBOX, NULL);
     ok(ret, "SetThreadErrorMode failed\n");
     mode = pGetThreadErrorMode();
     ok(mode == SEM_NOOPENFILEERRORBOX,
-       "GetThreadErrorMode returned mode 0x%x, expected SEM_NOOPENFILEERRORBOX\n",
+       "GetThreadErrorMode returned mode 0x%lx, expected SEM_NOOPENFILEERRORBOX\n",
        mode);
     rtlmode = pRtlGetThreadErrorMode();
     ok(rtlmode == 0x40,
-       "RtlGetThreadErrorMode returned mode 0x%x, expected 0x40\n", rtlmode);
+       "RtlGetThreadErrorMode returned mode 0x%lx, expected 0x40\n", rtlmode);
 
     for (mode = 1; mode; mode <<= 1)
     {
@@ -1860,17 +1860,17 @@ static void test_ThreadErrorMode(void)
                     SEM_NOOPENFILEERRORBOX))
         {
             ok(ret,
-               "SetThreadErrorMode(0x%x,NULL) failed with error %d\n",
+               "SetThreadErrorMode(0x%lx,NULL) failed with error %ld\n",
                mode, GetLastError());
         }
         else
         {
             DWORD GLE = GetLastError();
             ok(!ret,
-               "SetThreadErrorMode(0x%x,NULL) succeeded, expected failure\n",
+               "SetThreadErrorMode(0x%lx,NULL) succeeded, expected failure\n",
                mode);
             ok(GLE == ERROR_INVALID_PARAMETER,
-               "SetThreadErrorMode(0x%x,NULL) failed with %d, "
+               "SetThreadErrorMode(0x%lx,NULL) failed with %ld, "
                "expected ERROR_INVALID_PARAMETER\n",
                mode, GLE);
         }
@@ -1939,7 +1939,7 @@ static DWORD WINAPI fpu_thread(void *param)
     ctx->fpu_cw = get_fpu_cw();
 
     ret = SetEvent(ctx->finished);
-    ok(ret, "SetEvent failed, last error %#x.\n", GetLastError());
+    ok(ret, "SetEvent failed, last error %#lx.\n", GetLastError());
 
     return 0;
 }
@@ -1951,16 +1951,16 @@ static unsigned int get_thread_fpu_cw( unsigned long *fpu_cw )
     HANDLE thread;
 
     ctx.finished = CreateEventW(NULL, FALSE, FALSE, NULL);
-    ok(!!ctx.finished, "Failed to create event, last error %#x.\n", GetLastError());
+    ok(!!ctx.finished, "Failed to create event, last error %#lx.\n", GetLastError());
 
     thread = CreateThread(NULL, 0, fpu_thread, &ctx, 0, &tid);
-    ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
+    ok(!!thread, "Failed to create thread, last error %#lx.\n", GetLastError());
 
     res = WaitForSingleObject(ctx.finished, 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());
 
     res = CloseHandle(ctx.finished);
-    ok(!!res, "Failed to close event handle, last error %#x.\n", GetLastError());
+    ok(!!res, "Failed to close event handle, last error %#lx.\n", GetLastError());
 
     CloseHandle(thread);
     *fpu_cw = ctx.fpu_cw;
@@ -2078,7 +2078,7 @@ static void create_manifest_file(const char *filename, const char *manifest)
 
     MultiByteToWideChar( CP_ACP, 0, filename, -1, path, MAX_PATH );
     file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
-    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %lu\n", GetLastError());
     WriteFile(file, manifest, strlen(manifest), &size, NULL);
     CloseHandle(file);
 }
@@ -2095,10 +2095,10 @@ static HANDLE test_create(const char *file)
     actctx.lpSource = path;
 
     handle = CreateActCtxW(&actctx);
-    ok(handle != INVALID_HANDLE_VALUE, "failed to create context, error %u\n", GetLastError());
+    ok(handle != INVALID_HANDLE_VALUE, "failed to create context, error %lu\n", GetLastError());
 
-    ok(actctx.cbSize == sizeof(actctx), "cbSize=%d\n", actctx.cbSize);
-    ok(actctx.dwFlags == 0, "dwFlags=%d\n", actctx.dwFlags);
+    ok(actctx.cbSize == sizeof(actctx), "cbSize=%ld\n", actctx.cbSize);
+    ok(actctx.dwFlags == 0, "dwFlags=%ld\n", actctx.dwFlags);
     ok(actctx.lpSource == path, "lpSource=%p\n", actctx.lpSource);
     ok(actctx.wProcessorArchitecture == 0, "wProcessorArchitecture=%d\n", actctx.wProcessorArchitecture);
     ok(actctx.wLangId == 0, "wLangId=%d\n", actctx.wLangId);
@@ -2127,14 +2127,14 @@ static void test_thread_actctx(void)
 
     handle = (void*)0xdeadbeef;
     b = GetCurrentActCtx(&handle);
-    ok(b, "GetCurrentActCtx failed: %u\n", GetLastError());
+    ok(b, "GetCurrentActCtx failed: %lu\n", GetLastError());
     ok(handle == 0, "active context %p\n", handle);
 
     /* without active context */
     param.thread_context = (void*)0xdeadbeef;
     param.handle = NULL;
     thread = CreateThread(NULL, 0, thread_actctx_func, &param, 0, &tid);
-    ok(thread != NULL, "failed, got %u\n", GetLastError());
+    ok(thread != NULL, "failed, got %lu\n", GetLastError());
 
     ret = WaitForSingleObject(thread, 1000);
     ok(ret == WAIT_OBJECT_0, "wait timeout\n");
@@ -2142,21 +2142,21 @@ static void test_thread_actctx(void)
     CloseHandle(thread);
 
     b = ActivateActCtx(context, &cookie);
-    ok(b, "activation failed: %u\n", GetLastError());
+    ok(b, "activation failed: %lu\n", GetLastError());
 
     handle = 0;
     b = GetCurrentActCtx(&handle);
-    ok(b, "GetCurrentActCtx failed: %u\n", GetLastError());
+    ok(b, "GetCurrentActCtx failed: %lu\n", GetLastError());
     ok(handle != 0, "no active context\n");
     ReleaseActCtx(handle);
 
     param.handle = NULL;
     b = GetCurrentActCtx(&param.handle);
-    ok(b && param.handle != NULL, "failed to get context, %u\n", GetLastError());
+    ok(b && param.handle != NULL, "failed to get context, %lu\n", GetLastError());
 
     param.thread_context = (void*)0xdeadbeef;
     thread = CreateThread(NULL, 0, thread_actctx_func, &param, 0, &tid);
-    ok(thread != NULL, "failed, got %u\n", GetLastError());
+    ok(thread != NULL, "failed, got %lu\n", GetLastError());
 
     ret = WaitForSingleObject(thread, 1000);
     ok(ret == WAIT_OBJECT_0, "wait timeout\n");
@@ -2167,7 +2167,7 @@ static void test_thread_actctx(void)
     /* similar test for CreateRemoteThread() */
     param.thread_context = (void*)0xdeadbeef;
     thread = CreateRemoteThread(GetCurrentProcess(), NULL, 0, thread_actctx_func, &param, 0, &tid);
-    ok(thread != NULL, "failed, got %u\n", GetLastError());
+    ok(thread != NULL, "failed, got %lu\n", GetLastError());
 
     ret = WaitForSingleObject(thread, 1000);
     ok(ret == WAIT_OBJECT_0, "wait timeout\n");
@@ -2178,7 +2178,7 @@ static void test_thread_actctx(void)
     ReleaseActCtx(param.handle);
 
     b = DeactivateActCtx(0, cookie);
-    ok(b, "DeactivateActCtx failed: %u\n", GetLastError());
+    ok(b, "DeactivateActCtx failed: %lu\n", GetLastError());
     ReleaseActCtx(context);
 }
 
@@ -2201,7 +2201,7 @@ static void test_threadpool(void)
     }
 
     work = pCreateThreadpoolWork(threadpool_workcallback, &workcalled, NULL);
-    ok (work != NULL, "Error %d in CreateThreadpoolWork\n", GetLastError());
+    ok (work != NULL, "Error %ld in CreateThreadpoolWork\n", GetLastError());
     pSubmitThreadpoolWork(work);
     pWaitForThreadpoolWorkCallbacks(work, FALSE);
     pCloseThreadpoolWork(work);
@@ -2230,7 +2230,7 @@ static void test_reserved_tls(void)
 
     /* Also make sure that there is a TLS allocated. */
     tls = TlsAlloc();
-    ok(tls && tls != TLS_OUT_OF_INDEXES, "tls = %x\n", tls);
+    ok(tls && tls != TLS_OUT_OF_INDEXES, "tls = %lx\n", tls);
     TlsSetValue(tls, (void*)1);
 
     val = TlsGetValue(0);
@@ -2243,7 +2243,7 @@ static void test_reserved_tls(void)
         /* Set TLS index 0 value and see that this works and doesn't cause problems
          * for remaining tests. */
         ret = TlsSetValue(0, (void*)1);
-        ok(ret, "TlsSetValue(0, 1) failed: %u\n", GetLastError());
+        ok(ret, "TlsSetValue(0, 1) failed: %lu\n", GetLastError());
 
         val = TlsGetValue(0);
         ok(val == (void*)1, "TlsGetValue(0) = %p\n", val);
@@ -2323,27 +2323,27 @@ static void test_thread_info(void)
         case ThreadBasicInformation:
         case ThreadAmILastThread:
         case ThreadPriorityBoost:
-            ok(status == STATUS_SUCCESS, "for info %u expected STATUS_SUCCESS, got %08x (ret_len %u)\n", i, status, ret_len);
+            ok(status == STATUS_SUCCESS, "for info %lu expected STATUS_SUCCESS, got %08lx (ret_len %lu)\n", i, status, ret_len);
             break;
 
 #ifdef __i386__
         case ThreadDescriptorTableEntry:
             ok(status == STATUS_SUCCESS || broken(status == STATUS_ACCESS_DENIED) /* testbot VM is broken */,
-               "for info %u expected STATUS_SUCCESS, got %08x (ret_len %u)\n", i, status, ret_len);
+               "for info %lu expected STATUS_SUCCESS, got %08lx (ret_len %lu)\n", i, status, ret_len);
             break;
 #endif
 
         case ThreadTimes:
-            ok(status == STATUS_SUCCESS, "for info %u expected STATUS_SUCCESS, got %08x (ret_len %u)\n", i, status, ret_len);
+            ok(status == STATUS_SUCCESS, "for info %lu expected STATUS_SUCCESS, got %08lx (ret_len %lu)\n", i, status, ret_len);
             break;
 
         case ThreadIsIoPending:
             todo_wine
-            ok(status == STATUS_ACCESS_DENIED, "for info %u expected STATUS_ACCESS_DENIED, got %08x (ret_len %u)\n", i, status, ret_len);
+            ok(status == STATUS_ACCESS_DENIED, "for info %lu expected STATUS_ACCESS_DENIED, got %08lx (ret_len %lu)\n", i, status, ret_len);
             break;
 
         default:
-            ok(status == STATUS_ACCESS_DENIED, "for info %u expected STATUS_ACCESS_DENIED, got %08x (ret_len %u)\n", i, status, ret_len);
+            ok(status == STATUS_ACCESS_DENIED, "for info %lu expected STATUS_ACCESS_DENIED, got %08lx (ret_len %lu)\n", i, status, ret_len);
             break;
         }
     }
@@ -2373,47 +2373,47 @@ static void test_thread_description(void)
     /* Initial description. */
     ptr = NULL;
     hr = pGetThreadDescription(GetCurrentThread(), &ptr);
-    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to get thread description, hr %#x.\n", hr);
+    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to get thread description, hr %#lx.\n", hr);
     ok(!lstrcmpW(ptr, L""), "Unexpected description %s.\n", wine_dbgstr_w(ptr));
     LocalFree(ptr);
 
     len = 0;
     status = pNtQueryInformationThread(GetCurrentThread(), ThreadNameInformation, NULL, 0, &len);
-    ok(status == STATUS_BUFFER_TOO_SMALL, "Unexpected status %#x.\n", status);
-    ok(len == sizeof(*thread_desc), "Unexpected structure length %u.\n", len);
+    ok(status == STATUS_BUFFER_TOO_SMALL, "Unexpected status %#lx.\n", status);
+    ok(len == sizeof(*thread_desc), "Unexpected structure length %lu.\n", len);
 
     len2 = 0;
     thread_desc->ThreadName.Length = 1;
     thread_desc->ThreadName.MaximumLength = 0;
     thread_desc->ThreadName.Buffer = (WCHAR *)thread_desc;
     status = pNtQueryInformationThread(GetCurrentThread(), ThreadNameInformation, thread_desc, len, &len2);
-    ok(!status, "Failed to get thread info, status %#x.\n", status);
-    ok(len2 == sizeof(*thread_desc), "Unexpected structure length %u.\n", len);
+    ok(!status, "Failed to get thread info, status %#lx.\n", status);
+    ok(len2 == sizeof(*thread_desc), "Unexpected structure length %lu.\n", len);
     ok(!thread_desc->ThreadName.Length, "Unexpected description length %#x.\n", thread_desc->ThreadName.Length);
     ok(thread_desc->ThreadName.Buffer == (WCHAR *)(thread_desc + 1),
             "Unexpected description string pointer %p, %p.\n", thread_desc->ThreadName.Buffer, thread_desc);
 
     hr = pSetThreadDescription(GetCurrentThread(), NULL);
-    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to set thread description, hr %#x.\n", hr);
+    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to set thread description, hr %#lx.\n", hr);
 
     hr = pSetThreadDescription(GetCurrentThread(), desc);
-    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to set thread description, hr %#x.\n", hr);
+    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to set thread description, hr %#lx.\n", hr);
 
     ptr = NULL;
     hr = pGetThreadDescription(GetCurrentThread(), &ptr);
-    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to get thread description, hr %#x.\n", hr);
+    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to get thread description, hr %#lx.\n", hr);
     ok(!lstrcmpW(ptr, desc), "Unexpected description %s.\n", wine_dbgstr_w(ptr));
     LocalFree(ptr);
 
     len = 0;
     status = pNtQueryInformationThread(GetCurrentThread(), ThreadNameInformation, NULL, 0, &len);
-    ok(status == STATUS_BUFFER_TOO_SMALL, "Failed to get thread info, status %#x.\n", status);
-    ok(len == sizeof(*thread_desc) + desc_len, "Unexpected structure length %u.\n", len);
+    ok(status == STATUS_BUFFER_TOO_SMALL, "Failed to get thread info, status %#lx.\n", status);
+    ok(len == sizeof(*thread_desc) + desc_len, "Unexpected structure length %lu.\n", len);
 
     len = 0;
     status = pNtQueryInformationThread(GetCurrentThread(), ThreadNameInformation, buff, sizeof(buff), &len);
     ok(!status, "Failed to get thread info.\n");
-    ok(len == sizeof(*thread_desc) + desc_len, "Unexpected structure length %u.\n", len);
+    ok(len == sizeof(*thread_desc) + desc_len, "Unexpected structure length %lu.\n", len);
 
     ok(thread_desc->ThreadName.Length == desc_len && thread_desc->ThreadName.MaximumLength == desc_len,
             "Unexpected description length %u.\n", thread_desc->ThreadName.Length);
@@ -2424,56 +2424,56 @@ static void test_thread_description(void)
     /* Partial results. */
     len = 0;
     status = pNtQueryInformationThread(GetCurrentThread(), ThreadNameInformation, NULL, 0, &len);
-    ok(status == STATUS_BUFFER_TOO_SMALL, "Unexpected status %#x.\n", status);
-    ok(len == sizeof(*thread_desc) + desc_len, "Unexpected structure length %u.\n", len);
+    ok(status == STATUS_BUFFER_TOO_SMALL, "Unexpected status %#lx.\n", status);
+    ok(len == sizeof(*thread_desc) + desc_len, "Unexpected structure length %lu.\n", len);
 
     status = pNtQueryInformationThread(GetCurrentThread(), ThreadNameInformation, buff, len - sizeof(WCHAR), &len);
-    ok(status == STATUS_BUFFER_TOO_SMALL, "Unexpected status %#x.\n", status);
-    ok(len == sizeof(*thread_desc) + desc_len, "Unexpected structure length %u.\n", len);
+    ok(status == STATUS_BUFFER_TOO_SMALL, "Unexpected status %#lx.\n", status);
+    ok(len == sizeof(*thread_desc) + desc_len, "Unexpected structure length %lu.\n", len);
 
     /* Change description. */
     thread_desc->ThreadName.Length = thread_desc->ThreadName.MaximumLength = 8;
     lstrcpyW((WCHAR *)(thread_desc + 1), L"desc");
 
     status = pNtSetInformationThread(GetCurrentThread(), ThreadNameInformation, thread_desc, sizeof(*thread_desc));
-    ok(status == STATUS_SUCCESS, "Failed to set thread description, status %#x.\n", status);
+    ok(status == STATUS_SUCCESS, "Failed to set thread description, status %#lx.\n", status);
 
     ptr = NULL;
     hr = pGetThreadDescription(GetCurrentThread(), &ptr);
-    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to get thread description, hr %#x.\n", hr);
+    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to get thread description, hr %#lx.\n", hr);
     ok(!lstrcmpW(ptr, L"desc"), "Unexpected description %s.\n", wine_dbgstr_w(ptr));
     LocalFree(ptr);
 
     status = pNtSetInformationThread(GetCurrentThread(), ThreadNameInformation, thread_desc, sizeof(*thread_desc) - 1);
-    ok(status == STATUS_INFO_LENGTH_MISMATCH, "Unexpected status %#x.\n", status);
+    ok(status == STATUS_INFO_LENGTH_MISMATCH, "Unexpected status %#lx.\n", status);
 
     status = NtSetInformationThread(GetCurrentThread(), ThreadNameInformation, NULL, sizeof(*thread_desc));
-    ok(status == STATUS_ACCESS_VIOLATION, "Unexpected status %#x.\n", status);
+    ok(status == STATUS_ACCESS_VIOLATION, "Unexpected status %#lx.\n", status);
 
     thread_desc->ThreadName.Buffer = NULL;
     status = pNtSetInformationThread(GetCurrentThread(), ThreadNameInformation, thread_desc, sizeof(*thread_desc));
-    ok(status == STATUS_ACCESS_VIOLATION, "Unexpected status %#x.\n", status);
+    ok(status == STATUS_ACCESS_VIOLATION, "Unexpected status %#lx.\n", status);
 
     hr = pSetThreadDescription(GetCurrentThread(), NULL);
-    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to set thread description, hr %#x.\n", hr);
+    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to set thread description, hr %#lx.\n", hr);
 
     ptr = NULL;
     hr = pGetThreadDescription(GetCurrentThread(), &ptr);
-    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to get thread description, hr %#x.\n", hr);
+    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to get thread description, hr %#lx.\n", hr);
     ok(!lstrcmpW(ptr, L""), "Unexpected description %s.\n", wine_dbgstr_w(ptr));
     LocalFree(ptr);
 
     /* Set with 0 length/NULL pointer. */
     hr = pSetThreadDescription(GetCurrentThread(), L"123");
-    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to set thread description, hr %#x.\n", hr);
+    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to set thread description, hr %#lx.\n", hr);
 
     memset(thread_desc, 0, sizeof(*thread_desc));
     status = pNtSetInformationThread(GetCurrentThread(), ThreadNameInformation, thread_desc, sizeof(*thread_desc));
-    ok(!status, "Failed to set thread description, status %#x.\n", status);
+    ok(!status, "Failed to set thread description, status %#lx.\n", status);
 
     ptr = NULL;
     hr = pGetThreadDescription(GetCurrentThread(), &ptr);
-    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to get thread description, hr %#x.\n", hr);
+    ok(hr == HRESULT_FROM_NT(STATUS_SUCCESS), "Failed to get thread description, hr %#lx.\n", hr);
     ok(!lstrcmpW(ptr, L""), "Unexpected description %s.\n", wine_dbgstr_w(ptr));
     LocalFree(ptr);
 }
@@ -2552,7 +2552,7 @@ START_TEST(thread)
            HANDLE hThread;
            DWORD tid;
            hThread = CreateThread(NULL, 0, threadFunc2, NULL, 0, &tid);
-           ok(hThread != NULL, "CreateThread failed, error %u\n",
+           ok(hThread != NULL, "CreateThread failed, error %lu\n",
               GetLastError());
            ok(WaitForSingleObject(hThread, 200) == WAIT_OBJECT_0,
               "Thread did not exit in time\n");
diff --git a/dlls/kernel32/tests/time.c b/dlls/kernel32/tests/time.c
index 0ae272311bb..b1e14b1b8c4 100644
--- a/dlls/kernel32/tests/time.c
+++ b/dlls/kernel32/tests/time.c
@@ -122,14 +122,14 @@ static void test_conversions(void)
     SETUP_ZEROTIME(st)
     ok (SystemTimeToFileTime(&st, &ft), "Conversion failed ZERO_TIME\n");
     ok( (!((ft.dwHighDateTime != 0) || (ft.dwLowDateTime != 0))),
-        "Wrong time for ATIME: %08x %08x (correct %08x %08x)\n",
+        "Wrong time for ATIME: %08lx %08lx (correct %08x %08x)\n",
         ft.dwLowDateTime, ft.dwHighDateTime, 0, 0);
 
 
     SETUP_ATIME(st)
     ok (SystemTimeToFileTime(&st,&ft), "Conversion Failed ATIME\n");
     ok( (!((ft.dwHighDateTime != ATIME_HI) || (ft.dwLowDateTime!=ATIME_LOW))),
-        "Wrong time for ATIME: %08x %08x (correct %08x %08x)\n",
+        "Wrong time for ATIME: %08lx %08lx (correct %08x %08x)\n",
         ft.dwLowDateTime, ft.dwHighDateTime, ATIME_LOW, ATIME_HI);
 
 
@@ -138,7 +138,7 @@ static void test_conversions(void)
 
     ok( (!((ft.dwHighDateTime != MAYDAY_2002_HI) ||
          (ft.dwLowDateTime!=MAYDAY_2002_LO))),
-        "Wrong time for 2002 %08x %08x (correct %08x %08x)\n", ft.dwLowDateTime,
+        "Wrong time for 2002 %08lx %08lx (correct %08x %08x)\n", ft.dwLowDateTime,
         ft.dwHighDateTime, MAYDAY_2002_LO, MAYDAY_2002_HI);
 
 
@@ -147,7 +147,7 @@ static void test_conversions(void)
 
     ok( (!((ft.dwHighDateTime!=NEWYEAR_1980_HI) ||
         (ft.dwLowDateTime!=NEWYEAR_1980_LO))) ,
-        "Wrong time for 1980 %08x %08x (correct %08x %08x)\n", ft.dwLowDateTime,
+        "Wrong time for 1980 %08lx %08lx (correct %08x %08x)\n", ft.dwLowDateTime,
          ft.dwHighDateTime, NEWYEAR_1980_LO,NEWYEAR_1980_HI  );
 
     ok(DosDateTimeToFileTime(DOS_DATE(1980,1,1),DOS_TIME(0,0,0),&ft),
@@ -155,7 +155,7 @@ static void test_conversions(void)
 
     ok( (!((ft.dwHighDateTime!=NEWYEAR_1980_HI) ||
          (ft.dwLowDateTime!=NEWYEAR_1980_LO))),
-        "Wrong time DosDateTimeToFileTime %08x %08x (correct %08x %08x)\n",
+        "Wrong time DosDateTimeToFileTime %08lx %08lx (correct %08x %08x)\n",
         ft.dwHighDateTime, ft.dwLowDateTime, NEWYEAR_1980_HI, NEWYEAR_1980_LO);
 
 }
@@ -173,7 +173,7 @@ static void test_invalid_arg(void)
         "DosDateTimeToFileTime() failed\n");
 
     ok( (ft.dwHighDateTime==NEWYEAR_1980_HI) && (ft.dwLowDateTime==NEWYEAR_1980_LO),
-        "filetime for 1/1/80 00:00:00 was %08x %08x\n", ft.dwHighDateTime, ft.dwLowDateTime);
+        "filetime for 1/1/80 00:00:00 was %08lx %08lx\n", ft.dwHighDateTime, ft.dwLowDateTime);
 
     /* now check SystemTimeToFileTime */
     memset(&ft,0,sizeof ft);
@@ -206,7 +206,7 @@ static LONGLONG system_time_to_minutes(const SYSTEMTIME *st)
 
     SetLastError(0xdeadbeef);
     ret = SystemTimeToFileTime(st, &ft);
-    ok(ret, "SystemTimeToFileTime error %u\n", GetLastError());
+    ok(ret, "SystemTimeToFileTime error %lu\n", GetLastError());
 
     minutes = ((LONGLONG)ft.dwHighDateTime << 32) + ft.dwLowDateTime;
     minutes /= (LONGLONG)600000000; /* convert to minutes */
@@ -226,7 +226,7 @@ static LONG get_tz_bias(const TIME_ZONE_INFORMATION *tzinfo, DWORD tz_id)
         return tzinfo->StandardBias;
 
     default:
-        trace("unknown time zone id %d\n", tz_id);
+        trace("unknown time zone id %ld\n", tz_id);
         /* fall through */
     case TIME_ZONE_ID_UNKNOWN:
         return 0;
@@ -249,19 +249,19 @@ static void test_GetTimeZoneInformation(void)
 
     SetLastError(0xdeadbeef);
     res = SystemTimeToFileTime(&st, &s_ft);
-    ok(res, "SystemTimeToFileTime error %u\n", GetLastError());
+    ok(res, "SystemTimeToFileTime error %lu\n", GetLastError());
     SetLastError(0xdeadbeef);
     res = FileTimeToLocalFileTime(&s_ft, &l_ft);
-    ok(res, "FileTimeToLocalFileTime error %u\n", GetLastError());
+    ok(res, "FileTimeToLocalFileTime error %lu\n", GetLastError());
     SetLastError(0xdeadbeef);
     res = FileTimeToSystemTime(&l_ft, &local);
-    ok(res, "FileTimeToSystemTime error %u\n", GetLastError());
+    ok(res, "FileTimeToSystemTime error %lu\n", GetLastError());
     l_time = system_time_to_minutes(&local);
 
     tz_id = GetTimeZoneInformation(&tzinfo);
     ok(tz_id != TIME_ZONE_ID_INVALID, "GetTimeZoneInformation failed\n");
 
-    trace("tz_id %u (%s)\n", tz_id,
+    trace("tz_id %lu (%s)\n", tz_id,
           tz_id == TIME_ZONE_ID_DAYLIGHT ? "TIME_ZONE_ID_DAYLIGHT" :
           (tz_id == TIME_ZONE_ID_STANDARD ? "TIME_ZONE_ID_STANDARD" :
           (tz_id == TIME_ZONE_ID_UNKNOWN ? "TIME_ZONE_ID_UNKNOWN" :
@@ -269,14 +269,14 @@ static void test_GetTimeZoneInformation(void)
 
     WideCharToMultiByte(CP_ACP, 0, tzinfo.StandardName, -1, std_name, sizeof(std_name), NULL, NULL);
     WideCharToMultiByte(CP_ACP, 0, tzinfo.DaylightName, -1, dlt_name, sizeof(dlt_name), NULL, NULL);
-    trace("bias %d, %s - %s\n", tzinfo.Bias, std_name, dlt_name);
-    trace("standard (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n",
+    trace("bias %ld, %s - %s\n", tzinfo.Bias, std_name, dlt_name);
+    trace("standard (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %ld\n",
         tzinfo.StandardDate.wDay, tzinfo.StandardDate.wMonth,
         tzinfo.StandardDate.wYear, tzinfo.StandardDate.wDayOfWeek,
         tzinfo.StandardDate.wHour, tzinfo.StandardDate.wMinute,
         tzinfo.StandardDate.wSecond, tzinfo.StandardDate.wMilliseconds,
         tzinfo.StandardBias);
-    trace("daylight (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n",
+    trace("daylight (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %ld\n",
         tzinfo.DaylightDate.wDay, tzinfo.DaylightDate.wMonth,
         tzinfo.DaylightDate.wYear, tzinfo.DaylightDate.wDayOfWeek,
         tzinfo.DaylightDate.wHour, tzinfo.DaylightDate.wMinute,
@@ -285,7 +285,7 @@ static void test_GetTimeZoneInformation(void)
 
     diff = (LONG)(s_time - l_time);
     ok(diff == tzinfo.Bias + get_tz_bias(&tzinfo, tz_id),
-       "system/local diff %d != tz bias %d\n",
+       "system/local diff %ld != tz bias %ld\n",
        diff, tzinfo.Bias + get_tz_bias(&tzinfo, tz_id));
 
     ok(SetEnvironmentVariableA("TZ","GMT0") != 0,
@@ -317,16 +317,16 @@ static void test_GetTimeZoneInformation(void)
         return;
     }
 
-    ok(res, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
+    ok(res, "SystemTimeToTzSpecificLocalTime error %lu\n", GetLastError());
     s_time = system_time_to_minutes(&current);
 
     tzinfo.StandardBias -= 123;
     tzinfo.DaylightBias += 456;
 
     res = pSystemTimeToTzSpecificLocalTime(&tzinfo, &utc, &local);
-    ok(res, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
+    ok(res, "SystemTimeToTzSpecificLocalTime error %lu\n", GetLastError());
     l_time = system_time_to_minutes(&local);
-    ok(l_time - s_time == diff - get_tz_bias(&tzinfo, tz_id), "got %d, expected %d\n",
+    ok(l_time - s_time == diff - get_tz_bias(&tzinfo, tz_id), "got %ld, expected %ld\n",
        (LONG)(l_time - s_time), diff - get_tz_bias(&tzinfo, tz_id));
 
     /* pretend that there is no transition dates */
@@ -338,9 +338,9 @@ static void test_GetTimeZoneInformation(void)
     tzinfo.StandardDate.wYear = 0;
 
     res = pSystemTimeToTzSpecificLocalTime(&tzinfo, &utc, &local);
-    ok(res, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
+    ok(res, "SystemTimeToTzSpecificLocalTime error %lu\n", GetLastError());
     l_time = system_time_to_minutes(&local);
-    ok(l_time - s_time == diff, "got %d, expected %d\n",
+    ok(l_time - s_time == diff, "got %ld, expected %ld\n",
        (LONG)(l_time - s_time), diff);
 
     /* test 23:01, 31st of December date */
@@ -361,7 +361,7 @@ static void test_GetTimeZoneInformation(void)
     utc.wHour = 23;
     utc.wMinute = 1;
     res = pSystemTimeToTzSpecificLocalTime(&tzinfo, &utc, &local);
-    ok(res, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
+    ok(res, "SystemTimeToTzSpecificLocalTime error %lu\n", GetLastError());
     ok(local.wYear==2012 && local.wMonth==12 && local.wDay==31 && local.wHour==23 && local.wMinute==1,
             "got (%d-%d-%d %02d:%02d), expected (2012-12-31 23:01)\n",
             local.wYear, local.wMonth, local.wDay, local.wHour, local.wMinute);
@@ -378,7 +378,7 @@ static void test_FileTimeToSystemTime(void)
     ft.dwLowDateTime  = 0;
     ret = FileTimeToSystemTime(&ft, &st);
     ok( ret,
-       "FileTimeToSystemTime() failed with Error %d\n",GetLastError());
+       "FileTimeToSystemTime() failed with Error %ld\n",GetLastError());
     ok(((st.wYear == 1601) && (st.wMonth  == 1) && (st.wDay    == 1) &&
 	(st.wHour ==    0) && (st.wMinute == 0) && (st.wSecond == 0) &&
 	(st.wMilliseconds == 0)),
@@ -388,7 +388,7 @@ static void test_FileTimeToSystemTime(void)
     ft.dwLowDateTime  = (UINT)time;
     ret = FileTimeToSystemTime(&ft, &st);
     ok( ret,
-       "FileTimeToSystemTime() failed with Error %d\n",GetLastError());
+       "FileTimeToSystemTime() failed with Error %ld\n",GetLastError());
     ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
 	(st.wHour ==    0) && (st.wMinute == 0) && (st.wSecond == 1) &&
 	(st.wMilliseconds == 0)),
@@ -415,7 +415,7 @@ static void test_FileTimeToLocalFileTime(void)
     ft.dwLowDateTime  = (UINT)time;
     ret = FileTimeToLocalFileTime(&ft, &lft);
     ok( ret,
-       "FileTimeToLocalFileTime() failed with Error %d\n",GetLastError());
+       "FileTimeToLocalFileTime() failed with Error %ld\n",GetLastError());
     FileTimeToSystemTime(&lft, &st);
     ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
 	(st.wHour ==    0) && (st.wMinute == 0) && (st.wSecond == 1) &&
@@ -429,7 +429,7 @@ static void test_FileTimeToLocalFileTime(void)
     ok(res != TIME_ZONE_ID_INVALID, "GetTimeZoneInformation failed\n");
     ret = FileTimeToLocalFileTime(&ft, &lft);
     ok( ret,
-       "FileTimeToLocalFileTime() failed with Error %d\n",GetLastError());
+       "FileTimeToLocalFileTime() failed with Error %ld\n",GetLastError());
     FileTimeToSystemTime(&lft, &st);
     ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
 	(st.wHour ==    0) && (st.wMinute == 0) && (st.wSecond == 1) &&
@@ -647,25 +647,25 @@ static void test_FileTimeToDosDateTime(void)
     ret = FileTimeToDosDateTime(&ft, NULL, NULL);
     ok(!ret, "expected failure\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+       "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = FileTimeToDosDateTime(&ft, &fatdate, NULL);
     ok(!ret, "expected failure\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+       "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = FileTimeToDosDateTime(&ft, NULL, &fattime);
     ok(!ret, "expected failure\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+       "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = FileTimeToDosDateTime(&ft, &fatdate, &fattime);
     ok(!ret, "expected failure\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+       "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 }
 
 static void test_GetCalendarInfo(void)
@@ -683,57 +683,57 @@ static void test_GetCalendarInfo(void)
 
     ret = pGetCalendarInfoA( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER,
                              NULL, 0, &val1 );
-    ok( ret, "GetCalendarInfoA failed err %u\n", GetLastError() );
+    ok( ret, "GetCalendarInfoA failed err %lu\n", GetLastError() );
     ok( ret == sizeof(val1), "wrong size %u\n", ret );
-    ok( val1 >= 2000 && val1 < 2100, "wrong value %u\n", val1 );
+    ok( val1 >= 2000 && val1 < 2100, "wrong value %lu\n", val1 );
 
     ret = pGetCalendarInfoW( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER,
                              NULL, 0, &val2 );
-    ok( ret, "GetCalendarInfoW failed err %u\n", GetLastError() );
+    ok( ret, "GetCalendarInfoW failed err %lu\n", GetLastError() );
     ok( ret == sizeof(val2)/sizeof(WCHAR), "wrong size %u\n", ret );
-    ok( val1 == val2, "A/W mismatch %u/%u\n", val1, val2 );
+    ok( val1 == val2, "A/W mismatch %lu/%lu\n", val1, val2 );
 
     ret = pGetCalendarInfoA( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX, bufferA, sizeof(bufferA), NULL );
-    ok( ret, "GetCalendarInfoA failed err %u\n", GetLastError() );
+    ok( ret, "GetCalendarInfoA failed err %lu\n", GetLastError() );
     ok( ret == 5, "wrong size %u\n", ret );
-    ok( atoi( bufferA ) == val1, "wrong value %s/%u\n", bufferA, val1 );
+    ok( atoi( bufferA ) == val1, "wrong value %s/%lu\n", bufferA, val1 );
 
     ret = pGetCalendarInfoW( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX, bufferW, ARRAY_SIZE(bufferW), NULL );
-    ok( ret, "GetCalendarInfoW failed err %u\n", GetLastError() );
+    ok( ret, "GetCalendarInfoW failed err %lu\n", GetLastError() );
     ok( ret == 5, "wrong size %u\n", ret );
     memset( bufferA, 0x55, sizeof(bufferA) );
     WideCharToMultiByte( CP_ACP, 0, bufferW, -1, bufferA, sizeof(bufferA), NULL, NULL );
-    ok( atoi( bufferA ) == val1, "wrong value %s/%u\n", bufferA, val1 );
+    ok( atoi( bufferA ) == val1, "wrong value %s/%lu\n", bufferA, val1 );
 
     ret = pGetCalendarInfoA( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER,
                              NULL, 0, NULL );
     ok( !ret, "GetCalendarInfoA succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     ret = pGetCalendarInfoA( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX, NULL, 0, NULL );
-    ok( ret, "GetCalendarInfoA failed err %u\n", GetLastError() );
+    ok( ret, "GetCalendarInfoA failed err %lu\n", GetLastError() );
     ok( ret == 5, "wrong size %u\n", ret );
 
     ret = pGetCalendarInfoW( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER,
                              NULL, 0, NULL );
     ok( !ret, "GetCalendarInfoW succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     ret = pGetCalendarInfoW( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX, NULL, 0, NULL );
-    ok( ret, "GetCalendarInfoW failed err %u\n", GetLastError() );
+    ok( ret, "GetCalendarInfoW failed err %lu\n", GetLastError() );
     ok( ret == 5, "wrong size %u\n", ret );
 
     ret = pGetCalendarInfoA( LANG_SYSTEM_DEFAULT, CAL_GREGORIAN, CAL_SDAYNAME1,
                              bufferA, sizeof(bufferA), NULL);
-    ok( ret, "GetCalendarInfoA failed err %u\n", GetLastError() );
+    ok( ret, "GetCalendarInfoA failed err %lu\n", GetLastError() );
     ret2 = pGetCalendarInfoA( LANG_SYSTEM_DEFAULT, CAL_GREGORIAN, CAL_SDAYNAME1,
                               bufferA, 0, NULL);
-    ok( ret2, "GetCalendarInfoA failed err %u\n", GetLastError() );
+    ok( ret2, "GetCalendarInfoA failed err %lu\n", GetLastError() );
     ok( ret == ret2, "got %d, expected %d\n", ret2, ret );
 
     ret2 = pGetCalendarInfoW( LANG_SYSTEM_DEFAULT, CAL_GREGORIAN, CAL_SDAYNAME1,
                               bufferW, ARRAY_SIZE(bufferW), NULL);
-    ok( ret2, "GetCalendarInfoW failed err %u\n", GetLastError() );
+    ok( ret2, "GetCalendarInfoW failed err %lu\n", GetLastError() );
     ret2 = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
     ok( ret == ret2, "got %d, expected %d\n", ret, ret2 );
 }
@@ -752,13 +752,13 @@ static void test_GetDynamicTimeZoneInformation(void)
 
     ret = pGetDynamicTimeZoneInformation(&dyninfo);
     ret2 = GetTimeZoneInformation(&tzinfo);
-    ok(ret == ret2, "got %d, %d\n", ret, ret2);
+    ok(ret == ret2, "got %ld, %ld\n", ret, ret2);
 
-    ok(dyninfo.Bias == tzinfo.Bias, "got %d, %d\n", dyninfo.Bias, tzinfo.Bias);
+    ok(dyninfo.Bias == tzinfo.Bias, "got %ld, %ld\n", dyninfo.Bias, tzinfo.Bias);
     ok(!lstrcmpW(dyninfo.StandardName, tzinfo.StandardName), "got std name %s, %s\n",
         wine_dbgstr_w(dyninfo.StandardName), wine_dbgstr_w(tzinfo.StandardName));
     ok(!memcmp(&dyninfo.StandardDate, &tzinfo.StandardDate, sizeof(dyninfo.StandardDate)), "got different StandardDate\n");
-    ok(dyninfo.StandardBias == tzinfo.StandardBias, "got %d, %d\n", dyninfo.StandardBias, tzinfo.StandardBias);
+    ok(dyninfo.StandardBias == tzinfo.StandardBias, "got %ld, %ld\n", dyninfo.StandardBias, tzinfo.StandardBias);
     ok(!lstrcmpW(dyninfo.DaylightName, tzinfo.DaylightName), "got daylight name %s, %s\n",
         wine_dbgstr_w(dyninfo.DaylightName), wine_dbgstr_w(tzinfo.DaylightName));
     ok(!memcmp(&dyninfo.DaylightDate, &tzinfo.DaylightDate, sizeof(dyninfo.DaylightDate)), "got different DaylightDate\n");
@@ -856,7 +856,7 @@ static void test_GetSystemTimes(void)
 
     ok( !NtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), &ReturnLength),
                                   "NtQuerySystemInformation failed\n" );
-    ok( sizeof(sbi) == ReturnLength, "Inconsistent length %d\n", ReturnLength );
+    ok( sizeof(sbi) == ReturnLength, "Inconsistent length %ld\n", ReturnLength );
 
     /* Check if we have some return values */
     trace( "Number of Processors : %d\n", sbi.NumberOfProcessors );
@@ -972,30 +972,30 @@ static void test_GetTimeZoneInformationForYear(void)
     GetTimeZoneInformation(&local_tzinfo);
 
     ret = pGetTimeZoneInformationForYear(systemtime.wYear, NULL, &tzinfo);
-    ok(ret == TRUE, "GetTimeZoneInformationForYear failed, err %u\n", GetLastError());
-    ok(tzinfo.Bias == local_tzinfo.Bias, "Expected Bias %d, got %d\n", local_tzinfo.Bias, tzinfo.Bias);
+    ok(ret == TRUE, "GetTimeZoneInformationForYear failed, err %lu\n", GetLastError());
+    ok(tzinfo.Bias == local_tzinfo.Bias, "Expected Bias %ld, got %ld\n", local_tzinfo.Bias, tzinfo.Bias);
     ok(!lstrcmpW(tzinfo.StandardName, local_tzinfo.StandardName),
         "Expected StandardName %s, got %s\n", wine_dbgstr_w(local_tzinfo.StandardName), wine_dbgstr_w(tzinfo.StandardName));
     ok(!memcmp(&tzinfo.StandardDate, &local_tzinfo.StandardDate, sizeof(SYSTEMTIME)), "StandardDate does not match\n");
-    ok(tzinfo.StandardBias == local_tzinfo.StandardBias, "Expected StandardBias %d, got %d\n", local_tzinfo.StandardBias, tzinfo.StandardBias);
+    ok(tzinfo.StandardBias == local_tzinfo.StandardBias, "Expected StandardBias %ld, got %ld\n", local_tzinfo.StandardBias, tzinfo.StandardBias);
     ok(!lstrcmpW(tzinfo.DaylightName, local_tzinfo.DaylightName),
         "Expected DaylightName %s, got %s\n", wine_dbgstr_w(local_tzinfo.DaylightName), wine_dbgstr_w(tzinfo.DaylightName));
     ok(!memcmp(&tzinfo.DaylightDate, &local_tzinfo.DaylightDate, sizeof(SYSTEMTIME)), "DaylightDate does not match\n");
-    ok(tzinfo.DaylightBias == local_tzinfo.DaylightBias, "Expected DaylightBias %d, got %d\n", local_tzinfo.DaylightBias, tzinfo.DaylightBias);
+    ok(tzinfo.DaylightBias == local_tzinfo.DaylightBias, "Expected DaylightBias %ld, got %ld\n", local_tzinfo.DaylightBias, tzinfo.DaylightBias);
 
     pGetDynamicTimeZoneInformation(&dyn_tzinfo);
 
     ret = pGetTimeZoneInformationForYear(systemtime.wYear, &dyn_tzinfo, &tzinfo);
-    ok(ret == TRUE, "GetTimeZoneInformationForYear failed, err %u\n", GetLastError());
-    ok(tzinfo.Bias == local_tzinfo.Bias, "Expected Bias %d, got %d\n", local_tzinfo.Bias, tzinfo.Bias);
+    ok(ret == TRUE, "GetTimeZoneInformationForYear failed, err %lu\n", GetLastError());
+    ok(tzinfo.Bias == local_tzinfo.Bias, "Expected Bias %ld, got %ld\n", local_tzinfo.Bias, tzinfo.Bias);
     ok(!lstrcmpW(tzinfo.StandardName, local_tzinfo.StandardName),
         "Expected StandardName %s, got %s\n", wine_dbgstr_w(local_tzinfo.StandardName), wine_dbgstr_w(tzinfo.StandardName));
     ok(!memcmp(&tzinfo.StandardDate, &local_tzinfo.StandardDate, sizeof(SYSTEMTIME)), "StandardDate does not match\n");
-    ok(tzinfo.StandardBias == local_tzinfo.StandardBias, "Expected StandardBias %d, got %d\n", local_tzinfo.StandardBias, tzinfo.StandardBias);
+    ok(tzinfo.StandardBias == local_tzinfo.StandardBias, "Expected StandardBias %ld, got %ld\n", local_tzinfo.StandardBias, tzinfo.StandardBias);
     ok(!lstrcmpW(tzinfo.DaylightName, local_tzinfo.DaylightName),
         "Expected DaylightName %s, got %s\n", wine_dbgstr_w(local_tzinfo.DaylightName), wine_dbgstr_w(tzinfo.DaylightName));
     ok(!memcmp(&tzinfo.DaylightDate, &local_tzinfo.DaylightDate, sizeof(SYSTEMTIME)), "DaylightDate does not match\n");
-    ok(tzinfo.DaylightBias == local_tzinfo.DaylightBias, "Expected DaylightBias %d, got %d\n", local_tzinfo.DaylightBias, tzinfo.DaylightBias);
+    ok(tzinfo.DaylightBias == local_tzinfo.DaylightBias, "Expected DaylightBias %ld, got %ld\n", local_tzinfo.DaylightBias, tzinfo.DaylightBias);
 
     memset(&dyn_tzinfo, 0xaa, sizeof(dyn_tzinfo));
     lstrcpyW(dyn_tzinfo.TimeZoneKeyName, L"Greenland Daylight Time");
@@ -1005,7 +1005,7 @@ static void test_GetTimeZoneInformationForYear(void)
         broken_test = TRUE;
     ok((ret == FALSE && GetLastError() == ERROR_FILE_NOT_FOUND) ||
         broken(broken_test) /* vista,7 */,
-        "GetTimeZoneInformationForYear err %u\n", GetLastError());
+        "GetTimeZoneInformationForYear err %lu\n", GetLastError());
 
     memset(&dyn_tzinfo, 0xaa, sizeof(dyn_tzinfo));
     lstrcpyW(dyn_tzinfo.TimeZoneKeyName, L"Altai Standard Time");
@@ -1014,7 +1014,7 @@ static void test_GetTimeZoneInformationForYear(void)
     if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND)
         broken_test = TRUE;
     ok(ret == TRUE || broken(broken_test) /* before 10 1809 */,
-        "GetTimeZoneInformationForYear err %u\n", GetLastError());
+        "GetTimeZoneInformationForYear err %lu\n", GetLastError());
 
     if (broken(broken_test))
     {
@@ -1031,11 +1031,11 @@ static void test_GetTimeZoneInformationForYear(void)
 
         ret = pGetTimeZoneInformationForYear(test_data[i].year, &dyn_tzinfo, &tzinfo);
         todo_wine_if(test_data[i].tzinfo_todo)
-            ok(ret == TRUE, "GetTimeZoneInformationForYear failed, err %u, for %s\n", GetLastError(), wine_dbgstr_w(test_data[i].tzname));
+            ok(ret == TRUE, "GetTimeZoneInformationForYear failed, err %lu, for %s\n", GetLastError(), wine_dbgstr_w(test_data[i].tzname));
         if (!ret)
             continue;
         todo_wine_if(test_data[i].bias_todo)
-            ok(tzinfo.Bias == test_data[i].bias, "Expected bias %d, got %d, for %s\n",
+            ok(tzinfo.Bias == test_data[i].bias, "Expected bias %ld, got %ld, for %s\n",
                 test_data[i].bias, tzinfo.Bias, wine_dbgstr_w(test_data[i].tzname));
         todo_wine_if(test_data[i].std_month_todo)
             ok(tzinfo.StandardDate.wMonth == test_data[i].std_month, "Expected standard month %d, got %d, for %s\n",
@@ -1045,7 +1045,7 @@ static void test_GetTimeZoneInformationForYear(void)
             ok(std_day == test_data[i].std_day, "Expected standard day %d, got %d, for %s\n",
                 test_data[i].std_day, std_day, wine_dbgstr_w(test_data[i].tzname));
         todo_wine_if(test_data[i].std_bias_todo)
-            ok(tzinfo.StandardBias == test_data[i].std_bias, "Expected standard bias %d, got %d, for %s\n",
+            ok(tzinfo.StandardBias == test_data[i].std_bias, "Expected standard bias %ld, got %ld, for %s\n",
                 test_data[i].std_bias, tzinfo.StandardBias, wine_dbgstr_w(test_data[i].tzname));
         todo_wine_if(test_data[i].dlt_month_todo)
             ok(tzinfo.DaylightDate.wMonth == test_data[i].dlt_month, "Expected daylight month %d, got %d, for %s\n",
@@ -1055,7 +1055,7 @@ static void test_GetTimeZoneInformationForYear(void)
             ok(dlt_day == test_data[i].dlt_day, "Expected daylight day %d, got %d, for %s\n",
                 test_data[i].dlt_day, dlt_day, wine_dbgstr_w(test_data[i].tzname));
         todo_wine_if(test_data[i].dlt_bias_todo)
-            ok(tzinfo.DaylightBias == test_data[i].dlt_bias, "Expected daylight bias %d, got %d, for %s\n",
+            ok(tzinfo.DaylightBias == test_data[i].dlt_bias, "Expected daylight bias %ld, got %ld, for %s\n",
                 test_data[i].dlt_bias, tzinfo.DaylightBias, wine_dbgstr_w(test_data[i].tzname));
 
         if (i > 0 && test_data[i-1].tzname == test_data[i].tzname)
@@ -1090,8 +1090,8 @@ static void test_GetTickCount(void)
         t3 = pNtGetTickCount();
     } while(t3 < t1 && i++ < 1); /* allow for wrap, but only once */
 
-    ok(t1 <= t2, "out of order %d %d\n", t1, t2);
-    ok(t2 <= t3, "out of order %d %d\n", t2, t3);
+    ok(t1 <= t2, "out of order %ld %ld\n", t1, t2);
+    ok(t2 <= t3, "out of order %ld %ld\n", t2, t3);
 }
 
 BOOL (WINAPI *pQueryUnbiasedInterruptTime)(ULONGLONG *time);
@@ -1106,22 +1106,22 @@ static void test_QueryUnbiasedInterruptTime(void)
     {
         SetLastError( 0xdeadbeef );
         ret = pQueryUnbiasedInterruptTime( &time );
-        ok( ret, "QueryUnbiasedInterruptTime failed err %u\n", GetLastError() );
+        ok( ret, "QueryUnbiasedInterruptTime failed err %lu\n", GetLastError() );
         SetLastError( 0xdeadbeef );
         ret = pQueryUnbiasedInterruptTime( NULL );
         ok( !ret, "QueryUnbiasedInterruptTime succeeded\n" );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
     }
     else win_skip( "QueryUnbiasedInterruptTime not supported\n" );
     if (pRtlQueryUnbiasedInterruptTime)
     {
         SetLastError( 0xdeadbeef );
         ret = pRtlQueryUnbiasedInterruptTime( &time );
-        ok( ret, "RtlQueryUnbiasedInterruptTime failed err %u\n", GetLastError() );
+        ok( ret, "RtlQueryUnbiasedInterruptTime failed err %lu\n", GetLastError() );
         SetLastError( 0xdeadbeef );
         ret = pRtlQueryUnbiasedInterruptTime( NULL );
         ok( !ret, "RtlQueryUnbiasedInterruptTime succeeded\n" );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
     }
     else win_skip( "RtlQueryUnbiasedInterruptTime not supported\n" );
 }
diff --git a/dlls/kernel32/tests/timer.c b/dlls/kernel32/tests/timer.c
index 156f1acd7f1..47cfd11062e 100644
--- a/dlls/kernel32/tests/timer.c
+++ b/dlls/kernel32/tests/timer.c
@@ -79,10 +79,10 @@ static DWORD WINAPI thread_WaitForSingleObject(void *arg)
     ok(event != NULL, "CreateEvent failed\n");
     t = GetTickCount();
     r = WaitForSingleObject(event, 3000);
-    ok(r == WAIT_TIMEOUT, "WiatForSingleObject returned %x\n", r);
+    ok(r == WAIT_TIMEOUT, "WiatForSingleObject returned %lx\n", r);
     CloseHandle(event);
     t = GetTickCount() - t;
-    ok(t > 2000, "t = %d\n", t);
+    ok(t > 2000, "t = %ld\n", t);
     return 0;
 }
 
@@ -92,7 +92,7 @@ static DWORD WINAPI thread_Sleep(void *arg)
 
     Sleep(3000);
     t = GetTickCount() - t;
-    ok(t > 2000, "t = %d\n", t);
+    ok(t > 2000, "t = %ld\n", t);
     return 0;
 }
 
@@ -102,7 +102,7 @@ static DWORD WINAPI thread_SleepEx(void *arg)
 
     SleepEx(3000, TRUE);
     t = GetTickCount() - t;
-    ok(t > 2000, "t = %d\n", t);
+    ok(t > 2000, "t = %ld\n", t);
     return 0;
 }
 
@@ -122,10 +122,10 @@ static DWORD WINAPI thread_WaitableTimer_rel(void *arg)
     ok(r, "SetWaitableTimer failed\n");
 
     r = WaitForSingleObject(timer, INFINITE);
-    ok(r == WAIT_OBJECT_0, "WaitForSingleObject returned %d\n", r);
+    ok(r == WAIT_OBJECT_0, "WaitForSingleObject returned %ld\n", r);
     CloseHandle(timer);
     t = GetTickCount() - t;
-    ok(t > 2000, "t = %d\n", t);
+    ok(t > 2000, "t = %ld\n", t);
     return 0;
 }
 
@@ -149,10 +149,10 @@ static DWORD WINAPI thread_WaitableTimer_abs(void *arg)
     ok(r, "SetWaitableTimer failed\n");
 
     r = WaitForSingleObject(timer, INFINITE);
-    ok(r == WAIT_OBJECT_0, "WaitForSingleObject returned %d\n", r);
+    ok(r == WAIT_OBJECT_0, "WaitForSingleObject returned %ld\n", r);
     CloseHandle(timer);
     t = GetTickCount() - t;
-    ok(t < 2000, "t = %d\n", t);
+    ok(t < 2000, "t = %ld\n", t);
     return 0;
 }
 
@@ -172,13 +172,13 @@ static DWORD WINAPI thread_WaitableTimer_period(void *arg)
     ok(r, "SetWaitableTimer failed\n");
 
     r = WaitForSingleObject(timer, INFINITE);
-    ok(r == WAIT_OBJECT_0, "WaitForSingleObject returned %d\n", r);
+    ok(r == WAIT_OBJECT_0, "WaitForSingleObject returned %ld\n", r);
 
     r = WaitForSingleObject(timer, INFINITE);
-    ok(r == WAIT_OBJECT_0, "WaitForSingleObject returned %d\n", r);
+    ok(r == WAIT_OBJECT_0, "WaitForSingleObject returned %ld\n", r);
     CloseHandle(timer);
     t = GetTickCount() - t;
-    ok(t > 2000, "t = %d\n", t);
+    ok(t > 2000, "t = %ld\n", t);
     return 0;
 }
 
@@ -189,7 +189,7 @@ static DWORD WINAPI thread_SetTimer(void *arg)
     MSG msg;
 
     timer = SetTimer(NULL, 0, 3000, NULL);
-    ok(timer, "SetTimer failed (%d)\n", GetLastError());
+    ok(timer, "SetTimer failed (%ld)\n", GetLastError());
 
     while (GetMessageW(&msg, NULL, 0, 0))
     {
@@ -198,7 +198,7 @@ static DWORD WINAPI thread_SetTimer(void *arg)
     }
 
     t = GetTickCount() - t;
-    ok(t > 2000, "t = %d\n", t);
+    ok(t > 2000, "t = %ld\n", t);
     KillTimer(NULL, timer);
     return 0;
 }
@@ -210,7 +210,7 @@ static void test_timeouts(void)
 
     if (!adjust_system_time(1))
     {
-        skip("can't adjust system clock (%d)\n", GetLastError());
+        skip("can't adjust system clock (%ld)\n", GetLastError());
         return;
     }
 
diff --git a/dlls/kernel32/tests/toolhelp.c b/dlls/kernel32/tests/toolhelp.c
index 3bc07ec84f3..70ca23c4b20 100644
--- a/dlls/kernel32/tests/toolhelp.c
+++ b/dlls/kernel32/tests/toolhelp.c
@@ -124,7 +124,7 @@ static void test_process(DWORD curr_pid, DWORD sub_pcs_pid)
         {
             if (pe.th32ProcessID == curr_pid) found++;
             if (pe.th32ProcessID == sub_pcs_pid) { childpos = num; found++; }
-            trace("PID=%x %s\n", pe.th32ProcessID, pe.szExeFile);
+            trace("PID=%lx %s\n", pe.th32ProcessID, pe.szExeFile);
             num++;
         } while (pProcess32Next( hSnapshot, &pe ));
     }
@@ -138,7 +138,7 @@ static void test_process(DWORD curr_pid, DWORD sub_pcs_pid)
         {
             if (pe.th32ProcessID == curr_pid) found++;
             if (pe.th32ProcessID == sub_pcs_pid) found++;
-            trace("PID=%x %s\n", pe.th32ProcessID, pe.szExeFile);
+            trace("PID=%lx %s\n", pe.th32ProcessID, pe.szExeFile);
             num--;
         } while (pProcess32Next( hSnapshot, &pe ));
     }
@@ -237,7 +237,7 @@ static DWORD WINAPI get_id_thread(void* curr_pid)
         free(pcs_buffer);
         pcs_buffer = malloc(buf_size);
     }
-    ok(status == STATUS_SUCCESS, "got %#x\n", status);
+    ok(status == STATUS_SUCCESS, "got %#lx\n", status);
     found = FALSE;
     matched_idx = -1;
 
@@ -332,7 +332,7 @@ static void test_thread(DWORD curr_pid, DWORD sub_pcs_pid)
             if (te.th32OwnerProcessID == curr_pid) curr_found++;
             if (te.th32OwnerProcessID == sub_pcs_pid) sub_found++;
             if (winetest_debug > 1)
-                trace("PID=%x TID=%x %d\n", te.th32OwnerProcessID, te.th32ThreadID, te.tpBasePri);
+                trace("PID=%lx TID=%lx %ld\n", te.th32OwnerProcessID, te.th32ThreadID, te.tpBasePri);
             num++;
         } while (pThread32Next( hSnapshot, &te ));
     }
@@ -349,7 +349,7 @@ static void test_thread(DWORD curr_pid, DWORD sub_pcs_pid)
             if (te.th32OwnerProcessID == curr_pid) curr_found++;
             if (te.th32OwnerProcessID == sub_pcs_pid) sub_found++;
             if (winetest_debug > 1)
-                trace("PID=%x TID=%x %d\n", te.th32OwnerProcessID, te.th32ThreadID, te.tpBasePri);
+                trace("PID=%lx TID=%lx %ld\n", te.th32OwnerProcessID, te.th32ThreadID, te.tpBasePri);
             num--;
         } while (pThread32Next( hSnapshot, &te ));
     }
@@ -399,7 +399,7 @@ static void test_module(DWORD pid, const char* expected[], unsigned num_expected
     {
         do
         {
-            trace("PID=%x base=%p size=%x %s %s\n",
+            trace("PID=%lx base=%p size=%lx %s %s\n",
                   me.th32ProcessID, me.modBaseAddr, me.modBaseSize, me.szExePath, me.szModule);
             ok(me.th32ProcessID == pid, "wrong returned process id\n");
             for (i = 0; i < num_expected; i++)
@@ -418,7 +418,7 @@ static void test_module(DWORD pid, const char* expected[], unsigned num_expected
     {
         do
         {
-            trace("PID=%x base=%p size=%x %s %s\n",
+            trace("PID=%lx base=%p size=%lx %s %s\n",
                   me.th32ProcessID, me.modBaseAddr, me.modBaseSize, me.szExePath, me.szModule);
             for (i = 0; i < num_expected; i++)
                 if (!lstrcmpiA(expected[i], me.szModule)) found[i]++;
@@ -489,7 +489,7 @@ START_TEST(toolhelp)
     startup.dwFlags = STARTF_USESHOWWINDOW;
     startup.wShowWindow = SW_SHOWNORMAL;
 
-    sprintf(buffer, "%s toolhelp %lu %lu", selfname, (DWORD_PTR)ev1, (DWORD_PTR)ev2);
+    sprintf(buffer, "%s toolhelp %Iu %Iu", selfname, (DWORD_PTR)ev1, (DWORD_PTR)ev2);
     ok(CreateProcessA(NULL, buffer, NULL, NULL, TRUE, 0, NULL, NULL, &startup, &info), "CreateProcess\n");
     /* wait for child to be initialized */
     w = WaitForSingleObject(ev1, WAIT_TIME);
diff --git a/dlls/kernel32/tests/version.c b/dlls/kernel32/tests/version.c
index ec74c920960..1c280d2b2eb 100644
--- a/dlls/kernel32/tests/version.c
+++ b/dlls/kernel32/tests/version.c
@@ -93,10 +93,10 @@ static void test_GetProductInfo(void)
 
         if (entry[0] >= 6)
             ok(res && (product > PRODUCT_UNDEFINED) && (product <= PRODUCT_ENTERPRISE_S_N_EVALUATION),
-               "got %d and 0x%x (expected TRUE and a valid PRODUCT_* value)\n", res, product);
+               "got %ld and 0x%lx (expected TRUE and a valid PRODUCT_* value)\n", res, product);
         else
             ok(!res && !product && (GetLastError() == 0xdeadbeef),
-               "got %d and 0x%x with 0x%x (expected FALSE and PRODUCT_UNDEFINED with LastError untouched)\n",
+               "got %ld and 0x%lx with 0x%lx (expected FALSE and PRODUCT_UNDEFINED with LastError untouched)\n",
                res, product, GetLastError());
 
         entry+= 4;
@@ -106,7 +106,7 @@ static void test_GetProductInfo(void)
     SetLastError(0xdeadbeef);
     res = pGetProductInfo(6, 1, 0, 0, NULL);
     ok( (!res) && (GetLastError() == 0xdeadbeef),
-        "got %d with 0x%x (expected FALSE with LastError untouched\n", res, GetLastError());
+        "got %ld with 0x%lx (expected FALSE with LastError untouched\n", res, GetLastError());
 }
 
 static void test_GetVersionEx(void)
@@ -127,7 +127,7 @@ static void test_GetVersionEx(void)
     ok(!ret, "Expected GetVersionExA to fail\n");
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
         GetLastError() == 0xdeadbeef /* Win9x */,
-        "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %d\n",
+        "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %ld\n",
         GetLastError());
 
     SetLastError(0xdeadbeef);
@@ -136,7 +136,7 @@ static void test_GetVersionEx(void)
     ok(!ret, "Expected GetVersionExA to fail\n");
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
         GetLastError() == 0xdeadbeef /* Win9x */,
-        "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %d\n",
+        "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %ld\n",
         GetLastError());
 
     SetLastError(0xdeadbeef);
@@ -145,7 +145,7 @@ static void test_GetVersionEx(void)
     ok(!ret, "Expected GetVersionExA to fail\n");
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
         GetLastError() == 0xdeadbeef /* Win9x */,
-        "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %d\n",
+        "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %ld\n",
         GetLastError());
 
     SetLastError(0xdeadbeef);
@@ -153,7 +153,7 @@ static void test_GetVersionEx(void)
     ret = GetVersionExA(&infoA);
     ok(ret, "Expected GetVersionExA to succeed\n");
     ok(GetLastError() == 0xdeadbeef,
-        "Expected 0xdeadbeef, got %d\n", GetLastError());
+        "Expected 0xdeadbeef, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     infoExA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
@@ -665,7 +665,7 @@ static void test_VerifyVersionInfo(void)
         ret = VerifyVersionInfoA(&info, test->verifymask, mask);
         ok(test->err ? !ret : ret, "%u: unexpected return value %d.\n", i, ret);
         if (!ret)
-            ok(GetLastError() == test->err, "%u: unexpected error code %d, expected %d.\n", i, GetLastError(), test->err);
+            ok(GetLastError() == test->err, "%u: unexpected error code %ld, expected %ld.\n", i, GetLastError(), test->err);
     }
 
     /* test handling of version numbers */
@@ -676,21 +676,21 @@ static void test_VerifyVersionInfo(void)
     ret = VerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
         VerSetConditionMask(VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
             VER_MAJORVERSION, VER_GREATER_EQUAL));
-    ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
+    ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
 
     info.dwMinorVersion = 0;
     info.wServicePackMajor = 10;
     ret = VerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
         VerSetConditionMask(VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
             VER_MAJORVERSION, VER_GREATER_EQUAL));
-    ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
+    ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
 
     info.wServicePackMajor = 0;
     info.wServicePackMinor = 10;
     ret = VerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
         VerSetConditionMask(VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
             VER_MAJORVERSION, VER_GREATER_EQUAL));
-    ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
+    ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
 
     /* test bad dwOSVersionInfoSize */
     info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
@@ -698,7 +698,7 @@ static void test_VerifyVersionInfo(void)
     info.dwOSVersionInfoSize = 0;
     ret = VerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
         VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL));
-    ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
+    ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
 }
 
 static void test_GetSystemFirmwareTable(void)
@@ -733,11 +733,11 @@ static void test_GetSystemFirmwareTable(void)
 
     expected_len -= min_sfti_len;
     len = pGetSystemFirmwareTable(RSMB, 0, NULL, 0);
-    ok(len == expected_len, "Expected length %u, got %u\n", expected_len, len);
+    ok(len == expected_len, "Expected length %lu, got %u\n", expected_len, len);
 
     smbios_table = HeapAlloc(GetProcessHeap(), 0, expected_len);
     len = pGetSystemFirmwareTable(RSMB, 0, smbios_table, expected_len);
-    ok(len == expected_len, "Expected length %u, got %u\n", expected_len, len);
+    ok(len == expected_len, "Expected length %lu, got %u\n", expected_len, len);
     ok(len == 0 || !memcmp(smbios_table, sfti->TableBuffer, 6),
        "Expected prologue %02x %02x %02x %02x %02x %02x, got %02x %02x %02x %02x %02x %02x\n",
        sfti->TableBuffer[0], sfti->TableBuffer[1], sfti->TableBuffer[2],
@@ -826,7 +826,7 @@ static void test_PackageIdFromFullName(void)
     expected_size = get_package_id_size(&test_package_id);
     size = sizeof(id_buffer);
     ret = pPackageIdFromFullName(fullname, 0, &size, id_buffer);
-    ok(ret == ERROR_SUCCESS, "Got unexpected ret %u.\n", ret);
+    ok(ret == ERROR_SUCCESS, "Got unexpected ret %lu.\n", ret);
     ok(size == expected_size, "Got unexpected length %u, expected %u.\n", size, expected_size);
     ok(!lstrcmpW(id->name, test_package_id.name), "Got unexpected name %s.\n", debugstr_w(id->name));
     ok(!lstrcmpW(id->resourceId, test_package_id.resourceId), "Got unexpected resourceId %s.\n",
@@ -845,31 +845,31 @@ static void test_PackageIdFromFullName(void)
             "Got unexpected publisherId %p, buffer %p.\n", id->resourceId, id_buffer);
 
     ret = pPackageIdFromFullName(fullname, 0, NULL, id_buffer);
-    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %d.\n", ret);
+    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %ld.\n", ret);
 
     size = sizeof(id_buffer);
     ret = pPackageIdFromFullName(NULL, 0, &size, id_buffer);
-    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %d.\n", ret);
+    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %ld.\n", ret);
     ok(size == sizeof(id_buffer), "Got unexpected size %u.\n", size);
 
     size = sizeof(id_buffer);
     ret = pPackageIdFromFullName(fullname, 0, &size, NULL);
-    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %d.\n", ret);
+    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %ld.\n", ret);
     ok(size == sizeof(id_buffer), "Got unexpected size %u.\n", size);
 
     size = expected_size - 1;
     ret = pPackageIdFromFullName(fullname, 0, &size, NULL);
-    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %d.\n", ret);
+    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %ld.\n", ret);
     ok(size == expected_size - 1, "Got unexpected size %u.\n", size);
 
     size = expected_size - 1;
     ret = pPackageIdFromFullName(fullname, 0, &size, id_buffer);
-    ok(ret == ERROR_INSUFFICIENT_BUFFER, "Got unexpected ret %d.\n", ret);
+    ok(ret == ERROR_INSUFFICIENT_BUFFER, "Got unexpected ret %ld.\n", ret);
     ok(size == expected_size, "Got unexpected size %u.\n", size);
 
     size = 0;
     ret = pPackageIdFromFullName(fullname, 0, &size, NULL);
-    ok(ret == ERROR_INSUFFICIENT_BUFFER, "Got unexpected ret %d.\n", ret);
+    ok(ret == ERROR_INSUFFICIENT_BUFFER, "Got unexpected ret %ld.\n", ret);
     ok(size == expected_size, "Got unexpected size %u.\n", size);
 
     for (i = 0; i < ARRAY_SIZE(arch_data); ++i)
@@ -880,7 +880,7 @@ static void test_PackageIdFromFullName(void)
         size = expected_size;
         ret = pPackageIdFromFullName(fullname, 0, &size, id_buffer);
         ok(ret == ERROR_SUCCESS || broken(arch_data[i].broken && ret == ERROR_INVALID_PARAMETER),
-                "Got unexpected ret %u.\n", ret);
+                "Got unexpected ret %lu.\n", ret);
         if (ret != ERROR_SUCCESS)
             continue;
         ok(size == expected_size, "Got unexpected length %u, expected %u.\n", size, expected_size);
@@ -890,32 +890,32 @@ static void test_PackageIdFromFullName(void)
 
     size = sizeof(id_buffer);
     ret = pPackageIdFromFullName(L"TestPackage_1.2.3.4_X86_TestResourceId_0abcdefghjkme", 0, &size, id_buffer);
-    ok(ret == ERROR_SUCCESS, "Got unexpected ret %u.\n", ret);
+    ok(ret == ERROR_SUCCESS, "Got unexpected ret %lu.\n", ret);
 
     size = sizeof(id_buffer);
     ret = pPackageIdFromFullName(L"TestPackage_1.2.3.4_X86_TestResourceId_abcdefghjkme", 0, &size, id_buffer);
-    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %u.\n", ret);
+    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %lu.\n", ret);
 
     size = sizeof(id_buffer);
     ret = pPackageIdFromFullName(L"TestPackage_1.2.3.4_X86_TestResourceId_0abcdefghjkmee", 0, &size, id_buffer);
-    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %u.\n", ret);
+    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %lu.\n", ret);
 
     size = sizeof(id_buffer);
     ret = pPackageIdFromFullName(L"TestPackage_1.2.3_X86_TestResourceId_0abcdefghjkme", 0, &size, id_buffer);
-    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %u.\n", ret);
+    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %lu.\n", ret);
 
     size = sizeof(id_buffer);
     ret = pPackageIdFromFullName(L"TestPackage_1.2.3.4_X86_TestResourceId_0abcdefghjkme_", 0, &size, id_buffer);
-    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %u.\n", ret);
+    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %lu.\n", ret);
 
     size = sizeof(id_buffer);
     ret = pPackageIdFromFullName(L"TestPackage_1.2.3.4_X86__0abcdefghjkme", 0, &size, id_buffer);
-    ok(ret == ERROR_SUCCESS, "Got unexpected ret %u.\n", ret);
+    ok(ret == ERROR_SUCCESS, "Got unexpected ret %lu.\n", ret);
     ok(!lstrcmpW(id->resourceId, L""), "Got unexpected resourceId %s.\n", debugstr_w(id->resourceId));
 
     size = sizeof(id_buffer);
     ret = pPackageIdFromFullName(L"TestPackage_1.2.3.4_X86_0abcdefghjkme", 0, &size, id_buffer);
-    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %u.\n", ret);
+    ok(ret == ERROR_INVALID_PARAMETER, "Got unexpected ret %lu.\n", ret);
 }
 
 #define TEST_VERSION_WIN7   1
@@ -951,12 +951,12 @@ static void test_pe_os_version_child(unsigned int test)
 
     info.dwOSVersionInfoSize = sizeof(info);
     ret = GetVersionExA((OSVERSIONINFOA *)&info);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
     ok(info.dwMajorVersion == test_pe_os_version_tests[test].expected_major,
-            "Test %u, expected major version %u, got %u.\n", test, test_pe_os_version_tests[test].expected_major,
+            "Test %u, expected major version %u, got %lu.\n", test, test_pe_os_version_tests[test].expected_major,
             info.dwMajorVersion);
     ok(info.dwMinorVersion == test_pe_os_version_tests[test].expected_minor,
-            "Test %u, expected minor version %u, got %u.\n", test, test_pe_os_version_tests[test].expected_minor,
+            "Test %u, expected minor version %u, got %lu.\n", test, test_pe_os_version_tests[test].expected_minor,
             info.dwMinorVersion);
 }
 
@@ -1003,12 +1003,12 @@ static void test_pe_os_version(void)
     ok(!pRtlGetVersion(&rtlinfo), "RtlGetVersion failed.\n");
     if (rtlinfo.dwMajorVersion < 10)
     {
-        skip("Too old Windows version %u.%u, skipping tests.\n", rtlinfo.dwMajorVersion, rtlinfo.dwMinorVersion);
+        skip("Too old Windows version %lu.%lu, skipping tests.\n", rtlinfo.dwMajorVersion, rtlinfo.dwMinorVersion);
         return;
     }
 
     file = CreateFileA(argv[0], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
-    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed, GetLastError() %u.\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed, GetLastError() %lu.\n", GetLastError());
     SetFilePointer(file, 0x3c, NULL, FILE_BEGIN);
     ReadFile(file, &hdr_offset, sizeof(hdr_offset), &size, NULL);
     CloseHandle(file);
@@ -1024,10 +1024,10 @@ static void test_pe_os_version(void)
     {
         sprintf(tmp_exe_name, "tmp%u.exe", i);
         ret = CopyFileA(argv[0], tmp_exe_name, FALSE);
-        ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+        ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
         file = CreateFileA(tmp_exe_name, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
-        ok(file != INVALID_HANDLE_VALUE, "CreateFile failed, GetLastError() %u.\n", GetLastError());
+        ok(file != INVALID_HANDLE_VALUE, "CreateFile failed, GetLastError() %lu.\n", GetLastError());
 
         SetFilePointer(file, offset_major, NULL, FILE_BEGIN);
         WriteFile(file, &test_pe_os_version_tests[i].pe_version_major,
@@ -1040,7 +1040,7 @@ static void test_pe_os_version(void)
 
         sprintf(str, "%s.manifest", tmp_exe_name);
         file = CreateFileA(str, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
-        ok(file != INVALID_HANDLE_VALUE, "CreateFile failed, GetLastError() %u.\n", GetLastError());
+        ok(file != INVALID_HANDLE_VALUE, "CreateFile failed, GetLastError() %lu.\n", GetLastError());
 
         WriteFile(file, manifest_header, strlen(manifest_header), &size, NULL);
         for (j = 0; j < ARRAY_SIZE(version_guids); ++j)
@@ -1058,13 +1058,13 @@ static void test_pe_os_version(void)
         sprintf(str, "%s version pe_os_version %u", tmp_exe_name, i);
 
         ret = CreateProcessA(NULL, str, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-        ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+        ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
         CloseHandle(pi.hThread);
         result = WaitForSingleObject(pi.hProcess, 10000);
-        ok(result == WAIT_OBJECT_0, "Got unexpected result %#x.\n", result);
+        ok(result == WAIT_OBJECT_0, "Got unexpected result %#lx.\n", result);
 
         ret = GetExitCodeProcess(pi.hProcess, &code);
-        ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+        ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
         ok(!code, "Test %u failed.\n", i);
 
         CloseHandle(pi.hProcess);
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c
index a3b2d365c33..365194b9065 100644
--- a/dlls/kernel32/tests/virtual.c
+++ b/dlls/kernel32/tests/virtual.c
@@ -66,9 +66,9 @@ static HANDLE create_target_process(const char *arg)
     winetest_get_mainargs( &argv );
     sprintf(cmdline, "%s %s %s", argv[0], argv[1], arg);
     ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-    ok(ret, "error: %u\n", GetLastError());
+    ok(ret, "error: %lu\n", GetLastError());
     ret = CloseHandle(pi.hThread);
-    ok(ret, "error %u\n", GetLastError());
+    ok(ret, "error %lu\n", GetLastError());
     return pi.hProcess;
 }
 
@@ -89,7 +89,7 @@ static void test_VirtualAllocEx(void)
     SetLastError(0xdeadbeef);
     addr1 = VirtualAllocEx(hProcess, NULL, alloc_size, MEM_COMMIT,
                            PAGE_EXECUTE_READWRITE);
-    ok(addr1 != NULL, "VirtualAllocEx error %u\n", GetLastError());
+    ok(addr1 != NULL, "VirtualAllocEx error %lu\n", GetLastError());
 
     src = VirtualAlloc( NULL, alloc_size, MEM_COMMIT, PAGE_READWRITE );
     dst = VirtualAlloc( NULL, alloc_size, MEM_COMMIT, PAGE_READWRITE );
@@ -97,48 +97,48 @@ static void test_VirtualAllocEx(void)
         src[i] = i & 0xff;
 
     b = WriteProcessMemory(hProcess, addr1, src, alloc_size, &bytes_written);
-    ok(b && (bytes_written == alloc_size), "%lu bytes written\n",
+    ok(b && (bytes_written == alloc_size), "%Iu bytes written\n",
        bytes_written);
     b = ReadProcessMemory(hProcess, addr1, dst, alloc_size, &bytes_read);
-    ok(b && (bytes_read == alloc_size), "%lu bytes read\n", bytes_read);
+    ok(b && (bytes_read == alloc_size), "%Iu bytes read\n", bytes_read);
     ok(!memcmp(src, dst, alloc_size), "Data from remote process differs\n");
 
     /* test invalid source buffers */
 
     b = VirtualProtect( src + 0x2000, 0x2000, PAGE_NOACCESS, &old_prot );
-    ok( b, "VirtualProtect failed error %u\n", GetLastError() );
+    ok( b, "VirtualProtect failed error %lu\n", GetLastError() );
     b = WriteProcessMemory(hProcess, addr1, src, alloc_size, &bytes_written);
     ok( !b, "WriteProcessMemory succeeded\n" );
     ok( GetLastError() == ERROR_NOACCESS ||
         GetLastError() == ERROR_PARTIAL_COPY, /* vista */
-        "wrong error %u\n", GetLastError() );
-    ok( bytes_written == 0, "%lu bytes written\n", bytes_written );
+        "wrong error %lu\n", GetLastError() );
+    ok( bytes_written == 0, "%Iu bytes written\n", bytes_written );
     b = ReadProcessMemory(hProcess, addr1, src, alloc_size, &bytes_read);
     ok( !b, "ReadProcessMemory succeeded\n" );
     ok( GetLastError() == ERROR_NOACCESS ||
         GetLastError() == ERROR_PARTIAL_COPY, /* win10 v1607+ */
-        "wrong error %u\n", GetLastError() );
+        "wrong error %lu\n", GetLastError() );
     if (GetLastError() == ERROR_NOACCESS)
-        ok( bytes_read == 0, "%lu bytes written\n", bytes_read );
+        ok( bytes_read == 0, "%Iu bytes written\n", bytes_read );
 
     b = VirtualProtect( src, 0x2000, PAGE_NOACCESS, &old_prot );
-    ok( b, "VirtualProtect failed error %u\n", GetLastError() );
+    ok( b, "VirtualProtect failed error %lu\n", GetLastError() );
     b = WriteProcessMemory(hProcess, addr1, src, alloc_size, &bytes_written);
     ok( !b, "WriteProcessMemory succeeded\n" );
     ok( GetLastError() == ERROR_NOACCESS ||
         GetLastError() == ERROR_PARTIAL_COPY, /* vista */
-        "wrong error %u\n", GetLastError() );
-    ok( bytes_written == 0, "%lu bytes written\n", bytes_written );
+        "wrong error %lu\n", GetLastError() );
+    ok( bytes_written == 0, "%Iu bytes written\n", bytes_written );
     b = ReadProcessMemory(hProcess, addr1, src, alloc_size, &bytes_read);
     ok( !b, "ReadProcessMemory succeeded\n" );
     ok( GetLastError() == ERROR_NOACCESS ||
         GetLastError() == ERROR_PARTIAL_COPY, /* win10 v1607+ */
-        "wrong error %u\n", GetLastError() );
+        "wrong error %lu\n", GetLastError() );
     if (GetLastError() == ERROR_NOACCESS)
-        ok( bytes_read == 0, "%lu bytes written\n", bytes_read );
+        ok( bytes_read == 0, "%Iu bytes written\n", bytes_read );
 
     b = VirtualFreeEx(hProcess, addr1, 0, MEM_RELEASE);
-    ok(b != 0, "VirtualFreeEx, error %u\n", GetLastError());
+    ok(b != 0, "VirtualFreeEx, error %lu\n", GetLastError());
 
     VirtualFree( src, 0, MEM_RELEASE );
     VirtualFree( dst, 0, MEM_RELEASE );
@@ -151,7 +151,7 @@ static void test_VirtualAllocEx(void)
     addr1 = VirtualAllocEx(hProcess, 0, 0, MEM_RESERVE, PAGE_NOACCESS);
     ok(addr1 == NULL, "VirtualAllocEx should fail on zero-sized allocation\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-       "got %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
+       "got %lu, expected ERROR_INVALID_PARAMETER\n", GetLastError());
 
     addr1 = VirtualAllocEx(hProcess, 0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
     ok(addr1 != NULL, "VirtualAllocEx failed\n");
@@ -161,17 +161,17 @@ static void test_VirtualAllocEx(void)
     ok(VirtualQueryEx(hProcess, addr1, &info, sizeof(info)) == sizeof(info), "VirtualQueryEx failed\n");
     ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
     ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
-    ok(info.AllocationProtect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.AllocationProtect);
-    ok(info.RegionSize == 0x10000, "%lx != 0x10000\n", info.RegionSize);
-    ok(info.State == MEM_RESERVE, "%x != MEM_RESERVE\n", info.State);
-    ok(info.Protect == 0, "%x != PAGE_NOACCESS\n", info.Protect);
-    ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
+    ok(info.AllocationProtect == PAGE_NOACCESS, "%lx != PAGE_NOACCESS\n", info.AllocationProtect);
+    ok(info.RegionSize == 0x10000, "%Ix != 0x10000\n", info.RegionSize);
+    ok(info.State == MEM_RESERVE, "%lx != MEM_RESERVE\n", info.State);
+    ok(info.Protect == 0, "%lx != PAGE_NOACCESS\n", info.Protect);
+    ok(info.Type == MEM_PRIVATE, "%lx != MEM_PRIVATE\n", info.Type);
 
     SetLastError(0xdeadbeef);
     ok(!VirtualProtectEx(hProcess, addr1, 0xFFFC, PAGE_READONLY, &old_prot),
        "VirtualProtectEx should fail on a not committed memory\n");
     ok(GetLastError() == ERROR_INVALID_ADDRESS,
-        "got %u, expected ERROR_INVALID_ADDRESS\n", GetLastError());
+        "got %lu, expected ERROR_INVALID_ADDRESS\n", GetLastError());
 
     addr2 = VirtualAllocEx(hProcess, addr1, 0x1000, MEM_COMMIT, PAGE_NOACCESS);
     ok(addr1 == addr2, "VirtualAllocEx failed\n");
@@ -181,32 +181,32 @@ static void test_VirtualAllocEx(void)
         "VirtualQueryEx failed\n");
     ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
     ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
-    ok(info.AllocationProtect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.AllocationProtect);
-    ok(info.RegionSize == 0x1000, "%lx != 0x1000\n", info.RegionSize);
-    ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
+    ok(info.AllocationProtect == PAGE_NOACCESS, "%lx != PAGE_NOACCESS\n", info.AllocationProtect);
+    ok(info.RegionSize == 0x1000, "%Ix != 0x1000\n", info.RegionSize);
+    ok(info.State == MEM_COMMIT, "%lx != MEM_COMMIT\n", info.State);
     /* this time NT reports PAGE_NOACCESS as well */
-    ok(info.Protect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.Protect);
-    ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
+    ok(info.Protect == PAGE_NOACCESS, "%lx != PAGE_NOACCESS\n", info.Protect);
+    ok(info.Type == MEM_PRIVATE, "%lx != MEM_PRIVATE\n", info.Type);
 
     /* this should fail, since not the whole range is committed yet */
     SetLastError(0xdeadbeef);
     ok(!VirtualProtectEx(hProcess, addr1, 0xFFFC, PAGE_READONLY, &old_prot),
         "VirtualProtectEx should fail on a not committed memory\n");
     ok(GetLastError() == ERROR_INVALID_ADDRESS,
-       "got %u, expected ERROR_INVALID_ADDRESS\n", GetLastError());
+       "got %lu, expected ERROR_INVALID_ADDRESS\n", GetLastError());
 
     old_prot = 0;
     ok(VirtualProtectEx(hProcess, addr1, 0x1000, PAGE_READONLY, &old_prot), "VirtualProtectEx failed\n");
-    ok(old_prot == PAGE_NOACCESS, "wrong old protection: got %04x instead of PAGE_NOACCESS\n", old_prot);
+    ok(old_prot == PAGE_NOACCESS, "wrong old protection: got %04lx instead of PAGE_NOACCESS\n", old_prot);
 
     old_prot = 0;
     ok(VirtualProtectEx(hProcess, addr1, 0x1000, PAGE_READWRITE, &old_prot), "VirtualProtectEx failed\n");
-    ok(old_prot == PAGE_READONLY, "wrong old protection: got %04x instead of PAGE_READONLY\n", old_prot);
+    ok(old_prot == PAGE_READONLY, "wrong old protection: got %04lx instead of PAGE_READONLY\n", old_prot);
 
     ok(!VirtualFreeEx(hProcess, addr1, 0x10000, 0),
        "VirtualFreeEx should fail with type 0\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-        "got %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
+        "got %lu, expected ERROR_INVALID_PARAMETER\n", GetLastError());
 
     ok(VirtualFreeEx(hProcess, addr1, 0x10000, MEM_DECOMMIT), "VirtualFreeEx failed\n");
 
@@ -214,7 +214,7 @@ static void test_VirtualAllocEx(void)
     ok(!VirtualFreeEx(hProcess, addr1, 1, MEM_RELEASE),
        "VirtualFreeEx should fail\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-        "got %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
+        "got %lu, expected ERROR_INVALID_PARAMETER\n", GetLastError());
 
     ok(VirtualFreeEx(hProcess, addr1, 0, MEM_RELEASE), "VirtualFreeEx failed\n");
 
@@ -232,7 +232,7 @@ static void test_VirtualAlloc(void)
     addr1 = VirtualAlloc(0, 0, MEM_RESERVE, PAGE_NOACCESS);
     ok(addr1 == NULL, "VirtualAlloc should fail on zero-sized allocation\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-        "got %d, expected ERROR_INVALID_PARAMETER\n", GetLastError());
+        "got %ld, expected ERROR_INVALID_PARAMETER\n", GetLastError());
 
     addr1 = VirtualAlloc(0, 0xFFFC, MEM_RESERVE, PAGE_NOACCESS);
     ok(addr1 != NULL, "VirtualAlloc failed\n");
@@ -242,17 +242,17 @@ static void test_VirtualAlloc(void)
         "VirtualQuery failed\n");
     ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
     ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
-    ok(info.AllocationProtect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.AllocationProtect);
-    ok(info.RegionSize == 0x10000, "%lx != 0x10000\n", info.RegionSize);
-    ok(info.State == MEM_RESERVE, "%x != MEM_RESERVE\n", info.State);
-    ok(info.Protect == 0, "%x != PAGE_NOACCESS\n", info.Protect);
-    ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
+    ok(info.AllocationProtect == PAGE_NOACCESS, "%lx != PAGE_NOACCESS\n", info.AllocationProtect);
+    ok(info.RegionSize == 0x10000, "%Ix != 0x10000\n", info.RegionSize);
+    ok(info.State == MEM_RESERVE, "%lx != MEM_RESERVE\n", info.State);
+    ok(info.Protect == 0, "%lx != PAGE_NOACCESS\n", info.Protect);
+    ok(info.Type == MEM_PRIVATE, "%lx != MEM_PRIVATE\n", info.Type);
 
     SetLastError(0xdeadbeef);
     ok(!VirtualProtect(addr1, 0xFFFC, PAGE_READONLY, &old_prot),
        "VirtualProtect should fail on a not committed memory\n");
     ok( GetLastError() == ERROR_INVALID_ADDRESS,
-        "got %d, expected ERROR_INVALID_ADDRESS\n", GetLastError());
+        "got %ld, expected ERROR_INVALID_ADDRESS\n", GetLastError());
 
     addr2 = VirtualAlloc(addr1, 0x1000, MEM_COMMIT, PAGE_NOACCESS);
     ok(addr1 == addr2, "VirtualAlloc failed\n");
@@ -262,99 +262,99 @@ static void test_VirtualAlloc(void)
         "VirtualQuery failed\n");
     ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
     ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
-    ok(info.AllocationProtect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.AllocationProtect);
-    ok(info.RegionSize == 0x1000, "%lx != 0x1000\n", info.RegionSize);
-    ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
+    ok(info.AllocationProtect == PAGE_NOACCESS, "%lx != PAGE_NOACCESS\n", info.AllocationProtect);
+    ok(info.RegionSize == 0x1000, "%Ix != 0x1000\n", info.RegionSize);
+    ok(info.State == MEM_COMMIT, "%lx != MEM_COMMIT\n", info.State);
     /* this time NT reports PAGE_NOACCESS as well */
-    ok(info.Protect == PAGE_NOACCESS, "%x != PAGE_NOACCESS\n", info.Protect);
-    ok(info.Type == MEM_PRIVATE, "%x != MEM_PRIVATE\n", info.Type);
+    ok(info.Protect == PAGE_NOACCESS, "%lx != PAGE_NOACCESS\n", info.Protect);
+    ok(info.Type == MEM_PRIVATE, "%lx != MEM_PRIVATE\n", info.Type);
 
     /* this should fail, since not the whole range is committed yet */
     SetLastError(0xdeadbeef);
     ok(!VirtualProtect(addr1, 0xFFFC, PAGE_READONLY, &old_prot),
         "VirtualProtect should fail on a not committed memory\n");
     ok( GetLastError() == ERROR_INVALID_ADDRESS,
-        "got %d, expected ERROR_INVALID_ADDRESS\n", GetLastError());
+        "got %ld, expected ERROR_INVALID_ADDRESS\n", GetLastError());
 
     ok(VirtualProtect(addr1, 0x1000, PAGE_READONLY, &old_prot), "VirtualProtect failed\n");
     ok(old_prot == PAGE_NOACCESS,
-        "wrong old protection: got %04x instead of PAGE_NOACCESS\n", old_prot);
+        "wrong old protection: got %04lx instead of PAGE_NOACCESS\n", old_prot);
 
     ok(VirtualProtect(addr1, 0x1000, PAGE_READWRITE, &old_prot), "VirtualProtect failed\n");
     ok(old_prot == PAGE_READONLY,
-        "wrong old protection: got %04x instead of PAGE_READONLY\n", old_prot);
+        "wrong old protection: got %04lx instead of PAGE_READONLY\n", old_prot);
 
     ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info),
         "VirtualQuery failed\n");
-    ok(info.RegionSize == 0x1000, "%lx != 0x1000\n", info.RegionSize);
-    ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
-    ok(info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect);
+    ok(info.RegionSize == 0x1000, "%Ix != 0x1000\n", info.RegionSize);
+    ok(info.State == MEM_COMMIT, "%lx != MEM_COMMIT\n", info.State);
+    ok(info.Protect == PAGE_READWRITE, "%lx != PAGE_READWRITE\n", info.Protect);
     memset( addr1, 0x55, 20 );
-    ok( *(DWORD *)addr1 == 0x55555555, "wrong data %x\n", *(DWORD *)addr1 );
+    ok( *(DWORD *)addr1 == 0x55555555, "wrong data %lx\n", *(DWORD *)addr1 );
 
     addr2 = VirtualAlloc( addr1, 0x1000, MEM_RESET, PAGE_NOACCESS );
-    ok( addr2 == addr1, "VirtualAlloc failed err %u\n", GetLastError() );
-    ok( *(DWORD *)addr1 == 0x55555555 || *(DWORD *)addr1 == 0, "wrong data %x\n", *(DWORD *)addr1 );
+    ok( addr2 == addr1, "VirtualAlloc failed err %lu\n", GetLastError() );
+    ok( *(DWORD *)addr1 == 0x55555555 || *(DWORD *)addr1 == 0, "wrong data %lx\n", *(DWORD *)addr1 );
     ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info),
        "VirtualQuery failed\n");
-    ok(info.RegionSize == 0x1000, "%lx != 0x1000\n", info.RegionSize);
-    ok(info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State);
-    ok(info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect);
+    ok(info.RegionSize == 0x1000, "%Ix != 0x1000\n", info.RegionSize);
+    ok(info.State == MEM_COMMIT, "%lx != MEM_COMMIT\n", info.State);
+    ok(info.Protect == PAGE_READWRITE, "%lx != PAGE_READWRITE\n", info.Protect);
 
     addr2 = VirtualAlloc( (char *)addr1 + 0x1000, 0x1000, MEM_RESET, PAGE_NOACCESS );
     ok( (char *)addr2 == (char *)addr1 + 0x1000, "VirtualAlloc failed\n" );
 
     ok(VirtualQuery(addr2, &info, sizeof(info)) == sizeof(info),
        "VirtualQuery failed\n");
-    ok(info.RegionSize == 0xf000, "%lx != 0xf000\n", info.RegionSize);
-    ok(info.State == MEM_RESERVE, "%x != MEM_RESERVE\n", info.State);
-    ok(info.Protect == 0, "%x != 0\n", info.Protect);
+    ok(info.RegionSize == 0xf000, "%Ix != 0xf000\n", info.RegionSize);
+    ok(info.State == MEM_RESERVE, "%lx != MEM_RESERVE\n", info.State);
+    ok(info.Protect == 0, "%lx != 0\n", info.Protect);
 
     addr2 = VirtualAlloc( (char *)addr1 + 0xf000, 0x2000, MEM_RESET, PAGE_NOACCESS );
     ok( !addr2, "VirtualAlloc failed\n" );
-    ok( GetLastError() == ERROR_INVALID_ADDRESS, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_ADDRESS, "wrong error %lu\n", GetLastError() );
 
     /* invalid protection values */
     SetLastError(0xdeadbeef);
     addr2 = VirtualAlloc(NULL, 0x1000, MEM_RESERVE, 0);
     ok(!addr2, "VirtualAlloc succeeded\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     addr2 = VirtualAlloc(NULL, 0x1000, MEM_COMMIT, 0);
     ok(!addr2, "VirtualAlloc succeeded\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     addr2 = VirtualAlloc(addr1, 0x1000, MEM_COMMIT, PAGE_READONLY | PAGE_EXECUTE);
     ok(!addr2, "VirtualAlloc succeeded\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ok(!VirtualProtect(addr1, 0x1000, PAGE_READWRITE | PAGE_EXECUTE_WRITECOPY, &old_prot),
        "VirtualProtect succeeded\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ok(!VirtualProtect(addr1, 0x1000, 0, &old_prot), "VirtualProtect succeeded\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ok(!VirtualFree(addr1, 0x10000, 0), "VirtualFree should fail with type 0\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-        "got %d, expected ERROR_INVALID_PARAMETER\n", GetLastError());
+        "got %ld, expected ERROR_INVALID_PARAMETER\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ok(!VirtualFree(addr1, 0, MEM_FREE), "VirtualFree should fail with type MEM_FREE\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-        "got %d, expected ERROR_INVALID_PARAMETER\n", GetLastError());
+        "got %ld, expected ERROR_INVALID_PARAMETER\n", GetLastError());
 
     ok(VirtualFree(addr1, 0x10000, MEM_DECOMMIT), "VirtualFree failed\n");
 
     /* if the type is MEM_RELEASE, size must be 0 */
     ok(!VirtualFree(addr1, 1, MEM_RELEASE), "VirtualFree should fail\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
-        "got %d, expected ERROR_INVALID_PARAMETER\n", GetLastError());
+        "got %ld, expected ERROR_INVALID_PARAMETER\n", GetLastError());
 
     ok(VirtualFree(addr1, 0, MEM_RELEASE), "VirtualFree failed\n");
 
@@ -365,39 +365,39 @@ static void test_VirtualAlloc(void)
     ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
     ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
     ok(info.AllocationProtect == (PAGE_READWRITE | PAGE_NOCACHE),
-       "wrong protect %x\n", info.AllocationProtect);
-    ok(info.RegionSize == 0x2000, "wrong size %lx\n", info.RegionSize);
-    ok(info.State == MEM_COMMIT, "wrong state %x\n", info.State);
-    ok(info.Protect == (PAGE_READWRITE | PAGE_NOCACHE), "wrong protect %x\n", info.Protect);
-    ok(info.Type == MEM_PRIVATE, "wrong type %x\n", info.Type);
+       "wrong protect %lx\n", info.AllocationProtect);
+    ok(info.RegionSize == 0x2000, "wrong size %Ix\n", info.RegionSize);
+    ok(info.State == MEM_COMMIT, "wrong state %lx\n", info.State);
+    ok(info.Protect == (PAGE_READWRITE | PAGE_NOCACHE), "wrong protect %lx\n", info.Protect);
+    ok(info.Type == MEM_PRIVATE, "wrong type %lx\n", info.Type);
 
     ok(VirtualProtect(addr1, 0x1000, PAGE_READWRITE, &old_prot), "VirtualProtect failed\n");
-    ok( old_prot == (PAGE_READWRITE | PAGE_NOCACHE), "wrong protect %x\n", old_prot );
+    ok( old_prot == (PAGE_READWRITE | PAGE_NOCACHE), "wrong protect %lx\n", old_prot );
     ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info), "VirtualQuery failed\n");
     ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
     ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
     ok(info.AllocationProtect == (PAGE_READWRITE | PAGE_NOCACHE),
-       "wrong protect %x\n", info.AllocationProtect);
+       "wrong protect %lx\n", info.AllocationProtect);
     ok(info.RegionSize == 0x2000 || broken(info.RegionSize == 0x1000),
-       "wrong size %lx\n", info.RegionSize);
-    ok(info.State == MEM_COMMIT, "wrong state %x\n", info.State);
+       "wrong size %Ix\n", info.RegionSize);
+    ok(info.State == MEM_COMMIT, "wrong state %lx\n", info.State);
     ok(info.Protect == (PAGE_READWRITE | PAGE_NOCACHE) || broken(info.Protect == PAGE_READWRITE),
-       "wrong protect %x\n", info.Protect);
-    ok(info.Type == MEM_PRIVATE, "wrong type %x\n", info.Type);
+       "wrong protect %lx\n", info.Protect);
+    ok(info.Type == MEM_PRIVATE, "wrong type %lx\n", info.Type);
 
     ok(VirtualProtect(addr1, 0x1000, PAGE_READONLY, &old_prot), "VirtualProtect failed\n");
     ok( old_prot == (PAGE_READWRITE | PAGE_NOCACHE) || broken(old_prot == PAGE_READWRITE),
-        "wrong protect %x\n", old_prot );
+        "wrong protect %lx\n", old_prot );
     ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info), "VirtualQuery failed\n");
     ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
     ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
     ok(info.AllocationProtect == (PAGE_READWRITE | PAGE_NOCACHE),
-       "wrong protect %x\n", info.AllocationProtect);
-    ok(info.RegionSize == 0x1000, "wrong size %lx\n", info.RegionSize);
-    ok(info.State == MEM_COMMIT, "wrong state %x\n", info.State);
+       "wrong protect %lx\n", info.AllocationProtect);
+    ok(info.RegionSize == 0x1000, "wrong size %Ix\n", info.RegionSize);
+    ok(info.State == MEM_COMMIT, "wrong state %lx\n", info.State);
     ok(info.Protect == (PAGE_READONLY | PAGE_NOCACHE) || broken(info.Protect == PAGE_READONLY),
-       "wrong protect %x\n", info.Protect);
-    ok(info.Type == MEM_PRIVATE, "wrong type %x\n", info.Type);
+       "wrong protect %lx\n", info.Protect);
+    ok(info.Type == MEM_PRIVATE, "wrong type %lx\n", info.Type);
 
     ok(VirtualFree(addr1, 0, MEM_RELEASE), "VirtualFree failed\n");
 
@@ -407,23 +407,23 @@ static void test_VirtualAlloc(void)
     ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
     ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
     ok(info.AllocationProtect == PAGE_READWRITE,
-       "wrong protect %x\n", info.AllocationProtect);
-    ok(info.RegionSize == 0x2000, "wrong size %lx\n", info.RegionSize);
-    ok(info.State == MEM_COMMIT, "wrong state %x\n", info.State);
-    ok(info.Protect == PAGE_READWRITE, "wrong protect %x\n", info.Protect);
-    ok(info.Type == MEM_PRIVATE, "wrong type %x\n", info.Type);
+       "wrong protect %lx\n", info.AllocationProtect);
+    ok(info.RegionSize == 0x2000, "wrong size %Ix\n", info.RegionSize);
+    ok(info.State == MEM_COMMIT, "wrong state %lx\n", info.State);
+    ok(info.Protect == PAGE_READWRITE, "wrong protect %lx\n", info.Protect);
+    ok(info.Type == MEM_PRIVATE, "wrong type %lx\n", info.Type);
 
     ok(VirtualProtect(addr1, 0x1000, PAGE_READONLY | PAGE_NOCACHE, &old_prot), "VirtualProtect failed\n");
-    ok( old_prot == PAGE_READWRITE, "wrong protect %x\n", old_prot );
+    ok( old_prot == PAGE_READWRITE, "wrong protect %lx\n", old_prot );
     ok(VirtualQuery(addr1, &info, sizeof(info)) == sizeof(info), "VirtualQuery failed\n");
     ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
     ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
-    ok(info.AllocationProtect == PAGE_READWRITE, "wrong protect %x\n", info.AllocationProtect);
-    ok(info.RegionSize == 0x1000, "wrong size %lx\n", info.RegionSize);
-    ok(info.State == MEM_COMMIT, "wrong state %x\n", info.State);
+    ok(info.AllocationProtect == PAGE_READWRITE, "wrong protect %lx\n", info.AllocationProtect);
+    ok(info.RegionSize == 0x1000, "wrong size %Ix\n", info.RegionSize);
+    ok(info.State == MEM_COMMIT, "wrong state %lx\n", info.State);
     ok(info.Protect == PAGE_READONLY || broken(info.Protect == (PAGE_READONLY | PAGE_NOCACHE)),
-       "wrong protect %x\n", info.Protect);
-    ok(info.Type == MEM_PRIVATE, "wrong type %x\n", info.Type);
+       "wrong protect %lx\n", info.Protect);
+    ok(info.Type == MEM_PRIVATE, "wrong type %lx\n", info.Type);
 
     ok(VirtualFree(addr1, 0, MEM_RELEASE), "VirtualFree failed\n");
 
@@ -439,7 +439,7 @@ static void test_VirtualAlloc(void)
     SetLastError(0xdeadbeef);
     addr2 = VirtualAlloc(addr1, 0x1000, MEM_RESERVE | MEM_COMMIT | AT_ROUND_TO_PAGE, PAGE_EXECUTE_READWRITE);
     ok(!addr2, "VirtualAlloc unexpectedly succeeded\n");
-    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %d, expected ERROR_INVALID_PARAMETER\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld, expected ERROR_INVALID_PARAMETER\n", GetLastError());
 
     ok(VirtualFree(addr1, 0, MEM_RELEASE), "VirtualFree failed\n");
 }
@@ -459,21 +459,21 @@ static void test_VirtualAllocFromApp(void)
 
     SetLastError(0xdeadbeef);
     p = pVirtualAllocFromApp(NULL, 0x1000, MEM_RESERVE, PAGE_READWRITE);
-    ok(p && GetLastError() == 0xdeadbeef, "Got unexpected mem %p, GetLastError() %u.\n", p, GetLastError());
+    ok(p && GetLastError() == 0xdeadbeef, "Got unexpected mem %p, GetLastError() %lu.\n", p, GetLastError());
     ret = VirtualFree(p, 0, MEM_RELEASE);
-    ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError());
+    ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
 
     SetLastError(0xdeadbeef);
     p = pVirtualAllocFromApp(NULL, 0x1000, MEM_RESERVE, PAGE_EXECUTE);
-    ok(!p && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected mem %p, GetLastError() %u.\n",
+    ok(!p && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected mem %p, GetLastError() %lu.\n",
             p, GetLastError());
     SetLastError(0xdeadbeef);
     p = pVirtualAllocFromApp(NULL, 0x1000, MEM_RESERVE, PAGE_EXECUTE_READ);
-    ok(!p && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected mem %p, GetLastError() %u.\n",
+    ok(!p && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected mem %p, GetLastError() %lu.\n",
             p, GetLastError());
     SetLastError(0xdeadbeef);
     p = pVirtualAllocFromApp(NULL, 0x1000, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
-    ok(!p && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected mem %p, GetLastError() %u.\n",
+    ok(!p && GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected mem %p, GetLastError() %lu.\n",
             p, GetLastError());
 }
 
@@ -494,7 +494,7 @@ static void test_MapViewOfFile(void)
 
     SetLastError(0xdeadbeef);
     file = CreateFileA( testfile, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
-    ok( file != INVALID_HANDLE_VALUE, "CreateFile error %u\n", GetLastError() );
+    ok( file != INVALID_HANDLE_VALUE, "CreateFile error %lu\n", GetLastError() );
     SetFilePointer( file, 12288, NULL, FILE_BEGIN );
     SetEndOfFile( file );
 
@@ -502,56 +502,56 @@ static void test_MapViewOfFile(void)
 
     SetLastError(0xdeadbeef);
     mapping = CreateFileMappingA( file, NULL, PAGE_READWRITE, 0, 4096, NULL );
-    ok( mapping != 0, "CreateFileMapping error %u\n", GetLastError() );
+    ok( mapping != 0, "CreateFileMapping error %lu\n", GetLastError() );
 
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
-    ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %lu\n", GetLastError() );
     UnmapViewOfFile( ptr );
 
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( mapping, FILE_MAP_COPY, 0, 0, 4096 );
-    ok( ptr != NULL, "MapViewOfFile FILE_MAP_COPY error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile FILE_MAP_COPY error %lu\n", GetLastError() );
     UnmapViewOfFile( ptr );
 
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( mapping, 0, 0, 0, 4096 );
-    ok( ptr != NULL, "MapViewOfFile 0 error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile 0 error %lu\n", GetLastError() );
     UnmapViewOfFile( ptr );
 
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 4096 );
-    ok( ptr != NULL, "MapViewOfFile FILE_MAP_WRITE error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile FILE_MAP_WRITE error %lu\n", GetLastError() );
     UnmapViewOfFile( ptr );
 
     ret = DuplicateHandle( GetCurrentProcess(), mapping, GetCurrentProcess(), &map2,
                            FILE_MAP_READ|FILE_MAP_WRITE, FALSE, 0 );
-    ok( ret, "DuplicateHandle failed error %u\n", GetLastError());
+    ok( ret, "DuplicateHandle failed error %lu\n", GetLastError());
     ptr = MapViewOfFile( map2, FILE_MAP_WRITE, 0, 0, 4096 );
-    ok( ptr != NULL, "MapViewOfFile FILE_MAP_WRITE error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile FILE_MAP_WRITE error %lu\n", GetLastError() );
     UnmapViewOfFile( ptr );
     CloseHandle( map2 );
 
     ret = DuplicateHandle( GetCurrentProcess(), mapping, GetCurrentProcess(), &map2,
                            FILE_MAP_READ, FALSE, 0 );
-    ok( ret, "DuplicateHandle failed error %u\n", GetLastError());
+    ok( ret, "DuplicateHandle failed error %lu\n", GetLastError());
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( map2, FILE_MAP_WRITE, 0, 0, 4096 );
     ok( !ptr, "MapViewOfFile succeeded\n" );
-    ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %ld\n", GetLastError() );
     CloseHandle( map2 );
     ret = DuplicateHandle( GetCurrentProcess(), mapping, GetCurrentProcess(), &map2, 0, FALSE, 0 );
-    ok( ret, "DuplicateHandle failed error %u\n", GetLastError());
+    ok( ret, "DuplicateHandle failed error %lu\n", GetLastError());
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( map2, 0, 0, 0, 4096 );
     ok( !ptr, "MapViewOfFile succeeded\n" );
-    ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %ld\n", GetLastError() );
     CloseHandle( map2 );
     ret = DuplicateHandle( GetCurrentProcess(), mapping, GetCurrentProcess(), &map2,
                            FILE_MAP_READ, FALSE, 0 );
-    ok( ret, "DuplicateHandle failed error %u\n", GetLastError());
+    ok( ret, "DuplicateHandle failed error %lu\n", GetLastError());
     ptr = MapViewOfFile( map2, 0, 0, 0, 4096 );
-    ok( ptr != NULL, "MapViewOfFile NO_ACCESS error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile NO_ACCESS error %lu\n", GetLastError() );
 
     UnmapViewOfFile( ptr );
     CloseHandle( map2 );
@@ -561,56 +561,56 @@ static void test_MapViewOfFile(void)
 
     SetLastError(0xdeadbeef);
     mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 4096, NULL );
-    ok( mapping != 0, "CreateFileMapping error %u\n", GetLastError() );
+    ok( mapping != 0, "CreateFileMapping error %lu\n", GetLastError() );
 
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
-    ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %lu\n", GetLastError() );
     UnmapViewOfFile( ptr );
 
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( mapping, FILE_MAP_COPY, 0, 0, 4096 );
-    ok( ptr != NULL, "MapViewOfFile FILE_MAP_COPY error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile FILE_MAP_COPY error %lu\n", GetLastError() );
     UnmapViewOfFile( ptr );
 
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( mapping, 0, 0, 0, 4096 );
-    ok( ptr != NULL, "MapViewOfFile 0 error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile 0 error %lu\n", GetLastError() );
     UnmapViewOfFile( ptr );
 
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 4096 );
     ok( !ptr, "MapViewOfFile FILE_MAP_WRITE succeeded\n" );
     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
-        GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
+        GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %ld\n", GetLastError() );
     CloseHandle( mapping );
 
     /* copy-on-write mapping */
 
     SetLastError(0xdeadbeef);
     mapping = CreateFileMappingA( file, NULL, PAGE_WRITECOPY, 0, 4096, NULL );
-    ok( mapping != 0, "CreateFileMapping error %u\n", GetLastError() );
+    ok( mapping != 0, "CreateFileMapping error %lu\n", GetLastError() );
 
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
-    ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %lu\n", GetLastError() );
     UnmapViewOfFile( ptr );
 
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( mapping, FILE_MAP_COPY, 0, 0, 4096 );
-    ok( ptr != NULL, "MapViewOfFile FILE_MAP_COPY error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile FILE_MAP_COPY error %lu\n", GetLastError() );
     UnmapViewOfFile( ptr );
 
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( mapping, 0, 0, 0, 4096 );
-    ok( ptr != NULL, "MapViewOfFile 0 error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile 0 error %lu\n", GetLastError() );
     UnmapViewOfFile( ptr );
 
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 4096 );
     ok( !ptr, "MapViewOfFile FILE_MAP_WRITE succeeded\n" );
     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
-        GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
+        GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %ld\n", GetLastError() );
     CloseHandle( mapping );
 
     /* no access mapping */
@@ -618,29 +618,29 @@ static void test_MapViewOfFile(void)
     SetLastError(0xdeadbeef);
     mapping = CreateFileMappingA( file, NULL, PAGE_NOACCESS, 0, 4096, NULL );
     ok( !mapping, "CreateFileMappingA succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error %ld\n", GetLastError() );
     CloseHandle( file );
 
     /* now try read-only file */
 
     SetLastError(0xdeadbeef);
     file = CreateFileA( testfile, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0 );
-    ok( file != INVALID_HANDLE_VALUE, "CreateFile error %u\n", GetLastError() );
+    ok( file != INVALID_HANDLE_VALUE, "CreateFile error %lu\n", GetLastError() );
 
     SetLastError(0xdeadbeef);
     mapping = CreateFileMappingA( file, NULL, PAGE_READWRITE, 0, 4096, NULL );
     ok( !mapping, "CreateFileMapping PAGE_READWRITE succeeded\n" );
     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
-        GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
+        GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %ld\n", GetLastError() );
 
     SetLastError(0xdeadbeef);
     mapping = CreateFileMappingA( file, NULL, PAGE_WRITECOPY, 0, 4096, NULL );
-    ok( mapping != 0, "CreateFileMapping PAGE_WRITECOPY error %u\n", GetLastError() );
+    ok( mapping != 0, "CreateFileMapping PAGE_WRITECOPY error %lu\n", GetLastError() );
     CloseHandle( mapping );
 
     SetLastError(0xdeadbeef);
     mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 4096, NULL );
-    ok( mapping != 0, "CreateFileMapping PAGE_READONLY error %u\n", GetLastError() );
+    ok( mapping != 0, "CreateFileMapping PAGE_READONLY error %lu\n", GetLastError() );
     CloseHandle( mapping );
     CloseHandle( file );
 
@@ -648,25 +648,25 @@ static void test_MapViewOfFile(void)
 
     SetLastError(0xdeadbeef);
     file = CreateFileA( testfile, 0, 0, NULL, OPEN_EXISTING, 0, 0 );
-    ok( file != INVALID_HANDLE_VALUE, "CreateFile error %u\n", GetLastError() );
+    ok( file != INVALID_HANDLE_VALUE, "CreateFile error %lu\n", GetLastError() );
 
     SetLastError(0xdeadbeef);
     mapping = CreateFileMappingA( file, NULL, PAGE_READWRITE, 0, 4096, NULL );
     ok( !mapping, "CreateFileMapping PAGE_READWRITE succeeded\n" );
     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
-        GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
+        GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %ld\n", GetLastError() );
 
     SetLastError(0xdeadbeef);
     mapping = CreateFileMappingA( file, NULL, PAGE_WRITECOPY, 0, 4096, NULL );
     ok( !mapping, "CreateFileMapping PAGE_WRITECOPY succeeded\n" );
     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
-        GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
+        GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %ld\n", GetLastError() );
 
     SetLastError(0xdeadbeef);
     mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 4096, NULL );
     ok( !mapping, "CreateFileMapping PAGE_READONLY succeeded\n" );
     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
-        GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
+        GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %ld\n", GetLastError() );
 
     CloseHandle( file );
     DeleteFileA( testfile );
@@ -680,83 +680,83 @@ static void test_MapViewOfFile(void)
         name = "Foo";
         file = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4090, name );
     }
-    ok( file != 0, "CreateFileMapping PAGE_READWRITE error %u\n", GetLastError() );
+    ok( file != 0, "CreateFileMapping PAGE_READWRITE error %lu\n", GetLastError() );
 
     SetLastError(0xdeadbeef);
     mapping = OpenFileMappingA( FILE_MAP_READ, FALSE, name );
-    ok( mapping != 0, "OpenFileMapping FILE_MAP_READ error %u\n", GetLastError() );
+    ok( mapping != 0, "OpenFileMapping FILE_MAP_READ error %lu\n", GetLastError() );
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 0 );
     ok( !ptr, "MapViewOfFile FILE_MAP_WRITE succeeded\n" );
-    ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %ld\n", GetLastError() );
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 );
-    ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %lu\n", GetLastError() );
     SetLastError(0xdeadbeef);
     size = VirtualQuery( ptr, &info, sizeof(info) );
     ok( size == sizeof(info),
-        "VirtualQuery error %u\n", GetLastError() );
+        "VirtualQuery error %lu\n", GetLastError() );
     ok( info.BaseAddress == ptr, "%p != %p\n", info.BaseAddress, ptr );
     ok( info.AllocationBase == ptr, "%p != %p\n", info.AllocationBase, ptr );
-    ok( info.AllocationProtect == PAGE_READONLY, "%x != PAGE_READONLY\n", info.AllocationProtect );
-    ok( info.RegionSize == 4096, "%lx != 4096\n", info.RegionSize );
-    ok( info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State );
-    ok( info.Protect == PAGE_READONLY, "%x != PAGE_READONLY\n", info.Protect );
+    ok( info.AllocationProtect == PAGE_READONLY, "%lx != PAGE_READONLY\n", info.AllocationProtect );
+    ok( info.RegionSize == 4096, "%Ix != 4096\n", info.RegionSize );
+    ok( info.State == MEM_COMMIT, "%lx != MEM_COMMIT\n", info.State );
+    ok( info.Protect == PAGE_READONLY, "%lx != PAGE_READONLY\n", info.Protect );
     UnmapViewOfFile( ptr );
     status = pNtQuerySection( mapping, SectionBasicInformation, &section_info,
                               sizeof(section_info), &info_size );
-    ok( status == STATUS_ACCESS_DENIED, "NtQuerySection failed err %x\n", status );
+    ok( status == STATUS_ACCESS_DENIED, "NtQuerySection failed err %lx\n", status );
     CloseHandle( mapping );
     mapping = OpenFileMappingA( FILE_MAP_READ | SECTION_QUERY, FALSE, name );
-    ok( mapping != 0, "OpenFileMapping FILE_MAP_READ error %u\n", GetLastError() );
+    ok( mapping != 0, "OpenFileMapping FILE_MAP_READ error %lu\n", GetLastError() );
     info_size = (SIZE_T)0xdeadbeef << 16;
     status = pNtQuerySection( mapping, SectionBasicInformation, &section_info,
                               sizeof(section_info), &info_size );
-    ok( !status, "NtQuerySection failed err %x\n", status );
-    ok( info_size == sizeof(section_info), "NtQuerySection wrong size %lu\n", info_size );
-    ok( section_info.Attributes == SEC_COMMIT, "NtQuerySection wrong attr %08x\n",
+    ok( !status, "NtQuerySection failed err %lx\n", status );
+    ok( info_size == sizeof(section_info), "NtQuerySection wrong size %Iu\n", info_size );
+    ok( section_info.Attributes == SEC_COMMIT, "NtQuerySection wrong attr %08lx\n",
         section_info.Attributes );
     ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", section_info.BaseAddress );
-    ok( section_info.Size.QuadPart == info.RegionSize, "NtQuerySection wrong size %x%08x / %08lx\n",
+    ok( section_info.Size.QuadPart == info.RegionSize, "NtQuerySection wrong size %lx%08lx / %08Ix\n",
         section_info.Size.u.HighPart, section_info.Size.u.LowPart, info.RegionSize );
     CloseHandle( mapping );
 
     SetLastError(0xdeadbeef);
     mapping = OpenFileMappingA( FILE_MAP_WRITE, FALSE, name );
-    ok( mapping != 0, "OpenFileMapping FILE_MAP_WRITE error %u\n", GetLastError() );
+    ok( mapping != 0, "OpenFileMapping FILE_MAP_WRITE error %lu\n", GetLastError() );
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 );
     ok( !ptr, "MapViewOfFile succeeded\n" );
-    ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %ld\n", GetLastError() );
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 0 );
-    ok( ptr != NULL, "MapViewOfFile FILE_MAP_WRITE error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile FILE_MAP_WRITE error %lu\n", GetLastError() );
     SetLastError(0xdeadbeef);
     size = VirtualQuery( ptr, &info, sizeof(info) );
     ok( size == sizeof(info),
-        "VirtualQuery error %u\n", GetLastError() );
+        "VirtualQuery error %lu\n", GetLastError() );
     ok( info.BaseAddress == ptr, "%p != %p\n", info.BaseAddress, ptr );
     ok( info.AllocationBase == ptr, "%p != %p\n", info.AllocationBase, ptr );
-    ok( info.AllocationProtect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.AllocationProtect );
-    ok( info.RegionSize == 4096, "%lx != 4096\n", info.RegionSize );
-    ok( info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State );
-    ok( info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect );
+    ok( info.AllocationProtect == PAGE_READWRITE, "%lx != PAGE_READWRITE\n", info.AllocationProtect );
+    ok( info.RegionSize == 4096, "%Ix != 4096\n", info.RegionSize );
+    ok( info.State == MEM_COMMIT, "%lx != MEM_COMMIT\n", info.State );
+    ok( info.Protect == PAGE_READWRITE, "%lx != PAGE_READWRITE\n", info.Protect );
     UnmapViewOfFile( ptr );
     status = pNtQuerySection( mapping, SectionBasicInformation, &section_info,
                               sizeof(section_info), &info_size );
-    ok( status == STATUS_ACCESS_DENIED, "NtQuerySection failed err %x\n", status );
+    ok( status == STATUS_ACCESS_DENIED, "NtQuerySection failed err %lx\n", status );
     CloseHandle( mapping );
 
     mapping = OpenFileMappingA( FILE_MAP_WRITE | SECTION_QUERY, FALSE, name );
-    ok( mapping != 0, "OpenFileMapping FILE_MAP_WRITE error %u\n", GetLastError() );
+    ok( mapping != 0, "OpenFileMapping FILE_MAP_WRITE error %lu\n", GetLastError() );
     status = pNtQuerySection( mapping, SectionBasicInformation, &section_info,
                               sizeof(section_info), &info_size );
-    ok( !status, "NtQuerySection failed err %x\n", status );
-    ok( info_size == sizeof(section_info), "NtQuerySection wrong size %lu\n", info_size );
-    ok( section_info.Attributes == SEC_COMMIT, "NtQuerySection wrong attr %08x\n",
+    ok( !status, "NtQuerySection failed err %lx\n", status );
+    ok( info_size == sizeof(section_info), "NtQuerySection wrong size %Iu\n", info_size );
+    ok( section_info.Attributes == SEC_COMMIT, "NtQuerySection wrong attr %08lx\n",
         section_info.Attributes );
     ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", section_info.BaseAddress );
-    ok( section_info.Size.QuadPart == info.RegionSize, "NtQuerySection wrong size %x%08x / %08lx\n",
+    ok( section_info.Size.QuadPart == info.RegionSize, "NtQuerySection wrong size %lx%08lx / %08Ix\n",
         section_info.Size.u.HighPart, section_info.Size.u.LowPart, info.RegionSize );
     CloseHandle( mapping );
 
@@ -764,203 +764,203 @@ static void test_MapViewOfFile(void)
 
     /* read/write mapping with SEC_RESERVE */
     mapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE | SEC_RESERVE, 0, MAPPING_SIZE, NULL);
-    ok(mapping != 0, "CreateFileMappingA failed with error %d\n", GetLastError());
+    ok(mapping != 0, "CreateFileMappingA failed with error %ld\n", GetLastError());
     status = pNtQuerySection( mapping, SectionBasicInformation, &section_info,
                               sizeof(section_info), NULL );
-    ok( !status, "NtQuerySection failed err %x\n", status );
-    ok( section_info.Attributes == SEC_RESERVE, "NtQuerySection wrong attr %08x\n",
+    ok( !status, "NtQuerySection failed err %lx\n", status );
+    ok( section_info.Attributes == SEC_RESERVE, "NtQuerySection wrong attr %08lx\n",
         section_info.Attributes );
     ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", section_info.BaseAddress );
-    ok( section_info.Size.QuadPart == MAPPING_SIZE, "NtQuerySection wrong size %x%08x / %08x\n",
+    ok( section_info.Size.QuadPart == MAPPING_SIZE, "NtQuerySection wrong size %lx%08lx / %08x\n",
         section_info.Size.u.HighPart, section_info.Size.u.LowPart, MAPPING_SIZE );
 
     ptr = MapViewOfFile(mapping, FILE_MAP_WRITE, 0, 0, 0);
-    ok(ptr != NULL, "MapViewOfFile failed with error %d\n", GetLastError());
+    ok(ptr != NULL, "MapViewOfFile failed with error %ld\n", GetLastError());
 
     ptr2 = MapViewOfFile(mapping, FILE_MAP_WRITE, 0, 0, 0);
-    ok( ptr2 != NULL, "MapViewOfFile failed with error %d\n", GetLastError());
+    ok( ptr2 != NULL, "MapViewOfFile failed with error %ld\n", GetLastError());
     ok( ptr != ptr2, "MapViewOfFile returned same pointer\n" );
 
     ret = VirtualQuery(ptr, &info, sizeof(info));
-    ok(ret, "VirtualQuery failed with error %d\n", GetLastError());
+    ok(ret, "VirtualQuery failed with error %ld\n", GetLastError());
     ok(info.BaseAddress == ptr, "BaseAddress should have been %p but was %p instead\n", ptr, info.BaseAddress);
     ok(info.AllocationBase == ptr, "AllocationBase should have been %p but was %p instead\n", ptr, info.AllocationBase);
-    ok(info.RegionSize == MAPPING_SIZE, "RegionSize should have been 0x%x but was 0x%lx\n", MAPPING_SIZE, info.RegionSize);
-    ok(info.State == MEM_RESERVE, "State should have been MEM_RESERVE instead of 0x%x\n", info.State);
+    ok(info.RegionSize == MAPPING_SIZE, "RegionSize should have been 0x%x but was 0x%Ix\n", MAPPING_SIZE, info.RegionSize);
+    ok(info.State == MEM_RESERVE, "State should have been MEM_RESERVE instead of 0x%lx\n", info.State);
     ok(info.AllocationProtect == PAGE_READWRITE,
-       "AllocationProtect should have been PAGE_READWRITE but was 0x%x\n", info.AllocationProtect);
-    ok(info.Protect == 0, "Protect should have been 0 instead of 0x%x\n", info.Protect);
-    ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of 0x%x\n", info.Type);
+       "AllocationProtect should have been PAGE_READWRITE but was 0x%lx\n", info.AllocationProtect);
+    ok(info.Protect == 0, "Protect should have been 0 instead of 0x%lx\n", info.Protect);
+    ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of 0x%lx\n", info.Type);
 
     ret = VirtualQuery(ptr2, &info, sizeof(info));
-    ok(ret, "VirtualQuery failed with error %d\n", GetLastError());
+    ok(ret, "VirtualQuery failed with error %ld\n", GetLastError());
     ok(info.BaseAddress == ptr2,
        "BaseAddress should have been %p but was %p instead\n", ptr2, info.BaseAddress);
     ok(info.AllocationBase == ptr2,
        "AllocationBase should have been %p but was %p instead\n", ptr2, info.AllocationBase);
     ok(info.AllocationProtect == PAGE_READWRITE,
-       "AllocationProtect should have been PAGE_READWRITE but was 0x%x\n", info.AllocationProtect);
+       "AllocationProtect should have been PAGE_READWRITE but was 0x%lx\n", info.AllocationProtect);
     ok(info.RegionSize == MAPPING_SIZE,
-       "RegionSize should have been 0x%x but was 0x%lx\n", MAPPING_SIZE, info.RegionSize);
-    ok(info.State == MEM_RESERVE, "State should have been MEM_RESERVE instead of 0x%x\n", info.State);
-    ok(info.Protect == 0, "Protect should have been 0 instead of 0x%x\n", info.Protect);
-    ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of 0x%x\n", info.Type);
+       "RegionSize should have been 0x%x but was 0x%Ix\n", MAPPING_SIZE, info.RegionSize);
+    ok(info.State == MEM_RESERVE, "State should have been MEM_RESERVE instead of 0x%lx\n", info.State);
+    ok(info.Protect == 0, "Protect should have been 0 instead of 0x%lx\n", info.Protect);
+    ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of 0x%lx\n", info.Type);
 
     ptr = VirtualAlloc(ptr, 0x10000, MEM_COMMIT, PAGE_READONLY);
-    ok(ptr != NULL, "VirtualAlloc failed with error %d\n", GetLastError());
+    ok(ptr != NULL, "VirtualAlloc failed with error %ld\n", GetLastError());
 
     ret = VirtualQuery(ptr, &info, sizeof(info));
-    ok(ret, "VirtualQuery failed with error %d\n", GetLastError());
+    ok(ret, "VirtualQuery failed with error %ld\n", GetLastError());
     ok(info.BaseAddress == ptr, "BaseAddress should have been %p but was %p instead\n", ptr, info.BaseAddress);
     ok(info.AllocationBase == ptr, "AllocationBase should have been %p but was %p instead\n", ptr, info.AllocationBase);
-    ok(info.RegionSize == 0x10000, "RegionSize should have been 0x10000 but was 0x%lx\n", info.RegionSize);
-    ok(info.State == MEM_COMMIT, "State should have been MEM_COMMIT instead of 0x%x\n", info.State);
-    ok(info.Protect == PAGE_READONLY, "Protect should have been PAGE_READONLY instead of 0x%x\n", info.Protect);
+    ok(info.RegionSize == 0x10000, "RegionSize should have been 0x10000 but was 0x%Ix\n", info.RegionSize);
+    ok(info.State == MEM_COMMIT, "State should have been MEM_COMMIT instead of 0x%lx\n", info.State);
+    ok(info.Protect == PAGE_READONLY, "Protect should have been PAGE_READONLY instead of 0x%lx\n", info.Protect);
     ok(info.AllocationProtect == PAGE_READWRITE,
-       "AllocationProtect should have been PAGE_READWRITE but was 0x%x\n", info.AllocationProtect);
-    ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of 0x%x\n", info.Type);
+       "AllocationProtect should have been PAGE_READWRITE but was 0x%lx\n", info.AllocationProtect);
+    ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of 0x%lx\n", info.Type);
 
     /* shows that the VirtualAlloc above affects the mapping, not just the
      * virtual memory in this process - it also affects all other processes
      * with a view of the mapping, but that isn't tested here */
     ret = VirtualQuery(ptr2, &info, sizeof(info));
-    ok(ret, "VirtualQuery failed with error %d\n", GetLastError());
+    ok(ret, "VirtualQuery failed with error %ld\n", GetLastError());
     ok(info.BaseAddress == ptr2,
        "BaseAddress should have been %p but was %p instead\n", ptr2, info.BaseAddress);
     ok(info.AllocationBase == ptr2,
        "AllocationBase should have been %p but was %p instead\n", ptr2, info.AllocationBase);
     ok(info.AllocationProtect == PAGE_READWRITE,
-       "AllocationProtect should have been PAGE_READWRITE but was 0x%x\n", info.AllocationProtect);
+       "AllocationProtect should have been PAGE_READWRITE but was 0x%lx\n", info.AllocationProtect);
     ok(info.RegionSize == 0x10000,
-       "RegionSize should have been 0x10000 but was 0x%lx\n", info.RegionSize);
+       "RegionSize should have been 0x10000 but was 0x%Ix\n", info.RegionSize);
     ok(info.State == MEM_COMMIT,
-       "State should have been MEM_COMMIT instead of 0x%x\n", info.State);
+       "State should have been MEM_COMMIT instead of 0x%lx\n", info.State);
     ok(info.Protect == PAGE_READWRITE,
-       "Protect should have been PAGE_READWRITE instead of 0x%x\n", info.Protect);
-    ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of 0x%x\n", info.Type);
+       "Protect should have been PAGE_READWRITE instead of 0x%lx\n", info.Protect);
+    ok(info.Type == MEM_MAPPED, "Type should have been MEM_MAPPED instead of 0x%lx\n", info.Type);
 
     addr = VirtualAlloc( ptr, MAPPING_SIZE, MEM_RESET, PAGE_READONLY );
-    ok( addr == ptr, "VirtualAlloc failed with error %u\n", GetLastError() );
+    ok( addr == ptr, "VirtualAlloc failed with error %lu\n", GetLastError() );
 
     ret = VirtualFree( ptr, 0x10000, MEM_DECOMMIT );
     ok( !ret, "VirtualFree succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "VirtualFree failed with %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "VirtualFree failed with %lu\n", GetLastError() );
 
     ret = UnmapViewOfFile(ptr2);
-    ok(ret, "UnmapViewOfFile failed with error %d\n", GetLastError());
+    ok(ret, "UnmapViewOfFile failed with error %ld\n", GetLastError());
     ret = UnmapViewOfFile(ptr);
-    ok(ret, "UnmapViewOfFile failed with error %d\n", GetLastError());
+    ok(ret, "UnmapViewOfFile failed with error %ld\n", GetLastError());
     CloseHandle(mapping);
 
     /* same thing with SEC_COMMIT */
     mapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE | SEC_COMMIT, 0, MAPPING_SIZE, NULL);
-    ok(mapping != 0, "CreateFileMappingA failed with error %d\n", GetLastError());
+    ok(mapping != 0, "CreateFileMappingA failed with error %ld\n", GetLastError());
     status = pNtQuerySection( mapping, SectionBasicInformation, &section_info,
                               sizeof(section_info), NULL );
-    ok( !status, "NtQuerySection failed err %x\n", status );
-    ok( section_info.Attributes == SEC_COMMIT, "NtQuerySection wrong attr %08x\n",
+    ok( !status, "NtQuerySection failed err %lx\n", status );
+    ok( section_info.Attributes == SEC_COMMIT, "NtQuerySection wrong attr %08lx\n",
         section_info.Attributes );
     ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", section_info.BaseAddress );
-    ok( section_info.Size.QuadPart == MAPPING_SIZE, "NtQuerySection wrong size %x%08x / %08x\n",
+    ok( section_info.Size.QuadPart == MAPPING_SIZE, "NtQuerySection wrong size %lx%08lx / %08x\n",
         section_info.Size.u.HighPart, section_info.Size.u.LowPart, MAPPING_SIZE );
 
     ptr = MapViewOfFile(mapping, FILE_MAP_WRITE, 0, 0, 0);
-    ok(ptr != NULL, "MapViewOfFile failed with error %d\n", GetLastError());
+    ok(ptr != NULL, "MapViewOfFile failed with error %ld\n", GetLastError());
 
     ret = VirtualQuery(ptr, &info, sizeof(info));
-    ok(ret, "VirtualQuery failed with error %d\n", GetLastError());
+    ok(ret, "VirtualQuery failed with error %ld\n", GetLastError());
     ok(info.BaseAddress == ptr, "wrong BaseAddress %p/%p\n", ptr, info.BaseAddress);
     ok(info.AllocationBase == ptr, "wrong AllocationBase %p/%p\n", ptr, info.AllocationBase);
-    ok(info.RegionSize == MAPPING_SIZE, "wrong RegionSize 0x%lx\n", info.RegionSize);
-    ok(info.State == MEM_COMMIT, "wrong State 0x%x\n", info.State);
-    ok(info.AllocationProtect == PAGE_READWRITE, "wrong AllocationProtect 0x%x\n", info.AllocationProtect);
-    ok(info.Protect == PAGE_READWRITE, "wrong Protect 0x%x\n", info.Protect);
-    ok(info.Type == MEM_MAPPED, "wrong Type 0x%x\n", info.Type);
+    ok(info.RegionSize == MAPPING_SIZE, "wrong RegionSize 0x%Ix\n", info.RegionSize);
+    ok(info.State == MEM_COMMIT, "wrong State 0x%lx\n", info.State);
+    ok(info.AllocationProtect == PAGE_READWRITE, "wrong AllocationProtect 0x%lx\n", info.AllocationProtect);
+    ok(info.Protect == PAGE_READWRITE, "wrong Protect 0x%lx\n", info.Protect);
+    ok(info.Type == MEM_MAPPED, "wrong Type 0x%lx\n", info.Type);
 
     ptr = VirtualAlloc(ptr, 0x10000, MEM_COMMIT, PAGE_READONLY);
-    ok(ptr != NULL, "VirtualAlloc failed with error %d\n", GetLastError());
+    ok(ptr != NULL, "VirtualAlloc failed with error %ld\n", GetLastError());
 
     ret = VirtualQuery(ptr, &info, sizeof(info));
-    ok(ret, "VirtualQuery failed with error %d\n", GetLastError());
+    ok(ret, "VirtualQuery failed with error %ld\n", GetLastError());
     ok(info.BaseAddress == ptr, "wrong BaseAddress %p/%p\n", ptr, info.BaseAddress);
     ok(info.AllocationBase == ptr, "wrong AllocationBase %p/%p\n", ptr, info.AllocationBase);
-    ok(info.RegionSize == 0x10000, "wrong RegionSize 0x%lx\n", info.RegionSize);
-    ok(info.State == MEM_COMMIT, "wrong State 0x%x\n", info.State);
-    ok(info.AllocationProtect == PAGE_READWRITE, "wrong AllocationProtect 0x%x\n", info.AllocationProtect);
-    ok(info.Protect == PAGE_READONLY, "wrong Protect 0x%x\n", info.Protect);
-    ok(info.Type == MEM_MAPPED, "wrong Type 0x%x\n", info.Type);
+    ok(info.RegionSize == 0x10000, "wrong RegionSize 0x%Ix\n", info.RegionSize);
+    ok(info.State == MEM_COMMIT, "wrong State 0x%lx\n", info.State);
+    ok(info.AllocationProtect == PAGE_READWRITE, "wrong AllocationProtect 0x%lx\n", info.AllocationProtect);
+    ok(info.Protect == PAGE_READONLY, "wrong Protect 0x%lx\n", info.Protect);
+    ok(info.Type == MEM_MAPPED, "wrong Type 0x%lx\n", info.Type);
 
     addr = VirtualAlloc( ptr, MAPPING_SIZE, MEM_RESET, PAGE_READONLY );
-    ok( addr == ptr, "VirtualAlloc failed with error %u\n", GetLastError() );
+    ok( addr == ptr, "VirtualAlloc failed with error %lu\n", GetLastError() );
 
     ret = VirtualFree( ptr, 0x10000, MEM_DECOMMIT );
     ok( !ret, "VirtualFree succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "VirtualFree failed with %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "VirtualFree failed with %lu\n", GetLastError() );
 
     ret = UnmapViewOfFile(ptr);
-    ok(ret, "UnmapViewOfFile failed with error %d\n", GetLastError());
+    ok(ret, "UnmapViewOfFile failed with error %ld\n", GetLastError());
     CloseHandle(mapping);
 
     /* same thing with SEC_NOCACHE (only supported on recent Windows versions) */
     mapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE | SEC_COMMIT | SEC_NOCACHE,
                                  0, MAPPING_SIZE, NULL);
-    ok(mapping != 0, "CreateFileMappingA failed with error %d\n", GetLastError());
+    ok(mapping != 0, "CreateFileMappingA failed with error %ld\n", GetLastError());
     status = pNtQuerySection( mapping, SectionBasicInformation, &section_info,
                               sizeof(section_info), NULL );
-    ok( !status, "NtQuerySection failed err %x\n", status );
+    ok( !status, "NtQuerySection failed err %lx\n", status );
     ok( section_info.Attributes == (SEC_COMMIT | SEC_NOCACHE) ||
         broken(section_info.Attributes == SEC_COMMIT),
-        "NtQuerySection wrong attr %08x\n", section_info.Attributes );
+        "NtQuerySection wrong attr %08lx\n", section_info.Attributes );
     if (section_info.Attributes & SEC_NOCACHE)
     {
         ptr = MapViewOfFile(mapping, FILE_MAP_WRITE, 0, 0, 0);
-        ok(ptr != NULL, "MapViewOfFile failed with error %d\n", GetLastError());
+        ok(ptr != NULL, "MapViewOfFile failed with error %ld\n", GetLastError());
 
         ret = VirtualQuery(ptr, &info, sizeof(info));
-        ok(ret, "VirtualQuery failed with error %d\n", GetLastError());
+        ok(ret, "VirtualQuery failed with error %ld\n", GetLastError());
         ok(info.BaseAddress == ptr, "wrong BaseAddress %p/%p\n", ptr, info.BaseAddress);
         ok(info.AllocationBase == ptr, "wrong AllocationBase %p/%p\n", ptr, info.AllocationBase);
-        ok(info.RegionSize == MAPPING_SIZE, "wrong RegionSize 0x%lx\n", info.RegionSize);
-        ok(info.State == MEM_COMMIT, "wrong State 0x%x\n", info.State);
+        ok(info.RegionSize == MAPPING_SIZE, "wrong RegionSize 0x%Ix\n", info.RegionSize);
+        ok(info.State == MEM_COMMIT, "wrong State 0x%lx\n", info.State);
         ok(info.AllocationProtect == (PAGE_READWRITE | PAGE_NOCACHE),
-           "wrong AllocationProtect 0x%x\n", info.AllocationProtect);
-        ok(info.Protect == (PAGE_READWRITE | PAGE_NOCACHE), "wrong Protect 0x%x\n", info.Protect);
-        ok(info.Type == MEM_MAPPED, "wrong Type 0x%x\n", info.Type);
+           "wrong AllocationProtect 0x%lx\n", info.AllocationProtect);
+        ok(info.Protect == (PAGE_READWRITE | PAGE_NOCACHE), "wrong Protect 0x%lx\n", info.Protect);
+        ok(info.Type == MEM_MAPPED, "wrong Type 0x%lx\n", info.Type);
 
         ptr = VirtualAlloc(ptr, 0x10000, MEM_COMMIT, PAGE_READONLY);
-        ok(ptr != NULL, "VirtualAlloc failed with error %d\n", GetLastError());
+        ok(ptr != NULL, "VirtualAlloc failed with error %ld\n", GetLastError());
 
         ret = VirtualQuery(ptr, &info, sizeof(info));
-        ok(ret, "VirtualQuery failed with error %d\n", GetLastError());
+        ok(ret, "VirtualQuery failed with error %ld\n", GetLastError());
         ok(info.BaseAddress == ptr, "wrong BaseAddress %p/%p\n", ptr, info.BaseAddress);
         ok(info.AllocationBase == ptr, "wrong AllocationBase %p/%p\n", ptr, info.AllocationBase);
-        ok(info.RegionSize == 0x10000, "wrong RegionSize 0x%lx\n", info.RegionSize);
-        ok(info.State == MEM_COMMIT, "wrong State 0x%x\n", info.State);
+        ok(info.RegionSize == 0x10000, "wrong RegionSize 0x%Ix\n", info.RegionSize);
+        ok(info.State == MEM_COMMIT, "wrong State 0x%lx\n", info.State);
         ok(info.AllocationProtect == (PAGE_READWRITE | PAGE_NOCACHE),
-           "wrong AllocationProtect 0x%x\n", info.AllocationProtect);
-        ok(info.Protect == (PAGE_READONLY | PAGE_NOCACHE), "wrong Protect 0x%x\n", info.Protect);
-        ok(info.Type == MEM_MAPPED, "wrong Type 0x%x\n", info.Type);
+           "wrong AllocationProtect 0x%lx\n", info.AllocationProtect);
+        ok(info.Protect == (PAGE_READONLY | PAGE_NOCACHE), "wrong Protect 0x%lx\n", info.Protect);
+        ok(info.Type == MEM_MAPPED, "wrong Type 0x%lx\n", info.Type);
 
         ret = UnmapViewOfFile(ptr);
-        ok(ret, "UnmapViewOfFile failed with error %d\n", GetLastError());
+        ok(ret, "UnmapViewOfFile failed with error %ld\n", GetLastError());
     }
     CloseHandle(mapping);
 
     addr = VirtualAlloc(NULL, 0x10000, MEM_COMMIT, PAGE_READONLY );
-    ok( addr != NULL, "VirtualAlloc failed with error %u\n", GetLastError() );
+    ok( addr != NULL, "VirtualAlloc failed with error %lu\n", GetLastError() );
 
     SetLastError(0xdeadbeef);
     ok( !UnmapViewOfFile(addr), "UnmapViewOfFile should fail on VirtualAlloc mem\n" );
     ok( GetLastError() == ERROR_INVALID_ADDRESS,
-        "got %u, expected ERROR_INVALID_ADDRESS\n", GetLastError());
+        "got %lu, expected ERROR_INVALID_ADDRESS\n", GetLastError());
     SetLastError(0xdeadbeef);
     ok( !UnmapViewOfFile((char *)addr + 0x3000), "UnmapViewOfFile should fail on VirtualAlloc mem\n" );
     ok( GetLastError() == ERROR_INVALID_ADDRESS,
-        "got %u, expected ERROR_INVALID_ADDRESS\n", GetLastError());
+        "got %lu, expected ERROR_INVALID_ADDRESS\n", GetLastError());
     SetLastError(0xdeadbeef);
     ok( !UnmapViewOfFile((void *)0xdeadbeef), "UnmapViewOfFile should fail on VirtualAlloc mem\n" );
     ok( GetLastError() == ERROR_INVALID_ADDRESS,
-       "got %u, expected ERROR_INVALID_ADDRESS\n", GetLastError());
+       "got %lu, expected ERROR_INVALID_ADDRESS\n", GetLastError());
 
     ok( VirtualFree(addr, 0, MEM_RELEASE), "VirtualFree failed\n" );
 
@@ -968,268 +968,268 @@ static void test_MapViewOfFile(void)
     name = "Foo";
     SetLastError(0xdeadbeef);
     mapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, MAPPING_SIZE, name);
-    ok( mapping != 0, "CreateFileMappingA failed with error %d\n", GetLastError() );
+    ok( mapping != 0, "CreateFileMappingA failed with error %ld\n", GetLastError() );
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile(mapping, FILE_MAP_WRITE, 0, 0, 0);
-    ok( ptr != NULL, "MapViewOfFile failed with error %d\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile failed with error %ld\n", GetLastError() );
     SetLastError(0xdeadbeef);
     map2 = OpenFileMappingA(FILE_MAP_READ, FALSE, name);
-    ok( map2 != 0, "OpenFileMappingA failed with error %d\n", GetLastError() );
+    ok( map2 != 0, "OpenFileMappingA failed with error %ld\n", GetLastError() );
     SetLastError(0xdeadbeef);
     ret = CloseHandle(map2);
-    ok(ret, "CloseHandle error %d\n", GetLastError());
+    ok(ret, "CloseHandle error %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CloseHandle(mapping);
-    ok(ret, "CloseHandle error %d\n", GetLastError());
+    ok(ret, "CloseHandle error %ld\n", GetLastError());
 
     ret = IsBadReadPtr(ptr, MAPPING_SIZE);
     ok( !ret, "memory is not accessible\n" );
 
     ret = VirtualQuery(ptr, &info, sizeof(info));
-    ok(ret, "VirtualQuery error %d\n", GetLastError());
+    ok(ret, "VirtualQuery error %ld\n", GetLastError());
     ok(info.BaseAddress == ptr, "got %p != expected %p\n", info.BaseAddress, ptr);
-    ok(info.RegionSize == MAPPING_SIZE, "got %#lx != expected %#x\n", info.RegionSize, MAPPING_SIZE);
-    ok(info.Protect == PAGE_READWRITE, "got %#x != expected PAGE_READWRITE\n", info.Protect);
+    ok(info.RegionSize == MAPPING_SIZE, "got %#Ix != expected %#x\n", info.RegionSize, MAPPING_SIZE);
+    ok(info.Protect == PAGE_READWRITE, "got %#lx != expected PAGE_READWRITE\n", info.Protect);
     ok(info.AllocationBase == ptr, "%p != %p\n", info.AllocationBase, ptr);
-    ok(info.AllocationProtect == PAGE_READWRITE, "%#x != PAGE_READWRITE\n", info.AllocationProtect);
-    ok(info.State == MEM_COMMIT, "%#x != MEM_COMMIT\n", info.State);
-    ok(info.Type == MEM_MAPPED, "%#x != MEM_MAPPED\n", info.Type);
+    ok(info.AllocationProtect == PAGE_READWRITE, "%#lx != PAGE_READWRITE\n", info.AllocationProtect);
+    ok(info.State == MEM_COMMIT, "%#lx != MEM_COMMIT\n", info.State);
+    ok(info.Type == MEM_MAPPED, "%#lx != MEM_MAPPED\n", info.Type);
 
     SetLastError(0xdeadbeef);
     map2 = OpenFileMappingA(FILE_MAP_READ, FALSE, name);
     ok( map2 == 0, "OpenFileMappingA succeeded\n" );
-    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "OpenFileMappingA set error %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "OpenFileMappingA set error %ld\n", GetLastError() );
     if (map2) CloseHandle(map2); /* FIXME: remove once Wine is fixed */
     SetLastError(0xdeadbeef);
     mapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, MAPPING_SIZE, name);
     ok( mapping != 0, "CreateFileMappingA failed\n" );
-    ok( GetLastError() == ERROR_SUCCESS, "CreateFileMappingA set error %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_SUCCESS, "CreateFileMappingA set error %ld\n", GetLastError() );
     SetLastError(0xdeadbeef);
     ret = CloseHandle(mapping);
-    ok(ret, "CloseHandle error %d\n", GetLastError());
+    ok(ret, "CloseHandle error %ld\n", GetLastError());
 
     ret = IsBadReadPtr(ptr, MAPPING_SIZE);
     ok( !ret, "memory is not accessible\n" );
 
     ret = VirtualQuery(ptr, &info, sizeof(info));
-    ok(ret, "VirtualQuery error %d\n", GetLastError());
+    ok(ret, "VirtualQuery error %ld\n", GetLastError());
     ok(info.BaseAddress == ptr, "got %p != expected %p\n", info.BaseAddress, ptr);
-    ok(info.RegionSize == MAPPING_SIZE, "got %#lx != expected %#x\n", info.RegionSize, MAPPING_SIZE);
-    ok(info.Protect == PAGE_READWRITE, "got %#x != expected PAGE_READWRITE\n", info.Protect);
+    ok(info.RegionSize == MAPPING_SIZE, "got %#Ix != expected %#x\n", info.RegionSize, MAPPING_SIZE);
+    ok(info.Protect == PAGE_READWRITE, "got %#lx != expected PAGE_READWRITE\n", info.Protect);
     ok(info.AllocationBase == ptr, "%p != %p\n", info.AllocationBase, ptr);
-    ok(info.AllocationProtect == PAGE_READWRITE, "%#x != PAGE_READWRITE\n", info.AllocationProtect);
-    ok(info.State == MEM_COMMIT, "%#x != MEM_COMMIT\n", info.State);
-    ok(info.Type == MEM_MAPPED, "%#x != MEM_MAPPED\n", info.Type);
+    ok(info.AllocationProtect == PAGE_READWRITE, "%#lx != PAGE_READWRITE\n", info.AllocationProtect);
+    ok(info.State == MEM_COMMIT, "%#lx != MEM_COMMIT\n", info.State);
+    ok(info.Type == MEM_MAPPED, "%#lx != MEM_MAPPED\n", info.Type);
 
     SetLastError(0xdeadbeef);
     ret = UnmapViewOfFile(ptr);
-    ok( ret, "UnmapViewOfFile failed with error %d\n", GetLastError() );
+    ok( ret, "UnmapViewOfFile failed with error %ld\n", GetLastError() );
 
     ret = IsBadReadPtr(ptr, MAPPING_SIZE);
     ok( ret, "memory is accessible\n" );
 
     ret = VirtualQuery(ptr, &info, sizeof(info));
-    ok(ret, "VirtualQuery error %d\n", GetLastError());
+    ok(ret, "VirtualQuery error %ld\n", GetLastError());
     ok(info.BaseAddress == ptr, "got %p != expected %p\n", info.BaseAddress, ptr);
-    ok(info.Protect == PAGE_NOACCESS, "got %#x != expected PAGE_NOACCESS\n", info.Protect);
+    ok(info.Protect == PAGE_NOACCESS, "got %#lx != expected PAGE_NOACCESS\n", info.Protect);
     ok(info.AllocationBase == NULL, "%p != NULL\n", info.AllocationBase);
-    ok(info.AllocationProtect == 0, "%#x != 0\n", info.AllocationProtect);
-    ok(info.State == MEM_FREE, "%#x != MEM_FREE\n", info.State);
-    ok(info.Type == 0, "%#x != 0\n", info.Type);
+    ok(info.AllocationProtect == 0, "%#lx != 0\n", info.AllocationProtect);
+    ok(info.State == MEM_FREE, "%#lx != MEM_FREE\n", info.State);
+    ok(info.Type == 0, "%#lx != 0\n", info.Type);
 
     SetLastError(0xdeadbeef);
     file = CreateFileA(testfile, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
-    ok( file != INVALID_HANDLE_VALUE, "CreateFile error %u\n", GetLastError() );
+    ok( file != INVALID_HANDLE_VALUE, "CreateFile error %lu\n", GetLastError() );
     SetFilePointer(file, 4096, NULL, FILE_BEGIN);
     SetEndOfFile(file);
 
     SetLastError(0xdeadbeef);
     mapping = CreateFileMappingA(file, NULL, PAGE_READWRITE, 0, MAPPING_SIZE, name);
-    ok( mapping != 0, "CreateFileMappingA failed with error %d\n", GetLastError() );
+    ok( mapping != 0, "CreateFileMappingA failed with error %ld\n", GetLastError() );
     SetLastError(0xdeadbeef);
     ptr = MapViewOfFile(mapping, FILE_MAP_WRITE, 0, 0, 0);
-    ok( ptr != NULL, "MapViewOfFile failed with error %d\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile failed with error %ld\n", GetLastError() );
     SetLastError(0xdeadbeef);
     map2 = OpenFileMappingA(FILE_MAP_READ, FALSE, name);
-    ok( map2 != 0, "OpenFileMappingA failed with error %d\n", GetLastError() );
+    ok( map2 != 0, "OpenFileMappingA failed with error %ld\n", GetLastError() );
     SetLastError(0xdeadbeef);
     ret = CloseHandle(map2);
-    ok(ret, "CloseHandle error %d\n", GetLastError());
+    ok(ret, "CloseHandle error %ld\n", GetLastError());
     status = pNtQuerySection( mapping, SectionBasicInformation, &section_info,
                               sizeof(section_info), &info_size );
-    ok( !status, "NtQuerySection failed err %x\n", status );
-    ok( info_size == sizeof(section_info), "NtQuerySection wrong size %lu\n", info_size );
-    ok( section_info.Attributes == SEC_FILE, "NtQuerySection wrong attr %08x\n",
+    ok( !status, "NtQuerySection failed err %lx\n", status );
+    ok( info_size == sizeof(section_info), "NtQuerySection wrong size %Iu\n", info_size );
+    ok( section_info.Attributes == SEC_FILE, "NtQuerySection wrong attr %08lx\n",
         section_info.Attributes );
     ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", section_info.BaseAddress );
-    ok( section_info.Size.QuadPart == MAPPING_SIZE, "NtQuerySection wrong size %x%08x\n",
+    ok( section_info.Size.QuadPart == MAPPING_SIZE, "NtQuerySection wrong size %lx%08lx\n",
         section_info.Size.u.HighPart, section_info.Size.u.LowPart );
     SetLastError(0xdeadbeef);
     ret = CloseHandle(mapping);
-    ok(ret, "CloseHandle error %d\n", GetLastError());
+    ok(ret, "CloseHandle error %ld\n", GetLastError());
 
     ret = IsBadReadPtr(ptr, MAPPING_SIZE);
     ok( !ret, "memory is not accessible\n" );
 
     ret = VirtualQuery(ptr, &info, sizeof(info));
-    ok(ret, "VirtualQuery error %d\n", GetLastError());
+    ok(ret, "VirtualQuery error %ld\n", GetLastError());
     ok(info.BaseAddress == ptr, "got %p != expected %p\n", info.BaseAddress, ptr);
-    ok(info.RegionSize == MAPPING_SIZE, "got %#lx != expected %#x\n", info.RegionSize, MAPPING_SIZE);
-    ok(info.Protect == PAGE_READWRITE, "got %#x != expected PAGE_READWRITE\n", info.Protect);
+    ok(info.RegionSize == MAPPING_SIZE, "got %#Ix != expected %#x\n", info.RegionSize, MAPPING_SIZE);
+    ok(info.Protect == PAGE_READWRITE, "got %#lx != expected PAGE_READWRITE\n", info.Protect);
     ok(info.AllocationBase == ptr, "%p != %p\n", info.AllocationBase, ptr);
-    ok(info.AllocationProtect == PAGE_READWRITE, "%#x != PAGE_READWRITE\n", info.AllocationProtect);
-    ok(info.State == MEM_COMMIT, "%#x != MEM_COMMIT\n", info.State);
-    ok(info.Type == MEM_MAPPED, "%#x != MEM_MAPPED\n", info.Type);
+    ok(info.AllocationProtect == PAGE_READWRITE, "%#lx != PAGE_READWRITE\n", info.AllocationProtect);
+    ok(info.State == MEM_COMMIT, "%#lx != MEM_COMMIT\n", info.State);
+    ok(info.Type == MEM_MAPPED, "%#lx != MEM_MAPPED\n", info.Type);
 
     SetLastError(0xdeadbeef);
     map2 = OpenFileMappingA(FILE_MAP_READ, FALSE, name);
     ok( map2 == 0, "OpenFileMappingA succeeded\n" );
-    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "OpenFileMappingA set error %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "OpenFileMappingA set error %ld\n", GetLastError() );
     CloseHandle(map2);
     SetLastError(0xdeadbeef);
     mapping = CreateFileMappingA(file, NULL, PAGE_READWRITE, 0, MAPPING_SIZE, name);
     ok( mapping != 0, "CreateFileMappingA failed\n" );
-    ok( GetLastError() == ERROR_SUCCESS, "CreateFileMappingA set error %d\n", GetLastError() );
+    ok( GetLastError() == ERROR_SUCCESS, "CreateFileMappingA set error %ld\n", GetLastError() );
     SetLastError(0xdeadbeef);
     ret = CloseHandle(mapping);
-    ok(ret, "CloseHandle error %d\n", GetLastError());
+    ok(ret, "CloseHandle error %ld\n", GetLastError());
 
     ret = IsBadReadPtr(ptr, MAPPING_SIZE);
     ok( !ret, "memory is not accessible\n" );
 
     ret = VirtualQuery(ptr, &info, sizeof(info));
-    ok(ret, "VirtualQuery error %d\n", GetLastError());
+    ok(ret, "VirtualQuery error %ld\n", GetLastError());
     ok(info.BaseAddress == ptr, "got %p != expected %p\n", info.BaseAddress, ptr);
-    ok(info.RegionSize == MAPPING_SIZE, "got %#lx != expected %#x\n", info.RegionSize, MAPPING_SIZE);
-    ok(info.Protect == PAGE_READWRITE, "got %#x != expected PAGE_READWRITE\n", info.Protect);
+    ok(info.RegionSize == MAPPING_SIZE, "got %#Ix != expected %#x\n", info.RegionSize, MAPPING_SIZE);
+    ok(info.Protect == PAGE_READWRITE, "got %#lx != expected PAGE_READWRITE\n", info.Protect);
     ok(info.AllocationBase == ptr, "%p != %p\n", info.AllocationBase, ptr);
-    ok(info.AllocationProtect == PAGE_READWRITE, "%#x != PAGE_READWRITE\n", info.AllocationProtect);
-    ok(info.State == MEM_COMMIT, "%#x != MEM_COMMIT\n", info.State);
-    ok(info.Type == MEM_MAPPED, "%#x != MEM_MAPPED\n", info.Type);
+    ok(info.AllocationProtect == PAGE_READWRITE, "%#lx != PAGE_READWRITE\n", info.AllocationProtect);
+    ok(info.State == MEM_COMMIT, "%#lx != MEM_COMMIT\n", info.State);
+    ok(info.Type == MEM_MAPPED, "%#lx != MEM_MAPPED\n", info.Type);
 
     SetLastError(0xdeadbeef);
     ret = UnmapViewOfFile(ptr);
-    ok( ret, "UnmapViewOfFile failed with error %d\n", GetLastError() );
+    ok( ret, "UnmapViewOfFile failed with error %ld\n", GetLastError() );
 
     ret = IsBadReadPtr(ptr, MAPPING_SIZE);
     ok( ret, "memory is accessible\n" );
 
     ret = VirtualQuery(ptr, &info, sizeof(info));
-    ok(ret, "VirtualQuery error %d\n", GetLastError());
+    ok(ret, "VirtualQuery error %ld\n", GetLastError());
     ok(info.BaseAddress == ptr, "got %p != expected %p\n", info.BaseAddress, ptr);
-    ok(info.Protect == PAGE_NOACCESS, "got %#x != expected PAGE_NOACCESS\n", info.Protect);
+    ok(info.Protect == PAGE_NOACCESS, "got %#lx != expected PAGE_NOACCESS\n", info.Protect);
     ok(info.AllocationBase == NULL, "%p != NULL\n", info.AllocationBase);
-    ok(info.AllocationProtect == 0, "%#x != 0\n", info.AllocationProtect);
-    ok(info.State == MEM_FREE, "%#x != MEM_FREE\n", info.State);
-    ok(info.Type == 0, "%#x != 0\n", info.Type);
+    ok(info.AllocationProtect == 0, "%#lx != 0\n", info.AllocationProtect);
+    ok(info.State == MEM_FREE, "%#lx != MEM_FREE\n", info.State);
+    ok(info.Type == 0, "%#lx != 0\n", info.Type);
 
     mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 12288, NULL );
-    ok( mapping != NULL, "CreateFileMappingA failed with error %u\n", GetLastError() );
+    ok( mapping != NULL, "CreateFileMappingA failed with error %lu\n", GetLastError() );
 
     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 12288 );
-    ok( ptr != NULL, "MapViewOfFile failed with error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile failed with error %lu\n", GetLastError() );
 
     ret = UnmapViewOfFile( (char *)ptr + 100 );
-    ok( ret, "UnmapViewOfFile failed with error %u\n", GetLastError() );
+    ok( ret, "UnmapViewOfFile failed with error %lu\n", GetLastError() );
 
     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 12288 );
-    ok( ptr != NULL, "MapViewOfFile failed with error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile failed with error %lu\n", GetLastError() );
 
     ret = UnmapViewOfFile( (char *)ptr + 4096 );
-    ok( ret, "UnmapViewOfFile failed with error %u\n", GetLastError() );
+    ok( ret, "UnmapViewOfFile failed with error %lu\n", GetLastError() );
 
     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 12288 );
-    ok( ptr != NULL, "MapViewOfFile failed with error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile failed with error %lu\n", GetLastError() );
 
     ret = UnmapViewOfFile( (char *)ptr + 4096 + 100 );
-    ok( ret, "UnmapViewOfFile failed with error %u\n", GetLastError() );
+    ok( ret, "UnmapViewOfFile failed with error %lu\n", GetLastError() );
 
     CloseHandle(mapping);
 
     mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 36, NULL );
-    ok( mapping != NULL, "CreateFileMappingA failed with error %u\n", GetLastError() );
+    ok( mapping != NULL, "CreateFileMappingA failed with error %lu\n", GetLastError() );
     status = pNtQuerySection( mapping, SectionBasicInformation, &section_info,
                               sizeof(section_info), &info_size );
-    ok( !status, "NtQuerySection failed err %x\n", status );
-    ok( info_size == sizeof(section_info), "NtQuerySection wrong size %lu\n", info_size );
-    ok( section_info.Attributes == SEC_FILE, "NtQuerySection wrong attr %08x\n",
+    ok( !status, "NtQuerySection failed err %lx\n", status );
+    ok( info_size == sizeof(section_info), "NtQuerySection wrong size %Iu\n", info_size );
+    ok( section_info.Attributes == SEC_FILE, "NtQuerySection wrong attr %08lx\n",
         section_info.Attributes );
     ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", section_info.BaseAddress );
-    ok( section_info.Size.QuadPart == 36, "NtQuerySection wrong size %x%08x\n",
+    ok( section_info.Size.QuadPart == 36, "NtQuerySection wrong size %lx%08lx\n",
         section_info.Size.u.HighPart, section_info.Size.u.LowPart );
     CloseHandle(mapping);
 
     SetFilePointer(file, 0x3456, NULL, FILE_BEGIN);
     SetEndOfFile(file);
     mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 0, NULL );
-    ok( mapping != NULL, "CreateFileMappingA failed with error %u\n", GetLastError() );
+    ok( mapping != NULL, "CreateFileMappingA failed with error %lu\n", GetLastError() );
     status = pNtQuerySection( mapping, SectionBasicInformation, &section_info,
                               sizeof(section_info), &info_size );
-    ok( !status, "NtQuerySection failed err %x\n", status );
-    ok( info_size == sizeof(section_info), "NtQuerySection wrong size %lu\n", info_size );
-    ok( section_info.Attributes == SEC_FILE, "NtQuerySection wrong attr %08x\n",
+    ok( !status, "NtQuerySection failed err %lx\n", status );
+    ok( info_size == sizeof(section_info), "NtQuerySection wrong size %Iu\n", info_size );
+    ok( section_info.Attributes == SEC_FILE, "NtQuerySection wrong attr %08lx\n",
         section_info.Attributes );
     ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", section_info.BaseAddress );
-    ok( section_info.Size.QuadPart == 0x3456, "NtQuerySection wrong size %x%08x\n",
+    ok( section_info.Size.QuadPart == 0x3456, "NtQuerySection wrong size %lx%08lx\n",
         section_info.Size.u.HighPart, section_info.Size.u.LowPart );
     CloseHandle(mapping);
 
     map_size.QuadPart = 0x3457;
     status = pNtCreateSection( &mapping, SECTION_QUERY | SECTION_MAP_READ, NULL,
                                &map_size, PAGE_READONLY, SEC_COMMIT, file );
-    ok( status == STATUS_SECTION_TOO_BIG, "NtCreateSection failed %x\n", status );
+    ok( status == STATUS_SECTION_TOO_BIG, "NtCreateSection failed %lx\n", status );
     status = pNtCreateSection( &mapping, SECTION_QUERY | SECTION_MAP_READ, NULL,
                                &map_size, PAGE_READONLY, SEC_IMAGE, file );
-    ok( status == STATUS_INVALID_IMAGE_NOT_MZ, "NtCreateSection failed %x\n", status );
+    ok( status == STATUS_INVALID_IMAGE_NOT_MZ, "NtCreateSection failed %lx\n", status );
     if (!status) CloseHandle( mapping );
     map_size.QuadPart = 0x3452;
     status = pNtCreateSection( &mapping, SECTION_QUERY | SECTION_MAP_READ, NULL,
                                &map_size, PAGE_READONLY, SEC_COMMIT, file );
-    ok( !status, "NtCreateSection failed %x\n", status );
+    ok( !status, "NtCreateSection failed %lx\n", status );
     status = pNtQuerySection( mapping, SectionBasicInformation, &section_info, sizeof(section_info), NULL );
-    ok( !status, "NtQuerySection failed err %x\n", status );
-    ok( section_info.Attributes == SEC_FILE, "NtQuerySection wrong attr %08x\n",
+    ok( !status, "NtQuerySection failed err %lx\n", status );
+    ok( section_info.Attributes == SEC_FILE, "NtQuerySection wrong attr %08lx\n",
         section_info.Attributes );
     ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", section_info.BaseAddress );
-    ok( section_info.Size.QuadPart == 0x3452, "NtQuerySection wrong size %x%08x\n",
+    ok( section_info.Size.QuadPart == 0x3452, "NtQuerySection wrong size %lx%08lx\n",
         section_info.Size.u.HighPart, section_info.Size.u.LowPart );
     size = map_size.QuadPart;
     status = pNtMapViewOfSection( mapping, GetCurrentProcess(), &ptr, 0, 0, NULL,
                                   &size, ViewShare, 0, PAGE_READONLY );
-    ok( !status, "NtMapViewOfSection failed err %x\n", status );
+    ok( !status, "NtMapViewOfSection failed err %lx\n", status );
     pNtUnmapViewOfSection( GetCurrentProcess(), ptr );
     size = map_size.QuadPart + 1;
     status = pNtMapViewOfSection( mapping, GetCurrentProcess(), &ptr, 0, 0, NULL,
                                   &size, ViewShare, 0, PAGE_READONLY );
-    ok( status == STATUS_INVALID_VIEW_SIZE, "NtMapViewOfSection failed err %x\n", status );
+    ok( status == STATUS_INVALID_VIEW_SIZE, "NtMapViewOfSection failed err %lx\n", status );
     CloseHandle(mapping);
 
     status = pNtCreateSection( &mapping, SECTION_QUERY | SECTION_MAP_READ, NULL,
                                &map_size, PAGE_READONLY, SEC_COMMIT, 0 );
-    ok( !status, "NtCreateSection failed %x\n", status );
+    ok( !status, "NtCreateSection failed %lx\n", status );
     status = pNtQuerySection( mapping, SectionBasicInformation, &section_info, sizeof(section_info), NULL );
-    ok( !status, "NtQuerySection failed err %x\n", status );
-    ok( section_info.Attributes == SEC_COMMIT, "NtQuerySection wrong attr %08x\n",
+    ok( !status, "NtQuerySection failed err %lx\n", status );
+    ok( section_info.Attributes == SEC_COMMIT, "NtQuerySection wrong attr %08lx\n",
         section_info.Attributes );
     ok( section_info.BaseAddress == NULL, "NtQuerySection wrong base %p\n", section_info.BaseAddress );
-    ok( section_info.Size.QuadPart == 0x4000, "NtQuerySection wrong size %x%08x\n",
+    ok( section_info.Size.QuadPart == 0x4000, "NtQuerySection wrong size %lx%08lx\n",
         section_info.Size.u.HighPart, section_info.Size.u.LowPart );
     status = pNtQuerySection( mapping, SectionBasicInformation, &section_info, sizeof(section_info)-1, NULL );
-    ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQuerySection failed err %x\n", status );
+    ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQuerySection failed err %lx\n", status );
     status = pNtQuerySection( mapping, SectionBasicInformation, &section_info, sizeof(section_info)+1, NULL );
-    ok( !status, "NtQuerySection failed err %x\n", status );
+    ok( !status, "NtQuerySection failed err %lx\n", status );
     status = pNtQuerySection( mapping, SectionImageInformation, &image_info, sizeof(image_info)-1, NULL );
-    ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQuerySection failed err %x\n", status );
+    ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQuerySection failed err %lx\n", status );
     status = pNtQuerySection( mapping, SectionImageInformation, &image_info, sizeof(image_info), NULL );
-    ok( status == STATUS_SECTION_NOT_IMAGE, "NtQuerySection failed err %x\n", status );
+    ok( status == STATUS_SECTION_NOT_IMAGE, "NtQuerySection failed err %lx\n", status );
     status = pNtQuerySection( mapping, SectionImageInformation, &image_info, sizeof(image_info)+1, NULL );
-    ok( status == STATUS_SECTION_NOT_IMAGE, "NtQuerySection failed err %x\n", status );
+    ok( status == STATUS_SECTION_NOT_IMAGE, "NtQuerySection failed err %lx\n", status );
     if (sizeof(SIZE_T) > sizeof(int))
     {
         status = pNtQuerySection( mapping, SectionImageInformation, &image_info,
                                   sizeof(image_info) + ((SIZE_T)0x10000000 << 8), NULL );
         todo_wine
-        ok( status == STATUS_ACCESS_VIOLATION, "NtQuerySection wrong err %x\n", status );
+        ok( status == STATUS_ACCESS_VIOLATION, "NtQuerySection wrong err %lx\n", status );
     }
     CloseHandle(mapping);
 
@@ -1237,10 +1237,10 @@ static void test_MapViewOfFile(void)
     SetEndOfFile(file);
     status = pNtCreateSection( &mapping, SECTION_QUERY | SECTION_MAP_READ, NULL,
                                NULL, PAGE_READONLY, SEC_COMMIT, file );
-    ok( status == STATUS_MAPPED_FILE_SIZE_ZERO, "NtCreateSection failed %x\n", status );
+    ok( status == STATUS_MAPPED_FILE_SIZE_ZERO, "NtCreateSection failed %lx\n", status );
     status = pNtCreateSection( &mapping, SECTION_QUERY | SECTION_MAP_READ, NULL,
                                NULL, PAGE_READONLY, SEC_IMAGE, file );
-    ok( status == STATUS_INVALID_FILE_FOR_SECTION, "NtCreateSection failed %x\n", status );
+    ok( status == STATUS_INVALID_FILE_FOR_SECTION, "NtCreateSection failed %lx\n", status );
 
     CloseHandle(file);
     DeleteFileA(testfile);
@@ -1263,73 +1263,73 @@ static void test_NtAreMappedFilesTheSame(void)
 
     file = CreateFileA( testfile, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
                         NULL, CREATE_ALWAYS, 0, 0 );
-    ok( file != INVALID_HANDLE_VALUE, "CreateFile error %u\n", GetLastError() );
+    ok( file != INVALID_HANDLE_VALUE, "CreateFile error %lu\n", GetLastError() );
     SetFilePointer( file, 4096, NULL, FILE_BEGIN );
     SetEndOfFile( file );
 
     mapping = CreateFileMappingA( file, NULL, PAGE_READWRITE, 0, 4096, NULL );
-    ok( mapping != 0, "CreateFileMapping error %u\n", GetLastError() );
+    ok( mapping != 0, "CreateFileMapping error %lu\n", GetLastError() );
 
     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
-    ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %lu\n", GetLastError() );
 
     file2 = CreateFileA( testfile, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE,
                          NULL, OPEN_EXISTING, 0, 0 );
-    ok( file2 != INVALID_HANDLE_VALUE, "CreateFile error %u\n", GetLastError() );
+    ok( file2 != INVALID_HANDLE_VALUE, "CreateFile error %lu\n", GetLastError() );
 
     map2 = CreateFileMappingA( file2, NULL, PAGE_READONLY, 0, 4096, NULL );
-    ok( map2 != 0, "CreateFileMapping error %u\n", GetLastError() );
+    ok( map2 != 0, "CreateFileMapping error %lu\n", GetLastError() );
     ptr2 = MapViewOfFile( map2, FILE_MAP_READ, 0, 0, 4096 );
-    ok( ptr2 != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError() );
+    ok( ptr2 != NULL, "MapViewOfFile FILE_MAP_READ error %lu\n", GetLastError() );
     status = pNtAreMappedFilesTheSame( ptr, ptr2 );
-    ok( status == STATUS_NOT_SAME_DEVICE, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_NOT_SAME_DEVICE, "NtAreMappedFilesTheSame returned %lx\n", status );
     UnmapViewOfFile( ptr2 );
 
     ptr2 = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
-    ok( ptr2 != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError() );
+    ok( ptr2 != NULL, "MapViewOfFile FILE_MAP_READ error %lu\n", GetLastError() );
     status = pNtAreMappedFilesTheSame( ptr, ptr2 );
-    ok( status == STATUS_NOT_SAME_DEVICE, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_NOT_SAME_DEVICE, "NtAreMappedFilesTheSame returned %lx\n", status );
     UnmapViewOfFile( ptr2 );
     CloseHandle( map2 );
 
     map2 = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 4096, NULL );
-    ok( map2 != 0, "CreateFileMapping error %u\n", GetLastError() );
+    ok( map2 != 0, "CreateFileMapping error %lu\n", GetLastError() );
     ptr2 = MapViewOfFile( map2, FILE_MAP_READ, 0, 0, 4096 );
-    ok( ptr2 != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError() );
+    ok( ptr2 != NULL, "MapViewOfFile FILE_MAP_READ error %lu\n", GetLastError() );
     status = pNtAreMappedFilesTheSame( ptr, ptr2 );
-    ok( status == STATUS_NOT_SAME_DEVICE, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_NOT_SAME_DEVICE, "NtAreMappedFilesTheSame returned %lx\n", status );
     UnmapViewOfFile( ptr2 );
     CloseHandle( map2 );
     CloseHandle( file2 );
 
     status = pNtAreMappedFilesTheSame( ptr, ptr );
     ok( status == STATUS_SUCCESS || broken(status == STATUS_NOT_SAME_DEVICE),
-        "NtAreMappedFilesTheSame returned %x\n", status );
+        "NtAreMappedFilesTheSame returned %lx\n", status );
 
     status = pNtAreMappedFilesTheSame( ptr, (char *)ptr + 30 );
     ok( status == STATUS_SUCCESS || broken(status == STATUS_NOT_SAME_DEVICE),
-        "NtAreMappedFilesTheSame returned %x\n", status );
+        "NtAreMappedFilesTheSame returned %lx\n", status );
 
     status = pNtAreMappedFilesTheSame( ptr, GetModuleHandleA("kernel32.dll") );
-    ok( status == STATUS_NOT_SAME_DEVICE, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_NOT_SAME_DEVICE, "NtAreMappedFilesTheSame returned %lx\n", status );
 
     status = pNtAreMappedFilesTheSame( ptr, (void *)0xdeadbeef );
     ok( status == STATUS_CONFLICTING_ADDRESSES || status == STATUS_INVALID_ADDRESS,
-        "NtAreMappedFilesTheSame returned %x\n", status );
+        "NtAreMappedFilesTheSame returned %lx\n", status );
 
     status = pNtAreMappedFilesTheSame( ptr, NULL );
-    ok( status == STATUS_INVALID_ADDRESS, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_INVALID_ADDRESS, "NtAreMappedFilesTheSame returned %lx\n", status );
 
     status = pNtAreMappedFilesTheSame( ptr, (void *)GetProcessHeap() );
-    ok( status == STATUS_CONFLICTING_ADDRESSES, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_CONFLICTING_ADDRESSES, "NtAreMappedFilesTheSame returned %lx\n", status );
 
     status = pNtAreMappedFilesTheSame( NULL, NULL );
-    ok( status == STATUS_INVALID_ADDRESS, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_INVALID_ADDRESS, "NtAreMappedFilesTheSame returned %lx\n", status );
 
     ptr2 = VirtualAlloc( NULL, 0x10000, MEM_COMMIT, PAGE_READWRITE );
-    ok( ptr2 != NULL, "VirtualAlloc error %u\n", GetLastError() );
+    ok( ptr2 != NULL, "VirtualAlloc error %lu\n", GetLastError() );
     status = pNtAreMappedFilesTheSame( ptr, ptr2 );
-    ok( status == STATUS_CONFLICTING_ADDRESSES, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_CONFLICTING_ADDRESSES, "NtAreMappedFilesTheSame returned %lx\n", status );
     VirtualFree( ptr2, 0, MEM_RELEASE );
 
     UnmapViewOfFile( ptr );
@@ -1338,50 +1338,50 @@ static void test_NtAreMappedFilesTheSame(void)
 
     status = pNtAreMappedFilesTheSame( GetModuleHandleA("ntdll.dll"),
                                        GetModuleHandleA("kernel32.dll") );
-    ok( status == STATUS_NOT_SAME_DEVICE, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_NOT_SAME_DEVICE, "NtAreMappedFilesTheSame returned %lx\n", status );
     status = pNtAreMappedFilesTheSame( GetModuleHandleA("kernel32.dll"),
                                        GetModuleHandleA("kernel32.dll") );
-    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %lx\n", status );
     status = pNtAreMappedFilesTheSame( GetModuleHandleA("kernel32.dll"),
                                        (char *)GetModuleHandleA("kernel32.dll") + 4096 );
-    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %lx\n", status );
 
     GetSystemDirectoryA( path, MAX_PATH );
     strcat( path, "\\kernel32.dll" );
     file = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
-    ok( file != INVALID_HANDLE_VALUE, "CreateFile error %u\n", GetLastError() );
+    ok( file != INVALID_HANDLE_VALUE, "CreateFile error %lu\n", GetLastError() );
 
     mapping = CreateFileMappingA( file, NULL, PAGE_READONLY, 0, 4096, NULL );
-    ok( mapping != 0, "CreateFileMapping error %u\n", GetLastError() );
+    ok( mapping != 0, "CreateFileMapping error %lu\n", GetLastError() );
     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 4096 );
-    ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %lu\n", GetLastError() );
     status = pNtAreMappedFilesTheSame( ptr, GetModuleHandleA("kernel32.dll") );
-    ok( status == STATUS_NOT_SAME_DEVICE, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_NOT_SAME_DEVICE, "NtAreMappedFilesTheSame returned %lx\n", status );
     status = pNtAreMappedFilesTheSame( GetModuleHandleA("kernel32.dll"), ptr );
     todo_wine
-    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %lx\n", status );
     UnmapViewOfFile( ptr );
     CloseHandle( mapping );
 
     mapping = CreateFileMappingA( file, NULL, PAGE_READONLY | SEC_IMAGE, 0, 0, NULL );
-    ok( mapping != 0, "CreateFileMapping error %u\n", GetLastError() );
+    ok( mapping != 0, "CreateFileMapping error %lu\n", GetLastError() );
     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 );
-    ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError() );
+    ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %lu\n", GetLastError() );
     status = pNtAreMappedFilesTheSame( ptr, GetModuleHandleA("kernel32.dll") );
-    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %lx\n", status );
     status = pNtAreMappedFilesTheSame( GetModuleHandleA("kernel32.dll"), ptr );
-    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %lx\n", status );
 
     file2 = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
-    ok( file2 != INVALID_HANDLE_VALUE, "CreateFile error %u\n", GetLastError() );
+    ok( file2 != INVALID_HANDLE_VALUE, "CreateFile error %lu\n", GetLastError() );
     map2 = CreateFileMappingA( file2, NULL, PAGE_READONLY | SEC_IMAGE, 0, 0, NULL );
-    ok( map2 != 0, "CreateFileMapping error %u\n", GetLastError() );
+    ok( map2 != 0, "CreateFileMapping error %lu\n", GetLastError() );
     ptr2 = MapViewOfFile( map2, FILE_MAP_READ, 0, 0, 0 );
-    ok( ptr2 != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError() );
+    ok( ptr2 != NULL, "MapViewOfFile FILE_MAP_READ error %lu\n", GetLastError() );
     status = pNtAreMappedFilesTheSame( ptr, ptr2 );
-    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %lx\n", status );
     status = pNtAreMappedFilesTheSame( ptr2, ptr );
-    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %x\n", status );
+    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %lx\n", status );
     UnmapViewOfFile( ptr2 );
     CloseHandle( map2 );
     CloseHandle( file2 );
@@ -1456,32 +1456,32 @@ static void test_CreateFileMapping(void)
     SetLastError(0xdeadbeef);
     handle = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, SEC_COMMIT | PAGE_READWRITE, 0, 0x1000,
                                  "Wine Test Mapping");
-    ok( handle != NULL, "CreateFileMapping failed with error %u\n", GetLastError());
-    ok( GetLastError() == 0, "wrong error %u\n", GetLastError());
+    ok( handle != NULL, "CreateFileMapping failed with error %lu\n", GetLastError());
+    ok( GetLastError() == 0, "wrong error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     handle2 = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, SEC_COMMIT | PAGE_READWRITE, 0, 0x1000,
                                   "Wine Test Mapping");
-    ok( handle2 != NULL, "CreateFileMapping failed with error %d\n", GetLastError());
-    ok( GetLastError() == ERROR_ALREADY_EXISTS, "wrong error %u\n", GetLastError());
+    ok( handle2 != NULL, "CreateFileMapping failed with error %ld\n", GetLastError());
+    ok( GetLastError() == ERROR_ALREADY_EXISTS, "wrong error %lu\n", GetLastError());
     CloseHandle( handle2 );
 
     SetLastError(0xdeadbeef);
     handle2 = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, SEC_COMMIT | PAGE_READWRITE, 0, 0x1000,
                                  "WINE TEST MAPPING");
-    ok( handle2 != NULL, "CreateFileMapping failed with error %d\n", GetLastError());
-    ok( GetLastError() == 0, "wrong error %u\n", GetLastError());
+    ok( handle2 != NULL, "CreateFileMapping failed with error %ld\n", GetLastError());
+    ok( GetLastError() == 0, "wrong error %lu\n", GetLastError());
     CloseHandle( handle2 );
 
     SetLastError(0xdeadbeef);
     handle2 = OpenFileMappingA( FILE_MAP_ALL_ACCESS, FALSE, "Wine Test Mapping");
-    ok( handle2 != NULL, "OpenFileMapping failed with error %d\n", GetLastError());
+    ok( handle2 != NULL, "OpenFileMapping failed with error %ld\n", GetLastError());
     CloseHandle( handle2 );
 
     SetLastError(0xdeadbeef);
     handle2 = OpenFileMappingA( FILE_MAP_ALL_ACCESS, FALSE, "WINE TEST MAPPING");
     ok( !handle2, "OpenFileMapping succeeded\n");
-    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError());
+    ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %lu\n", GetLastError());
 
     CloseHandle( handle );
 
@@ -1492,14 +1492,14 @@ static void test_CreateFileMapping(void)
     GetTempFileNameA( path, "map", 0, filename );
 
     file[1] = CreateFileA( filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
-    ok( file[1] != INVALID_HANDLE_VALUE, "CreateFile error %u\n", GetLastError() );
+    ok( file[1] != INVALID_HANDLE_VALUE, "CreateFile error %lu\n", GetLastError() );
     SetFilePointer( file[1], 0x2000, NULL, FILE_BEGIN );
     SetEndOfFile( file[1] );
 
     GetSystemDirectoryA( path, MAX_PATH );
     strcat( path, "\\kernel32.dll" );
     file[2] = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
-    ok( file[2] != INVALID_HANDLE_VALUE, "CreateFile error %u\n", GetLastError() );
+    ok( file[2] != INVALID_HANDLE_VALUE, "CreateFile error %lu\n", GetLastError() );
 
     for (i = 0; i < ARRAY_SIZE(sec_flag_tests); i++)
     {
@@ -1511,7 +1511,7 @@ static void test_CreateFileMapping(void)
         if (sec_flag_tests[i].error)
         {
             ok( !handle, "%u: CreateFileMapping succeeded\n", i );
-            ok( GetLastError() == sec_flag_tests[i].error, "%u: wrong error %u\n", i, GetLastError());
+            ok( GetLastError() == sec_flag_tests[i].error, "%u: wrong error %lu\n", i, GetLastError());
         }
         else
         {
@@ -1519,9 +1519,9 @@ static void test_CreateFileMapping(void)
             BOOL new_flags = ((flags & SEC_WRITECOMBINE) ||
                               ((flags & SEC_IMAGE_NO_EXECUTE) == SEC_IMAGE_NO_EXECUTE));
             ok( handle != NULL || broken(new_flags),
-                "%u: CreateFileMapping failed with error %u\n", i, GetLastError());
+                "%u: CreateFileMapping failed with error %lu\n", i, GetLastError());
             ok( GetLastError() == 0 || broken(new_flags && GetLastError() == ERROR_INVALID_PARAMETER),
-                "%u: wrong error %u\n", i, GetLastError());
+                "%u: wrong error %lu\n", i, GetLastError());
         }
 
         if (handle)
@@ -1530,10 +1530,10 @@ static void test_CreateFileMapping(void)
             DWORD expect = sec_flag_tests[i].attrs ? sec_flag_tests[i].attrs : sec_flag_tests[i].flags;
 
             status = pNtQuerySection( handle, SectionBasicInformation, &info, sizeof(info), NULL );
-            ok( !status, "%u: NtQuerySection failed err %x\n", i, status );
+            ok( !status, "%u: NtQuerySection failed err %lx\n", i, status );
             /* SEC_NOCACHE not supported on older Windows */
             ok( info.Attributes == expect || broken( info.Attributes == (expect & ~SEC_NOCACHE) ),
-                "%u: NtQuerySection wrong attr %08x\n", i, info.Attributes );
+                "%u: NtQuerySection wrong attr %08lx\n", i, info.Attributes );
             CloseHandle( handle );
         }
     }
@@ -1636,11 +1636,11 @@ static DWORD CALLBACK read_pipe( void *arg )
     DWORD num_bytes;
     BOOL success = ConnectNamedPipe( args->pipe, NULL );
     ok( success || GetLastError() == ERROR_PIPE_CONNECTED,
-        "%u: ConnectNamedPipe failed %u\n", args->index, GetLastError() );
+        "%u: ConnectNamedPipe failed %lu\n", args->index, GetLastError() );
 
     success = ReadFile( args->pipe, args->base, args->size, &num_bytes, NULL );
-    ok( success, "%u: ReadFile failed %u\n", args->index, GetLastError() );
-    ok( num_bytes == sizeof(testdata), "%u: wrong number of bytes read %u\n", args->index, num_bytes );
+    ok( success, "%u: ReadFile failed %lu\n", args->index, GetLastError() );
+    ok( num_bytes == sizeof(testdata), "%u: wrong number of bytes read %lu\n", args->index, num_bytes );
     ok( !memcmp( args->base, testdata, sizeof(testdata)),
         "%u: didn't receive expected data\n", args->index );
     return 0;
@@ -1673,137 +1673,137 @@ static void test_write_watch(void)
         win_skip( "MEM_WRITE_WATCH not supported\n" );
         return;
     }
-    ok( base != NULL, "VirtualAlloc failed %u\n", GetLastError() );
+    ok( base != NULL, "VirtualAlloc failed %lu\n", GetLastError() );
     ret = VirtualQuery( base, &info, sizeof(info) );
-    ok(ret, "VirtualQuery failed %u\n", GetLastError());
+    ok(ret, "VirtualQuery failed %lu\n", GetLastError());
     ok( info.BaseAddress == base, "BaseAddress %p instead of %p\n", info.BaseAddress, base );
-    ok( info.AllocationProtect == PAGE_READWRITE, "wrong AllocationProtect %x\n", info.AllocationProtect );
-    ok( info.RegionSize == size, "wrong RegionSize 0x%lx\n", info.RegionSize );
-    ok( info.State == MEM_COMMIT, "wrong State 0x%x\n", info.State );
-    ok( info.Protect == PAGE_READWRITE, "wrong Protect 0x%x\n", info.Protect );
-    ok( info.Type == MEM_PRIVATE, "wrong Type 0x%x\n", info.Type );
+    ok( info.AllocationProtect == PAGE_READWRITE, "wrong AllocationProtect %lx\n", info.AllocationProtect );
+    ok( info.RegionSize == size, "wrong RegionSize 0x%Ix\n", info.RegionSize );
+    ok( info.State == MEM_COMMIT, "wrong State 0x%lx\n", info.State );
+    ok( info.Protect == PAGE_READWRITE, "wrong Protect 0x%lx\n", info.Protect );
+    ok( info.Type == MEM_PRIVATE, "wrong Type 0x%lx\n", info.Type );
 
     count = 64;
     SetLastError( 0xdeadbeef );
     ret = pGetWriteWatch( 0, NULL, size, results, &count, &pagesize );
-    ok( ret == ~0u, "GetWriteWatch succeeded %u\n", ret );
+    ok( ret == ~0u, "GetWriteWatch succeeded %lu\n", ret );
     ok( GetLastError() == ERROR_INVALID_PARAMETER ||
         broken( GetLastError() == 0xdeadbeef ), /* win98 */
-        "wrong error %u\n", GetLastError() );
+        "wrong error %lu\n", GetLastError() );
 
     SetLastError( 0xdeadbeef );
     ret = pGetWriteWatch( 0, GetModuleHandleW(NULL), size, results, &count, &pagesize );
     if (ret)
     {
-        ok( ret == ~0u, "GetWriteWatch succeeded %u\n", ret );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( ret == ~0u, "GetWriteWatch succeeded %lu\n", ret );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
     }
     else  /* win98 */
     {
-        ok( count == 0, "wrong count %lu\n", count );
+        ok( count == 0, "wrong count %Iu\n", count );
     }
 
     ret = pGetWriteWatch( 0, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 0, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 0, "wrong count %Iu\n", count );
 
     base[pagesize + 1] = 0x44;
 
     count = 64;
     ret = pGetWriteWatch( 0, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 1, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 1, "wrong count %Iu\n", count );
     ok( results[0] == base + pagesize, "wrong result %p\n", results[0] );
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 1, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 1, "wrong count %Iu\n", count );
     ok( results[0] == base + pagesize, "wrong result %p\n", results[0] );
 
     count = 64;
     ret = pGetWriteWatch( 0, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 0, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 0, "wrong count %Iu\n", count );
 
     base[2*pagesize + 3] = 0x11;
     base[4*pagesize + 8] = 0x11;
 
     count = 64;
     ret = pGetWriteWatch( 0, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 2, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 2, "wrong count %Iu\n", count );
     ok( results[0] == base + 2*pagesize, "wrong result %p\n", results[0] );
     ok( results[1] == base + 4*pagesize, "wrong result %p\n", results[1] );
 
     count = 64;
     ret = pGetWriteWatch( 0, base + 3*pagesize, 2*pagesize, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 1, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 1, "wrong count %Iu\n", count );
     ok( results[0] == base + 4*pagesize, "wrong result %p\n", results[0] );
 
     ret = pResetWriteWatch( base, 3*pagesize );
-    ok( !ret, "pResetWriteWatch failed %u\n", GetLastError() );
+    ok( !ret, "pResetWriteWatch failed %lu\n", GetLastError() );
 
     count = 64;
     ret = pGetWriteWatch( 0, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 1, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 1, "wrong count %Iu\n", count );
     ok( results[0] == base + 4*pagesize, "wrong result %p\n", results[0] );
 
     *(DWORD *)(base + 2*pagesize - 2) = 0xdeadbeef;
 
     count = 64;
     ret = pGetWriteWatch( 0, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 3, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 3, "wrong count %Iu\n", count );
     ok( results[0] == base + pagesize, "wrong result %p\n", results[0] );
     ok( results[1] == base + 2*pagesize, "wrong result %p\n", results[1] );
     ok( results[2] == base + 4*pagesize, "wrong result %p\n", results[2] );
 
     count = 1;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 1, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 1, "wrong count %Iu\n", count );
     ok( results[0] == base + pagesize, "wrong result %p\n", results[0] );
 
     count = 64;
     ret = pGetWriteWatch( 0, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 2, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 2, "wrong count %Iu\n", count );
     ok( results[0] == base + 2*pagesize, "wrong result %p\n", results[0] );
     ok( results[1] == base + 4*pagesize, "wrong result %p\n", results[1] );
 
     /* changing protections doesn't affect watches */
 
     ret = VirtualProtect( base, 3*pagesize, PAGE_READONLY, &old_prot );
-    ok( ret, "VirtualProtect failed error %u\n", GetLastError() );
-    ok( old_prot == PAGE_READWRITE, "wrong old prot %x\n", old_prot );
+    ok( ret, "VirtualProtect failed error %lu\n", GetLastError() );
+    ok( old_prot == PAGE_READWRITE, "wrong old prot %lx\n", old_prot );
 
     ret = VirtualQuery( base, &info, sizeof(info) );
-    ok(ret, "VirtualQuery failed %u\n", GetLastError());
+    ok(ret, "VirtualQuery failed %lu\n", GetLastError());
     ok( info.BaseAddress == base, "BaseAddress %p instead of %p\n", info.BaseAddress, base );
-    ok( info.RegionSize == 3*pagesize, "wrong RegionSize 0x%lx\n", info.RegionSize );
-    ok( info.State == MEM_COMMIT, "wrong State 0x%x\n", info.State );
-    ok( info.Protect == PAGE_READONLY, "wrong Protect 0x%x\n", info.Protect );
+    ok( info.RegionSize == 3*pagesize, "wrong RegionSize 0x%Ix\n", info.RegionSize );
+    ok( info.State == MEM_COMMIT, "wrong State 0x%lx\n", info.State );
+    ok( info.Protect == PAGE_READONLY, "wrong Protect 0x%lx\n", info.Protect );
 
     ret = VirtualProtect( base, 3*pagesize, PAGE_READWRITE, &old_prot );
-    ok( ret, "VirtualProtect failed error %u\n", GetLastError() );
-    ok( old_prot == PAGE_READONLY, "wrong old prot %x\n", old_prot );
+    ok( ret, "VirtualProtect failed error %lu\n", GetLastError() );
+    ok( old_prot == PAGE_READONLY, "wrong old prot %lx\n", old_prot );
 
     count = 64;
     ret = pGetWriteWatch( 0, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 2, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 2, "wrong count %Iu\n", count );
     ok( results[0] == base + 2*pagesize, "wrong result %p\n", results[0] );
     ok( results[1] == base + 4*pagesize, "wrong result %p\n", results[1] );
 
     ret = VirtualQuery( base, &info, sizeof(info) );
-    ok(ret, "VirtualQuery failed %u\n", GetLastError());
+    ok(ret, "VirtualQuery failed %lu\n", GetLastError());
     ok( info.BaseAddress == base, "BaseAddress %p instead of %p\n", info.BaseAddress, base );
-    ok( info.RegionSize == size, "wrong RegionSize 0x%lx\n", info.RegionSize );
-    ok( info.State == MEM_COMMIT, "wrong State 0x%x\n", info.State );
-    ok( info.Protect == PAGE_READWRITE, "wrong Protect 0x%x\n", info.Protect );
+    ok( info.RegionSize == size, "wrong RegionSize 0x%Ix\n", info.RegionSize );
+    ok( info.State == MEM_COMMIT, "wrong State 0x%lx\n", info.State );
+    ok( info.Protect == PAGE_READWRITE, "wrong Protect 0x%lx\n", info.Protect );
 
     /* ReadFile should trigger write watches */
 
@@ -1815,53 +1815,53 @@ static void test_write_watch(void)
         readpipe = CreateNamedPipeA( pipename, FILE_FLAG_OVERLAPPED | PIPE_ACCESS_INBOUND,
                                      (i ? PIPE_TYPE_MESSAGE : PIPE_TYPE_BYTE) | PIPE_WAIT, 1, 1024, 1024,
                                      NMPWAIT_USE_DEFAULT_WAIT, NULL );
-        ok( readpipe != INVALID_HANDLE_VALUE, "CreateNamedPipeA failed %u\n", GetLastError() );
+        ok( readpipe != INVALID_HANDLE_VALUE, "CreateNamedPipeA failed %lu\n", GetLastError() );
 
         success = ConnectNamedPipe( readpipe, &overlapped );
-        ok( !success, "%u: ConnectNamedPipe unexpectedly succeeded\n", i );
-        ok( GetLastError() == ERROR_IO_PENDING, "%u: expected ERROR_IO_PENDING, got %u\n",
+        ok( !success, "%lu: ConnectNamedPipe unexpectedly succeeded\n", i );
+        ok( GetLastError() == ERROR_IO_PENDING, "%lu: expected ERROR_IO_PENDING, got %lu\n",
             i, GetLastError() );
 
         writepipe = CreateFileA( pipename, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL );
-        ok( writepipe != INVALID_HANDLE_VALUE, "%u: CreateFileA failed %u\n", i, GetLastError() );
+        ok( writepipe != INVALID_HANDLE_VALUE, "%lu: CreateFileA failed %lu\n", i, GetLastError() );
 
         ret = WaitForSingleObject( overlapped.hEvent, 1000 );
-        ok( ret == WAIT_OBJECT_0, "%u: expected WAIT_OBJECT_0, got %u\n", i, ret );
+        ok( ret == WAIT_OBJECT_0, "%lu: expected WAIT_OBJECT_0, got %lu\n", i, ret );
 
         memset( base, 0, size );
 
         count = 64;
         ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-        ok( !ret, "%u: GetWriteWatch failed %u\n", i, GetLastError() );
-        ok( count == 16, "%u: wrong count %lu\n", i, count );
+        ok( !ret, "%lu: GetWriteWatch failed %lu\n", i, GetLastError() );
+        ok( count == 16, "%lu: wrong count %Iu\n", i, count );
 
         success = ReadFile( readpipe, base, size, NULL, &overlapped );
-        ok( !success, "%u: ReadFile unexpectedly succeeded\n", i );
-        ok( GetLastError() == ERROR_IO_PENDING, "%u: expected ERROR_IO_PENDING, got %u\n",
+        ok( !success, "%lu: ReadFile unexpectedly succeeded\n", i );
+        ok( GetLastError() == ERROR_IO_PENDING, "%lu: expected ERROR_IO_PENDING, got %lu\n",
             i, GetLastError() );
 
         count = 64;
         ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-        ok( !ret, "%u: GetWriteWatch failed %u\n", i, GetLastError() );
-        ok( count == 16, "%u: wrong count %lu\n", i, count );
+        ok( !ret, "%lu: GetWriteWatch failed %lu\n", i, GetLastError() );
+        ok( count == 16, "%lu: wrong count %Iu\n", i, count );
 
         num_bytes = 0;
         success = WriteFile( writepipe, testdata, sizeof(testdata), &num_bytes, NULL );
-        ok( success, "%u: WriteFile failed %u\n", i, GetLastError() );
-        ok( num_bytes == sizeof(testdata), "%u: wrong number of bytes written %u\n", i, num_bytes );
+        ok( success, "%lu: WriteFile failed %lu\n", i, GetLastError() );
+        ok( num_bytes == sizeof(testdata), "%lu: wrong number of bytes written %lu\n", i, num_bytes );
 
         num_bytes = 0;
         success = GetOverlappedResult( readpipe, &overlapped, &num_bytes, TRUE );
-        ok( success, "%u: GetOverlappedResult failed %u\n", i, GetLastError() );
-        ok( num_bytes == sizeof(testdata), "%u: wrong number of bytes read %u\n", i, num_bytes );
-        ok( !memcmp( base, testdata, sizeof(testdata)), "%u: didn't receive expected data\n", i );
+        ok( success, "%lu: GetOverlappedResult failed %lu\n", i, GetLastError() );
+        ok( num_bytes == sizeof(testdata), "%lu: wrong number of bytes read %lu\n", i, num_bytes );
+        ok( !memcmp( base, testdata, sizeof(testdata)), "%lu: didn't receive expected data\n", i );
 
         count = 64;
         memset( results, 0, sizeof(results) );
         ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-        ok( !ret, "%u: GetWriteWatch failed %u\n", i, GetLastError() );
-        ok( count == 1, "%u: wrong count %lu\n", i, count );
-        ok( results[0] == base, "%u: wrong result %p\n", i, results[0] );
+        ok( !ret, "%lu: GetWriteWatch failed %lu\n", i, GetLastError() );
+        ok( count == 1, "%lu: wrong count %Iu\n", i, count );
+        ok( results[0] == base, "%lu: wrong result %p\n", i, results[0] );
 
         CloseHandle( readpipe );
         CloseHandle( writepipe );
@@ -1876,14 +1876,14 @@ static void test_write_watch(void)
         readpipe = CreateNamedPipeA( pipename, PIPE_ACCESS_INBOUND,
                                      (i ? PIPE_TYPE_MESSAGE : PIPE_TYPE_BYTE) | PIPE_WAIT, 1, 1024, 1024,
                                      NMPWAIT_USE_DEFAULT_WAIT, NULL );
-        ok( readpipe != INVALID_HANDLE_VALUE, "CreateNamedPipeA failed %u\n", GetLastError() );
+        ok( readpipe != INVALID_HANDLE_VALUE, "CreateNamedPipeA failed %lu\n", GetLastError() );
 
         memset( base, 0, size );
 
         count = 64;
         ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-        ok( !ret, "%u: GetWriteWatch failed %u\n", i, GetLastError() );
-        ok( count == 16, "%u: wrong count %lu\n", i, count );
+        ok( !ret, "%lu: GetWriteWatch failed %lu\n", i, GetLastError() );
+        ok( count == 16, "%lu: wrong count %Iu\n", i, count );
 
         args.pipe = readpipe;
         args.index = i;
@@ -1892,26 +1892,26 @@ static void test_write_watch(void)
         thread = CreateThread( NULL, 0, read_pipe, &args, 0, NULL );
 
         writepipe = CreateFileA( pipename, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL );
-        ok( writepipe != INVALID_HANDLE_VALUE, "%u: CreateFileA failed %u\n", i, GetLastError() );
+        ok( writepipe != INVALID_HANDLE_VALUE, "%lu: CreateFileA failed %lu\n", i, GetLastError() );
         Sleep( 200 );
 
         count = 64;
         ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-        ok( !ret, "%u: GetWriteWatch failed %u\n", i, GetLastError() );
-        ok( count == 16, "%u: wrong count %lu\n", i, count );
+        ok( !ret, "%lu: GetWriteWatch failed %lu\n", i, GetLastError() );
+        ok( count == 16, "%lu: wrong count %Iu\n", i, count );
 
         num_bytes = 0;
         success = WriteFile( writepipe, testdata, sizeof(testdata), &num_bytes, NULL );
-        ok( success, "%u: WriteFile failed %u\n", i, GetLastError() );
-        ok( num_bytes == sizeof(testdata), "%u: wrong number of bytes written %u\n", i, num_bytes );
+        ok( success, "%lu: WriteFile failed %lu\n", i, GetLastError() );
+        ok( num_bytes == sizeof(testdata), "%lu: wrong number of bytes written %lu\n", i, num_bytes );
         WaitForSingleObject( thread, 10000 );
 
         count = 64;
         memset( results, 0, sizeof(results) );
         ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-        ok( !ret, "%u: GetWriteWatch failed %u\n", i, GetLastError() );
-        ok( count == 1, "%u: wrong count %lu\n", i, count );
-        ok( results[0] == base, "%u: wrong result %p\n", i, results[0] );
+        ok( !ret, "%lu: GetWriteWatch failed %lu\n", i, GetLastError() );
+        ok( count == 1, "%lu: wrong count %Iu\n", i, count );
+        ok( results[0] == base, "%lu: wrong result %p\n", i, results[0] );
 
         CloseHandle( readpipe );
         CloseHandle( writepipe );
@@ -1921,40 +1921,40 @@ static void test_write_watch(void)
     GetTempPathA( MAX_PATH, path );
     GetTempFileNameA( path, "map", 0, filename );
     file = CreateFileA( filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
-    ok( file != INVALID_HANDLE_VALUE, "CreateFile error %u\n", GetLastError() );
+    ok( file != INVALID_HANDLE_VALUE, "CreateFile error %lu\n", GetLastError() );
     SetFilePointer( file, 2 * pagesize + 3, NULL, FILE_BEGIN );
     SetEndOfFile( file );
     SetFilePointer( file, 0, NULL, FILE_BEGIN );
 
     success = ReadFile( file, base, size, &num_bytes, NULL );
-    ok( success, "ReadFile failed %u\n", GetLastError() );
-    ok( num_bytes == 2 * pagesize + 3, "wrong bytes %u\n", num_bytes );
+    ok( success, "ReadFile failed %lu\n", GetLastError() );
+    ok( num_bytes == 2 * pagesize + 3, "wrong bytes %lu\n", num_bytes );
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 16, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 16, "wrong count %Iu\n", count );
 
     success = ReadFile( file, base, size, &num_bytes, NULL );
-    ok( success, "ReadFile failed %u\n", GetLastError() );
-    ok( num_bytes == 0, "wrong bytes %u\n", num_bytes );
+    ok( success, "ReadFile failed %lu\n", GetLastError() );
+    ok( num_bytes == 0, "wrong bytes %lu\n", num_bytes );
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 16, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 16, "wrong count %Iu\n", count );
 
     CloseHandle( file );
     DeleteFileA( filename );
 
     success = ReadFile( (HANDLE)0xdead, base, size, &num_bytes, NULL );
     ok( !success, "ReadFile succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_HANDLE, "wrong error %lu\n", GetLastError() );
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 0, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 0, "wrong count %Iu\n", count );
 
     /* OVERLAPPED structure write watch */
     memset( &overlapped, 0, sizeof(overlapped) );
@@ -1963,17 +1963,17 @@ static void test_write_watch(void)
     readpipe = CreateNamedPipeA( pipename, FILE_FLAG_OVERLAPPED | PIPE_ACCESS_INBOUND,
                                  PIPE_TYPE_MESSAGE | PIPE_WAIT, 1, 1024, 1024,
                                  NMPWAIT_USE_DEFAULT_WAIT, NULL );
-    ok( readpipe != INVALID_HANDLE_VALUE, "CreateNamedPipeA failed %u\n", GetLastError() );
+    ok( readpipe != INVALID_HANDLE_VALUE, "CreateNamedPipeA failed %lu\n", GetLastError() );
 
     success = ConnectNamedPipe( readpipe, &overlapped );
     ok( !success, "ConnectNamedPipe unexpectedly succeeded\n" );
-    ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %lu\n", GetLastError() );
 
     writepipe = CreateFileA( pipename, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL );
-    ok( writepipe != INVALID_HANDLE_VALUE, "CreateFileA failed %u\n", GetLastError() );
+    ok( writepipe != INVALID_HANDLE_VALUE, "CreateFileA failed %lu\n", GetLastError() );
 
     ret = WaitForSingleObject( overlapped.hEvent, 1000 );
-    ok( ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", ret );
+    ok( ret == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %lu\n", ret );
 
     memset( base, 0, size );
     overlapped2 = (OVERLAPPED*)(base + size - sizeof(*overlapped2));
@@ -1981,35 +1981,35 @@ static void test_write_watch(void)
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 16, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 16, "wrong count %Iu\n", count );
 
     success = ReadFile( readpipe, base, sizeof(testdata), NULL, overlapped2 );
     ok( !success, "ReadFile unexpectedly succeeded\n" );
-    ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %lu\n", GetLastError() );
     overlapped2->Internal = 0xdeadbeef;
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 2, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 2, "wrong count %Iu\n", count );
 
     num_bytes = 0;
     success = WriteFile( writepipe, testdata, sizeof(testdata), &num_bytes, NULL );
-    ok( success, "WriteFile failed %u\n", GetLastError() );
-    ok( num_bytes == sizeof(testdata), "wrong number of bytes written %u\n", num_bytes );
+    ok( success, "WriteFile failed %lu\n", GetLastError() );
+    ok( num_bytes == sizeof(testdata), "wrong number of bytes written %lu\n", num_bytes );
 
     num_bytes = 0;
     success = GetOverlappedResult( readpipe, overlapped2, &num_bytes, TRUE );
-    ok( success, "GetOverlappedResult failed %u\n", GetLastError() );
-    ok( num_bytes == sizeof(testdata), "wrong number of bytes read %u\n", num_bytes );
+    ok( success, "GetOverlappedResult failed %lu\n", GetLastError() );
+    ok( num_bytes == sizeof(testdata), "wrong number of bytes read %lu\n", num_bytes );
     ok( !memcmp( base, testdata, sizeof(testdata)), "didn't receive expected data\n" );
 
     count = 64;
     memset( results, 0, sizeof(results) );
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 2, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 2, "wrong count %Iu\n", count );
     ok( results[0] == base, "wrong result %p\n", results[0] );
 
     CloseHandle( readpipe );
@@ -2024,139 +2024,139 @@ static void test_write_watch(void)
     ret = pGetWriteWatch( 0, base, size, results, &count, &pagesize );
     if (ret)
     {
-        ok( ret == ~0u, "GetWriteWatch succeeded %u\n", ret );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( ret == ~0u, "GetWriteWatch succeeded %lu\n", ret );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         ret = pGetWriteWatch( 0, base, size, results, NULL, &pagesize );
-        ok( ret == ~0u, "GetWriteWatch succeeded %u\n", ret );
-        ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() );
+        ok( ret == ~0u, "GetWriteWatch succeeded %lu\n", ret );
+        ok( GetLastError() == ERROR_NOACCESS, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         count = 64;
         ret = pGetWriteWatch( 0, base, size, results, &count, NULL );
-        ok( ret == ~0u, "GetWriteWatch succeeded %u\n", ret );
-        ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() );
+        ok( ret == ~0u, "GetWriteWatch succeeded %lu\n", ret );
+        ok( GetLastError() == ERROR_NOACCESS, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         count = 64;
         ret = pGetWriteWatch( 0, base, size, NULL, &count, &pagesize );
-        ok( ret == ~0u, "GetWriteWatch succeeded %u\n", ret );
-        ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() );
+        ok( ret == ~0u, "GetWriteWatch succeeded %lu\n", ret );
+        ok( GetLastError() == ERROR_NOACCESS, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         count = 0;
         ret = pGetWriteWatch( 0, base, size, NULL, &count, &pagesize );
-        ok( ret == ~0u, "GetWriteWatch succeeded %u\n", ret );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( ret == ~0u, "GetWriteWatch succeeded %lu\n", ret );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         count = 64;
         ret = pGetWriteWatch( 0xdeadbeef, base, size, results, &count, &pagesize );
-        ok( ret == ~0u, "GetWriteWatch succeeded %u\n", ret );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( ret == ~0u, "GetWriteWatch succeeded %lu\n", ret );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         count = 64;
         ret = pGetWriteWatch( 0, base, 0, results, &count, &pagesize );
-        ok( ret == ~0u, "GetWriteWatch succeeded %u\n", ret );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( ret == ~0u, "GetWriteWatch succeeded %lu\n", ret );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         count = 64;
         ret = pGetWriteWatch( 0, base, size * 2, results, &count, &pagesize );
-        ok( ret == ~0u, "GetWriteWatch succeeded %u\n", ret );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( ret == ~0u, "GetWriteWatch succeeded %lu\n", ret );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         count = 64;
         ret = pGetWriteWatch( 0, base + size - pagesize, pagesize + 1, results, &count, &pagesize );
-        ok( ret == ~0u, "GetWriteWatch succeeded %u\n", ret );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( ret == ~0u, "GetWriteWatch succeeded %lu\n", ret );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         ret = pResetWriteWatch( base, 0 );
-        ok( ret == ~0u, "ResetWriteWatch succeeded %u\n", ret );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( ret == ~0u, "ResetWriteWatch succeeded %lu\n", ret );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
         SetLastError( 0xdeadbeef );
         ret = pResetWriteWatch( GetModuleHandleW(NULL), size );
-        ok( ret == ~0u, "ResetWriteWatch succeeded %u\n", ret );
-        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ok( ret == ~0u, "ResetWriteWatch succeeded %lu\n", ret );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
     }
     else  /* win98 is completely different */
     {
         SetLastError( 0xdeadbeef );
         count = 64;
         ret = pGetWriteWatch( 0, base, size, NULL, &count, &pagesize );
-        ok( ret == ERROR_INVALID_PARAMETER, "GetWriteWatch succeeded %u\n", ret );
-        ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() );
+        ok( ret == ERROR_INVALID_PARAMETER, "GetWriteWatch succeeded %lu\n", ret );
+        ok( GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError() );
 
         count = 0;
         ret = pGetWriteWatch( 0, base, size, NULL, &count, &pagesize );
-        ok( !ret, "GetWriteWatch failed %u\n", ret );
+        ok( !ret, "GetWriteWatch failed %lu\n", ret );
 
         count = 64;
         ret = pGetWriteWatch( 0xdeadbeef, base, size, results, &count, &pagesize );
-        ok( !ret, "GetWriteWatch failed %u\n", ret );
+        ok( !ret, "GetWriteWatch failed %lu\n", ret );
 
         count = 64;
         ret = pGetWriteWatch( 0, base, 0, results, &count, &pagesize );
-        ok( !ret, "GetWriteWatch failed %u\n", ret );
+        ok( !ret, "GetWriteWatch failed %lu\n", ret );
 
         ret = pResetWriteWatch( base, 0 );
-        ok( !ret, "ResetWriteWatch failed %u\n", ret );
+        ok( !ret, "ResetWriteWatch failed %lu\n", ret );
 
         ret = pResetWriteWatch( GetModuleHandleW(NULL), size );
-        ok( !ret, "ResetWriteWatch failed %u\n", ret );
+        ok( !ret, "ResetWriteWatch failed %lu\n", ret );
     }
 
     VirtualFree( base, 0, MEM_RELEASE );
 
     base = VirtualAlloc( 0, size, MEM_RESERVE | MEM_WRITE_WATCH, PAGE_READWRITE );
-    ok( base != NULL, "VirtualAlloc failed %u\n", GetLastError() );
+    ok( base != NULL, "VirtualAlloc failed %lu\n", GetLastError() );
     VirtualFree( base, 0, MEM_RELEASE );
 
     base = VirtualAlloc( 0, size, MEM_WRITE_WATCH, PAGE_READWRITE );
     ok( !base, "VirtualAlloc succeeded\n" );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
 
     /* initial protect doesn't matter */
 
     base = VirtualAlloc( 0, size, MEM_RESERVE | MEM_WRITE_WATCH, PAGE_NOACCESS );
-    ok( base != NULL, "VirtualAlloc failed %u\n", GetLastError() );
+    ok( base != NULL, "VirtualAlloc failed %lu\n", GetLastError() );
     base = VirtualAlloc( base, size, MEM_COMMIT, PAGE_NOACCESS );
-    ok( base != NULL, "VirtualAlloc failed %u\n", GetLastError() );
+    ok( base != NULL, "VirtualAlloc failed %lu\n", GetLastError() );
 
     count = 64;
     ret = pGetWriteWatch( 0, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 0, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 0, "wrong count %Iu\n", count );
 
     ret = VirtualProtect( base, 6*pagesize, PAGE_READWRITE, &old_prot );
-    ok( ret, "VirtualProtect failed error %u\n", GetLastError() );
-    ok( old_prot == PAGE_NOACCESS, "wrong old prot %x\n", old_prot );
+    ok( ret, "VirtualProtect failed error %lu\n", GetLastError() );
+    ok( old_prot == PAGE_NOACCESS, "wrong old prot %lx\n", old_prot );
 
     base[5*pagesize + 200] = 3;
 
     ret = VirtualProtect( base, 6*pagesize, PAGE_NOACCESS, &old_prot );
-    ok( ret, "VirtualProtect failed error %u\n", GetLastError() );
-    ok( old_prot == PAGE_READWRITE, "wrong old prot %x\n", old_prot );
+    ok( ret, "VirtualProtect failed error %lu\n", GetLastError() );
+    ok( old_prot == PAGE_READWRITE, "wrong old prot %lx\n", old_prot );
 
     count = 64;
     ret = pGetWriteWatch( 0, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
-    ok( count == 1, "wrong count %lu\n", count );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
+    ok( count == 1, "wrong count %Iu\n", count );
     ok( results[0] == base + 5*pagesize, "wrong result %p\n", results[0] );
 
     ret = VirtualFree( base, size, MEM_DECOMMIT );
-    ok( ret, "VirtualFree failed %u\n", GetLastError() );
+    ok( ret, "VirtualFree failed %lu\n", GetLastError() );
 
     count = 64;
     ret = pGetWriteWatch( 0, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
     ok( count == 1 || broken(count == 0), /* win98 */
-        "wrong count %lu\n", count );
+        "wrong count %Iu\n", count );
     if (count) ok( results[0] == base + 5*pagesize, "wrong result %p\n", results[0] );
 
     VirtualFree( base, 0, MEM_RELEASE );
@@ -2219,12 +2219,12 @@ static void test_stack_commit(void)
     DWORD result;
 
     call_on_stack = VirtualAlloc( 0, 0x1000, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE );
-    ok( call_on_stack != NULL, "VirtualAlloc failed %u\n", GetLastError() );
+    ok( call_on_stack != NULL, "VirtualAlloc failed %lu\n", GetLastError() );
     memcpy( call_on_stack, code_call_on_stack, sizeof(code_call_on_stack) );
 
     /* allocate a new stack, only the first guard page is committed */
     new_stack = VirtualAlloc( 0, 0x400000, MEM_RESERVE, PAGE_READWRITE );
-    ok( new_stack != NULL, "VirtualAlloc failed %u\n", GetLastError() );
+    ok( new_stack != NULL, "VirtualAlloc failed %lu\n", GetLastError() );
     new_stack_base = (char *)new_stack + 0x400000;
     VirtualAlloc( (char *)new_stack_base - 0x1000, 0x1000, MEM_COMMIT, PAGE_READWRITE | PAGE_GUARD );
 
@@ -2242,7 +2242,7 @@ static void test_stack_commit(void)
     NtCurrentTeb()->Tib.StackBase      = old_stack_base;
     NtCurrentTeb()->Tib.StackLimit     = old_stack_limit;
 
-    ok( result == 42, "expected 42, got %u\n", result );
+    ok( result == 42, "expected 42, got %lu\n", result );
 
     VirtualFree( new_stack, 0, MEM_RELEASE );
     VirtualFree( call_on_stack, 0, MEM_RELEASE );
@@ -2256,11 +2256,11 @@ static LONG num_guard_page_calls;
 static DWORD guard_page_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_RECORD *frame,
                                  CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher )
 {
-    trace( "exception: %08x flags:%x addr:%p\n",
+    trace( "exception: %08lx flags:%lx addr:%p\n",
            rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress );
 
-    ok( rec->NumberParameters == 2, "NumberParameters is %d instead of 2\n", rec->NumberParameters );
-    ok( rec->ExceptionCode == STATUS_GUARD_PAGE_VIOLATION, "ExceptionCode is %08x instead of %08x\n",
+    ok( rec->NumberParameters == 2, "NumberParameters is %ld instead of 2\n", rec->NumberParameters );
+    ok( rec->ExceptionCode == STATUS_GUARD_PAGE_VIOLATION, "ExceptionCode is %08lx instead of %08lx\n",
         rec->ExceptionCode, STATUS_GUARD_PAGE_VIOLATION );
 
     InterlockedIncrement( &num_guard_page_calls );
@@ -2274,7 +2274,7 @@ static void test_guard_page(void)
     EXCEPTION_REGISTRATION_RECORD frame;
     MEMORY_BASIC_INFORMATION info;
     DWORD ret, size, old_prot;
-    int *value, old_value;
+    LONG *value, old_value;
     void *results[64];
     ULONG_PTR count;
     ULONG pagesize;
@@ -2283,63 +2283,63 @@ static void test_guard_page(void)
 
     size = 0x1000;
     base = VirtualAlloc( 0, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE | PAGE_GUARD );
-    ok( base != NULL, "VirtualAlloc failed %u\n", GetLastError() );
-    value = (int *)base;
+    ok( base != NULL, "VirtualAlloc failed %lu\n", GetLastError() );
+    value = (LONG *)base;
 
     /* verify info structure */
     ret = VirtualQuery( base, &info, sizeof(info) );
-    ok( ret, "VirtualQuery failed %u\n", GetLastError());
+    ok( ret, "VirtualQuery failed %lu\n", GetLastError());
     ok( info.BaseAddress == base, "BaseAddress %p instead of %p\n", info.BaseAddress, base );
-    ok( info.AllocationProtect == (PAGE_READWRITE | PAGE_GUARD), "wrong AllocationProtect %x\n", info.AllocationProtect );
+    ok( info.AllocationProtect == (PAGE_READWRITE | PAGE_GUARD), "wrong AllocationProtect %lx\n", info.AllocationProtect );
     ok( info.RegionSize == size, "wrong RegionSize 0x%lx\n", info.RegionSize );
-    ok( info.State == MEM_COMMIT, "wrong State 0x%x\n", info.State );
-    ok( info.Protect == (PAGE_READWRITE | PAGE_GUARD), "wrong Protect 0x%x\n", info.Protect );
-    ok( info.Type == MEM_PRIVATE, "wrong Type 0x%x\n", info.Type );
+    ok( info.State == MEM_COMMIT, "wrong State 0x%lx\n", info.State );
+    ok( info.Protect == (PAGE_READWRITE | PAGE_GUARD), "wrong Protect 0x%lx\n", info.Protect );
+    ok( info.Type == MEM_PRIVATE, "wrong Type 0x%lx\n", info.Type );
 
     /* put some initial value into the memory */
     success = VirtualProtect( base, size, PAGE_READWRITE, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
-    ok( old_prot == (PAGE_READWRITE | PAGE_GUARD), "wrong old prot %x\n", old_prot );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
+    ok( old_prot == (PAGE_READWRITE | PAGE_GUARD), "wrong old prot %lx\n", old_prot );
 
     *value       = 1;
     *(value + 1) = 2;
 
     success = VirtualProtect( base, size, PAGE_READWRITE | PAGE_GUARD, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
-    ok( old_prot == PAGE_READWRITE, "wrong old prot %x\n", old_prot );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
+    ok( old_prot == PAGE_READWRITE, "wrong old prot %lx\n", old_prot );
 
     /* test behaviour of VirtualLock - first attempt should fail */
     SetLastError( 0xdeadbeef );
     success = VirtualLock( base, size );
     ok( !success, "VirtualLock unexpectedly succeeded\n" );
     todo_wine
-    ok( GetLastError() == STATUS_GUARD_PAGE_VIOLATION, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == STATUS_GUARD_PAGE_VIOLATION, "wrong error %lu\n", GetLastError() );
 
     success = VirtualLock( base, size );
     todo_wine
-    ok( success, "VirtualLock failed %u\n", GetLastError() );
+    ok( success, "VirtualLock failed %lu\n", GetLastError() );
     if (success)
     {
-        ok( *value == 1, "memory block contains wrong value, expected 1, got 0x%x\n", *value );
+        ok( *value == 1, "memory block contains wrong value, expected 1, got 0x%lx\n", *value );
         success = VirtualUnlock( base, size );
-        ok( success, "VirtualUnlock failed %u\n", GetLastError() );
+        ok( success, "VirtualUnlock failed %lu\n", GetLastError() );
     }
 
     /* check info structure again, PAGE_GUARD should be removed now */
     ret = VirtualQuery( base, &info, sizeof(info) );
-    ok( ret, "VirtualQuery failed %u\n", GetLastError());
+    ok( ret, "VirtualQuery failed %lu\n", GetLastError());
     ok( info.BaseAddress == base, "BaseAddress %p instead of %p\n", info.BaseAddress, base );
-    ok( info.AllocationProtect == (PAGE_READWRITE | PAGE_GUARD), "wrong AllocationProtect %x\n", info.AllocationProtect );
+    ok( info.AllocationProtect == (PAGE_READWRITE | PAGE_GUARD), "wrong AllocationProtect %lx\n", info.AllocationProtect );
     ok( info.RegionSize == size, "wrong RegionSize 0x%lx\n", info.RegionSize );
-    ok( info.State == MEM_COMMIT, "wrong State 0x%x\n", info.State );
+    ok( info.State == MEM_COMMIT, "wrong State 0x%lx\n", info.State );
     todo_wine
-    ok( info.Protect == PAGE_READWRITE, "wrong Protect 0x%x\n", info.Protect );
-    ok( info.Type == MEM_PRIVATE, "wrong Type 0x%x\n", info.Type );
+    ok( info.Protect == PAGE_READWRITE, "wrong Protect 0x%lx\n", info.Protect );
+    ok( info.Type == MEM_PRIVATE, "wrong Type 0x%lx\n", info.Type );
 
     success = VirtualProtect( base, size, PAGE_READWRITE | PAGE_GUARD, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
     todo_wine
-    ok( old_prot == PAGE_READWRITE, "wrong old prot %x\n", old_prot );
+    ok( old_prot == PAGE_READWRITE, "wrong old prot %lx\n", old_prot );
 
     /* test directly accessing the memory - we need to setup an exception handler first */
     frame.Handler = guard_page_handler;
@@ -2349,19 +2349,19 @@ static void test_guard_page(void)
     InterlockedExchange( &num_guard_page_calls, 0 );
     InterlockedExchange( &old_value, *value ); /* exception handler increments value by 0x100 */
     *value = 2;
-    ok( old_value == 0x101, "memory block contains wrong value, expected 0x101, got 0x%x\n", old_value );
-    ok( num_guard_page_calls == 1, "expected one callback of guard page handler, got %d calls\n", num_guard_page_calls );
+    ok( old_value == 0x101, "memory block contains wrong value, expected 0x101, got 0x%lx\n", old_value );
+    ok( num_guard_page_calls == 1, "expected one callback of guard page handler, got %ld calls\n", num_guard_page_calls );
 
     NtCurrentTeb()->Tib.ExceptionList = frame.Prev;
 
     /* check info structure again, PAGE_GUARD should be removed now */
     ret = VirtualQuery( base, &info, sizeof(info) );
-    ok( ret, "VirtualQuery failed %u\n", GetLastError());
-    ok( info.Protect == PAGE_READWRITE, "wrong Protect 0x%x\n", info.Protect );
+    ok( ret, "VirtualQuery failed %lu\n", GetLastError());
+    ok( info.Protect == PAGE_READWRITE, "wrong Protect 0x%lx\n", info.Protect );
 
     success = VirtualProtect( base, size, PAGE_READWRITE | PAGE_GUARD, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
-    ok( old_prot == PAGE_READWRITE, "wrong old prot %x\n", old_prot );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
+    ok( old_prot == PAGE_READWRITE, "wrong old prot %lx\n", old_prot );
 
     /* test accessing second integer in memory */
     frame.Handler = guard_page_handler;
@@ -2370,19 +2370,19 @@ static void test_guard_page(void)
 
     InterlockedExchange( &num_guard_page_calls, 0 );
     old_value = *(value + 1);
-    ok( old_value == 0x102, "memory block contains wrong value, expected 0x102, got 0x%x\n", old_value );
-    ok( *value == 2, "memory block contains wrong value, expected 2, got 0x%x\n", *value );
-    ok( num_guard_page_calls == 1, "expected one callback of guard page handler, got %d calls\n", num_guard_page_calls );
+    ok( old_value == 0x102, "memory block contains wrong value, expected 0x102, got 0x%lx\n", old_value );
+    ok( *value == 2, "memory block contains wrong value, expected 2, got 0x%lx\n", *value );
+    ok( num_guard_page_calls == 1, "expected one callback of guard page handler, got %ld calls\n", num_guard_page_calls );
 
     NtCurrentTeb()->Tib.ExceptionList = frame.Prev;
 
     success = VirtualLock( base, size );
-    ok( success, "VirtualLock failed %u\n", GetLastError() );
+    ok( success, "VirtualLock failed %lu\n", GetLastError() );
     if (success)
     {
-        ok( *value == 2, "memory block contains wrong value, expected 2, got 0x%x\n", *value );
+        ok( *value == 2, "memory block contains wrong value, expected 2, got 0x%lx\n", *value );
         success = VirtualUnlock( base, size );
-        ok( success, "VirtualUnlock failed %u\n", GetLastError() );
+        ok( success, "VirtualUnlock failed %lu\n", GetLastError() );
     }
 
     VirtualFree( base, 0, MEM_RELEASE );
@@ -2400,21 +2400,21 @@ static void test_guard_page(void)
         win_skip( "MEM_WRITE_WATCH not supported\n" );
         return;
     }
-    ok( base != NULL, "VirtualAlloc failed %u\n", GetLastError() );
-    value = (int *)base;
+    ok( base != NULL, "VirtualAlloc failed %lu\n", GetLastError() );
+    value = (LONG *)base;
 
     ret = VirtualQuery( base, &info, sizeof(info) );
-    ok( ret, "VirtualQuery failed %u\n", GetLastError() );
+    ok( ret, "VirtualQuery failed %lu\n", GetLastError() );
     ok( info.BaseAddress == base, "BaseAddress %p instead of %p\n", info.BaseAddress, base );
-    ok( info.AllocationProtect == (PAGE_READWRITE | PAGE_GUARD), "wrong AllocationProtect %x\n", info.AllocationProtect );
+    ok( info.AllocationProtect == (PAGE_READWRITE | PAGE_GUARD), "wrong AllocationProtect %lx\n", info.AllocationProtect );
     ok( info.RegionSize == size, "wrong RegionSize 0x%lx\n", info.RegionSize );
-    ok( info.State == MEM_COMMIT, "wrong State 0x%x\n", info.State );
-    ok( info.Protect == (PAGE_READWRITE | PAGE_GUARD), "wrong Protect 0x%x\n", info.Protect );
-    ok( info.Type == MEM_PRIVATE, "wrong Type 0x%x\n", info.Type );
+    ok( info.State == MEM_COMMIT, "wrong State 0x%lx\n", info.State );
+    ok( info.Protect == (PAGE_READWRITE | PAGE_GUARD), "wrong Protect 0x%lx\n", info.Protect );
+    ok( info.Type == MEM_PRIVATE, "wrong Type 0x%lx\n", info.Type );
 
     count = 64;
     ret = pGetWriteWatch( 0, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
     ok( count == 0, "wrong count %lu\n", count );
 
     /* writing to a page should trigger should trigger guard page, even if write watch is set */
@@ -2425,18 +2425,18 @@ static void test_guard_page(void)
     InterlockedExchange( &num_guard_page_calls, 0 );
     *value       = 1;
     *(value + 1) = 2;
-    ok( num_guard_page_calls == 1, "expected one callback of guard page handler, got %d calls\n", num_guard_page_calls );
+    ok( num_guard_page_calls == 1, "expected one callback of guard page handler, got %ld calls\n", num_guard_page_calls );
 
     NtCurrentTeb()->Tib.ExceptionList = frame.Prev;
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
     ok( count == 1, "wrong count %lu\n", count );
     ok( results[0] == base, "wrong result %p\n", results[0] );
 
     success = VirtualProtect( base, size, PAGE_READWRITE | PAGE_GUARD, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     /* write watch is triggered from inside of the guard page handler */
     frame.Handler = guard_page_handler;
@@ -2445,47 +2445,47 @@ static void test_guard_page(void)
 
     InterlockedExchange( &num_guard_page_calls, 0 );
     old_value = *(value + 1); /* doesn't trigger write watch */
-    ok( old_value == 0x102, "memory block contains wrong value, expected 0x102, got 0x%x\n", old_value );
-    ok( *value == 1, "memory block contains wrong value, expected 1, got 0x%x\n", *value );
-    ok( num_guard_page_calls == 1, "expected one callback of guard page handler, got %d calls\n", num_guard_page_calls );
+    ok( old_value == 0x102, "memory block contains wrong value, expected 0x102, got 0x%lx\n", old_value );
+    ok( *value == 1, "memory block contains wrong value, expected 1, got 0x%lx\n", *value );
+    ok( num_guard_page_calls == 1, "expected one callback of guard page handler, got %ld calls\n", num_guard_page_calls );
 
     NtCurrentTeb()->Tib.ExceptionList = frame.Prev;
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
     ok( count == 1, "wrong count %lu\n", count );
     ok( results[0] == base, "wrong result %p\n", results[0] );
 
     success = VirtualProtect( base, size, PAGE_READWRITE | PAGE_GUARD, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     /* test behaviour of VirtualLock - first attempt should fail without triggering write watches */
     SetLastError( 0xdeadbeef );
     success = VirtualLock( base, size );
     ok( !success, "VirtualLock unexpectedly succeeded\n" );
     todo_wine
-    ok( GetLastError() == STATUS_GUARD_PAGE_VIOLATION, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == STATUS_GUARD_PAGE_VIOLATION, "wrong error %lu\n", GetLastError() );
 
     count = 64;
     ret = pGetWriteWatch( 0, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
     ok( count == 0, "wrong count %lu\n", count );
 
     success = VirtualLock( base, size );
     todo_wine
-    ok( success, "VirtualLock failed %u\n", GetLastError() );
+    ok( success, "VirtualLock failed %lu\n", GetLastError() );
     if (success)
     {
-        ok( *value == 1, "memory block contains wrong value, expected 1, got 0x%x\n", *value );
+        ok( *value == 1, "memory block contains wrong value, expected 1, got 0x%lx\n", *value );
         success = VirtualUnlock( base, size );
-        ok( success, "VirtualUnlock failed %u\n", GetLastError() );
+        ok( success, "VirtualUnlock failed %lu\n", GetLastError() );
     }
 
     count = 64;
     results[0] = (void *)0xdeadbeef;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
     todo_wine
     ok( count == 1 || broken(count == 0) /* Windows 8 */, "wrong count %lu\n", count );
     todo_wine
@@ -2502,13 +2502,13 @@ static DWORD execute_fault_seh_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTR
     ULONG flags = MEM_EXECUTE_OPTION_ENABLE;
     DWORD err;
 
-    trace( "exception: %08x flags:%x addr:%p info[0]:%ld info[1]:%p\n",
+    trace( "exception: %08lx flags:%lx addr:%p info[0]:%ld info[1]:%p\n",
            rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,
            rec->ExceptionInformation[0], (void *)rec->ExceptionInformation[1] );
 
-    ok( rec->NumberParameters == 2, "NumberParameters is %d instead of 2\n", rec->NumberParameters );
+    ok( rec->NumberParameters == 2, "NumberParameters is %ld instead of 2\n", rec->NumberParameters );
     ok( rec->ExceptionCode == STATUS_ACCESS_VIOLATION || rec->ExceptionCode == STATUS_GUARD_PAGE_VIOLATION,
-        "ExceptionCode is %08x instead of STATUS_ACCESS_VIOLATION or STATUS_GUARD_PAGE_VIOLATION\n", rec->ExceptionCode );
+        "ExceptionCode is %08lx instead of STATUS_ACCESS_VIOLATION or STATUS_GUARD_PAGE_VIOLATION\n", rec->ExceptionCode );
 
     NtQueryInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &flags, sizeof(flags), NULL );
 
@@ -2516,7 +2516,7 @@ static DWORD execute_fault_seh_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTR
     {
 
         err = IsProcessorFeaturePresent( PF_NX_ENABLED ) ? EXCEPTION_EXECUTE_FAULT : EXCEPTION_READ_FAULT;
-        ok( rec->ExceptionInformation[0] == err, "ExceptionInformation[0] is %d instead of %d\n",
+        ok( rec->ExceptionInformation[0] == err, "ExceptionInformation[0] is %ld instead of %ld\n",
             (DWORD)rec->ExceptionInformation[0], err );
 
         InterlockedIncrement( &num_guard_page_calls );
@@ -2527,12 +2527,12 @@ static DWORD execute_fault_seh_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTR
         BOOL success;
 
         err = (flags & MEM_EXECUTE_OPTION_DISABLE) ? EXCEPTION_EXECUTE_FAULT : EXCEPTION_READ_FAULT;
-        ok( rec->ExceptionInformation[0] == err, "ExceptionInformation[0] is %d instead of %d\n",
+        ok( rec->ExceptionInformation[0] == err, "ExceptionInformation[0] is %ld instead of %ld\n",
             (DWORD)rec->ExceptionInformation[0], err );
 
         success = VirtualProtect( (void *)rec->ExceptionInformation[1], 16, PAGE_EXECUTE_READWRITE, &old_prot );
-        ok( success, "VirtualProtect failed %u\n", GetLastError() );
-        ok( old_prot == PAGE_READWRITE, "wrong old prot %x\n", old_prot );
+        ok( success, "VirtualProtect failed %lu\n", GetLastError() );
+        ok( old_prot == PAGE_READWRITE, "wrong old prot %lx\n", old_prot );
 
         InterlockedIncrement( &num_execute_fault_calls );
     }
@@ -2546,13 +2546,13 @@ static LONG CALLBACK execute_fault_vec_handler( EXCEPTION_POINTERS *ExceptionInf
     DWORD old_prot;
     BOOL success;
 
-    trace( "exception: %08x flags:%x addr:%p info[0]:%ld info[1]:%p\n",
+    trace( "exception: %08lx flags:%lx addr:%p info[0]:%ld info[1]:%p\n",
            rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,
            rec->ExceptionInformation[0], (void *)rec->ExceptionInformation[1] );
 
-    ok( rec->NumberParameters == 2, "NumberParameters is %d instead of 2\n", rec->NumberParameters );
+    ok( rec->NumberParameters == 2, "NumberParameters is %ld instead of 2\n", rec->NumberParameters );
     ok( rec->ExceptionCode == STATUS_ACCESS_VIOLATION,
-        "ExceptionCode is %08x instead of STATUS_ACCESS_VIOLATION\n", rec->ExceptionCode );
+        "ExceptionCode is %08lx instead of STATUS_ACCESS_VIOLATION\n", rec->ExceptionCode );
 
     if (rec->ExceptionCode == STATUS_ACCESS_VIOLATION)
         InterlockedIncrement( &num_execute_fault_calls );
@@ -2561,8 +2561,8 @@ static LONG CALLBACK execute_fault_vec_handler( EXCEPTION_POINTERS *ExceptionInf
         return EXCEPTION_CONTINUE_SEARCH;
 
     success = VirtualProtect( (void *)rec->ExceptionInformation[1], 16, PAGE_EXECUTE_READWRITE, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
-    ok( old_prot == PAGE_NOACCESS, "wrong old prot %x\n", old_prot );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
+    ok( old_prot == PAGE_NOACCESS, "wrong old prot %lx\n", old_prot );
 
     return EXCEPTION_CONTINUE_EXECUTION;
 }
@@ -2615,7 +2615,7 @@ static LRESULT CALLBACK atl_test_func( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
 {
     DWORD arg = (DWORD)hWnd;
     if (uMsg == WM_USER)
-        ok( arg == 0x11223344, "arg is 0x%08x instead of 0x11223344\n", arg );
+        ok( arg == 0x11223344, "arg is 0x%08lx instead of 0x11223344\n", arg );
     else
         ok( arg != 0x11223344, "arg is unexpectedly 0x11223344\n" );
     return 43;
@@ -2645,7 +2645,7 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
     char *base;
     HWND hWnd;
 
-    trace( "Running DEP tests with ProcessExecuteFlags = %d\n", dep_flags );
+    trace( "Running DEP tests with ProcessExecuteFlags = %ld\n", dep_flags );
 
     NtQueryInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &old_flags, sizeof(old_flags), NULL );
     if (old_flags != dep_flags)
@@ -2654,16 +2654,16 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
         if (ret == STATUS_INVALID_INFO_CLASS /* Windows 2000 */ ||
             ret == STATUS_ACCESS_DENIED)
         {
-            win_skip( "Skipping DEP tests with ProcessExecuteFlags = %d\n", dep_flags );
+            win_skip( "Skipping DEP tests with ProcessExecuteFlags = %ld\n", dep_flags );
             return;
         }
-        ok( !ret, "NtSetInformationProcess failed with status %08x\n", ret );
+        ok( !ret, "NtSetInformationProcess failed with status %08lx\n", ret );
         restore_flags = TRUE;
     }
 
     size = 0x1000;
     base = VirtualAlloc( 0, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE );
-    ok( base != NULL, "VirtualAlloc failed %u\n", GetLastError() );
+    ok( base != NULL, "VirtualAlloc failed %lu\n", GetLastError() );
 
     /* Check result of GetProcessDEPPolicy */
     if (!pGetProcessDEPPolicy)
@@ -2684,10 +2684,10 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
         *(DWORD *)(base + 6) = (DWORD_PTR)pGetProcessDEPPolicy - (DWORD_PTR)(base + 10);
 
         success = VirtualProtect( base, size, PAGE_EXECUTE_READWRITE, &old_prot );
-        ok( success, "VirtualProtect failed %u\n", GetLastError() );
+        ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
         success = get_dep_policy( GetCurrentProcess(), &policy_flags, &policy_permanent );
-        ok( success, "GetProcessDEPPolicy failed %u\n", GetLastError() );
+        ok( success, "GetProcessDEPPolicy failed %lu\n", GetLastError() );
 
         ret = 0;
         if (dep_flags & MEM_EXECUTE_OPTION_DISABLE)
@@ -2695,7 +2695,7 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
         if (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION)
             ret |= PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION;
 
-        ok( policy_flags == ret, "expected policy flags %d, got %d\n", ret, policy_flags );
+        ok( policy_flags == ret, "expected policy flags %ld, got %ld\n", ret, policy_flags );
         ok( !policy_permanent || broken(policy_permanent == 0x44),
             "expected policy permanent FALSE, got %d\n", policy_permanent );
     }
@@ -2710,7 +2710,7 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
      * prevent crashes while creating the window. */
 
     success = VirtualProtect( base, size, PAGE_EXECUTE_READWRITE, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     memset( &wc, 0, sizeof(wc) );
     wc.cbSize        = sizeof(wc);
@@ -2721,56 +2721,56 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
     wc.lpszClassName = cls_name;
     wc.lpfnWndProc   = (WNDPROC)base;
     success = RegisterClassExA(&wc) != 0;
-    ok( success, "RegisterClassExA failed %u\n", GetLastError() );
+    ok( success, "RegisterClassExA failed %lu\n", GetLastError() );
 
     hWnd = CreateWindowExA(0, cls_name, "Test", WS_TILEDWINDOW, 0, 0, 640, 480, 0, 0, 0, 0);
-    ok( hWnd != 0, "CreateWindowExA failed %u\n", GetLastError() );
+    ok( hWnd != 0, "CreateWindowExA failed %lu\n", GetLastError() );
 
     ret = SendMessageA(hWnd, WM_USER, 0, 0);
-    ok( ret == 42, "SendMessage returned unexpected result %d\n", ret );
+    ok( ret == 42, "SendMessage returned unexpected result %ld\n", ret );
 
     /* At first try with an instruction which is not recognized as proper ATL thunk
      * by the Windows ATL Thunk Emulator. Removing execute permissions will lead to
      * STATUS_ACCESS_VIOLATION exceptions when DEP is enabled. */
 
     success = VirtualProtect( base, size, PAGE_READWRITE, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     ret = send_message_excpt( hWnd, WM_USER, 0, 0 );
-    ok( ret == 42, "call returned wrong result, expected 42, got %d\n", ret );
-    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
+    ok( ret == 42, "call returned wrong result, expected 42, got %ld\n", ret );
+    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
     if ((dep_flags & MEM_EXECUTE_OPTION_DISABLE) && !IsProcessorFeaturePresent( PF_NX_ENABLED ))
     {
         trace( "DEP hardware support is not available\n" );
-        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
         dep_flags = MEM_EXECUTE_OPTION_ENABLE;
     }
     else if (dep_flags & MEM_EXECUTE_OPTION_DISABLE)
     {
         trace( "DEP hardware support is available\n" );
-        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
     }
     else
-        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     /* Now a bit more complicated, the page containing the code is protected with
      * PAGE_GUARD memory protection. */
 
     success = VirtualProtect( base, size, PAGE_READWRITE | PAGE_GUARD, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     ret = send_message_excpt( hWnd, WM_USER, 0, 0 );
-    ok( ret == 42, "call returned wrong result, expected 42, got %d\n", ret );
-    ok( num_guard_page_calls == 1, "expected one STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
+    ok( ret == 42, "call returned wrong result, expected 42, got %ld\n", ret );
+    ok( num_guard_page_calls == 1, "expected one STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
     if (dep_flags & MEM_EXECUTE_OPTION_DISABLE)
-        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
     else
-        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     ret = send_message_excpt( hWnd, WM_USER, 0, 0 );
-    ok( ret == 42, "call returned wrong result, expected 42, got %d\n", ret );
-    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
-    ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+    ok( ret == 42, "call returned wrong result, expected 42, got %ld\n", ret );
+    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
+    ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     /* Now test with a proper ATL thunk instruction. */
 
@@ -2778,43 +2778,43 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
     *(DWORD *)(base + 9) = (DWORD_PTR)atl_test_func - (DWORD_PTR)(base + 13);
 
     success = VirtualProtect( base, size, PAGE_EXECUTE_READWRITE, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     ret = SendMessageA(hWnd, WM_USER, 0, 0);
-    ok( ret == 43, "SendMessage returned unexpected result %d\n", ret );
+    ok( ret == 43, "SendMessage returned unexpected result %ld\n", ret );
 
     /* Try executing with PAGE_READWRITE protection. */
 
     success = VirtualProtect( base, size, PAGE_READWRITE, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     ret = send_message_excpt( hWnd, WM_USER, 0, 0 );
-    ok( ret == 43, "call returned wrong result, expected 43, got %d\n", ret );
-    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
+    ok( ret == 43, "call returned wrong result, expected 43, got %ld\n", ret );
+    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
     if ((dep_flags & MEM_EXECUTE_OPTION_DISABLE) && (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION))
-        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
     else
-        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     /* Now a bit more complicated, the page containing the code is protected with
      * PAGE_GUARD memory protection. */
 
     success = VirtualProtect( base, size, PAGE_READWRITE | PAGE_GUARD, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     /* the same, but with PAGE_GUARD set */
     ret = send_message_excpt( hWnd, WM_USER, 0, 0 );
-    ok( ret == 43, "call returned wrong result, expected 43, got %d\n", ret );
-    ok( num_guard_page_calls == 1, "expected one STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
+    ok( ret == 43, "call returned wrong result, expected 43, got %ld\n", ret );
+    ok( num_guard_page_calls == 1, "expected one STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
     if ((dep_flags & MEM_EXECUTE_OPTION_DISABLE) && (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION))
-        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
     else
-        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     ret = send_message_excpt( hWnd, WM_USER, 0, 0 );
-    ok( ret == 43, "call returned wrong result, expected 43, got %d\n", ret );
-    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
-    ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+    ok( ret == 43, "call returned wrong result, expected 43, got %ld\n", ret );
+    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
+    ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     /* The following test shows that on Windows, even a vectored exception handler
      * cannot intercept internal exceptions thrown by the ATL thunk emulation layer. */
@@ -2826,7 +2826,7 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
             PVOID vectored_handler;
 
             success = VirtualProtect( base, size, PAGE_NOACCESS, &old_prot );
-            ok( success, "VirtualProtect failed %u\n", GetLastError() );
+            ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
             vectored_handler = pRtlAddVectoredExceptionHandler( TRUE, &execute_fault_vec_handler );
             ok( vectored_handler != 0, "RtlAddVectoredExceptionHandler failed\n" );
@@ -2835,8 +2835,8 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
 
             pRtlRemoveVectoredExceptionHandler( vectored_handler );
 
-            ok( ret == 43, "call returned wrong result, expected 43, got %d\n", ret );
-            ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+            ok( ret == 43, "call returned wrong result, expected 43, got %ld\n", ret );
+            ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
         }
         else
             win_skip( "RtlAddVectoredExceptionHandler or RtlRemoveVectoredExceptionHandler not found\n" );
@@ -2848,67 +2848,67 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
     *(DWORD *)(base + 6) = (DWORD_PTR)atl_test_func - (DWORD_PTR)(base + 10);
 
     success = VirtualProtect( base, size, PAGE_READWRITE, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     ret = send_message_excpt( hWnd, WM_USER + 1, 0, 0 );
     /* FIXME: we don't check the content of the register ECX yet */
-    ok( ret == 43, "call returned wrong result, expected 43, got %d\n", ret );
-    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
+    ok( ret == 43, "call returned wrong result, expected 43, got %ld\n", ret );
+    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
     if ((dep_flags & MEM_EXECUTE_OPTION_DISABLE) && (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION))
-        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
     else
-        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     memcpy( base, code_atl3, sizeof(code_atl3) );
     *(DWORD *)(base + 6) = (DWORD_PTR)atl_test_func;
 
     success = VirtualProtect( base, size, PAGE_READWRITE, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     ret = send_message_excpt( hWnd, WM_USER + 1, 0, 0 );
     /* FIXME: we don't check the content of the registers ECX/EDX yet */
-    ok( ret == 43, "call returned wrong result, expected 43, got %d\n", ret );
-    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
+    ok( ret == 43, "call returned wrong result, expected 43, got %ld\n", ret );
+    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
     if ((dep_flags & MEM_EXECUTE_OPTION_DISABLE) && (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION))
-        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
     else
-        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     memcpy( base, code_atl4, sizeof(code_atl4) );
     *(DWORD *)(base + 6) = (DWORD_PTR)atl_test_func;
 
     success = VirtualProtect( base, size, PAGE_READWRITE, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     ret = send_message_excpt( hWnd, WM_USER + 1, 0, 0 );
     /* FIXME: We don't check the content of the registers EAX/ECX yet */
-    ok( ret == 43, "call returned wrong result, expected 43, got %d\n", ret );
-    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
+    ok( ret == 43, "call returned wrong result, expected 43, got %ld\n", ret );
+    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
     if ((dep_flags & MEM_EXECUTE_OPTION_DISABLE) && (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION))
-        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
     else if (dep_flags & MEM_EXECUTE_OPTION_DISABLE)
         ok( num_execute_fault_calls == 0 || broken(num_execute_fault_calls == 1) /* Windows XP */,
-            "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+            "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
     else
-        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     memcpy( base, code_atl5, sizeof(code_atl5) );
 
     success = VirtualProtect( base, size, PAGE_READWRITE, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     results[1] = atl5_test_func;
     ret = call_proc_excpt( (void *)base, results );
     /* FIXME: We don't check the content of the registers EAX/ECX yet */
-    ok( ret == 44, "call returned wrong result, expected 44, got %d\n", ret );
-    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
+    ok( ret == 44, "call returned wrong result, expected 44, got %ld\n", ret );
+    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
     if ((dep_flags & MEM_EXECUTE_OPTION_DISABLE) && (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION))
-        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
     else if (dep_flags & MEM_EXECUTE_OPTION_DISABLE)
         ok( num_execute_fault_calls == 0 || broken(num_execute_fault_calls == 1) /* Windows XP */,
-            "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+            "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
     else
-        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     /* Restore the JMP instruction, set to executable, and then destroy the Window */
 
@@ -2916,12 +2916,12 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
     *(DWORD *)(base + 1) = (DWORD_PTR)jmp_test_func - (DWORD_PTR)(base + 5);
 
     success = VirtualProtect( base, size, PAGE_EXECUTE_READWRITE, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     DestroyWindow( hWnd );
 
     success = UnregisterClassA( cls_name, GetModuleHandleA(0) );
-    ok( success, "UnregisterClass failed %u\n", GetLastError() );
+    ok( success, "UnregisterClass failed %lu\n", GetLastError() );
 
     VirtualFree( base, 0, MEM_RELEASE );
 
@@ -2933,11 +2933,11 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
         win_skip( "MEM_WRITE_WATCH not supported\n" );
         goto out;
     }
-    ok( base != NULL, "VirtualAlloc failed %u\n", GetLastError() );
+    ok( base != NULL, "VirtualAlloc failed %lu\n", GetLastError() );
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
     ok( count == 0, "wrong count %lu\n", count );
 
     memcpy( base, code_jmp, sizeof(code_jmp) );
@@ -2945,14 +2945,14 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
     ok( count == 1, "wrong count %lu\n", count );
     ok( results[0] == base, "wrong result %p\n", results[0] );
 
     /* Create a new window class and associated Window (see above) */
 
     success = VirtualProtect( base, size, PAGE_EXECUTE_READWRITE, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     memset( &wc, 0, sizeof(wc) );
     wc.cbSize        = sizeof(wc);
@@ -2963,17 +2963,17 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
     wc.lpszClassName = cls_name;
     wc.lpfnWndProc   = (WNDPROC)base;
     success = RegisterClassExA(&wc) != 0;
-    ok( success, "RegisterClassExA failed %u\n", GetLastError() );
+    ok( success, "RegisterClassExA failed %lu\n", GetLastError() );
 
     hWnd = CreateWindowExA(0, cls_name, "Test", WS_TILEDWINDOW, 0, 0, 640, 480, 0, 0, 0, 0);
-    ok( hWnd != 0, "CreateWindowExA failed %u\n", GetLastError() );
+    ok( hWnd != 0, "CreateWindowExA failed %lu\n", GetLastError() );
 
     ret = SendMessageA(hWnd, WM_USER, 0, 0);
-    ok( ret == 42, "SendMessage returned unexpected result %d\n", ret );
+    ok( ret == 42, "SendMessage returned unexpected result %ld\n", ret );
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
     ok( count == 0, "wrong count %lu\n", count );
 
     /* At first try with an instruction which is not recognized as proper ATL thunk
@@ -2981,48 +2981,48 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
      * STATUS_ACCESS_VIOLATION exceptions when DEP is enabled. */
 
     success = VirtualProtect( base, size, PAGE_READWRITE, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     ret = send_message_excpt( hWnd, WM_USER, 0, 0 );
-    ok( ret == 42, "call returned wrong result, expected 42, got %d\n", ret );
-    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
+    ok( ret == 42, "call returned wrong result, expected 42, got %ld\n", ret );
+    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
     if (dep_flags & MEM_EXECUTE_OPTION_DISABLE)
-        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
     else
-        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
     ok( count == 0, "wrong count %lu\n", count );
 
     ret = send_message_excpt( hWnd, WM_USER, 0, 0 );
-    ok( ret == 42, "call returned wrong result, expected 42, got %d\n", ret );
-    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
-    ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+    ok( ret == 42, "call returned wrong result, expected 42, got %ld\n", ret );
+    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
+    ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     /* Now a bit more complicated, the page containing the code is protected with
      * PAGE_GUARD memory protection. */
 
     success = VirtualProtect( base, size, PAGE_READWRITE | PAGE_GUARD, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     ret = send_message_excpt( hWnd, WM_USER, 0, 0 );
-    ok( ret == 42, "call returned wrong result, expected 42, got %d\n", ret );
-    ok( num_guard_page_calls == 1, "expected one STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
+    ok( ret == 42, "call returned wrong result, expected 42, got %ld\n", ret );
+    ok( num_guard_page_calls == 1, "expected one STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
     if (dep_flags & MEM_EXECUTE_OPTION_DISABLE)
-        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
     else
-        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     ret = send_message_excpt( hWnd, WM_USER, 0, 0 );
-    ok( ret == 42, "call returned wrong result, expected 42, got %d\n", ret );
-    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
-    ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+    ok( ret == 42, "call returned wrong result, expected 42, got %ld\n", ret );
+    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
+    ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
     ok( count == 0 || broken(count == 1) /* Windows 8 */, "wrong count %lu\n", count );
 
     /* Now test with a proper ATL thunk instruction. */
@@ -3032,62 +3032,62 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
     ok( count == 1, "wrong count %lu\n", count );
     ok( results[0] == base, "wrong result %p\n", results[0] );
 
     success = VirtualProtect( base, size, PAGE_EXECUTE_READWRITE, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     ret = SendMessageA(hWnd, WM_USER, 0, 0);
-    ok( ret == 43, "SendMessage returned unexpected result %d\n", ret );
+    ok( ret == 43, "SendMessage returned unexpected result %ld\n", ret );
 
     /* Try executing with PAGE_READWRITE protection. */
 
     success = VirtualProtect( base, size, PAGE_READWRITE, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     ret = send_message_excpt( hWnd, WM_USER, 0, 0 );
-    ok( ret == 43, "call returned wrong result, expected 43, got %d\n", ret );
-    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
+    ok( ret == 43, "call returned wrong result, expected 43, got %ld\n", ret );
+    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
     if ((dep_flags & MEM_EXECUTE_OPTION_DISABLE) && (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION))
-        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
     else
-        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
     ok( count == 0, "wrong count %lu\n", count );
 
     ret = send_message_excpt( hWnd, WM_USER, 0, 0 );
-    ok( ret == 43, "call returned wrong result, expected 43, got %d\n", ret );
-    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
-    ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+    ok( ret == 43, "call returned wrong result, expected 43, got %ld\n", ret );
+    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
+    ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     /* Now a bit more complicated, the page containing the code is protected with
      * PAGE_GUARD memory protection. */
 
     success = VirtualProtect( base, size, PAGE_READWRITE | PAGE_GUARD, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     /* the same, but with PAGE_GUARD set */
     ret = send_message_excpt( hWnd, WM_USER, 0, 0 );
-    ok( ret == 43, "call returned wrong result, expected 43, got %d\n", ret );
-    ok( num_guard_page_calls == 1, "expected one STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
+    ok( ret == 43, "call returned wrong result, expected 43, got %ld\n", ret );
+    ok( num_guard_page_calls == 1, "expected one STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
     if ((dep_flags & MEM_EXECUTE_OPTION_DISABLE) && (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION))
-        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 1, "expected one STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
     else
-        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+        ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     ret = send_message_excpt( hWnd, WM_USER, 0, 0 );
-    ok( ret == 43, "call returned wrong result, expected 43, got %d\n", ret );
-    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %d exceptions\n", num_guard_page_calls );
-    ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %d exceptions\n", num_execute_fault_calls );
+    ok( ret == 43, "call returned wrong result, expected 43, got %ld\n", ret );
+    ok( num_guard_page_calls == 0, "expected no STATUS_GUARD_PAGE_VIOLATION exception, got %ld exceptions\n", num_guard_page_calls );
+    ok( num_execute_fault_calls == 0, "expected no STATUS_ACCESS_VIOLATION exception, got %ld exceptions\n", num_execute_fault_calls );
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
     ok( count == 0 || broken(count == 1) /* Windows 8 */, "wrong count %lu\n", count );
 
     /* Restore the JMP instruction, set to executable, and then destroy the Window */
@@ -3097,17 +3097,17 @@ static void test_atl_thunk_emulation( ULONG dep_flags )
 
     count = 64;
     ret = pGetWriteWatch( WRITE_WATCH_FLAG_RESET, base, size, results, &count, &pagesize );
-    ok( !ret, "GetWriteWatch failed %u\n", GetLastError() );
+    ok( !ret, "GetWriteWatch failed %lu\n", GetLastError() );
     ok( count == 1, "wrong count %lu\n", count );
     ok( results[0] == base, "wrong result %p\n", results[0] );
 
     success = VirtualProtect( base, size, PAGE_EXECUTE_READWRITE, &old_prot );
-    ok( success, "VirtualProtect failed %u\n", GetLastError() );
+    ok( success, "VirtualProtect failed %lu\n", GetLastError() );
 
     DestroyWindow( hWnd );
 
     success = UnregisterClassA( cls_name, GetModuleHandleA(0) );
-    ok( success, "UnregisterClass failed %u\n", GetLastError() );
+    ok( success, "UnregisterClass failed %lu\n", GetLastError() );
 
     VirtualFree( base, 0, MEM_RELEASE );
 
@@ -3115,7 +3115,7 @@ out:
     if (restore_flags)
     {
         ret = NtSetInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &old_flags, sizeof(old_flags) );
-        ok( !ret, "NtSetInformationProcess failed with status %08x\n", ret );
+        ok( !ret, "NtSetInformationProcess failed with status %08lx\n", ret );
     }
 }
 
@@ -3170,74 +3170,74 @@ static void test_VirtualProtect(void)
 
     SetLastError(0xdeadbeef);
     base = VirtualAlloc(0, si.dwPageSize, MEM_RESERVE | MEM_COMMIT, PAGE_NOACCESS);
-    ok(base != NULL, "VirtualAlloc failed %d\n", GetLastError());
+    ok(base != NULL, "VirtualAlloc failed %ld\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = VirtualProtect(base, si.dwPageSize, PAGE_READONLY, NULL);
     ok(!ret, "VirtualProtect should fail\n");
-    ok(GetLastError() == ERROR_NOACCESS, "expected ERROR_NOACCESS, got %d\n", GetLastError());
+    ok(GetLastError() == ERROR_NOACCESS, "expected ERROR_NOACCESS, got %ld\n", GetLastError());
     old_prot = 0xdeadbeef;
     ret = VirtualProtect(base, si.dwPageSize, PAGE_NOACCESS, &old_prot);
-    ok(ret, "VirtualProtect failed %d\n", GetLastError());
-    ok(old_prot == PAGE_NOACCESS, "got %#x != expected PAGE_NOACCESS\n", old_prot);
+    ok(ret, "VirtualProtect failed %ld\n", GetLastError());
+    ok(old_prot == PAGE_NOACCESS, "got %#lx != expected PAGE_NOACCESS\n", old_prot);
 
     addr = base;
     size = si.dwPageSize;
     status = pNtProtectVirtualMemory(GetCurrentProcess(), &addr, &size, PAGE_READONLY, NULL);
-    ok(status == STATUS_ACCESS_VIOLATION, "NtProtectVirtualMemory should fail, got %08x\n", status);
+    ok(status == STATUS_ACCESS_VIOLATION, "NtProtectVirtualMemory should fail, got %08lx\n", status);
     addr = base;
     size = si.dwPageSize;
     old_prot = 0xdeadbeef;
     status = pNtProtectVirtualMemory(GetCurrentProcess(), &addr, &size, PAGE_NOACCESS, &old_prot);
-    ok(status == STATUS_SUCCESS, "NtProtectVirtualMemory should succeed, got %08x\n", status);
-    ok(old_prot == PAGE_NOACCESS, "got %#x != expected PAGE_NOACCESS\n", old_prot);
+    ok(status == STATUS_SUCCESS, "NtProtectVirtualMemory should succeed, got %08lx\n", status);
+    ok(old_prot == PAGE_NOACCESS, "got %#lx != expected PAGE_NOACCESS\n", old_prot);
 
     for (i = 0; i < ARRAY_SIZE(td); i++)
     {
         SetLastError(0xdeadbeef);
         ret = VirtualQuery(base, &info, sizeof(info));
-        ok(ret, "VirtualQuery failed %d\n", GetLastError());
-        ok(info.BaseAddress == base, "%d: got %p != expected %p\n", i, info.BaseAddress, base);
-        ok(info.RegionSize == si.dwPageSize, "%d: got %#lx != expected %#x\n", i, info.RegionSize, si.dwPageSize);
-        ok(info.Protect == PAGE_NOACCESS, "%d: got %#x != expected PAGE_NOACCESS\n", i, info.Protect);
-        ok(info.AllocationBase == base, "%d: %p != %p\n", i, info.AllocationBase, base);
-        ok(info.AllocationProtect == PAGE_NOACCESS, "%d: %#x != PAGE_NOACCESS\n", i, info.AllocationProtect);
-        ok(info.State == MEM_COMMIT, "%d: %#x != MEM_COMMIT\n", i, info.State);
-        ok(info.Type == MEM_PRIVATE, "%d: %#x != MEM_PRIVATE\n", i, info.Type);
+        ok(ret, "VirtualQuery failed %ld\n", GetLastError());
+        ok(info.BaseAddress == base, "%ld: got %p != expected %p\n", i, info.BaseAddress, base);
+        ok(info.RegionSize == si.dwPageSize, "%ld: got %#Ix != expected %#lx\n", i, info.RegionSize, si.dwPageSize);
+        ok(info.Protect == PAGE_NOACCESS, "%ld: got %#lx != expected PAGE_NOACCESS\n", i, info.Protect);
+        ok(info.AllocationBase == base, "%ld: %p != %p\n", i, info.AllocationBase, base);
+        ok(info.AllocationProtect == PAGE_NOACCESS, "%ld: %#lx != PAGE_NOACCESS\n", i, info.AllocationProtect);
+        ok(info.State == MEM_COMMIT, "%ld: %#lx != MEM_COMMIT\n", i, info.State);
+        ok(info.Type == MEM_PRIVATE, "%ld: %#lx != MEM_PRIVATE\n", i, info.Type);
 
         old_prot = 0xdeadbeef;
         SetLastError(0xdeadbeef);
         ret = VirtualProtect(base, si.dwPageSize, td[i].prot_set, &old_prot);
         if (td[i].prot_get)
         {
-            ok(ret, "%d: VirtualProtect error %d\n", i, GetLastError());
-            ok(old_prot == PAGE_NOACCESS, "%d: got %#x != expected PAGE_NOACCESS\n", i, old_prot);
+            ok(ret, "%ld: VirtualProtect error %ld\n", i, GetLastError());
+            ok(old_prot == PAGE_NOACCESS, "%ld: got %#lx != expected PAGE_NOACCESS\n", i, old_prot);
 
             SetLastError(0xdeadbeef);
             ret = VirtualQuery(base, &info, sizeof(info));
-            ok(ret, "VirtualQuery failed %d\n", GetLastError());
-            ok(info.BaseAddress == base, "%d: got %p != expected %p\n", i, info.BaseAddress, base);
-            ok(info.RegionSize == si.dwPageSize, "%d: got %#lx != expected %#x\n", i, info.RegionSize, si.dwPageSize);
-            ok(info.Protect == td[i].prot_get, "%d: got %#x != expected %#x\n", i, info.Protect, td[i].prot_get);
-            ok(info.AllocationBase == base, "%d: %p != %p\n", i, info.AllocationBase, base);
-            ok(info.AllocationProtect == PAGE_NOACCESS, "%d: %#x != PAGE_NOACCESS\n", i, info.AllocationProtect);
-            ok(info.State == MEM_COMMIT, "%d: %#x != MEM_COMMIT\n", i, info.State);
-            ok(info.Type == MEM_PRIVATE, "%d: %#x != MEM_PRIVATE\n", i, info.Type);
+            ok(ret, "VirtualQuery failed %ld\n", GetLastError());
+            ok(info.BaseAddress == base, "%ld: got %p != expected %p\n", i, info.BaseAddress, base);
+            ok(info.RegionSize == si.dwPageSize, "%ld: got %#Ix != expected %#lx\n", i, info.RegionSize, si.dwPageSize);
+            ok(info.Protect == td[i].prot_get, "%ld: got %#lx != expected %#lx\n", i, info.Protect, td[i].prot_get);
+            ok(info.AllocationBase == base, "%ld: %p != %p\n", i, info.AllocationBase, base);
+            ok(info.AllocationProtect == PAGE_NOACCESS, "%ld: %#lx != PAGE_NOACCESS\n", i, info.AllocationProtect);
+            ok(info.State == MEM_COMMIT, "%ld: %#lx != MEM_COMMIT\n", i, info.State);
+            ok(info.Type == MEM_PRIVATE, "%ld: %#lx != MEM_PRIVATE\n", i, info.Type);
         }
         else
         {
-            ok(!ret, "%d: VirtualProtect should fail\n", i);
-            ok(GetLastError() == ERROR_INVALID_PARAMETER, "%d: expected ERROR_INVALID_PARAMETER, got %d\n", i, GetLastError());
+            ok(!ret, "%ld: VirtualProtect should fail\n", i);
+            ok(GetLastError() == ERROR_INVALID_PARAMETER, "%ld: expected ERROR_INVALID_PARAMETER, got %ld\n", i, GetLastError());
         }
 
         old_prot = 0xdeadbeef;
         SetLastError(0xdeadbeef);
         ret = VirtualProtect(base, si.dwPageSize, PAGE_NOACCESS, &old_prot);
-        ok(ret, "%d: VirtualProtect error %d\n", i, GetLastError());
+        ok(ret, "%ld: VirtualProtect error %ld\n", i, GetLastError());
         if (td[i].prot_get)
-            ok(old_prot == td[i].prot_get, "%d: got %#x != expected %#x\n", i, old_prot, td[i].prot_get);
+            ok(old_prot == td[i].prot_get, "%ld: got %#lx != expected %#lx\n", i, old_prot, td[i].prot_get);
         else
-            ok(old_prot == PAGE_NOACCESS, "%d: got %#x != expected PAGE_NOACCESS\n", i, old_prot);
+            ok(old_prot == PAGE_NOACCESS, "%ld: got %#lx != expected PAGE_NOACCESS\n", i, old_prot);
     }
 
     exec_prot = 0;
@@ -3254,19 +3254,19 @@ static void test_VirtualProtect(void)
             ptr = VirtualAlloc(base, si.dwPageSize, MEM_COMMIT, prot);
             if ((rw_prot && exec_prot) || (!rw_prot && !exec_prot))
             {
-                ok(!ptr, "VirtualAlloc(%02x) should fail\n", prot);
-                ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+                ok(!ptr, "VirtualAlloc(%02lx) should fail\n", prot);
+                ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
             }
             else
             {
                 if (prot & (PAGE_WRITECOPY | PAGE_EXECUTE_WRITECOPY))
                 {
-                    ok(!ptr, "VirtualAlloc(%02x) should fail\n", prot);
-                    ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+                    ok(!ptr, "VirtualAlloc(%02lx) should fail\n", prot);
+                    ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
                 }
                 else
                 {
-                    ok(ptr != NULL, "VirtualAlloc(%02x) error %d\n", prot, GetLastError());
+                    ok(ptr != NULL, "VirtualAlloc(%02lx) error %ld\n", prot, GetLastError());
                     ok(ptr == base, "expected %p, got %p\n", base, ptr);
                 }
             }
@@ -3275,18 +3275,18 @@ static void test_VirtualProtect(void)
             ret = VirtualProtect(base, si.dwPageSize, prot, &old_prot);
             if ((rw_prot && exec_prot) || (!rw_prot && !exec_prot))
             {
-                ok(!ret, "VirtualProtect(%02x) should fail\n", prot);
-                ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+                ok(!ret, "VirtualProtect(%02lx) should fail\n", prot);
+                ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
             }
             else
             {
                 if (prot & (PAGE_WRITECOPY | PAGE_EXECUTE_WRITECOPY))
                 {
-                    ok(!ret, "VirtualProtect(%02x) should fail\n", prot);
-                    ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+                    ok(!ret, "VirtualProtect(%02lx) should fail\n", prot);
+                    ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
                 }
                 else
-                    ok(ret, "VirtualProtect(%02x) error %d\n", prot, GetLastError());
+                    ok(ret, "VirtualProtect(%02lx) error %ld\n", prot, GetLastError());
             }
 
             rw_prot = 1 << j;
@@ -3365,18 +3365,18 @@ static void test_VirtualAlloc_protection(void)
 
         if (td[i].success)
         {
-            ok(base != NULL, "%d: VirtualAlloc failed %d\n", i, GetLastError());
+            ok(base != NULL, "%ld: VirtualAlloc failed %ld\n", i, GetLastError());
 
             SetLastError(0xdeadbeef);
             ret = VirtualQuery(base, &info, sizeof(info));
-            ok(ret, "VirtualQuery failed %d\n", GetLastError());
-            ok(info.BaseAddress == base, "%d: got %p != expected %p\n", i, info.BaseAddress, base);
-            ok(info.RegionSize == si.dwPageSize, "%d: got %#lx != expected %#x\n", i, info.RegionSize, si.dwPageSize);
-            ok(info.Protect == td[i].prot, "%d: got %#x != expected %#x\n", i, info.Protect, td[i].prot);
-            ok(info.AllocationBase == base, "%d: %p != %p\n", i, info.AllocationBase, base);
-            ok(info.AllocationProtect == td[i].prot, "%d: %#x != %#x\n", i, info.AllocationProtect, td[i].prot);
-            ok(info.State == MEM_COMMIT, "%d: %#x != MEM_COMMIT\n", i, info.State);
-            ok(info.Type == MEM_PRIVATE, "%d: %#x != MEM_PRIVATE\n", i, info.Type);
+            ok(ret, "VirtualQuery failed %ld\n", GetLastError());
+            ok(info.BaseAddress == base, "%ld: got %p != expected %p\n", i, info.BaseAddress, base);
+            ok(info.RegionSize == si.dwPageSize, "%ld: got %#Ix != expected %#lx\n", i, info.RegionSize, si.dwPageSize);
+            ok(info.Protect == td[i].prot, "%ld: got %#lx != expected %#lx\n", i, info.Protect, td[i].prot);
+            ok(info.AllocationBase == base, "%ld: %p != %p\n", i, info.AllocationBase, base);
+            ok(info.AllocationProtect == td[i].prot, "%ld: %#lx != %#lx\n", i, info.AllocationProtect, td[i].prot);
+            ok(info.State == MEM_COMMIT, "%ld: %#lx != MEM_COMMIT\n", i, info.State);
+            ok(info.Type == MEM_PRIVATE, "%ld: %#lx != MEM_PRIVATE\n", i, info.Type);
 
             if (is_mem_writable(info.Protect))
             {
@@ -3384,20 +3384,20 @@ static void test_VirtualAlloc_protection(void)
 
                 SetLastError(0xdeadbeef);
                 ret = VirtualQuery(base, &info, sizeof(info));
-                ok(ret, "VirtualQuery failed %d\n", GetLastError());
-                ok(info.Protect == td[i].prot, "%d: got %#x != expected %#x\n", i, info.Protect, td[i].prot);
+                ok(ret, "VirtualQuery failed %ld\n", GetLastError());
+                ok(info.Protect == td[i].prot, "%ld: got %#lx != expected %#lx\n", i, info.Protect, td[i].prot);
             }
 
             SetLastError(0xdeadbeef);
             ptr = VirtualAlloc(base, si.dwPageSize, MEM_COMMIT, td[i].prot);
-            ok(ptr == base, "%d: VirtualAlloc failed %d\n", i, GetLastError());
+            ok(ptr == base, "%ld: VirtualAlloc failed %ld\n", i, GetLastError());
 
             VirtualFree(base, 0, MEM_RELEASE);
         }
         else
         {
-            ok(!base, "%d: VirtualAlloc should fail\n", i);
-            ok(GetLastError() == ERROR_INVALID_PARAMETER, "%d: expected ERROR_INVALID_PARAMETER, got %d\n", i, GetLastError());
+            ok(!base, "%ld: VirtualAlloc should fail\n", i);
+            ok(GetLastError() == ERROR_INVALID_PARAMETER, "%ld: expected ERROR_INVALID_PARAMETER, got %ld\n", i, GetLastError());
         }
     }
 }
@@ -3457,7 +3457,7 @@ static void test_CreateFileMapping_protection(void)
 
     SetLastError(0xdeadbeef);
     hfile = CreateFileA(file_name, GENERIC_READ|GENERIC_WRITE|GENERIC_EXECUTE, 0, NULL, CREATE_ALWAYS, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile(%s) error %d\n", file_name, GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile(%s) error %ld\n", file_name, GetLastError());
     SetFilePointer(hfile, si.dwPageSize, NULL, FILE_BEGIN);
     SetEndOfFile(hfile);
 
@@ -3470,51 +3470,51 @@ static void test_CreateFileMapping_protection(void)
         {
             if (!hmap)
             {
-                trace("%d: CreateFileMapping(%04x) failed: %d\n", i, td[i].prot, GetLastError());
+                trace("%ld: CreateFileMapping(%04lx) failed: %ld\n", i, td[i].prot, GetLastError());
                 /* NT4 and win2k don't support EXEC on file mappings */
                 if (td[i].prot == PAGE_EXECUTE_READ || td[i].prot == PAGE_EXECUTE_READWRITE)
                 {
                     page_exec_supported = FALSE;
-                    ok(broken(!hmap), "%d: CreateFileMapping doesn't support PAGE_EXECUTE\n", i);
+                    ok(broken(!hmap), "%ld: CreateFileMapping doesn't support PAGE_EXECUTE\n", i);
                     continue;
                 }
                 /* Vista+ supports PAGE_EXECUTE_WRITECOPY, earlier versions don't */
                 if (td[i].prot == PAGE_EXECUTE_WRITECOPY)
                 {
                     page_exec_supported = FALSE;
-                    ok(broken(!hmap), "%d: CreateFileMapping doesn't support PAGE_EXECUTE_WRITECOPY\n", i);
+                    ok(broken(!hmap), "%ld: CreateFileMapping doesn't support PAGE_EXECUTE_WRITECOPY\n", i);
                     continue;
                 }
             }
-            ok(hmap != 0, "%d: CreateFileMapping(%04x) error %d\n", i, td[i].prot, GetLastError());
+            ok(hmap != 0, "%ld: CreateFileMapping(%04lx) error %ld\n", i, td[i].prot, GetLastError());
 
             base = MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0);
-            ok(base != NULL, "%d: MapViewOfFile failed %d\n", i, GetLastError());
+            ok(base != NULL, "%ld: MapViewOfFile failed %ld\n", i, GetLastError());
 
             SetLastError(0xdeadbeef);
             ret = VirtualQuery(base, &info, sizeof(info));
-            ok(ret, "VirtualQuery failed %d\n", GetLastError());
-            ok(info.BaseAddress == base, "%d: got %p != expected %p\n", i, info.BaseAddress, base);
-            ok(info.RegionSize == si.dwPageSize, "%d: got %#lx != expected %#x\n", i, info.RegionSize, si.dwPageSize);
-            ok(info.Protect == PAGE_READONLY, "%d: got %#x != expected PAGE_READONLY\n", i, info.Protect);
-            ok(info.AllocationBase == base, "%d: %p != %p\n", i, info.AllocationBase, base);
-            ok(info.AllocationProtect == PAGE_READONLY, "%d: %#x != PAGE_READONLY\n", i, info.AllocationProtect);
-            ok(info.State == MEM_COMMIT, "%d: %#x != MEM_COMMIT\n", i, info.State);
-            ok(info.Type == MEM_MAPPED, "%d: %#x != MEM_MAPPED\n", i, info.Type);
+            ok(ret, "VirtualQuery failed %ld\n", GetLastError());
+            ok(info.BaseAddress == base, "%ld: got %p != expected %p\n", i, info.BaseAddress, base);
+            ok(info.RegionSize == si.dwPageSize, "%ld: got %#Ix != expected %#lx\n", i, info.RegionSize, si.dwPageSize);
+            ok(info.Protect == PAGE_READONLY, "%ld: got %#lx != expected PAGE_READONLY\n", i, info.Protect);
+            ok(info.AllocationBase == base, "%ld: %p != %p\n", i, info.AllocationBase, base);
+            ok(info.AllocationProtect == PAGE_READONLY, "%ld: %#lx != PAGE_READONLY\n", i, info.AllocationProtect);
+            ok(info.State == MEM_COMMIT, "%ld: %#lx != MEM_COMMIT\n", i, info.State);
+            ok(info.Type == MEM_MAPPED, "%ld: %#lx != MEM_MAPPED\n", i, info.Type);
 
             SetLastError(0xdeadbeef);
             ptr = VirtualAlloc(base, si.dwPageSize, MEM_COMMIT, td[i].prot);
-            ok(!ptr, "%d: VirtualAlloc(%02x) should fail\n", i, td[i].prot);
-            ok(GetLastError() == ERROR_ACCESS_DENIED, "%d: expected ERROR_ACCESS_DENIED, got %d\n", i, GetLastError());
+            ok(!ptr, "%ld: VirtualAlloc(%02lx) should fail\n", i, td[i].prot);
+            ok(GetLastError() == ERROR_ACCESS_DENIED, "%ld: expected ERROR_ACCESS_DENIED, got %ld\n", i, GetLastError());
 
             SetLastError(0xdeadbeef);
             ret = VirtualProtect(base, si.dwPageSize, td[i].prot, &old_prot);
             if (td[i].prot == PAGE_READONLY || td[i].prot == PAGE_WRITECOPY)
-                ok(ret, "%d: VirtualProtect(%02x) error %d\n", i, td[i].prot, GetLastError());
+                ok(ret, "%ld: VirtualProtect(%02lx) error %ld\n", i, td[i].prot, GetLastError());
             else
             {
-                ok(!ret, "%d: VirtualProtect(%02x) should fail\n", i, td[i].prot);
-                ok(GetLastError() == ERROR_INVALID_PARAMETER, "%d: expected ERROR_INVALID_PARAMETER, got %d\n", i, GetLastError());
+                ok(!ret, "%ld: VirtualProtect(%02lx) should fail\n", i, td[i].prot);
+                ok(GetLastError() == ERROR_INVALID_PARAMETER, "%ld: expected ERROR_INVALID_PARAMETER, got %ld\n", i, GetLastError());
             }
 
             UnmapViewOfFile(base);
@@ -3522,8 +3522,8 @@ static void test_CreateFileMapping_protection(void)
         }
         else
         {
-            ok(!hmap, "%d: CreateFileMapping should fail\n", i);
-            ok(GetLastError() == ERROR_INVALID_PARAMETER, "%d: expected ERROR_INVALID_PARAMETER, got %d\n", i, GetLastError());
+            ok(!hmap, "%ld: CreateFileMapping should fail\n", i);
+            ok(GetLastError() == ERROR_INVALID_PARAMETER, "%ld: expected ERROR_INVALID_PARAMETER, got %ld\n", i, GetLastError());
         }
     }
 
@@ -3531,30 +3531,30 @@ static void test_CreateFileMapping_protection(void)
     else alloc_prot = PAGE_READWRITE;
     SetLastError(0xdeadbeef);
     hmap = CreateFileMappingW(hfile, NULL, alloc_prot, 0, si.dwPageSize, NULL);
-    ok(hmap != 0, "%d: CreateFileMapping error %d\n", i, GetLastError());
+    ok(hmap != 0, "%ld: CreateFileMapping error %ld\n", i, GetLastError());
 
     for (i = 0; i < ARRAY_SIZE(td); i++)
     {
         SetLastError(0xdeadbeef);
         base = MapViewOfFile(hmap, FILE_MAP_READ | FILE_MAP_WRITE | (page_exec_supported ? FILE_MAP_EXECUTE : 0), 0, 0, 0);
-        ok(base != NULL, "MapViewOfFile failed %d\n", GetLastError());
+        ok(base != NULL, "MapViewOfFile failed %ld\n", GetLastError());
 
         old_prot = 0xdeadbeef;
         SetLastError(0xdeadbeef);
         ret = VirtualProtect(base, si.dwPageSize, PAGE_NOACCESS, &old_prot);
-        ok(ret, "VirtualProtect error %d\n", GetLastError());
-        ok(old_prot == alloc_prot, "got %#x != expected %#x\n", old_prot, alloc_prot);
+        ok(ret, "VirtualProtect error %ld\n", GetLastError());
+        ok(old_prot == alloc_prot, "got %#lx != expected %#lx\n", old_prot, alloc_prot);
 
         SetLastError(0xdeadbeef);
         ret = VirtualQuery(base, &info, sizeof(info));
-        ok(ret, "VirtualQuery failed %d\n", GetLastError());
-        ok(info.BaseAddress == base, "%d: got %p != expected %p\n", i, info.BaseAddress, base);
-        ok(info.RegionSize == si.dwPageSize, "%d: got %#lx != expected %#x\n", i, info.RegionSize, si.dwPageSize);
-        ok(info.Protect == PAGE_NOACCESS, "%d: got %#x != expected PAGE_NOACCESS\n", i, info.Protect);
-        ok(info.AllocationBase == base, "%d: %p != %p\n", i, info.AllocationBase, base);
-        ok(info.AllocationProtect == alloc_prot, "%d: %#x != %#x\n", i, info.AllocationProtect, alloc_prot);
-        ok(info.State == MEM_COMMIT, "%d: %#x != MEM_COMMIT\n", i, info.State);
-        ok(info.Type == MEM_MAPPED, "%d: %#x != MEM_MAPPED\n", i, info.Type);
+        ok(ret, "VirtualQuery failed %ld\n", GetLastError());
+        ok(info.BaseAddress == base, "%ld: got %p != expected %p\n", i, info.BaseAddress, base);
+        ok(info.RegionSize == si.dwPageSize, "%ld: got %#Ix != expected %#lx\n", i, info.RegionSize, si.dwPageSize);
+        ok(info.Protect == PAGE_NOACCESS, "%ld: got %#lx != expected PAGE_NOACCESS\n", i, info.Protect);
+        ok(info.AllocationBase == base, "%ld: %p != %p\n", i, info.AllocationBase, base);
+        ok(info.AllocationProtect == alloc_prot, "%ld: %#lx != %#lx\n", i, info.AllocationProtect, alloc_prot);
+        ok(info.State == MEM_COMMIT, "%ld: %#lx != MEM_COMMIT\n", i, info.State);
+        ok(info.Type == MEM_MAPPED, "%ld: %#lx != MEM_MAPPED\n", i, info.Type);
 
         old_prot = 0xdeadbeef;
         SetLastError(0xdeadbeef);
@@ -3566,36 +3566,36 @@ static void test_CreateFileMapping_protection(void)
                 /* win2k and XP don't support EXEC on file mappings */
                 if (td[i].prot == PAGE_EXECUTE)
                 {
-                    ok(broken(!ret), "%d: VirtualProtect doesn't support PAGE_EXECUTE\n", i);
+                    ok(broken(!ret), "%ld: VirtualProtect doesn't support PAGE_EXECUTE\n", i);
                     continue;
                 }
                 /* NT4 and win2k don't support EXEC on file mappings */
                 if (td[i].prot == PAGE_EXECUTE_READ || td[i].prot == PAGE_EXECUTE_READWRITE)
                 {
-                    ok(broken(!ret), "%d: VirtualProtect doesn't support PAGE_EXECUTE\n", i);
+                    ok(broken(!ret), "%ld: VirtualProtect doesn't support PAGE_EXECUTE\n", i);
                     continue;
                 }
                 /* Vista+ supports PAGE_EXECUTE_WRITECOPY, earlier versions don't */
                 if (td[i].prot == PAGE_EXECUTE_WRITECOPY)
                 {
-                    ok(broken(!ret), "%d: VirtualProtect doesn't support PAGE_EXECUTE_WRITECOPY\n", i);
+                    ok(broken(!ret), "%ld: VirtualProtect doesn't support PAGE_EXECUTE_WRITECOPY\n", i);
                     continue;
                 }
             }
 
-            ok(ret, "%d: VirtualProtect error %d\n", i, GetLastError());
-            ok(old_prot == PAGE_NOACCESS, "%d: got %#x != expected PAGE_NOACCESS\n", i, old_prot);
+            ok(ret, "%ld: VirtualProtect error %ld\n", i, GetLastError());
+            ok(old_prot == PAGE_NOACCESS, "%ld: got %#lx != expected PAGE_NOACCESS\n", i, old_prot);
 
             SetLastError(0xdeadbeef);
             ret = VirtualQuery(base, &info, sizeof(info));
-            ok(ret, "VirtualQuery failed %d\n", GetLastError());
-            ok(info.BaseAddress == base, "%d: got %p != expected %p\n", i, info.BaseAddress, base);
-            ok(info.RegionSize == si.dwPageSize, "%d: got %#lx != expected %#x\n", i, info.RegionSize, si.dwPageSize);
-            ok(info.Protect == td[i].prot, "%d: got %#x != expected %#x\n", i, info.Protect, td[i].prot);
-            ok(info.AllocationBase == base, "%d: %p != %p\n", i, info.AllocationBase, base);
-            ok(info.AllocationProtect == alloc_prot, "%d: %#x != %#x\n", i, info.AllocationProtect, alloc_prot);
-            ok(info.State == MEM_COMMIT, "%d: %#x != MEM_COMMIT\n", i, info.State);
-            ok(info.Type == MEM_MAPPED, "%d: %#x != MEM_MAPPED\n", i, info.Type);
+            ok(ret, "VirtualQuery failed %ld\n", GetLastError());
+            ok(info.BaseAddress == base, "%ld: got %p != expected %p\n", i, info.BaseAddress, base);
+            ok(info.RegionSize == si.dwPageSize, "%ld: got %#Ix != expected %#lx\n", i, info.RegionSize, si.dwPageSize);
+            ok(info.Protect == td[i].prot, "%ld: got %#lx != expected %#lx\n", i, info.Protect, td[i].prot);
+            ok(info.AllocationBase == base, "%ld: %p != %p\n", i, info.AllocationBase, base);
+            ok(info.AllocationProtect == alloc_prot, "%ld: %#lx != %#lx\n", i, info.AllocationProtect, alloc_prot);
+            ok(info.State == MEM_COMMIT, "%ld: %#lx != MEM_COMMIT\n", i, info.State);
+            ok(info.Type == MEM_MAPPED, "%ld: %#lx != MEM_MAPPED\n", i, info.Type);
 
             if (is_mem_writable(info.Protect))
             {
@@ -3603,26 +3603,26 @@ static void test_CreateFileMapping_protection(void)
 
                 SetLastError(0xdeadbeef);
                 ret = VirtualQuery(base, &info, sizeof(info));
-                ok(ret, "VirtualQuery failed %d\n", GetLastError());
+                ok(ret, "VirtualQuery failed %ld\n", GetLastError());
                 /* FIXME: remove the condition below once Wine is fixed */
                 todo_wine_if (td[i].prot == PAGE_WRITECOPY || td[i].prot == PAGE_EXECUTE_WRITECOPY)
-                    ok(info.Protect == td[i].prot_after_write, "%d: got %#x != expected %#x\n", i, info.Protect, td[i].prot_after_write);
+                    ok(info.Protect == td[i].prot_after_write, "%ld: got %#lx != expected %#lx\n", i, info.Protect, td[i].prot_after_write);
             }
         }
         else
         {
-            ok(!ret, "%d: VirtualProtect should fail\n", i);
-            ok(GetLastError() == ERROR_INVALID_PARAMETER, "%d: expected ERROR_INVALID_PARAMETER, got %d\n", i, GetLastError());
+            ok(!ret, "%ld: VirtualProtect should fail\n", i);
+            ok(GetLastError() == ERROR_INVALID_PARAMETER, "%ld: expected ERROR_INVALID_PARAMETER, got %ld\n", i, GetLastError());
             continue;
         }
 
         old_prot = 0xdeadbeef;
         SetLastError(0xdeadbeef);
         ret = VirtualProtect(base, si.dwPageSize, PAGE_NOACCESS, &old_prot);
-        ok(ret, "%d: VirtualProtect error %d\n", i, GetLastError());
+        ok(ret, "%ld: VirtualProtect error %ld\n", i, GetLastError());
         /* FIXME: remove the condition below once Wine is fixed */
         todo_wine_if (td[i].prot == PAGE_WRITECOPY || td[i].prot == PAGE_EXECUTE_WRITECOPY)
-            ok(old_prot == td[i].prot_after_write, "%d: got %#x != expected %#x\n", i, old_prot, td[i].prot_after_write);
+            ok(old_prot == td[i].prot_after_write, "%ld: got %#lx != expected %#lx\n", i, old_prot, td[i].prot_after_write);
 
         UnmapViewOfFile(base);
     }
@@ -3799,7 +3799,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
     MEMORY_BASIC_INFORMATION info, nt_info;
     BOOL anon_mapping = (hfile == INVALID_HANDLE_VALUE);
 
-    trace( "testing %s mapping flags %08x %s\n", anon_mapping ? "anonymous" : "file",
+    trace( "testing %s mapping flags %08lx %s\n", anon_mapping ? "anonymous" : "file",
             sec_flags, readonly ? "readonly file" : "" );
     for (i = 0; i < ARRAY_SIZE(page_prot); i++)
     {
@@ -3811,9 +3811,9 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
         {
             todo_wine_if(page_prot[i] == PAGE_EXECUTE_READ || page_prot[i] == PAGE_EXECUTE_WRITECOPY)
             {
-                ok(!hmap, "%d: CreateFileMapping(%04x) should fail\n", i, page_prot[i]);
+                ok(!hmap, "%ld: CreateFileMapping(%04lx) should fail\n", i, page_prot[i]);
                 ok(GetLastError() == ERROR_ACCESS_DENIED || broken(GetLastError() == ERROR_INVALID_PARAMETER),
-                        "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+                        "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
             }
             if (hmap) CloseHandle(hmap);
             continue;
@@ -3824,7 +3824,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
             HANDLE hmap2;
 
             ok(!hmap, "CreateFileMapping(PAGE_NOACCESS) should fail\n");
-            ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+            ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
             /* A trick to create a not accessible mapping */
             SetLastError(0xdeadbeef);
@@ -3832,10 +3832,10 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
                 hmap = CreateFileMappingW(hfile, NULL, PAGE_WRITECOPY | sec_flags, 0, si.dwPageSize, NULL);
             else
                 hmap = CreateFileMappingW(hfile, NULL, PAGE_READONLY | sec_flags, 0, si.dwPageSize, NULL);
-            ok(hmap != 0, "CreateFileMapping(PAGE_READWRITE) error %d\n", GetLastError());
+            ok(hmap != 0, "CreateFileMapping(PAGE_READWRITE) error %ld\n", GetLastError());
             SetLastError(0xdeadbeef);
             ret = DuplicateHandle(GetCurrentProcess(), hmap, GetCurrentProcess(), &hmap2, 0, FALSE, 0);
-            ok(ret, "DuplicateHandle error %d\n", GetLastError());
+            ok(ret, "DuplicateHandle error %ld\n", GetLastError());
             CloseHandle(hmap);
             hmap = hmap2;
         }
@@ -3843,13 +3843,13 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
         {
             ok(!hmap, "CreateFileMapping(PAGE_EXECUTE) should fail\n");
             ok(GetLastError() == ERROR_INVALID_PARAMETER,
-               "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+               "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
             continue;
         }
 
         if (!hmap)
         {
-            trace("%d: CreateFileMapping(%04x) failed: %d\n", i, page_prot[i], GetLastError());
+            trace("%ld: CreateFileMapping(%04lx) failed: %ld\n", i, page_prot[i], GetLastError());
 
             if ((sec_flags & SEC_IMAGE) &&
                 (page_prot[i] == PAGE_READWRITE || page_prot[i] == PAGE_EXECUTE_READWRITE))
@@ -3858,18 +3858,18 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
             /* NT4 and win2k don't support EXEC on file mappings */
             if (page_prot[i] == PAGE_EXECUTE_READ || page_prot[i] == PAGE_EXECUTE_READWRITE)
             {
-                ok(broken(!hmap), "%d: CreateFileMapping doesn't support PAGE_EXECUTE\n", i);
+                ok(broken(!hmap), "%ld: CreateFileMapping doesn't support PAGE_EXECUTE\n", i);
                 continue;
             }
             /* Vista+ supports PAGE_EXECUTE_WRITECOPY, earlier versions don't */
             if (page_prot[i] == PAGE_EXECUTE_WRITECOPY)
             {
-                ok(broken(!hmap), "%d: CreateFileMapping doesn't support PAGE_EXECUTE_WRITECOPY\n", i);
+                ok(broken(!hmap), "%ld: CreateFileMapping doesn't support PAGE_EXECUTE_WRITECOPY\n", i);
                 continue;
             }
         }
 
-        ok(hmap != 0, "%d: CreateFileMapping(%04x) error %d\n", i, page_prot[i], GetLastError());
+        ok(hmap != 0, "%ld: CreateFileMapping(%04lx) error %ld\n", i, page_prot[i], GetLastError());
 
         for (j = 0; j < ARRAY_SIZE(view); j++)
         {
@@ -3878,7 +3878,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
             {
                 SetLastError(0xdeadbeef);
                 ret = VirtualQuery(nt_base, &nt_info, sizeof(nt_info));
-                ok(ret, "%d: VirtualQuery failed %d\n", j, GetLastError());
+                ok(ret, "%ld: VirtualQuery failed %ld\n", j, GetLastError());
                 UnmapViewOfFile(nt_base);
             }
 
@@ -3888,22 +3888,22 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
             /* Vista+ supports FILE_MAP_EXECUTE properly, earlier versions don't */
             ok(!nt_base == !base ||
                broken((view[j].access & FILE_MAP_EXECUTE) && !nt_base != !base),
-               "%d: (%04x/%04x) NT %p kernel %p\n", j, page_prot[i], view[j].access, nt_base, base);
+               "%ld: (%04lx/%04lx) NT %p kernel %p\n", j, page_prot[i], view[j].access, nt_base, base);
 
             if (!is_compatible_access(page_prot[i], view[j].access))
             {
                 /* FILE_MAP_EXECUTE | FILE_MAP_COPY broken on XP */
                 if (base != NULL && view[j].access == (FILE_MAP_EXECUTE | FILE_MAP_COPY))
                 {
-                    ok( broken(base != NULL), "%d: MapViewOfFile(%04x/%04x) should fail\n",
+                    ok( broken(base != NULL), "%ld: MapViewOfFile(%04lx/%04lx) should fail\n",
                         j, page_prot[i], view[j].access);
                     UnmapViewOfFile( base );
                 }
                 else
                 {
-                    ok(!base, "%d: MapViewOfFile(%04x/%04x) should fail\n",
+                    ok(!base, "%ld: MapViewOfFile(%04lx/%04lx) should fail\n",
                        j, page_prot[i], view[j].access);
-                    ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %d\n", GetLastError());
+                    ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %ld\n", GetLastError());
                 }
                 continue;
             }
@@ -3911,49 +3911,49 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
             /* Vista+ properly supports FILE_MAP_EXECUTE, earlier versions don't */
             if (!base && (view[j].access & FILE_MAP_EXECUTE))
             {
-                ok(broken(!base), "%d: MapViewOfFile(%04x/%04x) failed %d\n", j, page_prot[i], view[j].access, GetLastError());
+                ok(broken(!base), "%ld: MapViewOfFile(%04lx/%04lx) failed %ld\n", j, page_prot[i], view[j].access, GetLastError());
                 continue;
             }
 
-            ok(base != NULL, "%d: MapViewOfFile(%04x/%04x) failed %d\n", j, page_prot[i], view[j].access, GetLastError());
+            ok(base != NULL, "%ld: MapViewOfFile(%04lx/%04lx) failed %ld\n", j, page_prot[i], view[j].access, GetLastError());
 
             SetLastError(0xdeadbeef);
             ret = VirtualQuery(base, &info, sizeof(info));
-            ok(ret, "%d: VirtualQuery failed %d\n", j, GetLastError());
-            ok(info.BaseAddress == base, "%d: (%04x) got %p, expected %p\n", j, view[j].access, info.BaseAddress, base);
+            ok(ret, "%ld: VirtualQuery failed %ld\n", j, GetLastError());
+            ok(info.BaseAddress == base, "%ld: (%04lx) got %p, expected %p\n", j, view[j].access, info.BaseAddress, base);
             ok(info.RegionSize == 2*si.dwPageSize || (info.RegionSize == si.dwPageSize && (sec_flags & SEC_IMAGE)),
-               "%d: (%04x) got %#lx != expected %#x\n", j, view[j].access, info.RegionSize, 2*si.dwPageSize);
+               "%ld: (%04lx) got %#Ix != expected %#lx\n", j, view[j].access, info.RegionSize, 2*si.dwPageSize);
             if (sec_flags & SEC_IMAGE)
                 ok(info.Protect == PAGE_READONLY,
-                    "%d: (%04x) got %#x, expected %#x\n", j, view[j].access, info.Protect, view[j].prot);
+                    "%ld: (%04lx) got %#lx, expected %#lx\n", j, view[j].access, info.Protect, view[j].prot);
             else
                 ok(info.Protect == view[j].prot ||
                    broken(view[j].prot == PAGE_EXECUTE_READ && info.Protect == PAGE_READONLY) || /* win2k */
                    broken(view[j].prot == PAGE_EXECUTE_READWRITE && info.Protect == PAGE_READWRITE) || /* win2k */
                    broken(view[j].prot == PAGE_EXECUTE_WRITECOPY && info.Protect == PAGE_NOACCESS), /* XP */
-                   "%d: (%04x) got %#x, expected %#x\n", j, view[j].access, info.Protect, view[j].prot);
-            ok(info.AllocationBase == base, "%d: (%04x) got %p, expected %p\n", j, view[j].access, info.AllocationBase, base);
+                   "%ld: (%04lx) got %#lx, expected %#lx\n", j, view[j].access, info.Protect, view[j].prot);
+            ok(info.AllocationBase == base, "%ld: (%04lx) got %p, expected %p\n", j, view[j].access, info.AllocationBase, base);
             if (sec_flags & SEC_IMAGE)
-                ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%d: (%04x) got %#x, expected %#x\n",
+                ok(info.AllocationProtect == PAGE_EXECUTE_WRITECOPY, "%ld: (%04lx) got %#lx, expected %#lx\n",
                    j, view[j].access, info.AllocationProtect, info.Protect);
             else
-                ok(info.AllocationProtect == info.Protect, "%d: (%04x) got %#x, expected %#x\n",
+                ok(info.AllocationProtect == info.Protect, "%ld: (%04lx) got %#lx, expected %#lx\n",
                    j, view[j].access, info.AllocationProtect, info.Protect);
-            ok(info.State == MEM_COMMIT, "%d: (%04x) got %#x, expected MEM_COMMIT\n", j, view[j].access, info.State);
+            ok(info.State == MEM_COMMIT, "%ld: (%04lx) got %#lx, expected MEM_COMMIT\n", j, view[j].access, info.State);
             ok(info.Type == (sec_flags & SEC_IMAGE) ? SEC_IMAGE : MEM_MAPPED,
-               "%d: (%04x) got %#x, expected MEM_MAPPED\n", j, view[j].access, info.Type);
+               "%ld: (%04lx) got %#lx, expected MEM_MAPPED\n", j, view[j].access, info.Type);
 
             if (nt_base && base)
             {
-                ok(nt_info.RegionSize == info.RegionSize, "%d: (%04x) got %#lx != expected %#lx\n", j, view[j].access, nt_info.RegionSize, info.RegionSize);
+                ok(nt_info.RegionSize == info.RegionSize, "%ld: (%04lx) got %#Ix != expected %#Ix\n", j, view[j].access, nt_info.RegionSize, info.RegionSize);
                 ok(nt_info.Protect == info.Protect /* Vista+ */ ||
                    broken(nt_info.AllocationProtect == PAGE_EXECUTE_WRITECOPY && info.Protect == PAGE_NOACCESS), /* XP */
-                   "%d: (%04x) got %#x, expected %#x\n", j, view[j].access, nt_info.Protect, info.Protect);
+                   "%ld: (%04lx) got %#lx, expected %#lx\n", j, view[j].access, nt_info.Protect, info.Protect);
                 ok(nt_info.AllocationProtect == info.AllocationProtect /* Vista+ */ ||
                    broken(nt_info.AllocationProtect == PAGE_EXECUTE_WRITECOPY && info.Protect == PAGE_NOACCESS), /* XP */
-                   "%d: (%04x) got %#x, expected %#x\n", j, view[j].access, nt_info.AllocationProtect, info.AllocationProtect);
-                ok(nt_info.State == info.State, "%d: (%04x) got %#x, expected %#x\n", j, view[j].access, nt_info.State, info.State);
-                ok(nt_info.Type == info.Type, "%d: (%04x) got %#x, expected %#x\n", j, view[j].access, nt_info.Type, info.Type);
+                   "%ld: (%04lx) got %#lx, expected %#lx\n", j, view[j].access, nt_info.AllocationProtect, info.AllocationProtect);
+                ok(nt_info.State == info.State, "%ld: (%04lx) got %#lx, expected %#lx\n", j, view[j].access, nt_info.State, info.State);
+                ok(nt_info.Type == info.Type, "%ld: (%04lx) got %#lx, expected %#lx\n", j, view[j].access, nt_info.Type, info.Type);
             }
 
             prev_prot = info.Protect;
@@ -3976,22 +3976,22 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
                     }
 
                     todo_wine_if(readonly && page_prot[k] == PAGE_WRITECOPY && view[j].prot != PAGE_WRITECOPY)
-                    ok(ret, "VirtualProtect error %d, map %#x, view %#x, requested prot %#x\n", GetLastError(), page_prot[i], view[j].prot, page_prot[k]);
+                    ok(ret, "VirtualProtect error %ld, map %#lx, view %#lx, requested prot %#lx\n", GetLastError(), page_prot[i], view[j].prot, page_prot[k]);
                     todo_wine_if(readonly && page_prot[k] == PAGE_WRITECOPY && view[j].prot != PAGE_WRITECOPY)
-                    ok(old_prot == prev_prot, "got %#x, expected %#x\n", old_prot, prev_prot);
+                    ok(old_prot == prev_prot, "got %#lx, expected %#lx\n", old_prot, prev_prot);
                     prev_prot = actual_prot;
 
                     ret = VirtualQuery(base, &info, sizeof(info));
-                    ok(ret, "%d: VirtualQuery failed %d\n", j, GetLastError());
+                    ok(ret, "%ld: VirtualQuery failed %ld\n", j, GetLastError());
                     todo_wine_if(readonly && page_prot[k] == PAGE_WRITECOPY && view[j].prot != PAGE_WRITECOPY)
                     ok(info.Protect == actual_prot,
-                       "VirtualProtect wrong prot, map %#x, view %#x, requested prot %#x got %#x\n",
+                       "VirtualProtect wrong prot, map %#lx, view %#lx, requested prot %#lx got %#lx\n",
                        page_prot[i], view[j].prot, page_prot[k], info.Protect );
                 }
                 else
                 {
-                    ok(!ret, "VirtualProtect should fail, map %#x, view %#x, requested prot %#x\n", page_prot[i], view[j].prot, page_prot[k]);
-                    ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+                    ok(!ret, "VirtualProtect should fail, map %#lx, view %#lx, requested prot %#lx\n", page_prot[i], view[j].prot, page_prot[k]);
+                    ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
                 }
             }
 
@@ -4004,34 +4004,34 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
                 {
                     if (is_compatible_protection(view[j].prot, page_prot[k]))
                     {
-                        ok(ptr != NULL, "VirtualAlloc error %u, map %#x, view %#x, requested prot %#x\n",
+                        ok(ptr != NULL, "VirtualAlloc error %lu, map %#lx, view %#lx, requested prot %#lx\n",
                            GetLastError(), page_prot[i], view[j].prot, page_prot[k]);
                     }
                     else
                     {
                         /* versions <= Vista accept all protections without checking */
                         ok(!ptr || broken(ptr != NULL),
-                           "VirtualAlloc should fail, map %#x, view %#x, requested prot %#x\n",
+                           "VirtualAlloc should fail, map %#lx, view %#lx, requested prot %#lx\n",
                            page_prot[i], view[j].prot, page_prot[k]);
                         if (!ptr) ok( GetLastError() == ERROR_INVALID_PARAMETER,
-                                      "wrong error %u\n", GetLastError());
+                                      "wrong error %lu\n", GetLastError());
                     }
                     if (ptr)
                     {
                         ret = VirtualQuery(base, &info, sizeof(info));
-                        ok(ret, "%d: VirtualQuery failed %d\n", j, GetLastError());
+                        ok(ret, "%ld: VirtualQuery failed %ld\n", j, GetLastError());
                         ok(info.Protect == page_prot[k] ||
                            /* if the mapping doesn't have write access,
                             *  broken versions silently switch to WRITECOPY */
                            broken( info.Protect == map_prot_no_write(page_prot[k]) ),
-                           "VirtualAlloc wrong prot, map %#x, view %#x, requested prot %#x got %#x\n",
+                           "VirtualAlloc wrong prot, map %#lx, view %#lx, requested prot %#lx got %#lx\n",
                            page_prot[i], view[j].prot, page_prot[k], info.Protect );
                     }
                 }
                 else
                 {
-                    ok(!ptr, "VirtualAlloc(%02x) should fail\n", page_prot[k]);
-                    ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
+                    ok(!ptr, "VirtualAlloc(%02lx) should fail\n", page_prot[k]);
+                    ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %ld\n", GetLastError());
                 }
             }
 
@@ -4039,15 +4039,15 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
             {
                 ret = VirtualProtect(base, sec_flags & SEC_IMAGE ? si.dwPageSize : 2*si.dwPageSize, PAGE_WRITECOPY, &old_prot);
                 todo_wine_if(readonly && view[j].prot != PAGE_WRITECOPY)
-                ok(ret, "VirtualProtect error %d, map %#x, view %#x\n", GetLastError(), page_prot[i], view[j].prot);
+                ok(ret, "VirtualProtect error %ld, map %#lx, view %#lx\n", GetLastError(), page_prot[i], view[j].prot);
                 if (ret) *(DWORD*)base = 0xdeadbeef;
                 ret = VirtualQuery(base, &info, sizeof(info));
-                ok(ret, "%d: VirtualQuery failed %d\n", j, GetLastError());
+                ok(ret, "%ld: VirtualQuery failed %ld\n", j, GetLastError());
                 todo_wine
-                ok(info.Protect == PAGE_READWRITE, "VirtualProtect wrong prot, map %#x, view %#x got %#x\n",
+                ok(info.Protect == PAGE_READWRITE, "VirtualProtect wrong prot, map %#lx, view %#lx got %#lx\n",
                    page_prot[i], view[j].prot, info.Protect );
                 todo_wine_if (!(sec_flags & SEC_IMAGE))
-                ok(info.RegionSize == si.dwPageSize, "wrong region size %#lx after write, map %#x, view %#x got %#x\n",
+                ok(info.RegionSize == si.dwPageSize, "wrong region size %#Ix after write, map %#lx, view %#lx got %#lx\n",
                    info.RegionSize, page_prot[i], view[j].prot, info.Protect );
 
                 prev_prot = info.Protect;
@@ -4056,9 +4056,9 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
                 if (!(sec_flags & SEC_IMAGE))
                 {
                     ret = VirtualQuery((char*)base + si.dwPageSize, &info, sizeof(info));
-                    ok(ret, "%d: VirtualQuery failed %d\n", j, GetLastError());
+                    ok(ret, "%ld: VirtualQuery failed %ld\n", j, GetLastError());
                     todo_wine_if(readonly && view[j].prot != PAGE_WRITECOPY)
-                    ok(info.Protect == PAGE_WRITECOPY, "wrong prot, map %#x, view %#x got %#x\n",
+                    ok(info.Protect == PAGE_WRITECOPY, "wrong prot, map %#lx, view %#lx got %#lx\n",
                        page_prot[i], view[j].prot, info.Protect);
                 }
 
@@ -4078,22 +4078,22 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
                         }
 
                         todo_wine_if(readonly && page_prot[k] == PAGE_WRITECOPY && view[j].prot != PAGE_WRITECOPY)
-                        ok(ret, "VirtualProtect error %d, map %#x, view %#x, requested prot %#x\n", GetLastError(), page_prot[i], view[j].prot, page_prot[k]);
+                        ok(ret, "VirtualProtect error %ld, map %#lx, view %#lx, requested prot %#lx\n", GetLastError(), page_prot[i], view[j].prot, page_prot[k]);
                         todo_wine_if(readonly && page_prot[k] == PAGE_WRITECOPY && view[j].prot != PAGE_WRITECOPY)
-                        ok(old_prot == prev_prot, "got %#x, expected %#x\n", old_prot, prev_prot);
+                        ok(old_prot == prev_prot, "got %#lx, expected %#lx\n", old_prot, prev_prot);
 
                         ret = VirtualQuery(base, &info, sizeof(info));
-                        ok(ret, "%d: VirtualQuery failed %d\n", j, GetLastError());
+                        ok(ret, "%ld: VirtualQuery failed %ld\n", j, GetLastError());
                         todo_wine_if( map_prot_written( page_prot[k] ) != actual_prot )
                         ok(info.Protect == map_prot_written( page_prot[k] ),
-                           "VirtualProtect wrong prot, map %#x, view %#x, requested prot %#x got %#x\n",
+                           "VirtualProtect wrong prot, map %#lx, view %#lx, requested prot %#lx got %#lx\n",
                            page_prot[i], view[j].prot, page_prot[k], info.Protect );
                         prev_prot = info.Protect;
                     }
                     else
                     {
-                        ok(!ret, "VirtualProtect should fail, map %#x, view %#x, requested prot %#x\n", page_prot[i], view[j].prot, page_prot[k]);
-                        ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+                        ok(!ret, "VirtualProtect should fail, map %#lx, view %#lx, requested prot %#lx\n", page_prot[i], view[j].prot, page_prot[k]);
+                        ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
                     }
                 }
             }
@@ -4115,7 +4115,7 @@ static void test_mappings(void)
     GetTempFileNameA(temp_path, "map", 0, file_name);
 
     hfile = CreateFileA(file_name, GENERIC_READ|GENERIC_WRITE|GENERIC_EXECUTE, 0, NULL, CREATE_ALWAYS, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile(%s) error %d\n", file_name, GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile(%s) error %ld\n", file_name, GetLastError());
     SetFilePointer(hfile, 2*si.dwPageSize, NULL, FILE_BEGIN);
     SetEndOfFile(hfile);
 
@@ -4124,14 +4124,14 @@ static void test_mappings(void)
     /* test that file was not modified */
     SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
     ok(ReadFile(hfile, &data, sizeof(data), &num_bytes, NULL), "ReadFile failed\n");
-    ok(num_bytes == sizeof(data), "num_bytes = %d\n", num_bytes);
+    ok(num_bytes == sizeof(data), "num_bytes = %ld\n", num_bytes);
     todo_wine
-    ok(!data, "data = %x\n", data);
+    ok(!data, "data = %lx\n", data);
 
     CloseHandle( hfile );
 
     hfile = CreateFileA(file_name, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
-    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile(%s) error %d\n", file_name, GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile(%s) error %ld\n", file_name, GetLastError());
 
     test_mapping( hfile, SEC_COMMIT, TRUE );
 
@@ -4143,7 +4143,7 @@ static void test_mappings(void)
     strcat( file_name, "\\kernel32.dll" );
 
     hfile = CreateFileA( file_name, GENERIC_READ|GENERIC_EXECUTE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
-    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile(%s) error %d\n", file_name, GetLastError());
+    ok(hfile != INVALID_HANDLE_VALUE, "CreateFile(%s) error %ld\n", file_name, GetLastError());
 
     test_mapping( hfile, SEC_IMAGE, FALSE );
 
@@ -4160,17 +4160,17 @@ static void test_shared_memory(BOOL is_child)
 
     SetLastError(0xdeadbef);
     mapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, "winetest_virtual.c");
-    ok(mapping != 0, "CreateFileMapping error %d\n", GetLastError());
+    ok(mapping != 0, "CreateFileMapping error %ld\n", GetLastError());
     if (is_child)
-        ok(GetLastError() == ERROR_ALREADY_EXISTS, "expected ERROR_ALREADY_EXISTS, got %d\n", GetLastError());
+        ok(GetLastError() == ERROR_ALREADY_EXISTS, "expected ERROR_ALREADY_EXISTS, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbef);
     p = MapViewOfFile(mapping, FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, 4096);
-    ok(p != NULL, "MapViewOfFile error %d\n", GetLastError());
+    ok(p != NULL, "MapViewOfFile error %ld\n", GetLastError());
 
     if (is_child)
     {
-        ok(*p == 0x1a2b3c4d, "expected 0x1a2b3c4d in child, got %#x\n", *p);
+        ok(*p == 0x1a2b3c4d, "expected 0x1a2b3c4d in child, got %#lx\n", *p);
     }
     else
     {
@@ -4185,7 +4185,7 @@ static void test_shared_memory(BOOL is_child)
         winetest_get_mainargs(&argv);
         sprintf(cmdline, "\"%s\" virtual sharedmem", argv[0]);
         ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-        ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError());
+        ok(ret, "CreateProcess(%s) error %ld\n", cmdline, GetLastError());
         wait_child_process(pi.hProcess);
         CloseHandle(pi.hThread);
         CloseHandle(pi.hProcess);
@@ -4202,13 +4202,13 @@ static void test_shared_memory_ro(BOOL is_child, DWORD child_access)
 
     SetLastError(0xdeadbef);
     mapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, "winetest_virtual.c_ro");
-    ok(mapping != 0, "CreateFileMapping error %d\n", GetLastError());
+    ok(mapping != 0, "CreateFileMapping error %ld\n", GetLastError());
     if (is_child)
-        ok(GetLastError() == ERROR_ALREADY_EXISTS, "expected ERROR_ALREADY_EXISTS, got %d\n", GetLastError());
+        ok(GetLastError() == ERROR_ALREADY_EXISTS, "expected ERROR_ALREADY_EXISTS, got %ld\n", GetLastError());
 
     SetLastError(0xdeadbef);
     p = MapViewOfFile(mapping, is_child ? child_access : FILE_MAP_READ, 0, 0, 4096);
-    ok(p != NULL, "MapViewOfFile error %d\n", GetLastError());
+    ok(p != NULL, "MapViewOfFile error %ld\n", GetLastError());
 
     if (is_child)
     {
@@ -4223,17 +4223,17 @@ static void test_shared_memory_ro(BOOL is_child, DWORD child_access)
         DWORD ret;
 
         winetest_get_mainargs(&argv);
-        sprintf(cmdline, "\"%s\" virtual sharedmemro %x", argv[0], child_access);
+        sprintf(cmdline, "\"%s\" virtual sharedmemro %lx", argv[0], child_access);
         ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
-        ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError());
+        ok(ret, "CreateProcess(%s) error %ld\n", cmdline, GetLastError());
         wait_child_process(pi.hProcess);
         CloseHandle(pi.hThread);
         CloseHandle(pi.hProcess);
 
         if(child_access & FILE_MAP_WRITE)
-            ok(*p == 0xdeadbeef, "*p = %x, expected 0xdeadbeef\n", *p);
+            ok(*p == 0xdeadbeef, "*p = %lx, expected 0xdeadbeef\n", *p);
         else
-            ok(!*p, "*p = %x, expected 0\n", *p);
+            ok(!*p, "*p = %lx, expected 0\n", *p);
     }
 
     UnmapViewOfFile(p);
@@ -4269,10 +4269,10 @@ START_TEST(virtual)
             BOOL ret;
             mem = VirtualAlloc(NULL, 1<<20, MEM_COMMIT|MEM_RESERVE,
                                PAGE_EXECUTE_READWRITE);
-            ok(mem != NULL, "VirtualAlloc failed %u\n", GetLastError());
+            ok(mem != NULL, "VirtualAlloc failed %lu\n", GetLastError());
             if (mem == NULL) break;
             ret = VirtualFree(mem, 0, MEM_RELEASE);
-            ok(ret, "VirtualFree failed %u\n", GetLastError());
+            ok(ret, "VirtualFree failed %lu\n", GetLastError());
             if (!ret) break;
         }
         return;
@@ -4297,7 +4297,7 @@ START_TEST(virtual)
     pVirtualAllocFromApp = (void *)GetProcAddress( hkernelbase, "VirtualAllocFromApp" );
 
     GetSystemInfo(&si);
-    trace("system page size %#x\n", si.dwPageSize);
+    trace("system page size %#lx\n", si.dwPageSize);
 
     test_shared_memory(FALSE);
     test_shared_memory_ro(FALSE, FILE_MAP_READ|FILE_MAP_WRITE);
diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c
index 723dfabb817..9166cf228d9 100644
--- a/dlls/kernel32/tests/volume.c
+++ b/dlls/kernel32/tests/volume.c
@@ -74,20 +74,20 @@ static void test_query_dos_deviceA(void)
     SetLastError(0xdeadbeef);
     ret = QueryDosDeviceA( NULL, NULL, 0 );
     ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
-       "QueryDosDeviceA(no buffer): returned %u, le=%u\n", ret, GetLastError());
+       "QueryDosDeviceA(no buffer): returned %lu, le=%lu\n", ret, GetLastError());
 
     buffer = HeapAlloc( GetProcessHeap(), 0, buflen );
     SetLastError(0xdeadbeef);
     ret = QueryDosDeviceA( NULL, buffer, buflen );
     ok((ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER),
-        "QueryDosDeviceA failed to return list, last error %u\n", GetLastError());
+        "QueryDosDeviceA failed to return list, last error %lu\n", GetLastError());
 
     if (ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
         p = buffer;
         for (;;) {
             if (!*p) break;
             ret2 = QueryDosDeviceA( p, buffer2, sizeof(buffer2) );
-            ok(ret2, "QueryDosDeviceA failed to return current mapping for %s, last error %u\n", p, GetLastError());
+            ok(ret2, "QueryDosDeviceA failed to return current mapping for %s, last error %lu\n", p, GetLastError());
             p += strlen(p) + 1;
             if (ret <= (p-buffer)) break;
         }
@@ -97,7 +97,7 @@ static void test_query_dos_deviceA(void)
         /* Older W2K fails with ERROR_INSUFFICIENT_BUFFER when buflen is > 32767 */
         ret = QueryDosDeviceA( drivestr, buffer, buflen - 1);
         ok(ret || GetLastError() == ERROR_FILE_NOT_FOUND,
-            "QueryDosDeviceA failed to return current mapping for %s, last error %u\n", drivestr, GetLastError());
+            "QueryDosDeviceA failed to return current mapping for %s, last error %lu\n", drivestr, GetLastError());
         if(ret) {
             for (p = buffer; *p; p++) *p = toupper(*p);
             if (strstr(buffer, "HARDDISK") || strstr(buffer, "RAMDISK")) found = TRUE;
@@ -127,16 +127,16 @@ static void test_dos_devices(void)
     }
 
     ret = DefineDosDeviceA( 0, drivestr, "C:/windows/" );
-    ok(ret, "failed to define drive %s, error %u\n", drivestr, GetLastError());
+    ok(ret, "failed to define drive %s, error %lu\n", drivestr, GetLastError());
 
     ret = QueryDosDeviceA( drivestr, buf, sizeof(buf) );
-    ok(ret, "failed to query drive %s, error %u\n", drivestr, GetLastError());
+    ok(ret, "failed to query drive %s, error %lu\n", drivestr, GetLastError());
     ok(!strcmp(buf, "\\??\\C:\\windows\\"), "got path %s\n", debugstr_a(buf));
 
     sprintf(buf, "%s/system32", drivestr);
     file = CreateFileA( buf, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
             OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL );
-    todo_wine ok(file != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
+    todo_wine ok(file != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError());
     CloseHandle( file );
 
     /* but it's not a volume mount point */
@@ -144,47 +144,47 @@ static void test_dos_devices(void)
     sprintf(buf, "%s\\", drivestr);
     ret = GetVolumeNameForVolumeMountPointA( buf, buf2, sizeof(buf2) );
     ok(!ret, "expected failure\n");
-    todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %lu\n", GetLastError());
 
     ret = DefineDosDeviceA(DDD_REMOVE_DEFINITION, drivestr, NULL);
-    ok(ret, "failed to remove drive %s, error %u\n", drivestr, GetLastError());
+    ok(ret, "failed to remove drive %s, error %lu\n", drivestr, GetLastError());
 
     ret = QueryDosDeviceA( drivestr, buf, sizeof(buf) );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %lu\n", GetLastError());
 
     sprintf(buf, "%s/system32", drivestr);
     file = CreateFileA( buf, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
             OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL );
     ok(file == INVALID_HANDLE_VALUE, "expected failure\n");
-    todo_wine ok(GetLastError() == ERROR_PATH_NOT_FOUND, "got error %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_PATH_NOT_FOUND, "got error %lu\n", GetLastError());
 
     /* try with DDD_RAW_TARGET_PATH */
 
     ret = DefineDosDeviceA( DDD_RAW_TARGET_PATH, drivestr, "\\??\\C:\\windows\\" );
-    ok(ret, "failed to define drive %s, error %u\n", drivestr, GetLastError());
+    ok(ret, "failed to define drive %s, error %lu\n", drivestr, GetLastError());
 
     ret = QueryDosDeviceA( drivestr, buf, sizeof(buf) );
-    ok(ret, "failed to query drive %s, error %u\n", drivestr, GetLastError());
+    ok(ret, "failed to query drive %s, error %lu\n", drivestr, GetLastError());
     ok(!strcmp(buf, "\\??\\C:\\windows\\"), "got path %s\n", debugstr_a(buf));
 
     sprintf(buf, "%s/system32", drivestr);
     file = CreateFileA( buf, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
             OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL );
-    todo_wine ok(file != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
+    todo_wine ok(file != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError());
     CloseHandle( file );
 
     sprintf(buf, "%s\\", drivestr);
     ret = GetVolumeNameForVolumeMountPointA( buf, buf2, sizeof(buf2) );
     ok(!ret, "expected failure\n");
-    todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %u\n", GetLastError());
+    todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %lu\n", GetLastError());
 
     ret = DefineDosDeviceA(DDD_REMOVE_DEFINITION, drivestr, NULL);
-    ok(ret, "failed to remove drive %s, error %u\n", drivestr, GetLastError());
+    ok(ret, "failed to remove drive %s, error %lu\n", drivestr, GetLastError());
 
     ret = QueryDosDeviceA( drivestr, buf, sizeof(buf) );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "got error %lu\n", GetLastError());
 }
 
 static void test_FindFirstVolume(void)
@@ -202,12 +202,12 @@ static void test_FindFirstVolume(void)
     ok( handle == INVALID_HANDLE_VALUE, "succeeded with short buffer\n" );
     ok( GetLastError() == ERROR_MORE_DATA ||  /* XP */
         GetLastError() == ERROR_FILENAME_EXCED_RANGE,  /* Vista */
-        "wrong error %u\n", GetLastError() );
+        "wrong error %lu\n", GetLastError() );
     handle = pFindFirstVolumeA( volume, 49 );
     ok( handle == INVALID_HANDLE_VALUE, "succeeded with short buffer\n" );
-    ok( GetLastError() == ERROR_FILENAME_EXCED_RANGE, "wrong error %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_FILENAME_EXCED_RANGE, "wrong error %lu\n", GetLastError() );
     handle = pFindFirstVolumeA( volume, 51 );
-    ok( handle != INVALID_HANDLE_VALUE, "failed err %u\n", GetLastError() );
+    ok( handle != INVALID_HANDLE_VALUE, "failed err %lu\n", GetLastError() );
     if (handle != INVALID_HANDLE_VALUE)
     {
         do
@@ -216,7 +216,7 @@ static void test_FindFirstVolume(void)
             ok( !memcmp( volume, "\\\\?\\Volume{", 11 ), "bad volume name %s\n", volume );
             ok( !memcmp( volume + 47, "}\\", 2 ), "bad volume name %s\n", volume );
         } while (pFindNextVolumeA( handle, volume, MAX_PATH ));
-        ok( GetLastError() == ERROR_NO_MORE_FILES, "wrong error %u\n", GetLastError() );
+        ok( GetLastError() == ERROR_NO_MORE_FILES, "wrong error %lu\n", GetLastError() );
         pFindVolumeClose( handle );
     }
 }
@@ -229,14 +229,14 @@ static void test_GetVolumeNameForVolumeMountPointA(void)
     char temp_path[MAX_PATH];
 
     reti = GetTempPathA(MAX_PATH, temp_path);
-    ok(reti != 0, "GetTempPathA error %d\n", GetLastError());
+    ok(reti != 0, "GetTempPathA error %ld\n", GetLastError());
     ok(reti < MAX_PATH, "temp path should fit into MAX_PATH\n");
 
     ret = GetVolumeNameForVolumeMountPointA(path, volume, 0);
     ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
     ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE ||
         GetLastError() == ERROR_INVALID_PARAMETER, /* Vista */
-        "wrong error, last=%d\n", GetLastError());
+        "wrong error, last=%ld\n", GetLastError());
 
     if (0) { /* these crash on XP */
     ret = GetVolumeNameForVolumeMountPointA(path, NULL, len);
@@ -255,7 +255,7 @@ static void test_GetVolumeNameForVolumeMountPointA(void)
     /* test with too small buffer */
     ret = GetVolumeNameForVolumeMountPointA(path, volume, 10);
     ok(ret == FALSE && GetLastError() == ERROR_FILENAME_EXCED_RANGE,
-            "GetVolumeNameForVolumeMountPointA failed, wrong error returned, was %d, should be ERROR_FILENAME_EXCED_RANGE\n",
+            "GetVolumeNameForVolumeMountPointA failed, wrong error returned, was %ld, should be ERROR_FILENAME_EXCED_RANGE\n",
              GetLastError());
 
     /* Try on an arbitrary directory */
@@ -264,7 +264,7 @@ static void test_GetVolumeNameForVolumeMountPointA(void)
     ret = GetVolumeNameForVolumeMountPointA(temp_path, volume, len);
     ok(ret == FALSE && (GetLastError() == ERROR_NOT_A_REPARSE_POINT ||
         GetLastError() == ERROR_INVALID_FUNCTION),
-        "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n",
+        "GetVolumeNameForVolumeMountPointA failed on %s, last=%ld\n",
         temp_path, GetLastError());
 
     /* Try on a nonexistent dos drive */
@@ -278,14 +278,14 @@ static void test_GetVolumeNameForVolumeMountPointA(void)
         path[2] = '\\';
         ret = GetVolumeNameForVolumeMountPointA(path, volume, len);
         ok(ret == FALSE && GetLastError() == ERROR_FILE_NOT_FOUND,
-            "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n",
+            "GetVolumeNameForVolumeMountPointA failed on %s, last=%ld\n",
             path, GetLastError());
 
         /* Try without trailing \ and on a nonexistent dos drive  */
         path[2] = 0;
         ret = GetVolumeNameForVolumeMountPointA(path, volume, len);
         ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
-            "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n",
+            "GetVolumeNameForVolumeMountPointA failed on %s, last=%ld\n",
             path, GetLastError());
     }
 }
@@ -300,7 +300,7 @@ static void test_GetVolumeNameForVolumeMountPointW(void)
     ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n");
     ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE ||
         GetLastError() == ERROR_INVALID_PARAMETER, /* Vista */
-        "wrong error, last=%d\n", GetLastError());
+        "wrong error, last=%ld\n", GetLastError());
 
     if (0) { /* these crash on XP */
     ret = GetVolumeNameForVolumeMountPointW(path, NULL, len);
@@ -403,34 +403,34 @@ static void test_GetVolumeInformationA(void)
     /* get windows drive letter and update strings for testing */
     result = GetWindowsDirectoryA(windowsdir, sizeof(windowsdir));
     ok(result < sizeof(windowsdir), "windowsdir is abnormally long!\n");
-    ok(result != 0, "GetWindowsDirectory: error %d\n", GetLastError());
+    ok(result != 0, "GetWindowsDirectory: error %ld\n", GetLastError());
     Root_Colon[0] = windowsdir[0];
     Root_Slash[0] = windowsdir[0];
     Root_UNC[4] = windowsdir[0];
 
     result = GetCurrentDirectoryA(MAX_PATH, currentdir);
-    ok(result, "GetCurrentDirectory: error %d\n", GetLastError());
+    ok(result, "GetCurrentDirectory: error %ld\n", GetLastError());
     /* Note that GetCurrentDir yields no trailing slash for subdirs */
 
     /* check for NO error on no trailing \ when current dir is root dir */
     ret = SetCurrentDirectoryA(Root_Slash);
-    ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
+    ok(ret, "SetCurrentDirectory: error %ld\n", GetLastError());
     ret = GetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
             NULL, NULL, fs_name_buf, fs_name_len);
-    ok(ret, "GetVolumeInformationA root failed, last error %u\n", GetLastError());
+    ok(ret, "GetVolumeInformationA root failed, last error %lu\n", GetLastError());
 
     /* check for error on no trailing \ when current dir is subdir (windows) of queried drive */
     ret = SetCurrentDirectoryA(windowsdir);
-    ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
+    ok(ret, "SetCurrentDirectory: error %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = GetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
             NULL, NULL, fs_name_buf, fs_name_len);
     ok(!ret && (GetLastError() == ERROR_INVALID_NAME),
-        "GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError());
+        "GetVolumeInformationA did%s fail, last error %lu\n", ret ? " not":"", GetLastError());
 
     /* reset current directory */
     ret = SetCurrentDirectoryA(currentdir);
-    ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
+    ok(ret, "SetCurrentDirectory: error %ld\n", GetLastError());
 
     if (toupper(currentdir[0]) == toupper(windowsdir[0])) {
         skip("Please re-run from another device than %c:\n", windowsdir[0]);
@@ -445,26 +445,26 @@ static void test_GetVolumeInformationA(void)
         ok(ret, "SetEnvironmentVariable %s failed\n", Root_Env);
 
         ret = SetCurrentDirectoryA(windowsdir);
-        ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
+        ok(ret, "SetCurrentDirectory: error %ld\n", GetLastError());
         ret = SetCurrentDirectoryA(currentdir);
-        ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
+        ok(ret, "SetCurrentDirectory: error %ld\n", GetLastError());
 
         /* windows dir is current on the root drive, call fails */
         SetLastError(0xdeadbeef);
         ret = GetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
                 NULL, NULL, fs_name_buf, fs_name_len);
         ok(!ret && (GetLastError() == ERROR_INVALID_NAME),
-           "GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError());
+           "GetVolumeInformationA did%s fail, last error %lu\n", ret ? " not":"", GetLastError());
 
         /* Try normal drive letter with trailing \ */
         ret = GetVolumeInformationA(Root_Slash, vol_name_buf, vol_name_size, NULL,
                 NULL, NULL, fs_name_buf, fs_name_len);
-        ok(ret, "GetVolumeInformationA with \\ failed, last error %u\n", GetLastError());
+        ok(ret, "GetVolumeInformationA with \\ failed, last error %lu\n", GetLastError());
 
         ret = SetCurrentDirectoryA(Root_Slash);
-        ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
+        ok(ret, "SetCurrentDirectory: error %ld\n", GetLastError());
         ret = SetCurrentDirectoryA(currentdir);
-        ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
+        ok(ret, "SetCurrentDirectory: error %ld\n", GetLastError());
 
         /* windows dir is STILL CURRENT on root drive; the call fails as before,   */
         /* proving that SetCurrentDir did not remember the other drive's directory */
@@ -472,7 +472,7 @@ static void test_GetVolumeInformationA(void)
         ret = GetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
                 NULL, NULL, fs_name_buf, fs_name_len);
         ok(!ret && (GetLastError() == ERROR_INVALID_NAME),
-           "GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError());
+           "GetVolumeInformationA did%s fail, last error %lu\n", ret ? " not":"", GetLastError());
 
         /* Now C:\ becomes the current directory on drive C: */
         ret = SetEnvironmentVariableA(Root_Env, Root_Slash); /* set =C:=C:\ */
@@ -481,42 +481,42 @@ static void test_GetVolumeInformationA(void)
         /* \ is current on root drive, call succeeds */
         ret = GetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
                 NULL, NULL, fs_name_buf, fs_name_len);
-        ok(ret, "GetVolumeInformationA failed, last error %u\n", GetLastError());
+        ok(ret, "GetVolumeInformationA failed, last error %lu\n", GetLastError());
 
         /* again, SetCurrentDirectory on another drive does not matter */
         ret = SetCurrentDirectoryA(Root_Slash);
-        ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
+        ok(ret, "SetCurrentDirectory: error %ld\n", GetLastError());
         ret = SetCurrentDirectoryA(currentdir);
-        ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
+        ok(ret, "SetCurrentDirectory: error %ld\n", GetLastError());
 
         /* \ is current on root drive, call succeeds */
         ret = GetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
                 NULL, NULL, fs_name_buf, fs_name_len);
-        ok(ret, "GetVolumeInformationA failed, last error %u\n", GetLastError());
+        ok(ret, "GetVolumeInformationA failed, last error %lu\n", GetLastError());
     }
 
     /* try null root directory to return "root of the current directory"  */
     ret = GetVolumeInformationA(NULL, vol_name_buf, vol_name_size, NULL,
             NULL, NULL, fs_name_buf, fs_name_len);
-    ok(ret, "GetVolumeInformationA failed on null root dir, last error %u\n", GetLastError());
+    ok(ret, "GetVolumeInformationA failed on null root dir, last error %lu\n", GetLastError());
 
     /* Try normal drive letter with trailing \  */
     ret = GetVolumeInformationA(Root_Slash, vol_name_buf, vol_name_size,
             &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
-    ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", Root_Slash, GetLastError());
+    ok(ret, "GetVolumeInformationA failed, root=%s, last error=%lu\n", Root_Slash, GetLastError());
 
     /* try again with drive letter and the "disable parsing" prefix */
     SetLastError(0xdeadbeef);
     ret = GetVolumeInformationA(Root_UNC, vol_name_buf, vol_name_size,
             &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
-    ok(ret, "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", Root_UNC, GetLastError());
+    ok(ret, "GetVolumeInformationA did%s fail, root=%s, last error=%lu\n", ret ? " not":"", Root_UNC, GetLastError());
 
     /* try again with device name space  */
     Root_UNC[2] = '.';
     SetLastError(0xdeadbeef);
     ret = GetVolumeInformationA(Root_UNC, vol_name_buf, vol_name_size,
             &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
-    ok(ret, "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", Root_UNC, GetLastError());
+    ok(ret, "GetVolumeInformationA did%s fail, root=%s, last error=%lu\n", ret ? " not":"", Root_UNC, GetLastError());
 
     /* try again with a directory off the root - should generate error  */
     if (windowsdir[strlen(windowsdir)-1] != '\\') strcat(windowsdir, "\\");
@@ -524,14 +524,14 @@ static void test_GetVolumeInformationA(void)
     ret = GetVolumeInformationA(windowsdir, vol_name_buf, vol_name_size,
             &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
     ok(!ret && (GetLastError()==ERROR_DIR_NOT_ROOT),
-          "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", windowsdir, GetLastError());
+          "GetVolumeInformationA did%s fail, root=%s, last error=%lu\n", ret ? " not":"", windowsdir, GetLastError());
     /* A subdir with trailing \ yields DIR_NOT_ROOT instead of INVALID_NAME */
     if (windowsdir[strlen(windowsdir)-1] == '\\') windowsdir[strlen(windowsdir)-1] = 0;
     SetLastError(0xdeadbeef);
     ret = GetVolumeInformationA(windowsdir, vol_name_buf, vol_name_size,
             &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
     ok(!ret && (GetLastError()==ERROR_INVALID_NAME),
-          "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", windowsdir, GetLastError());
+          "GetVolumeInformationA did%s fail, root=%s, last error=%lu\n", ret ? " not":"", windowsdir, GetLastError());
 
     /* get the unique volume name for the windows drive  */
     ret = GetVolumeNameForVolumeMountPointA(Root_Slash, volume, MAX_PATH);
@@ -540,7 +540,7 @@ static void test_GetVolumeInformationA(void)
     /* try again with unique volume name */
     ret = GetVolumeInformationA(volume, vol_name_buf, vol_name_size,
             &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
-    ok(ret, "GetVolumeInformationA failed, root=%s, last error=%u\n", volume, GetLastError());
+    ok(ret, "GetVolumeInformationA failed, root=%s, last error=%lu\n", volume, GetLastError());
 }
 
 /* Test to check that unique volume name from windows dir mount point  */
@@ -559,7 +559,7 @@ static void test_enum_vols(void)
     /*get windows drive letter and update strings for testing  */
     ret = GetWindowsDirectoryA( windowsdir, sizeof(windowsdir) );
     ok(ret < sizeof(windowsdir), "windowsdir is abnormally long!\n");
-    ok(ret != 0, "GetWindowsDirectory: error %d\n", GetLastError());
+    ok(ret != 0, "GetWindowsDirectory: error %ld\n", GetLastError());
     path[0] = windowsdir[0];
 
     /* get the unique volume name for the windows drive  */
@@ -569,7 +569,7 @@ static void test_enum_vols(void)
 
     /* get first unique volume name of list  */
     hFind = pFindFirstVolumeA( Volume_2, MAX_PATH );
-    ok(hFind != INVALID_HANDLE_VALUE, "FindFirstVolume failed, err=%u\n",
+    ok(hFind != INVALID_HANDLE_VALUE, "FindFirstVolume failed, err=%lu\n",
                 GetLastError());
 
     do
@@ -596,7 +596,7 @@ static void test_disk_extents(void)
     handle = CreateFileA( "\\\\.\\c:", GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
     if (handle == INVALID_HANDLE_VALUE)
     {
-        win_skip("can't open c: drive %u\n", GetLastError());
+        win_skip("can't open c: drive %lu\n", GetLastError());
         return;
     }
     size = 0;
@@ -608,8 +608,8 @@ static void test_disk_extents(void)
         CloseHandle( handle );
         return;
     }
-    ok(ret, "DeviceIoControl failed %u\n", GetLastError());
-    ok(size == 32, "expected 32, got %u\n", size);
+    ok(ret, "DeviceIoControl failed %lu\n", GetLastError());
+    ok(size == 32, "expected 32, got %lu\n", size);
     CloseHandle( handle );
 }
 
@@ -627,7 +627,7 @@ static void test_disk_query_property(void)
                          0, 0);
     if (handle == INVALID_HANDLE_VALUE)
     {
-        win_skip("can't open \\\\.\\PhysicalDrive0 %#x\n", GetLastError());
+        win_skip("can't open \\\\.\\PhysicalDrive0 %#lx\n", GetLastError());
         return;
     }
 
@@ -639,20 +639,20 @@ static void test_disk_query_property(void)
                           NULL);
     error = GetLastError();
     ok(ret, "expect ret %#x, got %#x\n", TRUE, ret);
-    ok(error == 0xdeadbeef, "expect err %#x, got err %#x\n", 0xdeadbeef, error);
-    ok(size == sizeof(header), "got size %d\n", size);
-    ok(header.Version == sizeof(descriptor), "got header.Version %d\n", header.Version);
-    ok(header.Size >= sizeof(descriptor), "got header.Size %d\n", header.Size);
+    ok(error == 0xdeadbeef, "expect err %#x, got err %#lx\n", 0xdeadbeef, error);
+    ok(size == sizeof(header), "got size %ld\n", size);
+    ok(header.Version == sizeof(descriptor), "got header.Version %ld\n", header.Version);
+    ok(header.Size >= sizeof(descriptor), "got header.Size %ld\n", header.Size);
 
     SetLastError(0xdeadbeef);
     ret = DeviceIoControl(handle, IOCTL_STORAGE_QUERY_PROPERTY, &query, sizeof(query), &descriptor, sizeof(descriptor),
                           &size, NULL);
     error = GetLastError();
     ok(ret, "expect ret %#x, got %#x\n", TRUE, ret);
-    ok(error == 0xdeadbeef, "expect err %#x, got err %#x\n", 0xdeadbeef, error);
-    ok(size == sizeof(descriptor), "got size %d\n", size);
-    ok(descriptor.Version == sizeof(descriptor), "got descriptor.Version %d\n", descriptor.Version);
-    ok(descriptor.Size >= sizeof(descriptor), "got descriptor.Size %d\n", descriptor.Size);
+    ok(error == 0xdeadbeef, "expect err %#x, got err %#lx\n", 0xdeadbeef, error);
+    ok(size == sizeof(descriptor), "got size %ld\n", size);
+    ok(descriptor.Version == sizeof(descriptor), "got descriptor.Version %ld\n", descriptor.Version);
+    ok(descriptor.Size >= sizeof(descriptor), "got descriptor.Size %ld\n", descriptor.Size);
 
     CloseHandle(handle);
 }
@@ -844,7 +844,7 @@ static void test_GetVolumePathNameA(void)
         {
             /* On success Windows always returns ERROR_MORE_DATA, so only worry about failure */
             success = (error == test_paths[i].error || broken(error == test_paths[i].broken_error));
-            ok(success, "GetVolumePathName test %d unexpectedly returned error 0x%x (expected 0x%x).\n",
+            ok(success, "GetVolumePathName test %d unexpectedly returned error 0x%lx (expected 0x%lx).\n",
                         i, error, test_paths[i].error);
         }
 
@@ -854,14 +854,14 @@ static void test_GetVolumePathNameA(void)
     }
 
     ret = GetCurrentDirectoryA( sizeof(cwd), cwd );
-    ok(ret, "Failed to obtain the current working directory, error %u.\n", GetLastError());
+    ok(ret, "Failed to obtain the current working directory, error %lu.\n", GetLastError());
     ret = GetVolumePathNameA( cwd, expect_path, sizeof(expect_path) );
-    ok(ret, "Failed to obtain the current volume path, error %u.\n", GetLastError());
+    ok(ret, "Failed to obtain the current volume path, error %lu.\n", GetLastError());
 
     for (i = 0; i < ARRAY_SIZE(relative_tests); i++)
     {
         ret = GetVolumePathNameA( relative_tests[i], volume_path, sizeof(volume_path) );
-        ok(ret, "GetVolumePathName(%s) failed unexpectedly, error %u.\n",
+        ok(ret, "GetVolumePathName(%s) failed unexpectedly, error %lu.\n",
                 debugstr_a( relative_tests[i] ), GetLastError());
         ok(!strcmp( volume_path, expect_path ), "%s: expected %s, got %s.\n",
                 debugstr_a( relative_tests[i] ), debugstr_a( expect_path ), debugstr_a( volume_path ));
@@ -871,27 +871,27 @@ static void test_GetVolumePathNameA(void)
     for (i = 0; i < ARRAY_SIZE(global_prefix_tests); i++)
     {
         ret = GetVolumePathNameA( global_prefix_tests[i], volume_path, sizeof(volume_path) );
-        ok(ret, "GetVolumePathName(%s) failed unexpectedly, error %u.\n",
+        ok(ret, "GetVolumePathName(%s) failed unexpectedly, error %lu.\n",
                 debugstr_a( global_prefix_tests[i] ), GetLastError());
         ok(!strcmp( volume_path, cwd ), "%s: expected %s, got %s.\n",
                 debugstr_a( global_prefix_tests[i] ), debugstr_a( cwd ), debugstr_a( volume_path ));
     }
 
     ret = GetVolumePathNameA( "C:.", expect_path, sizeof(expect_path) );
-    ok(ret, "Failed to obtain the volume path, error %u.\n", GetLastError());
+    ok(ret, "Failed to obtain the volume path, error %lu.\n", GetLastError());
 
     SetLastError( 0xdeadbeef );
     ret = GetVolumePathNameA( "C::", volume_path, 1 );
     ok(!ret, "Expected failure.\n");
-    ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE, "Got error %u.\n", GetLastError());
+    ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE, "Got error %lu.\n", GetLastError());
 
     ret = GetVolumePathNameA( "C::", volume_path, sizeof(volume_path) );
-    ok(ret, "Failed to obtain the volume path, error %u.\n", GetLastError());
+    ok(ret, "Failed to obtain the volume path, error %lu.\n", GetLastError());
     ok(!strcmp(volume_path, expect_path), "Expected %s, got %s.\n",
             debugstr_a( expect_path ), debugstr_a( volume_path ));
 
     ret = GetVolumePathNameA( "C:ABC:DEF:\\AnInvalidFolder", volume_path, sizeof(volume_path) );
-    ok(ret, "Failed to obtain the volume path, error %u.\n", GetLastError());
+    ok(ret, "Failed to obtain the volume path, error %lu.\n", GetLastError());
     ok(!strcmp(volume_path, expect_path), "Expected %s, got %s.\n",
             debugstr_a( expect_path ), debugstr_a( volume_path ));
 }
@@ -905,7 +905,7 @@ static void test_GetVolumePathNameW(void)
     volume_path[1] = 0x11;
     ret = GetVolumePathNameW( L"C:\\", volume_path, 1 );
     ok(!ret, "GetVolumePathNameW test succeeded unexpectedly.\n");
-    ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE, "GetVolumePathNameW unexpectedly returned error 0x%x (expected 0x%x).\n",
+    ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE, "GetVolumePathNameW unexpectedly returned error 0x%lx (expected 0x%x).\n",
         GetLastError(), ERROR_FILENAME_EXCED_RANGE);
     ok(volume_path[1] == 0x11, "GetVolumePathW corrupted byte after end of buffer.\n");
 
@@ -913,7 +913,7 @@ static void test_GetVolumePathNameW(void)
     volume_path[2] = 0x11;
     ret = GetVolumePathNameW( L"C:\\", volume_path, 2 );
     ok(!ret, "GetVolumePathNameW test succeeded unexpectedly.\n");
-    ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE, "GetVolumePathNameW unexpectedly returned error 0x%x (expected 0x%x).\n",
+    ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE, "GetVolumePathNameW unexpectedly returned error 0x%lx (expected 0x%x).\n",
         GetLastError(), ERROR_FILENAME_EXCED_RANGE);
     ok(volume_path[2] == 0x11, "GetVolumePathW corrupted byte after end of buffer.\n");
 
@@ -946,36 +946,36 @@ static void test_GetVolumePathNamesForVolumeNameA(void)
     }
 
     ret = GetVolumeNameForVolumeMountPointA( "c:\\", volume, sizeof(volume) );
-    ok(ret, "failed to get volume name %u\n", GetLastError());
+    ok(ret, "failed to get volume name %lu\n", GetLastError());
     trace("c:\\ -> %s\n", volume);
 
     SetLastError( 0xdeadbeef );
     ret = pGetVolumePathNamesForVolumeNameA( NULL, NULL, 0, NULL );
     error = GetLastError();
     ok(!ret, "expected failure\n");
-    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %u\n", error);
+    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %lu\n", error);
 
     SetLastError( 0xdeadbeef );
     ret = pGetVolumePathNamesForVolumeNameA( "", NULL, 0, NULL );
     error = GetLastError();
     ok(!ret, "expected failure\n");
-    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %u\n", error);
+    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %lu\n", error);
 
     SetLastError( 0xdeadbeef );
     ret = pGetVolumePathNamesForVolumeNameA( volume, NULL, 0, NULL );
     error = GetLastError();
     ok(!ret, "expected failure\n");
-    ok(error == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %u\n", error);
+    ok(error == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %lu\n", error);
 
     SetLastError( 0xdeadbeef );
     ret = pGetVolumePathNamesForVolumeNameA( volume, buffer, 0, NULL );
     error = GetLastError();
     ok(!ret, "expected failure\n");
-    ok(error == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %u\n", error);
+    ok(error == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %lu\n", error);
 
     memset( buffer, 0xff, sizeof(buffer) );
     ret = pGetVolumePathNamesForVolumeNameA( volume, buffer, sizeof(buffer), NULL );
-    ok(ret, "failed to get path names %u\n", GetLastError());
+    ok(ret, "failed to get path names %lu\n", GetLastError());
     ok(!strcmp( "C:\\", buffer ), "expected \"\\C:\" got \"%s\"\n", buffer);
     ok(!buffer[4], "expected double null-terminated buffer\n");
 
@@ -984,34 +984,34 @@ static void test_GetVolumePathNamesForVolumeNameA(void)
     ret = pGetVolumePathNamesForVolumeNameA( NULL, NULL, 0, &len );
     error = GetLastError();
     ok(!ret, "expected failure\n");
-    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %u\n", error);
+    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %lu\n", error);
 
     len = 0;
     SetLastError( 0xdeadbeef );
     ret = pGetVolumePathNamesForVolumeNameA( NULL, NULL, sizeof(buffer), &len );
     error = GetLastError();
     ok(!ret, "expected failure\n");
-    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %u\n", error);
+    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %lu\n", error);
 
     len = 0;
     SetLastError( 0xdeadbeef );
     ret = pGetVolumePathNamesForVolumeNameA( NULL, buffer, sizeof(buffer), &len );
     error = GetLastError();
     ok(!ret, "expected failure\n");
-    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %u\n", error);
+    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %lu\n", error);
 
     len = 0;
     SetLastError( 0xdeadbeef );
     ret = pGetVolumePathNamesForVolumeNameA( NULL, buffer, sizeof(buffer), &len );
     error = GetLastError();
     ok(!ret, "expected failure\n");
-    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %u\n", error);
+    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %lu\n", error);
 
     len = 0;
     memset( buffer, 0xff, sizeof(buffer) );
     ret = pGetVolumePathNamesForVolumeNameA( volume, buffer, sizeof(buffer), &len );
-    ok(ret, "failed to get path names %u\n", GetLastError());
-    ok(len == 5 || broken(len == 2), "expected 5 got %u\n", len);
+    ok(ret, "failed to get path names %lu\n", GetLastError());
+    ok(len == 5 || broken(len == 2), "expected 5 got %lu\n", len);
     ok(!strcmp( "C:\\", buffer ), "expected \"\\C:\" got \"%s\"\n", buffer);
     ok(!buffer[4], "expected double null-terminated buffer\n");
 }
@@ -1034,39 +1034,39 @@ static void test_GetVolumePathNamesForVolumeNameW(void)
     }
 
     ret = GetVolumeNameForVolumeMountPointW( drive_c, volume, ARRAY_SIZE(volume) );
-    ok(ret, "failed to get volume name %u\n", GetLastError());
+    ok(ret, "failed to get volume name %lu\n", GetLastError());
 
     SetLastError( 0xdeadbeef );
     ret = pGetVolumePathNamesForVolumeNameW( empty, NULL, 0, NULL );
     error = GetLastError();
     ok(!ret, "expected failure\n");
-    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %u\n", error);
+    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %lu\n", error);
 
     SetLastError( 0xdeadbeef );
     ret = pGetVolumePathNamesForVolumeNameW( volume, NULL, 0, NULL );
     error = GetLastError();
     ok(!ret, "expected failure\n");
-    ok(error == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %u\n", error);
+    ok(error == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %lu\n", error);
 
     SetLastError( 0xdeadbeef );
     ret = pGetVolumePathNamesForVolumeNameW( volume, buffer, 0, NULL );
     error = GetLastError();
     ok(!ret, "expected failure\n");
-    ok(error == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %u\n", error);
+    ok(error == ERROR_MORE_DATA, "expected ERROR_MORE_DATA got %lu\n", error);
 
     if (0) { /* crash */
     ret = pGetVolumePathNamesForVolumeNameW( volume, NULL, ARRAY_SIZE(buffer), NULL );
-    ok(ret, "failed to get path names %u\n", GetLastError());
+    ok(ret, "failed to get path names %lu\n", GetLastError());
     }
 
     ret = pGetVolumePathNamesForVolumeNameW( volume, buffer, ARRAY_SIZE(buffer), NULL );
-    ok(ret, "failed to get path names %u\n", GetLastError());
+    ok(ret, "failed to get path names %lu\n", GetLastError());
 
     len = 0;
     memset( buffer, 0xff, sizeof(buffer) );
     ret = pGetVolumePathNamesForVolumeNameW( volume, buffer, ARRAY_SIZE(buffer), &len );
-    ok(ret, "failed to get path names %u\n", GetLastError());
-    ok(len == 5, "expected 5 got %u\n", len);
+    ok(ret, "failed to get path names %lu\n", GetLastError());
+    ok(len == 5, "expected 5 got %lu\n", len);
     ok(!buffer[4], "expected double null-terminated buffer\n");
 
     len = 0;
@@ -1076,7 +1076,7 @@ static void test_GetVolumePathNamesForVolumeNameW(void)
     ret = pGetVolumePathNamesForVolumeNameW( volume, buffer, ARRAY_SIZE(buffer), &len );
     error = GetLastError();
     ok(!ret, "expected failure\n");
-    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %u\n", error);
+    ok(error == ERROR_INVALID_NAME, "expected ERROR_INVALID_NAME got %lu\n", error);
 
     len = 0;
     volume[0] = '\\';
@@ -1085,7 +1085,7 @@ static void test_GetVolumePathNamesForVolumeNameW(void)
     ret = pGetVolumePathNamesForVolumeNameW( volume, buffer, ARRAY_SIZE(buffer), &len );
     error = GetLastError();
     ok(!ret, "expected failure\n");
-    todo_wine ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", error);
+    todo_wine ok(error == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %lu\n", error);
 
     len = 0;
     lstrcpyW( volume, volume_null );
@@ -1093,7 +1093,7 @@ static void test_GetVolumePathNamesForVolumeNameW(void)
     ret = pGetVolumePathNamesForVolumeNameW( volume, buffer, ARRAY_SIZE(buffer), &len );
     error = GetLastError();
     ok(!ret, "expected failure\n");
-    ok(error == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND got %u\n", error);
+    ok(error == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND got %lu\n", error);
 }
 
 static void test_dvd_read_structure(HANDLE handle)
@@ -1123,7 +1123,7 @@ static void test_dvd_read_structure(HANDLE handle)
 
     if(!ret)
     {
-        skip("IOCTL_DVD_READ_STRUCTURE not supported: %u\n", GetLastError());
+        skip("IOCTL_DVD_READ_STRUCTURE not supported: %lu\n", GetLastError());
         return;
     }
 
@@ -1180,7 +1180,7 @@ static void test_dvd_read_structure(HANDLE handle)
     /* Strangely, with NULL lpOutBuffer, last error is insufficient buffer, not invalid parameter as we could expect */
     ret = DeviceIoControl(handle, IOCTL_DVD_READ_STRUCTURE, &dvdReadStructure, sizeof(DVD_READ_STRUCTURE),
         NULL, sizeof(DVD_COPYRIGHT_DESCRIPTOR), &nbBytes, NULL);
-    ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "IOCTL_DVD_READ_STRUCTURE should have failed %d %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "IOCTL_DVD_READ_STRUCTURE should have failed %d %lu\n", ret, GetLastError());
 
     for(i=0; i<sizeof(DVD_COPYRIGHT_DESCRIPTOR); i++)
     {
@@ -1188,7 +1188,7 @@ static void test_dvd_read_structure(HANDLE handle)
 
         ret = DeviceIoControl(handle, IOCTL_DVD_READ_STRUCTURE, &dvdReadStructure, sizeof(DVD_READ_STRUCTURE),
             &dvdCopyrightDescriptor, i, &nbBytes, NULL);
-        ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "IOCTL_DVD_READ_STRUCTURE should have failed %d %u\n", ret, GetLastError());
+        ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "IOCTL_DVD_READ_STRUCTURE should have failed %d %lu\n", ret, GetLastError());
     }
 
 
@@ -1200,7 +1200,7 @@ static void test_dvd_read_structure(HANDLE handle)
     ret = DeviceIoControl(handle, IOCTL_DVD_READ_STRUCTURE, &dvdReadStructure, sizeof(DVD_READ_STRUCTURE),
         &completeDvdManufacturerDescriptor, sizeof(DVD_MANUFACTURER_DESCRIPTOR), &nbBytes, NULL);
     ok(ret || broken(GetLastError() == ERROR_NOT_READY),
-        "IOCTL_DVD_READ_STRUCTURE (DvdManufacturerDescriptor) failed, last error = %u\n", GetLastError());
+        "IOCTL_DVD_READ_STRUCTURE (DvdManufacturerDescriptor) failed, last error = %lu\n", GetLastError());
     if(!ret)
         return;
 
@@ -1214,7 +1214,7 @@ static void test_dvd_read_structure(HANDLE handle)
     /* Basic parameter check */
     ret = DeviceIoControl(handle, IOCTL_DVD_READ_STRUCTURE, &dvdReadStructure, sizeof(DVD_READ_STRUCTURE),
         NULL, sizeof(DVD_MANUFACTURER_DESCRIPTOR), &nbBytes, NULL);
-    ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "IOCTL_DVD_READ_STRUCTURE should have failed %d %u\n", ret, GetLastError());
+    ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "IOCTL_DVD_READ_STRUCTURE should have failed %d %lu\n", ret, GetLastError());
 }
 
 static void test_cdrom_ioctl(void)
@@ -1226,7 +1226,7 @@ static void test_cdrom_ioctl(void)
     bitmask = GetLogicalDrives();
     if(!bitmask)
     {
-        trace("GetLogicalDrives failed : %u\n", GetLastError());
+        trace("GetLogicalDrives failed : %lu\n", GetLastError());
         return;
     }
 
@@ -1248,7 +1248,7 @@ static void test_cdrom_ioctl(void)
         handle = CreateFileA(drive_full_path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
         if(handle == INVALID_HANDLE_VALUE)
         {
-            trace("Failed to open the device : %u\n", GetLastError());
+            trace("Failed to open the device : %lu\n", GetLastError());
             continue;
         }
 
@@ -1273,25 +1273,25 @@ static void test_mounted_folder(void)
 
     file = CreateFileA( "C:\\", 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
             OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL );
-    ok(file != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError());
 
     status = NtQueryInformationFile( file, &io, &info, sizeof(info), FileAttributeTagInformation );
-    ok(!status, "got status %#x\n", status);
+    ok(!status, "got status %#lx\n", status);
     ok(!(info.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
-            && (info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY), "got attributes %#x\n", info.FileAttributes);
-    ok(!info.ReparseTag, "got reparse tag %#x\n", info.ReparseTag);
+            && (info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY), "got attributes %#lx\n", info.FileAttributes);
+    ok(!info.ReparseTag, "got reparse tag %#lx\n", info.ReparseTag);
 
     CloseHandle( file );
 
     file = CreateFileA( "C:\\", 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
             OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL );
-    ok(file != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError());
 
     status = NtQueryInformationFile( file, &io, &info, sizeof(info), FileAttributeTagInformation );
-    ok(!status, "got status %#x\n", status);
+    ok(!status, "got status %#lx\n", status);
     ok(!(info.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
-            && (info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY), "got attributes %#x\n", info.FileAttributes);
-    ok(!info.ReparseTag, "got reparse tag %#x\n", info.ReparseTag);
+            && (info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY), "got attributes %#lx\n", info.FileAttributes);
+    ok(!info.ReparseTag, "got reparse tag %#lx\n", info.ReparseTag);
 
     CloseHandle( file );
 
@@ -1304,10 +1304,10 @@ static void test_mounted_folder(void)
         skip("Not enough permissions to create a folder in the C: drive.\n");
         return;
     }
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     ret = GetVolumeNameForVolumeMountPointA( "C:\\", volume_name, sizeof(volume_name) );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     ret = SetVolumeMountPointA( "C:\\winetest_mnt\\", volume_name );
     if (!ret)
@@ -1316,21 +1316,21 @@ static void test_mounted_folder(void)
         RemoveDirectoryA( "C:\\winetest_mnt" );
         return;
     }
-    todo_wine ok(ret, "got error %u\n", GetLastError());
+    todo_wine ok(ret, "got error %lu\n", GetLastError());
 
     file = CreateFileA( "C:\\winetest_mnt", 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
             OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL );
-    ok(file != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError());
 
     status = NtQueryInformationFile( file, &io, &info, sizeof(info), FileAttributeTagInformation );
-    ok(!status, "got status %#x\n", status);
+    ok(!status, "got status %#lx\n", status);
     ok((info.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
-            && (info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY), "got attributes %#x\n", info.FileAttributes);
-    ok(info.ReparseTag == IO_REPARSE_TAG_MOUNT_POINT, "got reparse tag %#x\n", info.ReparseTag);
+            && (info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY), "got attributes %#lx\n", info.FileAttributes);
+    ok(info.ReparseTag == IO_REPARSE_TAG_MOUNT_POINT, "got reparse tag %#lx\n", info.ReparseTag);
 
     status = NtQueryInformationFile( file, &io, name, sizeof(name_buffer), FileNameInformation );
-    ok(!status, "got status %#x\n", status);
-    ok(name->FileNameLength == wcslen(L"\\winetest_mnt") * sizeof(WCHAR), "got length %u\n", name->FileNameLength);
+    ok(!status, "got status %#lx\n", status);
+    ok(name->FileNameLength == wcslen(L"\\winetest_mnt") * sizeof(WCHAR), "got length %lu\n", name->FileNameLength);
     ok(!wcsnicmp(name->FileName, L"\\winetest_mnt", wcslen(L"\\winetest_mnt")), "got name %s\n",
             debugstr_wn(name->FileName, name->FileNameLength / sizeof(WCHAR)));
 
@@ -1338,100 +1338,100 @@ static void test_mounted_folder(void)
 
     file = CreateFileA( "C:\\winetest_mnt", 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
             OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL );
-    ok(file != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError());
 
     status = NtQueryInformationFile( file, &io, &info, sizeof(info), FileAttributeTagInformation );
-    ok(!status, "got status %#x\n", status);
+    ok(!status, "got status %#lx\n", status);
     ok(!(info.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
-            && (info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY), "got attributes %#x\n", info.FileAttributes);
-    ok(!info.ReparseTag, "got reparse tag %#x\n", info.ReparseTag);
+            && (info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY), "got attributes %#lx\n", info.FileAttributes);
+    ok(!info.ReparseTag, "got reparse tag %#lx\n", info.ReparseTag);
 
     status = NtQueryInformationFile( file, &io, name, sizeof(name_buffer), FileNameInformation );
-    ok(!status, "got status %#x\n", status);
-    ok(name->FileNameLength == wcslen(L"\\") * sizeof(WCHAR), "got length %u\n", name->FileNameLength);
+    ok(!status, "got status %#lx\n", status);
+    ok(name->FileNameLength == wcslen(L"\\") * sizeof(WCHAR), "got length %lu\n", name->FileNameLength);
     ok(!wcsnicmp(name->FileName, L"\\", wcslen(L"\\")), "got name %s\n",
             debugstr_wn(name->FileName, name->FileNameLength / sizeof(WCHAR)));
 
     CloseHandle( file );
 
     ret = GetFileAttributesA( "C:\\winetest_mnt" );
-    ok(ret != INVALID_FILE_ATTRIBUTES, "got error %u\n", GetLastError());
+    ok(ret != INVALID_FILE_ATTRIBUTES, "got error %lu\n", GetLastError());
     ok((ret & FILE_ATTRIBUTE_REPARSE_POINT) && (ret & FILE_ATTRIBUTE_DIRECTORY), "got attributes %#x\n", ret);
 
     file = CreateFileA( "C:\\winetest_mnt\\windows", 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
             NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL );
-    ok(file != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError());
 
     status = NtQueryInformationFile( file, &io, name, sizeof(name_buffer), FileNameInformation );
-    ok(!status, "got status %#x\n", status);
-    ok(name->FileNameLength == wcslen(L"\\windows") * sizeof(WCHAR), "got length %u\n", name->FileNameLength);
+    ok(!status, "got status %#lx\n", status);
+    ok(name->FileNameLength == wcslen(L"\\windows") * sizeof(WCHAR), "got length %lu\n", name->FileNameLength);
     ok(!wcsnicmp(name->FileName, L"\\windows", wcslen(L"\\windows")), "got name %s\n",
             debugstr_wn(name->FileName, name->FileNameLength / sizeof(WCHAR)));
 
     CloseHandle( file );
 
     ret = GetVolumePathNameA( "C:\\winetest_mnt", path, sizeof(path) );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ok(!strcmp(path, "C:\\winetest_mnt\\"), "got %s\n", debugstr_a(path));
     SetLastError(0xdeadbeef);
     ret = GetVolumeNameForVolumeMountPointA( "C:\\winetest_mnt", path, sizeof(path) );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_INVALID_NAME, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_NAME, "wrong error %lu\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = GetVolumeInformationA( "C:\\winetest_mnt", NULL, 0, NULL, NULL, NULL, NULL, 0 );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_INVALID_NAME, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_NAME, "wrong error %lu\n", GetLastError());
 
     ret = GetVolumeNameForVolumeMountPointA( "C:\\winetest_mnt\\", path, sizeof(path) );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ok(!strcmp(path, volume_name), "expected %s, got %s\n", debugstr_a(volume_name), debugstr_a(path));
     ret = GetVolumeInformationA( "C:\\winetest_mnt\\", NULL, 0, NULL, NULL, NULL, NULL, 0 );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     ret = GetVolumePathNameA( "C:\\winetest_mnt\\windows", path, sizeof(path) );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ok(!strcmp(path, "C:\\winetest_mnt\\"), "got %s\n", debugstr_a(path));
     SetLastError(0xdeadbeef);
     ret = GetVolumeNameForVolumeMountPointA( "C:\\winetest_mnt\\windows\\", path, sizeof(path) );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_NOT_A_REPARSE_POINT, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_NOT_A_REPARSE_POINT, "wrong error %lu\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = GetVolumeInformationA( "C:\\winetest_mnt\\windows\\", NULL, 0, NULL, NULL, NULL, NULL, 0 );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_DIR_NOT_ROOT, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_DIR_NOT_ROOT, "wrong error %lu\n", GetLastError());
 
     ret = GetVolumePathNameA( "C:\\winetest_mnt\\nonexistent\\", path, sizeof(path) );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ok(!strcmp(path, "C:\\winetest_mnt\\"), "got %s\n", debugstr_a(path));
     SetLastError(0xdeadbeef);
     ret = GetVolumeNameForVolumeMountPointA( "C:\\winetest_mnt\\nonexistent\\", path, sizeof(path) );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %lu\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = GetVolumeInformationA( "C:\\winetest_mnt\\nonexistent\\", NULL, 0, NULL, NULL, NULL, NULL, 0 );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %lu\n", GetLastError());
 
     ret = GetVolumePathNameA( "C:\\winetest_mnt\\winetest_mnt", path, sizeof(path) );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ok(!strcmp(path, "C:\\winetest_mnt\\winetest_mnt\\"), "got %s\n", debugstr_a(path));
     ret = GetVolumeNameForVolumeMountPointA( "C:\\winetest_mnt\\winetest_mnt\\", path, sizeof(path) );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ok(!strcmp(path, volume_name), "expected %s, got %s\n", debugstr_a(volume_name), debugstr_a(path));
     ret = GetVolumeInformationA( "C:\\winetest_mnt\\winetest_mnt\\", NULL, 0, NULL, NULL, NULL, NULL, 0 );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     ret = GetVolumePathNameA( "C:/winetest_mnt/../winetest_mnt/.", path, sizeof(path) );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ok(!strcmp(path, "C:\\winetest_mnt\\"), "got %s\n", debugstr_a(path));
     ret = GetVolumeNameForVolumeMountPointA( "C:/winetest_mnt/../winetest_mnt/.\\", path, sizeof(path) );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ok(!strcmp(path, volume_name), "expected %s, got %s\n", debugstr_a(volume_name), debugstr_a(path));
     ret = GetVolumeInformationA( "C:/winetest_mnt/../winetest_mnt/.\\", NULL, 0, NULL, NULL, NULL, NULL, 0 );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     ret = GetVolumePathNamesForVolumeNameA( volume_name, path, sizeof(path), &size );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     got_path = FALSE;
     for (p = path; *p; p += strlen(p) + 1)
     {
@@ -1446,62 +1446,62 @@ static void test_mounted_folder(void)
     if (pCreateSymbolicLinkA)
     {
         ret = pCreateSymbolicLinkA( "C:\\winetest_link", "C:\\winetest_mnt\\", SYMBOLIC_LINK_FLAG_DIRECTORY );
-        ok(ret, "got error %u\n", GetLastError());
+        ok(ret, "got error %lu\n", GetLastError());
 
         ret = GetVolumePathNameA( "C:\\winetest_link\\", path, sizeof(path) );
-        ok(ret, "got error %u\n", GetLastError());
+        ok(ret, "got error %lu\n", GetLastError());
         ok(!strcmp(path, "C:\\"), "got %s\n", path);
         SetLastError(0xdeadbeef);
         ret = GetVolumeNameForVolumeMountPointA( "C:\\winetest_link\\", path, sizeof(path) );
         ok(!ret, "expected failure\n");
         ok(GetLastError() == ERROR_INVALID_PARAMETER
-                || broken(GetLastError() == ERROR_SUCCESS) /* 2008 */, "wrong error %u\n", GetLastError());
+                || broken(GetLastError() == ERROR_SUCCESS) /* 2008 */, "wrong error %lu\n", GetLastError());
         ret = GetVolumeInformationA( "C:\\winetest_link\\", NULL, 0, NULL, NULL, NULL, NULL, 0 );
-        ok(ret, "got error %u\n", GetLastError());
+        ok(ret, "got error %lu\n", GetLastError());
 
         ret = GetVolumePathNameA( "C:\\winetest_link\\windows\\", path, sizeof(path) );
-        ok(ret, "got error %u\n", GetLastError());
+        ok(ret, "got error %lu\n", GetLastError());
         ok(!strcmp(path, "C:\\"), "got %s\n", path);
         SetLastError(0xdeadbeef);
         ret = GetVolumeNameForVolumeMountPointA( "C:\\winetest_link\\windows\\", path, sizeof(path) );
         ok(!ret, "expected failure\n");
-        ok(GetLastError() == ERROR_NOT_A_REPARSE_POINT, "wrong error %u\n", GetLastError());
+        ok(GetLastError() == ERROR_NOT_A_REPARSE_POINT, "wrong error %lu\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = GetVolumeInformationA( "C:\\winetest_link\\windows\\", NULL, 0, NULL, NULL, NULL, NULL, 0 );
         ok(!ret, "expected failure\n");
-        ok(GetLastError() == ERROR_DIR_NOT_ROOT, "wrong error %u\n", GetLastError());
+        ok(GetLastError() == ERROR_DIR_NOT_ROOT, "wrong error %lu\n", GetLastError());
 
         ret = GetVolumePathNameA( "C:\\winetest_link\\winetest_mnt", path, sizeof(path) );
-        ok(ret, "got error %u\n", GetLastError());
+        ok(ret, "got error %lu\n", GetLastError());
         ok(!strcmp(path, "C:\\winetest_link\\winetest_mnt\\"), "got %s\n", debugstr_a(path));
         ret = GetVolumeNameForVolumeMountPointA( "C:\\winetest_link\\winetest_mnt\\", path, sizeof(path) );
-        ok(ret, "got error %u\n", GetLastError());
+        ok(ret, "got error %lu\n", GetLastError());
         ok(!strcmp(path, volume_name), "expected %s, got %s\n", debugstr_a(volume_name), debugstr_a(path));
         ret = GetVolumeInformationA( "C:\\winetest_link\\winetest_mnt\\", NULL, 0, NULL, NULL, NULL, NULL, 0 );
-        ok(ret, "got error %u\n", GetLastError());
+        ok(ret, "got error %lu\n", GetLastError());
 
         /* The following test makes it clear that when we encounter a symlink
          * while resolving, we resolve *every* junction in the path, i.e. both
          * mount points and symlinks. */
         ret = GetVolumePathNameA( "C:\\winetest_link\\winetest_mnt\\winetest_link\\windows\\", path, sizeof(path) );
-        ok(ret, "got error %u\n", GetLastError());
+        ok(ret, "got error %lu\n", GetLastError());
         ok(!strcmp(path, "C:\\") || !strcmp(path, "C:\\winetest_link\\winetest_mnt\\") /* 2008 */,
                 "got %s\n", debugstr_a(path));
 
         file = CreateFileA( "C:\\winetest_link\\winetest_mnt\\winetest_link\\windows\\", 0,
                 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL );
-        ok(file != INVALID_HANDLE_VALUE, "got error %u\n", GetLastError());
+        ok(file != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError());
 
         status = NtQueryInformationFile( file, &io, name, sizeof(name_buffer), FileNameInformation );
-        ok(!status, "got status %#x\n", status);
-        ok(name->FileNameLength == wcslen(L"\\windows") * sizeof(WCHAR), "got length %u\n", name->FileNameLength);
+        ok(!status, "got status %#lx\n", status);
+        ok(name->FileNameLength == wcslen(L"\\windows") * sizeof(WCHAR), "got length %lu\n", name->FileNameLength);
         ok(!wcsnicmp(name->FileName, L"\\windows", wcslen(L"\\windows")), "got name %s\n",
                 debugstr_wn(name->FileName, name->FileNameLength / sizeof(WCHAR)));
 
         CloseHandle( file );
 
         ret = RemoveDirectoryA( "C:\\winetest_link\\" );
-        ok(ret, "got error %u\n", GetLastError());
+        ok(ret, "got error %lu\n", GetLastError());
 
         /* The following cannot be automatically tested:
          *
@@ -1513,9 +1513,9 @@ static void test_mounted_folder(void)
     }
 
     ret = DeleteVolumeMountPointA( "C:\\winetest_mnt\\" );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
     ret = RemoveDirectoryA( "C:\\winetest_mnt" );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 }
 
 static void test_GetVolumeInformationByHandle(void)
@@ -1539,47 +1539,47 @@ static void test_GetVolumeInformationByHandle(void)
 
     file = CreateFileA( "C:/windows", 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
             OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL );
-    ok(file != INVALID_HANDLE_VALUE, "failed to open file, error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "failed to open file, error %lu\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetVolumeInformationByHandleW( INVALID_HANDLE_VALUE, label, ARRAY_SIZE(label), &serial,
             &filename_len, &flags, fsname, ARRAY_SIZE(fsname) );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_INVALID_HANDLE, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got error %lu\n", GetLastError());
 
     ret = pGetVolumeInformationByHandleW( file, NULL, 0, NULL, NULL, NULL, NULL, 0 );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     ret = pGetVolumeInformationByHandleW( file, label, ARRAY_SIZE(label), &serial,
             &filename_len, &flags, fsname, ARRAY_SIZE(fsname) );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     memset(buffer, 0, sizeof(buffer));
     status = NtQueryVolumeInformationFile( file, &io, buffer, sizeof(buffer), FileFsAttributeInformation );
-    ok(!status, "got status %#x\n", status);
-    ok(flags == attr_info->FileSystemAttributes, "expected flags %#x, got %#x\n",
+    ok(!status, "got status %#lx\n", status);
+    ok(flags == attr_info->FileSystemAttributes, "expected flags %#lx, got %#lx\n",
             attr_info->FileSystemAttributes, flags);
-    ok(filename_len == attr_info->MaximumComponentNameLength, "expected filename_len %u, got %u\n",
+    ok(filename_len == attr_info->MaximumComponentNameLength, "expected filename_len %lu, got %lu\n",
             attr_info->MaximumComponentNameLength, filename_len);
     ok(!wcscmp( fsname, attr_info->FileSystemName ), "expected fsname %s, got %s\n",
             debugstr_w( attr_info->FileSystemName ), debugstr_w( fsname ));
     ok(wcslen( fsname ) == attr_info->FileSystemNameLength / sizeof(WCHAR),
-            "expected fsname length %u, got %u\n", attr_info->FileSystemNameLength / sizeof(WCHAR), wcslen( fsname ));
+            "expected fsname length %Iu, got %Iu\n", attr_info->FileSystemNameLength / sizeof(WCHAR), wcslen( fsname ));
 
     SetLastError(0xdeadbeef);
     ret = pGetVolumeInformationByHandleW( file, NULL, 0, NULL, &filename_len, &flags, fsname, 2 );
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_BAD_LENGTH, "got error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_BAD_LENGTH, "got error %lu\n", GetLastError());
 
     memset(buffer, 0, sizeof(buffer));
     status = NtQueryVolumeInformationFile( file, &io, buffer, sizeof(buffer), FileFsVolumeInformation );
-    ok(!status, "got status %#x\n", status);
-    ok(serial == volume_info->VolumeSerialNumber, "expected serial %08x, got %08x\n",
+    ok(!status, "got status %#lx\n", status);
+    ok(serial == volume_info->VolumeSerialNumber, "expected serial %08lx, got %08lx\n",
             volume_info->VolumeSerialNumber, serial);
     ok(!wcscmp( label, volume_info->VolumeLabel ), "expected label %s, got %s\n",
             debugstr_w( volume_info->VolumeLabel ), debugstr_w( label ));
     ok(wcslen( label ) == volume_info->VolumeLabelLength / sizeof(WCHAR),
-            "expected label length %u, got %u\n", volume_info->VolumeLabelLength / sizeof(WCHAR), wcslen( label ));
+            "expected label length %Iu, got %Iu\n", volume_info->VolumeLabelLength / sizeof(WCHAR), wcslen( label ));
 
     CloseHandle( file );
 
@@ -1591,33 +1591,33 @@ static void test_GetVolumeInformationByHandle(void)
 
     file = CreateFileA( volume, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
             OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL );
-    ok(file != INVALID_HANDLE_VALUE, "failed to open file, error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "failed to open file, error %lu\n", GetLastError());
 
     ret = pGetVolumeInformationByHandleW( file, label, ARRAY_SIZE(label), &serial,
             &filename_len, &flags, fsname, ARRAY_SIZE(fsname) );
-    ok(ret, "got error %u\n", GetLastError());
+    ok(ret, "got error %lu\n", GetLastError());
 
     memset(buffer, 0, sizeof(buffer));
     status = NtQueryVolumeInformationFile( file, &io, buffer, sizeof(buffer), FileFsVolumeInformation );
-    ok(!status, "got status %#x\n", status);
-    ok(serial == volume_info->VolumeSerialNumber, "expected serial %08x, got %08x\n",
+    ok(!status, "got status %#lx\n", status);
+    ok(serial == volume_info->VolumeSerialNumber, "expected serial %08lx, got %08lx\n",
             volume_info->VolumeSerialNumber, serial);
     ok(!wcscmp( label, volume_info->VolumeLabel ), "expected label %s, got %s\n",
             debugstr_w( volume_info->VolumeLabel ), debugstr_w( label ));
     ok(wcslen( label ) == volume_info->VolumeLabelLength / sizeof(WCHAR),
-            "expected label length %u, got %u\n", volume_info->VolumeLabelLength / sizeof(WCHAR), wcslen( label ));
+            "expected label length %Iu, got %Iu\n", volume_info->VolumeLabelLength / sizeof(WCHAR), wcslen( label ));
 
     memset(buffer, 0, sizeof(buffer));
     status = NtQueryVolumeInformationFile( file, &io, buffer, sizeof(buffer), FileFsAttributeInformation );
-    ok(!status, "got status %#x\n", status);
-    ok(flags == attr_info->FileSystemAttributes, "expected flags %#x, got %#x\n",
+    ok(!status, "got status %#lx\n", status);
+    ok(flags == attr_info->FileSystemAttributes, "expected flags %#lx, got %#lx\n",
             attr_info->FileSystemAttributes, flags);
-    ok(filename_len == attr_info->MaximumComponentNameLength, "expected filename_len %u, got %u\n",
+    ok(filename_len == attr_info->MaximumComponentNameLength, "expected filename_len %lu, got %lu\n",
             attr_info->MaximumComponentNameLength, filename_len);
     ok(!wcscmp( fsname, attr_info->FileSystemName ), "expected fsname %s, got %s\n",
             debugstr_w( attr_info->FileSystemName ), debugstr_w( fsname ));
     ok(wcslen( fsname ) == attr_info->FileSystemNameLength / sizeof(WCHAR),
-            "expected fsname length %u, got %u\n", attr_info->FileSystemNameLength / sizeof(WCHAR), wcslen( fsname ));
+            "expected fsname length %Iu, got %Iu\n", attr_info->FileSystemNameLength / sizeof(WCHAR), wcslen( fsname ));
 
     CloseHandle( file );
 }
@@ -1634,14 +1634,14 @@ static void test_mountmgr_query_points(void)
     output = malloc(1024);
 
     file = CreateFileW( MOUNTMGR_DOS_DEVICE_NAME, 0, 0, NULL, OPEN_EXISTING, 0, NULL );
-    ok(file != INVALID_HANDLE_VALUE, "failed to open mountmgr, error %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "failed to open mountmgr, error %lu\n", GetLastError());
 
     io.Status = 0xdeadf00d;
     io.Information = 0xdeadf00d;
     status = NtDeviceIoControlFile( file, NULL, NULL, NULL, &io,
             IOCTL_MOUNTMGR_QUERY_POINTS, NULL, 0, NULL, 0 );
-    ok(status == STATUS_INVALID_PARAMETER, "got %#x\n", status);
-    ok(io.Status == 0xdeadf00d, "got status %#x\n", io.Status);
+    ok(status == STATUS_INVALID_PARAMETER, "got %#lx\n", status);
+    ok(io.Status == 0xdeadf00d, "got status %#lx\n", io.Status);
     ok(io.Information == 0xdeadf00d, "got information %#Ix\n", io.Information);
 
     memset( input, 0, sizeof(*input) );
@@ -1650,16 +1650,16 @@ static void test_mountmgr_query_points(void)
     io.Information = 0xdeadf00d;
     status = NtDeviceIoControlFile( file, NULL, NULL, NULL, &io,
             IOCTL_MOUNTMGR_QUERY_POINTS, input, sizeof(*input) - 1, NULL, 0 );
-    ok(status == STATUS_INVALID_PARAMETER, "got %#x\n", status);
-    ok(io.Status == 0xdeadf00d, "got status %#x\n", io.Status);
+    ok(status == STATUS_INVALID_PARAMETER, "got %#lx\n", status);
+    ok(io.Status == 0xdeadf00d, "got status %#lx\n", io.Status);
     ok(io.Information == 0xdeadf00d, "got information %#Ix\n", io.Information);
 
     io.Status = 0xdeadf00d;
     io.Information = 0xdeadf00d;
     status = NtDeviceIoControlFile( file, NULL, NULL, NULL, &io,
             IOCTL_MOUNTMGR_QUERY_POINTS, input, sizeof(*input), NULL, 0 );
-    ok(status == STATUS_INVALID_PARAMETER, "got %#x\n", status);
-    ok(io.Status == 0xdeadf00d, "got status %#x\n", io.Status);
+    ok(status == STATUS_INVALID_PARAMETER, "got %#lx\n", status);
+    ok(io.Status == 0xdeadf00d, "got status %#lx\n", io.Status);
     ok(io.Information == 0xdeadf00d, "got information %#Ix\n", io.Information);
 
     io.Status = 0xdeadf00d;
@@ -1667,23 +1667,23 @@ static void test_mountmgr_query_points(void)
     memset(output, 0xcc, sizeof(*output));
     status = NtDeviceIoControlFile( file, NULL, NULL, NULL, &io,
             IOCTL_MOUNTMGR_QUERY_POINTS, input, sizeof(*input), output, sizeof(*output) - 1 );
-    ok(status == STATUS_INVALID_PARAMETER, "got %#x\n", status);
-    ok(io.Status == 0xdeadf00d, "got status %#x\n", io.Status);
+    ok(status == STATUS_INVALID_PARAMETER, "got %#lx\n", status);
+    ok(io.Status == 0xdeadf00d, "got status %#lx\n", io.Status);
     ok(io.Information == 0xdeadf00d, "got information %#Ix\n", io.Information);
-    ok(output->Size == 0xcccccccc, "got size %u\n", output->Size);
-    ok(output->NumberOfMountPoints == 0xcccccccc, "got count %u\n", output->NumberOfMountPoints);
+    ok(output->Size == 0xcccccccc, "got size %lu\n", output->Size);
+    ok(output->NumberOfMountPoints == 0xcccccccc, "got count %lu\n", output->NumberOfMountPoints);
 
     io.Status = 0xdeadf00d;
     io.Information = 0xdeadf00d;
     memset(output, 0xcc, sizeof(*output));
     status = NtDeviceIoControlFile( file, NULL, NULL, NULL, &io,
             IOCTL_MOUNTMGR_QUERY_POINTS, input, sizeof(*input), output, sizeof(*output) );
-    ok(status == STATUS_BUFFER_OVERFLOW, "got %#x\n", status);
-    ok(io.Status == STATUS_BUFFER_OVERFLOW, "got status %#x\n", io.Status);
+    ok(status == STATUS_BUFFER_OVERFLOW, "got %#lx\n", status);
+    ok(io.Status == STATUS_BUFFER_OVERFLOW, "got status %#lx\n", io.Status);
     todo_wine ok(io.Information == offsetof(MOUNTMGR_MOUNT_POINTS, MountPoints[0]), "got information %#Ix\n", io.Information);
-    ok(output->Size > offsetof(MOUNTMGR_MOUNT_POINTS, MountPoints[0]), "got size %u\n", output->Size);
+    ok(output->Size > offsetof(MOUNTMGR_MOUNT_POINTS, MountPoints[0]), "got size %lu\n", output->Size);
     todo_wine ok(output->NumberOfMountPoints && output->NumberOfMountPoints != 0xcccccccc,
-            "got count %u\n", output->NumberOfMountPoints);
+            "got count %lu\n", output->NumberOfMountPoints);
 
     output = realloc(output, output->Size);
 
@@ -1691,12 +1691,12 @@ static void test_mountmgr_query_points(void)
     io.Information = 0xdeadf00d;
     status = NtDeviceIoControlFile( file, NULL, NULL, NULL, &io,
             IOCTL_MOUNTMGR_QUERY_POINTS, input, sizeof(*input), output, output->Size );
-    ok(!status, "got %#x\n", status);
-    ok(!io.Status, "got status %#x\n", io.Status);
-    ok(io.Information == output->Size, "got size %u, information %#Ix\n", output->Size, io.Information);
-    ok(output->Size > offsetof(MOUNTMGR_MOUNT_POINTS, MountPoints[0]), "got size %u\n", output->Size);
+    ok(!status, "got %#lx\n", status);
+    ok(!io.Status, "got status %#lx\n", io.Status);
+    ok(io.Information == output->Size, "got size %lu, information %#Ix\n", output->Size, io.Information);
+    ok(output->Size > offsetof(MOUNTMGR_MOUNT_POINTS, MountPoints[0]), "got size %lu\n", output->Size);
     ok(output->NumberOfMountPoints && output->NumberOfMountPoints != 0xcccccccc,
-            "got count %u\n", output->NumberOfMountPoints);
+            "got count %lu\n", output->NumberOfMountPoints);
 
     CloseHandle( file );
 




More information about the wine-devel mailing list