[PATCH 20/22] dlls/crypt32/tests: enable compilation with long types

Eric Pouech eric.pouech at gmail.com
Wed Feb 23 02:12:05 CST 2022


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

---
 dlls/crypt32/tests/Makefile.in   |    1 
 dlls/crypt32/tests/base64.c      |  148 ++--
 dlls/crypt32/tests/cert.c        |  790 ++++++++++----------
 dlls/crypt32/tests/chain.c       |  140 ++--
 dlls/crypt32/tests/crl.c         |  204 +++--
 dlls/crypt32/tests/ctl.c         |   56 +
 dlls/crypt32/tests/encode.c      | 1474 +++++++++++++++++++-------------------
 dlls/crypt32/tests/main.c        |   94 +-
 dlls/crypt32/tests/message.c     |  260 +++----
 dlls/crypt32/tests/msg.c         |  758 ++++++++++----------
 dlls/crypt32/tests/object.c      |   24 -
 dlls/crypt32/tests/oid.c         |  130 ++-
 dlls/crypt32/tests/protectdata.c |   20 -
 dlls/crypt32/tests/sip.c         |   40 +
 dlls/crypt32/tests/store.c       |  608 ++++++++--------
 dlls/crypt32/tests/str.c         |  104 +--
 16 files changed, 2425 insertions(+), 2426 deletions(-)

diff --git a/dlls/crypt32/tests/Makefile.in b/dlls/crypt32/tests/Makefile.in
index 3a227243221..339cff30e0f 100644
--- a/dlls/crypt32/tests/Makefile.in
+++ b/dlls/crypt32/tests/Makefile.in
@@ -1,4 +1,3 @@
-EXTRADEFS = -DWINE_NO_LONG_TYPES
 TESTDLL   = crypt32.dll
 IMPORTS   = crypt32 advapi32 user32 shlwapi shell32 bcrypt
 
diff --git a/dlls/crypt32/tests/base64.c b/dlls/crypt32/tests/base64.c
index 64148342b2b..a1517b294ad 100644
--- a/dlls/crypt32/tests/base64.c
+++ b/dlls/crypt32/tests/base64.c
@@ -115,18 +115,18 @@ static void encodeAndCompareBase64_A(const BYTE *toEncode, DWORD toEncodeLen,
 
     strLen = 0;
     ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, NULL, &strLen);
-    ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
-    ok(strLen == required, "Unexpected required length %u, expected %u.\n", required, strLen);
+    ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError());
+    ok(strLen == required, "Unexpected required length %lu, expected %lu.\n", required, strLen);
 
     strLen2 = strLen;
     ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, NULL, &strLen2);
-    ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
-    ok(strLen == strLen2, "Unexpected required length %u, expected %u.\n", strLen2, strLen);
+    ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError());
+    ok(strLen == strLen2, "Unexpected required length %lu, expected %lu.\n", strLen2, strLen);
 
     strLen2 = strLen - 1;
     ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, NULL, &strLen2);
-    ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
-    ok(strLen == strLen2, "Unexpected required length %u, expected %u.\n", strLen2, strLen);
+    ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError());
+    ok(strLen == strLen2, "Unexpected required length %lu, expected %lu.\n", strLen2, strLen);
 
     str = heap_alloc(strLen);
 
@@ -134,17 +134,17 @@ static void encodeAndCompareBase64_A(const BYTE *toEncode, DWORD toEncodeLen,
     strLen2 = strLen - 1;
     str[0] = 0x12;
     ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, str, &strLen2);
-    ok((!ret && GetLastError() == ERROR_MORE_DATA) || broken(ret) /* XP */, "CryptBinaryToStringA failed %d, error %d.\n",
+    ok((!ret && GetLastError() == ERROR_MORE_DATA) || broken(ret) /* XP */, "CryptBinaryToStringA failed %d, error %ld.\n",
         ret, GetLastError());
-    ok(strLen2 == strLen || broken(strLen2 == strLen - 1), "Expected length %d, got %d\n", strLen, strLen2);
+    ok(strLen2 == strLen || broken(strLen2 == strLen - 1), "Expected length %ld, got %ld\n", strLen, strLen2);
     if (header)
         ok(str[0] == header[0], "Unexpected buffer contents %#x.\n", str[0]);
     else
         ok(str[0] == expected[0], "Unexpected buffer contents %#x.\n", str[0]);
     strLen2 = strLen;
     ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, str, &strLen2);
-    ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
-    ok(strLen2 == strLen - 1, "Expected length %d, got %d\n", strLen - 1, strLen2);
+    ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError());
+    ok(strLen2 == strLen - 1, "Expected length %ld, got %ld\n", strLen - 1, strLen2);
 
     ptr = str;
     if (header)
@@ -177,23 +177,23 @@ static void encode_compare_base64_W(const BYTE *toEncode, DWORD toEncodeLen, DWO
 
     strLen = 0;
     ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, NULL, &strLen);
-    ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
-    ok(strLen == required, "Unexpected required length %u, expected %u.\n", strLen, required);
+    ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
+    ok(strLen == required, "Unexpected required length %lu, expected %u.\n", strLen, required);
 
     /* Same call with non-zero length value. */
     strLen2 = strLen;
     ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, NULL, &strLen2);
-    ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
+    ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
     ok(strLen == strLen2, "Unexpected required length.\n");
 
     strLen2 = strLen - 1;
     ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, NULL, &strLen2);
-    ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
+    ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
     ok(strLen == strLen2, "Unexpected required length.\n");
 
     strLen2 = strLen - 1;
     ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, NULL, &strLen2);
-    ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
+    ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
     ok(strLen == strLen2, "Unexpected required length.\n");
 
     strW = heap_alloc(strLen * sizeof(WCHAR));
@@ -204,7 +204,7 @@ static void encode_compare_base64_W(const BYTE *toEncode, DWORD toEncodeLen, DWO
     strLen2 = strLen - 1;
     strW[0] = 0x1234;
     ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, strW, &strLen2);
-    ok((!ret && GetLastError() == ERROR_MORE_DATA) || broken(ret) /* XP */, "CryptBinaryToStringW failed, %d, error %d\n",
+    ok((!ret && GetLastError() == ERROR_MORE_DATA) || broken(ret) /* XP */, "CryptBinaryToStringW failed, %d, error %ld\n",
         ret, GetLastError());
     if (headerW)
         ok(strW[0] == 0x1234, "Unexpected buffer contents %#x.\n", strW[0]);
@@ -213,9 +213,9 @@ static void encode_compare_base64_W(const BYTE *toEncode, DWORD toEncodeLen, DWO
 
     strLen2 = strLen;
     ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, strW, &strLen2);
-    ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
+    ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
 
-    ok(strLen2 == strLen - 1, "Expected length %d, got %d\n", strLen - 1, strLen);
+    ok(strLen2 == strLen - 1, "Expected length %ld, got %ld\n", strLen - 1, strLen);
 
     ptr = strW;
     if (headerW)
@@ -271,12 +271,12 @@ static void test_CryptBinaryToString(void)
 
     ret = CryptBinaryToStringA(NULL, 0, 0, NULL, NULL);
     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-     "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+     "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
 
     strLen = 123;
     ret = CryptBinaryToStringA(NULL, 0, 0, NULL, &strLen);
     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-     "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+     "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
     ok(strLen == 123, "Unexpected length.\n");
 
     if (0)
@@ -284,7 +284,7 @@ static void test_CryptBinaryToString(void)
 
     strLen = 123;
     ret = CryptBinaryToStringW(NULL, 0, 0, NULL, &strLen);
-    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Unexpected error %d\n", GetLastError());
+    ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Unexpected error %ld\n", GetLastError());
     ok(strLen == 123, "Unexpected length.\n");
 
     for (i = 0; i < ARRAY_SIZE(tests); i++)
@@ -295,27 +295,27 @@ static void test_CryptBinaryToString(void)
 
         strLen = 0;
         ret = CryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, NULL, &strLen);
-        ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
-        ok(strLen == tests[i].toEncodeLen, "Unexpected required length %u.\n", strLen);
+        ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError());
+        ok(strLen == tests[i].toEncodeLen, "Unexpected required length %lu.\n", strLen);
 
         strLen2 = strLen;
         str = heap_alloc(strLen);
         ret = CryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, str, &strLen2);
-        ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
-        ok(strLen == strLen2, "Expected length %u, got %u\n", strLen, strLen2);
+        ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError());
+        ok(strLen == strLen2, "Expected length %lu, got %lu\n", strLen, strLen2);
         ok(!memcmp(str, tests[i].toEncode, tests[i].toEncodeLen), "Unexpected value\n");
         heap_free(str);
 
         strLen = 0;
         ret = CryptBinaryToStringW(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, NULL, &strLen);
-        ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
-        ok(strLen == tests[i].toEncodeLen, "Unexpected required length %u.\n", strLen);
+        ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
+        ok(strLen == tests[i].toEncodeLen, "Unexpected required length %lu.\n", strLen);
 
         strLen2 = strLen;
         strW = heap_alloc(strLen);
         ret = CryptBinaryToStringW(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, strW, &strLen2);
-        ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
-        ok(strLen == strLen2, "Expected length %u, got %u\n", strLen, strLen2);
+        ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
+        ok(strLen == strLen2, "Expected length %lu, got %lu\n", strLen, strLen2);
         ok(!memcmp(strW, tests[i].toEncode, tests[i].toEncodeLen), "Unexpected value\n");
         heap_free(strW);
 
@@ -349,14 +349,14 @@ static void test_CryptBinaryToString(void)
 
         ret = CryptBinaryToStringA(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen,
             CRYPT_STRING_BINARY | CRYPT_STRING_NOCR, NULL, &strLen);
-        ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
+        ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError());
 
         strLen2 = strLen;
         str = heap_alloc(strLen);
         ret = CryptBinaryToStringA(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen,
             CRYPT_STRING_BINARY | CRYPT_STRING_NOCR, str, &strLen2);
-        ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError());
-        ok(strLen == strLen2, "Expected length %d, got %d\n", strLen, strLen2);
+        ok(ret, "CryptBinaryToStringA failed: %ld\n", GetLastError());
+        ok(strLen == strLen2, "Expected length %ld, got %ld\n", strLen, strLen2);
         ok(!memcmp(str, testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen), "Unexpected value\n");
         heap_free(str);
 
@@ -390,7 +390,7 @@ static void test_CryptBinaryToString(void)
     strLen = 0;
     ret = CryptBinaryToStringW(input, 3, CRYPT_STRING_HEXRAW, NULL, &strLen);
     ok(ret, "Failed to get string length.\n");
-    ok(strLen == 9 || broken(strLen == 7), "Unexpected string length %d.\n", strLen);
+    ok(strLen == 9 || broken(strLen == 7), "Unexpected string length %ld.\n", strLen);
     if (strLen == 7)
     {
         win_skip("CryptBinaryToString(HEXRAW) not supported\n");
@@ -404,13 +404,13 @@ static void test_CryptBinaryToString(void)
     {
         strLen = 0;
         ret = CryptBinaryToStringW(input, sizeof(input), CRYPT_STRING_HEXRAW|flags[i], NULL, &strLen);
-        ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
+        ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
         ok(strLen > 0, "Unexpected string length.\n");
 
         strLen = ~0;
         ret = CryptBinaryToStringW(input, sizeof(input), CRYPT_STRING_HEXRAW|flags[i],
                                    NULL, &strLen);
-        ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
+        ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
         if (flags[i] & CRYPT_STRING_NOCRLF)
             strLen2 = 0;
         else if (flags[i] & CRYPT_STRING_NOCR)
@@ -418,7 +418,7 @@ static void test_CryptBinaryToString(void)
         else
             strLen2 = 2;
         strLen2 += sizeof(input) * 2 + 1;
-        ok(strLen == strLen2, "Expected length %d, got %d\n", strLen2, strLen);
+        ok(strLen == strLen2, "Expected length %ld, got %ld\n", strLen2, strLen);
 
         hex = heap_alloc(strLen * sizeof(WCHAR));
         memset(hex, 0xcc, strLen * sizeof(WCHAR));
@@ -440,17 +440,17 @@ static void test_CryptBinaryToString(void)
         *ptr++ = 0;
         ret = CryptBinaryToStringW(input, sizeof(input), CRYPT_STRING_HEXRAW|flags[i],
                                    hex, &strLen);
-        ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
+        ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
         strLen2--;
-        ok(strLen == strLen2, "Expected length %d, got %d\n", strLen, strLen2);
+        ok(strLen == strLen2, "Expected length %ld, got %ld\n", strLen, strLen2);
         ok(!memcmp(hex, cmp, strLen * sizeof(WCHAR)), "Unexpected value\n");
 
         /* adjusts size if buffer too big */
         strLen *= 2;
         ret = CryptBinaryToStringW(input, sizeof(input), CRYPT_STRING_HEXRAW|flags[i],
                                    hex, &strLen);
-        ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
-        ok(strLen == strLen2, "Expected length %d, got %d\n", strLen, strLen2);
+        ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
+        ok(strLen == strLen2, "Expected length %ld, got %ld\n", strLen, strLen2);
 
         /* no writes if buffer too small */
         strLen /= 2;
@@ -460,9 +460,9 @@ static void test_CryptBinaryToString(void)
         SetLastError(0xdeadbeef);
         ret = CryptBinaryToStringW(input, sizeof(input), CRYPT_STRING_HEXRAW|flags[i],
                                    hex, &strLen);
-        ok(!ret && GetLastError() == ERROR_MORE_DATA,"Expected ERROR_MORE_DATA, got ret=%d le=%u\n",
+        ok(!ret && GetLastError() == ERROR_MORE_DATA,"Expected ERROR_MORE_DATA, got ret=%d le=%lu\n",
            ret, GetLastError());
-        ok(strLen == strLen2, "Expected length %d, got %d\n", strLen, strLen2);
+        ok(strLen == strLen2, "Expected length %ld, got %ld\n", strLen, strLen2);
         ok(!memcmp(hex, cmp, strLen * sizeof(WCHAR)), "Unexpected value\n");
 
         heap_free(hex);
@@ -474,14 +474,14 @@ static void test_CryptBinaryToString(void)
     {
         strLen = 0;
         ret = CryptBinaryToStringW(input, sizes[k], CRYPT_STRING_HEX | flags[i], NULL, &strLen);
-        ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
+        ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
         ok(strLen > 0, "Unexpected string length.\n");
 
         strLen = ~0;
         ret = CryptBinaryToStringW(input, sizes[k], CRYPT_STRING_HEX | flags[i], NULL, &strLen);
-        ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
+        ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
         strLen2 = binary_to_hex_len(sizes[k], CRYPT_STRING_HEX | flags[i]);
-        ok(strLen == strLen2, "%u: Expected length %d, got %d\n", i, strLen2, strLen);
+        ok(strLen == strLen2, "%lu: Expected length %ld, got %ld\n", i, strLen2, strLen);
 
         hex = heap_alloc(strLen * sizeof(WCHAR) + 256);
         memset(hex, 0xcc, strLen * sizeof(WCHAR));
@@ -529,16 +529,16 @@ static void test_CryptBinaryToString(void)
         *ptr++ = 0;
 
         ret = CryptBinaryToStringW(input, sizes[k], CRYPT_STRING_HEX | flags[i], hex, &strLen);
-        ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
+        ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
         strLen2--;
-        ok(strLen == strLen2, "%u: Expected length %d, got %d\n", i, strLen, strLen2);
-        ok(!memcmp(hex, cmp, strLen * sizeof(WCHAR)), "%u: got %s\n", i, wine_dbgstr_wn(hex, strLen));
+        ok(strLen == strLen2, "%lu: Expected length %ld, got %ld\n", i, strLen, strLen2);
+        ok(!memcmp(hex, cmp, strLen * sizeof(WCHAR)), "%lu: got %s\n", i, wine_dbgstr_wn(hex, strLen));
 
         /* adjusts size if buffer too big */
         strLen *= 2;
         ret = CryptBinaryToStringW(input, sizes[k], CRYPT_STRING_HEX | flags[i], hex, &strLen);
-        ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError());
-        ok(strLen == strLen2, "%u: Expected length %d, got %d\n", i, strLen, strLen2);
+        ok(ret, "CryptBinaryToStringW failed: %ld\n", GetLastError());
+        ok(strLen == strLen2, "%lu: Expected length %ld, got %ld\n", i, strLen, strLen2);
 
         /* no writes if buffer too small */
         strLen /= 2;
@@ -547,10 +547,10 @@ static void test_CryptBinaryToString(void)
         memset(cmp, 0xcc, strLen * sizeof(WCHAR));
         SetLastError(0xdeadbeef);
         ret = CryptBinaryToStringW(input, sizes[k], CRYPT_STRING_HEX | flags[i], hex, &strLen);
-        ok(!ret && GetLastError() == ERROR_MORE_DATA,"Expected ERROR_MORE_DATA, got ret=%d le=%u\n",
+        ok(!ret && GetLastError() == ERROR_MORE_DATA,"Expected ERROR_MORE_DATA, got ret=%d le=%lu\n",
            ret, GetLastError());
-        ok(strLen == strLen2, "%u: Expected length %d, got %d\n", i, strLen, strLen2);
-        ok(!memcmp(hex, cmp, strLen * sizeof(WCHAR)), "%u: got %s\n", i, wine_dbgstr_wn(hex, strLen));
+        ok(strLen == strLen2, "%lu: Expected length %ld, got %ld\n", i, strLen, strLen2);
+        ok(!memcmp(hex, cmp, strLen * sizeof(WCHAR)), "%lu: got %s\n", i, wine_dbgstr_wn(hex, strLen));
 
         heap_free(hex);
         heap_free(cmp);
@@ -585,7 +585,7 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
             strcat(str, trailer);
         ret = CryptStringToBinaryA(str, 0, useFormat, NULL, &bufLen, NULL,
          NULL);
-        ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
+        ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError());
         buf = HeapAlloc(GetProcessHeap(), 0, bufLen);
         if (buf)
         {
@@ -594,16 +594,16 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
             /* check as normal, make sure last two parameters are optional */
             ret = CryptStringToBinaryA(str, 0, useFormat, buf, &bufLen, NULL,
              NULL);
-            ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
+            ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError());
             ok(bufLen == expectedLen,
-             "Expected length %d, got %d\n", expectedLen, bufLen);
+             "Expected length %ld, got %ld\n", expectedLen, bufLen);
             ok(!memcmp(buf, expected, bufLen), "Unexpected value\n");
             /* check last two params */
             ret = CryptStringToBinaryA(str, 0, useFormat, buf, &bufLen,
              &skipped, &usedFormat);
-            ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
-            ok(skipped == 0, "Expected skipped 0, got %d\n", skipped);
-            ok(usedFormat == expectedFormat, "Expected format %d, got %d\n",
+            ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError());
+            ok(skipped == 0, "Expected skipped 0, got %ld\n", skipped);
+            ok(usedFormat == expectedFormat, "Expected format %ld, got %ld\n",
              expectedFormat, usedFormat);
             HeapFree(GetProcessHeap(), 0, buf);
         }
@@ -619,10 +619,10 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
          NULL);
         /* expect failure with no header, and success with one */
         if (header)
-            ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
+            ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError());
         else
             ok(!ret && GetLastError() == ERROR_INVALID_DATA,
-             "Expected !ret and last error ERROR_INVALID_DATA, got ret=%d, error=%d\n", ret, GetLastError());
+             "Expected !ret and last error ERROR_INVALID_DATA, got ret=%d, error=%ld\n", ret, GetLastError());
         if (ret)
         {
             buf = HeapAlloc(GetProcessHeap(), 0, bufLen);
@@ -632,9 +632,9 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
 
                 ret = CryptStringToBinaryA(str, 0, useFormat, buf, &bufLen,
                  &skipped, &usedFormat);
-                ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
+                ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError());
                 ok(skipped == strlen(garbage),
-                 "Expected %d characters of \"%s\" skipped when trying format %08x, got %d (used format is %08x)\n",
+                 "Expected %d characters of \"%s\" skipped when trying format %08lx, got %ld (used format is %08lx)\n",
                  lstrlenA(garbage), str, useFormat, skipped, usedFormat);
                 HeapFree(GetProcessHeap(), 0, buf);
             }
@@ -668,14 +668,14 @@ static void decodeBase64WithLenFmt(LPCSTR str, int len, DWORD fmt, LPCSTR expect
     if (expected) {
         BOOL correct = ret && strcmp(expected, (char*)buf) == 0;
         ok(correct || (isBroken && broken(!ret)),
-         "base64 \"%s\" len %d: expected \"%s\", got \"%s\" (ret %d, le %d)\n",
+         "base64 \"%s\" len %d: expected \"%s\", got \"%s\" (ret %d, le %ld)\n",
          str, len, expected, (char*)buf, ret, GetLastError());
         if (correct)
-            ok(fmtUsed == fmt, "base64 \"%s\" len %d: expected fmt %d, used %d\n",
+            ok(fmtUsed == fmt, "base64 \"%s\" len %d: expected fmt %ld, used %ld\n",
              str, len, fmt, fmtUsed);
     } else {
         ok(!ret && GetLastError() == le,
-         "base64 \"%s\" len %d: expected failure, got \"%s\" (ret %d, le %d)\n",
+         "base64 \"%s\" len %d: expected failure, got \"%s\" (ret %d, le %ld)\n",
          str, len, (char*)buf, ret, GetLastError());
     }
 
@@ -715,20 +715,20 @@ static void testStringToBinaryA(void)
 
     ret = CryptStringToBinaryA(NULL, 0, 0, NULL, NULL, NULL, NULL);
     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-     "Expected ERROR_INVALID_PARAMETER, got ret=%d le=%u\n", ret, GetLastError());
+     "Expected ERROR_INVALID_PARAMETER, got ret=%d le=%lu\n", ret, GetLastError());
     ret = CryptStringToBinaryA(NULL, 0, 0, NULL, &bufLen, NULL, NULL);
     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-     "Expected ERROR_INVALID_PARAMETER, got ret=%d le=%u\n", ret, GetLastError());
+     "Expected ERROR_INVALID_PARAMETER, got ret=%d le=%lu\n", ret, GetLastError());
     /* Bogus format */
     ret = CryptStringToBinaryA(tests[0].base64, 0, 0, NULL, &bufLen, NULL,
      NULL);
     ok(!ret && GetLastError() == ERROR_INVALID_DATA,
-     "Expected ERROR_INVALID_DATA, got ret=%d le=%u\n", ret, GetLastError());
+     "Expected ERROR_INVALID_DATA, got ret=%d le=%lu\n", ret, GetLastError());
     /* Decoding doesn't expect the NOCR flag to be specified */
     ret = CryptStringToBinaryA(tests[0].base64, 1,
      CRYPT_STRING_BASE64 | CRYPT_STRING_NOCR, NULL, &bufLen, NULL, NULL);
     ok(!ret && GetLastError() == ERROR_INVALID_DATA,
-     "Expected ERROR_INVALID_DATA, got ret=%d le=%u\n", ret, GetLastError());
+     "Expected ERROR_INVALID_DATA, got ret=%d le=%lu\n", ret, GetLastError());
     /* Bad strings */
     for (i = 0; i < ARRAY_SIZE(badStrings); i++)
     {
@@ -736,7 +736,7 @@ static void testStringToBinaryA(void)
         ret = CryptStringToBinaryA(badStrings[i].str, 0, badStrings[i].format,
          NULL, &bufLen, NULL, NULL);
         ok(!ret && GetLastError() == ERROR_INVALID_DATA,
-           "%d: Expected ERROR_INVALID_DATA, got ret=%d le=%u\n", i, ret, GetLastError());
+           "%ld: Expected ERROR_INVALID_DATA, got ret=%d le=%lu\n", i, ret, GetLastError());
     }
     /* Weird base64 strings (invalid padding, extra white-space etc.) */
     decodeBase64WithLen("V=", 0, 0, ERROR_INVALID_DATA);
@@ -793,7 +793,7 @@ static void testStringToBinaryA(void)
     bufLen = 4;
     ret = CryptStringToBinaryA("VVVVVVVV", 8, CRYPT_STRING_BASE64, (BYTE*)buf, &bufLen, NULL, NULL);
     ok(!ret && bufLen == 4 && buf[0] == 0,
-     "Expected ret 0, bufLen 4, buf[0] '\\0', got ret %d, bufLen %d, buf[0] '%c'\n",
+     "Expected ret 0, bufLen 4, buf[0] '\\0', got ret %d, bufLen %ld, buf[0] '%c'\n",
      ret, bufLen, buf[0]);
 
     /* Good strings */
@@ -805,7 +805,7 @@ static void testStringToBinaryA(void)
          */
         ret = CryptStringToBinaryA(tests[i].base64, 1, CRYPT_STRING_BASE64,
          NULL, &bufLen, NULL, NULL);
-        ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
+        ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError());
         /* Check with the precise format */
         decodeAndCompareBase64_A(tests[i].base64, NULL, NULL,
          CRYPT_STRING_BASE64, CRYPT_STRING_BASE64, tests[i].toEncode,
@@ -862,7 +862,7 @@ static void testStringToBinaryA(void)
          */
         ret = CryptStringToBinaryA(testsNoCR[i].base64, 1, CRYPT_STRING_BASE64,
          NULL, &bufLen, NULL, NULL);
-        ok(ret, "CryptStringToBinaryA failed: %d\n", GetLastError());
+        ok(ret, "CryptStringToBinaryA failed: %ld\n", GetLastError());
         /* Check with the precise format */
         decodeAndCompareBase64_A(testsNoCR[i].base64, NULL, NULL,
          CRYPT_STRING_BASE64, CRYPT_STRING_BASE64, testsNoCR[i].toEncode,
diff --git a/dlls/crypt32/tests/cert.c b/dlls/crypt32/tests/cert.c
index b96f94cc662..99b9487be46 100644
--- a/dlls/crypt32/tests/cert.c
+++ b/dlls/crypt32/tests/cert.c
@@ -148,7 +148,7 @@ static void testAddCert(void)
 
     store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(store != NULL, "CertOpenStore failed: %d\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
     if (!store)
         return;
 
@@ -161,13 +161,13 @@ static void testAddCert(void)
          sizeof(bigCert), 0, NULL);
         ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION ||
          GetLastError() == E_INVALIDARG),
-         "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08x\n",
+         "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n",
          GetLastError());
         ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
          bigCert, sizeof(bigCert), 0, NULL);
         ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION ||
          GetLastError() == E_INVALIDARG),
-         "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08x\n",
+         "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n",
          GetLastError());
     }
 
@@ -178,7 +178,7 @@ static void testAddCert(void)
     ret = CertAddEncodedCertificateToStore(0, X509_ASN_ENCODING, bigCert,
      sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &context);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* win98 */),
-     "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+     "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     if (context)
         CertFreeCertificateContext(context);
     if (!ret && GetLastError() == OSS_DATA_ERROR)
@@ -189,16 +189,16 @@ static void testAddCert(void)
 
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      bigCert2, sizeof(bigCert2), CERT_STORE_ADD_NEW, NULL);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
     /* This has the same name as bigCert, so finding isn't done by name */
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      certWithUsage, sizeof(certWithUsage), CERT_STORE_ADD_NEW, &context);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
     ok(context != NULL, "Expected a context\n");
     if (context)
@@ -213,7 +213,7 @@ static void testAddCert(void)
         /* Set the same hash as bigCert2, and try to readd it */
         ret = CertSetCertificateContextProperty(context, CERT_HASH_PROP_ID,
          0, &hash);
-        ok(ret, "CertSetCertificateContextProperty failed: %08x\n",
+        ok(ret, "CertSetCertificateContextProperty failed: %08lx\n",
          GetLastError());
         ret = CertAddCertificateContextToStore(store, context,
          CERT_STORE_ADD_NEW, NULL);
@@ -232,7 +232,7 @@ static void testAddCert(void)
         ret = CertAddCertificateContextToStore(store, context,
          CERT_STORE_ADD_NEW, NULL);
         ok(!ret && GetLastError() == CRYPT_E_EXISTS,
-         "Expected CRYPT_E_EXISTS, got %08x\n", GetLastError());
+         "Expected CRYPT_E_EXISTS, got %08lx\n", GetLastError());
         CertFreeCertificateContext(context);
     }
 
@@ -243,7 +243,7 @@ static void testAddCert(void)
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      bigCert2WithDifferentSerial, sizeof(bigCert2WithDifferentSerial),
      CERT_STORE_ADD_NEW, &context);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
     if (context)
         CertDeleteCertificateFromStore(context);
@@ -255,7 +255,7 @@ static void testAddCert(void)
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      bigCertWithDifferentSubject, sizeof(bigCertWithDifferentSubject),
      CERT_STORE_ADD_NEW, &context);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
     if (context)
         CertDeleteCertificateFromStore(context);
@@ -267,14 +267,14 @@ static void testAddCert(void)
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      bigCertWithDifferentIssuer, sizeof(bigCertWithDifferentIssuer),
      CERT_STORE_ADD_NEW, &context);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
     if (context)
         CertDeleteCertificateFromStore(context);
 
     collection = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(collection != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(collection != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     if (collection)
     {
         /* Add store to the collection, but disable updates */
@@ -289,19 +289,19 @@ static void testAddCert(void)
             ret = CertAddCertificateContextToStore(collection, context,
              CERT_STORE_ADD_NEW, NULL);
             ok(!ret && GetLastError() == CRYPT_E_EXISTS,
-             "Expected CRYPT_E_EXISTS, got %08x\n", GetLastError());
+             "Expected CRYPT_E_EXISTS, got %08lx\n", GetLastError());
             /* Replacing an existing certificate context is allowed, even
              * though updates to the collection aren't..
              */
             ret = CertAddCertificateContextToStore(collection, context,
              CERT_STORE_ADD_REPLACE_EXISTING, NULL);
-            ok(ret, "CertAddCertificateContextToStore failed: %08x\n",
+            ok(ret, "CertAddCertificateContextToStore failed: %08lx\n",
              GetLastError());
             /* use the existing certificate and ask for a copy of the context*/
             copyContext = NULL;
             ret = CertAddCertificateContextToStore(collection, context,
              CERT_STORE_ADD_USE_EXISTING, &copyContext);
-            ok(ret, "CertAddCertificateContextToStore failed: %08x\n",
+            ok(ret, "CertAddCertificateContextToStore failed: %08lx\n",
              GetLastError());
             ok(copyContext != NULL, "Expected on output a non NULL copyContext\n");
             if (copyContext)
@@ -310,7 +310,7 @@ static void testAddCert(void)
             ret = CertAddCertificateContextToStore(collection, context,
              CERT_STORE_ADD_ALWAYS, NULL);
             ok(!ret && GetLastError() == E_ACCESSDENIED,
-             "Expected E_ACCESSDENIED, got %08x\n", GetLastError());
+             "Expected E_ACCESSDENIED, got %08lx\n", GetLastError());
             CertFreeCertificateContext(context);
         }
 
@@ -332,18 +332,18 @@ static void checkHash(const BYTE *data, DWORD dataLen, ALG_ID algID,
     memset(hashProperty, 0, sizeof(hashProperty));
     size = sizeof(hash);
     ret = CryptHashCertificate(0, algID, 0, data, dataLen, hash, &size);
-    ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError());
+    ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError());
     ret = CertGetCertificateContextProperty(context, propID, NULL,
      &dwSizeWithNull);
-    ok(ret, "algID %08x, propID %d: CertGetCertificateContextProperty failed: %08x\n",
+    ok(ret, "algID %08x, propID %ld: CertGetCertificateContextProperty failed: %08lx\n",
      algID, propID, GetLastError());
     ret = CertGetCertificateContextProperty(context, propID, hashProperty,
      &size);
-    ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
+    ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
      GetLastError());
-    ok(!memcmp(hash, hashProperty, size), "Unexpected hash for property %d\n",
+    ok(!memcmp(hash, hashProperty, size), "Unexpected hash for property %ld\n",
      propID);
-    ok(size == dwSizeWithNull, "Unexpected length of hash for property: received %d instead of %d\n",
+    ok(size == dwSizeWithNull, "Unexpected length of hash for property: received %ld instead of %ld\n",
      dwSizeWithNull,size);
 }
 
@@ -411,7 +411,7 @@ static void testCertProperties(void)
     CERT_KEY_CONTEXT keyContext;
 
     ok(context != NULL || broken(GetLastError() == OSS_DATA_ERROR /* win98 */),
-     "CertCreateCertificateContext failed: %08x\n", GetLastError());
+     "CertCreateCertificateContext failed: %08lx\n", GetLastError());
     if (!context)
         return;
 
@@ -426,12 +426,12 @@ static void testCertProperties(void)
         if (propID)
             numProps++;
     } while (propID != 0);
-    ok(numProps == 0, "Expected 0 properties, got %d\n", numProps);
+    ok(numProps == 0, "Expected 0 properties, got %ld\n", numProps);
 
     /* Tests with a NULL cert context.  Prop ID 0 fails.. */
     ret = CertSetCertificateContextProperty(NULL, 0, 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* while this just crashes.
     ret = CertSetCertificateContextProperty(NULL,
      CERT_KEY_PROV_HANDLE_PROP_ID, 0, NULL);
@@ -439,7 +439,7 @@ static void testCertProperties(void)
 
     ret = CertSetCertificateContextProperty(context, 0, 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* Can't set the cert property directly, this crashes.
     ret = CertSetCertificateContextProperty(context,
      CERT_CERT_PROP_ID, 0, bigCert2);
@@ -458,12 +458,12 @@ static void testCertProperties(void)
     ret = CertGetCertificateContextProperty(context,
      CERT_KEY_PROV_INFO_PROP_ID, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
-     "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
     /* And, an implicit property */
     size = sizeof(access);
     ret = CertGetCertificateContextProperty(context,
      CERT_ACCESS_STATE_PROP_ID, &access, &size);
-    ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
+    ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
      GetLastError());
     ok(!(access & CERT_ACCESS_STATE_WRITE_PERSIST_FLAG),
      "Didn't expect a persisted cert\n");
@@ -478,18 +478,18 @@ static void testCertProperties(void)
     blob.cbData = sizeof(hash);
     ret = CertSetCertificateContextProperty(context, CERT_HASH_PROP_ID, 0,
      &blob);
-    ok(ret, "CertSetCertificateContextProperty failed: %08x\n",
+    ok(ret, "CertSetCertificateContextProperty failed: %08lx\n",
      GetLastError());
     size = sizeof(hashProperty);
     ret = CertGetCertificateContextProperty(context, CERT_HASH_PROP_ID,
      hashProperty, &size);
-    ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
+    ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
      GetLastError());
     ok(!memcmp(hashProperty, hash, sizeof(hash)), "Unexpected hash\n");
     /* Delete the (bogus) hash, and get the real one */
     ret = CertSetCertificateContextProperty(context, CERT_HASH_PROP_ID, 0,
      NULL);
-    ok(ret, "CertSetCertificateContextProperty failed: %08x\n",
+    ok(ret, "CertSetCertificateContextProperty failed: %08lx\n",
      GetLastError());
     checkHash(bigCert, sizeof(bigCert), CALG_SHA1, context,
      CERT_HASH_PROP_ID);
@@ -504,7 +504,7 @@ static void testCertProperties(void)
         if (propID)
             numProps++;
     } while (propID != 0);
-    ok(numProps == 1, "Expected 1 properties, got %d\n", numProps);
+    ok(numProps == 1, "Expected 1 properties, got %ld\n", numProps);
 
     /* Check a few other implicit properties */
     checkHash(bigCert, sizeof(bigCert), CALG_MD5, context,
@@ -518,57 +518,57 @@ static void testCertProperties(void)
        (GetLastError() == CRYPT_E_ASN1_BADTAG ||
         GetLastError() == CRYPT_E_NOT_FOUND ||
         GetLastError() == OSS_DATA_ERROR), /* win9x */
-       "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
+       "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
 
     /* Test key contexts and handles and such */
     size = 0;
     ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
      NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
-     "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
     size = sizeof(CERT_KEY_CONTEXT);
     ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
      NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
-     "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
     ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
      &keyContext, &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
-     "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
     /* Key context with an invalid size */
     keyContext.cbSize = 0;
     ret = CertSetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
      0, &keyContext);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     size = sizeof(keyContext);
     ret = CertGetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
      &keyContext, &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
-     "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
     keyContext.cbSize = sizeof(keyContext);
     keyContext.hCryptProv = 0;
     keyContext.dwKeySpec = AT_SIGNATURE;
     ret = CertSetCertificateContextProperty(context, CERT_KEY_CONTEXT_PROP_ID,
      0, &keyContext);
-    ok(ret, "CertSetCertificateContextProperty failed: %08x\n", GetLastError());
+    ok(ret, "CertSetCertificateContextProperty failed: %08lx\n", GetLastError());
     /* Now that that's set, the key prov handle property is also gettable.
      */
     size = sizeof(keyContext.hCryptProv);
     ret = CertGetCertificateContextProperty(context,
      CERT_KEY_PROV_HANDLE_PROP_ID, &keyContext.hCryptProv, &size);
-    ok(ret, "Expected to get the CERT_KEY_PROV_HANDLE_PROP_ID, got %08x\n",
+    ok(ret, "Expected to get the CERT_KEY_PROV_HANDLE_PROP_ID, got %08lx\n",
      GetLastError());
     /* Remove the key prov handle property.. */
     ret = CertSetCertificateContextProperty(context,
      CERT_KEY_PROV_HANDLE_PROP_ID, 0, NULL);
-    ok(ret, "CertSetCertificateContextProperty failed: %08x\n",
+    ok(ret, "CertSetCertificateContextProperty failed: %08lx\n",
      GetLastError());
     /* and the key context's CSP is set to NULL. */
     size = sizeof(keyContext);
     ret = CertGetCertificateContextProperty(context,
      CERT_KEY_CONTEXT_PROP_ID, &keyContext, &size);
-    ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
+    ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
      GetLastError());
     ok(keyContext.hCryptProv == 0, "Expected no hCryptProv\n");
 
@@ -579,7 +579,7 @@ static void testCertProperties(void)
     ret = CertGetCertificateContextProperty(context,
      CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size);
     ok(!ret && GetLastError() == ERROR_INVALID_DATA,
-     "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError());
+     "Expected ERROR_INVALID_DATA, got %08lx\n", GetLastError());
     CertFreeCertificateContext(context);
     /* This cert does have a public key, but its subject key identifier still
      * isn't available: */
@@ -588,7 +588,7 @@ static void testCertProperties(void)
     ret = CertGetCertificateContextProperty(context,
      CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size);
     ok(!ret && GetLastError() == ERROR_INVALID_DATA,
-     "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError());
+     "Expected ERROR_INVALID_DATA, got %08lx\n", GetLastError());
     CertFreeCertificateContext(context);
     /* This cert with a subject key extension can have its key identifier
      * property retrieved:
@@ -597,7 +597,7 @@ static void testCertProperties(void)
      v1CertWithSubjectKeyId, sizeof(v1CertWithSubjectKeyId));
     ret = CertGetCertificateContextProperty(context,
      CERT_KEY_IDENTIFIER_PROP_ID, NULL, &size);
-    ok(ret, "CertGetCertificateContextProperty failed: %08x\n", GetLastError());
+    ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError());
     if (ret)
     {
         LPBYTE buf = HeapAlloc(GetProcessHeap(), 0, size);
@@ -606,7 +606,7 @@ static void testCertProperties(void)
         {
             ret = CertGetCertificateContextProperty(context,
              CERT_KEY_IDENTIFIER_PROP_ID, buf, &size);
-            ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
+            ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
              GetLastError());
             ok(!memcmp(buf, subjectKeyId, size), "Unexpected subject key id\n");
             HeapFree(GetProcessHeap(), 0, buf);
@@ -620,8 +620,8 @@ static void testCertProperties(void)
     size = 0;
     ret = CertGetCertificateContextProperty(context,
      CERT_SIGNATURE_HASH_PROP_ID, NULL, &size);
-    ok(ret, "CertGetCertificateContextProperty failed: %08x\n", GetLastError());
-    ok(size == sizeof(selfSignedSignatureHash), "unexpected size %d\n", size);
+    ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError());
+    ok(size == sizeof(selfSignedSignatureHash), "unexpected size %ld\n", size);
     ret = CertGetCertificateContextProperty(context,
      CERT_SIGNATURE_HASH_PROP_ID, hashProperty, &size);
     if (ret)
@@ -639,22 +639,22 @@ static void testCreateCert(void)
     SetLastError(0xdeadbeef);
     cert = CertCreateCertificateContext(0, NULL, 0);
     ok(!cert && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     cert = CertCreateCertificateContext(0, selfSignedCert,
      sizeof(selfSignedCert));
     ok(!cert && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     cert = CertCreateCertificateContext(X509_ASN_ENCODING, NULL, 0);
     ok(!cert &&
      (GetLastError() == CRYPT_E_ASN1_EOD ||
      broken(GetLastError() == OSS_MORE_INPUT /* NT4 */)),
-     "expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
+     "expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
 
     cert = CertCreateCertificateContext(X509_ASN_ENCODING,
      selfSignedCert, sizeof(selfSignedCert));
-    ok(cert != NULL, "creating cert failed: %08x\n", GetLastError());
+    ok(cert != NULL, "creating cert failed: %08lx\n", GetLastError());
     /* Even in-memory certs are expected to have a store associated with them */
     ok(cert->hCertStore != NULL, "expected created cert to have a store\n");
     /* The cert doesn't have the archived property set (which would imply it
@@ -664,13 +664,13 @@ static void testCreateCert(void)
     ret = CertGetCertificateContextProperty(cert, CERT_ARCHIVED_PROP_ID,
      NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
-       "expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+       "expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
     /* Strangely, enumerating the certs in the store finds none. */
     enumCert = NULL;
     count = 0;
     while ((enumCert = CertEnumCertificatesInStore(cert->hCertStore, enumCert)))
         count++;
-    ok(!count, "expected 0, got %d\n", count);
+    ok(!count, "expected 0, got %ld\n", count);
     CertFreeCertificateContext(cert);
 }
 
@@ -682,14 +682,14 @@ static void testDupCert(void)
 
     store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(store != NULL, "CertOpenStore failed: %d\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
     if (!store)
         return;
 
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &context);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* win98 */),
-     "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+     "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     if (!ret && GetLastError() == OSS_DATA_ERROR)
     {
         skip("bigCert can't be decoded, skipping tests\n");
@@ -699,7 +699,7 @@ static void testDupCert(void)
     if (context)
     {
         ok(context->cbCertEncoded == sizeof(bigCert),
-         "Wrong cert size %d\n", context->cbCertEncoded);
+         "Wrong cert size %ld\n", context->cbCertEncoded);
         ok(!memcmp(context->pbCertEncoded, bigCert, sizeof(bigCert)),
          "Unexpected encoded cert in context\n");
         ok(context->hCertStore == store, "Unexpected store\n");
@@ -725,7 +725,7 @@ static void testDupCert(void)
     ok(ret, "CertFreeCertificateContext failed\n");
 
     store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(store != NULL, "CertOpenStore failed: %d\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
 
     ret = CertAddCertificateContextToStore(store, context, CERT_STORE_ADD_NEW, &storeContext);
     ok(ret, "CertAddCertificateContextToStore failed\n");
@@ -737,7 +737,7 @@ static void testDupCert(void)
     ok(storeContext->pCertInfo != context->pCertInfo, "unexpected pCertInfo\n");
 
     store2 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(store2 != NULL, "CertOpenStore failed: %d\n", GetLastError());
+    ok(store2 != NULL, "CertOpenStore failed: %ld\n", GetLastError());
 
     ret = CertAddCertificateContextToStore(store2, storeContext, CERT_STORE_ADD_NEW, &storeContext2);
     ok(ret, "CertAddCertificateContextToStore failed\n");
@@ -781,7 +781,7 @@ static void testLinkCert(void)
     ok(context != NULL, "CertCreateCertificateContext failed\n");
 
     store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(store != NULL, "CertOpenStore failed: %d\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
 
     ret = CertAddCertificateLinkToStore(store, context, CERT_STORE_ADD_NEW, &link);
     ok(ret, "CertAddCertificateContextToStore failed\n");
@@ -1141,14 +1141,14 @@ static void testFindCert(void)
 
     store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(store != NULL, "CertOpenStore failed: %d\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
     if (!store)
         return;
 
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      bigCert, sizeof(bigCert), CERT_STORE_ADD_NEW, NULL);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* win98 */),
-     "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+     "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     if (!ret && GetLastError() == OSS_DATA_ERROR)
     {
         skip("bigCert can't be decoded, skipping tests\n");
@@ -1156,12 +1156,12 @@ static void testFindCert(void)
     }
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      bigCert2, sizeof(bigCert2), CERT_STORE_ADD_NEW, NULL);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
     /* This has the same name as bigCert */
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      certWithUsage, sizeof(certWithUsage), CERT_STORE_ADD_NEW, NULL);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
 
     /* Crashes
@@ -1175,7 +1175,7 @@ static void testFindCert(void)
     certInfo.SerialNumber.cbData = sizeof(serialNum);
     context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0,
      CERT_FIND_ISSUER_NAME, &certInfo.Subject, NULL);
-    ok(context != NULL, "CertFindCertificateInStore failed: %08x\n",
+    ok(context != NULL, "CertFindCertificateInStore failed: %08lx\n",
      GetLastError());
     if (context)
     {
@@ -1195,7 +1195,7 @@ static void testFindCert(void)
     certInfo.Subject.cbData = sizeof(subjectName2);
     context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0,
      CERT_FIND_SUBJECT_NAME, &certInfo.Subject, NULL);
-    ok(context != NULL, "CertFindCertificateInStore failed: %08x\n",
+    ok(context != NULL, "CertFindCertificateInStore failed: %08lx\n",
      GetLastError());
     if (context)
     {
@@ -1216,7 +1216,7 @@ static void testFindCert(void)
     certInfo.Issuer.cbData = sizeof(subjectName2);
     context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0,
      CERT_FIND_SUBJECT_CERT, &certInfo, NULL);
-    ok(context != NULL, "CertFindCertificateInStore failed: %08x\n",
+    ok(context != NULL, "CertFindCertificateInStore failed: %08lx\n",
      GetLastError());
     if (context)
     {
@@ -1249,7 +1249,7 @@ static void testFindCert(void)
     blob.cbData = sizeof(bigCertHash);
     context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0,
      CERT_FIND_SHA1_HASH, &blob, NULL);
-    ok(context != NULL, "CertFindCertificateInStore failed: %08x\n",
+    ok(context != NULL, "CertFindCertificateInStore failed: %08lx\n",
      GetLastError());
     if (context)
     {
@@ -1291,7 +1291,7 @@ static void testFindCert(void)
      CERT_FIND_ISSUER_STR, malcolm, NULL);
     ok(!context, "expected no certs\n");
     ok(GetLastError() == CRYPT_E_NOT_FOUND,
-     "expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
 
     CertCloseStore(store, 0);
 
@@ -1300,19 +1300,19 @@ static void testFindCert(void)
      CERT_STORE_CREATE_NEW_FLAG, NULL);
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      iTunesCert0, sizeof(iTunesCert0), CERT_STORE_ADD_NEW, NULL);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      iTunesCert1, sizeof(iTunesCert1), CERT_STORE_ADD_NEW, NULL);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      iTunesCert2, sizeof(iTunesCert2), CERT_STORE_ADD_NEW, NULL);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      iTunesCert3, sizeof(iTunesCert3), CERT_STORE_ADD_NEW, &subject);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
 
     /* The certInfo's issuer does not match any subject, but the serial
@@ -1366,14 +1366,14 @@ static void testGetSubjectCert(void)
 
     store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(store != NULL, "CertOpenStore failed: %d\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
     if (!store)
         return;
 
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* win98 */),
-     "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+     "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     if (!ret && GetLastError() == OSS_DATA_ERROR)
     {
         skip("bigCert can't be decoded, skipping tests\n");
@@ -1381,34 +1381,34 @@ static void testGetSubjectCert(void)
     }
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      bigCert2, sizeof(bigCert2), CERT_STORE_ADD_NEW, &context1);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
     ok(context1 != NULL, "Expected a context\n");
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      certWithUsage, sizeof(certWithUsage), CERT_STORE_ADD_NEW, NULL);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
 
     context2 = CertGetSubjectCertificateFromStore(store, X509_ASN_ENCODING,
      NULL);
     ok(!context2 && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     context2 = CertGetSubjectCertificateFromStore(store, X509_ASN_ENCODING,
      &info);
     ok(!context2 && GetLastError() == CRYPT_E_NOT_FOUND,
-     "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
     info.SerialNumber.cbData = sizeof(serialNum);
     info.SerialNumber.pbData = serialNum;
     context2 = CertGetSubjectCertificateFromStore(store, X509_ASN_ENCODING,
      &info);
     ok(!context2 && GetLastError() == CRYPT_E_NOT_FOUND,
-     "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
     info.Issuer.cbData = sizeof(subjectName2);
     info.Issuer.pbData = subjectName2;
     context2 = CertGetSubjectCertificateFromStore(store, X509_ASN_ENCODING,
      &info);
     ok(context2 != NULL,
-     "CertGetSubjectCertificateFromStore failed: %08x\n", GetLastError());
+     "CertGetSubjectCertificateFromStore failed: %08lx\n", GetLastError());
     /* Not only should this find a context, but it should be the same
      * (same address) as context1.
      */
@@ -1569,16 +1569,16 @@ static void testGetIssuerCert(void)
     HCERTSTORE store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
 
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
 
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      expiredCert, sizeof(expiredCert), CERT_STORE_ADD_ALWAYS, NULL);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
 
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      childOfExpired, sizeof(childOfExpired), CERT_STORE_ADD_ALWAYS, &child);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
 
     /* These crash:
@@ -1587,13 +1587,13 @@ static void testGetIssuerCert(void)
      */
     parent = CertGetIssuerCertificateFromStore(NULL, NULL, NULL, &flags);
     ok(!parent && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     parent = CertGetIssuerCertificateFromStore(store, NULL, NULL, &flags);
     ok(!parent && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
     ok(!parent && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* Confusing: the caller cannot set either of the
      * CERT_STORE_NO_*_FLAGs, as these are not checks,
      * they're results:
@@ -1601,24 +1601,24 @@ static void testGetIssuerCert(void)
     flags = CERT_STORE_NO_CRL_FLAG | CERT_STORE_NO_ISSUER_FLAG;
     parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
     ok(!parent && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* Perform no checks */
     flags = 0;
     parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
-    ok(parent != NULL, "CertGetIssuerCertificateFromStore failed: %08x\n",
+    ok(parent != NULL, "CertGetIssuerCertificateFromStore failed: %08lx\n",
      GetLastError());
     if (parent)
         CertFreeCertificateContext(parent);
     /* Check revocation and signature only */
     flags = CERT_STORE_REVOCATION_FLAG | CERT_STORE_SIGNATURE_FLAG;
     parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
-    ok(parent != NULL, "CertGetIssuerCertificateFromStore failed: %08x\n",
+    ok(parent != NULL, "CertGetIssuerCertificateFromStore failed: %08lx\n",
      GetLastError());
     /* Confusing: CERT_STORE_REVOCATION_FLAG succeeds when there is no CRL by
      * setting CERT_STORE_NO_CRL_FLAG.
      */
     ok(flags == (CERT_STORE_REVOCATION_FLAG | CERT_STORE_NO_CRL_FLAG),
-     "Expected CERT_STORE_REVOCATION_FLAG | CERT_STORE_NO_CRL_FLAG, got %08x\n",
+     "Expected CERT_STORE_REVOCATION_FLAG | CERT_STORE_NO_CRL_FLAG, got %08lx\n",
      flags);
     if (parent)
         CertFreeCertificateContext(parent);
@@ -1637,33 +1637,33 @@ static void testGetIssuerCert(void)
     /* With only the child certificate, no issuer will be found */
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      chain7_1, sizeof(chain7_1), CERT_STORE_ADD_ALWAYS, &child);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
     ok(parent == NULL, "Expected no issuer\n");
-    ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08X\n", GetLastError());
+    ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError());
     /* Adding an issuer allows one (and only one) issuer to be found */
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      chain10_1, sizeof(chain10_1), CERT_STORE_ADD_ALWAYS, &cert1);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
     ok(parent == cert1, "Expected cert1 to be the issuer\n");
     parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
     ok(parent == NULL, "Expected only one issuer\n");
-    ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08X\n", GetLastError());
+    ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError());
     /* Adding a second issuer allows two issuers to be found - and the second
      * issuer is found before the first, implying certs are added to the head
      * of a list.
      */
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      chain10_0, sizeof(chain10_0), CERT_STORE_ADD_ALWAYS, &cert2);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
     ok(parent == cert2, "Expected cert2 to be the first issuer\n");
     parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
     ok(parent == cert1, "Expected cert1 to be the second issuer\n");
     parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
     ok(parent == NULL, "Expected no more than two issuers\n");
-    ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08X\n", GetLastError());
+    ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError());
     CertFreeCertificateContext(child);
     CertFreeCertificateContext(cert1);
     CertFreeCertificateContext(cert2);
@@ -1677,33 +1677,33 @@ static void testGetIssuerCert(void)
     /* With only the child certificate, no issuer will be found */
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      chain7_1, sizeof(chain7_1), CERT_STORE_ADD_ALWAYS, &child);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
     ok(parent == NULL, "Expected no issuer\n");
-    ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08X\n", GetLastError());
+    ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError());
     /* Adding an issuer allows one (and only one) issuer to be found */
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      chain10_0, sizeof(chain10_0), CERT_STORE_ADD_ALWAYS, &cert1);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
     ok(parent == cert1, "Expected cert1 to be the issuer\n");
     parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
     ok(parent == NULL, "Expected only one issuer\n");
-    ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08X\n", GetLastError());
+    ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError());
     /* Adding a second issuer allows two issuers to be found - and the second
      * issuer is found before the first, implying certs are added to the head
      * of a list.
      */
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      chain10_1, sizeof(chain10_1), CERT_STORE_ADD_ALWAYS, &cert2);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     parent = CertGetIssuerCertificateFromStore(store, child, NULL, &flags);
     ok(parent == cert2, "Expected cert2 to be the first issuer\n");
     parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
     ok(parent == cert1, "Expected cert1 to be the second issuer\n");
     parent = CertGetIssuerCertificateFromStore(store, child, parent, &flags);
     ok(parent == NULL, "Expected no more than two issuers\n");
-    ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08X\n", GetLastError());
+    ok(GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08lX\n", GetLastError());
 
     /* Self-sign a certificate, add to the store and test getting the issuer */
     size = 0;
@@ -1717,7 +1717,7 @@ static void testGetIssuerCert(void)
     cert3 = CertCreateSelfSignCertificate(0, &certsubject, 0, NULL, NULL, NULL, NULL, NULL);
     ok(cert3 != NULL, "CertCreateSelfSignCertificate should have worked\n");
     ret = CertAddCertificateContextToStore(store, cert3, CERT_STORE_ADD_REPLACE_EXISTING, 0);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     CertFreeCertificateContext(cert3);
     cert3 = CertEnumCertificatesInStore(store, NULL);
     ok(cert3 != NULL, "CertEnumCertificatesInStore should have worked\n");
@@ -1726,7 +1726,7 @@ static void testGetIssuerCert(void)
     parent = CertGetIssuerCertificateFromStore(store, cert3, NULL, &flags);
     ok(!parent, "Expected NULL\n");
     ok(GetLastError() == CRYPT_E_SELF_SIGNED,
-       "Expected CRYPT_E_SELF_SIGNED, got %08X\n", GetLastError());
+       "Expected CRYPT_E_SELF_SIGNED, got %08lX\n", GetLastError());
     CertFreeCertificateContext(child);
     CertFreeCertificateContext(cert1);
     CertFreeCertificateContext(cert2);
@@ -1736,7 +1736,7 @@ static void testGetIssuerCert(void)
 
     /* Test root storage self-signed certificate */
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER, rootW);
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     flags = 0;
     cert1 = CertEnumCertificatesInStore(store, NULL);
     ok(cert1 != NULL, "CertEnumCertificatesInStore should have worked\n");
@@ -1744,7 +1744,7 @@ static void testGetIssuerCert(void)
     parent = CertGetIssuerCertificateFromStore(store, cert1, NULL, &flags);
     ok(!parent, "Expected NULL\n");
     ok(GetLastError() == CRYPT_E_SELF_SIGNED,
-       "Expected CRYPT_E_SELF_SIGNED, got %08X\n", GetLastError());
+       "Expected CRYPT_E_SELF_SIGNED, got %08lX\n", GetLastError());
     CertFreeCertificateContext(cert1);
     CertCloseStore(store, 0);
 }
@@ -1770,17 +1770,17 @@ static void testCryptHashCert(void)
     /* Test empty hash */
     ret = CryptHashCertificate(0, 0, 0, toHash, sizeof(toHash), NULL,
      &hashLen);
-    ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError());
-    ok(hashLen == sizeof(hash), "Got unexpected size of hash %d\n", hashLen);
+    ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError());
+    ok(hashLen == sizeof(hash), "Got unexpected size of hash %ld\n", hashLen);
     /* Test with empty buffer */
     ret = CryptHashCertificate(0, 0, 0, NULL, 0, hash, &hashLen);
-    ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError());
+    ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError());
     ok(!memcmp(hash, emptyHash, sizeof(emptyHash)),
      "Unexpected hash of nothing\n");
     /* Test a known value */
     ret = CryptHashCertificate(0, 0, 0, toHash, sizeof(toHash), hash,
      &hashLen);
-    ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError());
+    ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError());
     ok(!memcmp(hash, knownHash, sizeof(knownHash)), "Unexpected hash\n");
 }
 
@@ -1810,22 +1810,22 @@ static void testCryptHashCert2(void)
     /* Test empty hash */
     hashLen = sizeof(hash);
     ret = pCryptHashCertificate2(SHA1, 0, NULL, NULL, 0, hash, &hashLen);
-    ok(ret, "CryptHashCertificate2 failed: %08x\n", GetLastError());
-    ok(hashLen == sizeof(hash), "Got unexpected size of hash %d\n", hashLen);
+    ok(ret, "CryptHashCertificate2 failed: %08lx\n", GetLastError());
+    ok(hashLen == sizeof(hash), "Got unexpected size of hash %ld\n", hashLen);
     ok(!memcmp(hash, emptyHash, sizeof(emptyHash)), "Unexpected hash of nothing\n");
 
     /* Test known hash */
     hashLen = sizeof(hash);
     ret = pCryptHashCertificate2(SHA1, 0, NULL, toHash, sizeof(toHash), hash, &hashLen);
-    ok(ret, "CryptHashCertificate2 failed: %08x\n", GetLastError());
-    ok(hashLen == sizeof(hash), "Got unexpected size of hash %d\n", hashLen);
+    ok(ret, "CryptHashCertificate2 failed: %08lx\n", GetLastError());
+    ok(hashLen == sizeof(hash), "Got unexpected size of hash %ld\n", hashLen);
     ok(!memcmp(hash, knownHash, sizeof(knownHash)), "Unexpected hash\n");
 
     /* Test null hash size pointer just sets hash size */
     hashLen = 0;
     ret = pCryptHashCertificate2(SHA1, 0, NULL, toHash, sizeof(toHash), NULL, &hashLen);
-    ok(ret, "CryptHashCertificate2 failed: %08x\n", GetLastError());
-    ok(hashLen == sizeof(hash), "Hash size not set correctly (%d)\n", hashLen);
+    ok(ret, "CryptHashCertificate2 failed: %08lx\n", GetLastError());
+    ok(hashLen == sizeof(hash), "Hash size not set correctly (%ld)\n", hashLen);
 
     /* Null algorithm ID crashes Windows implementations */
     if (0) {
@@ -1839,14 +1839,14 @@ static void testCryptHashCert2(void)
     SetLastError(0xdeadbeef);
     ret = pCryptHashCertificate2(invalidAlgorithm, 0, NULL, toHash, sizeof(toHash), hash, &hashLen);
     ok(!ret && GetLastError() == STATUS_NOT_FOUND,
-     "Expected STATUS_NOT_FOUND (0x%08x), got 0x%08x\n", STATUS_NOT_FOUND, GetLastError());
+     "Expected STATUS_NOT_FOUND (0x%08lx), got 0x%08lx\n", STATUS_NOT_FOUND, GetLastError());
 
     /* Test hash buffer too small */
     hashLen = sizeof(hash) / 2;
     SetLastError(0xdeadbeef);
     ret = pCryptHashCertificate2(SHA1, 0, NULL, toHash, sizeof(toHash), hash, &hashLen);
     ok(!ret && GetLastError() == ERROR_MORE_DATA,
-     "Expected ERROR_MORE_DATA (%d), got %d\n", ERROR_MORE_DATA, GetLastError());
+     "Expected ERROR_MORE_DATA (%d), got %ld\n", ERROR_MORE_DATA, GetLastError());
 
     /* Null hash length crashes Windows implementations */
     if (0) {
@@ -1864,20 +1864,20 @@ static void verifySig(HCRYPTPROV csp, const BYTE *toSign, size_t toSignLen,
     HCRYPTHASH hash;
     BOOL ret = CryptCreateHash(csp, CALG_SHA1, 0, 0, &hash);
 
-    ok(ret, "CryptCreateHash failed: %08x\n", GetLastError());
+    ok(ret, "CryptCreateHash failed: %08lx\n", GetLastError());
     if (ret)
     {
         BYTE mySig[64];
         DWORD mySigSize = sizeof(mySig);
 
         ret = CryptHashData(hash, toSign, toSignLen, 0);
-        ok(ret, "CryptHashData failed: %08x\n", GetLastError());
+        ok(ret, "CryptHashData failed: %08lx\n", GetLastError());
         /* use the A variant so the test can run on Win9x */
         ret = CryptSignHashA(hash, AT_SIGNATURE, NULL, 0, mySig, &mySigSize);
-        ok(ret, "CryptSignHash failed: %08x\n", GetLastError());
+        ok(ret, "CryptSignHash failed: %08lx\n", GetLastError());
         if (ret)
         {
-            ok(mySigSize == sigLen, "Expected sig length %d, got %d\n",
+            ok(mySigSize == sigLen, "Expected sig length %d, got %ld\n",
              sigLen, mySigSize);
             ok(!memcmp(mySig, sig, sigLen), "Unexpected signature\n");
         }
@@ -1907,40 +1907,40 @@ static void testSignCert(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned,
     ret = CryptSignCertificate(0, 0, 0, toBeSigned->pbData, toBeSigned->cbData,
      &algoID, NULL, NULL, &size);
     ok(!ret && GetLastError() == NTE_BAD_ALGID, 
-     "Expected NTE_BAD_ALGID, got %08x\n", GetLastError());
+     "Expected NTE_BAD_ALGID, got %08lx\n", GetLastError());
     algoID.pszObjId = (LPSTR)sigOID;
     ret = CryptSignCertificate(0, 0, 0, toBeSigned->pbData, toBeSigned->cbData,
      &algoID, NULL, NULL, &size);
     ok(!ret &&
      (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == NTE_BAD_ALGID),
-     "Expected ERROR_INVALID_PARAMETER or NTE_BAD_ALGID, got %08x\n",
+     "Expected ERROR_INVALID_PARAMETER or NTE_BAD_ALGID, got %08lx\n",
      GetLastError());
     ret = CryptSignCertificate(0, AT_SIGNATURE, 0, toBeSigned->pbData,
      toBeSigned->cbData, &algoID, NULL, NULL, &size);
     ok(!ret &&
      (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == NTE_BAD_ALGID),
-     "Expected ERROR_INVALID_PARAMETER or NTE_BAD_ALGID, got %08x\n",
+     "Expected ERROR_INVALID_PARAMETER or NTE_BAD_ALGID, got %08lx\n",
      GetLastError());
 
     /* No keys exist in the new CSP yet.. */
     ret = CryptSignCertificate(csp, AT_SIGNATURE, 0, toBeSigned->pbData,
      toBeSigned->cbData, &algoID, NULL, NULL, &size);
     ok(!ret && (GetLastError() == NTE_BAD_KEYSET || GetLastError() ==
-     NTE_NO_KEY), "Expected NTE_BAD_KEYSET or NTE_NO_KEY, got %08x\n",
+     NTE_NO_KEY), "Expected NTE_BAD_KEYSET or NTE_NO_KEY, got %08lx\n",
      GetLastError());
     ret = CryptGenKey(csp, AT_SIGNATURE, 0, &key);
-    ok(ret, "CryptGenKey failed: %08x\n", GetLastError());
+    ok(ret, "CryptGenKey failed: %08lx\n", GetLastError());
     if (ret)
     {
         ret = CryptSignCertificate(csp, AT_SIGNATURE, 0, toBeSigned->pbData,
          toBeSigned->cbData, &algoID, NULL, NULL, &size);
-        ok(ret, "CryptSignCertificate failed: %08x\n", GetLastError());
-        ok(size <= *sigLen, "Expected size <= %d, got %d\n", *sigLen, size);
+        ok(ret, "CryptSignCertificate failed: %08lx\n", GetLastError());
+        ok(size <= *sigLen, "Expected size <= %ld, got %ld\n", *sigLen, size);
         if (ret)
         {
             ret = CryptSignCertificate(csp, AT_SIGNATURE, 0, toBeSigned->pbData,
              toBeSigned->cbData, &algoID, NULL, sig, &size);
-            ok(ret, "CryptSignCertificate failed: %08x\n", GetLastError());
+            ok(ret, "CryptSignCertificate failed: %08lx\n", GetLastError());
             if (ret)
             {
                 *sigLen = size;
@@ -1967,15 +1967,15 @@ static void testVerifyCertSig(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned,
     }
     ret = CryptVerifyCertificateSignature(0, 0, NULL, 0, NULL);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     ret = CryptVerifyCertificateSignature(csp, 0, NULL, 0, NULL);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     ret = CryptVerifyCertificateSignature(csp, X509_ASN_ENCODING, NULL, 0,
      NULL);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD ||
      GetLastError() == OSS_BAD_ARG),
-     "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08lx\n", GetLastError());
     info.ToBeSigned.cbData = toBeSigned->cbData;
     info.ToBeSigned.pbData = toBeSigned->pbData;
     info.SignatureAlgorithm.pszObjId = (LPSTR)sigOID;
@@ -1985,7 +1985,7 @@ static void testVerifyCertSig(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned,
     info.Signature.cUnusedBits = 0;
     ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, X509_CERT, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &cert, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (cert)
     {
         PCERT_PUBLIC_KEY_INFO pubKeyInfo = NULL;
@@ -2005,12 +2005,12 @@ static void testVerifyCertSig(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned,
             ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE,
              X509_ASN_ENCODING, (LPSTR)sigOID, 0, NULL, pubKeyInfo,
              &pubKeySize);
-            ok(ret, "CryptExportKey failed: %08x\n", GetLastError());
+            ok(ret, "CryptExportKey failed: %08lx\n", GetLastError());
             if (ret)
             {
                 ret = CryptVerifyCertificateSignature(csp, X509_ASN_ENCODING,
                  cert, size, pubKeyInfo);
-                ok(ret, "CryptVerifyCertificateSignature failed: %08x\n",
+                ok(ret, "CryptVerifyCertificateSignature failed: %08lx\n",
                  GetLastError());
             }
             HeapFree(GetProcessHeap(), 0, pubKeyInfo);
@@ -2039,14 +2039,14 @@ static void testVerifyCertSigEx(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigne
     }
     ret = pCryptVerifyCertificateSignatureEx(0, 0, 0, NULL, 0, NULL, 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     ret = pCryptVerifyCertificateSignatureEx(csp, 0, 0, NULL, 0, NULL, 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING, 0, NULL, 0,
      NULL, 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* This crashes
     ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING,
      CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, NULL, 0, NULL, 0, NULL);
@@ -2060,7 +2060,7 @@ static void testVerifyCertSigEx(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigne
     info.Signature.cUnusedBits = 0;
     ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, X509_CERT, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &cert, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (cert)
     {
         CRYPT_DATA_BLOB certBlob = { 0, NULL };
@@ -2069,7 +2069,7 @@ static void testVerifyCertSigEx(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigne
         ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING,
          CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, 0, NULL, 0, NULL);
         ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD,
-         "Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
+         "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
         certBlob.cbData = 1;
         certBlob.pbData = (void *)0xdeadbeef;
         ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING,
@@ -2077,7 +2077,7 @@ static void testVerifyCertSigEx(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigne
         ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION ||
                     GetLastError() == CRYPT_E_ASN1_EOD /* Win9x */ ||
                     GetLastError() == CRYPT_E_ASN1_BADTAG /* Win98 */),
-         "Expected STATUS_ACCESS_VIOLATION, CRYPT_E_ASN1_EOD, OR CRYPT_E_ASN1_BADTAG, got %08x\n",
+         "Expected STATUS_ACCESS_VIOLATION, CRYPT_E_ASN1_EOD, OR CRYPT_E_ASN1_BADTAG, got %08lx\n",
          GetLastError());
 
         certBlob.cbData = size;
@@ -2085,12 +2085,12 @@ static void testVerifyCertSigEx(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigne
         ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING,
          CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob, 0, NULL, 0, NULL);
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
         ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING,
          CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob,
          CRYPT_VERIFY_CERT_SIGN_ISSUER_NULL, NULL, 0, NULL);
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
         /* This crashes
         ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING,
          CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob,
@@ -2103,13 +2103,13 @@ static void testVerifyCertSigEx(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigne
         {
             ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE,
              X509_ASN_ENCODING, (LPSTR)sigOID, 0, NULL, pubKeyInfo, &size);
-            ok(ret, "CryptExportKey failed: %08x\n", GetLastError());
+            ok(ret, "CryptExportKey failed: %08lx\n", GetLastError());
             if (ret)
             {
                 ret = pCryptVerifyCertificateSignatureEx(csp, X509_ASN_ENCODING,
                  CRYPT_VERIFY_CERT_SIGN_SUBJECT_BLOB, &certBlob,
                  CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY, pubKeyInfo, 0, NULL);
-                ok(ret, "CryptVerifyCertificateSignatureEx failed: %08x\n",
+                ok(ret, "CryptVerifyCertificateSignatureEx failed: %08lx\n",
                  GetLastError());
             }
             HeapFree(GetProcessHeap(), 0, pubKeyInfo);
@@ -2133,7 +2133,7 @@ static void testCertSigs(void)
      CRYPT_DELETEKEYSET);
     ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL,
      CRYPT_NEWKEYSET);
-    ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError());
+    ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
 
     testSignCert(csp, &toBeSigned, szOID_RSA_SHA1RSA, sig, &sigSize);
     testVerifyCertSig(csp, &toBeSigned, szOID_RSA_SHA1RSA, sig, sigSize);
@@ -2142,7 +2142,7 @@ static void testCertSigs(void)
     CryptReleaseContext(csp, 0);
     ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL,
      CRYPT_DELETEKEYSET);
-    ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError());
+    ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
 }
 
 static const BYTE md5SignedEmptyCert[] = {
@@ -2178,22 +2178,22 @@ static void testSignAndEncodeCert(void)
     ret = CryptSignAndEncodeCertificate(0, 0, 0, NULL, NULL, &algID, NULL, NULL,
      &size);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING, NULL, NULL,
      &algID, NULL, NULL, &size);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     ret = CryptSignAndEncodeCertificate(0, 0, 0, X509_CERT_TO_BE_SIGNED, NULL,
      &algID, NULL, NULL, &size);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     /* Crashes on some win9x boxes */
     if (0)
     {
         ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING,
          X509_CERT_TO_BE_SIGNED, NULL, &algID, NULL, NULL, &size);
         ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
-         "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
+         "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
     }
     /* Crashes
     ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING,
@@ -2204,7 +2204,7 @@ static void testSignAndEncodeCert(void)
     ok(!ret &&
      (GetLastError() == NTE_BAD_ALGID ||
       GetLastError() == OSS_BAD_PTR), /* win9x */
-     "Expected NTE_BAD_ALGID, got %08x\n", GetLastError());
+     "Expected NTE_BAD_ALGID, got %08lx\n", GetLastError());
     algID.pszObjId = oid_rsa_md5rsa;
     ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING,
      X509_CERT_TO_BE_SIGNED, &info, &algID, NULL, NULL, &size);
@@ -2212,7 +2212,7 @@ static void testSignAndEncodeCert(void)
      (GetLastError() == ERROR_INVALID_PARAMETER ||
       GetLastError() == NTE_BAD_ALGID ||
       GetLastError() == OSS_BAD_PTR), /* Win9x */
-     "Expected ERROR_INVALID_PARAMETER or NTE_BAD_ALGID, got %08x\n",
+     "Expected ERROR_INVALID_PARAMETER or NTE_BAD_ALGID, got %08lx\n",
      GetLastError());
     algID.pszObjId = oid_rsa_md5;
     ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING,
@@ -2226,14 +2226,14 @@ static void testSignAndEncodeCert(void)
         {
             ret = CryptSignAndEncodeCertificate(0, 0, X509_ASN_ENCODING,
              X509_CERT_TO_BE_SIGNED, &info, &algID, NULL, buf, &size);
-            ok(ret, "CryptSignAndEncodeCertificate failed: %08x\n",
+            ok(ret, "CryptSignAndEncodeCertificate failed: %08lx\n",
              GetLastError());
             /* Tricky: because the NULL parameters may either be omitted or
              * included as an asn.1-encoded NULL (0x05,0x00), two different
              * values are allowed.
              */
             ok(size == sizeof(md5SignedEmptyCert) ||
-             size == sizeof(md5SignedEmptyCertNoNull), "Unexpected size %d\n",
+             size == sizeof(md5SignedEmptyCertNoNull), "Unexpected size %ld\n",
              size);
             if (size == sizeof(md5SignedEmptyCert))
                 ok(!memcmp(buf, md5SignedEmptyCert, size),
@@ -2276,19 +2276,19 @@ static void testCreateSelfSignCert(void)
      CRYPT_DELETEKEYSET);
     ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL,
      CRYPT_NEWKEYSET);
-    ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError());
+    ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
 
     context = pCertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL,
      NULL, NULL);
     ok(!context && GetLastError() == NTE_NO_KEY,
-     "Expected NTE_NO_KEY, got %08x\n", GetLastError());
+     "Expected NTE_NO_KEY, got %08lx\n", GetLastError());
     ret = CryptGenKey(csp, AT_SIGNATURE, 0, &key);
-    ok(ret, "CryptGenKey failed: %08x\n", GetLastError());
+    ok(ret, "CryptGenKey failed: %08lx\n", GetLastError());
     if (ret)
     {
         context = pCertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL,
          NULL, NULL);
-        ok(context != NULL, "CertCreateSelfSignCertificate failed: %08x\n",
+        ok(context != NULL, "CertCreateSelfSignCertificate failed: %08lx\n",
          GetLastError());
         if (context)
         {
@@ -2306,7 +2306,7 @@ static void testCreateSelfSignCert(void)
                 {
                     ret = CertGetCertificateContextProperty(context,
                      CERT_KEY_PROV_INFO_PROP_ID, pInfo, &size);
-                    ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
+                    ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
                      GetLastError());
                     if (ret)
                     {
@@ -2316,7 +2316,7 @@ static void testCreateSelfSignCert(void)
                         ok(!lstrcmpW(pInfo->pwszProvName, MS_DEF_PROV_W),
                          "Unexpected provider\n");
                         ok(pInfo->dwKeySpec == AT_SIGNATURE,
-                         "Expected AT_SIGNATURE, got %d\n", pInfo->dwKeySpec);
+                         "Expected AT_SIGNATURE, got %ld\n", pInfo->dwKeySpec);
                     }
                     HeapFree(GetProcessHeap(), 0, pInfo);
                 }
@@ -2331,16 +2331,16 @@ static void testCreateSelfSignCert(void)
     CryptReleaseContext(csp, 0);
     ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL,
      CRYPT_DELETEKEYSET);
-    ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError());
+    ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
 
     /* Do the same test with a CSP, AT_KEYEXCHANGE and key info */
     CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL,
      CRYPT_DELETEKEYSET);
     ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL,
      CRYPT_NEWKEYSET);
-    ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError());
+    ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
     ret = CryptGenKey(csp, AT_SIGNATURE, 0, &key);
-    ok(ret, "CryptGenKey failed: %08x\n", GetLastError());
+    ok(ret, "CryptGenKey failed: %08lx\n", GetLastError());
 
     memset(&info,0,sizeof(info));
     info.dwProvType = PROV_RSA_FULL;
@@ -2355,7 +2355,7 @@ static void testCreateSelfSignCert(void)
     if (context != NULL)
         CertFreeCertificateContext(context);
     else
-        ok(GetLastError() == NTE_NO_KEY, "expected NTE_NO_KEY, got %08x\n",
+        ok(GetLastError() == NTE_NO_KEY, "expected NTE_NO_KEY, got %08lx\n",
             GetLastError());
     /* Again, with a CSP, AT_SIGNATURE and key info */
     info.dwKeySpec = AT_SIGNATURE;
@@ -2363,7 +2363,7 @@ static void testCreateSelfSignCert(void)
     context = pCertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL,
         NULL, NULL);
     ok(context != NULL,
-        "CertCreateSelfSignCertificate failed: %08x\n", GetLastError());
+        "CertCreateSelfSignCertificate failed: %08lx\n", GetLastError());
     if (context)
     {
         DWORD size = 0;
@@ -2380,7 +2380,7 @@ static void testCreateSelfSignCert(void)
             {
                 ret = CertGetCertificateContextProperty(context,
                     CERT_KEY_PROV_INFO_PROP_ID, pInfo, &size);
-                ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
+                ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
                     GetLastError());
                 if (ret)
                 {
@@ -2390,7 +2390,7 @@ static void testCreateSelfSignCert(void)
                     ok(!lstrcmpW(pInfo->pwszProvName, MS_DEF_PROV_W),
                         "Unexpected provider\n");
                     ok(pInfo->dwKeySpec == AT_SIGNATURE,
-                        "Expected AT_SIGNATURE, got %d\n", pInfo->dwKeySpec);
+                        "Expected AT_SIGNATURE, got %ld\n", pInfo->dwKeySpec);
                 }
                 HeapFree(GetProcessHeap(), 0, pInfo);
             }
@@ -2403,13 +2403,13 @@ static void testCreateSelfSignCert(void)
     CryptReleaseContext(csp, 0);
     ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL,
      CRYPT_DELETEKEYSET);
-    ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError());
+    ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
 
     /* Do the same test with no CSP, AT_KEYEXCHANGE and key info */
     info.dwKeySpec = AT_KEYEXCHANGE;
     context = pCertCreateSelfSignCertificate(0, &name, 0, &info, NULL, NULL,
         NULL, NULL);
-    ok(context != NULL, "CertCreateSelfSignCertificate failed: %08x\n",
+    ok(context != NULL, "CertCreateSelfSignCertificate failed: %08lx\n",
         GetLastError());
     if (context)
     {
@@ -2427,7 +2427,7 @@ static void testCreateSelfSignCert(void)
             {
                 ret = CertGetCertificateContextProperty(context,
                     CERT_KEY_PROV_INFO_PROP_ID, pInfo, &size);
-                ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
+                ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
                     GetLastError());
                 if (ret)
                 {
@@ -2437,7 +2437,7 @@ static void testCreateSelfSignCert(void)
                     ok(!lstrcmpW(pInfo->pwszProvName, MS_DEF_PROV_W),
                         "Unexpected provider\n");
                     ok(pInfo->dwKeySpec == AT_KEYEXCHANGE,
-                        "Expected AT_KEYEXCHANGE, got %d\n", pInfo->dwKeySpec);
+                        "Expected AT_KEYEXCHANGE, got %ld\n", pInfo->dwKeySpec);
                 }
                 HeapFree(GetProcessHeap(), 0, pInfo);
             }
@@ -2454,14 +2454,14 @@ static void testCreateSelfSignCert(void)
      CRYPT_DELETEKEYSET);
     ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL,
      CRYPT_NEWKEYSET);
-    ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError());
+    ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
 
     context = pCertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL,
      NULL, NULL);
     ok(!context && GetLastError() == NTE_NO_KEY,
-     "Expected NTE_NO_KEY, got %08x\n", GetLastError());
+     "Expected NTE_NO_KEY, got %08lx\n", GetLastError());
     ret = CryptGenKey(csp, AT_KEYEXCHANGE, 0, &key);
-    ok(ret, "CryptGenKey failed: %08x\n", GetLastError());
+    ok(ret, "CryptGenKey failed: %08lx\n", GetLastError());
     CryptDestroyKey(key);
 
     memset(&info,0,sizeof(info));
@@ -2477,7 +2477,7 @@ static void testCreateSelfSignCert(void)
     if (context != NULL)
         CertFreeCertificateContext(context);
     else
-        ok(GetLastError() == NTE_NO_KEY, "expected NTE_NO_KEY, got %08x\n",
+        ok(GetLastError() == NTE_NO_KEY, "expected NTE_NO_KEY, got %08lx\n",
             GetLastError());
     /* Again, with a CSP, AT_KEYEXCHANGE and key info. This succeeds because the
      * CSP has an AT_KEYEXCHANGE key in it.
@@ -2487,7 +2487,7 @@ static void testCreateSelfSignCert(void)
     context = pCertCreateSelfSignCertificate(csp, &name, 0, &info, NULL, NULL,
         NULL, NULL);
     ok(context != NULL,
-        "CertCreateSelfSignCertificate failed: %08x\n", GetLastError());
+        "CertCreateSelfSignCertificate failed: %08lx\n", GetLastError());
     if (context)
     {
         DWORD size = 0;
@@ -2504,7 +2504,7 @@ static void testCreateSelfSignCert(void)
             {
                 ret = CertGetCertificateContextProperty(context,
                     CERT_KEY_PROV_INFO_PROP_ID, pInfo, &size);
-                ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
+                ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
                     GetLastError());
                 if (ret)
                 {
@@ -2514,7 +2514,7 @@ static void testCreateSelfSignCert(void)
                     ok(!lstrcmpW(pInfo->pwszProvName, MS_DEF_PROV_W),
                         "Unexpected provider\n");
                     ok(pInfo->dwKeySpec == AT_KEYEXCHANGE,
-                        "Expected AT_KEYEXCHANGE, got %d\n", pInfo->dwKeySpec);
+                        "Expected AT_KEYEXCHANGE, got %ld\n", pInfo->dwKeySpec);
                 }
                 HeapFree(GetProcessHeap(), 0, pInfo);
             }
@@ -2526,7 +2526,7 @@ static void testCreateSelfSignCert(void)
     CryptReleaseContext(csp, 0);
     ret = CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL,
      CRYPT_DELETEKEYSET);
-    ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError());
+    ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError());
 
 }
 
@@ -2566,7 +2566,7 @@ static void testIntendedKeyUsage(void)
     /* The unused bytes are filled with 0. */
     ret = CertGetIntendedKeyUsage(X509_ASN_ENCODING, &info, usage_bytes,
      sizeof(usage_bytes));
-    ok(ret, "CertGetIntendedKeyUsage failed: %08x\n", GetLastError());
+    ok(ret, "CertGetIntendedKeyUsage failed: %08lx\n", GetLastError());
     ok(!memcmp(usage_bytes, expected_usage1, sizeof(expected_usage1)),
      "unexpected value\n");
     /* The usage bytes are copied in big-endian order. */
@@ -2574,7 +2574,7 @@ static void testIntendedKeyUsage(void)
     ext.Value.pbData = usage2;
     ret = CertGetIntendedKeyUsage(X509_ASN_ENCODING, &info, usage_bytes,
      sizeof(usage_bytes));
-    ok(ret, "CertGetIntendedKeyUsage failed: %08x\n", GetLastError());
+    ok(ret, "CertGetIntendedKeyUsage failed: %08lx\n", GetLastError());
     ok(!memcmp(usage_bytes, expected_usage2, sizeof(expected_usage2)),
      "unexpected value\n");
 }
@@ -2591,15 +2591,15 @@ static void testKeyUsage(void)
     /* Test base cases */
     ret = CertGetEnhancedKeyUsage(NULL, 0, NULL, NULL);
     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-     "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
+     "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
     size = 1;
     ret = CertGetEnhancedKeyUsage(NULL, 0, NULL, &size);
     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-     "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
+     "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
     size = 0;
     ret = CertGetEnhancedKeyUsage(NULL, 0, NULL, &size);
     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-     "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
+     "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
     /* These crash
     ret = CertSetEnhancedKeyUsage(NULL, NULL);
     usage.cUsageIdentifier = 0;
@@ -2608,7 +2608,7 @@ static void testKeyUsage(void)
     /* Test with a cert with no enhanced key usage extension */
     context = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
      sizeof(bigCert));
-    ok(context != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
     if (context)
     {
@@ -2618,7 +2618,7 @@ static void testKeyUsage(void)
 
         ret = CertGetEnhancedKeyUsage(context, 0, NULL, NULL);
         ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-         "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
+         "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
         size = 1;
         ret = CertGetEnhancedKeyUsage(context, 0, NULL, &size);
         if (ret)
@@ -2628,11 +2628,11 @@ static void testKeyUsage(void)
              * usage set for this cert (which implies it's valid for all uses.)
              */
             ok(GetLastError() == CRYPT_E_NOT_FOUND,
-             "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
-            ok(size == sizeof(CERT_ENHKEY_USAGE), "Wrong size %d\n", size);
+             "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
+            ok(size == sizeof(CERT_ENHKEY_USAGE), "Wrong size %ld\n", size);
             ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
-            ok(ret, "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
-            ok(pUsage->cUsageIdentifier == 0, "Expected 0 usages, got %d\n",
+            ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
+            ok(pUsage->cUsageIdentifier == 0, "Expected 0 usages, got %ld\n",
              pUsage->cUsageIdentifier);
         }
         else
@@ -2641,18 +2641,18 @@ static void testKeyUsage(void)
              * CRYPT_E_NOT_FOUND.
              */
             ok(GetLastError() == CRYPT_E_NOT_FOUND,
-             "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+             "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
         }
         /* I can add a usage identifier when no key usage has been set */
         ret = CertAddEnhancedKeyUsageIdentifier(context, oid);
-        ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08x\n",
+        ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08lx\n",
          GetLastError());
         size = sizeof(buf);
         ret = CertGetEnhancedKeyUsage(context,
          CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG, pUsage, &size);
         ok(ret && GetLastError() == 0,
-         "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
-        ok(pUsage->cUsageIdentifier == 1, "Expected 1 usage, got %d\n",
+         "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
+        ok(pUsage->cUsageIdentifier == 1, "Expected 1 usage, got %ld\n",
          pUsage->cUsageIdentifier);
         if (pUsage->cUsageIdentifier)
             ok(!strcmp(pUsage->rgpszUsageIdentifier[0], oid),
@@ -2660,35 +2660,35 @@ static void testKeyUsage(void)
         /* Now set an empty key usage */
         pUsage->cUsageIdentifier = 0;
         ret = CertSetEnhancedKeyUsage(context, pUsage);
-        ok(ret, "CertSetEnhancedKeyUsage failed: %08x\n", GetLastError());
+        ok(ret, "CertSetEnhancedKeyUsage failed: %08lx\n", GetLastError());
         /* Shouldn't find it in the cert */
         size = sizeof(buf);
         ret = CertGetEnhancedKeyUsage(context,
          CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG, pUsage, &size);
         ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
-         "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+         "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
         /* Should find it as an extended property */
         ret = CertGetEnhancedKeyUsage(context,
          CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG, pUsage, &size);
         ok(ret && GetLastError() == 0,
-         "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
-        ok(pUsage->cUsageIdentifier == 0, "Expected 0 usages, got %d\n",
+         "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
+        ok(pUsage->cUsageIdentifier == 0, "Expected 0 usages, got %ld\n",
          pUsage->cUsageIdentifier);
         /* Should find it as either */
         ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
         ok(ret && GetLastError() == 0,
-         "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
-        ok(pUsage->cUsageIdentifier == 0, "Expected 0 usages, got %d\n",
+         "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
+        ok(pUsage->cUsageIdentifier == 0, "Expected 0 usages, got %ld\n",
          pUsage->cUsageIdentifier);
         /* Add a usage identifier */
         ret = CertAddEnhancedKeyUsageIdentifier(context, oid);
-        ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08x\n",
+        ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08lx\n",
          GetLastError());
         size = sizeof(buf);
         ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
         ok(ret && GetLastError() == 0,
-         "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
-        ok(pUsage->cUsageIdentifier == 1, "Expected 1 identifier, got %d\n",
+         "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
+        ok(pUsage->cUsageIdentifier == 1, "Expected 1 identifier, got %ld\n",
          pUsage->cUsageIdentifier);
         if (pUsage->cUsageIdentifier)
             ok(!strcmp(pUsage->rgpszUsageIdentifier[0], oid),
@@ -2697,14 +2697,14 @@ static void testKeyUsage(void)
          * a duplicate usage identifier on versions prior to Vista
          */
         ret = CertAddEnhancedKeyUsageIdentifier(context, oid);
-        ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08x\n",
+        ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08lx\n",
          GetLastError());
         size = sizeof(buf);
         ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
         ok(ret && GetLastError() == 0,
-         "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
+         "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
         ok(pUsage->cUsageIdentifier == 1 || pUsage->cUsageIdentifier == 2,
-         "Expected 1 or 2 identifiers, got %d\n", pUsage->cUsageIdentifier);
+         "Expected 1 or 2 identifiers, got %ld\n", pUsage->cUsageIdentifier);
         if (pUsage->cUsageIdentifier)
             ok(!strcmp(pUsage->rgpszUsageIdentifier[0], oid),
              "Expected %s, got %s\n", oid, pUsage->rgpszUsageIdentifier[0]);
@@ -2713,21 +2713,21 @@ static void testKeyUsage(void)
              "Expected %s, got %s\n", oid, pUsage->rgpszUsageIdentifier[1]);
         /* Now set a NULL extended property--this deletes the property. */
         ret = CertSetEnhancedKeyUsage(context, NULL);
-        ok(ret, "CertSetEnhancedKeyUsage failed: %08x\n", GetLastError());
+        ok(ret, "CertSetEnhancedKeyUsage failed: %08lx\n", GetLastError());
         SetLastError(0xbaadcafe);
         size = sizeof(buf);
         ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
         ok(ret || broken(!ret && GetLastError() == CRYPT_E_NOT_FOUND /* NT4 */),
-	 "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
+	 "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
         ok(GetLastError() == CRYPT_E_NOT_FOUND,
-         "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+         "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
 
         CertFreeCertificateContext(context);
     }
     /* Now test with a cert with an enhanced key usage extension */
     context = CertCreateCertificateContext(X509_ASN_ENCODING, certWithUsage,
      sizeof(certWithUsage));
-    ok(context != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
     if (context)
     {
@@ -2739,7 +2739,7 @@ static void testKeyUsage(void)
          */
         ret = CertGetEnhancedKeyUsage(context,
          CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG, NULL, &bufSize);
-        ok(ret, "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
+        ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
         buf = HeapAlloc(GetProcessHeap(), 0, bufSize);
         if (buf)
         {
@@ -2750,8 +2750,8 @@ static void testKeyUsage(void)
             ret = CertGetEnhancedKeyUsage(context,
              CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG, pUsage, &size);
             ok(ret && GetLastError() == 0,
-             "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
-            ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %d\n",
+             "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
+            ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %ld\n",
              pUsage->cUsageIdentifier);
             for (i = 0; i < pUsage->cUsageIdentifier; i++)
                 ok(!strcmp(pUsage->rgpszUsageIdentifier[i], keyUsages[i]),
@@ -2760,7 +2760,7 @@ static void testKeyUsage(void)
             HeapFree(GetProcessHeap(), 0, buf);
         }
         ret = CertGetEnhancedKeyUsage(context, 0, NULL, &bufSize);
-        ok(ret, "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
+        ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
         buf = HeapAlloc(GetProcessHeap(), 0, bufSize);
         if (buf)
         {
@@ -2774,8 +2774,8 @@ static void testKeyUsage(void)
              * count is positive.  I don't enforce that here.
              */
             ok(ret,
-             "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
-            ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %d\n",
+             "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
+            ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %ld\n",
              pUsage->cUsageIdentifier);
             for (i = 0; i < pUsage->cUsageIdentifier; i++)
                 ok(!strcmp(pUsage->rgpszUsageIdentifier[i], keyUsages[i]),
@@ -2787,13 +2787,13 @@ static void testKeyUsage(void)
         ret = CertGetEnhancedKeyUsage(context,
          CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG, NULL, &size);
         ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
-         "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+         "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
         /* Adding a usage identifier overrides the cert's usage!? */
         ret = CertAddEnhancedKeyUsageIdentifier(context, szOID_RSA_RSA);
-        ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08x\n",
+        ok(ret, "CertAddEnhancedKeyUsageIdentifier failed: %08lx\n",
          GetLastError());
         ret = CertGetEnhancedKeyUsage(context, 0, NULL, &bufSize);
-        ok(ret, "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
+        ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
         buf = HeapAlloc(GetProcessHeap(), 0, bufSize);
         if (buf)
         {
@@ -2803,8 +2803,8 @@ static void testKeyUsage(void)
             size = bufSize;
             ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
             ok(ret,
-             "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
-            ok(pUsage->cUsageIdentifier == 1, "Expected 1 usage, got %d\n",
+             "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
+            ok(pUsage->cUsageIdentifier == 1, "Expected 1 usage, got %ld\n",
              pUsage->cUsageIdentifier);
             ok(!strcmp(pUsage->rgpszUsageIdentifier[0], szOID_RSA_RSA),
              "Expected %s, got %s\n", szOID_RSA_RSA,
@@ -2814,7 +2814,7 @@ static void testKeyUsage(void)
         /* But querying the cert directly returns its usage */
         ret = CertGetEnhancedKeyUsage(context,
          CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG, NULL, &bufSize);
-        ok(ret, "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
+        ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
         buf = HeapAlloc(GetProcessHeap(), 0, bufSize);
         if (buf)
         {
@@ -2824,8 +2824,8 @@ static void testKeyUsage(void)
             ret = CertGetEnhancedKeyUsage(context,
              CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG, pUsage, &size);
             ok(ret,
-             "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
-            ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %d\n",
+             "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
+            ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %ld\n",
              pUsage->cUsageIdentifier);
             for (i = 0; i < pUsage->cUsageIdentifier; i++)
                 ok(!strcmp(pUsage->rgpszUsageIdentifier[i], keyUsages[i]),
@@ -2837,9 +2837,9 @@ static void testKeyUsage(void)
          * results in the cert's key usage being found.
          */
         ret = CertRemoveEnhancedKeyUsageIdentifier(context, szOID_RSA_RSA);
-        ok(ret, "CertRemoveEnhancedKeyUsage failed: %08x\n", GetLastError());
+        ok(ret, "CertRemoveEnhancedKeyUsage failed: %08lx\n", GetLastError());
         ret = CertGetEnhancedKeyUsage(context, 0, NULL, &bufSize);
-        ok(ret, "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
+        ok(ret, "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
         buf = HeapAlloc(GetProcessHeap(), 0, bufSize);
         if (buf)
         {
@@ -2849,8 +2849,8 @@ static void testKeyUsage(void)
             size = bufSize;
             ret = CertGetEnhancedKeyUsage(context, 0, pUsage, &size);
             ok(ret,
-             "CertGetEnhancedKeyUsage failed: %08x\n", GetLastError());
-            ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %d\n",
+             "CertGetEnhancedKeyUsage failed: %08lx\n", GetLastError());
+            ok(pUsage->cUsageIdentifier == 3, "Expected 3 usages, got %ld\n",
              pUsage->cUsageIdentifier);
             for (i = 0; i < pUsage->cUsageIdentifier; i++)
                 ok(!strcmp(pUsage->rgpszUsageIdentifier[i], keyUsages[i]),
@@ -2906,9 +2906,9 @@ static void testGetValidUsages(void)
     size = numOIDs = 0xdeadbeef;
     SetLastError(0xdeadbeef);
     ret = pCertGetValidUsages(1, &contexts[0], &numOIDs, NULL, &size);
-    ok(ret, "CertGetValidUsages failed: %d\n", GetLastError());
+    ok(ret, "CertGetValidUsages failed: %ld\n", GetLastError());
     ok(numOIDs == -1, "Expected -1, got %d\n", numOIDs);
-    ok(size == 0, "Expected size 0, got %d\n", size);
+    ok(size == 0, "Expected size 0, got %ld\n", size);
     contexts[0] = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
      sizeof(bigCert));
     contexts[1] = CertCreateCertificateContext(X509_ASN_ENCODING, certWithUsage,
@@ -2917,16 +2917,16 @@ static void testGetValidUsages(void)
      cert2WithUsage, sizeof(cert2WithUsage));
     size = numOIDs = 0xdeadbeef;
     ret = pCertGetValidUsages(0, NULL, &numOIDs, NULL, &size);
-    ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError());
+    ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
     ok(numOIDs == -1, "Expected -1, got %d\n", numOIDs);
-    ok(size == 0, "Expected size 0, got %d\n", size);
+    ok(size == 0, "Expected size 0, got %ld\n", size);
     size = numOIDs = 0xdeadbeef;
     ret = pCertGetValidUsages(1, contexts, &numOIDs, NULL, &size);
-    ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError());
+    ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
     ok(numOIDs == -1, "Expected -1, got %d\n", numOIDs);
-    ok(size == 0, "Expected size 0, got %d\n", size);
+    ok(size == 0, "Expected size 0, got %ld\n", size);
     ret = pCertGetValidUsages(1, &contexts[1], &numOIDs, NULL, &size);
-    ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError());
+    ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
     ok(numOIDs == 3, "Expected 3, got %d\n", numOIDs);
     ok(size, "Expected non-zero size\n");
     oids = HeapAlloc(GetProcessHeap(), 0, size);
@@ -2938,9 +2938,9 @@ static void testGetValidUsages(void)
         SetLastError(0xdeadbeef);
         ret = pCertGetValidUsages(1, &contexts[1], &numOIDs, oids, &smallSize);
         ok(!ret && GetLastError() == ERROR_MORE_DATA,
-         "Expected ERROR_MORE_DATA, got %d\n", GetLastError());
+         "Expected ERROR_MORE_DATA, got %ld\n", GetLastError());
         ret = pCertGetValidUsages(1, &contexts[1], &numOIDs, oids, &size);
-        ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError());
+        ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
         for (i = 0; i < numOIDs; i++)
             ok(!lstrcmpA(oids[i], expectedOIDs[i]), "unexpected OID %s\n",
              oids[i]);
@@ -2953,7 +2953,7 @@ static void testGetValidUsages(void)
      */
     size = 0;
     ret = pCertGetValidUsages(2, contexts, &numOIDs, NULL, &size);
-    ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError());
+    ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
     ok(numOIDs == 3, "Expected 3, got %d\n", numOIDs);
     ok(size, "Expected non-zero size\n");
     oids = HeapAlloc(GetProcessHeap(), 0, size);
@@ -2962,7 +2962,7 @@ static void testGetValidUsages(void)
         int i;
 
         ret = pCertGetValidUsages(1, &contexts[1], &numOIDs, oids, &size);
-        ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError());
+        ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
         for (i = 0; i < numOIDs; i++)
             ok(!lstrcmpA(oids[i], expectedOIDs[i]), "unexpected OID %s\n",
              oids[i]);
@@ -2971,7 +2971,7 @@ static void testGetValidUsages(void)
     numOIDs = 0xdeadbeef;
     size = 0;
     ret = pCertGetValidUsages(1, &contexts[2], &numOIDs, NULL, &size);
-    ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError());
+    ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
     ok(numOIDs == 2, "Expected 2, got %d\n", numOIDs);
     ok(size, "Expected non-zero size\n");
     oids = HeapAlloc(GetProcessHeap(), 0, size);
@@ -2980,7 +2980,7 @@ static void testGetValidUsages(void)
         int i;
 
         ret = pCertGetValidUsages(1, &contexts[2], &numOIDs, oids, &size);
-        ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError());
+        ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
         for (i = 0; i < numOIDs; i++)
             ok(!lstrcmpA(oids[i], expectedOIDs2[i]), "unexpected OID %s\n",
              oids[i]);
@@ -2989,7 +2989,7 @@ static void testGetValidUsages(void)
     numOIDs = 0xdeadbeef;
     size = 0;
     ret = pCertGetValidUsages(3, contexts, &numOIDs, NULL, &size);
-    ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError());
+    ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
     ok(numOIDs == 2, "Expected 2, got %d\n", numOIDs);
     ok(size, "Expected non-zero size\n");
     oids = HeapAlloc(GetProcessHeap(), 0, size);
@@ -2998,7 +2998,7 @@ static void testGetValidUsages(void)
         int i;
 
         ret = pCertGetValidUsages(3, contexts, &numOIDs, oids, &size);
-        ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError());
+        ok(ret, "CertGetValidUsages failed: %08lx\n", GetLastError());
         for (i = 0; i < numOIDs; i++)
             ok(!lstrcmpA(oids[i], expectedOIDs2[i]), "unexpected OID %s\n",
              oids[i]);
@@ -3047,12 +3047,12 @@ static void testCompareCertName(void)
     blob1.pbData = emptyCert;
     blob1.cbData = sizeof(emptyCert);
     ret = CertCompareCertificateName(0, &blob1, &blob1);
-    ok(ret, "CertCompareCertificateName failed: %08x\n", GetLastError());
+    ok(ret, "CertCompareCertificateName failed: %08lx\n", GetLastError());
     /* It doesn't have to be a valid encoded name.. */
     blob1.pbData = bogus;
     blob1.cbData = sizeof(bogus);
     ret = CertCompareCertificateName(0, &blob1, &blob1);
-    ok(ret, "CertCompareCertificateName failed: %08x\n", GetLastError());
+    ok(ret, "CertCompareCertificateName failed: %08lx\n", GetLastError());
     /* Leading zeroes matter.. */
     blob2.pbData = bogusPrime;
     blob2.cbData = sizeof(bogusPrime);
@@ -3130,41 +3130,41 @@ static void testIsRDNAttrsInCertificateName(void)
     SetLastError(0xdeadbeef);
     ret = CertIsRDNAttrsInCertificateName(0, 0, &name, NULL);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn);
-    ok(ret, "CertIsRDNAttrsInCertificateName failed: %08x\n", GetLastError());
+    ok(ret, "CertIsRDNAttrsInCertificateName failed: %08lx\n", GetLastError());
     attr[0].pszObjId = oid_1_2_3;
     rdn.rgRDNAttr = attr;
     rdn.cRDNAttr = 1;
     SetLastError(0xdeadbeef);
     ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn);
     ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
-     "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
     attr[0].pszObjId = oid_common_name;
     attr[0].dwValueType = CERT_RDN_PRINTABLE_STRING;
     attr[0].Value.cbData = strlen(juan);
     attr[0].Value.pbData = (BYTE *)juan;
     ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn);
-    ok(ret, "CertIsRDNAttrsInCertificateName failed: %08x\n", GetLastError());
+    ok(ret, "CertIsRDNAttrsInCertificateName failed: %08lx\n", GetLastError());
     /* Again, spaces are not removed for name comparison. */
     attr[0].Value.cbData = strlen(juan_with_leading_space);
     attr[0].Value.pbData = (BYTE *)juan_with_leading_space;
     SetLastError(0xdeadbeef);
     ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn);
     ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
-     "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
     attr[0].Value.cbData = strlen(juan_with_intermediate_space);
     attr[0].Value.pbData = (BYTE *)juan_with_intermediate_space;
     SetLastError(0xdeadbeef);
     ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn);
     ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
-     "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
     attr[0].Value.cbData = strlen(juan_with_trailing_space);
     attr[0].Value.pbData = (BYTE *)juan_with_trailing_space;
     SetLastError(0xdeadbeef);
     ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn);
     ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
-     "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
     /* The lower case name isn't matched unless a case insensitive match is
      * specified.
      */
@@ -3173,12 +3173,12 @@ static void testIsRDNAttrsInCertificateName(void)
     SetLastError(0xdeadbeef);
     ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn);
     ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
-     "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
     ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING,
      CERT_CASE_INSENSITIVE_IS_RDN_ATTRS_FLAG, &name, &rdn);
     ok(ret ||
      broken(!ret && GetLastError() == CRYPT_E_NO_MATCH), /* Older crypt32 */
-     "CertIsRDNAttrsInCertificateName failed: %08x\n", GetLastError());
+     "CertIsRDNAttrsInCertificateName failed: %08lx\n", GetLastError());
     /* The values don't match unless they have the same RDN type */
     attr[0].dwValueType = CERT_RDN_UNICODE_STRING;
     attr[0].Value.cbData = lstrlenW(juanW) * sizeof(WCHAR);
@@ -3186,19 +3186,19 @@ static void testIsRDNAttrsInCertificateName(void)
     SetLastError(0xdeadbeef);
     ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn);
     ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
-     "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING,
      CERT_UNICODE_IS_RDN_ATTRS_FLAG, &name, &rdn);
     ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
-     "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
     attr[0].dwValueType = CERT_RDN_IA5_STRING;
     attr[0].Value.cbData = strlen(juan);
     attr[0].Value.pbData = (BYTE *)juan;
     SetLastError(0xdeadbeef);
     ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn);
     ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
-     "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
     /* All attributes must be present */
     attr[0].dwValueType = CERT_RDN_PRINTABLE_STRING;
     attr[0].Value.cbData = strlen(juan);
@@ -3211,18 +3211,18 @@ static void testIsRDNAttrsInCertificateName(void)
     SetLastError(0xdeadbeef);
     ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn);
     ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
-     "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
     /* Order also matters */
     name.pbData = cnThenO;
     name.cbData = sizeof(cnThenO);
     ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn);
-    ok(ret, "CertIsRDNAttrsInCertificateName failed: %08x\n", GetLastError());
+    ok(ret, "CertIsRDNAttrsInCertificateName failed: %08lx\n", GetLastError());
     name.pbData = oThenCN;
     name.cbData = sizeof(oThenCN);
     SetLastError(0xdeadbeef);
     ret = CertIsRDNAttrsInCertificateName(X509_ASN_ENCODING, 0, &name, &rdn);
     ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
-     "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
 }
 
 static BYTE int1[] = { 0x88, 0xff, 0xff, 0xff };
@@ -3255,7 +3255,7 @@ static void testCompareIntegerBlob(void)
     {
         ret = CertCompareIntegerBlob(&intBlobs[i].blob1, &intBlobs[i].blob2);
         ok(ret == intBlobs[i].areEqual,
-         "%d: expected blobs %s compare\n", i, intBlobs[i].areEqual ?
+         "%ld: expected blobs %s compare\n", i, intBlobs[i].areEqual ?
          "to" : "not to");
     }
 }
@@ -3282,23 +3282,23 @@ static void testComparePublicKeyInfo(void)
      */
     /* Empty public keys compare */
     ret = CertComparePublicKeyInfo(0, &info1, &info2);
-    ok(ret, "CertComparePublicKeyInfo failed: %08x\n", GetLastError());
+    ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError());
     ret = CertComparePublicKeyInfo(X509_ASN_ENCODING, &info1, &info2);
-    ok(ret, "CertComparePublicKeyInfo failed: %08x\n", GetLastError());
+    ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError());
 
     /* Different OIDs appear to compare */
     info1.Algorithm.pszObjId = oid_rsa_rsa;
     info2.Algorithm.pszObjId = oid_rsa_sha1rsa;
     ret = CertComparePublicKeyInfo(0, &info1, &info2);
-    ok(ret, "CertComparePublicKeyInfo failed: %08x\n", GetLastError());
+    ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError());
     ret = CertComparePublicKeyInfo(X509_ASN_ENCODING, &info1, &info2);
-    ok(ret, "CertComparePublicKeyInfo failed: %08x\n", GetLastError());
+    ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError());
 
     info2.Algorithm.pszObjId = oid_x957_dsa;
     ret = CertComparePublicKeyInfo(0, &info1, &info2);
-    ok(ret, "CertComparePublicKeyInfo failed: %08x\n", GetLastError());
+    ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError());
     ret = CertComparePublicKeyInfo(X509_ASN_ENCODING, &info1, &info2);
-    ok(ret, "CertComparePublicKeyInfo failed: %08x\n", GetLastError());
+    ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError());
 
     info1.PublicKey.cbData = sizeof(bits1);
     info1.PublicKey.pbData = bits1;
@@ -3307,9 +3307,9 @@ static void testComparePublicKeyInfo(void)
     info2.PublicKey.pbData = bits1;
     info2.PublicKey.cUnusedBits = 0;
     ret = CertComparePublicKeyInfo(0, &info1, &info2);
-    ok(ret, "CertComparePublicKeyInfo failed: %08x\n", GetLastError());
+    ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError());
     ret = CertComparePublicKeyInfo(X509_ASN_ENCODING, &info1, &info2);
-    ok(ret, "CertComparePublicKeyInfo failed: %08x\n", GetLastError());
+    ok(ret, "CertComparePublicKeyInfo failed: %08lx\n", GetLastError());
 
     info2.Algorithm.pszObjId = oid_rsa_rsa;
     info1.PublicKey.cbData = sizeof(bits4);
@@ -3405,21 +3405,21 @@ static void testHashPublicKeyInfo(void)
      */
     ret = CryptHashPublicKeyInfo(0, 0, 0, 0, NULL, NULL, &len);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     /* Crashes on some win9x boxes */
     if (0)
     {
         ret = CryptHashPublicKeyInfo(0, 0, 0, X509_ASN_ENCODING, NULL, NULL, &len);
         ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
-         "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
+         "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
     }
     ret = CryptHashPublicKeyInfo(0, 0, 0, X509_ASN_ENCODING, &info, NULL, &len);
     ok(ret ||
      broken(!ret), /* win9x */
-     "CryptHashPublicKeyInfo failed: %08x\n", GetLastError());
+     "CryptHashPublicKeyInfo failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(len == 16, "Expected hash size 16, got %d\n", len);
+        ok(len == 16, "Expected hash size 16, got %ld\n", len);
         if (len == 16)
         {
             static const BYTE emptyHash[] = { 0xb8,0x51,0x3a,0x31,0x0e,0x9f,0x40,
@@ -3428,7 +3428,7 @@ static void testHashPublicKeyInfo(void)
 
             ret = CryptHashPublicKeyInfo(0, 0, 0, X509_ASN_ENCODING, &info, buf,
              &len);
-            ok(ret, "CryptHashPublicKeyInfo failed: %08x\n", GetLastError());
+            ok(ret, "CryptHashPublicKeyInfo failed: %08lx\n", GetLastError());
             ok(!memcmp(buf, emptyHash, len), "Unexpected hash\n");
         }
     }
@@ -3451,13 +3451,13 @@ static void testHashToBeSigned(void)
     SetLastError(0xdeadbeef);
     ret = CryptHashToBeSigned(0, 0, NULL, 0, NULL, &size);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+     "expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, NULL, 0, NULL, &size);
     ok(!ret &&
      (GetLastError() == CRYPT_E_ASN1_EOD ||
       GetLastError() == OSS_BAD_ARG), /* win9x */
-     "expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
+     "expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
     /* Can't sign anything:  has to be asn.1 encoded, at least */
     SetLastError(0xdeadbeef);
     ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, int1, sizeof(int1),
@@ -3465,7 +3465,7 @@ static void testHashToBeSigned(void)
     ok(!ret &&
      (GetLastError() == CRYPT_E_ASN1_BADTAG ||
       GetLastError() == OSS_MORE_INPUT), /* win9x */
-     "expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
+     "expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
     /* Can't be empty, either */
     SetLastError(0xdeadbeef);
     ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, emptyCert,
@@ -3473,22 +3473,22 @@ static void testHashToBeSigned(void)
     ok(!ret &&
      (GetLastError() == CRYPT_E_ASN1_CORRUPT ||
       GetLastError() == OSS_DATA_ERROR), /* win9x */
-     "expected CRYPT_E_ASN1_CORRUPT, got %08x\n", GetLastError());
+     "expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError());
     /* Signing a cert works */
     ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, md5SignedEmptyCert,
      sizeof(md5SignedEmptyCert), NULL, &size);
     ok(ret ||
      broken(!ret), /* win9x */
-     "CryptHashToBeSigned failed: %08x\n", GetLastError());
+     "CryptHashToBeSigned failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(md5SignedEmptyCertHash), "unexpected size %d\n", size);
+        ok(size == sizeof(md5SignedEmptyCertHash), "unexpected size %ld\n", size);
     }
 
     ret = CryptHashToBeSigned(0, X509_ASN_ENCODING, md5SignedEmptyCert,
      sizeof(md5SignedEmptyCert), hash, &size);
     ok(ret || broken(!ret && GetLastError() == NTE_BAD_ALGID) /* NT4 */,
-     "CryptHashToBeSigned failed: %08x\n", GetLastError());
+     "CryptHashToBeSigned failed: %08lx\n", GetLastError());
 
     ok(!memcmp(hash, md5SignedEmptyCertHash, size), "unexpected value\n");
 }
@@ -3537,45 +3537,45 @@ static void testVerifySubjectCert(void)
      */
     flags = 0;
     ret = CertVerifySubjectCertificateContext(NULL, NULL, &flags);
-    ok(ret, "CertVerifySubjectCertificateContext failed; %08x\n",
+    ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n",
      GetLastError());
     flags = CERT_STORE_NO_CRL_FLAG;
     ret = CertVerifySubjectCertificateContext(NULL, NULL, &flags);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
 
     flags = 0;
     context1 = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
      sizeof(bigCert));
     ret = CertVerifySubjectCertificateContext(NULL, context1, &flags);
-    ok(ret, "CertVerifySubjectCertificateContext failed; %08x\n",
+    ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n",
      GetLastError());
     ret = CertVerifySubjectCertificateContext(context1, NULL, &flags);
-    ok(ret, "CertVerifySubjectCertificateContext failed; %08x\n",
+    ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n",
      GetLastError());
     ret = CertVerifySubjectCertificateContext(context1, context1, &flags);
-    ok(ret, "CertVerifySubjectCertificateContext failed; %08x\n",
+    ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n",
      GetLastError());
 
     context2 = CertCreateCertificateContext(X509_ASN_ENCODING,
      bigCertWithDifferentSubject, sizeof(bigCertWithDifferentSubject));
     SetLastError(0xdeadbeef);
     ret = CertVerifySubjectCertificateContext(context1, context2, &flags);
-    ok(ret, "CertVerifySubjectCertificateContext failed; %08x\n",
+    ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n",
      GetLastError());
     flags = CERT_STORE_REVOCATION_FLAG;
     ret = CertVerifySubjectCertificateContext(context1, context2, &flags);
-    ok(ret, "CertVerifySubjectCertificateContext failed; %08x\n",
+    ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n",
      GetLastError());
     ok(flags == (CERT_STORE_REVOCATION_FLAG | CERT_STORE_NO_CRL_FLAG),
-     "Expected CERT_STORE_REVOCATION_FLAG | CERT_STORE_NO_CRL_FLAG, got %08x\n",
+     "Expected CERT_STORE_REVOCATION_FLAG | CERT_STORE_NO_CRL_FLAG, got %08lx\n",
      flags);
     flags = CERT_STORE_SIGNATURE_FLAG;
     ret = CertVerifySubjectCertificateContext(context1, context2, &flags);
-    ok(ret, "CertVerifySubjectCertificateContext failed; %08x\n",
+    ok(ret, "CertVerifySubjectCertificateContext failed; %08lx\n",
      GetLastError());
     ok(flags == CERT_STORE_SIGNATURE_FLAG,
-     "Expected CERT_STORE_SIGNATURE_FLAG, got %08x\n", flags);
+     "Expected CERT_STORE_SIGNATURE_FLAG, got %08lx\n", flags);
     CertFreeCertificateContext(context2);
 
     CertFreeCertificateContext(context1);
@@ -3681,24 +3681,24 @@ static void testVerifyRevocation(void)
     SetLastError(0xdeadbeef);
     ret = CertVerifyRevocation(0, 0, 0, NULL, 0, NULL, &status);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     status.cbSize = sizeof(status);
     ret = CertVerifyRevocation(0, 0, 0, NULL, 0, NULL, &status);
-    ok(ret, "CertVerifyRevocation failed: %08x\n", GetLastError());
+    ok(ret, "CertVerifyRevocation failed: %08lx\n", GetLastError());
     ret = CertVerifyRevocation(0, 2, 0, NULL, 0, NULL, &status);
-    ok(ret, "CertVerifyRevocation failed: %08x\n", GetLastError());
+    ok(ret, "CertVerifyRevocation failed: %08lx\n", GetLastError());
     ret = CertVerifyRevocation(2, 0, 0, NULL, 0, NULL, &status);
-    ok(ret, "CertVerifyRevocation failed: %08x\n", GetLastError());
+    ok(ret, "CertVerifyRevocation failed: %08lx\n", GetLastError());
     certs[0] = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
      sizeof(bigCert));
     SetLastError(0xdeadbeef);
     ret = CertVerifyRevocation(0, 0, 1, (void **)certs, 0, NULL, &status);
     ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_DLL,
-     "Expected CRYPT_E_NO_REVOCATION_DLL, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NO_REVOCATION_DLL, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CertVerifyRevocation(0, 2, 1, (void **)certs, 0, NULL, &status);
     ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_DLL,
-     "Expected CRYPT_E_NO_REVOCATION_DLL, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NO_REVOCATION_DLL, got %08lx\n", GetLastError());
 
     CertFreeCertificateContext(certs[0]);
 
@@ -3716,36 +3716,36 @@ static void testVerifyRevocation(void)
         return;
     }
     ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_CHECK,
-     "expected CRYPT_E_NO_REVOCATION_CHECK, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", GetLastError());
     ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK,
-     "expected CRYPT_E_NO_REVOCATION_CHECK, got %08x\n", status.dwError);
-    ok(status.dwIndex == 0, "expected index 0, got %d\n", status.dwIndex);
+     "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", status.dwError);
+    ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex);
     /* Neither can the end cert */
     SetLastError(0xdeadbeef);
     ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE,
      1, (void **)&certs[1], 0, NULL, &status);
     ok(!ret && (GetLastError() == CRYPT_E_NO_REVOCATION_CHECK /* Win9x */ ||
      GetLastError() == CRYPT_E_REVOCATION_OFFLINE),
-     "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08x\n",
+     "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n",
      GetLastError());
     ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK /* Win9x */ ||
      status.dwError == CRYPT_E_REVOCATION_OFFLINE,
-     "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08x\n",
+     "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n",
      status.dwError);
-    ok(status.dwIndex == 0, "expected index 0, got %d\n", status.dwIndex);
+    ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex);
     /* Both certs together can't, either (they're not CRLs) */
     SetLastError(0xdeadbeef);
     ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE,
      2, (void **)certs, 0, NULL, &status);
     ok(!ret && (GetLastError() == CRYPT_E_NO_REVOCATION_CHECK ||
      GetLastError() == CRYPT_E_REVOCATION_OFFLINE /* WinME */),
-     "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08x\n",
+     "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n",
      GetLastError());
     ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK ||
      status.dwError == CRYPT_E_REVOCATION_OFFLINE /* WinME */,
-     "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08x\n",
+     "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n",
      status.dwError);
-    ok(status.dwIndex == 0, "expected index 0, got %d\n", status.dwIndex);
+    ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex);
     /* Now add a CRL to the hCrlStore */
     revPara.hCrlStore = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
@@ -3756,22 +3756,22 @@ static void testVerifyRevocation(void)
      2, (void **)certs, 0, &revPara, &status);
     ok(!ret && (GetLastError() == CRYPT_E_NO_REVOCATION_CHECK ||
      GetLastError() == CRYPT_E_REVOCATION_OFFLINE /* WinME */),
-     "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08x\n",
+     "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n",
      GetLastError());
     ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK ||
      status.dwError == CRYPT_E_REVOCATION_OFFLINE /* WinME */,
-     "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08x\n",
+     "expected CRYPT_E_NO_REVOCATION_CHECK or CRYPT_E_REVOCATION_OFFLINE, got %08lx\n",
      status.dwError);
-    ok(status.dwIndex == 0, "expected index 0, got %d\n", status.dwIndex);
+    ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex);
     /* Specifying CERT_VERIFY_REV_CHAIN_FLAG doesn't change things either */
     SetLastError(0xdeadbeef);
     ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE,
      2, (void **)certs, CERT_VERIFY_REV_CHAIN_FLAG, &revPara, &status);
     ok(!ret && GetLastError() == CRYPT_E_NO_REVOCATION_CHECK,
-     "expected CRYPT_E_NO_REVOCATION_CHECK, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", GetLastError());
     ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK,
-     "expected CRYPT_E_NO_REVOCATION_CHECK, got %08x\n", status.dwError);
-    ok(status.dwIndex == 0, "expected index 0, got %d\n", status.dwIndex);
+     "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", status.dwError);
+    ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex);
     /* Again, specifying the issuer cert: no change */
     revPara.pIssuerCert = certs[0];
     SetLastError(0xdeadbeef);
@@ -3782,11 +3782,11 @@ static void testVerifyRevocation(void)
      */
     ok(!ret && (GetLastError() == CRYPT_E_NO_REVOCATION_CHECK ||
      broken(GetLastError() == CRYPT_E_REVOKED /* Win2k */)),
-     "expected CRYPT_E_NO_REVOCATION_CHECK, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", GetLastError());
     ok(status.dwError == CRYPT_E_NO_REVOCATION_CHECK ||
      broken(status.dwError == CRYPT_E_REVOKED /* Win2k */),
-     "expected CRYPT_E_NO_REVOCATION_CHECK, got %08x\n", status.dwError);
-    ok(status.dwIndex == 0, "expected index 0, got %d\n", status.dwIndex);
+     "expected CRYPT_E_NO_REVOCATION_CHECK, got %08lx\n", status.dwError);
+    ok(status.dwIndex == 0, "expected index 0, got %ld\n", status.dwIndex);
     CertCloseStore(revPara.hCrlStore, 0);
     CertFreeCertificateContext(certs[1]);
     CertFreeCertificateContext(certs[0]);
@@ -3881,11 +3881,11 @@ static void testAcquireCertPrivateKey(void)
     /* Missing private key */
     ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, NULL, NULL);
     ok(!ret && (GetLastError() == CRYPT_E_NO_KEY_PROPERTY || GetLastError() == NTE_BAD_PROV_TYPE /* win10 */),
-     "Expected CRYPT_E_NO_KEY_PROPERTY, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NO_KEY_PROPERTY, got %08lx\n", GetLastError());
     ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, &keySpec,
      &callerFree);
     ok(!ret && (GetLastError() == CRYPT_E_NO_KEY_PROPERTY || GetLastError() == NTE_BAD_PROV_TYPE /* win10 */),
-     "Expected CRYPT_E_NO_KEY_PROPERTY, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NO_KEY_PROPERTY, got %08lx\n", GetLastError());
     CertSetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, 0,
      &keyProvInfo);
     ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, &keySpec,
@@ -3893,12 +3893,12 @@ static void testAcquireCertPrivateKey(void)
     ok(!ret && (GetLastError() == CRYPT_E_NO_KEY_PROPERTY ||
        GetLastError() == NTE_BAD_KEYSET /* win8 */ ||
        GetLastError() == NTE_BAD_PROV_TYPE /* win10 */),
-     "Expected CRYPT_E_NO_KEY_PROPERTY, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NO_KEY_PROPERTY, got %08lx\n", GetLastError());
 
     CryptAcquireContextA(&csp, cspNameA, MS_DEF_PROV_A, PROV_RSA_FULL,
      CRYPT_NEWKEYSET);
     ret = CryptImportKey(csp, privKey, sizeof(privKey), 0, 0, &key);
-    ok(ret, "CryptImportKey failed: %08x\n", GetLastError());
+    ok(ret, "CryptImportKey failed: %08lx\n", GetLastError());
     if (ret)
     {
         HCRYPTPROV certCSP;
@@ -3910,7 +3910,7 @@ static void testAcquireCertPrivateKey(void)
          &keySpec, &callerFree);
         ok(ret ||
          broken(!ret), /* win95 */
-         "CryptAcquireCertificatePrivateKey failed: %08x\n",
+         "CryptAcquireCertificatePrivateKey failed: %08lx\n",
          GetLastError());
         if (ret)
         {
@@ -3922,7 +3922,7 @@ static void testAcquireCertPrivateKey(void)
          NULL, NULL);
         ok(ret ||
          broken(!ret), /* win95 */
-         "CryptAcquireCertificatePrivateKey failed: %08x\n",
+         "CryptAcquireCertificatePrivateKey failed: %08lx\n",
          GetLastError());
         CryptReleaseContext(certCSP, 0);
 
@@ -3932,7 +3932,7 @@ static void testAcquireCertPrivateKey(void)
          &callerFree);
         ok(ret ||
          broken(!ret), /* win95 */
-         "CryptAcquireCertificatePrivateKey failed: %08x\n",
+         "CryptAcquireCertificatePrivateKey failed: %08lx\n",
          GetLastError());
         if (ret)
         {
@@ -3945,7 +3945,7 @@ static void testAcquireCertPrivateKey(void)
          CRYPT_ACQUIRE_CACHE_FLAG, NULL, &certCSP, &keySpec, &callerFree);
         ok(ret ||
          broken(!ret), /* win95 */
-         "CryptAcquireCertificatePrivateKey failed: %08x\n",
+         "CryptAcquireCertificatePrivateKey failed: %08lx\n",
          GetLastError());
         ok(!callerFree, "Expected callerFree to be FALSE\n");
         size = sizeof(keyContext);
@@ -3953,7 +3953,7 @@ static void testAcquireCertPrivateKey(void)
          &keyContext, &size);
         ok(ret ||
          broken(!ret), /* win95 */
-         "CertGetCertificateContextProperty failed: %08x\n",
+         "CertGetCertificateContextProperty failed: %08lx\n",
          GetLastError());
 
         /* Remove the cached provider */
@@ -3970,7 +3970,7 @@ static void testAcquireCertPrivateKey(void)
          &callerFree);
         ok(ret ||
          broken(!ret), /* win95 */
-         "CryptAcquireCertificatePrivateKey failed: %08x\n",
+         "CryptAcquireCertificatePrivateKey failed: %08lx\n",
          GetLastError());
         ok(!callerFree, "Expected callerFree to be FALSE\n");
         size = sizeof(keyContext);
@@ -3978,7 +3978,7 @@ static void testAcquireCertPrivateKey(void)
          &keyContext, &size);
         ok(ret ||
          broken(!ret), /* win95 */
-         "CertGetCertificateContextProperty failed: %08x\n",
+         "CertGetCertificateContextProperty failed: %08lx\n",
          GetLastError());
         CryptReleaseContext(certCSP, 0);
 
@@ -3988,26 +3988,26 @@ static void testAcquireCertPrivateKey(void)
     /* Some sanity-checking on public key exporting */
     ret = CryptImportPublicKeyInfo(csp, X509_ASN_ENCODING,
      &cert->pCertInfo->SubjectPublicKeyInfo, &key);
-    ok(ret, "CryptImportPublicKeyInfo failed: %08x\n", GetLastError());
+    ok(ret, "CryptImportPublicKeyInfo failed: %08lx\n", GetLastError());
     if (ret)
     {
         ret = CryptExportKey(key, 0, PUBLICKEYBLOB, 0, NULL, &size);
-        ok(ret, "CryptExportKey failed: %08x\n", GetLastError());
+        ok(ret, "CryptExportKey failed: %08lx\n", GetLastError());
         if (ret)
         {
             LPBYTE buf = HeapAlloc(GetProcessHeap(), 0, size), encodedKey;
 
             ret = CryptExportKey(key, 0, PUBLICKEYBLOB, 0, buf, &size);
-            ok(ret, "CryptExportKey failed: %08x\n", GetLastError());
-            ok(size == sizeof(exportedPublicKeyBlob), "Unexpected size %d\n",
+            ok(ret, "CryptExportKey failed: %08lx\n", GetLastError());
+            ok(size == sizeof(exportedPublicKeyBlob), "Unexpected size %ld\n",
              size);
             ok(!memcmp(buf, exportedPublicKeyBlob, size), "Unexpected value\n");
             ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, RSA_CSP_PUBLICKEYBLOB,
              buf, CRYPT_ENCODE_ALLOC_FLAG, NULL, &encodedKey, &size);
-            ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+            ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
             if (ret)
             {
-                ok(size == sizeof(asnEncodedPublicKey), "Unexpected size %d\n",
+                ok(size == sizeof(asnEncodedPublicKey), "Unexpected size %ld\n",
                  size);
                 ok(!memcmp(encodedKey, asnEncodedPublicKey, size),
                  "Unexpected value\n");
@@ -4019,18 +4019,18 @@ static void testAcquireCertPrivateKey(void)
     }
     ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE, X509_ASN_ENCODING,
      NULL, 0, NULL, NULL, &size);
-    ok(ret, "CryptExportPublicKeyInfoEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptExportPublicKeyInfoEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         PCERT_PUBLIC_KEY_INFO info = HeapAlloc(GetProcessHeap(), 0, size);
 
         ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE, X509_ASN_ENCODING,
          NULL, 0, NULL, info, &size);
-        ok(ret, "CryptExportPublicKeyInfoEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptExportPublicKeyInfoEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             ok(info->PublicKey.cbData == sizeof(asnEncodedPublicKey),
-             "Unexpected size %d\n", info->PublicKey.cbData);
+             "Unexpected size %ld\n", info->PublicKey.cbData);
             ok(!memcmp(info->PublicKey.pbData, asnEncodedPublicKey,
              info->PublicKey.cbData), "Unexpected value\n");
         }
@@ -4062,28 +4062,28 @@ static void testGetPublicKeyLength(void)
     SetLastError(0xdeadbeef);
     ret = CertGetPublicKeyLength(0, &info);
     ok(ret == 0 && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %d, %08x\n",
+     "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %ld, %08lx\n",
      ret, GetLastError());
     SetLastError(0xdeadbeef);
     ret = CertGetPublicKeyLength(X509_ASN_ENCODING, &info);
     ok(ret == 0 &&
      (GetLastError() == CRYPT_E_ASN1_EOD ||
       GetLastError() == OSS_BAD_ARG), /* win9x */
-     "Expected length 0 and CRYPT_E_ASN1_EOD, got length %d, %08x\n",
+     "Expected length 0 and CRYPT_E_ASN1_EOD, got length %ld, %08lx\n",
      ret, GetLastError());
     /* With a nearly-empty public key info */
     info.Algorithm.pszObjId = oid_rsa_rsa;
     SetLastError(0xdeadbeef);
     ret = CertGetPublicKeyLength(0, &info);
     ok(ret == 0 && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %d, %08x\n",
+     "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %ld, %08lx\n",
      ret, GetLastError());
     SetLastError(0xdeadbeef);
     ret = CertGetPublicKeyLength(X509_ASN_ENCODING, &info);
     ok(ret == 0 &&
      (GetLastError() == CRYPT_E_ASN1_EOD ||
       GetLastError() == OSS_BAD_ARG), /* win9x */
-     "Expected length 0 and CRYPT_E_ASN1_EOD, got length %d, %08x\n",
+     "Expected length 0 and CRYPT_E_ASN1_EOD, got length %ld, %08lx\n",
      ret, GetLastError());
     /* With a bogus key */
     info.PublicKey.cbData = sizeof(bogusKey);
@@ -4091,14 +4091,14 @@ static void testGetPublicKeyLength(void)
     SetLastError(0xdeadbeef);
     ret = CertGetPublicKeyLength(0, &info);
     ok(ret == 0 && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %d, %08x\n",
+     "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %ld, %08lx\n",
      ret, GetLastError());
     SetLastError(0xdeadbeef);
     ret = CertGetPublicKeyLength(X509_ASN_ENCODING, &info);
     ok(ret == 0 &&
      (GetLastError() == CRYPT_E_ASN1_BADTAG ||
       GetLastError() == OSS_PDU_MISMATCH), /* win9x */
-     "Expected length 0 and CRYPT_E_ASN1_BADTAGTAG, got length %d, %08x\n",
+     "Expected length 0 and CRYPT_E_ASN1_BADTAGTAG, got length %ld, %08lx\n",
      ret, GetLastError());
     /* With a believable RSA key but a bogus OID */
     info.Algorithm.pszObjId = bogusOID;
@@ -4107,12 +4107,12 @@ static void testGetPublicKeyLength(void)
     SetLastError(0xdeadbeef);
     ret = CertGetPublicKeyLength(0, &info);
     ok(ret == 0 && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %d, %08x\n",
+     "Expected length 0 and ERROR_FILE_NOT_FOUND, got length %ld, %08lx\n",
      ret, GetLastError());
     SetLastError(0xdeadbeef);
     ret = CertGetPublicKeyLength(X509_ASN_ENCODING, &info);
     ok(ret == 56 || broken(ret == 0 && GetLastError() == NTE_BAD_LEN) /* Win7 */,
-       "Expected length 56, got %d\n", ret);
+       "Expected length 56, got %ld\n", ret);
     /* An RSA key with the DH OID */
     info.Algorithm.pszObjId = oid_rsa_dh;
     SetLastError(0xdeadbeef);
@@ -4120,20 +4120,20 @@ static void testGetPublicKeyLength(void)
     ok(ret == 0 &&
      (GetLastError() == CRYPT_E_ASN1_BADTAG ||
       GetLastError() == E_INVALIDARG), /* win9x */
-     "Expected length 0 and CRYPT_E_ASN1_BADTAG, got length %d, %08x\n",
+     "Expected length 0 and CRYPT_E_ASN1_BADTAG, got length %ld, %08lx\n",
      ret, GetLastError());
     /* With the RSA OID */
     info.Algorithm.pszObjId = oid_rsa_rsa;
     SetLastError(0xdeadbeef);
     ret = CertGetPublicKeyLength(X509_ASN_ENCODING, &info);
     ok(ret == 56 || broken(ret == 0 && GetLastError() == NTE_BAD_LEN) /* Win7 */,
-       "Expected length 56, got %d\n", ret);
+       "Expected length 56, got %ld\n", ret);
     /* With the RSA OID and a message encoding */
     info.Algorithm.pszObjId = oid_rsa_rsa;
     SetLastError(0xdeadbeef);
     ret = CertGetPublicKeyLength(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, &info);
     ok(ret == 56 || broken(ret == 0 && GetLastError() == NTE_BAD_LEN) /* Win7 */,
-       "Expected length 56, got %d\n", ret);
+       "Expected length 56, got %ld\n", ret);
 }
 
 static void testKeyProvInfo(void)
@@ -4150,10 +4150,10 @@ static void testKeyProvInfo(void)
 
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, 0,
                           CERT_SYSTEM_STORE_CURRENT_USER, "My");
-    ok(store != NULL, "CertOpenStore error %u\n", GetLastError());
+    ok(store != NULL, "CertOpenStore error %lu\n", GetLastError());
 
     cert = CertCreateCertificateContext(X509_ASN_ENCODING, selfSignedCert, sizeof(selfSignedCert));
-    ok(cert != NULL, "CertCreateCertificateContext error %#x\n", GetLastError());
+    ok(cert != NULL, "CertCreateCertificateContext error %#lx\n", GetLastError());
 
     info2.pwszContainerName = containerW;
     info2.pwszProvName = providerW;
@@ -4163,39 +4163,39 @@ static void testKeyProvInfo(void)
     info2.rgProvParam = param;
     info2.dwKeySpec = 0x11223344;
     ret = CertSetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, 0, &info2);
-    ok(ret, "CertSetCertificateContextProperty error %#x\n", GetLastError());
+    ok(ret, "CertSetCertificateContextProperty error %#lx\n", GetLastError());
 
     ret = CertGetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, NULL, &size);
-    ok(ret, "CertGetCertificateContextProperty error %#x\n", GetLastError());
+    ok(ret, "CertGetCertificateContextProperty error %#lx\n", GetLastError());
     info = HeapAlloc(GetProcessHeap(), 0, size);
     ret = CertGetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, info, &size);
-    ok(ret, "CertGetCertificateContextProperty error %#x\n", GetLastError());
+    ok(ret, "CertGetCertificateContextProperty error %#lx\n", GetLastError());
     ok(!lstrcmpW(info->pwszContainerName, containerW), "got %s\n", wine_dbgstr_w(info->pwszContainerName));
     ok(!lstrcmpW(info->pwszProvName, providerW), "got %s\n", wine_dbgstr_w(info->pwszProvName));
-    ok(info->dwProvType == 0x12345678, "got %#x\n", info->dwProvType);
-    ok(info->dwFlags == 0x87654321, "got %#x\n", info->dwFlags);
-    ok(info->dwKeySpec == 0x11223344, "got %#x\n", info->dwKeySpec);
-    ok(info->cProvParam == 2, "got %#x\n", info->cProvParam);
+    ok(info->dwProvType == 0x12345678, "got %#lx\n", info->dwProvType);
+    ok(info->dwFlags == 0x87654321, "got %#lx\n", info->dwFlags);
+    ok(info->dwKeySpec == 0x11223344, "got %#lx\n", info->dwKeySpec);
+    ok(info->cProvParam == 2, "got %#lx\n", info->cProvParam);
     ok(info->rgProvParam != NULL, "got %p\n", info->rgProvParam);
-    ok(info->rgProvParam[0].dwParam == param[0].dwParam, "got %#x\n", info->rgProvParam[0].dwParam);
-    ok(info->rgProvParam[0].cbData == param[0].cbData, "got %#x\n", info->rgProvParam[0].cbData);
+    ok(info->rgProvParam[0].dwParam == param[0].dwParam, "got %#lx\n", info->rgProvParam[0].dwParam);
+    ok(info->rgProvParam[0].cbData == param[0].cbData, "got %#lx\n", info->rgProvParam[0].cbData);
     ok(!memcmp(info->rgProvParam[0].pbData, param[0].pbData, param[0].cbData), "param1 mismatch\n");
-    ok(info->rgProvParam[0].dwFlags == param[0].dwFlags, "got %#x\n", info->rgProvParam[1].dwFlags);
-    ok(info->rgProvParam[1].dwParam == param[1].dwParam, "got %#x\n", info->rgProvParam[1].dwParam);
-    ok(info->rgProvParam[1].cbData == param[1].cbData, "got %#x\n", info->rgProvParam[1].cbData);
+    ok(info->rgProvParam[0].dwFlags == param[0].dwFlags, "got %#lx\n", info->rgProvParam[1].dwFlags);
+    ok(info->rgProvParam[1].dwParam == param[1].dwParam, "got %#lx\n", info->rgProvParam[1].dwParam);
+    ok(info->rgProvParam[1].cbData == param[1].cbData, "got %#lx\n", info->rgProvParam[1].cbData);
     ok(!memcmp(info->rgProvParam[1].pbData, param[1].pbData, param[1].cbData), "param2 mismatch\n");
-    ok(info->rgProvParam[1].dwFlags == param[1].dwFlags, "got %#x\n", info->rgProvParam[1].dwFlags);
+    ok(info->rgProvParam[1].dwFlags == param[1].dwFlags, "got %#lx\n", info->rgProvParam[1].dwFlags);
     HeapFree(GetProcessHeap(), 0, info);
 
     ret = CertAddCertificateContextToStore(store, cert, CERT_STORE_ADD_NEW, NULL);
-    ok(ret, "CertAddCertificateContextToStore error %#x\n", GetLastError());
+    ok(ret, "CertAddCertificateContextToStore error %#lx\n", GetLastError());
 
     CertFreeCertificateContext(cert);
     CertCloseStore(store, 0);
 
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, 0,
                           CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, "My");
-    ok(store != NULL, "CertOpenStore error %u\n", GetLastError());
+    ok(store != NULL, "CertOpenStore error %lu\n", GetLastError());
 
     name.pbData = subjectName;
     name.cbData = sizeof(subjectName);
@@ -4203,29 +4203,29 @@ static void testKeyProvInfo(void)
     ok(cert != NULL, "certificate should exist in My store\n");
 
     ret = CertGetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, NULL, &size);
-    ok(ret, "CertGetCertificateContextProperty error %#x\n", GetLastError());
+    ok(ret, "CertGetCertificateContextProperty error %#lx\n", GetLastError());
     info = HeapAlloc(GetProcessHeap(), 0, size);
     ret = CertGetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, info, &size);
-    ok(ret, "CertGetCertificateContextProperty error %#x\n", GetLastError());
+    ok(ret, "CertGetCertificateContextProperty error %#lx\n", GetLastError());
     ok(!lstrcmpW(info->pwszContainerName, containerW), "got %s\n", wine_dbgstr_w(info->pwszContainerName));
     ok(!lstrcmpW(info->pwszProvName, providerW), "got %s\n", wine_dbgstr_w(info->pwszProvName));
-    ok(info->dwProvType == 0x12345678, "got %#x\n", info->dwProvType);
-    ok(info->dwFlags == 0x87654321, "got %#x\n", info->dwFlags);
-    ok(info->dwKeySpec == 0x11223344, "got %#x\n", info->dwKeySpec);
-    ok(info->cProvParam == 2, "got %#x\n", info->cProvParam);
+    ok(info->dwProvType == 0x12345678, "got %#lx\n", info->dwProvType);
+    ok(info->dwFlags == 0x87654321, "got %#lx\n", info->dwFlags);
+    ok(info->dwKeySpec == 0x11223344, "got %#lx\n", info->dwKeySpec);
+    ok(info->cProvParam == 2, "got %#lx\n", info->cProvParam);
     ok(info->rgProvParam != NULL, "got %p\n", info->rgProvParam);
-    ok(info->rgProvParam[0].dwParam == param[0].dwParam, "got %#x\n", info->rgProvParam[0].dwParam);
-    ok(info->rgProvParam[0].cbData == param[0].cbData, "got %#x\n", info->rgProvParam[0].cbData);
+    ok(info->rgProvParam[0].dwParam == param[0].dwParam, "got %#lx\n", info->rgProvParam[0].dwParam);
+    ok(info->rgProvParam[0].cbData == param[0].cbData, "got %#lx\n", info->rgProvParam[0].cbData);
     ok(!memcmp(info->rgProvParam[0].pbData, param[0].pbData, param[0].cbData), "param1 mismatch\n");
-    ok(info->rgProvParam[0].dwFlags == param[0].dwFlags, "got %#x\n", info->rgProvParam[1].dwFlags);
-    ok(info->rgProvParam[1].dwParam == param[1].dwParam, "got %#x\n", info->rgProvParam[1].dwParam);
-    ok(info->rgProvParam[1].cbData == param[1].cbData, "got %#x\n", info->rgProvParam[1].cbData);
+    ok(info->rgProvParam[0].dwFlags == param[0].dwFlags, "got %#lx\n", info->rgProvParam[1].dwFlags);
+    ok(info->rgProvParam[1].dwParam == param[1].dwParam, "got %#lx\n", info->rgProvParam[1].dwParam);
+    ok(info->rgProvParam[1].cbData == param[1].cbData, "got %#lx\n", info->rgProvParam[1].cbData);
     ok(!memcmp(info->rgProvParam[1].pbData, param[1].pbData, param[1].cbData), "param2 mismatch\n");
-    ok(info->rgProvParam[1].dwFlags == param[1].dwFlags, "got %#x\n", info->rgProvParam[1].dwFlags);
+    ok(info->rgProvParam[1].dwFlags == param[1].dwFlags, "got %#lx\n", info->rgProvParam[1].dwFlags);
     HeapFree(GetProcessHeap(), 0, info);
 
     ret = CertDeleteCertificateFromStore(cert);
-    ok(ret, "CertDeleteCertificateFromStore error %#x\n", GetLastError());
+    ok(ret, "CertDeleteCertificateFromStore error %#lx\n", GetLastError());
 
     CertFreeCertificateContext(cert);
     CertCloseStore(store, 0);
@@ -4249,32 +4249,32 @@ static void test_VerifySignature(void)
     NTSTATUS status;
 
     cert = CertCreateCertificateContext(X509_ASN_ENCODING, selfSignedCert, sizeof(selfSignedCert));
-    ok(cert != NULL, "CertCreateCertificateContext error %#x\n", GetLastError());
+    ok(cert != NULL, "CertCreateCertificateContext error %#lx\n", GetLastError());
 
     /* 1. Verify certificate signature with Crypto API */
     ret = CryptVerifyCertificateSignature(0, cert->dwCertEncodingType,
             cert->pbCertEncoded, cert->cbCertEncoded, &cert->pCertInfo->SubjectPublicKeyInfo);
-    ok(ret, "CryptVerifyCertificateSignature error %#x\n", GetLastError());
+    ok(ret, "CryptVerifyCertificateSignature error %#lx\n", GetLastError());
 
     /* 2. Verify certificate signature with Crypto API manually */
     ret = CryptAcquireContextA(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
-    ok(ret, "CryptAcquireContext error %#x\n", GetLastError());
+    ok(ret, "CryptAcquireContext error %#lx\n", GetLastError());
 
     ret = CryptImportPublicKeyInfoEx(prov, cert->dwCertEncodingType, &cert->pCertInfo->SubjectPublicKeyInfo, 0, 0, NULL, &key);
-    ok(ret, "CryptImportPublicKeyInfoEx error %#x\n", GetLastError());
+    ok(ret, "CryptImportPublicKeyInfoEx error %#lx\n", GetLastError());
 
     ret = CryptDecodeObjectEx(cert->dwCertEncodingType, X509_CERT,
             cert->pbCertEncoded, cert->cbCertEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size);
-    ok(ret, "CryptDecodeObjectEx error %#x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx error %#lx\n", GetLastError());
 
     ret = CryptCreateHash(prov, CALG_SHA1, 0, 0, &hash);
-    ok(ret, "CryptCreateHash error %#x\n", GetLastError());
+    ok(ret, "CryptCreateHash error %#lx\n", GetLastError());
 
     ret = CryptHashData(hash, info->ToBeSigned.pbData, info->ToBeSigned.cbData, 0);
-    ok(ret, "CryptHashData error %#x\n", GetLastError());
+    ok(ret, "CryptHashData error %#lx\n", GetLastError());
 
     ret = CryptVerifySignatureW(hash, info->Signature.pbData, info->Signature.cbData, key, NULL, 0);
-    ok(ret, "CryptVerifySignature error %#x\n", GetLastError());
+    ok(ret, "CryptVerifySignature error %#lx\n", GetLastError());
 
     CryptDestroyHash(hash);
     CryptDestroyKey(key);
@@ -4282,13 +4282,13 @@ static void test_VerifySignature(void)
 
     /* 3. Verify certificate signature with CNG */
     ret = CryptImportPublicKeyInfoEx2(cert->dwCertEncodingType, &cert->pCertInfo->SubjectPublicKeyInfo, 0, NULL, &bkey);
-    ok(ret, "CryptImportPublicKeyInfoEx error %#x\n", GetLastError());
+    ok(ret, "CryptImportPublicKeyInfoEx error %#lx\n", GetLastError());
 
     status = BCryptOpenAlgorithmProvider(&alg, BCRYPT_SHA1_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
-    ok(!status, "got %#x\n", status);
+    ok(!status, "got %#lx\n", status);
 
     status = BCryptCreateHash(alg, &bhash, NULL, 0, NULL, 0, 0);
-    ok(!status || broken(status == STATUS_INVALID_PARAMETER) /* Vista */, "got %#x\n", status);
+    ok(!status || broken(status == STATUS_INVALID_PARAMETER) /* Vista */, "got %#lx\n", status);
     if (status == STATUS_INVALID_PARAMETER)
     {
         win_skip("broken BCryptCreateHash\n");
@@ -4296,15 +4296,15 @@ static void test_VerifySignature(void)
     }
 
     status = BCryptHashData(bhash, info->ToBeSigned.pbData, info->ToBeSigned.cbData, 0);
-    ok(!status, "got %#x\n", status);
+    ok(!status, "got %#lx\n", status);
 
     status = BCryptFinishHash(bhash, hash_value, sizeof(hash_value), 0);
-    ok(!status, "got %#x\n", status);
+    ok(!status, "got %#lx\n", status);
     ok(!memcmp(hash_value, selfSignedSignatureHash, sizeof(hash_value)), "got wrong hash value\n");
 
     status = BCryptGetProperty(bhash, BCRYPT_HASH_LENGTH, (BYTE *)&hash_len, sizeof(hash_len), &size, 0);
-    ok(!status, "got %#x\n", status);
-    ok(hash_len == sizeof(hash_value), "got %u\n", hash_len);
+    ok(!status, "got %#lx\n", status);
+    ok(hash_len == sizeof(hash_value), "got %lu\n", hash_len);
 
     sig_value = HeapAlloc(GetProcessHeap(), 0, info->Signature.cbData);
     for (i = 0; i < info->Signature.cbData; i++)
@@ -4312,7 +4312,7 @@ static void test_VerifySignature(void)
 
     pad.pszAlgId = BCRYPT_SHA1_ALGORITHM;
     status = BCryptVerifySignature(bkey, &pad, hash_value, sizeof(hash_value), sig_value, info->Signature.cbData, BCRYPT_PAD_PKCS1);
-    ok(!status, "got %#x\n", status);
+    ok(!status, "got %#lx\n", status);
 
     HeapFree(GetProcessHeap(), 0, sig_value);
     BCryptDestroyHash(bhash);
diff --git a/dlls/crypt32/tests/chain.c b/dlls/crypt32/tests/chain.c
index 5f7f6a5b777..9165e87249f 100644
--- a/dlls/crypt32/tests/chain.c
+++ b/dlls/crypt32/tests/chain.c
@@ -97,18 +97,18 @@ static void testCreateCertChainEngine(void)
      */
     ret = pCertCreateCertificateChainEngine(pConfig, &engine);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* Crashes
     config.cbSize = sizeof(config);
     ret = pCertCreateCertificateChainEngine(pConfig, NULL);
      */
     config.cbSize = sizeof(config);
     ret = pCertCreateCertificateChainEngine(pConfig, &engine);
-    ok(ret, "CertCreateCertificateChainEngine failed: %08x\n", GetLastError());
+    ok(ret, "CertCreateCertificateChainEngine failed: %08lx\n", GetLastError());
     pCertFreeCertificateChainEngine(engine);
     config.dwFlags = 0xff000000;
     ret = pCertCreateCertificateChainEngine(pConfig, &engine);
-    ok(ret, "CertCreateCertificateChainEngine failed: %08x\n", GetLastError());
+    ok(ret, "CertCreateCertificateChainEngine failed: %08lx\n", GetLastError());
     pCertFreeCertificateChainEngine(engine);
 
     /* Creating a cert with no root certs at all is allowed.. */
@@ -116,7 +116,7 @@ static void testCreateCertChainEngine(void)
      CERT_STORE_CREATE_NEW_FLAG, NULL);
     config.hRestrictedRoot = store;
     ret = pCertCreateCertificateChainEngine(pConfig, &engine);
-    ok(ret, "CertCreateCertificateChainEngine failed: %08x\n", GetLastError());
+    ok(ret, "CertCreateCertificateChainEngine failed: %08lx\n", GetLastError());
     pCertFreeCertificateChainEngine(engine);
 
     /* but creating one with a restricted root with a cert that isn't a member
@@ -128,7 +128,7 @@ static void testCreateCertChainEngine(void)
     /* ERROR_FILE_NOT_FOUND used in Windows 10 */
     ok(!ret && ((GetLastError() == CRYPT_E_NOT_FOUND) ||
                 (GetLastError() == ERROR_FILE_NOT_FOUND)),
-        "Expected CRYPT_E_NOT_FOUND or ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+        "Expected CRYPT_E_NOT_FOUND or ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
 
     CertCloseStore(store, 0);
 }
@@ -3380,7 +3380,7 @@ static PCCERT_CHAIN_CONTEXT getChain(HCERTCHAINENGINE engine,
                 ret = CertAddEncodedCertificateToStore(store,
                  X509_ASN_ENCODING, certArray->rgBlob[i].pbData,
                  certArray->rgBlob[i].cbData, CERT_STORE_ADD_ALWAYS, NULL);
-                ok(ret, "Chain %d: adding cert %d failed: %08x\n",
+                ok(ret, "Chain %ld: adding cert %ld failed: %08lx\n",
                  testIndex, i, GetLastError());
             }
         }
@@ -3388,7 +3388,7 @@ static PCCERT_CHAIN_CONTEXT getChain(HCERTCHAINENGINE engine,
          X509_ASN_ENCODING, certArray->rgBlob[certArray->cBlob - 1].pbData,
          certArray->rgBlob[certArray->cBlob - 1].cbData, CERT_STORE_ADD_ALWAYS,
          &endCert);
-        ok(ret, "Chain %d: adding end cert failed: %08x\n",
+        ok(ret, "Chain %ld: adding end cert failed: %08lx\n",
          testIndex, GetLastError());
         if (ret)
         {
@@ -3402,7 +3402,7 @@ static PCCERT_CHAIN_CONTEXT getChain(HCERTCHAINENGINE engine,
             ret = pCertGetCertificateChain(engine, endCert, &fileTime,
              includeStore ? store : NULL, &chainPara, flags, NULL, &chain);
             todo_wine_if (todo & TODO_CHAIN)
-                ok(ret, "Chain %d: CertGetCertificateChain failed: %08x\n",
+                ok(ret, "Chain %ld: CertGetCertificateChain failed: %08lx\n",
                  testIndex, GetLastError());
             CertFreeCertificateContext(endCert);
         }
@@ -3424,27 +3424,27 @@ static void checkElementStatus(const CERT_TRUST_STATUS *expected,
 {
     if (got->dwErrorStatus == expected->dwErrorStatus)
         ok(got->dwErrorStatus == expected->dwErrorStatus,
-         "%s[%d], element [%d,%d]: expected error %08x, got %08x\n",
+         "%s[%ld], element [%ld,%ld]: expected error %08lx, got %08lx\n",
          testName, testIndex, chainIndex, elementIndex, expected->dwErrorStatus,
          got->dwErrorStatus);
     else todo_wine_if (todo & TODO_ERROR)
         ok(got->dwErrorStatus == expected->dwErrorStatus ||
          broken((got->dwErrorStatus & ~ignore->dwErrorStatus) ==
          (expected->dwErrorStatus & ~ignore->dwErrorStatus)),
-         "%s[%d], element [%d,%d]: expected error %08x, got %08x. %08x is "
+         "%s[%ld], element [%ld,%ld]: expected error %08lx, got %08lx. %08x is "
          "expected if no valid root certificate is available.\n",
          testName, testIndex, chainIndex, elementIndex, expected->dwErrorStatus,
          got->dwErrorStatus, CERT_TRUST_IS_UNTRUSTED_ROOT);
     if (got->dwInfoStatus == expected->dwInfoStatus)
         ok(got->dwInfoStatus == expected->dwInfoStatus,
-         "%s[%d], element [%d,%d]: expected info %08x, got %08x\n",
+         "%s[%ld], element [%ld,%ld]: expected info %08lx, got %08lx\n",
          testName, testIndex, chainIndex, elementIndex, expected->dwInfoStatus,
          got->dwInfoStatus);
     else todo_wine_if (todo & TODO_INFO)
         ok(got->dwInfoStatus == expected->dwInfoStatus ||
          broken((got->dwInfoStatus & ~ignore->dwInfoStatus) ==
          (expected->dwInfoStatus & ~ignore->dwInfoStatus)),
-         "%s[%d], element [%d,%d]: expected info %08x, got %08x\n",
+         "%s[%ld], element [%ld,%ld]: expected info %08lx, got %08lx\n",
          testName, testIndex, chainIndex, elementIndex, expected->dwInfoStatus,
          got->dwInfoStatus);
 }
@@ -3456,7 +3456,7 @@ static void checkSimpleChainStatus(const CERT_SIMPLE_CHAIN *simpleChain,
 {
     todo_wine_if (todo & TODO_ELEMENTS)
         ok(simpleChain->cElement == simpleChainStatus->cElement,
-         "%s[%d]: expected %d elements, got %d\n", testName, testIndex,
+         "%s[%ld]: expected %ld elements, got %ld\n", testName, testIndex,
          simpleChainStatus->cElement, simpleChain->cElement);
     if (simpleChain->cElement == simpleChainStatus->cElement)
     {
@@ -3482,7 +3482,7 @@ static void checkChainStatus(PCCERT_CHAIN_CONTEXT chain,
  DWORD testIndex)
 {
     ok(chain->cChain == chainStatus->cChain,
-     "%s[%d]: expected %d simple chains, got %d\n", testName, testIndex,
+     "%s[%ld]: expected %ld simple chains, got %ld\n", testName, testIndex,
      chainStatus->cChain, chain->cChain);
     todo_wine_if (todo & TODO_ERROR &&
      chain->TrustStatus.dwErrorStatus != chainStatus->status.dwErrorStatus)
@@ -3492,7 +3492,7 @@ static void checkChainStatus(PCCERT_CHAIN_CONTEXT chain,
          ~chainStatus->statusToIgnore.dwErrorStatus) ==
          (chainStatus->status.dwErrorStatus &
          ~chainStatus->statusToIgnore.dwErrorStatus)),
-         "%s[%d]: expected error %08x, got %08x. %08x is expected if no valid "
+         "%s[%ld]: expected error %08lx, got %08lx. %08x is expected if no valid "
          "root certificate is available.\n",
          testName, testIndex, chainStatus->status.dwErrorStatus,
          chain->TrustStatus.dwErrorStatus, CERT_TRUST_IS_UNTRUSTED_ROOT);
@@ -3504,7 +3504,7 @@ static void checkChainStatus(PCCERT_CHAIN_CONTEXT chain,
          ~chainStatus->statusToIgnore.dwInfoStatus) ==
          (chainStatus->status.dwInfoStatus &
          ~chainStatus->statusToIgnore.dwInfoStatus)),
-         "%s[%d]: expected info %08x, got %08x\n",
+         "%s[%ld]: expected info %08lx, got %08lx\n",
          testName, testIndex, chainStatus->status.dwInfoStatus,
          chain->TrustStatus.dwInfoStatus);
     if (chain->cChain == chainStatus->cChain)
@@ -4358,12 +4358,12 @@ static void testGetCertChain(void)
         /* Crash on Vista */
         ret = pCertGetCertificateChain(NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL);
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     }
     ret = pCertGetCertificateChain(NULL, NULL, NULL, NULL, NULL, 0, NULL,
      &chain);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* Crash
     ret = pCertGetCertificateChain(NULL, NULL, NULL, NULL, &para, 0, NULL, NULL);
     ret = pCertGetCertificateChain(NULL, NULL, NULL, NULL, &para, 0, NULL,
@@ -4376,7 +4376,7 @@ static void testGetCertChain(void)
         /* Crash on Vista */
         ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, NULL, 0, NULL, NULL);
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     }
     /* Crash
     ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, &para, 0, NULL, NULL);
@@ -4389,7 +4389,7 @@ static void testGetCertChain(void)
     ok(!ret, "Expected failure\n");
     ok(GetLastError() == ERROR_INVALID_DATA ||
      GetLastError() == CRYPT_E_ASN1_BADTAG /* Vista */,
-     "Expected ERROR_INVALID_DATA or CRYPT_E_ASN1_BADTAG, got %d\n", GetLastError());
+     "Expected ERROR_INVALID_DATA or CRYPT_E_ASN1_BADTAG, got %ld\n", GetLastError());
     para.cbSize = sizeof(para);
     SetLastError(0xdeadbeef);
     ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, &para, 0, NULL,
@@ -4397,7 +4397,7 @@ static void testGetCertChain(void)
     ok(!ret, "Expected failure\n");
     ok(GetLastError() == ERROR_INVALID_DATA ||
      GetLastError() == CRYPT_E_ASN1_BADTAG /* Vista */,
-     "Expected ERROR_INVALID_DATA or CRYPT_E_ASN1_BADTAG, got %d\n", GetLastError());
+     "Expected ERROR_INVALID_DATA or CRYPT_E_ASN1_BADTAG, got %ld\n", GetLastError());
 
     para.cbSize = 0;
     SetLastError(0xdeadbeef);
@@ -4406,7 +4406,7 @@ static void testGetCertChain(void)
     ok(!ret, "Expected failure\n");
     ok(GetLastError() == ERROR_INVALID_DATA ||
      GetLastError() == CRYPT_E_ASN1_BADTAG, /* Vista and higher */
-     "Expected ERROR_INVALID_DATA or CRYPT_E_ASN1_BADTAG, got %d\n", GetLastError());
+     "Expected ERROR_INVALID_DATA or CRYPT_E_ASN1_BADTAG, got %ld\n", GetLastError());
 
     CertFreeCertificateContext(cert);
 
@@ -4428,7 +4428,7 @@ static void testGetCertChain(void)
     para.RequestedUsage.Usage.cUsageIdentifier = 1;
     ret = pCertGetCertificateChain(NULL, cert, &fileTime, store, &para,
      0, NULL, &chain);
-    ok(ret, "CertGetCertificateChain failed: %08x\n", GetLastError());
+    ok(ret, "CertGetCertificateChain failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(chain->TrustStatus.dwErrorStatus & CERT_TRUST_IS_NOT_VALID_FOR_USAGE,
@@ -4438,11 +4438,11 @@ static void testGetCertChain(void)
     oids[0] = oid_server_auth;
     ret = pCertGetCertificateChain(NULL, cert, &fileTime, store, &para,
      0, NULL, &chain);
-    ok(ret, "CertGetCertificateChain failed: %08x\n", GetLastError());
+    ok(ret, "CertGetCertificateChain failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(!(chain->TrustStatus.dwErrorStatus & CERT_TRUST_IS_NOT_VALID_FOR_USAGE),
-           "didn't expect CERT_TRUST_IS_NOT_VALID_FOR_USAGE, got %x\n", chain->TrustStatus.dwErrorStatus);
+           "didn't expect CERT_TRUST_IS_NOT_VALID_FOR_USAGE, got %lx\n", chain->TrustStatus.dwErrorStatus);
         pCertFreeCertificateChain(chain);
     }
     oids[1] = one_two_three;
@@ -4450,7 +4450,7 @@ static void testGetCertChain(void)
     para.RequestedUsage.dwType = USAGE_MATCH_TYPE_AND;
     ret = pCertGetCertificateChain(NULL, cert, &fileTime, store, &para,
      0, NULL, &chain);
-    ok(ret, "CertGetCertificateChain failed: %08x\n", GetLastError());
+    ok(ret, "CertGetCertificateChain failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(chain->TrustStatus.dwErrorStatus & CERT_TRUST_IS_NOT_VALID_FOR_USAGE,
@@ -4460,7 +4460,7 @@ static void testGetCertChain(void)
     para.RequestedUsage.dwType = USAGE_MATCH_TYPE_OR;
     ret = pCertGetCertificateChain(NULL, cert, &fileTime, store, &para,
      0, NULL, &chain);
-    ok(ret, "CertGetCertificateChain failed: %08x\n", GetLastError());
+    ok(ret, "CertGetCertificateChain failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(!(chain->TrustStatus.dwErrorStatus &
@@ -4492,7 +4492,7 @@ static void testGetCertChain(void)
          ~incompleteOpensslChainCheck.status.statusToIgnore.dwErrorStatus) ==
          (incompleteOpensslChainCheck.status.status.dwErrorStatus &
          ~incompleteOpensslChainCheck.status.statusToIgnore.dwErrorStatus)),
-         "unexpected chain error status %08x\n",
+         "unexpected chain error status %08lx\n",
          chain->TrustStatus.dwErrorStatus);
         if (opensslChainCheck.status.status.dwErrorStatus ==
          chain->TrustStatus.dwErrorStatus)
@@ -4525,7 +4525,7 @@ static void testGetCertChain(void)
          ~chainCheckEmbeddedNullBroken.status.statusToIgnore.dwErrorStatus) ==
          (chainCheckEmbeddedNullBroken.status.status.dwErrorStatus &
          ~chainCheckEmbeddedNullBroken.status.statusToIgnore.dwErrorStatus)),
-         "unexpected chain error status %08x\n",
+         "unexpected chain error status %08lx\n",
          chain->TrustStatus.dwErrorStatus);
         if (chainCheckEmbeddedNull.status.status.dwErrorStatus ==
          chain->TrustStatus.dwErrorStatus)
@@ -4539,11 +4539,11 @@ static void testGetCertChain(void)
     }
 
     store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(store != NULL, "CertOpenStore failed: %u\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %lu\n", GetLastError());
 
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, winehq_org, sizeof(winehq_org),
             CERT_STORE_ADD_ALWAYS, &cert);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %u\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %lu\n", GetLastError());
 
     oids[0] = oid_server_auth;
     memset(&para, 0, sizeof(para));
@@ -4554,7 +4554,7 @@ static void testGetCertChain(void)
 
     /* Pass store that does not contain all certs in chain. */
     ret = CertGetCertificateChain(NULL, cert, &fileTime, store, &para, 0, NULL, &chain);
-    ok(ret, "CertGetCertificateChain failed: %u\n", GetLastError());
+    ok(ret, "CertGetCertificateChain failed: %lu\n", GetLastError());
 
     if(chain->TrustStatus.dwErrorStatus == CERT_TRUST_IS_PARTIAL_CHAIN) { /* win2k */
         win_skip("winehq cert reported as partial chain, skipping its tests\n");
@@ -4563,40 +4563,40 @@ static void testGetCertChain(void)
         return;
     }
 
-    ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, "chain->TrustStatus.dwErrorStatus = %x\n",
+    ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, "chain->TrustStatus.dwErrorStatus = %lx\n",
        chain->TrustStatus.dwErrorStatus);
     todo_wine
-    ok(chain->TrustStatus.dwInfoStatus == CERT_TRUST_HAS_PREFERRED_ISSUER, "chain->TrustStatus.dwInfoStatus = %x\n",
+    ok(chain->TrustStatus.dwInfoStatus == CERT_TRUST_HAS_PREFERRED_ISSUER, "chain->TrustStatus.dwInfoStatus = %lx\n",
        chain->TrustStatus.dwInfoStatus);
 
-    ok(chain->cChain == 1, "chain->cChain = %d\n", chain->cChain);
-    ok(!chain->cLowerQualityChainContext, "chain->cLowerQualityChainContext = %x\n", chain->cLowerQualityChainContext);
+    ok(chain->cChain == 1, "chain->cChain = %ld\n", chain->cChain);
+    ok(!chain->cLowerQualityChainContext, "chain->cLowerQualityChainContext = %lx\n", chain->cLowerQualityChainContext);
     ok(!chain->rgpLowerQualityChainContext, "chain->rgpLowerQualityChainContext =  %p\n", chain->rgpLowerQualityChainContext);
 
     simple_chain = *chain->rgpChain;
-    ok(simple_chain->cbSize == sizeof(*simple_chain), "simple_chain->cbSize = %u\n", simple_chain->cbSize);
-    ok(simple_chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, "simple_chain->TrustStatus.dwErrorStatus = %x\n",
+    ok(simple_chain->cbSize == sizeof(*simple_chain), "simple_chain->cbSize = %lu\n", simple_chain->cbSize);
+    ok(simple_chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, "simple_chain->TrustStatus.dwErrorStatus = %lx\n",
        simple_chain->TrustStatus.dwErrorStatus);
     todo_wine
     ok(simple_chain->TrustStatus.dwInfoStatus == CERT_TRUST_HAS_PREFERRED_ISSUER,
-       "simple_chain->TrustStatus.dwInfoStatus = %x\n", simple_chain->TrustStatus.dwInfoStatus);
-    ok(simple_chain->cElement == 3, "simple_chain->cElement = %u\n", simple_chain->cElement);
+       "simple_chain->TrustStatus.dwInfoStatus = %lx\n", simple_chain->TrustStatus.dwInfoStatus);
+    ok(simple_chain->cElement == 3, "simple_chain->cElement = %lu\n", simple_chain->cElement);
 
     for(i=0; i < simple_chain->cElement; i++) {
         chain_elem = simple_chain->rgpElement[i];
-        ok(chain_elem->cbSize == sizeof(*chain_elem), "chain_elem->cbSize = %u\n", chain_elem->cbSize);
+        ok(chain_elem->cbSize == sizeof(*chain_elem), "chain_elem->cbSize = %lu\n", chain_elem->cbSize);
         if (!i)
             ok(chain_elem->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER,
-               "chain_elem->TrustStatus.dwErrorStatus = %x\n", chain_elem->TrustStatus.dwErrorStatus);
+               "chain_elem->TrustStatus.dwErrorStatus = %lx\n", chain_elem->TrustStatus.dwErrorStatus);
         else if (i == 1)
-            todo_wine ok(!chain_elem->TrustStatus.dwErrorStatus, "chain_elem->TrustStatus.dwErrorStatus = %x\n",
+            todo_wine ok(!chain_elem->TrustStatus.dwErrorStatus, "chain_elem->TrustStatus.dwErrorStatus = %lx\n",
                          chain_elem->TrustStatus.dwErrorStatus);
         else
-            ok(!chain_elem->TrustStatus.dwErrorStatus, "chain_elem->TrustStatus.dwErrorStatus = %x\n",
+            ok(!chain_elem->TrustStatus.dwErrorStatus, "chain_elem->TrustStatus.dwErrorStatus = %lx\n",
                chain_elem->TrustStatus.dwErrorStatus);
-        trace("info[%u] = %x\n", i, chain_elem->TrustStatus.dwInfoStatus);
+        trace("info[%lu] = %lx\n", i, chain_elem->TrustStatus.dwInfoStatus);
         ok(chain_elem->pCertContext->dwCertEncodingType == CRYPT_ASN_ENCODING,
-           "chain_elem->pCertContext->dwCertEncodingType = %x\n",
+           "chain_elem->pCertContext->dwCertEncodingType = %lx\n",
            chain_elem->pCertContext->dwCertEncodingType);
     }
 
@@ -4615,28 +4615,28 @@ static void testGetCertChain(void)
     /* Test revocation flags */
     ret = CertGetCertificateChain(NULL, cert, &fileTime, store, &para, CERT_CHAIN_REVOCATION_CHECK_END_CERT, NULL,
                                   &chain);
-    ok(ret, "CertGetCertificateChain failed: %u\n", GetLastError());
-    ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, "chain->TrustStatus.dwErrorStatus = %x\n",
+    ok(ret, "CertGetCertificateChain failed: %lu\n", GetLastError());
+    ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, "chain->TrustStatus.dwErrorStatus = %lx\n",
        chain->TrustStatus.dwErrorStatus);
     pCertFreeCertificateChain(chain);
 
     ret = CertGetCertificateChain(NULL, cert, &fileTime, store, &para, CERT_CHAIN_REVOCATION_CHECK_CHAIN, NULL, &chain);
-    ok(ret, "CertGetCertificateChain failed: %u\n", GetLastError());
+    ok(ret, "CertGetCertificateChain failed: %lu\n", GetLastError());
     ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER ||
        broken(chain->TrustStatus.dwErrorStatus == (CERT_TRUST_IS_NOT_TIME_VALID|CERT_TRUST_REVOCATION_STATUS_UNKNOWN)), /* XP */
-       "chain->TrustStatus.dwErrorStatus = %x\n", chain->TrustStatus.dwErrorStatus);
+       "chain->TrustStatus.dwErrorStatus = %lx\n", chain->TrustStatus.dwErrorStatus);
     pCertFreeCertificateChain(chain);
 
     ret = CertGetCertificateChain(NULL, cert, &fileTime, store, &para, CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT,
                                   NULL, &chain);
-    ok(ret, "CertGetCertificateChain failed: %u\n", GetLastError());
-    ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, "chain->TrustStatus.dwErrorStatus = %x\n",
+    ok(ret, "CertGetCertificateChain failed: %lu\n", GetLastError());
+    ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_HAS_EXACT_MATCH_ISSUER, "chain->TrustStatus.dwErrorStatus = %lx\n",
        chain->TrustStatus.dwErrorStatus);
     pCertFreeCertificateChain(chain);
 
     /* Test HCCE_LOCAL_MACHINE */
     ret = CertGetCertificateChain(HCCE_LOCAL_MACHINE, cert, &fileTime, store, &para, 0, NULL, &chain);
-    ok(ret, "CertGetCertificateChain failed: %u\n", GetLastError());
+    ok(ret, "CertGetCertificateChain failed: %lu\n", GetLastError());
     pCertFreeCertificateChain(chain);
 
     CertFreeCertificateContext(cert);
@@ -4658,11 +4658,11 @@ static void test_CERT_CHAIN_PARA_cbSize(void)
     ret = CertAddEncodedCertificateToStore(store,
      X509_ASN_ENCODING, chain0_0, sizeof(chain0_0),
      CERT_STORE_ADD_ALWAYS, NULL);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     ret = CertAddEncodedCertificateToStore(store,
      X509_ASN_ENCODING, chain0_1, sizeof(chain0_1),
      CERT_STORE_ADD_ALWAYS, &cert);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
 
     for (i = 0; i < sizeof(CERT_CHAIN_PARA) + 2; i++)
     {
@@ -4673,7 +4673,7 @@ static void test_CERT_CHAIN_PARA_cbSize(void)
         para.cbSize = i;
         ret = pCertGetCertificateChain(NULL, cert, &fileTime,
          NULL, &para, 0, NULL, &chain);
-        ok(ret, "CertGetCertificateChain failed %u\n", GetLastError());
+        ok(ret, "CertGetCertificateChain failed %lu\n", GetLastError());
         pCertFreeCertificateChain(chain);
     }
 
@@ -5001,7 +5001,7 @@ static void checkChainPolicyStatus(LPCSTR policy, HCERTCHAINENGINE engine,
 
         if (check->todo & TODO_POLICY)
             todo_wine ok(ret,
-             "%s[%d](%s): CertVerifyCertificateChainPolicy failed: %08x\n",
+             "%s[%ld](%s): CertVerifyCertificateChainPolicy failed: %08lx\n",
              testName, testIndex,
              IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy,
              GetLastError());
@@ -5009,13 +5009,13 @@ static void checkChainPolicyStatus(LPCSTR policy, HCERTCHAINENGINE engine,
         {
             if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND)
             {
-                skip("%s[%d]: missing policy %s, skipping test\n",
+                skip("%s[%ld]: missing policy %s, skipping test\n",
                  testName, testIndex,
                  IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy);
                 pCertFreeCertificateChain(chain);
                 return;
             }
-            ok(ret, "%s[%d](%s): CertVerifyCertificateChainPolicy failed: %08x\n",
+            ok(ret, "%s[%ld](%s): CertVerifyCertificateChainPolicy failed: %08lx\n",
              testName, testIndex,
              IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy,
              GetLastError());
@@ -5027,13 +5027,13 @@ static void checkChainPolicyStatus(LPCSTR policy, HCERTCHAINENGINE engine,
                  broken(policyStatus.dwError == CERT_TRUST_NO_ERROR) ||
                  (check->brokenStatus && broken(policyStatus.dwError ==
                  check->brokenStatus->dwError)),
-                 "%s[%d](%s): expected %08x, got %08x\n",
+                 "%s[%ld](%s): expected %08lx, got %08lx\n",
                  testName, testIndex,
                  IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy,
                  check->status.dwError, policyStatus.dwError);
             if (policyStatus.dwError != check->status.dwError)
             {
-                skip("%s[%d](%s): error %08x doesn't match expected %08x, not checking indexes\n",
+                skip("%s[%ld](%s): error %08lx doesn't match expected %08lx, not checking indexes\n",
                  testName, testIndex,
                  IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy,
                  policyStatus.dwError, check->status.dwError);
@@ -5044,7 +5044,7 @@ static void checkChainPolicyStatus(LPCSTR policy, HCERTCHAINENGINE engine,
                 ok(policyStatus.lChainIndex == check->status.lChainIndex ||
                  (check->brokenStatus && broken(policyStatus.lChainIndex ==
                  check->brokenStatus->lChainIndex)),
-                 "%s[%d](%s): expected %d, got %d\n",
+                 "%s[%ld](%s): expected %ld, got %ld\n",
                  testName, testIndex,
                  IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy,
                  check->status.lChainIndex, policyStatus.lChainIndex);
@@ -5052,7 +5052,7 @@ static void checkChainPolicyStatus(LPCSTR policy, HCERTCHAINENGINE engine,
                 ok(policyStatus.lElementIndex == check->status.lElementIndex ||
                  (check->brokenStatus && broken(policyStatus.lElementIndex ==
                  check->brokenStatus->lElementIndex)),
-                 "%s[%d](%s): expected %d, got %d\n",
+                 "%s[%ld](%s): expected %ld, got %ld\n",
                  testName, testIndex,
                  IS_INTOID(policy) ? num_to_str(LOWORD(policy)) : policy,
                  check->status.lElementIndex, policyStatus.lElementIndex);
@@ -5369,7 +5369,7 @@ static void testVerifyCertChainPolicy(void)
     SetLastError(0xdeadbeef);
     ret = pCertVerifyCertificateChainPolicy(NULL, NULL, NULL, &policyStatus);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     /* Crashes
     ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, NULL,
      &policyStatus);
@@ -5388,21 +5388,21 @@ static void testVerifyCertChainPolicy(void)
     /* Size of policy status is apparently ignored, as is pChainPolicyPara */
     ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, NULL,
      &policyStatus);
-    ok(ret, "CertVerifyCertificateChainPolicy failed: %08x\n", GetLastError());
+    ok(ret, "CertVerifyCertificateChainPolicy failed: %08lx\n", GetLastError());
     ok(policyStatus.dwError == CERT_E_UNTRUSTEDROOT ||
         policyStatus.dwError == TRUST_E_CERT_SIGNATURE, /* win7 + win8 */
-        "Expected CERT_E_UNTRUSTEDROOT or TRUST_E_CERT_SIGNATURE, got %08x\n", policyStatus.dwError);
+        "Expected CERT_E_UNTRUSTEDROOT or TRUST_E_CERT_SIGNATURE, got %08lx\n", policyStatus.dwError);
     ok(policyStatus.lChainIndex == 0 && policyStatus.lElementIndex == 0,
-     "Expected both indexes 0, got %d, %d\n", policyStatus.lChainIndex,
+     "Expected both indexes 0, got %ld, %ld\n", policyStatus.lChainIndex,
      policyStatus.lElementIndex);
     ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain,
      &policyPara, &policyStatus);
-    ok(ret, "CertVerifyCertificateChainPolicy failed: %08x\n", GetLastError());
+    ok(ret, "CertVerifyCertificateChainPolicy failed: %08lx\n", GetLastError());
     ok(policyStatus.dwError == CERT_E_UNTRUSTEDROOT ||
         policyStatus.dwError == TRUST_E_CERT_SIGNATURE, /* win7 + win8 */
-        "Expected CERT_E_UNTRUSTEDROOT or TRUST_E_CERT_SIGNATURE, got %08x\n", policyStatus.dwError);
+        "Expected CERT_E_UNTRUSTEDROOT or TRUST_E_CERT_SIGNATURE, got %08lx\n", policyStatus.dwError);
     ok(policyStatus.lChainIndex == 0 && policyStatus.lElementIndex == 0,
-     "Expected both indexes 0, got %d, %d\n", policyStatus.lChainIndex,
+     "Expected both indexes 0, got %ld, %ld\n", policyStatus.lChainIndex,
      policyStatus.lElementIndex);
     pCertFreeCertificateChain(chain);
     CertFreeCertificateContext(cert);
diff --git a/dlls/crypt32/tests/crl.c b/dlls/crypt32/tests/crl.c
index c350b20f007..3797fc4cfbf 100644
--- a/dlls/crypt32/tests/crl.c
+++ b/dlls/crypt32/tests/crl.c
@@ -96,11 +96,11 @@ static void testCreateCRL(void)
 
     context = CertCreateCRLContext(0, NULL, 0);
     ok(!context && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     context = CertCreateCRLContext(X509_ASN_ENCODING, NULL, 0);
     GLE = GetLastError();
     ok(!context && (GLE == CRYPT_E_ASN1_EOD || GLE == OSS_MORE_INPUT),
-     "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08x\n", GLE);
+     "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08lx\n", GLE);
     context = CertCreateCRLContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert));
     ok(!context, "Expected failure\n");
     context = CertCreateCRLContext(X509_ASN_ENCODING, signedCRL,
@@ -108,11 +108,11 @@ static void testCreateCRL(void)
     ok(!context, "Expected failure\n");
     context = CertCreateCRLContext(X509_ASN_ENCODING, signedCRL,
      sizeof(signedCRL));
-    ok(context != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
+    ok(context != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
     if (context)
         CertFreeCRLContext(context);
     context = CertCreateCRLContext(X509_ASN_ENCODING, CRL, sizeof(CRL));
-    ok(context != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
+    ok(context != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
     if (context)
         CertFreeCRLContext(context);
 }
@@ -148,41 +148,41 @@ static void testAddCRL(void)
     BOOL ret;
     DWORD GLE;
 
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     if (!store) return;
 
     /* Bad CRL encoding type */
     ret = CertAddEncodedCRLToStore(0, 0, NULL, 0, 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     ret = CertAddEncodedCRLToStore(store, 0, NULL, 0, 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     ret = CertAddEncodedCRLToStore(0, 0, signedCRL, sizeof(signedCRL), 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     ret = CertAddEncodedCRLToStore(store, 0, signedCRL, sizeof(signedCRL), 0,
      NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     ret = CertAddEncodedCRLToStore(0, 0, signedCRL, sizeof(signedCRL),
      CERT_STORE_ADD_ALWAYS, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     ret = CertAddEncodedCRLToStore(store, 0, signedCRL, sizeof(signedCRL),
      CERT_STORE_ADD_ALWAYS, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
 
     /* No CRL */
     ret = CertAddEncodedCRLToStore(0, X509_ASN_ENCODING, NULL, 0, 0, NULL);
     GLE = GetLastError();
     ok(!ret && (GLE == CRYPT_E_ASN1_EOD || GLE == OSS_MORE_INPUT),
-     "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08x\n", GLE);
+     "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08lx\n", GLE);
     ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, NULL, 0, 0, NULL);
     GLE = GetLastError();
     ok(!ret && (GLE == CRYPT_E_ASN1_EOD || GLE == OSS_MORE_INPUT),
-     "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08x\n", GLE);
+     "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08lx\n", GLE);
 
     /* Weird--bad add disposition leads to an access violation in Windows.
      * Both tests crash on some win9x boxes.
@@ -193,12 +193,12 @@ static void testAddCRL(void)
          sizeof(signedCRL), 0, NULL);
         ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION ||
                     GetLastError() == E_INVALIDARG /* Vista */),
-         "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n", GetLastError());
         ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL,
          sizeof(signedCRL), 0, NULL);
         ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION ||
                     GetLastError() == E_INVALIDARG /* Vista */),
-         "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected STATUS_ACCESS_VIOLATION or E_INVALIDARG, got %08lx\n", GetLastError());
     }
 
     /* Weird--can add a CRL to the NULL store (does this have special meaning?)
@@ -206,28 +206,28 @@ static void testAddCRL(void)
     context = NULL;
     ret = CertAddEncodedCRLToStore(0, X509_ASN_ENCODING, signedCRL,
      sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, &context);
-    ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
     if (context)
         CertFreeCRLContext(context);
 
     /* Normal cases: a "signed" CRL is okay.. */
     ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL,
      sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL);
-    ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
     /* and an unsigned one is too. */
     ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, CRL, sizeof(CRL),
      CERT_STORE_ADD_ALWAYS, NULL);
-    ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
 
     ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, newerCRL,
      sizeof(newerCRL), CERT_STORE_ADD_NEW, NULL);
     ok(!ret && GetLastError() == CRYPT_E_EXISTS,
-     "Expected CRYPT_E_EXISTS, got %08x\n", GetLastError());
+     "Expected CRYPT_E_EXISTS, got %08lx\n", GetLastError());
 
     /* This should replace (one of) the existing CRL(s). */
     ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, newerCRL,
      sizeof(newerCRL), CERT_STORE_ADD_NEWER, NULL);
-    ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
 
     CertCloseStore(store, 0);
 
@@ -441,12 +441,12 @@ static void testFindCRL(void)
 
     store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
                           CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     if (!store) return;
 
     ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL,
      sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL);
-    ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
 
     /* Crashes
     context = pCertFindCRLInStore(NULL, 0, 0, 0, NULL, NULL);
@@ -477,7 +477,7 @@ static void testFindCRL(void)
     /* Try to match an issuer that isn't in the store */
     cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert2,
      sizeof(bigCert2));
-    ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
     context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL);
     ok(context == NULL, "Expected no matching context\n");
@@ -486,7 +486,7 @@ static void testFindCRL(void)
     /* Match an issuer that is in the store */
     cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
      sizeof(bigCert));
-    ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
     context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL);
     ok(context != NULL, "Expected a context\n");
@@ -522,7 +522,7 @@ static void testFindCRL(void)
     if (context)
     {
         ok(context->cbCrlEncoded == sizeof(signedCRL),
-         "unexpected CRL size %d\n", context->cbCrlEncoded);
+         "unexpected CRL size %ld\n", context->cbCrlEncoded);
         ok(!memcmp(context->pbCrlEncoded, signedCRL, context->cbCrlEncoded),
          "unexpected CRL data\n");
         CertFreeCRLContext(context);
@@ -531,14 +531,14 @@ static void testFindCRL(void)
     ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING,
      v1CRLWithIssuerAndEntry, sizeof(v1CRLWithIssuerAndEntry),
      CERT_STORE_ADD_ALWAYS, NULL);
-    ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
     ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING,
      v2CRLWithIssuingDistPoint, sizeof(v2CRLWithIssuingDistPoint),
      CERT_STORE_ADD_ALWAYS, NULL);
-    ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
     ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING,
      verisignCRL, sizeof(verisignCRL), CERT_STORE_ADD_ALWAYS, NULL);
-    ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
     issuedForPara.pSubjectCert = cert;
     issuedForPara.pIssuerCert = cert;
     context = NULL;
@@ -561,19 +561,19 @@ static void testFindCRL(void)
      * is 0.
      */
     ok(count == 3 || broken(count == 0 /* NT4, Win9x */),
-     "expected 3 matching CRLs, got %d\n", count);
+     "expected 3 matching CRLs, got %ld\n", count);
     /* Only v1CRLWithIssuerAndEntry and v2CRLWithIssuingDistPoint contain
      * entries, so the count of CRL entries that match cert is 2.
      */
     ok(revoked_count == 2 || broken(revoked_count == 0 /* NT4, Win9x */),
-     "expected 2 matching CRL entries, got %d\n", revoked_count);
+     "expected 2 matching CRL entries, got %ld\n", revoked_count);
 
     CertFreeCertificateContext(cert);
 
     /* Try again with a cert that doesn't match any CRLs in the store */
     cert = CertCreateCertificateContext(X509_ASN_ENCODING,
      bigCertWithDifferentIssuer, sizeof(bigCertWithDifferentIssuer));
-    ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
     issuedForPara.pSubjectCert = cert;
     issuedForPara.pIssuerCert = cert;
@@ -592,8 +592,8 @@ static void testFindCRL(void)
                 revoked_count++;
         }
     } while (context);
-    ok(count == 0, "expected 0 matching CRLs, got %d\n", count);
-    ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n",
+    ok(count == 0, "expected 0 matching CRLs, got %ld\n", count);
+    ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n",
      revoked_count);
     CertFreeCertificateContext(cert);
 
@@ -602,7 +602,7 @@ static void testFindCRL(void)
      */
     cert = CertCreateCertificateContext(X509_ASN_ENCODING,
      verisignCommercialSoftPubCA, sizeof(verisignCommercialSoftPubCA));
-    ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
     issuedForPara.pIssuerCert = cert;
     issuedForPara.pSubjectCert = cert;
@@ -622,8 +622,8 @@ static void testFindCRL(void)
         }
     } while (context);
     ok(count == 1 || broken(count == 0 /* Win9x, NT4 */),
-     "expected 1 matching CRLs, got %d\n", count);
-    ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n",
+     "expected 1 matching CRLs, got %ld\n", count);
+    ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n",
      revoked_count);
     CertFreeCertificateContext(cert);
 
@@ -662,9 +662,9 @@ static void testFindCRL(void)
         }
     } while (context);
     ok(count == 1 || broken(count == 0 /* Win9x, NT4 */),
-     "expected 1 matching CRLs, got %d\n", count);
+     "expected 1 matching CRLs, got %ld\n", count);
     ok(revoked_count == 1 || broken(revoked_count == 0 /* Win9x, NT4 */),
-     "expected 1 matching CRL entries, got %d\n", revoked_count);
+     "expected 1 matching CRL entries, got %ld\n", revoked_count);
 
     /* Test CRL_FIND_ISSUED_BY flags */
     count = revoked_count = 0;
@@ -681,8 +681,8 @@ static void testFindCRL(void)
                 revoked_count++;
         }
     } while (context);
-    ok(count == 0, "expected 0 matching CRLs, got %d\n", count);
-    ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n",
+    ok(count == 0, "expected 0 matching CRLs, got %ld\n", count);
+    ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n",
      revoked_count);
     count = revoked_count = 0;
     do {
@@ -698,8 +698,8 @@ static void testFindCRL(void)
                 revoked_count++;
         }
     } while (context);
-    ok(count == 1, "expected 1 matching CRLs, got %d\n", count);
-    ok(revoked_count == 1, "expected 1 matching CRL entries, got %d\n",
+    ok(count == 1, "expected 1 matching CRLs, got %ld\n", count);
+    ok(revoked_count == 1, "expected 1 matching CRL entries, got %ld\n",
      revoked_count);
     count = revoked_count = 0;
     do {
@@ -715,8 +715,8 @@ static void testFindCRL(void)
                 revoked_count++;
         }
     } while (context);
-    ok(count == 0, "expected 0 matching CRLs, got %d\n", count);
-    ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n",
+    ok(count == 0, "expected 0 matching CRLs, got %ld\n", count);
+    ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n",
      revoked_count);
     count = revoked_count = 0;
     do {
@@ -733,8 +733,8 @@ static void testFindCRL(void)
         }
     } while (context);
     ok(count == 0 || broken(count == 1 /* Win9x */),
-     "expected 0 matching CRLs, got %d\n", count);
-    ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n",
+     "expected 0 matching CRLs, got %ld\n", count);
+    ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n",
      revoked_count);
     count = revoked_count = 0;
     do {
@@ -751,8 +751,8 @@ static void testFindCRL(void)
                 revoked_count++;
         }
     } while (context);
-    ok(count == 0, "expected 0 matching CRLs, got %d\n", count);
-    ok(revoked_count == 0, "expected 0 matching CRL entries, got %d\n",
+    ok(count == 0, "expected 0 matching CRLs, got %ld\n", count);
+    ok(revoked_count == 0, "expected 0 matching CRL entries, got %ld\n",
      revoked_count);
     count = revoked_count = 0;
     do {
@@ -769,8 +769,8 @@ static void testFindCRL(void)
                 revoked_count++;
         }
     } while (context);
-    ok(count == 1, "expected 1 matching CRLs, got %d\n", count);
-    ok(revoked_count == 1, "expected 1 matching CRL entries, got %d\n",
+    ok(count == 1, "expected 1 matching CRLs, got %ld\n", count);
+    ok(revoked_count == 1, "expected 1 matching CRL entries, got %ld\n",
      revoked_count);
     CertFreeCertificateContext(rootCert);
     CertFreeCertificateContext(endCert);
@@ -787,7 +787,7 @@ static void testGetCRLFromStore(void)
     DWORD flags;
     BOOL ret;
 
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     if (!store) return;
 
     /* Crash
@@ -799,17 +799,17 @@ static void testGetCRLFromStore(void)
     flags = 0xffffffff;
     context = CertGetCRLFromStore(store, NULL, NULL, &flags);
     ok(!context && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
 
     /* Test an empty store */
     flags = 0;
     context = CertGetCRLFromStore(store, NULL, NULL, &flags);
     ok(context == NULL && GetLastError() == CRYPT_E_NOT_FOUND,
-     "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
 
     ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL,
      sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL);
-    ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
 
     /* NULL matches any CRL */
     flags = 0;
@@ -820,17 +820,17 @@ static void testGetCRLFromStore(void)
     /* This cert's issuer isn't in */
     cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert2,
      sizeof(bigCert2));
-    ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
     context = CertGetCRLFromStore(store, cert, NULL, &flags);
     ok(context == NULL && GetLastError() == CRYPT_E_NOT_FOUND,
-     "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
     CertFreeCertificateContext(cert);
 
     /* But this one is */
     cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
      sizeof(bigCert));
-    ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
     context = CertGetCRLFromStore(store, cert, NULL, &flags);
     ok(context != NULL, "Expected a context\n");
@@ -851,10 +851,10 @@ static void checkCRLHash(const BYTE *data, DWORD dataLen, ALG_ID algID,
     memset(hashProperty, 0, sizeof(hashProperty));
     size = sizeof(hash);
     ret = CryptHashCertificate(0, algID, 0, data, dataLen, hash, &size);
-    ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError());
+    ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError());
     ret = CertGetCRLContextProperty(context, propID, hashProperty, &size);
-    ok(ret, "CertGetCRLContextProperty failed: %08x\n", GetLastError());
-    ok(!memcmp(hash, hashProperty, size), "Unexpected hash for property %d\n",
+    ok(ret, "CertGetCRLContextProperty failed: %08lx\n", GetLastError());
+    ok(!memcmp(hash, hashProperty, size), "Unexpected hash for property %ld\n",
      propID);
 }
 
@@ -863,7 +863,7 @@ static void testCRLProperties(void)
     PCCRL_CONTEXT context = CertCreateCRLContext(X509_ASN_ENCODING,
      CRL, sizeof(CRL));
 
-    ok(context != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
+    ok(context != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
     if (context)
     {
         DWORD propID, numProps, access, size;
@@ -882,12 +882,12 @@ static void testCRLProperties(void)
             if (propID)
                 numProps++;
         } while (propID != 0);
-        ok(numProps == 0, "Expected 0 properties, got %d\n", numProps);
+        ok(numProps == 0, "Expected 0 properties, got %ld\n", numProps);
 
         /* Tests with a NULL cert context.  Prop ID 0 fails.. */
         ret = CertSetCRLContextProperty(NULL, 0, 0, NULL);
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
         /* while this just crashes.
         ret = CertSetCRLContextProperty(NULL, CERT_KEY_PROV_HANDLE_PROP_ID, 0,
          NULL);
@@ -895,7 +895,7 @@ static void testCRLProperties(void)
 
         ret = CertSetCRLContextProperty(context, 0, 0, NULL);
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
         /* Can't set the cert property directly, this crashes.
         ret = CertSetCRLContextProperty(context, CERT_CRL_PROP_ID, 0, CRL);
          */
@@ -912,14 +912,14 @@ static void testCRLProperties(void)
         ret = CertGetCRLContextProperty(context, CERT_KEY_PROV_INFO_PROP_ID,
          NULL, &size);
         ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
-         "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+         "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
         /* And, an implicit property */
         ret = CertGetCRLContextProperty(context, CERT_ACCESS_STATE_PROP_ID,
          NULL, &size);
-        ok(ret, "CertGetCRLContextProperty failed: %08x\n", GetLastError());
+        ok(ret, "CertGetCRLContextProperty failed: %08lx\n", GetLastError());
         ret = CertGetCRLContextProperty(context, CERT_ACCESS_STATE_PROP_ID,
          &access, &size);
-        ok(ret, "CertGetCRLContextProperty failed: %08x\n", GetLastError());
+        ok(ret, "CertGetCRLContextProperty failed: %08lx\n", GetLastError());
         ok(!(access & CERT_ACCESS_STATE_WRITE_PERSIST_FLAG),
          "Didn't expect a persisted crl\n");
         /* Trying to set this "read only" property crashes.
@@ -932,16 +932,16 @@ static void testCRLProperties(void)
         blob.pbData = hash;
         blob.cbData = sizeof(hash);
         ret = CertSetCRLContextProperty(context, CERT_HASH_PROP_ID, 0, &blob);
-        ok(ret, "CertSetCRLContextProperty failed: %08x\n",
+        ok(ret, "CertSetCRLContextProperty failed: %08lx\n",
          GetLastError());
         size = sizeof(hashProperty);
         ret = CertGetCRLContextProperty(context, CERT_HASH_PROP_ID,
          hashProperty, &size);
-        ok(ret, "CertSetCRLContextProperty failed: %08x\n", GetLastError());
+        ok(ret, "CertSetCRLContextProperty failed: %08lx\n", GetLastError());
         ok(!memcmp(hashProperty, hash, sizeof(hash)), "Unexpected hash\n");
         /* Delete the (bogus) hash, and get the real one */
         ret = CertSetCRLContextProperty(context, CERT_HASH_PROP_ID, 0, NULL);
-        ok(ret, "CertSetCRLContextProperty failed: %08x\n", GetLastError());
+        ok(ret, "CertSetCRLContextProperty failed: %08lx\n", GetLastError());
         checkCRLHash(CRL, sizeof(CRL), CALG_SHA1, context, CERT_HASH_PROP_ID);
 
         /* Now that the hash property is set, we should get one property when
@@ -954,7 +954,7 @@ static void testCRLProperties(void)
             if (propID)
                 numProps++;
         } while (propID != 0);
-        ok(numProps == 1, "Expected 1 properties, got %d\n", numProps);
+        ok(numProps == 1, "Expected 1 properties, got %ld\n", numProps);
 
         /* Check a few other implicit properties */
         checkCRLHash(CRL, sizeof(CRL), CALG_MD5, context,
@@ -989,10 +989,10 @@ static void testIsValidCRLForCert(void)
 
     crl = CertCreateCRLContext(X509_ASN_ENCODING, v1CRLWithIssuerAndEntry,
      sizeof(v1CRLWithIssuerAndEntry));
-    ok(crl != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
+    ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
     cert1 = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
      sizeof(bigCert));
-    ok(cert1 != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(cert1 != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
 
     /* Crash
@@ -1002,15 +1002,15 @@ static void testIsValidCRLForCert(void)
 
     /* Curiously, any CRL is valid for the NULL certificate */
     ret = pCertIsValidCRLForCertificate(NULL, crl, 0, NULL);
-    ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
+    ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
 
     /* Same issuer for both cert and CRL, this CRL is valid for that cert */
     ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL);
-    ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
+    ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
 
     cert2 = CertCreateCertificateContext(X509_ASN_ENCODING,
      bigCertWithDifferentIssuer, sizeof(bigCertWithDifferentIssuer));
-    ok(cert2 != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(cert2 != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
 
     /* Yet more curious: different issuers for these, yet the CRL is valid for
@@ -1018,7 +1018,7 @@ static void testIsValidCRLForCert(void)
      * CRL has a CRL_ISSUING_DIST_POINT extension.
      */
     ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL);
-    ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
+    ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
 
     CertFreeCRLContext(crl);
 
@@ -1027,38 +1027,38 @@ static void testIsValidCRLForCert(void)
      */
     crl = CertCreateCRLContext(X509_ASN_ENCODING, v2CRLWithIssuingDistPoint,
      sizeof(v2CRLWithIssuingDistPoint));
-    ok(crl != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
+    ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
 
     ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL);
     ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
-     "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
     ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL);
     ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
-     "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
 
     /* With a CRL_ISSUING_DIST_POINT in the CRL, it matches the cert containing
      * a CRL_DIST_POINTS_INFO extension.
      */
     cert3 = CertCreateCertificateContext(X509_ASN_ENCODING,
      bigCertWithCRLDistPoints, sizeof(bigCertWithCRLDistPoints));
-    ok(cert3 != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(cert3 != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
     ret = pCertIsValidCRLForCertificate(cert3, crl, 0, NULL);
-    ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
+    ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
 
     CertFreeCRLContext(crl);
 
     /* And again, with a real CRL, the CRL is valid for all three certs. */
     crl = CertCreateCRLContext(X509_ASN_ENCODING, verisignCRL,
      sizeof(verisignCRL));
-    ok(crl != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
+    ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
 
     ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL);
-    ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
+    ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
     ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL);
-    ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
+    ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
     ret = pCertIsValidCRLForCertificate(cert3, crl, 0, NULL);
-    ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
+    ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
 
     CertFreeCRLContext(crl);
 
@@ -1067,18 +1067,18 @@ static void testIsValidCRLForCert(void)
      */
     store = CertOpenStore(CERT_STORE_PROV_MEMORY, X509_ASN_ENCODING, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
 
     ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, verisignCRL,
      sizeof(verisignCRL), CERT_STORE_ADD_ALWAYS, &crl);
-    ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
 
     ret = pCertIsValidCRLForCertificate(cert1, crl, 0, NULL);
-    ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
+    ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
     ret = pCertIsValidCRLForCertificate(cert2, crl, 0, NULL);
-    ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
+    ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
     ret = pCertIsValidCRLForCertificate(cert3, crl, 0, NULL);
-    ok(ret, "CertIsValidCRLForCertificate failed: %08x\n", GetLastError());
+    ok(ret, "CertIsValidCRLForCertificate failed: %08lx\n", GetLastError());
 
     CertFreeCRLContext(crl);
 
@@ -1111,7 +1111,7 @@ static void testFindCertInCRL(void)
 
     cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
      sizeof(bigCert));
-    ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(cert != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
 
     /* Crash
@@ -1127,14 +1127,14 @@ static void testFindCertInCRL(void)
     crl = CertCreateCRLContext(X509_ASN_ENCODING, verisignCRL,
      sizeof(verisignCRL));
     ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, &entry);
-    ok(ret, "CertFindCertificateInCRL failed: %08x\n", GetLastError());
+    ok(ret, "CertFindCertificateInCRL failed: %08lx\n", GetLastError());
     ok(entry == NULL, "Expected not to find an entry in CRL\n");
     CertFreeCRLContext(crl);
 
     crl = CertCreateCRLContext(X509_ASN_ENCODING, v1CRLWithIssuerAndEntry,
      sizeof(v1CRLWithIssuerAndEntry));
     ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, &entry);
-    ok(ret, "CertFindCertificateInCRL failed: %08x\n", GetLastError());
+    ok(ret, "CertFindCertificateInCRL failed: %08lx\n", GetLastError());
     ok(entry != NULL, "Expected to find an entry in CRL\n");
     CertFreeCRLContext(crl);
 
@@ -1142,7 +1142,7 @@ static void testFindCertInCRL(void)
     crl = CertCreateCRLContext(X509_ASN_ENCODING, crlWithDifferentIssuer,
      sizeof(crlWithDifferentIssuer));
     ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, &entry);
-    ok(ret, "CertFindCertificateInCRL failed: %08x\n", GetLastError());
+    ok(ret, "CertFindCertificateInCRL failed: %08lx\n", GetLastError());
     ok(entry != NULL, "Expected to find an entry in CRL\n");
     CertFreeCRLContext(crl);
 
@@ -1156,18 +1156,18 @@ static void testVerifyCRLRevocation(void)
     PCCRL_CONTEXT crl;
 
     ret = CertVerifyCRLRevocation(0, NULL, 0, NULL);
-    ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
+    ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
     ret = CertVerifyCRLRevocation(X509_ASN_ENCODING, NULL, 0, NULL);
-    ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
+    ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
 
     cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
      sizeof(bigCert));
 
     /* Check against no CRL */
     ret = CertVerifyCRLRevocation(0, cert->pCertInfo, 0, NULL);
-    ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
+    ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
     ret = CertVerifyCRLRevocation(X509_ASN_ENCODING, cert->pCertInfo, 0, NULL);
-    ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
+    ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
 
     /* Check against CRL with entry for the cert */
     crl = CertCreateCRLContext(X509_ASN_ENCODING, v1CRLWithIssuerAndEntry,
@@ -1183,7 +1183,7 @@ static void testVerifyCRLRevocation(void)
     /* Check against CRL with different issuer and entry for the cert */
     crl = CertCreateCRLContext(X509_ASN_ENCODING, crlWithDifferentIssuer,
      sizeof(crlWithDifferentIssuer));
-    ok(crl != NULL, "CertCreateCRLContext failed: %08x\n", GetLastError());
+    ok(crl != NULL, "CertCreateCRLContext failed: %08lx\n", GetLastError());
     ret = CertVerifyCRLRevocation(X509_ASN_ENCODING, cert->pCertInfo, 1,
      (PCRL_INFO *)&crl->pCrlInfo);
     ok(!ret, "CertVerifyCRLRevocation should have been revoked\n");
@@ -1194,10 +1194,10 @@ static void testVerifyCRLRevocation(void)
      sizeof(verisignCRL));
     ret = CertVerifyCRLRevocation(0, cert->pCertInfo, 1,
      (PCRL_INFO *)&crl->pCrlInfo);
-    ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
+    ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
     ret = CertVerifyCRLRevocation(X509_ASN_ENCODING, cert->pCertInfo, 1,
      (PCRL_INFO *)&crl->pCrlInfo);
-    ok(ret, "CertVerifyCRLRevocation failed: %08x\n", GetLastError());
+    ok(ret, "CertVerifyCRLRevocation failed: %08lx\n", GetLastError());
     CertFreeCRLContext(crl);
 
     CertFreeCertificateContext(cert);
diff --git a/dlls/crypt32/tests/ctl.c b/dlls/crypt32/tests/ctl.c
index 79a60f8c6ee..c94727cda04 100644
--- a/dlls/crypt32/tests/ctl.c
+++ b/dlls/crypt32/tests/ctl.c
@@ -114,13 +114,13 @@ static void testCreateCTL(void)
     SetLastError(0xdeadbeef);
     ctl = CertCreateCTLContext(0, NULL, 0);
     ok(!ctl && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ctl = CertCreateCTLContext(X509_ASN_ENCODING, NULL, 0);
     ok(!ctl &&
      (GetLastError() == ERROR_INVALID_DATA ||
       GetLastError() == OSS_MORE_INPUT), /* win9x */
-     "expected ERROR_INVALID_DATA, got %d (0x%08x)\n", GetLastError(),
+     "expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", GetLastError(),
      GetLastError());
     /* An empty CTL can't be created.. */
     SetLastError(0xdeadbeef);
@@ -128,7 +128,7 @@ static void testCreateCTL(void)
     ok(!ctl &&
      (GetLastError() == ERROR_INVALID_DATA ||
       GetLastError() == OSS_DATA_ERROR), /* win9x */
-     "expected ERROR_INVALID_DATA, got %d (0x%08x)\n", GetLastError(),
+     "expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", GetLastError(),
      GetLastError());
     /* Nor can any of these "signed" CTLs whose inner content OID isn't
      * szOID_CTL.
@@ -139,7 +139,7 @@ static void testCreateCTL(void)
      (GetLastError() == ERROR_INVALID_DATA ||
       GetLastError() == CRYPT_E_UNEXPECTED_MSG_TYPE /* win9x */ ||
       GetLastError() == ERROR_SUCCESS /* some win98 */),
-     "expected ERROR_INVALID_DATA, CRYPT_E_UNEXPECTED_MSG_TYPE, or ERROR_SUCCESS, got %d (0x%08x)\n", GetLastError(),
+     "expected ERROR_INVALID_DATA, CRYPT_E_UNEXPECTED_MSG_TYPE, or ERROR_SUCCESS, got %ld (0x%08lx)\n", GetLastError(),
      GetLastError());
     SetLastError(0xdeadbeef);
     ctl = CertCreateCTLContext(X509_ASN_ENCODING, ctlWithOneEntry,
@@ -149,7 +149,7 @@ static void testCreateCTL(void)
       GetLastError() == CRYPT_E_UNEXPECTED_MSG_TYPE /* win9x */ ||
       GetLastError() == OSS_DATA_ERROR /* some win98 */ ||
       GetLastError() == ERROR_SUCCESS /* some win98 */),
-     "expected ERROR_INVALID_DATA, CRYPT_E_UNEXPECTED_MSG_TYPE, OSS_DATA_ERROR, or ERROR_SUCCESS, got %d (0x%08x)\n", GetLastError(),
+     "expected ERROR_INVALID_DATA, CRYPT_E_UNEXPECTED_MSG_TYPE, OSS_DATA_ERROR, or ERROR_SUCCESS, got %ld (0x%08lx)\n", GetLastError(),
      GetLastError());
     SetLastError(0xdeadbeef);
     ctl = CertCreateCTLContext(X509_ASN_ENCODING,
@@ -158,13 +158,13 @@ static void testCreateCTL(void)
      (GetLastError() == ERROR_INVALID_DATA ||
       GetLastError() == CRYPT_E_UNEXPECTED_MSG_TYPE /* win9x */ ||
       GetLastError() == ERROR_SUCCESS /* some win98 */),
-     "expected ERROR_INVALID_DATA, got %d (0x%08x)\n", GetLastError(),
+     "expected ERROR_INVALID_DATA, got %ld (0x%08lx)\n", GetLastError(),
      GetLastError());
     /* This signed CTL with the appropriate inner content type can be decoded.
      */
     ctl = CertCreateCTLContext(X509_ASN_ENCODING,
      signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent));
-    ok(ctl != NULL, "CertCreateCTLContext failed: %08x\n", GetLastError());
+    ok(ctl != NULL, "CertCreateCTLContext failed: %08lx\n", GetLastError());
     if (ctl)
     {
         /* Even though the CTL was decoded with X509_ASN_ENCODING, the
@@ -172,7 +172,7 @@ static void testCreateCTL(void)
          */
         ok(ctl->dwMsgAndCertEncodingType ==
          (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING),
-         "expected X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, got %08x\n",
+         "expected X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, got %08lx\n",
          ctl->dwMsgAndCertEncodingType);
         CertFreeCTLContext(ctl);
     }
@@ -182,7 +182,7 @@ static void testCreateCTL(void)
     ctl = CertCreateCTLContext(X509_ASN_ENCODING,
      signedCTLWithCTLInnerContentAndBadSig,
      sizeof(signedCTLWithCTLInnerContentAndBadSig));
-    ok(ctl != NULL, "CertCreateCTLContext failed: %08x\n", GetLastError());
+    ok(ctl != NULL, "CertCreateCTLContext failed: %08lx\n", GetLastError());
     if (ctl)
         CertFreeCTLContext(ctl);
 }
@@ -221,12 +221,12 @@ static void checkHash(const BYTE *data, DWORD dataLen, ALG_ID algID,
     memset(hashProperty, 0, sizeof(hashProperty));
     size = sizeof(hash);
     ret = CryptHashCertificate(0, algID, 0, data, dataLen, hash, &size);
-    ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError());
+    ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError());
     ret = CertGetCTLContextProperty(context, propID, hashProperty, &size);
-    ok(ret, "CertGetCTLContextProperty failed: %08x\n", GetLastError());
+    ok(ret, "CertGetCTLContextProperty failed: %08lx\n", GetLastError());
     if (ret)
         ok(!memcmp(hash, hashProperty, size),
-         "Unexpected hash for property %d\n", propID);
+         "Unexpected hash for property %ld\n", propID);
 }
 
 static void testCTLProperties(void)
@@ -239,7 +239,7 @@ static void testCTLProperties(void)
      signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent));
     if (!ctl)
     {
-        skip("CertCreateCTLContext failed: %08x\n", GetLastError());
+        skip("CertCreateCTLContext failed: %08lx\n", GetLastError());
         return;
     }
 
@@ -251,17 +251,17 @@ static void testCTLProperties(void)
         if (propID)
             numProps++;
     } while (propID != 0);
-    ok(numProps == 0, "Expected 0 properties, got %d\n", numProps);
+    ok(numProps == 0, "Expected 0 properties, got %ld\n", numProps);
 
     /* An implicit property */
     ret = CertGetCTLContextProperty(ctl, CERT_ACCESS_STATE_PROP_ID, NULL,
      &size);
     ok(ret || broken(GetLastError() == CRYPT_E_NOT_FOUND /* some win98 */),
-     "CertGetCTLContextProperty failed: %08x\n", GetLastError());
+     "CertGetCTLContextProperty failed: %08lx\n", GetLastError());
     ret = CertGetCTLContextProperty(ctl, CERT_ACCESS_STATE_PROP_ID, &access,
      &size);
     ok(ret || broken(GetLastError() == CRYPT_E_NOT_FOUND /* some win98 */),
-     "CertGetCTLContextProperty failed: %08x\n", GetLastError());
+     "CertGetCTLContextProperty failed: %08lx\n", GetLastError());
     if (ret)
         ok(!(access & CERT_ACCESS_STATE_WRITE_PERSIST_FLAG),
          "Didn't expect a persisted cert\n");
@@ -279,7 +279,7 @@ static void testCTLProperties(void)
         if (propID)
             numProps++;
     } while (propID != 0);
-    ok(numProps == 1, "Expected 1 properties, got %d\n", numProps);
+    ok(numProps == 1, "Expected 1 properties, got %ld\n", numProps);
 
     checkHash(signedCTLWithCTLInnerContent,
      sizeof(signedCTLWithCTLInnerContent), CALG_MD5, ctl,
@@ -360,12 +360,12 @@ static void testAddCTLToStore(void)
     ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING,
      signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent),
      CERT_STORE_ADD_ALWAYS, NULL);
-    ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError());
     ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING,
      signedCTLWithCTLInnerContentAndBadSig,
      sizeof(signedCTLWithCTLInnerContentAndBadSig), CERT_STORE_ADD_ALWAYS,
      NULL);
-    ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError());
     /* Check that two exist */
     numCTLs = 0;
     ctl = NULL;
@@ -374,7 +374,7 @@ static void testAddCTLToStore(void)
         if (ctl)
             numCTLs++;
     } while (ctl);
-    ok(numCTLs == 2, "expected 2 CTLs, got %d\n", numCTLs);
+    ok(numCTLs == 2, "expected 2 CTLs, got %ld\n", numCTLs);
     CertCloseStore(store, 0);
 
     store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
@@ -383,7 +383,7 @@ static void testAddCTLToStore(void)
     ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING,
      signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent),
      CERT_STORE_ADD_NEW, NULL);
-    ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError());
     /* so adding the second CTL fails. */
     SetLastError(0xdeadbeef);
     ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING,
@@ -391,7 +391,7 @@ static void testAddCTLToStore(void)
      sizeof(signedCTLWithCTLInnerContentAndBadSig), CERT_STORE_ADD_NEW,
      NULL);
     ok(!ret && (GetLastError() == CRYPT_E_EXISTS || GetLastError() == OSS_DATA_ERROR),
-     "expected CRYPT_E_EXISTS or OSS_DATA_ERROR, got %d %08x\n", ret, GetLastError());
+     "expected CRYPT_E_EXISTS or OSS_DATA_ERROR, got %d %08lx\n", ret, GetLastError());
     CertCloseStore(store, 0);
 
     store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
@@ -402,13 +402,13 @@ static void testAddCTLToStore(void)
     ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING,
      signedCTLWithCTLInnerContent, sizeof(signedCTLWithCTLInnerContent),
      CERT_STORE_ADD_NEW, NULL);
-    ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError());
     expectedCTLs = 1;
     ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING,
      signedCTLWithUsage, sizeof(signedCTLWithUsage), CERT_STORE_ADD_NEW,
      NULL);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* some win98 */),
-       "CertAddEncodedCTLToStore failed: %08x\n", GetLastError());
+       "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError());
     if (ret)
         expectedCTLs++;
     /* Check that two exist */
@@ -419,7 +419,7 @@ static void testAddCTLToStore(void)
         if (ctl)
             numCTLs++;
     } while (ctl);
-    ok(numCTLs == expectedCTLs, "expected %d CTLs, got %d\n", expectedCTLs,
+    ok(numCTLs == expectedCTLs, "expected %ld CTLs, got %ld\n", expectedCTLs,
        numCTLs);
     CertCloseStore(store, 0);
 
@@ -436,11 +436,11 @@ static void testAddCTLToStore(void)
         skip("adding a CTL with an empty usage not supported\n");
         return;
     }
-    ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError());
     ret = CertAddEncodedCTLToStore(store, X509_ASN_ENCODING,
      signedCTLWithListID2, sizeof(signedCTLWithListID2), CERT_STORE_ADD_NEW,
      NULL);
-    ok(ret, "CertAddEncodedCTLToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCTLToStore failed: %08lx\n", GetLastError());
     /* Check that two exist */
     numCTLs = 0;
     ctl = NULL;
@@ -449,7 +449,7 @@ static void testAddCTLToStore(void)
         if (ctl)
             numCTLs++;
     } while (ctl);
-    ok(numCTLs == 2, "expected 2 CTLs, got %d\n", numCTLs);
+    ok(numCTLs == 2, "expected 2 CTLs, got %ld\n", numCTLs);
     CertCloseStore(store, 0);
 }
 
diff --git a/dlls/crypt32/tests/encode.c b/dlls/crypt32/tests/encode.c
index 9353bd201a7..3ba6b2680a7 100644
--- a/dlls/crypt32/tests/encode.c
+++ b/dlls/crypt32/tests/encode.c
@@ -110,7 +110,7 @@ static void test_encodeInt(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(0, X509_INTEGER, &ints[0].val, 0, NULL, NULL,
      &bufSize);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
     if (0)
     {
         /* check with NULL integer buffer.  Windows XP incorrectly returns an
@@ -119,17 +119,17 @@ static void test_encodeInt(DWORD dwEncoding)
         ret = pCryptEncodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, NULL, NULL,
          &bufSize);
         ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
-         "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
+         "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
     }
     for (i = 0; i < ARRAY_SIZE(ints); i++)
     {
         /* encode as normal integer */
         ret = pCryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, 0,
          NULL, NULL, &bufSize);
-        ok(ret, "Expected success, got %d\n", GetLastError());
+        ok(ret, "Expected success, got %ld\n", GetLastError());
         ret = pCryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-        ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError());
         if (ret)
         {
             ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n",
@@ -145,10 +145,10 @@ static void test_encodeInt(DWORD dwEncoding)
         blob.pbData = (BYTE *)&ints[i].val;
         ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob,
          0, NULL, NULL, &bufSize);
-        ok(ret, "Expected success, got %d\n", GetLastError());
+        ok(ret, "Expected success, got %ld\n", GetLastError());
         ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-        ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError());
         if (ret)
         {
             ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n",
@@ -169,10 +169,10 @@ static void test_encodeInt(DWORD dwEncoding)
         blob.pbData = (BYTE *)bigInts[i].val;
         ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob,
          0, NULL, NULL, &bufSize);
-        ok(ret, "Expected success, got %d\n", GetLastError());
+        ok(ret, "Expected success, got %ld\n", GetLastError());
         ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-        ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError());
         if (ret)
         {
             ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n",
@@ -192,10 +192,10 @@ static void test_encodeInt(DWORD dwEncoding)
         blob.pbData = (BYTE*)bigUInts[i].val;
         ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob,
          0, NULL, NULL, &bufSize);
-        ok(ret, "Expected success, got %d\n", GetLastError());
+        ok(ret, "Expected success, got %ld\n", GetLastError());
         ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-        ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError());
         if (ret)
         {
             ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n",
@@ -230,25 +230,25 @@ static void test_decodeInt(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(3, X509_INTEGER, (BYTE *)&ints[0].encoded,
      ints[0].encoded[1] + 2, 0, NULL, NULL, &bufSize);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
     /* check with NULL integer buffer */
     ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, 0, NULL, NULL,
      &bufSize);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD ||
      GetLastError() == OSS_BAD_ARG /* Win9x */),
-     "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08lx\n", GetLastError());
     /* check with a valid, but too large, integer */
     ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, bigInt, bigInt[1] + 2,
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
     ok((!ret && GetLastError() == CRYPT_E_ASN1_LARGE) ||
      broken(ret) /* Win9x */,
-     "Expected CRYPT_E_ASN1_LARGE, got %d\n", GetLastError());
+     "Expected CRYPT_E_ASN1_LARGE, got %ld\n", GetLastError());
     /* check with a DER-encoded string */
     ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, testStr, testStr[1] + 2,
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
      GetLastError() == OSS_PDU_MISMATCH /* Win9x */ ),
-     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %08x\n",
+     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %08lx\n",
      GetLastError());
     for (i = 0; i < ARRAY_SIZE(ints); i++)
     {
@@ -258,12 +258,12 @@ static void test_decodeInt(DWORD dwEncoding)
          ints[i].encoded, ints[i].encoded[1] + 2, 0, NULL, NULL,
          &bufSize);
         ok(ret && GetLastError() == NOERROR,
-         "Expected success and NOERROR, got %d\n", GetLastError());
+         "Expected success and NOERROR, got %ld\n", GetLastError());
         ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER,
          ints[i].encoded, ints[i].encoded[1] + 2,
          CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-        ok(ret, "CryptDecodeObjectEx failed: %d\n", GetLastError());
-        ok(bufSize == sizeof(int), "Wrong size %d\n", bufSize);
+        ok(ret, "CryptDecodeObjectEx failed: %ld\n", GetLastError());
+        ok(bufSize == sizeof(int), "Wrong size %ld\n", bufSize);
         ok(buf != NULL, "Expected allocated buffer\n");
         if (ret)
         {
@@ -278,19 +278,19 @@ static void test_decodeInt(DWORD dwEncoding)
          bigInts[i].encoded, bigInts[i].encoded[1] + 2, 0, NULL, NULL,
          &bufSize);
         ok(ret && GetLastError() == NOERROR,
-         "Expected success and NOERROR, got %d\n", GetLastError());
+         "Expected success and NOERROR, got %ld\n", GetLastError());
         ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER,
          bigInts[i].encoded, bigInts[i].encoded[1] + 2,
          CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-        ok(ret, "CryptDecodeObjectEx failed: %d\n", GetLastError());
-        ok(bufSize >= sizeof(CRYPT_INTEGER_BLOB), "Wrong size %d\n", bufSize);
+        ok(ret, "CryptDecodeObjectEx failed: %ld\n", GetLastError());
+        ok(bufSize >= sizeof(CRYPT_INTEGER_BLOB), "Wrong size %ld\n", bufSize);
         ok(buf != NULL, "Expected allocated buffer\n");
         if (ret)
         {
             CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)buf;
 
             ok(blob->cbData == strlen((const char*)bigInts[i].decoded),
-             "Expected len %d, got %d\n", lstrlenA((const char*)bigInts[i].decoded),
+             "Expected len %d, got %ld\n", lstrlenA((const char*)bigInts[i].decoded),
              blob->cbData);
             ok(!memcmp(blob->pbData, bigInts[i].decoded, blob->cbData),
              "Unexpected value\n");
@@ -303,19 +303,19 @@ static void test_decodeInt(DWORD dwEncoding)
          bigUInts[i].encoded, bigUInts[i].encoded[1] + 2, 0, NULL, NULL,
          &bufSize);
         ok(ret && GetLastError() == NOERROR,
-         "Expected success and NOERROR, got %d\n", GetLastError());
+         "Expected success and NOERROR, got %ld\n", GetLastError());
         ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT,
          bigUInts[i].encoded, bigUInts[i].encoded[1] + 2,
          CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-        ok(ret, "CryptDecodeObjectEx failed: %d\n", GetLastError());
-        ok(bufSize >= sizeof(CRYPT_INTEGER_BLOB), "Wrong size %d\n", bufSize);
+        ok(ret, "CryptDecodeObjectEx failed: %ld\n", GetLastError());
+        ok(bufSize >= sizeof(CRYPT_INTEGER_BLOB), "Wrong size %ld\n", bufSize);
         ok(buf != NULL, "Expected allocated buffer\n");
         if (ret)
         {
             CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)buf;
 
             ok(blob->cbData == strlen((const char*)bigUInts[i].val),
-             "Expected len %d, got %d\n", lstrlenA((const char*)bigUInts[i].val),
+             "Expected len %d, got %ld\n", lstrlenA((const char*)bigUInts[i].val),
              blob->cbData);
             ok(!memcmp(blob->pbData, bigUInts[i].val, blob->cbData),
              "Unexpected value\n");
@@ -325,7 +325,7 @@ static void test_decodeInt(DWORD dwEncoding)
     /* Decode the value 1 with long-form length */
     ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, longForm,
      sizeof(longForm), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(*(int *)buf == 1, "Expected 1, got %d\n", *(int *)buf);
@@ -334,7 +334,7 @@ static void test_decodeInt(DWORD dwEncoding)
     /* check with extra bytes at the end */
     ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, extraBytes,
      sizeof(extraBytes), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(*(int *)buf == 1, "Expected 1, got %d\n", *(int *)buf);
@@ -360,7 +360,7 @@ static void test_decodeInt(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, bigBogus,
      0x01ffffff, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
     ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
-     "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
+     "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
     }
 }
 
@@ -396,7 +396,7 @@ static void test_encodeEnumerated(DWORD dwEncoding)
             ret = pCryptEncodeObjectEx(dwEncoding, enumeratedTypes[i],
              &enums[j].val, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf,
              &bufSize);
-            ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError());
+            ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError());
             if (ret)
             {
                 ok(buf[0] == 0xa,
@@ -429,9 +429,9 @@ static void test_decodeEnumerated(DWORD dwEncoding)
             ret = pCryptDecodeObjectEx(dwEncoding, enumeratedTypes[i],
              enums[j].encoded, enums[j].encoded[1] + 2, 0, NULL,
              &val, &bufSize);
-            ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+            ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
             ok(bufSize == sizeof(int),
-             "Got unexpected size %d for enumerated\n", bufSize);
+             "Got unexpected size %ld for enumerated\n", bufSize);
             ok(val == enums[j].val, "Unexpected value %d, expected %d\n",
              val, enums[j].val);
         }
@@ -453,7 +453,7 @@ static void testTimeEncoding(DWORD dwEncoding, LPCSTR structType,
     BOOL ret;
 
     ret = SystemTimeToFileTime(&time->sysTime, &ft);
-    ok(ret, "SystemTimeToFileTime failed: %d\n", GetLastError());
+    ok(ret, "SystemTimeToFileTime failed: %ld\n", GetLastError());
     ret = pCryptEncodeObjectEx(dwEncoding, structType, &ft,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
     /* years other than 1950-2050 are not allowed for encodings other than
@@ -462,7 +462,7 @@ static void testTimeEncoding(DWORD dwEncoding, LPCSTR structType,
     if (structType == X509_CHOICE_OF_TIME ||
      (time->sysTime.wYear >= 1950 && time->sysTime.wYear <= 2050))
     {
-        ok(ret, "CryptEncodeObjectEx failed: %d (0x%08x)\n", GetLastError(),
+        ok(ret, "CryptEncodeObjectEx failed: %ld (0x%08lx)\n", GetLastError(),
          GetLastError());
         ok(buf != NULL, "Expected an allocated buffer\n");
         if (ret)
@@ -470,7 +470,7 @@ static void testTimeEncoding(DWORD dwEncoding, LPCSTR structType,
             ok(buf[0] == time->encodedTime[0],
              "Expected type 0x%02x, got 0x%02x\n", time->encodedTime[0],
              buf[0]);
-            ok(buf[1] == time->encodedTime[1], "Expected %d bytes, got %d\n",
+            ok(buf[1] == time->encodedTime[1], "Expected %d bytes, got %ld\n",
              time->encodedTime[1], bufSize);
             ok(!memcmp(time->encodedTime + 2, buf + 2, time->encodedTime[1]),
              "Got unexpected value for time encoding\n");
@@ -480,7 +480,7 @@ static void testTimeEncoding(DWORD dwEncoding, LPCSTR structType,
     else
         ok((!ret && GetLastError() == CRYPT_E_BAD_ENCODE) ||
          broken(GetLastError() == ERROR_SUCCESS),
-         "Expected CRYPT_E_BAD_ENCODE, got 0x%08x\n", GetLastError());
+         "Expected CRYPT_E_BAD_ENCODE, got 0x%08lx\n", GetLastError());
 }
 
 static const char *printSystemTime(const SYSTEMTIME *st)
@@ -542,7 +542,7 @@ static void testTimeDecoding(DWORD dwEncoding, LPCSTR structType,
      (time->sysTime.wYear >= 1950 && time->sysTime.wYear <= 2050))
     {
         ok(ret || broken(GetLastError() == OSS_DATA_ERROR),
-         "CryptDecodeObjectEx failed: %d (0x%08x)\n", GetLastError(),
+         "CryptDecodeObjectEx failed: %ld (0x%08lx)\n", GetLastError(),
          GetLastError());
         if (ret)
             compareTime(&time->sysTime, &ft);
@@ -550,7 +550,7 @@ static void testTimeDecoding(DWORD dwEncoding, LPCSTR structType,
     else
         ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
          GetLastError() == OSS_PDU_MISMATCH /* Win9x */ ),
-         "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %08x\n",
+         "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %08lx\n",
          GetLastError());
 }
 
@@ -646,12 +646,12 @@ static void test_decodeFiletime(DWORD dwEncoding)
 
     /* Check bogus length with non-NULL buffer */
     ret = SystemTimeToFileTime(&times[0].sysTime, &ft1);
-    ok(ret, "SystemTimeToFileTime failed: %d\n", GetLastError());
+    ok(ret, "SystemTimeToFileTime failed: %ld\n", GetLastError());
     size = 1;
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME,
      times[0].encodedTime, times[0].encodedTime[1] + 2, 0, NULL, &ft2, &size);
     ok(!ret && GetLastError() == ERROR_MORE_DATA,
-     "Expected ERROR_MORE_DATA, got %d\n", GetLastError());
+     "Expected ERROR_MORE_DATA, got %ld\n", GetLastError());
     /* Normal tests */
     for (i = 0; i < ARRAY_SIZE(times); i++)
     {
@@ -673,7 +673,7 @@ static void test_decodeFiletime(DWORD dwEncoding)
         ok((!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT ||
                      GetLastError() == OSS_DATA_ERROR /* Win9x */)) ||
            broken(ret), /* Win9x and NT4 for bin38 */
-         "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n",
+         "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n",
          GetLastError());
     }
 }
@@ -766,14 +766,14 @@ static void test_encodeName(DWORD dwEncoding)
         ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, NULL,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
         ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
-         "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
+         "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
     }
     /* Test with empty CERT_NAME_INFO */
     info.cRDN = 0;
     info.rgRDN = NULL;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(!memcmp(buf, emptySequence, sizeof(emptySequence)),
@@ -787,7 +787,7 @@ static void test_encodeName(DWORD dwEncoding)
         ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
         ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
-         "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
+         "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
     }
     /* Test with empty CERT_RDN */
     rdn.cRDNAttr = 0;
@@ -796,7 +796,7 @@ static void test_encodeName(DWORD dwEncoding)
     info.rgRDN = &rdn;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(!memcmp(buf, emptyRDNs, sizeof(emptyRDNs)),
@@ -811,7 +811,7 @@ static void test_encodeName(DWORD dwEncoding)
         ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
         ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
-         "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
+         "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
     }
     /* oddly, a bogus OID is accepted by Windows XP; not testing.
     attrs[0].pszObjId = "bogus";
@@ -839,7 +839,7 @@ static void test_encodeName(DWORD dwEncoding)
     rdn.rgRDNAttr = attrs;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(!memcmp(buf, twoRDNs, sizeof(twoRDNs)),
@@ -853,10 +853,10 @@ static void test_encodeName(DWORD dwEncoding)
     rdn.cRDNAttr = 1;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(encodedTwoRDNs), "Unexpected size %d\n", size);
+        ok(size == sizeof(encodedTwoRDNs), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, encodedTwoRDNs, size),
          "Unexpected value for re-encoded two RDN array\n");
         LocalFree(buf);
@@ -867,7 +867,7 @@ static void test_encodeName(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* Test a more complex name */
     rdn.cRDNAttr = ARRAY_SIZE(rdnAttrs);
     rdn.rgRDNAttr = rdnAttrs;
@@ -877,10 +877,10 @@ static void test_encodeName(DWORD dwEncoding)
     size = 0;
     ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, X509_NAME, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(encodedRDNAttrs), "Wrong size %d\n", size);
+        ok(size == sizeof(encodedRDNAttrs), "Wrong size %ld\n", size);
         ok(!memcmp(buf, encodedRDNAttrs, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -916,14 +916,14 @@ static void test_encodeUnicodeName(DWORD dwEncoding)
         ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, NULL,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
         ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
-         "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
+         "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
     }
     /* Test with empty CERT_NAME_INFO */
     info.cRDN = 0;
     info.rgRDN = NULL;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(!memcmp(buf, emptySequence, sizeof(emptySequence)),
@@ -944,8 +944,8 @@ static void test_encodeUnicodeName(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_PRINTABLE_STRING,
-     "Expected CRYPT_E_INVALID_PRINTABLE_STRING, got %08x\n", GetLastError());
-    ok(size == 9, "Unexpected error index %08x\n", size);
+     "Expected CRYPT_E_INVALID_PRINTABLE_STRING, got %08lx\n", GetLastError());
+    ok(size == 9, "Unexpected error index %08lx\n", size);
     /* Check with two NULL-terminated CERT_RDN_ATTRs.  Note DER encoding
      * forces the order of the encoded attributes to be swapped.
      */
@@ -963,7 +963,7 @@ static void test_encodeUnicodeName(DWORD dwEncoding)
     info.rgRDN = &rdn;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(!memcmp(buf, twoRDNsNoNull, sizeof(twoRDNsNoNull)),
@@ -977,10 +977,10 @@ static void test_encodeUnicodeName(DWORD dwEncoding)
     rdn.cRDNAttr = 1;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(encodedTwoRDNs), "Unexpected size %d\n", size);
+        ok(size == sizeof(encodedTwoRDNs), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, encodedTwoRDNs, size),
          "Unexpected value for re-encoded two RDN array\n");
         LocalFree(buf);
@@ -990,10 +990,10 @@ static void test_encodeUnicodeName(DWORD dwEncoding)
     attrs[0].dwValueType = CERT_RDN_ANY_TYPE;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    todo_wine ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    todo_wine ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(anyType), "Unexpected size %d\n", size);
+        ok(size == sizeof(anyType), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, anyType, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -1010,16 +1010,16 @@ static void compareNameValues(const CERT_NAME_VALUE *expected,
     }
 
     ok(got->dwValueType == expected->dwValueType,
-     "Expected string type %d, got %d\n", expected->dwValueType,
+     "Expected string type %ld, got %ld\n", expected->dwValueType,
      got->dwValueType);
     ok(got->Value.cbData == expected->Value.cbData ||
      got->Value.cbData == expected->Value.cbData - sizeof(WCHAR) /* Win8 */,
-     "String type %d: unexpected data size, got %d, expected %d\n",
+     "String type %ld: unexpected data size, got %ld, expected %ld\n",
      expected->dwValueType, got->Value.cbData, expected->Value.cbData);
     if (got->Value.cbData && got->Value.pbData)
         ok(!memcmp(got->Value.pbData, expected->Value.pbData,
          min(got->Value.cbData, expected->Value.cbData)),
-         "String type %d: unexpected value\n", expected->dwValueType);
+         "String type %ld: unexpected value\n", expected->dwValueType);
 }
 
 static void compareRDNAttrs(const CERT_RDN_ATTR *expected,
@@ -1043,7 +1043,7 @@ static void compareRDNAttrs(const CERT_RDN_ATTR *expected,
 static void compareRDNs(const CERT_RDN *expected, const CERT_RDN *got)
 {
     ok(got->cRDNAttr == expected->cRDNAttr,
-     "Expected %d RDN attrs, got %d\n", expected->cRDNAttr, got->cRDNAttr);
+     "Expected %ld RDN attrs, got %ld\n", expected->cRDNAttr, got->cRDNAttr);
     if (got->cRDNAttr)
     {
         DWORD i;
@@ -1056,7 +1056,7 @@ static void compareRDNs(const CERT_RDN *expected, const CERT_RDN *got)
 static void compareNames(const CERT_NAME_INFO *expected,
  const CERT_NAME_INFO *got)
 {
-    ok(got->cRDN == expected->cRDN, "Expected %d RDNs, got %d\n",
+    ok(got->cRDN == expected->cRDN, "Expected %ld RDNs, got %ld\n",
      expected->cRDN, got->cRDN);
     if (got->cRDN)
     {
@@ -1087,15 +1087,15 @@ static void test_decodeName(DWORD dwEncoding)
      emptySequence[1] + 2,
      CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL,
      &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     /* Interestingly, in Windows, if cRDN is 0, rgRGN may not be NULL.  My
      * decoder works the same way, so only test the count.
      */
     if (ret)
     {
-        ok(bufSize == sizeof(CERT_NAME_INFO), "Wrong bufSize %d\n", bufSize);
+        ok(bufSize == sizeof(CERT_NAME_INFO), "Wrong bufSize %ld\n", bufSize);
         ok(((CERT_NAME_INFO *)buf)->cRDN == 0,
-         "Expected 0 RDNs in empty info, got %d\n",
+         "Expected 0 RDNs in empty info, got %ld\n",
          ((CERT_NAME_INFO *)buf)->cRDN);
         LocalFree(buf);
     }
@@ -1103,12 +1103,12 @@ static void test_decodeName(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, emptyIndefiniteSequence,
      sizeof(emptyIndefiniteSequence), CRYPT_DECODE_ALLOC_FLAG, NULL,
      &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(bufSize == sizeof(CERT_NAME_INFO), "Wrong bufSize %d\n", bufSize);
+        ok(bufSize == sizeof(CERT_NAME_INFO), "Wrong bufSize %ld\n", bufSize);
         ok(((CERT_NAME_INFO *)buf)->cRDN == 0,
-         "Expected 0 RDNs in empty info, got %d\n",
+         "Expected 0 RDNs in empty info, got %ld\n",
          ((CERT_NAME_INFO *)buf)->cRDN);
         LocalFree(buf);
     }
@@ -1118,7 +1118,7 @@ static void test_decodeName(DWORD dwEncoding)
      emptyRDNs[1] + 2,
      CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL,
      &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_NAME_INFO *info = (CERT_NAME_INFO *)buf;
@@ -1134,7 +1134,7 @@ static void test_decodeName(DWORD dwEncoding)
      twoRDNs[1] + 2,
      CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL,
      &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         static CHAR oid_sur_name[]    = szOID_SUR_NAME,
@@ -1156,13 +1156,13 @@ static void test_decodeName(DWORD dwEncoding)
     bufSize = 0;
     ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, twoRDNsExtraBytes,
      sizeof(twoRDNsExtraBytes), 0, NULL, NULL, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     /* And, a slightly more complicated name */
     buf = NULL;
     bufSize = 0;
     ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_NAME, encodedRDNAttrs,
      sizeof(encodedRDNAttrs), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         rdn.cRDNAttr = ARRAY_SIZE(decodedRdnAttrs);
@@ -1186,13 +1186,13 @@ static void test_decodeUnicodeName(DWORD dwEncoding)
      emptySequence[1] + 2,
      CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL,
      &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(bufSize == sizeof(CERT_NAME_INFO),
-         "Got wrong bufSize %d\n", bufSize);
+         "Got wrong bufSize %ld\n", bufSize);
         ok(((CERT_NAME_INFO *)buf)->cRDN == 0,
-         "Expected 0 RDNs in empty info, got %d\n",
+         "Expected 0 RDNs in empty info, got %ld\n",
          ((CERT_NAME_INFO *)buf)->cRDN);
         LocalFree(buf);
     }
@@ -1202,7 +1202,7 @@ static void test_decodeUnicodeName(DWORD dwEncoding)
      emptyRDNs[1] + 2,
      CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL,
      &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_NAME_INFO *info = (CERT_NAME_INFO *)buf;
@@ -1218,7 +1218,7 @@ static void test_decodeUnicodeName(DWORD dwEncoding)
      sizeof(twoRDNsNoNull),
      CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL,
      &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         static CHAR oid_sur_name[]    = szOID_SUR_NAME,
@@ -1331,10 +1331,10 @@ static void test_encodeNameValue(DWORD dwEncoding)
     value.Value.cbData = sizeof(printableCommonNameValue);
     ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, &value,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(printableCommonNameValue), "Unexpected size %d\n",
+        ok(size == sizeof(printableCommonNameValue), "Unexpected size %ld\n",
          size);
         ok(!memcmp(buf, printableCommonNameValue, size),
          "Unexpected encoding\n");
@@ -1345,12 +1345,12 @@ static void test_encodeNameValue(DWORD dwEncoding)
         ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE,
          &nameValues[i].value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
         ok(ret || broken(GetLastError() == OSS_PDU_MISMATCH) /* NT4/Win9x */,
-         "Type %d: CryptEncodeObjectEx failed: %08x\n",
+         "Type %ld: CryptEncodeObjectEx failed: %08lx\n",
          nameValues[i].value.dwValueType, GetLastError());
         if (ret)
         {
             ok(size == nameValues[i].encodedSize,
-             "Expected size %d, got %d\n", nameValues[i].encodedSize, size);
+             "Expected size %ld, got %ld\n", nameValues[i].encodedSize, size);
             ok(!memcmp(buf, nameValues[i].encoded, size),
              "Got unexpected encoding\n");
             LocalFree(buf);
@@ -1359,12 +1359,12 @@ static void test_encodeNameValue(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE,
      &embeddedNullNameValue.value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(ret || broken(GetLastError() == OSS_PDU_MISMATCH) /* NT4/Win9x */,
-     "Type %d: CryptEncodeObjectEx failed: %08x\n",
+     "Type %ld: CryptEncodeObjectEx failed: %08lx\n",
      embeddedNullNameValue.value.dwValueType, GetLastError());
     if (ret)
     {
         ok(size == embeddedNullNameValue.encodedSize,
-         "Expected size %d, got %d\n", embeddedNullNameValue.encodedSize, size);
+         "Expected size %ld, got %ld\n", embeddedNullNameValue.encodedSize, size);
         ok(!memcmp(buf, embeddedNullNameValue.encoded, size),
          "Got unexpected encoding\n");
         LocalFree(buf);
@@ -1384,7 +1384,7 @@ static void test_decodeNameValue(DWORD dwEncoding)
          nameValues[i].encoded, nameValues[i].encoded[1] + 2,
          CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL,
          &buf, &bufSize);
-        ok(ret, "Value type %d: CryptDecodeObjectEx failed: %08x\n",
+        ok(ret, "Value type %ld: CryptDecodeObjectEx failed: %08lx\n",
          nameValues[i].value.dwValueType, GetLastError());
         if (ret)
         {
@@ -1415,7 +1415,7 @@ static void test_decodeNameValue(DWORD dwEncoding)
          */
         ok(got->dwValueType == CERT_RDN_ENCODED_BLOB ||
          got->dwValueType == CERT_RDN_IA5_STRING,
-         "Expected CERT_RDN_ENCODED_BLOB or CERT_RDN_IA5_STRING, got %d\n",
+         "Expected CERT_RDN_ENCODED_BLOB or CERT_RDN_IA5_STRING, got %ld\n",
          got->dwValueType);
         if (got->dwValueType == CERT_RDN_ENCODED_BLOB)
             expected = &rdnEncodedValue;
@@ -1424,12 +1424,12 @@ static void test_decodeNameValue(DWORD dwEncoding)
         if (expected)
         {
             ok(got->Value.cbData == expected->Value.cbData,
-             "String type %d: unexpected data size, got %d, expected %d\n",
+             "String type %ld: unexpected data size, got %ld, expected %ld\n",
              got->dwValueType, got->Value.cbData, expected->Value.cbData);
             if (got->Value.cbData && got->Value.pbData)
                 ok(!memcmp(got->Value.pbData, expected->Value.pbData,
                  min(got->Value.cbData, expected->Value.cbData)),
-                 "String type %d: unexpected value\n", expected->dwValueType);
+                 "String type %ld: unexpected value\n", expected->dwValueType);
         }
         LocalFree(buf);
     }
@@ -1471,7 +1471,7 @@ static void test_encodeAltName(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (ret)
     {
-        ok(size == sizeof(emptySequence), "Wrong size %d\n", size);
+        ok(size == sizeof(emptySequence), "Wrong size %ld\n", size);
         ok(!memcmp(buf, emptySequence, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -1481,14 +1481,14 @@ static void test_encodeAltName(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* Test with an empty pointer */
     entry.dwAltNameChoice = CERT_ALT_NAME_URL;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (ret)
     {
-        ok(size == sizeof(emptyURL), "Wrong size %d\n", size);
+        ok(size == sizeof(emptyURL), "Wrong size %ld\n", size);
         ok(!memcmp(buf, emptyURL, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -1498,7 +1498,7 @@ static void test_encodeAltName(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (ret)
     {
-        ok(size == sizeof(encodedURL), "Wrong size %d\n", size);
+        ok(size == sizeof(encodedURL), "Wrong size %ld\n", size);
         ok(!memcmp(buf, encodedURL, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -1507,16 +1507,16 @@ static void test_encodeAltName(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_IA5_STRING,
-     "Expected CRYPT_E_INVALID_IA5_STRING, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_IA5_STRING, got %08lx\n", GetLastError());
     /* The first invalid character is at index 7 */
     ok(GET_CERT_ALT_NAME_VALUE_ERR_INDEX(size) == 7,
-     "Expected invalid char at index 7, got %d\n",
+     "Expected invalid char at index 7, got %ld\n",
      GET_CERT_ALT_NAME_VALUE_ERR_INDEX(size));
     /* Now with the URL missing a scheme */
     U(entry).pwszURL = (LPWSTR)dnsName;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         /* This succeeds, but it shouldn't, so don't worry about conforming */
@@ -1526,10 +1526,10 @@ static void test_encodeAltName(DWORD dwEncoding)
     entry.dwAltNameChoice = CERT_ALT_NAME_DNS_NAME;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(encodedDnsName), "Wrong size %d\n", size);
+        ok(size == sizeof(encodedDnsName), "Wrong size %ld\n", size);
         ok(!memcmp(buf, encodedDnsName, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -1541,7 +1541,7 @@ static void test_encodeAltName(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (ret)
     {
-        ok(size == sizeof(encodedIPAddr), "Wrong size %d\n", size);
+        ok(size == sizeof(encodedIPAddr), "Wrong size %ld\n", size);
         ok(!memcmp(buf, encodedIPAddr, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -1552,7 +1552,7 @@ static void test_encodeAltName(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (ret)
     {
-        ok(size == sizeof(encodedOidName), "Wrong size %d\n", size);
+        ok(size == sizeof(encodedOidName), "Wrong size %ld\n", size);
         ok(!memcmp(buf, encodedOidName, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -1564,7 +1564,7 @@ static void test_encodeAltName(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (ret)
     {
-        ok(size == sizeof(encodedDirectoryName), "Wrong size %d\n", size);
+        ok(size == sizeof(encodedDirectoryName), "Wrong size %ld\n", size);
         ok(!memcmp(buf, encodedDirectoryName, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -1593,38 +1593,38 @@ static void test_decodeAltName(DWORD dwEncoding)
      NULL, &buf, &bufSize);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
      GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "Expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08x\n",
+     "Expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08lx\n",
      GetLastError());
     ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME,
      bogusType, sizeof(bogusType), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf,
      &bufSize);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT ||
      GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n",
+     "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n",
      GetLastError());
     /* Now expected cases */
     ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptySequence,
      emptySequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         info = (CERT_ALT_NAME_INFO *)buf;
 
-        ok(info->cAltEntry == 0, "Expected 0 entries, got %d\n",
+        ok(info->cAltEntry == 0, "Expected 0 entries, got %ld\n",
          info->cAltEntry);
         LocalFree(buf);
     }
     ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptyURL,
      emptyURL[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         info = (CERT_ALT_NAME_INFO *)buf;
 
-        ok(info->cAltEntry == 1, "Expected 1 entries, got %d\n",
+        ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n",
          info->cAltEntry);
         ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_URL,
-         "Expected CERT_ALT_NAME_URL, got %d\n",
+         "Expected CERT_ALT_NAME_URL, got %ld\n",
          info->rgAltEntry[0].dwAltNameChoice);
         ok(U(info->rgAltEntry[0]).pwszURL == NULL || !*U(info->rgAltEntry[0]).pwszURL,
          "Expected empty URL\n");
@@ -1632,33 +1632,33 @@ static void test_decodeAltName(DWORD dwEncoding)
     }
     ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME,
      emptyURLExtraBytes, sizeof(emptyURLExtraBytes), 0, NULL, NULL, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedURL,
      encodedURL[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         info = (CERT_ALT_NAME_INFO *)buf;
 
-        ok(info->cAltEntry == 1, "Expected 1 entries, got %d\n",
+        ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n",
          info->cAltEntry);
         ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_URL,
-         "Expected CERT_ALT_NAME_URL, got %d\n",
+         "Expected CERT_ALT_NAME_URL, got %ld\n",
          info->rgAltEntry[0].dwAltNameChoice);
         ok(!lstrcmpW(U(info->rgAltEntry[0]).pwszURL, url), "Unexpected URL\n");
         LocalFree(buf);
     }
     ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedDnsName,
      encodedDnsName[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         info = (CERT_ALT_NAME_INFO *)buf;
 
-        ok(info->cAltEntry == 1, "Expected 1 entries, got %d\n",
+        ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n",
          info->cAltEntry);
         ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_DNS_NAME,
-         "Expected CERT_ALT_NAME_DNS_NAME, got %d\n",
+         "Expected CERT_ALT_NAME_DNS_NAME, got %ld\n",
          info->rgAltEntry[0].dwAltNameChoice);
         ok(!lstrcmpW(U(info->rgAltEntry[0]).pwszDNSName, dnsName),
          "Unexpected DNS name\n");
@@ -1666,18 +1666,18 @@ static void test_decodeAltName(DWORD dwEncoding)
     }
     ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedIPAddr,
      encodedIPAddr[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         info = (CERT_ALT_NAME_INFO *)buf;
 
-        ok(info->cAltEntry == 1, "Expected 1 entries, got %d\n",
+        ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n",
          info->cAltEntry);
         ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_IP_ADDRESS,
-         "Expected CERT_ALT_NAME_IP_ADDRESS, got %d\n",
+         "Expected CERT_ALT_NAME_IP_ADDRESS, got %ld\n",
          info->rgAltEntry[0].dwAltNameChoice);
         ok(U(info->rgAltEntry[0]).IPAddress.cbData == sizeof(localhost),
-         "Unexpected IP address length %d\n",
+         "Unexpected IP address length %ld\n",
           U(info->rgAltEntry[0]).IPAddress.cbData);
         ok(!memcmp(U(info->rgAltEntry[0]).IPAddress.pbData, localhost,
          sizeof(localhost)), "Unexpected IP address value\n");
@@ -1685,15 +1685,15 @@ static void test_decodeAltName(DWORD dwEncoding)
     }
     ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedOidName,
      sizeof(encodedOidName), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         info = (CERT_ALT_NAME_INFO *)buf;
 
-        ok(info->cAltEntry == 1, "Expected 1 entries, got %d\n",
+        ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n",
          info->cAltEntry);
         ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_REGISTERED_ID,
-         "Expected CERT_ALT_NAME_REGISTERED_ID, got %d\n",
+         "Expected CERT_ALT_NAME_REGISTERED_ID, got %ld\n",
          info->rgAltEntry[0].dwAltNameChoice);
         ok(!strcmp(U(info->rgAltEntry[0]).pszRegisteredID, "1.2.3"),
            "Expected OID 1.2.3, got %s\n", U(info->rgAltEntry[0]).pszRegisteredID);
@@ -1702,18 +1702,18 @@ static void test_decodeAltName(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME,
      encodedDirectoryName, sizeof(encodedDirectoryName),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         info = (CERT_ALT_NAME_INFO *)buf;
 
-        ok(info->cAltEntry == 1, "Expected 1 entries, got %d\n",
+        ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n",
          info->cAltEntry);
         ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_DIRECTORY_NAME,
-         "Expected CERT_ALT_NAME_DIRECTORY_NAME, got %d\n",
+         "Expected CERT_ALT_NAME_DIRECTORY_NAME, got %ld\n",
          info->rgAltEntry[0].dwAltNameChoice);
         ok(U(info->rgAltEntry[0]).DirectoryName.cbData ==
-         sizeof(encodedCommonName), "Unexpected directory name length %d\n",
+         sizeof(encodedCommonName), "Unexpected directory name length %ld\n",
           U(info->rgAltEntry[0]).DirectoryName.cbData);
         ok(!memcmp(U(info->rgAltEntry[0]).DirectoryName.pbData,
          encodedCommonName, sizeof(encodedCommonName)),
@@ -1733,15 +1733,15 @@ static void test_decodeAltName(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME,
      dns_embedded_bell, sizeof(dns_embedded_bell), CRYPT_DECODE_ALLOC_FLAG,
      NULL, &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         info = (CERT_ALT_NAME_INFO *)buf;
 
-        ok(info->cAltEntry == 1, "Expected 1 entries, got %d\n",
+        ok(info->cAltEntry == 1, "Expected 1 entries, got %ld\n",
          info->cAltEntry);
         ok(info->rgAltEntry[0].dwAltNameChoice == CERT_ALT_NAME_DNS_NAME,
-         "Expected CERT_ALT_NAME_DNS_NAME, got %d\n",
+         "Expected CERT_ALT_NAME_DNS_NAME, got %ld\n",
          info->rgAltEntry[0].dwAltNameChoice);
         LocalFree(buf);
     }
@@ -1838,7 +1838,7 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding)
         ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, NULL,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
         ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
-         "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
+         "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
     }
     /* Have to have a string of some sort */
     value.dwValueType = 0; /* aka CERT_RDN_ANY_TYPE */
@@ -1847,23 +1847,23 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING,
-     "Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError());
     value.dwValueType = CERT_RDN_ENCODED_BLOB;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING,
-     "Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError());
     value.dwValueType = CERT_RDN_ANY_TYPE;
     value.Value.pbData = (LPBYTE)oneW;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING,
-     "Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError());
     value.Value.cbData = sizeof(oneW);
     ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING,
-     "Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError());
     /* An encoded string with specified length isn't good enough either */
     value.dwValueType = CERT_RDN_ENCODED_BLOB;
     value.Value.pbData = oneUniversal;
@@ -1871,7 +1871,7 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING,
-     "Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_CHAR_STRING, got %08lx\n", GetLastError());
     /* More failure checking */
     value.Value.cbData = 0;
     for (i = 0; i < ARRAY_SIZE(unicodeErrors); i++)
@@ -1881,10 +1881,10 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding)
         ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
         ok(!ret && GetLastError() == unicodeErrors[i].error,
-         "Value type %d: expected %08x, got %08x\n", value.dwValueType,
+         "Value type %ld: expected %08lx, got %08lx\n", value.dwValueType,
          unicodeErrors[i].error, GetLastError());
         ok(size == unicodeErrors[i].errorIndex,
-         "Expected error index %d, got %d\n", unicodeErrors[i].errorIndex,
+         "Expected error index %ld, got %ld\n", unicodeErrors[i].errorIndex,
          size);
     }
     /* cbData can be zero if the string is NULL-terminated */
@@ -1896,14 +1896,14 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding)
         ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
         ok(ret || broken(GetLastError() == OSS_PDU_MISMATCH /* Win9x */),
-         "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+         "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             ok(size == unicodeResults[i].encoded.cbData,
-             "Value type %d: expected size %d, got %d\n",
+             "Value type %ld: expected size %ld, got %ld\n",
              value.dwValueType, unicodeResults[i].encoded.cbData, size);
             ok(!memcmp(unicodeResults[i].encoded.pbData, buf, size),
-             "Value type %d: unexpected value\n", value.dwValueType);
+             "Value type %ld: unexpected value\n", value.dwValueType);
             LocalFree(buf);
         }
     }
@@ -1917,14 +1917,14 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding)
         value.dwValueType = unicodeWeirdness[i].valueType;
         ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-        ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             ok(size == unicodeWeirdness[i].encoded.cbData,
-             "Value type %d: expected size %d, got %d\n",
+             "Value type %ld: expected size %ld, got %ld\n",
              value.dwValueType, unicodeWeirdness[i].encoded.cbData, size);
             ok(!memcmp(unicodeWeirdness[i].encoded.pbData, buf, size),
-             "Value type %d: unexpected value\n", value.dwValueType);
+             "Value type %ld: unexpected value\n", value.dwValueType);
             LocalFree(buf);
         }
     }
@@ -1944,17 +1944,17 @@ static void test_decodeUnicodeNameValue(DWORD dwEncoding)
          unicodeResults[i].encoded.pbData, unicodeResults[i].encoded.cbData,
          CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
         ok(ret || broken(GetLastError() == CRYPT_E_NOT_CHAR_STRING /* Win9x */),
-         "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+         "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
         if (ret && buf)
         {
             PCERT_NAME_VALUE value = (PCERT_NAME_VALUE)buf;
 
             ok(value->dwValueType == unicodeResults[i].valueType,
-             "Expected value type %d, got %d\n", unicodeResults[i].valueType,
+             "Expected value type %ld, got %ld\n", unicodeResults[i].valueType,
              value->dwValueType);
             ok(!wcsncmp((LPWSTR)value->Value.pbData, unicodeResults[i].str,
              value->Value.cbData / sizeof(WCHAR)),
-             "Unexpected decoded value for index %d (value type %d)\n", i,
+             "Unexpected decoded value for index %ld (value type %ld)\n", i,
              unicodeResults[i].valueType);
             LocalFree(buf);
         }
@@ -2002,15 +2002,15 @@ static void test_encodeOctets(DWORD dwEncoding)
         blob.pbData = (BYTE*)tests[i].decoded;
         ret = pCryptEncodeObjectEx(dwEncoding, X509_OCTET_STRING, &blob,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-        ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError());
         if (ret)
         {
-            ok(bufSize == tests[i].encoded_size, "[%u] buf size %u expected %u\n",
+            ok(bufSize == tests[i].encoded_size, "[%lu] buf size %lu expected %u\n",
                i, bufSize, tests[i].encoded_size);
             ok(buf[0] == 4, "Got unexpected type %d for octet string (expected 4)\n", buf[0]);
-            ok(buf[1] == tests[i].decoded_size, "[%u] Got length %d, expected %d\n",
+            ok(buf[1] == tests[i].decoded_size, "[%lu] Got length %d, expected %d\n",
                i, buf[1], tests[i].decoded_size);
-            ok(!memcmp(buf, tests[i].encoded, tests[i].encoded_size), "[%u] Got unexpected value\n", i);
+            ok(!memcmp(buf, tests[i].encoded, tests[i].encoded_size), "[%lu] Got unexpected value\n", i);
             LocalFree(buf);
         }
     }
@@ -2078,19 +2078,19 @@ static void test_decodeOctets(DWORD dwEncoding)
         if (tests[i].error)
         {
             ok(!ret && GetLastError() == tests[i].error,
-               "[%u] CryptDecodeObjectEx returned %x(%x)\n", i, ret, GetLastError());
+               "[%lu] CryptDecodeObjectEx returned %x(%lx)\n", i, ret, GetLastError());
             continue;
         }
-        ok(ret, "[%u] CryptDecodeObjectEx failed: %08x\n", i, GetLastError());
+        ok(ret, "[%lu] CryptDecodeObjectEx failed: %08lx\n", i, GetLastError());
         ok(bufSize >= sizeof(CRYPT_DATA_BLOB) + tests[i].decoded_size,
-           "[%u] Expected size >= %d, got %d\n", i,
+           "[%lu] Expected size >= %d, got %ld\n", i,
            (int)sizeof(CRYPT_DATA_BLOB) + tests[i].decoded_size, bufSize);
         ok(buf != NULL, "Expected allocated buffer\n");
         if (ret)
         {
             CRYPT_DATA_BLOB *blob = (CRYPT_DATA_BLOB *)buf;
 
-            ok (blob->cbData == tests[i].decoded_size, "[%u] cbData = %u\n", i, blob->cbData);
+            ok (blob->cbData == tests[i].decoded_size, "[%lu] cbData = %lu\n", i, blob->cbData);
             if (blob->cbData)
                 ok(!memcmp(blob->pbData, tests[i].decoded, blob->cbData),
                  "Unexpected value\n");
@@ -2140,14 +2140,14 @@ static void test_encodeBits(DWORD dwEncoding)
         blob.cUnusedBits = bits[i].cUnusedBits;
         ret = pCryptEncodeObjectEx(dwEncoding, X509_BITS, &blob,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-        ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             ok(bufSize == bits[i].encoded[1] + 2,
-             "%d: Got unexpected size %d, expected %d\n", i, bufSize,
+             "%ld: Got unexpected size %ld, expected %d\n", i, bufSize,
              bits[i].encoded[1] + 2);
             ok(!memcmp(buf, bits[i].encoded, bits[i].encoded[1] + 2),
-             "%d: Unexpected value\n", i);
+             "%ld: Unexpected value\n", i);
             LocalFree(buf);
         }
     }
@@ -2168,16 +2168,16 @@ static void test_decodeBits(DWORD dwEncoding)
         ret = pCryptDecodeObjectEx(dwEncoding, X509_BITS, bits[i].encoded,
          bits[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf,
          &bufSize);
-        ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             CRYPT_BIT_BLOB *blob;
 
             ok(bufSize >= sizeof(CRYPT_BIT_BLOB) + bits[i].cbDecoded,
-               "Got unexpected size %d\n", bufSize);
+               "Got unexpected size %ld\n", bufSize);
             blob = (CRYPT_BIT_BLOB *)buf;
             ok(blob->cbData == bits[i].cbDecoded,
-             "Got unexpected length %d, expected %d\n", blob->cbData,
+             "Got unexpected length %ld, expected %ld\n", blob->cbData,
              bits[i].cbDecoded);
             if (blob->cbData && bits[i].cbDecoded)
                 ok(!memcmp(blob->pbData, bits[i].decoded, bits[i].cbDecoded),
@@ -2190,16 +2190,16 @@ static void test_decodeBits(DWORD dwEncoding)
      */
     ret = pCryptDecodeObjectEx(dwEncoding, X509_BITS, ber, ber[1] + 2,
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CRYPT_BIT_BLOB *blob;
 
         ok(bufSize >= sizeof(CRYPT_BIT_BLOB) + sizeof(berDecoded),
-           "Got unexpected size %d\n", bufSize);
+           "Got unexpected size %ld\n", bufSize);
         blob = (CRYPT_BIT_BLOB *)buf;
         ok(blob->cbData == sizeof(berDecoded),
-           "Got unexpected length %d\n", blob->cbData);
+           "Got unexpected length %ld\n", blob->cbData);
         if (blob->cbData)
             ok(*blob->pbData == berDecoded, "Unexpected value\n");
         LocalFree(buf);
@@ -2255,11 +2255,11 @@ static void test_encodeBasicConstraints(DWORD dwEncoding)
         ret = pCryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2,
          &constraints2[i].info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf,
          &bufSize);
-        ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             ok(bufSize == constraints2[i].encoded[1] + 2,
-             "Expected %d bytes, got %d\n", constraints2[i].encoded[1] + 2,
+             "Expected %d bytes, got %ld\n", constraints2[i].encoded[1] + 2,
              bufSize);
             ok(!memcmp(buf, constraints2[i].encoded,
              constraints2[i].encoded[1] + 2), "Unexpected value\n");
@@ -2273,10 +2273,10 @@ static void test_encodeBasicConstraints(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
     ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */,
-     "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+     "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(bufSize == sizeof(emptyConstraint), "Wrong size %d\n", bufSize);
+        ok(bufSize == sizeof(emptyConstraint), "Wrong size %ld\n", bufSize);
         ok(!memcmp(buf, emptyConstraint, sizeof(emptyConstraint)),
          "Unexpected value\n");
         LocalFree(buf);
@@ -2289,10 +2289,10 @@ static void test_encodeBasicConstraints(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
     ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */,
-     "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+     "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(bufSize == sizeof(constraintWithDomainName), "Wrong size %d\n", bufSize);
+        ok(bufSize == sizeof(constraintWithDomainName), "Wrong size %ld\n", bufSize);
         ok(!memcmp(buf, constraintWithDomainName,
          sizeof(constraintWithDomainName)), "Unexpected value\n");
         LocalFree(buf);
@@ -2318,7 +2318,7 @@ static void test_decodeBasicConstraints(DWORD dwEncoding)
         ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2,
          constraints2[i].encoded, constraints2[i].encoded[1] + 2,
          CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-        ok(ret, "CryptDecodeObjectEx failed for item %d: %08x\n", i,
+        ok(ret, "CryptDecodeObjectEx failed for item %ld: %08lx\n", i,
          GetLastError());
         if (ret)
         {
@@ -2326,7 +2326,7 @@ static void test_decodeBasicConstraints(DWORD dwEncoding)
              (CERT_BASIC_CONSTRAINTS2_INFO *)buf;
 
             ok(!memcmp(info, &constraints2[i].info, sizeof(*info)),
-             "Unexpected value for item %d\n", i);
+             "Unexpected value for item %ld\n", i);
             LocalFree(buf);
         }
     }
@@ -2337,14 +2337,14 @@ static void test_decodeBasicConstraints(DWORD dwEncoding)
      &bufSize);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT ||
      GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n",
+     "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n",
      GetLastError());
     ok(!buf, "Expected buf to be set to NULL\n");
     /* Check with a non-DER bool */
     ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2,
      badBool.encoded, badBool.encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL,
      &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_BASIC_CONSTRAINTS2_INFO *info =
@@ -2359,13 +2359,13 @@ static void test_decodeBasicConstraints(DWORD dwEncoding)
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT ||
      GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n",
+     "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n",
      GetLastError());
     /* Now check with the more complex CERT_BASIC_CONSTRAINTS_INFO */
     ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS,
      emptyConstraint, sizeof(emptyConstraint), CRYPT_DECODE_ALLOC_FLAG, NULL,
      &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_BASIC_CONSTRAINTS_INFO *info = (CERT_BASIC_CONSTRAINTS_INFO *)buf;
@@ -2378,7 +2378,7 @@ static void test_decodeBasicConstraints(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS,
      constraintWithDomainName, sizeof(constraintWithDomainName),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_BASIC_CONSTRAINTS_INFO *info = (CERT_BASIC_CONSTRAINTS_INFO *)buf;
@@ -2389,7 +2389,7 @@ static void test_decodeBasicConstraints(DWORD dwEncoding)
         if (info->cSubtreesConstraint && info->rgSubtreesConstraint)
         {
             ok(info->rgSubtreesConstraint[0].cbData ==
-             sizeof(encodedDomainName), "Wrong size %d\n",
+             sizeof(encodedDomainName), "Wrong size %ld\n",
              info->rgSubtreesConstraint[0].cbData);
             ok(!memcmp(info->rgSubtreesConstraint[0].pbData, encodedDomainName,
              sizeof(encodedDomainName)), "Unexpected value\n");
@@ -2446,7 +2446,7 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB,
      toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* Now with a bogus reserved field */
     hdr->bType = PUBLICKEYBLOB;
     hdr->reserved = 1;
@@ -2455,7 +2455,7 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding)
     if (ret)
     {
         ok(bufSize == rsaPubKeys[0].encoded[1] + 2,
-         "Expected size %d, got %d\n", rsaPubKeys[0].encoded[1] + 2, bufSize);
+         "Expected size %d, got %ld\n", rsaPubKeys[0].encoded[1] + 2, bufSize);
         ok(!memcmp(buf, rsaPubKeys[0].encoded, bufSize), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -2467,7 +2467,7 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding)
     if (ret)
     {
         ok(bufSize == rsaPubKeys[0].encoded[1] + 2,
-         "Expected size %d, got %d\n", rsaPubKeys[0].encoded[1] + 2, bufSize);
+         "Expected size %d, got %ld\n", rsaPubKeys[0].encoded[1] + 2, bufSize);
         ok(!memcmp(buf, rsaPubKeys[0].encoded, bufSize), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -2479,7 +2479,7 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding)
     if (ret)
     {
         ok(bufSize == rsaPubKeys[0].encoded[1] + 2,
-         "Expected size %d, got %d\n", rsaPubKeys[0].encoded[1] + 2, bufSize);
+         "Expected size %d, got %ld\n", rsaPubKeys[0].encoded[1] + 2, bufSize);
         ok(!memcmp(buf, rsaPubKeys[0].encoded, bufSize), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -2488,11 +2488,11 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, szOID_RSA_RSA,
      toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     ret = pCryptEncodeObjectEx(dwEncoding, szOID_RSA_SHA1RSA,
      toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     /* Finally, all valid */
     hdr->aiKeyAlg = CALG_RSA_KEYX;
     for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++)
@@ -2501,11 +2501,11 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding)
          rsaPubKeys[i].modulus, rsaPubKeys[i].modulusLen);
         ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB,
          toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-        ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             ok(bufSize == rsaPubKeys[i].encoded[1] + 2,
-             "Expected size %d, got %d\n", rsaPubKeys[i].encoded[1] + 2,
+             "Expected size %d, got %ld\n", rsaPubKeys[i].encoded[1] + 2,
              bufSize);
             ok(!memcmp(buf, rsaPubKeys[i].encoded, bufSize),
              "Unexpected value\n");
@@ -2527,19 +2527,19 @@ static void test_decodeRsaPublicKey(DWORD dwEncoding)
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD ||
      GetLastError() == OSS_MORE_INPUT /* Win9x/NT4 */),
-     "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08x\n",
+     "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08lx\n",
      GetLastError());
     /* Try with a couple of RSA-related OIDs */
     ret = pCryptDecodeObjectEx(dwEncoding, szOID_RSA_RSA,
      rsaPubKeys[0].encoded, rsaPubKeys[0].encoded[1] + 2,
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     ret = pCryptDecodeObjectEx(dwEncoding, szOID_RSA_SHA1RSA,
      rsaPubKeys[0].encoded, rsaPubKeys[0].encoded[1] + 2,
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     /* Now try success cases */
     for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++)
     {
@@ -2547,7 +2547,7 @@ static void test_decodeRsaPublicKey(DWORD dwEncoding)
         ret = pCryptDecodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB,
          rsaPubKeys[i].encoded, rsaPubKeys[i].encoded[1] + 2,
          CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-        ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             BLOBHEADER *hdr = (BLOBHEADER *)buf;
@@ -2555,7 +2555,7 @@ static void test_decodeRsaPublicKey(DWORD dwEncoding)
 
             ok(bufSize >= sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) +
              rsaPubKeys[i].decodedModulusLen,
-             "Wrong size %d\n", bufSize);
+             "Wrong size %ld\n", bufSize);
             ok(hdr->bType == PUBLICKEYBLOB,
              "Expected type PUBLICKEYBLOB (%d), got %d\n", PUBLICKEYBLOB,
              hdr->bType);
@@ -2567,10 +2567,10 @@ static void test_decodeRsaPublicKey(DWORD dwEncoding)
             ok(hdr->aiKeyAlg == CALG_RSA_KEYX,
              "Expected CALG_RSA_KEYX, got %08x\n", hdr->aiKeyAlg);
             ok(rsaPubKey->magic == 0x31415352,
-             "Expected magic RSA1, got %08x\n", rsaPubKey->magic);
+             "Expected magic RSA1, got %08lx\n", rsaPubKey->magic);
             ok(rsaPubKey->bitlen == rsaPubKeys[i].decodedModulusLen * 8,
-             "Wrong bit len %d\n", rsaPubKey->bitlen);
-            ok(rsaPubKey->pubexp == 65537, "Expected pubexp 65537, got %d\n",
+             "Wrong bit len %ld\n", rsaPubKey->bitlen);
+            ok(rsaPubKey->pubexp == 65537, "Expected pubexp 65537, got %ld\n",
              rsaPubKey->pubexp);
             ok(!memcmp(buf + sizeof(BLOBHEADER) + sizeof(RSAPUBKEY),
              rsaPubKeys[i].modulus, rsaPubKeys[i].decodedModulusLen),
@@ -2606,7 +2606,7 @@ static void test_encodeRsaPublicKey_Bcrypt(DWORD dwEncoding)
 
     ret = pCryptEncodeObjectEx(dwEncoding, CNG_RSA_PUBLIC_KEY_BLOB,
      toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
 
     /* Finally, all valid */
     hdr->Magic = BCRYPT_RSAPUBLIC_MAGIC;
@@ -2620,11 +2620,11 @@ static void test_encodeRsaPublicKey_Bcrypt(DWORD dwEncoding)
 
         ret = pCryptEncodeObjectEx(dwEncoding, CNG_RSA_PUBLIC_KEY_BLOB,
          toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-        ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             ok(bufSize == rsaPubKeys[i].encoded[1] + 2,
-             "Expected size %d, got %d\n", rsaPubKeys[i].encoded[1] + 2,
+             "Expected size %d, got %ld\n", rsaPubKeys[i].encoded[1] + 2,
              bufSize);
             ok(!memcmp(buf, rsaPubKeys[i].encoded, bufSize),
              "Unexpected value\n");
@@ -2647,7 +2647,7 @@ static void test_decodeRsaPublicKey_Bcrypt(DWORD dwEncoding)
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD ||
      GetLastError() == OSS_MORE_INPUT /* Win9x/NT4 */),
-     "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08x\n",
+     "Expected CRYPT_E_ASN1_EOD or OSS_MORE_INPUT, got %08lx\n",
      GetLastError());
     /* Now try success cases */
     for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++)
@@ -2656,7 +2656,7 @@ static void test_decodeRsaPublicKey_Bcrypt(DWORD dwEncoding)
         ret = pCryptDecodeObjectEx(dwEncoding, CNG_RSA_PUBLIC_KEY_BLOB,
          rsaPubKeys[i].encoded, rsaPubKeys[i].encoded[1] + 2,
          CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-        ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             BCRYPT_RSAKEY_BLOB *hdr = (BCRYPT_RSAKEY_BLOB *)buf;
@@ -2667,20 +2667,20 @@ static void test_decodeRsaPublicKey_Bcrypt(DWORD dwEncoding)
             CRYPT_CopyReversed((BYTE *)&pubexp, buf + sizeof(BCRYPT_RSAKEY_BLOB), hdr->cbPublicExp);
             ok(bufSize >= sizeof(BCRYPT_RSAKEY_BLOB) +
              rsaPubKeys[i].decodedModulusLen,
-             "Wrong size %d\n", bufSize);
+             "Wrong size %ld\n", bufSize);
             ok(hdr->Magic == BCRYPT_RSAPUBLIC_MAGIC,
-             "Expected magic BCRYPT_RSAPUBLIC_MAGIC (%d), got %d\n", BCRYPT_RSAPUBLIC_MAGIC,
+             "Expected magic BCRYPT_RSAPUBLIC_MAGIC (%d), got %ld\n", BCRYPT_RSAPUBLIC_MAGIC,
              hdr->Magic);
             ok(hdr->BitLength == rsaPubKeys[i].decodedModulusLen * 8,
-             "Wrong bit len %d\n", hdr->BitLength);
+             "Wrong bit len %ld\n", hdr->BitLength);
             /* Windows decodes the exponent to 3 bytes, since it will fit.
              * Our implementation currently unconditionally decodes to a DWORD (4 bytes)
              */
-            todo_wine ok(hdr->cbPublicExp == 3, "Expected cbPublicExp 3, got %d\n", hdr->cbPublicExp);
+            todo_wine ok(hdr->cbPublicExp == 3, "Expected cbPublicExp 3, got %ld\n", hdr->cbPublicExp);
             ok(hdr->cbModulus == rsaPubKeys[i].decodedModulusLen,
-              "Wrong modulus len %d\n", hdr->cbModulus);
-            ok(hdr->cbPrime1 == 0,"Wrong cbPrime1 %d\n", hdr->cbPrime1);
-            ok(hdr->cbPrime2 == 0,"Wrong cbPrime2 %d\n", hdr->cbPrime2);
+              "Wrong modulus len %ld\n", hdr->cbModulus);
+            ok(hdr->cbPrime1 == 0,"Wrong cbPrime1 %ld\n", hdr->cbPrime1);
+            ok(hdr->cbPrime2 == 0,"Wrong cbPrime2 %ld\n", hdr->cbPrime2);
             ok(!memcmp(pubexp, pubexp_expected, sizeof(pubexp_expected)), "Wrong exponent\n");
             todo_wine ok(pubexp[3] == 0xff, "Got %02x\n", pubexp[3]);
 
@@ -2729,10 +2729,10 @@ static void test_encodeSequenceOfAny(DWORD dwEncoding)
 
     ret = pCryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(bufSize == sizeof(intSequence), "Wrong size %d\n", bufSize);
+        ok(bufSize == sizeof(intSequence), "Wrong size %ld\n", bufSize);
         ok(!memcmp(buf, intSequence, intSequence[1] + 2), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -2743,10 +2743,10 @@ static void test_encodeSequenceOfAny(DWORD dwEncoding)
     blobs[0].pbData = (BYTE *)times[0].encodedTime;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(bufSize == sizeof(mixedSequence), "Wrong size %d\n", bufSize);
+        ok(bufSize == sizeof(mixedSequence), "Wrong size %ld\n", bufSize);
         ok(!memcmp(buf, mixedSequence, mixedSequence[1] + 2),
          "Unexpected value\n");
         LocalFree(buf);
@@ -2761,17 +2761,17 @@ static void test_decodeSequenceOfAny(DWORD dwEncoding)
 
     ret = pCryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, intSequence,
      intSequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CRYPT_SEQUENCE_OF_ANY *seq = (CRYPT_SEQUENCE_OF_ANY *)buf;
         DWORD i;
 
-        ok(seq->cValue == ARRAY_SIZE(ints), "Wrong elements %d\n", seq->cValue);
+        ok(seq->cValue == ARRAY_SIZE(ints), "Wrong elements %ld\n", seq->cValue);
         for (i = 0; i < min(seq->cValue, ARRAY_SIZE(ints)); i++)
         {
             ok(seq->rgValue[i].cbData == ints[i].encoded[1] + 2,
-             "Expected %d bytes, got %d\n", ints[i].encoded[1] + 2,
+             "Expected %d bytes, got %ld\n", ints[i].encoded[1] + 2,
              seq->rgValue[i].cbData);
             ok(!memcmp(seq->rgValue[i].pbData, ints[i].encoded,
              ints[i].encoded[1] + 2), "Unexpected value\n");
@@ -2781,15 +2781,15 @@ static void test_decodeSequenceOfAny(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, mixedSequence,
      mixedSequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf,
      &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CRYPT_SEQUENCE_OF_ANY *seq = (CRYPT_SEQUENCE_OF_ANY *)buf;
 
-        ok(seq->cValue == ARRAY_SIZE(ints), "Wrong elements %d\n", seq->cValue);
+        ok(seq->cValue == ARRAY_SIZE(ints), "Wrong elements %ld\n", seq->cValue);
         /* Just check the first element since it's all that changed */
         ok(seq->rgValue[0].cbData == times[0].encodedTime[1] + 2,
-         "Expected %d bytes, got %d\n", times[0].encodedTime[1] + 2,
+         "Expected %d bytes, got %ld\n", times[0].encodedTime[1] + 2,
          seq->rgValue[0].cbData);
         ok(!memcmp(seq->rgValue[0].pbData, times[0].encodedTime,
          times[0].encodedTime[1] + 2), "Unexpected value\n");
@@ -2840,11 +2840,11 @@ static void test_encodeExtensions(DWORD dwEncoding)
 
         ret = pCryptEncodeObjectEx(dwEncoding, X509_EXTENSIONS, &exts[i].exts,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-        ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             ok(bufSize == exts[i].encoded[1] + 2,
-             "Expected %d bytes, got %d\n", exts[i].encoded[1] + 2, bufSize);
+             "Expected %d bytes, got %ld\n", exts[i].encoded[1] + 2, bufSize);
             ok(!memcmp(buf, exts[i].encoded, exts[i].encoded[1] + 2),
              "Unexpected value\n");
             LocalFree(buf);
@@ -2865,14 +2865,14 @@ static void test_decodeExtensions(DWORD dwEncoding)
         ret = pCryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS,
          exts[i].encoded, exts[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG,
          NULL, &buf, &bufSize);
-        ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             CERT_EXTENSIONS *ext = (CERT_EXTENSIONS *)buf;
             DWORD j;
 
             ok(ext->cExtension == exts[i].exts.cExtension,
-             "Expected %d extensions, see %d\n", exts[i].exts.cExtension,
+             "Expected %ld extensions, see %ld\n", exts[i].exts.cExtension,
              ext->cExtension);
             for (j = 0; j < min(ext->cExtension, exts[i].exts.cExtension); j++)
             {
@@ -2890,13 +2890,13 @@ static void test_decodeExtensions(DWORD dwEncoding)
         }
         ret = pCryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS,
          exts[i].encoded, exts[i].encoded[1] + 2, 0, NULL, NULL, &bufSize);
-        ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
         buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bufSize);
         if (buf)
         {
             ret = pCryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS,
              exts[i].encoded, exts[i].encoded[1] + 2, 0, NULL, buf, &bufSize);
-            ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+            ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
             HeapFree(GetProcessHeap(), 0, buf);
         }
     }
@@ -2980,11 +2980,11 @@ static void test_encodePublicKeyInfo(DWORD dwEncoding)
          &pubKeys[i].info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf,
          &bufSize);
         ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */,
-         "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+         "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             ok(bufSize == pubKeys[i].encoded[1] + 2,
-             "Expected %d bytes, got %d\n", pubKeys[i].encoded[1] + 2, bufSize);
+             "Expected %d bytes, got %ld\n", pubKeys[i].encoded[1] + 2, bufSize);
             if (bufSize == pubKeys[i].encoded[1] + 2)
                 ok(!memcmp(buf, pubKeys[i].encoded, pubKeys[i].encoded[1] + 2),
                  "Unexpected value\n");
@@ -3001,14 +3001,14 @@ static void comparePublicKeyInfo(const CERT_PUBLIC_KEY_INFO *expected,
      got->Algorithm.pszObjId);
     ok(expected->Algorithm.Parameters.cbData ==
      got->Algorithm.Parameters.cbData,
-     "Expected parameters of %d bytes, got %d\n",
+     "Expected parameters of %ld bytes, got %ld\n",
      expected->Algorithm.Parameters.cbData, got->Algorithm.Parameters.cbData);
     if (expected->Algorithm.Parameters.cbData)
         ok(!memcmp(expected->Algorithm.Parameters.pbData,
          got->Algorithm.Parameters.pbData, got->Algorithm.Parameters.cbData),
          "Unexpected algorithm parameters\n");
     ok(expected->PublicKey.cbData == got->PublicKey.cbData,
-     "Expected public key of %d bytes, got %d\n",
+     "Expected public key of %ld bytes, got %ld\n",
      expected->PublicKey.cbData, got->PublicKey.cbData);
     if (expected->PublicKey.cbData)
         ok(!memcmp(expected->PublicKey.pbData, got->PublicKey.pbData,
@@ -3032,7 +3032,7 @@ static void test_decodePublicKeyInfo(DWORD dwEncoding)
         ret = pCryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO,
          pubKeys[i].encoded, pubKeys[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG,
          NULL, &buf, &bufSize);
-        ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             comparePublicKeyInfo(&pubKeys[i].decoded,
@@ -3043,7 +3043,7 @@ static void test_decodePublicKeyInfo(DWORD dwEncoding)
         ret = pCryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO,
          pubKeys[i].encodedNoNull, pubKeys[i].encodedNoNull[1] + 2,
          CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-        ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             comparePublicKeyInfo(&pubKeys[i].info, (CERT_PUBLIC_KEY_INFO *)buf);
@@ -3056,7 +3056,7 @@ static void test_decodePublicKeyInfo(DWORD dwEncoding)
      NULL, &buf, &bufSize);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT ||
      GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n",
+     "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n",
      GetLastError());
 }
 
@@ -3185,16 +3185,16 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding)
         ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
         ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
-         "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
+         "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
     }
     /* Test with a V1 cert */
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */,
-     "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+     "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == v1Cert[1] + 2, "Expected size %d, got %d\n",
+        ok(size == v1Cert[1] + 2, "Expected size %d, got %ld\n",
          v1Cert[1] + 2, size);
         ok(!memcmp(buf, v1Cert, size), "Got unexpected value\n");
         LocalFree(buf);
@@ -3204,10 +3204,10 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */,
-     "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+     "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(v2Cert), "Wrong size %d\n", size);
+        ok(size == sizeof(v2Cert), "Wrong size %ld\n", size);
         ok(!memcmp(buf, v2Cert, size), "Got unexpected value\n");
         LocalFree(buf);
     }
@@ -3216,10 +3216,10 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */,
-     "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+     "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(v3Cert), "Wrong size %d\n", size);
+        ok(size == sizeof(v3Cert), "Wrong size %ld\n", size);
         ok(!memcmp(buf, v3Cert, size), "Got unexpected value\n");
         LocalFree(buf);
     }
@@ -3229,7 +3229,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (ret)
     {
-        ok(size == sizeof(v4Cert), "Wrong size %d\n", size);
+        ok(size == sizeof(v4Cert), "Wrong size %ld\n", size);
         ok(!memcmp(buf, v4Cert, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -3242,10 +3242,10 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(ret || GetLastError() == OSS_BAD_PTR /* Win9x */,
-     "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+     "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(v1CertWithConstraints), "Wrong size %d\n", size);
+        ok(size == sizeof(v1CertWithConstraints), "Wrong size %ld\n", size);
         ok(!memcmp(buf, v1CertWithConstraints, size), "Got unexpected value\n");
         LocalFree(buf);
     }
@@ -3256,7 +3256,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (ret)
     {
-        ok(size == sizeof(v1CertWithSerial), "Wrong size %d\n", size);
+        ok(size == sizeof(v1CertWithSerial), "Wrong size %ld\n", size);
         ok(!memcmp(buf, v1CertWithSerial, size), "Got unexpected value\n");
         LocalFree(buf);
     }
@@ -3268,10 +3268,10 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(ret || broken(GetLastError() == OSS_BAD_PTR /* Win98 */),
-     "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+     "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(v1CertWithIssuerUniqueId), "Wrong size %d\n", size);
+        ok(size == sizeof(v1CertWithIssuerUniqueId), "Wrong size %ld\n", size);
         ok(!memcmp(buf, v1CertWithIssuerUniqueId, size),
          "Got unexpected value\n");
         LocalFree(buf);
@@ -3289,7 +3289,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (ret)
     {
-        ok(size == sizeof(bigCert), "Wrong size %d\n", size);
+        ok(size == sizeof(bigCert), "Wrong size %ld\n", size);
         ok(!memcmp(buf, bigCert, size), "Got unexpected value\n");
         LocalFree(buf);
     }
@@ -3302,7 +3302,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding)
     if (ret)
     {
         ok(size == sizeof(v1CertWithPubKey) ||
-         size == sizeof(v1CertWithPubKeyNoNull), "Wrong size %d\n", size);
+         size == sizeof(v1CertWithPubKeyNoNull), "Wrong size %ld\n", size);
         if (size == sizeof(v1CertWithPubKey))
             ok(!memcmp(buf, v1CertWithPubKey, size), "Got unexpected value\n");
         else if (size == sizeof(v1CertWithPubKeyNoNull))
@@ -3315,12 +3315,12 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding)
     info.IssuerUniqueId.pbData = (BYTE *)serialNum;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(size == sizeof(v1CertWithSubjectIssuerSerialAndIssuerUniqueId) ||
          size == sizeof(v1CertWithSubjectIssuerSerialAndIssuerUniqueIdNoNull),
-         "Wrong size %d\n", size);
+         "Wrong size %ld\n", size);
         if (size == sizeof(v1CertWithSubjectIssuerSerialAndIssuerUniqueId))
             ok(!memcmp(buf, v1CertWithSubjectIssuerSerialAndIssuerUniqueId,
              size), "unexpected value\n");
@@ -3347,7 +3347,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (ret)
     {
-        ok(size == sizeof(v1CertWithSubjectKeyId), "Wrong size %d\n", size);
+        ok(size == sizeof(v1CertWithSubjectKeyId), "Wrong size %ld\n", size);
         ok(!memcmp(buf, v1CertWithSubjectKeyId, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -3366,14 +3366,14 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding)
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD ||
      GetLastError() == OSS_BAD_ARG /* Win9x */),
-     "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08lx\n", GetLastError());
     if (0)
     {
         /* Crashes on win9x */
         ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, 1,
          CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
         ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
-         "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
+         "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
     }
     /* The following certs all fail with CRYPT_E_ASN1_CORRUPT or
      * CRYPT_E_ASN1_BADTAG, because at a minimum a cert must have a non-zero
@@ -3392,15 +3392,15 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED,
      v1CertWithSubjectKeyId, sizeof(v1CertWithSubjectKeyId),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_INFO *info = (CERT_INFO *)buf;
 
-        ok(size >= sizeof(CERT_INFO), "Wrong size %d\n", size);
-        ok(info->dwVersion == CERT_V1, "expected CERT_V1, got %d\n",
+        ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size);
+        ok(info->dwVersion == CERT_V1, "expected CERT_V1, got %ld\n",
          info->dwVersion);
-        ok(info->cExtension == 1, "expected 1 extension, got %d\n",
+        ok(info->cExtension == 1, "expected 1 extension, got %ld\n",
          info->cExtension);
         LocalFree(buf);
     }
@@ -3411,16 +3411,16 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding)
      v1CertWithSubjectIssuerSerialAndIssuerUniqueId,
      sizeof(v1CertWithSubjectIssuerSerialAndIssuerUniqueId),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_INFO *info = (CERT_INFO *)buf;
 
-        ok(size >= sizeof(CERT_INFO), "Wrong size %d\n", size);
-        ok(info->dwVersion == CERT_V1, "expected CERT_V1, got %d\n",
+        ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size);
+        ok(info->dwVersion == CERT_V1, "expected CERT_V1, got %ld\n",
          info->dwVersion);
         ok(info->IssuerUniqueId.cbData == sizeof(serialNum),
-         "unexpected issuer unique id size %d\n", info->IssuerUniqueId.cbData);
+         "unexpected issuer unique id size %ld\n", info->IssuerUniqueId.cbData);
         ok(!memcmp(info->IssuerUniqueId.pbData, serialNum, sizeof(serialNum)),
          "unexpected issuer unique id value\n");
         LocalFree(buf);
@@ -3428,23 +3428,23 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding)
     /* Now check with serial number, subject and issuer specified */
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, bigCert,
      sizeof(bigCert), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_INFO *info = (CERT_INFO *)buf;
 
-        ok(size >= sizeof(CERT_INFO), "Wrong size %d\n", size);
+        ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size);
         ok(info->SerialNumber.cbData == 1,
-         "Expected serial number size 1, got %d\n", info->SerialNumber.cbData);
+         "Expected serial number size 1, got %ld\n", info->SerialNumber.cbData);
         ok(*info->SerialNumber.pbData == *serialNum,
          "Expected serial number %d, got %d\n", *serialNum,
          *info->SerialNumber.pbData);
         ok(info->Issuer.cbData == sizeof(encodedCommonName),
-         "Wrong size %d\n", info->Issuer.cbData);
+         "Wrong size %ld\n", info->Issuer.cbData);
         ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
          "Unexpected issuer\n");
         ok(info->Subject.cbData == sizeof(encodedCommonName),
-         "Wrong size %d\n", info->Subject.cbData);
+         "Wrong size %ld\n", info->Subject.cbData);
         ok(!memcmp(info->Subject.pbData, encodedCommonName,
          info->Subject.cbData), "Unexpected subject\n");
         LocalFree(buf);
@@ -3453,30 +3453,30 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED,
      v1CertWithPubKey, sizeof(v1CertWithPubKey), CRYPT_DECODE_ALLOC_FLAG, NULL,
      &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_INFO *info = (CERT_INFO *)buf;
 
-        ok(size >= sizeof(CERT_INFO), "Wrong size %d\n", size);
+        ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size);
         ok(info->SerialNumber.cbData == 1,
-         "Expected serial number size 1, got %d\n", info->SerialNumber.cbData);
+         "Expected serial number size 1, got %ld\n", info->SerialNumber.cbData);
         ok(*info->SerialNumber.pbData == *serialNum,
          "Expected serial number %d, got %d\n", *serialNum,
          *info->SerialNumber.pbData);
         ok(info->Issuer.cbData == sizeof(encodedCommonName),
-         "Wrong size %d\n", info->Issuer.cbData);
+         "Wrong size %ld\n", info->Issuer.cbData);
         ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
          "Unexpected issuer\n");
         ok(info->Subject.cbData == sizeof(encodedCommonName),
-         "Wrong size %d\n", info->Subject.cbData);
+         "Wrong size %ld\n", info->Subject.cbData);
         ok(!memcmp(info->Subject.pbData, encodedCommonName,
          info->Subject.cbData), "Unexpected subject\n");
         ok(!strcmp(info->SubjectPublicKeyInfo.Algorithm.pszObjId,
          szOID_RSA_RSA), "Expected szOID_RSA_RSA, got %s\n",
          info->SubjectPublicKeyInfo.Algorithm.pszObjId);
         ok(info->SubjectPublicKeyInfo.PublicKey.cbData == sizeof(aKey),
-         "Wrong size %d\n", info->SubjectPublicKeyInfo.PublicKey.cbData);
+         "Wrong size %ld\n", info->SubjectPublicKeyInfo.PublicKey.cbData);
         ok(!memcmp(info->SubjectPublicKeyInfo.PublicKey.pbData, aKey,
          sizeof(aKey)), "Unexpected public key\n");
         LocalFree(buf);
@@ -3572,10 +3572,10 @@ static void test_encodeCert(DWORD dwEncoding)
 
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(bufSize == sizeof(signedBigCert), "Wrong size %d\n", bufSize);
+        ok(bufSize == sizeof(signedBigCert), "Wrong size %ld\n", bufSize);
         ok(!memcmp(buf, signedBigCert, bufSize), "Unexpected cert\n");
         LocalFree(buf);
     }
@@ -3589,17 +3589,17 @@ static void test_decodeCert(DWORD dwEncoding)
 
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT, signedBigCert,
      sizeof(signedBigCert), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_SIGNED_CONTENT_INFO *info = (CERT_SIGNED_CONTENT_INFO *)buf;
 
         ok(info->ToBeSigned.cbData == sizeof(bigCert),
-         "Wrong cert size %d\n", info->ToBeSigned.cbData);
+         "Wrong cert size %ld\n", info->ToBeSigned.cbData);
         ok(!memcmp(info->ToBeSigned.pbData, bigCert, info->ToBeSigned.cbData),
          "Unexpected cert\n");
         ok(info->Signature.cbData == sizeof(hash),
-         "Wrong signature size %d\n", info->Signature.cbData);
+         "Wrong signature size %ld\n", info->Signature.cbData);
         ok(!memcmp(info->Signature.pbData, hash, info->Signature.cbData),
          "Unexpected signature\n");
         LocalFree(buf);
@@ -3607,46 +3607,46 @@ static void test_decodeCert(DWORD dwEncoding)
     /* A signed cert decodes as a CERT_INFO too */
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, signedBigCert,
      sizeof(signedBigCert), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_INFO *info = (CERT_INFO *)buf;
 
-        ok(size >= sizeof(CERT_INFO), "Wrong size %d\n", size);
+        ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size);
         ok(info->SerialNumber.cbData == 1,
-         "Expected serial number size 1, got %d\n", info->SerialNumber.cbData);
+         "Expected serial number size 1, got %ld\n", info->SerialNumber.cbData);
         ok(*info->SerialNumber.pbData == *serialNum,
          "Expected serial number %d, got %d\n", *serialNum,
          *info->SerialNumber.pbData);
         ok(info->Issuer.cbData == sizeof(encodedCommonName),
-         "Wrong size %d\n", info->Issuer.cbData);
+         "Wrong size %ld\n", info->Issuer.cbData);
         ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
          "Unexpected issuer\n");
         ok(info->Subject.cbData == sizeof(encodedCommonName),
-         "Wrong size %d\n", info->Subject.cbData);
+         "Wrong size %ld\n", info->Subject.cbData);
         ok(!memcmp(info->Subject.pbData, encodedCommonName,
          info->Subject.cbData), "Unexpected subject\n");
         LocalFree(buf);
     }
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, signedBigCertWithIndefiniteSeq,
      sizeof(signedBigCertWithIndefiniteSeq), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_INFO *info = (CERT_INFO *)buf;
 
-        ok(size >= sizeof(CERT_INFO), "Wrong size %d\n", size);
+        ok(size >= sizeof(CERT_INFO), "Wrong size %ld\n", size);
         ok(info->SerialNumber.cbData == 1,
-         "Expected serial number size 1, got %d\n", info->SerialNumber.cbData);
+         "Expected serial number size 1, got %ld\n", info->SerialNumber.cbData);
         ok(*info->SerialNumber.pbData == *serialNum,
          "Expected serial number %d, got %d\n", *serialNum,
          *info->SerialNumber.pbData);
         ok(info->Issuer.cbData == sizeof(encodedCommonName),
-         "Wrong size %d\n", info->Issuer.cbData);
+         "Wrong size %ld\n", info->Issuer.cbData);
         ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
          "Unexpected issuer\n");
         ok(info->Subject.cbData == sizeof(encodedCommonName),
-         "Wrong size %d\n", info->Subject.cbData);
+         "Wrong size %ld\n", info->Subject.cbData);
         ok(!memcmp(info->Subject.pbData, encodedCommonName,
          info->Subject.cbData), "Unexpected subject\n");
         LocalFree(buf);
@@ -3683,16 +3683,16 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* Test with one empty dist point */
     info.cDistPoint = 1;
     info.rgDistPoint = &point;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(emptyDistPoint), "Wrong size %d\n", size);
+        ok(size == sizeof(emptyDistPoint), "Wrong size %ld\n", size);
         ok(!memcmp(buf, emptyDistPoint, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -3705,19 +3705,19 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_IA5_STRING,
-     "Expected CRYPT_E_INVALID_IA5_STRING, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_IA5_STRING, got %08lx\n", GetLastError());
     /* The first invalid character is at index 7 */
     ok(GET_CERT_ALT_NAME_VALUE_ERR_INDEX(size) == 7,
-     "Expected invalid char at index 7, got %d\n",
+     "Expected invalid char at index 7, got %ld\n",
      GET_CERT_ALT_NAME_VALUE_ERR_INDEX(size));
     /* A dist point with (just) a valid name */
     U(entry).pwszURL = (LPWSTR)url;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(distPointWithUrl), "Wrong size %d\n", size);
+        ok(size == sizeof(distPointWithUrl), "Wrong size %ld\n", size);
         ok(!memcmp(buf, distPointWithUrl, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -3727,10 +3727,10 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding)
     point.ReasonFlags.pbData = (LPBYTE)&crlReason;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(distPointWithReason), "Wrong size %d\n", size);
+        ok(size == sizeof(distPointWithReason), "Wrong size %ld\n", size);
         ok(!memcmp(buf, distPointWithReason, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -3740,10 +3740,10 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding)
     point.CRLIssuer.rgAltEntry = &entry;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(distPointWithIssuer), "Wrong size %d\n", size);
+        ok(size == sizeof(distPointWithIssuer), "Wrong size %ld\n", size);
         ok(!memcmp(buf, distPointWithIssuer, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -3751,11 +3751,11 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding)
     point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_FULL_NAME;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(size == sizeof(distPointWithUrlAndIssuer),
-         "Wrong size %d\n", size);
+         "Wrong size %ld\n", size);
         ok(!memcmp(buf, distPointWithUrlAndIssuer, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -3773,17 +3773,17 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS,
      emptyDistPoint, emptyDistPoint[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL,
      &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         info = (PCRL_DIST_POINTS_INFO)buf;
         ok(size >= sizeof(CRL_DIST_POINTS_INFO) + sizeof(CRL_DIST_POINT),
-         "Wrong size %d\n", size);
-        ok(info->cDistPoint == 1, "Expected 1 dist points, got %d\n",
+         "Wrong size %ld\n", size);
+        ok(info->cDistPoint == 1, "Expected 1 dist points, got %ld\n",
          info->cDistPoint);
         point = info->rgDistPoint;
         ok(point->DistPointName.dwDistPointNameChoice == CRL_DIST_POINT_NO_NAME,
-         "Expected CRL_DIST_POINT_NO_NAME, got %d\n",
+         "Expected CRL_DIST_POINT_NO_NAME, got %ld\n",
          point->DistPointName.dwDistPointNameChoice);
         ok(point->ReasonFlags.cbData == 0, "Expected no reason\n");
         ok(point->CRLIssuer.cAltEntry == 0, "Expected no issuer\n");
@@ -3792,25 +3792,25 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS,
      distPointWithUrl, distPointWithUrl[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL,
      &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         info = (PCRL_DIST_POINTS_INFO)buf;
         ok(size >= sizeof(CRL_DIST_POINTS_INFO) + sizeof(CRL_DIST_POINT),
-         "Wrong size %d\n", size);
-        ok(info->cDistPoint == 1, "Expected 1 dist points, got %d\n",
+         "Wrong size %ld\n", size);
+        ok(info->cDistPoint == 1, "Expected 1 dist points, got %ld\n",
          info->cDistPoint);
         point = info->rgDistPoint;
         ok(point->DistPointName.dwDistPointNameChoice ==
          CRL_DIST_POINT_FULL_NAME,
-         "Expected CRL_DIST_POINT_FULL_NAME, got %d\n",
+         "Expected CRL_DIST_POINT_FULL_NAME, got %ld\n",
          point->DistPointName.dwDistPointNameChoice);
         ok(U(point->DistPointName).FullName.cAltEntry == 1,
-         "Expected 1 name entry, got %d\n",
+         "Expected 1 name entry, got %ld\n",
          U(point->DistPointName).FullName.cAltEntry);
         entry = U(point->DistPointName).FullName.rgAltEntry;
         ok(entry->dwAltNameChoice == CERT_ALT_NAME_URL,
-         "Expected CERT_ALT_NAME_URL, got %d\n", entry->dwAltNameChoice);
+         "Expected CERT_ALT_NAME_URL, got %ld\n", entry->dwAltNameChoice);
         ok(!lstrcmpW(U(*entry).pwszURL, url), "Unexpected name\n");
         ok(point->ReasonFlags.cbData == 0, "Expected no reason\n");
         ok(point->CRLIssuer.cAltEntry == 0, "Expected no issuer\n");
@@ -3819,18 +3819,18 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS,
      distPointWithReason, distPointWithReason[1] + 2, CRYPT_DECODE_ALLOC_FLAG,
      NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         info = (PCRL_DIST_POINTS_INFO)buf;
         ok(size >= sizeof(CRL_DIST_POINTS_INFO) + sizeof(CRL_DIST_POINT),
-         "Wrong size %d\n", size);
-        ok(info->cDistPoint == 1, "Expected 1 dist points, got %d\n",
+         "Wrong size %ld\n", size);
+        ok(info->cDistPoint == 1, "Expected 1 dist points, got %ld\n",
          info->cDistPoint);
         point = info->rgDistPoint;
         ok(point->DistPointName.dwDistPointNameChoice ==
          CRL_DIST_POINT_NO_NAME,
-         "Expected CRL_DIST_POINT_NO_NAME, got %d\n",
+         "Expected CRL_DIST_POINT_NO_NAME, got %ld\n",
          point->DistPointName.dwDistPointNameChoice);
         ok(point->ReasonFlags.cbData == sizeof(crlReason),
          "Expected reason length\n");
@@ -3842,46 +3842,46 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS,
      distPointWithUrlAndIssuer, distPointWithUrlAndIssuer[1] + 2,
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         info = (PCRL_DIST_POINTS_INFO)buf;
         ok(size >= sizeof(CRL_DIST_POINTS_INFO) + sizeof(CRL_DIST_POINT),
-         "Wrong size %d\n", size);
-        ok(info->cDistPoint == 1, "Expected 1 dist points, got %d\n",
+         "Wrong size %ld\n", size);
+        ok(info->cDistPoint == 1, "Expected 1 dist points, got %ld\n",
          info->cDistPoint);
         point = info->rgDistPoint;
         ok(point->DistPointName.dwDistPointNameChoice ==
          CRL_DIST_POINT_FULL_NAME,
-         "Expected CRL_DIST_POINT_FULL_NAME, got %d\n",
+         "Expected CRL_DIST_POINT_FULL_NAME, got %ld\n",
          point->DistPointName.dwDistPointNameChoice);
         ok(U(point->DistPointName).FullName.cAltEntry == 1,
-         "Expected 1 name entry, got %d\n",
+         "Expected 1 name entry, got %ld\n",
          U(point->DistPointName).FullName.cAltEntry);
         entry = U(point->DistPointName).FullName.rgAltEntry;
         ok(entry->dwAltNameChoice == CERT_ALT_NAME_URL,
-         "Expected CERT_ALT_NAME_URL, got %d\n", entry->dwAltNameChoice);
+         "Expected CERT_ALT_NAME_URL, got %ld\n", entry->dwAltNameChoice);
         ok(!lstrcmpW(U(*entry).pwszURL, url), "Unexpected name\n");
         ok(point->ReasonFlags.cbData == 0, "Expected no reason\n");
         ok(point->CRLIssuer.cAltEntry == 1,
-         "Expected 1 issuer entry, got %d\n", point->CRLIssuer.cAltEntry);
+         "Expected 1 issuer entry, got %ld\n", point->CRLIssuer.cAltEntry);
         entry = point->CRLIssuer.rgAltEntry;
         ok(entry->dwAltNameChoice == CERT_ALT_NAME_URL,
-         "Expected CERT_ALT_NAME_URL, got %d\n", entry->dwAltNameChoice);
+         "Expected CERT_ALT_NAME_URL, got %ld\n", entry->dwAltNameChoice);
         ok(!lstrcmpW(U(*entry).pwszURL, url), "Unexpected name\n");
         LocalFree(buf);
     }
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS,
      distPointWithUrlAndIssuer, distPointWithUrlAndIssuer[1] + 2, 0,
      NULL, NULL, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
     if (buf)
     {
         ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS,
          distPointWithUrlAndIssuer, distPointWithUrlAndIssuer[1] + 2, 0,
          NULL, buf, &size);
-        ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
         HeapFree(GetProcessHeap(), 0, buf);
     }
 }
@@ -3908,13 +3908,13 @@ static void test_encodeCRLIssuingDistPoint(DWORD dwEncoding)
         return;
     }
     ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
-     "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
+     "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
     ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(emptySequence), "Unexpected size %d\n", size);
+        ok(size == sizeof(emptySequence), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, emptySequence, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -3923,10 +3923,10 @@ static void test_encodeCRLIssuingDistPoint(DWORD dwEncoding)
     point.fOnlyContainsCACerts = TRUE;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(badFlagsIDP), "Unexpected size %d\n", size);
+        ok(size == sizeof(badFlagsIDP), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, badFlagsIDP, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -3936,16 +3936,16 @@ static void test_encodeCRLIssuingDistPoint(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* empty name */
     point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_FULL_NAME;
     U(point.DistPointName).FullName.cAltEntry = 0;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(emptyNameIDP), "Unexpected size %d\n", size);
+        ok(size == sizeof(emptyNameIDP), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, emptyNameIDP, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -3956,10 +3956,10 @@ static void test_encodeCRLIssuingDistPoint(DWORD dwEncoding)
     U(point.DistPointName).FullName.rgAltEntry = &entry;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(urlIDP), "Unexpected size %d\n", size);
+        ok(size == sizeof(urlIDP), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, urlIDP, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -3969,7 +3969,7 @@ static void compareAltNameEntry(const CERT_ALT_NAME_ENTRY *expected,
  const CERT_ALT_NAME_ENTRY *got)
 {
     ok(expected->dwAltNameChoice == got->dwAltNameChoice,
-     "Expected name choice %d, got %d\n", expected->dwAltNameChoice,
+     "Expected name choice %ld, got %ld\n", expected->dwAltNameChoice,
      got->dwAltNameChoice);
     if (expected->dwAltNameChoice == got->dwAltNameChoice)
     {
@@ -3990,7 +3990,7 @@ static void compareAltNameEntry(const CERT_ALT_NAME_ENTRY *expected,
         case CERT_ALT_NAME_DIRECTORY_NAME:
         case CERT_ALT_NAME_IP_ADDRESS:
             ok(U(*got).IPAddress.cbData == U(*expected).IPAddress.cbData,
-               "Unexpected IP address length %d\n", U(*got).IPAddress.cbData);
+               "Unexpected IP address length %ld\n", U(*got).IPAddress.cbData);
             ok(!memcmp(U(*got).IPAddress.pbData, U(*expected).IPAddress.pbData,
                        U(*got).IPAddress.cbData), "Unexpected value\n");
             break;
@@ -4003,7 +4003,7 @@ static void compareAltNameInfo(const CERT_ALT_NAME_INFO *expected,
 {
     DWORD i;
 
-    ok(expected->cAltEntry == got->cAltEntry, "Expected %d entries, got %d\n",
+    ok(expected->cAltEntry == got->cAltEntry, "Expected %ld entries, got %ld\n",
      expected->cAltEntry, got->cAltEntry);
     for (i = 0; i < min(expected->cAltEntry, got->cAltEntry); i++)
         compareAltNameEntry(&expected->rgAltEntry[i], &got->rgAltEntry[i]);
@@ -4013,7 +4013,7 @@ static void compareDistPointName(const CRL_DIST_POINT_NAME *expected,
  const CRL_DIST_POINT_NAME *got)
 {
     ok(got->dwDistPointNameChoice == expected->dwDistPointNameChoice,
-     "Unexpected name choice %d\n", got->dwDistPointNameChoice);
+     "Unexpected name choice %ld\n", got->dwDistPointNameChoice);
     if (got->dwDistPointNameChoice == CRL_DIST_POINT_FULL_NAME)
         compareAltNameInfo(&(U(*expected).FullName), &(U(*got).FullName));
 }
@@ -4047,7 +4047,7 @@ static void test_decodeCRLIssuingDistPoint(DWORD dwEncoding)
         skip("no X509_ISSUING_DIST_POINT decode support\n");
         return;
     }
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         compareCRLIssuingDistPoints(&point, (PCRL_ISSUING_DIST_POINT)buf);
@@ -4056,7 +4056,7 @@ static void test_decodeCRLIssuingDistPoint(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT,
      badFlagsIDP, badFlagsIDP[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL,
      &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         point.fOnlyContainsUserCerts = point.fOnlyContainsCACerts = TRUE;
@@ -4066,7 +4066,7 @@ static void test_decodeCRLIssuingDistPoint(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT,
      emptyNameIDP, emptyNameIDP[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL,
      &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         point.fOnlyContainsCACerts = point.fOnlyContainsUserCerts = FALSE;
@@ -4077,7 +4077,7 @@ static void test_decodeCRLIssuingDistPoint(DWORD dwEncoding)
     }
     ret = pCryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT,
      urlIDP, urlIDP[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_ALT_NAME_ENTRY entry;
@@ -4148,10 +4148,10 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+     "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(v1CRL), "Wrong size %d\n", size);
+        ok(size == sizeof(v1CRL), "Wrong size %ld\n", size);
         ok(!memcmp(buf, v1CRL, size), "Got unexpected value\n");
         LocalFree(buf);
     }
@@ -4160,10 +4160,10 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+     "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == v2CRL[1] + 2, "Expected size %d, got %d\n",
+        ok(size == v2CRL[1] + 2, "Expected size %d, got %ld\n",
          v2CRL[1] + 2, size);
         ok(!memcmp(buf, v2CRL, size), "Got unexpected value\n");
         LocalFree(buf);
@@ -4174,10 +4174,10 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding)
     info.Issuer.pbData = (BYTE *)encodedCommonName;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(v1CRLWithIssuer), "Wrong size %d\n", size);
+        ok(size == sizeof(v1CRLWithIssuer), "Wrong size %ld\n", size);
         ok(!memcmp(buf, v1CRLWithIssuer, size), "Got unexpected value\n");
         LocalFree(buf);
     }
@@ -4188,7 +4188,7 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding)
         ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
         ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
-         "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
+         "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
     }
     /* now set an empty entry */
     info.cCRLEntry = 1;
@@ -4198,7 +4198,7 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding)
     if (ret)
     {
         ok(size == sizeof(v1CRLWithIssuerAndEmptyEntry),
-         "Wrong size %d\n", size);
+         "Wrong size %ld\n", size);
         ok(!memcmp(buf, v1CRLWithIssuerAndEmptyEntry, size),
          "Got unexpected value\n");
         LocalFree(buf);
@@ -4211,7 +4211,7 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding)
     if (ret)
     {
         ok(size == sizeof(v1CRLWithIssuerAndEntry),
-         "Wrong size %d\n", size);
+         "Wrong size %ld\n", size);
         ok(!memcmp(buf, v1CRLWithIssuerAndEntry, size),
          "Got unexpected value\n");
         LocalFree(buf);
@@ -4221,10 +4221,10 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding)
     entry.rgExtension = &criticalExt;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(v1CRLWithEntryExt), "Wrong size %d\n", size);
+        ok(size == sizeof(v1CRLWithEntryExt), "Wrong size %ld\n", size);
         ok(!memcmp(buf, v1CRLWithEntryExt, size), "Got unexpected value\n");
         LocalFree(buf);
     }
@@ -4234,10 +4234,10 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding)
     info.rgExtension = &criticalExt;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(v1CRLWithExt), "Wrong size %d\n", size);
+        ok(size == sizeof(v1CRLWithExt), "Wrong size %ld\n", size);
         ok(!memcmp(buf, v1CRLWithExt, size), "Got unexpected value\n");
         LocalFree(buf);
     }
@@ -4246,10 +4246,10 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding)
     info.rgExtension = &nonCriticalExt;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(v2CRLWithExt), "Wrong size %d\n", size);
+        ok(size == sizeof(v2CRLWithExt), "Wrong size %ld\n", size);
         ok(!memcmp(buf, v2CRLWithExt, size), "Got unexpected value\n");
         LocalFree(buf);
     }
@@ -4814,23 +4814,23 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding)
          &buf, &size);
         ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT ||
          GetLastError() == OSS_DATA_ERROR /* Win9x */),
-         "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n",
+         "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n",
          GetLastError());
     }
     /* at a minimum, a CRL must contain an issuer: */
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED,
      v1CRLWithIssuer, v1CRLWithIssuer[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL,
      &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CRL_INFO *info = (CRL_INFO *)buf;
 
-        ok(size >= sizeof(CRL_INFO), "Wrong size %d\n", size);
-        ok(info->cCRLEntry == 0, "Expected 0 CRL entries, got %d\n",
+        ok(size >= sizeof(CRL_INFO), "Wrong size %ld\n", size);
+        ok(info->cCRLEntry == 0, "Expected 0 CRL entries, got %ld\n",
          info->cCRLEntry);
         ok(info->Issuer.cbData == sizeof(encodedCommonName),
-         "Wrong issuer size %d\n", info->Issuer.cbData);
+         "Wrong issuer size %ld\n", info->Issuer.cbData);
         ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
          "Unexpected issuer\n");
         LocalFree(buf);
@@ -4842,31 +4842,31 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding)
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT ||
      GetLastError() == OSS_DATA_ERROR /* Win9x */ ||
      GetLastError() == CRYPT_E_BAD_ENCODE /* Win8 */),
-     "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n",
+     "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n",
      GetLastError());
     /* with a real CRL entry */
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED,
      v1CRLWithIssuerAndEntry, v1CRLWithIssuerAndEntry[1] + 2,
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CRL_INFO *info = (CRL_INFO *)buf;
         CRL_ENTRY *entry;
 
-        ok(size >= sizeof(CRL_INFO), "Wrong size %d\n", size);
-        ok(info->cCRLEntry == 1, "Expected 1 CRL entries, got %d\n",
+        ok(size >= sizeof(CRL_INFO), "Wrong size %ld\n", size);
+        ok(info->cCRLEntry == 1, "Expected 1 CRL entries, got %ld\n",
          info->cCRLEntry);
         ok(info->rgCRLEntry != NULL, "Expected a valid CRL entry array\n");
         entry = info->rgCRLEntry;
         ok(entry->SerialNumber.cbData == 1,
-         "Expected serial number size 1, got %d\n",
+         "Expected serial number size 1, got %ld\n",
          entry->SerialNumber.cbData);
         ok(*entry->SerialNumber.pbData == *serialNum,
          "Expected serial number %d, got %d\n", *serialNum,
          *entry->SerialNumber.pbData);
         ok(info->Issuer.cbData == sizeof(encodedCommonName),
-         "Wrong issuer size %d\n", info->Issuer.cbData);
+         "Wrong issuer size %ld\n", info->Issuer.cbData);
         ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
          "Unexpected issuer\n");
         LocalFree(buf);
@@ -4875,16 +4875,16 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED,
      verisignCRL, sizeof(verisignCRL), CRYPT_DECODE_ALLOC_FLAG,
      NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CRL_INFO *info = (CRL_INFO *)buf;
 
-        ok(size >= sizeof(CRL_INFO), "Wrong size %d\n", size);
-        ok(info->cCRLEntry == 3, "Expected 3 CRL entries, got %d\n",
+        ok(size >= sizeof(CRL_INFO), "Wrong size %ld\n", size);
+        ok(info->cCRLEntry == 3, "Expected 3 CRL entries, got %ld\n",
          info->cCRLEntry);
         ok(info->rgCRLEntry != NULL, "Expected a valid CRL entry array\n");
-        ok(info->cExtension == 2, "Expected 2 extensions, got %d\n",
+        ok(info->cExtension == 2, "Expected 2 extensions, got %ld\n",
          info->cExtension);
         LocalFree(buf);
     }
@@ -4892,15 +4892,15 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED,
      verisignCRLWithLotsOfEntries, sizeof(verisignCRLWithLotsOfEntries),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CRL_INFO *info = (CRL_INFO *)buf;
 
-        ok(size >= sizeof(CRL_INFO), "Got size %d\n", size);
-        ok(info->cCRLEntry == 209, "Expected 209 CRL entries, got %d\n",
+        ok(size >= sizeof(CRL_INFO), "Got size %ld\n", size);
+        ok(info->cCRLEntry == 209, "Expected 209 CRL entries, got %ld\n",
          info->cCRLEntry);
-        ok(info->cExtension == 0, "Expected 0 extensions, got %d\n",
+        ok(info->cExtension == 0, "Expected 0 extensions, got %ld\n",
          info->cExtension);
         LocalFree(buf);
     }
@@ -4908,40 +4908,40 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED,
      v1CRLWithExt, sizeof(v1CRLWithExt), CRYPT_DECODE_ALLOC_FLAG,
      NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CRL_INFO *info = (CRL_INFO *)buf;
         CRL_ENTRY *entry;
 
-        ok(size >= sizeof(CRL_INFO), "Wrong size %d\n", size);
-        ok(info->cCRLEntry == 1, "Expected 1 CRL entries, got %d\n",
+        ok(size >= sizeof(CRL_INFO), "Wrong size %ld\n", size);
+        ok(info->cCRLEntry == 1, "Expected 1 CRL entries, got %ld\n",
          info->cCRLEntry);
         ok(info->rgCRLEntry != NULL, "Expected a valid CRL entry array\n");
         entry = info->rgCRLEntry;
         ok(entry->SerialNumber.cbData == 1,
-         "Expected serial number size 1, got %d\n",
+         "Expected serial number size 1, got %ld\n",
          entry->SerialNumber.cbData);
         ok(*entry->SerialNumber.pbData == *serialNum,
          "Expected serial number %d, got %d\n", *serialNum,
          *entry->SerialNumber.pbData);
         ok(info->Issuer.cbData == sizeof(encodedCommonName),
-         "Wrong issuer size %d\n", info->Issuer.cbData);
+         "Wrong issuer size %ld\n", info->Issuer.cbData);
         ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData),
          "Unexpected issuer\n");
-        ok(info->cExtension == 1, "Expected 1 extensions, got %d\n",
+        ok(info->cExtension == 1, "Expected 1 extensions, got %ld\n",
          info->cExtension);
         LocalFree(buf);
     }
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED,
      v2CRLWithExt, sizeof(v2CRLWithExt), CRYPT_DECODE_ALLOC_FLAG,
      NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CRL_INFO *info = (CRL_INFO *)buf;
 
-        ok(info->cExtension == 1, "Expected 1 extensions, got %d\n",
+        ok(info->cExtension == 1, "Expected 1 extensions, got %ld\n",
          info->cExtension);
         LocalFree(buf);
     }
@@ -4965,10 +4965,10 @@ static void test_encodeEnhancedKeyUsage(DWORD dwEncoding)
     usage.cUsageIdentifier = 0;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(emptySequence), "Wrong size %d\n", size);
+        ok(size == sizeof(emptySequence), "Wrong size %ld\n", size);
         ok(!memcmp(buf, emptySequence, size), "Got unexpected value\n");
         LocalFree(buf);
     }
@@ -4977,10 +4977,10 @@ static void test_encodeEnhancedKeyUsage(DWORD dwEncoding)
     usage.rgpszUsageIdentifier = (LPSTR *)keyUsages;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(encodedUsage), "Wrong size %d\n", size);
+        ok(size == sizeof(encodedUsage), "Wrong size %ld\n", size);
         ok(!memcmp(buf, encodedUsage, size), "Got unexpected value\n");
         LocalFree(buf);
     }
@@ -4995,30 +4995,30 @@ static void test_decodeEnhancedKeyUsage(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE,
      emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL,
      &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_ENHKEY_USAGE *usage = (CERT_ENHKEY_USAGE *)buf;
 
         ok(size >= sizeof(CERT_ENHKEY_USAGE),
-         "Wrong size %d\n", size);
-        ok(usage->cUsageIdentifier == 0, "Expected 0 CRL entries, got %d\n",
+         "Wrong size %ld\n", size);
+        ok(usage->cUsageIdentifier == 0, "Expected 0 CRL entries, got %ld\n",
          usage->cUsageIdentifier);
         LocalFree(buf);
     }
     ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE,
      encodedUsage, sizeof(encodedUsage), CRYPT_DECODE_ALLOC_FLAG, NULL,
      &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_ENHKEY_USAGE *usage = (CERT_ENHKEY_USAGE *)buf;
         DWORD i;
 
         ok(size >= sizeof(CERT_ENHKEY_USAGE),
-         "Wrong size %d\n", size);
+         "Wrong size %ld\n", size);
         ok(usage->cUsageIdentifier == ARRAY_SIZE(keyUsages),
-           "Wrong CRL entries count %d\n", usage->cUsageIdentifier);
+           "Wrong CRL entries count %ld\n", usage->cUsageIdentifier);
         for (i = 0; i < usage->cUsageIdentifier; i++)
             ok(!strcmp(usage->rgpszUsageIdentifier[i], keyUsages[i]),
              "Expected OID %s, got %s\n", keyUsages[i],
@@ -5027,13 +5027,13 @@ static void test_decodeEnhancedKeyUsage(DWORD dwEncoding)
     }
     ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE,
      encodedUsage, sizeof(encodedUsage), 0, NULL, NULL, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
     if (buf)
     {
         ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE,
          encodedUsage, sizeof(encodedUsage), 0, NULL, buf, &size);
-        ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
         HeapFree(GetProcessHeap(), 0, buf);
     }
 }
@@ -5056,10 +5056,10 @@ static void test_encodeAuthorityKeyId(DWORD dwEncoding)
     /* Test with empty id */
     ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(emptySequence), "Unexpected size %d\n", size);
+        ok(size == sizeof(emptySequence), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, emptySequence, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -5068,10 +5068,10 @@ static void test_encodeAuthorityKeyId(DWORD dwEncoding)
     info.KeyId.pbData = keyId;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(authorityKeyIdWithId), "Unexpected size %d\n", size);
+        ok(size == sizeof(authorityKeyIdWithId), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, authorityKeyIdWithId, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -5081,10 +5081,10 @@ static void test_encodeAuthorityKeyId(DWORD dwEncoding)
     info.CertIssuer.pbData = (BYTE *)encodedCommonName;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(authorityKeyIdWithIssuer), "Unexpected size %d\n",
+        ok(size == sizeof(authorityKeyIdWithIssuer), "Unexpected size %ld\n",
          size);
         ok(!memcmp(buf, authorityKeyIdWithIssuer, size), "Unexpected value\n");
         LocalFree(buf);
@@ -5095,10 +5095,10 @@ static void test_encodeAuthorityKeyId(DWORD dwEncoding)
     info.CertSerialNumber.pbData = (BYTE *)serialNum;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(authorityKeyIdWithSerial), "Unexpected size %d\n",
+        ok(size == sizeof(authorityKeyIdWithSerial), "Unexpected size %ld\n",
          size);
         ok(!memcmp(buf, authorityKeyIdWithSerial, size), "Unexpected value\n");
         LocalFree(buf);
@@ -5114,12 +5114,12 @@ static void test_decodeAuthorityKeyId(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID,
      emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL,
      &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_AUTHORITY_KEY_ID_INFO *info = (CERT_AUTHORITY_KEY_ID_INFO *)buf;
 
-        ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %d\n",
+        ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %ld\n",
          size);
         ok(info->KeyId.cbData == 0, "Expected no key id\n");
         ok(info->CertIssuer.cbData == 0, "Expected no issuer name\n");
@@ -5129,12 +5129,12 @@ static void test_decodeAuthorityKeyId(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID,
      authorityKeyIdWithId, sizeof(authorityKeyIdWithId),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_AUTHORITY_KEY_ID_INFO *info = (CERT_AUTHORITY_KEY_ID_INFO *)buf;
 
-        ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %d\n",
+        ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %ld\n",
          size);
         ok(info->KeyId.cbData == sizeof(keyId), "Unexpected key id len\n");
         ok(!memcmp(info->KeyId.pbData, keyId, sizeof(keyId)),
@@ -5146,12 +5146,12 @@ static void test_decodeAuthorityKeyId(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID,
      authorityKeyIdWithIssuer, sizeof(authorityKeyIdWithIssuer),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_AUTHORITY_KEY_ID_INFO *info = (CERT_AUTHORITY_KEY_ID_INFO *)buf;
 
-        ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %d\n",
+        ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %ld\n",
          size);
         ok(info->KeyId.cbData == 0, "Expected no key id\n");
         ok(info->CertIssuer.cbData == sizeof(encodedCommonName),
@@ -5164,12 +5164,12 @@ static void test_decodeAuthorityKeyId(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID,
      authorityKeyIdWithSerial, sizeof(authorityKeyIdWithSerial),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_AUTHORITY_KEY_ID_INFO *info = (CERT_AUTHORITY_KEY_ID_INFO *)buf;
 
-        ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %d\n",
+        ok(size >= sizeof(CERT_AUTHORITY_KEY_ID_INFO), "Unexpected size %ld\n",
          size);
         ok(info->KeyId.cbData == 0, "Expected no key id\n");
         ok(info->CertIssuer.cbData == 0, "Expected no issuer name\n");
@@ -5196,10 +5196,10 @@ static void test_encodeAuthorityKeyId2(DWORD dwEncoding)
     /* Test with empty id */
     ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(emptySequence), "Unexpected size %d\n", size);
+        ok(size == sizeof(emptySequence), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, emptySequence, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -5208,10 +5208,10 @@ static void test_encodeAuthorityKeyId2(DWORD dwEncoding)
     info.KeyId.pbData = keyId;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(authorityKeyIdWithId), "Unexpected size %d\n",
+        ok(size == sizeof(authorityKeyIdWithId), "Unexpected size %ld\n",
          size);
         ok(!memcmp(buf, authorityKeyIdWithId, size), "Unexpected value\n");
         LocalFree(buf);
@@ -5223,16 +5223,16 @@ static void test_encodeAuthorityKeyId2(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* With an issuer name */
     entry.dwAltNameChoice = CERT_ALT_NAME_URL;
     U(entry).pwszURL = (LPWSTR)url;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(authorityKeyIdWithIssuerUrl), "Unexpected size %d\n",
+        ok(size == sizeof(authorityKeyIdWithIssuerUrl), "Unexpected size %ld\n",
          size);
         ok(!memcmp(buf, authorityKeyIdWithIssuerUrl, size),
          "Unexpected value\n");
@@ -5244,10 +5244,10 @@ static void test_encodeAuthorityKeyId2(DWORD dwEncoding)
     info.AuthorityCertSerialNumber.pbData = (BYTE *)serialNum;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(authorityKeyIdWithSerial), "Unexpected size %d\n",
+        ok(size == sizeof(authorityKeyIdWithSerial), "Unexpected size %ld\n",
          size);
         ok(!memcmp(buf, authorityKeyIdWithSerial, size), "Unexpected value\n");
         LocalFree(buf);
@@ -5263,12 +5263,12 @@ static void test_decodeAuthorityKeyId2(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2,
      emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL,
      &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_AUTHORITY_KEY_ID2_INFO *info = (CERT_AUTHORITY_KEY_ID2_INFO *)buf;
 
-        ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %d\n",
+        ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %ld\n",
          size);
         ok(info->KeyId.cbData == 0, "Expected no key id\n");
         ok(info->AuthorityCertIssuer.cAltEntry == 0,
@@ -5280,12 +5280,12 @@ static void test_decodeAuthorityKeyId2(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2,
      authorityKeyIdWithId, sizeof(authorityKeyIdWithId),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_AUTHORITY_KEY_ID2_INFO *info = (CERT_AUTHORITY_KEY_ID2_INFO *)buf;
 
-        ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %d\n",
+        ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %ld\n",
          size);
         ok(info->KeyId.cbData == sizeof(keyId), "Unexpected key id len\n");
         ok(!memcmp(info->KeyId.pbData, keyId, sizeof(keyId)),
@@ -5299,19 +5299,19 @@ static void test_decodeAuthorityKeyId2(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2,
      authorityKeyIdWithIssuerUrl, sizeof(authorityKeyIdWithIssuerUrl),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_AUTHORITY_KEY_ID2_INFO *info = (CERT_AUTHORITY_KEY_ID2_INFO *)buf;
 
-        ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %d\n",
+        ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %ld\n",
          size);
         ok(info->KeyId.cbData == 0, "Expected no key id\n");
         ok(info->AuthorityCertIssuer.cAltEntry == 1,
-         "Expected 1 issuer entry, got %d\n",
+         "Expected 1 issuer entry, got %ld\n",
          info->AuthorityCertIssuer.cAltEntry);
         ok(info->AuthorityCertIssuer.rgAltEntry[0].dwAltNameChoice ==
-         CERT_ALT_NAME_URL, "Expected CERT_ALT_NAME_URL, got %d\n",
+         CERT_ALT_NAME_URL, "Expected CERT_ALT_NAME_URL, got %ld\n",
          info->AuthorityCertIssuer.rgAltEntry[0].dwAltNameChoice);
         ok(!lstrcmpW(U(info->AuthorityCertIssuer.rgAltEntry[0]).pwszURL,
          url), "Unexpected URL\n");
@@ -5322,12 +5322,12 @@ static void test_decodeAuthorityKeyId2(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2,
      authorityKeyIdWithSerial, sizeof(authorityKeyIdWithSerial),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         CERT_AUTHORITY_KEY_ID2_INFO *info = (CERT_AUTHORITY_KEY_ID2_INFO *)buf;
 
-        ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %d\n",
+        ok(size >= sizeof(CERT_AUTHORITY_KEY_ID2_INFO), "Unexpected size %ld\n",
          size);
         ok(info->KeyId.cbData == 0, "Expected no key id\n");
         ok(info->AuthorityCertIssuer.cAltEntry == 0,
@@ -5364,10 +5364,10 @@ static void test_encodeAuthorityInfoAccess(DWORD dwEncoding)
     /* Having no access descriptions is allowed */
     ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(emptySequence), "unexpected size %d\n", size);
+        ok(size == sizeof(emptySequence), "unexpected size %ld\n", size);
         ok(!memcmp(buf, emptySequence, size), "unexpected value\n");
         LocalFree(buf);
         buf = NULL;
@@ -5379,22 +5379,22 @@ static void test_encodeAuthorityInfoAccess(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && (GetLastError() == E_INVALIDARG ||
      GetLastError() == OSS_LIMITED /* Win9x */),
-     "expected E_INVALIDARG or OSS_LIMITED, got %08x\n", GetLastError());
+     "expected E_INVALIDARG or OSS_LIMITED, got %08lx\n", GetLastError());
     /* It can't have an empty location */
     accessDescription[0].pszAccessMethod = oid1;
     SetLastError(0xdeadbeef);
     ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
     accessDescription[0].AccessLocation.dwAltNameChoice = CERT_ALT_NAME_URL;
     U(accessDescription[0].AccessLocation).pwszURL = (LPWSTR)url;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(authorityInfoAccessWithUrl), "unexpected size %d\n",
+        ok(size == sizeof(authorityInfoAccessWithUrl), "unexpected size %ld\n",
          size);
         ok(!memcmp(buf, authorityInfoAccessWithUrl, size),
          "unexpected value\n");
@@ -5411,11 +5411,11 @@ static void test_encodeAuthorityInfoAccess(DWORD dwEncoding)
     aia.cAccDescr = 2;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, &aia,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(size == sizeof(authorityInfoAccessWithUrlAndIPAddr),
-         "unexpected size %d\n", size);
+         "unexpected size %ld\n", size);
         ok(!memcmp(buf, authorityInfoAccessWithUrlAndIPAddr, size),
          "unexpected value\n");
         LocalFree(buf);
@@ -5430,12 +5430,12 @@ static void compareAuthorityInfoAccess(LPCSTR header,
     DWORD i;
 
     ok(expected->cAccDescr == got->cAccDescr,
-     "%s: expected %d access descriptions, got %d\n", header,
+     "%s: expected %ld access descriptions, got %ld\n", header,
      expected->cAccDescr, got->cAccDescr);
     for (i = 0; i < expected->cAccDescr; i++)
     {
         ok(!strcmp(expected->rgAccDescr[i].pszAccessMethod,
-         got->rgAccDescr[i].pszAccessMethod), "%s[%d]: expected %s, got %s\n",
+         got->rgAccDescr[i].pszAccessMethod), "%s[%ld]: expected %s, got %s\n",
          header, i, expected->rgAccDescr[i].pszAccessMethod,
          got->rgAccDescr[i].pszAccessMethod);
         compareAltNameEntry(&expected->rgAccDescr[i].AccessLocation,
@@ -5454,7 +5454,7 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS,
      emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL,
      &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
         CERT_AUTHORITY_INFO_ACCESS aia = { 0, NULL };
@@ -5467,7 +5467,7 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS,
      authorityInfoAccessWithUrl, sizeof(authorityInfoAccessWithUrl),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
         CERT_ACCESS_DESCRIPTION accessDescription;
@@ -5487,7 +5487,7 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding)
      authorityInfoAccessWithUrlAndIPAddr,
      sizeof(authorityInfoAccessWithUrlAndIPAddr), CRYPT_DECODE_ALLOC_FLAG,
      NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
         CERT_ACCESS_DESCRIPTION accessDescription[2];
@@ -5513,14 +5513,14 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS,
      authorityInfoAccessWithUrlAndIPAddr,
      sizeof(authorityInfoAccessWithUrlAndIPAddr), 0, NULL, NULL, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
     buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
     if (buf)
     {
         ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS,
          authorityInfoAccessWithUrlAndIPAddr,
          sizeof(authorityInfoAccessWithUrlAndIPAddr), 0, NULL, buf, &size);
-        ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+        ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
         HeapFree(GetProcessHeap(), 0, buf);
     }
 }
@@ -5582,10 +5582,10 @@ static void test_encodeCTL(DWORD dwEncoding)
     memset(&info, 0, sizeof(info));
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(emptyCTL), "unexpected size %d\n", size);
+        ok(size == sizeof(emptyCTL), "unexpected size %ld\n", size);
         ok(!memcmp(buf, emptyCTL, size), "unexpected value\n");
         LocalFree(buf);
         buf = NULL;
@@ -5593,10 +5593,10 @@ static void test_encodeCTL(DWORD dwEncoding)
     info.dwVersion = 1;
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(emptyCTLWithVersion1), "unexpected size %d\n", size);
+        ok(size == sizeof(emptyCTLWithVersion1), "unexpected size %ld\n", size);
         ok(!memcmp(buf, emptyCTLWithVersion1, size), "unexpected value\n");
         LocalFree(buf);
         buf = NULL;
@@ -5606,10 +5606,10 @@ static void test_encodeCTL(DWORD dwEncoding)
     info.SubjectUsage.rgpszUsageIdentifier = &pOid1;
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(ctlWithUsageIdentifier), "unexpected size %d\n",
+        ok(size == sizeof(ctlWithUsageIdentifier), "unexpected size %ld\n",
          size);
         ok(!memcmp(buf, ctlWithUsageIdentifier, size), "unexpected value\n");
         LocalFree(buf);
@@ -5620,10 +5620,10 @@ static void test_encodeCTL(DWORD dwEncoding)
     info.ListIdentifier.pbData = (LPBYTE)serialNum;
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(ctlWithListIdentifier), "unexpected size %d\n", size);
+        ok(size == sizeof(ctlWithListIdentifier), "unexpected size %ld\n", size);
         ok(!memcmp(buf, ctlWithListIdentifier, size), "unexpected value\n");
         LocalFree(buf);
         buf = NULL;
@@ -5633,10 +5633,10 @@ static void test_encodeCTL(DWORD dwEncoding)
     info.SequenceNumber.pbData = (LPBYTE)serialNum;
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(ctlWithSequenceNumber), "unexpected size %d\n",
+        ok(size == sizeof(ctlWithSequenceNumber), "unexpected size %ld\n",
          size);
         ok(!memcmp(buf, ctlWithSequenceNumber, size), "unexpected value\n");
         LocalFree(buf);
@@ -5646,10 +5646,10 @@ static void test_encodeCTL(DWORD dwEncoding)
     SystemTimeToFileTime(&thisUpdate, &info.ThisUpdate);
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(ctlWithThisUpdate), "unexpected size %d\n", size);
+        ok(size == sizeof(ctlWithThisUpdate), "unexpected size %ld\n", size);
         ok(!memcmp(buf, ctlWithThisUpdate, size), "unexpected value\n");
         LocalFree(buf);
         buf = NULL;
@@ -5657,10 +5657,10 @@ static void test_encodeCTL(DWORD dwEncoding)
     SystemTimeToFileTime(&thisUpdate, &info.NextUpdate);
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(ctlWithThisAndNextUpdate), "unexpected size %d\n",
+        ok(size == sizeof(ctlWithThisAndNextUpdate), "unexpected size %ld\n",
          size);
         ok(!memcmp(buf, ctlWithThisAndNextUpdate, size), "unexpected value\n");
         LocalFree(buf);
@@ -5671,10 +5671,10 @@ static void test_encodeCTL(DWORD dwEncoding)
     info.SubjectAlgorithm.pszObjId = oid2;
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(ctlWithAlgId), "unexpected size %d\n", size);
+        ok(size == sizeof(ctlWithAlgId), "unexpected size %ld\n", size);
         ok(!memcmp(buf, ctlWithAlgId, size), "unexpected value\n");
         LocalFree(buf);
         buf = NULL;
@@ -5696,10 +5696,10 @@ static void test_encodeCTL(DWORD dwEncoding)
     info.rgCTLEntry = ctlEntry;
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(ctlWithBogusEntry), "unexpected size %d\n", size);
+        ok(size == sizeof(ctlWithBogusEntry), "unexpected size %ld\n", size);
         ok(!memcmp(buf, ctlWithBogusEntry, size), "unexpected value\n");
         LocalFree(buf);
         buf = NULL;
@@ -5708,10 +5708,10 @@ static void test_encodeCTL(DWORD dwEncoding)
     value1.pbData = (LPBYTE)emptySequence;
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(ctlWithOneEntry), "unexpected size %d\n", size);
+        ok(size == sizeof(ctlWithOneEntry), "unexpected size %ld\n", size);
         ok(!memcmp(buf, ctlWithOneEntry, size), "unexpected value\n");
         LocalFree(buf);
         buf = NULL;
@@ -5728,10 +5728,10 @@ static void test_encodeCTL(DWORD dwEncoding)
     info.cCTLEntry = 2;
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CTL, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(ctlWithTwoEntries), "unexpected size %d\n", size);
+        ok(size == sizeof(ctlWithTwoEntries), "unexpected size %ld\n", size);
         ok(!memcmp(buf, ctlWithTwoEntries, size), "unexpected value\n");
         LocalFree(buf);
         buf = NULL;
@@ -5744,39 +5744,39 @@ static void compareCTLInfo(LPCSTR header, const CTL_INFO *expected,
     DWORD i, j, k;
 
     ok(expected->dwVersion == got->dwVersion,
-     "%s: expected version %d, got %d\n", header, expected->dwVersion,
+     "%s: expected version %ld, got %ld\n", header, expected->dwVersion,
      got->dwVersion);
     ok(expected->SubjectUsage.cUsageIdentifier ==
      got->SubjectUsage.cUsageIdentifier,
-     "%s: expected %d usage identifiers, got %d\n", header,
+     "%s: expected %ld usage identifiers, got %ld\n", header,
      expected->SubjectUsage.cUsageIdentifier,
      got->SubjectUsage.cUsageIdentifier);
     for (i = 0; i < expected->SubjectUsage.cUsageIdentifier; i++)
         ok(!strcmp(expected->SubjectUsage.rgpszUsageIdentifier[i],
          got->SubjectUsage.rgpszUsageIdentifier[i]),
-         "%s[%d]: expected %s, got %s\n", header, i,
+         "%s[%ld]: expected %s, got %s\n", header, i,
          expected->SubjectUsage.rgpszUsageIdentifier[i],
          got->SubjectUsage.rgpszUsageIdentifier[i]);
     ok(expected->ListIdentifier.cbData == got->ListIdentifier.cbData,
-     "%s: expected list identifier of %d bytes, got %d\n", header,
+     "%s: expected list identifier of %ld bytes, got %ld\n", header,
      expected->ListIdentifier.cbData, got->ListIdentifier.cbData);
     if (expected->ListIdentifier.cbData)
         ok(!memcmp(expected->ListIdentifier.pbData, got->ListIdentifier.pbData,
          expected->ListIdentifier.cbData),
          "%s: unexpected list identifier value\n", header);
     ok(expected->SequenceNumber.cbData == got->SequenceNumber.cbData,
-     "%s: expected sequence number of %d bytes, got %d\n", header,
+     "%s: expected sequence number of %ld bytes, got %ld\n", header,
      expected->SequenceNumber.cbData, got->SequenceNumber.cbData);
     if (expected->SequenceNumber.cbData)
         ok(!memcmp(expected->SequenceNumber.pbData, got->SequenceNumber.pbData,
          expected->SequenceNumber.cbData),
          "%s: unexpected sequence number value\n", header);
     ok(!memcmp(&expected->ThisUpdate, &got->ThisUpdate, sizeof(FILETIME)),
-     "%s: expected this update = (%d, %d), got (%d, %d)\n", header,
+     "%s: expected this update = (%ld, %ld), got (%ld, %ld)\n", header,
      expected->ThisUpdate.dwLowDateTime, expected->ThisUpdate.dwHighDateTime,
      got->ThisUpdate.dwLowDateTime, got->ThisUpdate.dwHighDateTime);
     ok(!memcmp(&expected->NextUpdate, &got->NextUpdate, sizeof(FILETIME)),
-     "%s: expected next update = (%d, %d), got (%d, %d)\n", header,
+     "%s: expected next update = (%ld, %ld), got (%ld, %ld)\n", header,
      expected->NextUpdate.dwLowDateTime, expected->NextUpdate.dwHighDateTime,
      got->NextUpdate.dwLowDateTime, got->NextUpdate.dwHighDateTime);
     if (expected->SubjectAlgorithm.pszObjId &&
@@ -5790,7 +5790,7 @@ static void compareCTLInfo(LPCSTR header, const CTL_INFO *expected,
          expected->SubjectAlgorithm.pszObjId, got->SubjectAlgorithm.pszObjId);
     ok(expected->SubjectAlgorithm.Parameters.cbData ==
      got->SubjectAlgorithm.Parameters.cbData,
-     "%s: expected subject algorithm parameters of %d bytes, got %d\n", header,
+     "%s: expected subject algorithm parameters of %ld bytes, got %ld\n", header,
      expected->SubjectAlgorithm.Parameters.cbData,
      got->SubjectAlgorithm.Parameters.cbData);
     if (expected->SubjectAlgorithm.Parameters.cbData)
@@ -5799,33 +5799,33 @@ static void compareCTLInfo(LPCSTR header, const CTL_INFO *expected,
          expected->SubjectAlgorithm.Parameters.cbData),
          "%s: unexpected subject algorithm parameter value\n", header);
     ok(expected->cCTLEntry == got->cCTLEntry,
-     "%s: expected %d CTL entries, got %d\n", header, expected->cCTLEntry,
+     "%s: expected %ld CTL entries, got %ld\n", header, expected->cCTLEntry,
      got->cCTLEntry);
     for (i = 0; i < expected->cCTLEntry; i++)
     {
         ok(expected->rgCTLEntry[i].SubjectIdentifier.cbData ==
          got->rgCTLEntry[i].SubjectIdentifier.cbData,
-         "%s[%d]: expected subject identifier of %d bytes, got %d\n",
+         "%s[%ld]: expected subject identifier of %ld bytes, got %ld\n",
          header, i, expected->rgCTLEntry[i].SubjectIdentifier.cbData,
          got->rgCTLEntry[i].SubjectIdentifier.cbData);
         if (expected->rgCTLEntry[i].SubjectIdentifier.cbData)
             ok(!memcmp(expected->rgCTLEntry[i].SubjectIdentifier.pbData,
              got->rgCTLEntry[i].SubjectIdentifier.pbData,
              expected->rgCTLEntry[i].SubjectIdentifier.cbData),
-             "%s[%d]: unexpected subject identifier value\n",
+             "%s[%ld]: unexpected subject identifier value\n",
              header, i);
         for (j = 0; j < expected->rgCTLEntry[i].cAttribute; j++)
         {
             ok(!strcmp(expected->rgCTLEntry[i].rgAttribute[j].pszObjId,
              got->rgCTLEntry[i].rgAttribute[j].pszObjId),
-             "%s[%d][%d]: expected attribute OID %s, got %s\n", header, i, j,
+             "%s[%ld][%ld]: expected attribute OID %s, got %s\n", header, i, j,
              expected->rgCTLEntry[i].rgAttribute[j].pszObjId,
              got->rgCTLEntry[i].rgAttribute[j].pszObjId);
             for (k = 0; k < expected->rgCTLEntry[i].rgAttribute[j].cValue; k++)
             {
                 ok(expected->rgCTLEntry[i].rgAttribute[j].rgValue[k].cbData ==
                  got->rgCTLEntry[i].rgAttribute[j].rgValue[k].cbData,
-                 "%s[%d][%d][%d]: expected value of %d bytes, got %d\n",
+                 "%s[%ld][%ld][%ld]: expected value of %ld bytes, got %ld\n",
                  header, i, j, k,
                  expected->rgCTLEntry[i].rgAttribute[j].rgValue[k].cbData,
                  got->rgCTLEntry[i].rgAttribute[j].rgValue[k].cbData);
@@ -5834,33 +5834,33 @@ static void compareCTLInfo(LPCSTR header, const CTL_INFO *expected,
                      expected->rgCTLEntry[i].rgAttribute[j].rgValue[k].pbData,
                      got->rgCTLEntry[i].rgAttribute[j].rgValue[k].pbData,
                      expected->rgCTLEntry[i].rgAttribute[j].rgValue[k].cbData),
-                     "%s[%d][%d][%d]: unexpected value\n",
+                     "%s[%ld][%ld][%ld]: unexpected value\n",
                      header, i, j, k);
             }
         }
     }
     ok(expected->cExtension == got->cExtension,
-     "%s: expected %d extensions, got %d\n", header, expected->cExtension,
+     "%s: expected %ld extensions, got %ld\n", header, expected->cExtension,
      got->cExtension);
     for (i = 0; i < expected->cExtension; i++)
     {
         ok(!strcmp(expected->rgExtension[i].pszObjId,
-         got->rgExtension[i].pszObjId), "%s[%d]: expected %s, got %s\n",
+         got->rgExtension[i].pszObjId), "%s[%ld]: expected %s, got %s\n",
          header, i, expected->rgExtension[i].pszObjId,
          got->rgExtension[i].pszObjId);
         ok(expected->rgExtension[i].fCritical == got->rgExtension[i].fCritical,
-         "%s[%d]: expected fCritical = %d, got %d\n", header, i,
+         "%s[%ld]: expected fCritical = %d, got %d\n", header, i,
          expected->rgExtension[i].fCritical, got->rgExtension[i].fCritical);
         ok(expected->rgExtension[i].Value.cbData ==
          got->rgExtension[i].Value.cbData,
-         "%s[%d]: expected extension value to have %d bytes, got %d\n",
+         "%s[%ld]: expected extension value to have %ld bytes, got %ld\n",
          header, i, expected->rgExtension[i].Value.cbData,
          got->rgExtension[i].Value.cbData);
         if (expected->rgExtension[i].Value.cbData)
             ok(!memcmp(expected->rgExtension[i].Value.pbData,
              got->rgExtension[i].Value.pbData,
              expected->rgExtension[i].Value.cbData),
-             "%s[%d]: unexpected extension value\n", header, i);
+             "%s[%ld]: unexpected extension value\n", header, i);
     }
 }
 
@@ -5918,7 +5918,7 @@ static void test_decodeCTL(DWORD dwEncoding)
     memset(&info, 0, sizeof(info));
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, emptyCTL, sizeof(emptyCTL),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         compareCTLInfo("empty CTL", &info, (CTL_INFO *)buf);
@@ -5929,7 +5929,7 @@ static void test_decodeCTL(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, emptyCTLWithVersion1,
      sizeof(emptyCTLWithVersion1), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf,
      &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         compareCTLInfo("v1 CTL", &info, (CTL_INFO *)buf);
@@ -5942,7 +5942,7 @@ static void test_decodeCTL(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithUsageIdentifier,
      sizeof(ctlWithUsageIdentifier), CRYPT_DECODE_ALLOC_FLAG, NULL,
      &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         compareCTLInfo("CTL with usage identifier", &info, (CTL_INFO *)buf);
@@ -5954,7 +5954,7 @@ static void test_decodeCTL(DWORD dwEncoding)
     info.ListIdentifier.pbData = (LPBYTE)serialNum;
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithListIdentifier,
      sizeof(ctlWithListIdentifier), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         compareCTLInfo("CTL with list identifier", &info, (CTL_INFO *)buf);
@@ -5966,7 +5966,7 @@ static void test_decodeCTL(DWORD dwEncoding)
     info.SequenceNumber.pbData = (LPBYTE)serialNum;
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithSequenceNumber,
      sizeof(ctlWithSequenceNumber), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         compareCTLInfo("CTL with sequence number", &info, (CTL_INFO *)buf);
@@ -5977,7 +5977,7 @@ static void test_decodeCTL(DWORD dwEncoding)
     SystemTimeToFileTime(&thisUpdate, &info.ThisUpdate);
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithThisUpdate,
      sizeof(ctlWithThisUpdate), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         compareCTLInfo("CTL with this update", &info, (CTL_INFO *)buf);
@@ -5988,7 +5988,7 @@ static void test_decodeCTL(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithThisAndNextUpdate,
      sizeof(ctlWithThisAndNextUpdate), CRYPT_DECODE_ALLOC_FLAG, NULL,
      &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         compareCTLInfo("CTL with this and next update", &info, (CTL_INFO *)buf);
@@ -6002,7 +6002,7 @@ static void test_decodeCTL(DWORD dwEncoding)
     info.SubjectAlgorithm.Parameters.pbData = nullData;
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithAlgId,
      sizeof(ctlWithAlgId), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         compareCTLInfo("CTL with algorithm identifier", &info, (CTL_INFO *)buf);
@@ -6016,7 +6016,7 @@ static void test_decodeCTL(DWORD dwEncoding)
      (GetLastError() == CRYPT_E_ASN1_EOD ||
       GetLastError() == CRYPT_E_ASN1_CORRUPT ||
       GetLastError() == OSS_MORE_INPUT), /* Win9x */
-     "expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %08x\n",
+     "expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %08lx\n",
      GetLastError());
     info.SubjectAlgorithm.Parameters.cbData = 0;
     info.ThisUpdate.dwLowDateTime = info.ThisUpdate.dwHighDateTime = 0;
@@ -6036,7 +6036,7 @@ static void test_decodeCTL(DWORD dwEncoding)
     SetLastError(0xdeadbeef);
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithOneEntry,
      sizeof(ctlWithOneEntry), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         compareCTLInfo("CTL with one entry", &info, (CTL_INFO *)buf);
@@ -6055,7 +6055,7 @@ static void test_decodeCTL(DWORD dwEncoding)
     info.cCTLEntry = 2;
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL, ctlWithTwoEntries,
      sizeof(ctlWithTwoEntries), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         compareCTLInfo("CTL with two entries", &info, (CTL_INFO *)buf);
@@ -6068,7 +6068,7 @@ static void test_decodeCTL(DWORD dwEncoding)
      sizeof(signedCTL), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
      GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08x\n",
+     "expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08lx\n",
      GetLastError());
     SetLastError(0xdeadbeef);
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CTL,
@@ -6076,7 +6076,7 @@ static void test_decodeCTL(DWORD dwEncoding)
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
      GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08x\n",
+     "expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08lx\n",
      GetLastError());
 }
 
@@ -6104,21 +6104,21 @@ static void test_encodePKCSContentInfo(DWORD dwEncoding)
         ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, NULL,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
         ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
-         "Expected STATUS_ACCESS_VIOLATION, got %x\n", GetLastError());
+         "Expected STATUS_ACCESS_VIOLATION, got %lx\n", GetLastError());
     }
     SetLastError(0xdeadbeef);
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && (GetLastError() == E_INVALIDARG ||
      GetLastError() == OSS_LIMITED /* Win9x */),
-     "Expected E_INVALIDARG or OSS_LIMITED, got %x\n", GetLastError());
+     "Expected E_INVALIDARG or OSS_LIMITED, got %lx\n", GetLastError());
     info.pszObjId = oid1;
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(emptyPKCSContentInfo), "Unexpected size %d\n", size);
+        ok(size == sizeof(emptyPKCSContentInfo), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, emptyPKCSContentInfo, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -6126,10 +6126,10 @@ static void test_encodePKCSContentInfo(DWORD dwEncoding)
     info.Content.cbData = sizeof(bogusDER);
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed; %x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed; %lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(bogusPKCSContentInfo), "Unexpected size %d\n", size);
+        ok(size == sizeof(bogusPKCSContentInfo), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, bogusPKCSContentInfo, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -6139,7 +6139,7 @@ static void test_encodePKCSContentInfo(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (ret)
     {
-        ok(size == sizeof(intPKCSContentInfo), "Unexpected size %d\n", size);
+        ok(size == sizeof(intPKCSContentInfo), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, intPKCSContentInfo, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -6232,19 +6232,19 @@ static void test_decodePKCSContentInfo(DWORD dwEncoding)
     {
         ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, tests[i].encoded,
             tests[i].encoded_size, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-        ok(ret, "[%u] CryptDecodeObjectEx failed: %x\n", i, GetLastError());
+        ok(ret, "[%lu] CryptDecodeObjectEx failed: %lx\n", i, GetLastError());
         if (!ret) continue;
 
         info = (CRYPT_CONTENT_INFO *)buf;
 
-        ok(!strcmp(info->pszObjId, tests[i].obj_id), "[%u] Expected %s, got %s\n",
+        ok(!strcmp(info->pszObjId, tests[i].obj_id), "[%lu] Expected %s, got %s\n",
            i, tests[i].obj_id, info->pszObjId);
         ok(info->Content.cbData == tests[i].content_size,
-           "[%u] Unexpected size %d expected %d\n", i, info->Content.cbData,
+           "[%lu] Unexpected size %ld expected %d\n", i, info->Content.cbData,
            tests[i].content_size);
         if (tests[i].content)
             ok(!memcmp(info->Content.pbData, tests[i].content, tests[i].content_size),
-               "[%u] Unexpected value\n", i);
+               "[%lu] Unexpected value\n", i);
         LocalFree(buf);
     }
 
@@ -6256,7 +6256,7 @@ static void test_decodePKCSContentInfo(DWORD dwEncoding)
      */
     ok((!ret && (GetLastError() == CRYPT_E_ASN1_EOD ||
      GetLastError() == CRYPT_E_ASN1_CORRUPT)) || broken(ret),
-     "Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %x\n",
+     "Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %lx\n",
      GetLastError());
 }
 
@@ -6283,21 +6283,21 @@ static void test_encodePKCSAttribute(DWORD dwEncoding)
         ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, NULL,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
         ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
-         "Expected STATUS_ACCESS_VIOLATION, got %x\n", GetLastError());
+         "Expected STATUS_ACCESS_VIOLATION, got %lx\n", GetLastError());
     }
     SetLastError(0xdeadbeef);
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && (GetLastError() == E_INVALIDARG ||
      GetLastError() == OSS_LIMITED /* Win9x */),
-     "Expected E_INVALIDARG or OSS_LIMITED, got %x\n", GetLastError());
+     "Expected E_INVALIDARG or OSS_LIMITED, got %lx\n", GetLastError());
     attr.pszObjId = oid;
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(emptyPKCSAttr), "Unexpected size %d\n", size);
+        ok(size == sizeof(emptyPKCSAttr), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, emptyPKCSAttr, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -6307,10 +6307,10 @@ static void test_encodePKCSAttribute(DWORD dwEncoding)
     attr.rgValue = &blob;
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(bogusPKCSAttr), "Unexpected size %d\n", size);
+        ok(size == sizeof(bogusPKCSAttr), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, bogusPKCSAttr, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -6320,7 +6320,7 @@ static void test_encodePKCSAttribute(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (ret)
     {
-        ok(size == sizeof(intPKCSAttr), "Unexpected size %d\n", size);
+        ok(size == sizeof(intPKCSAttr), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, intPKCSAttr, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -6336,14 +6336,14 @@ static void test_decodePKCSAttribute(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE,
      emptyPKCSAttr, sizeof(emptyPKCSAttr),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
         attr = (CRYPT_ATTRIBUTE *)buf;
 
         ok(!strcmp(attr->pszObjId, "1.2.3"), "Expected 1.2.3, got %s\n",
          attr->pszObjId);
-        ok(attr->cValue == 0, "Expected no value, got %d\n", attr->cValue);
+        ok(attr->cValue == 0, "Expected no value, got %ld\n", attr->cValue);
         LocalFree(buf);
     }
     SetLastError(0xdeadbeef);
@@ -6356,21 +6356,21 @@ static void test_decodePKCSAttribute(DWORD dwEncoding)
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD ||
      GetLastError() == CRYPT_E_ASN1_CORRUPT ||
      GetLastError() == OSS_MORE_INPUT /* Win9x */),
-     "Expected CRYPT_E_ASN1_EOD, CRYPT_E_ASN1_CORRUPT, or OSS_MORE_INPUT, got %x\n",
+     "Expected CRYPT_E_ASN1_EOD, CRYPT_E_ASN1_CORRUPT, or OSS_MORE_INPUT, got %lx\n",
      GetLastError());
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE,
      intPKCSAttr, sizeof(intPKCSAttr),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
         attr = (CRYPT_ATTRIBUTE *)buf;
 
         ok(!strcmp(attr->pszObjId, "1.2.3"), "Expected 1.2.3, got %s\n",
          attr->pszObjId);
-        ok(attr->cValue == 1, "Expected 1 value, got %d\n", attr->cValue);
+        ok(attr->cValue == 1, "Expected 1 value, got %ld\n", attr->cValue);
         ok(attr->rgValue[0].cbData == ints[0].encoded[1] + 2,
-         "Unexpected size %d\n", attr->rgValue[0].cbData);
+         "Unexpected size %ld\n", attr->rgValue[0].cbData);
         ok(!memcmp(attr->rgValue[0].pbData, ints[0].encoded,
          attr->rgValue[0].cbData), "Unexpected value\n");
         LocalFree(buf);
@@ -6395,10 +6395,10 @@ static void test_encodePKCSAttributes(DWORD dwEncoding)
 
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(emptyPKCSAttributes), "Unexpected size %d\n", size);
+        ok(size == sizeof(emptyPKCSAttributes), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, emptyPKCSAttributes, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -6409,13 +6409,13 @@ static void test_encodePKCSAttributes(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && (GetLastError() == E_INVALIDARG ||
      GetLastError() == OSS_LIMITED /* Win9x */),
-     "Expected E_INVALIDARG or OSS_LIMITED, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG or OSS_LIMITED, got %08lx\n", GetLastError());
     attr[0].pszObjId = oid1;
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (ret)
     {
-        ok(size == sizeof(singlePKCSAttributes), "Unexpected size %d\n", size);
+        ok(size == sizeof(singlePKCSAttributes), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, singlePKCSAttributes, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -6427,10 +6427,10 @@ static void test_encodePKCSAttributes(DWORD dwEncoding)
     attributes.cAttr = 2;
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(doublePKCSAttributes), "Unexpected size %d\n", size);
+        ok(size == sizeof(doublePKCSAttributes), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, doublePKCSAttributes, size), "Unexpected value\n");
         LocalFree(buf);
     }
@@ -6446,61 +6446,61 @@ static void test_decodePKCSAttributes(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES,
      emptyPKCSAttributes, sizeof(emptyPKCSAttributes),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
         attributes = (CRYPT_ATTRIBUTES *)buf;
-        ok(attributes->cAttr == 0, "Expected no attributes, got %d\n",
+        ok(attributes->cAttr == 0, "Expected no attributes, got %ld\n",
          attributes->cAttr);
         LocalFree(buf);
     }
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES,
      singlePKCSAttributes, sizeof(singlePKCSAttributes),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
         attributes = (CRYPT_ATTRIBUTES *)buf;
-        ok(attributes->cAttr == 1, "Expected 1 attribute, got %d\n",
+        ok(attributes->cAttr == 1, "Expected 1 attribute, got %ld\n",
          attributes->cAttr);
         ok(!strcmp(attributes->rgAttr[0].pszObjId, "1.2.3"),
          "Expected 1.2.3, got %s\n", attributes->rgAttr[0].pszObjId);
         ok(attributes->rgAttr[0].cValue == 0,
-         "Expected no attributes, got %d\n", attributes->rgAttr[0].cValue);
+         "Expected no attributes, got %ld\n", attributes->rgAttr[0].cValue);
         LocalFree(buf);
     }
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES,
      doublePKCSAttributes, sizeof(doublePKCSAttributes),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
         attributes = (CRYPT_ATTRIBUTES *)buf;
-        ok(attributes->cAttr == 2, "Expected 2 attributes, got %d\n",
+        ok(attributes->cAttr == 2, "Expected 2 attributes, got %ld\n",
          attributes->cAttr);
         ok(!strcmp(attributes->rgAttr[0].pszObjId, "1.2.3"),
          "Expected 1.2.3, got %s\n", attributes->rgAttr[0].pszObjId);
         ok(attributes->rgAttr[0].cValue == 0,
-         "Expected no attributes, got %d\n", attributes->rgAttr[0].cValue);
+         "Expected no attributes, got %ld\n", attributes->rgAttr[0].cValue);
         ok(!strcmp(attributes->rgAttr[1].pszObjId, "1.5.6"),
          "Expected 1.5.6, got %s\n", attributes->rgAttr[1].pszObjId);
         ok(attributes->rgAttr[1].cValue == 1,
-         "Expected 1 attribute, got %d\n", attributes->rgAttr[1].cValue);
+         "Expected 1 attribute, got %ld\n", attributes->rgAttr[1].cValue);
         ok(attributes->rgAttr[1].rgValue[0].cbData == ints[0].encoded[1] + 2,
-         "Unexpected size %d\n", attributes->rgAttr[1].rgValue[0].cbData);
+         "Unexpected size %ld\n", attributes->rgAttr[1].rgValue[0].cbData);
         ok(!memcmp(attributes->rgAttr[1].rgValue[0].pbData, ints[0].encoded,
          attributes->rgAttr[1].rgValue[0].cbData), "Unexpected value\n");
         LocalFree(buf);
     }
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES,
      doublePKCSAttributes, sizeof(doublePKCSAttributes), 0, NULL, NULL, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
     buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
     if (buf)
     {
         ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES,
          doublePKCSAttributes, sizeof(doublePKCSAttributes), 0, NULL, buf, &size);
-        ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+        ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
         HeapFree(GetProcessHeap(), 0, buf);
     }
 }
@@ -6525,10 +6525,10 @@ static void test_encodePKCSSMimeCapabilities(DWORD dwEncoding)
     capabilities.cCapability = 0;
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES,
      &capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(emptySequence), "unexpected size %d\n", size);
+        ok(size == sizeof(emptySequence), "unexpected size %ld\n", size);
         ok(!memcmp(buf, emptySequence, size), "unexpected value\n");
         LocalFree(buf);
     }
@@ -6544,14 +6544,14 @@ static void test_encodePKCSSMimeCapabilities(DWORD dwEncoding)
      &capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && (GetLastError() == E_INVALIDARG ||
      GetLastError() == OSS_LIMITED /* Win9x */),
-     "Expected E_INVALIDARG or OSS_LIMITED, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG or OSS_LIMITED, got %08lx\n", GetLastError());
     capability[0].pszObjId = oid1;
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES,
      &capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(singleCapability), "unexpected size %d\n", size);
+        ok(size == sizeof(singleCapability), "unexpected size %ld\n", size);
         ok(!memcmp(buf, singleCapability, size), "unexpected value\n");
         LocalFree(buf);
     }
@@ -6560,10 +6560,10 @@ static void test_encodePKCSSMimeCapabilities(DWORD dwEncoding)
     capabilities.cCapability = 2;
     ret = pCryptEncodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES,
      &capabilities, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(twoCapabilities), "unexpected size %d\n", size);
+        ok(size == sizeof(twoCapabilities), "unexpected size %ld\n", size);
         ok(!memcmp(buf, twoCapabilities, size), "unexpected value\n");
         LocalFree(buf);
     }
@@ -6575,24 +6575,24 @@ static void compareSMimeCapabilities(LPCSTR header,
     DWORD i;
 
     ok(got->cCapability == expected->cCapability,
-     "%s: expected %d capabilities, got %d\n", header, expected->cCapability,
+     "%s: expected %ld capabilities, got %ld\n", header, expected->cCapability,
      got->cCapability);
     for (i = 0; i < expected->cCapability; i++)
     {
         ok(!strcmp(expected->rgCapability[i].pszObjId,
-         got->rgCapability[i].pszObjId), "%s[%d]: expected %s, got %s\n",
+         got->rgCapability[i].pszObjId), "%s[%ld]: expected %s, got %s\n",
          header, i, expected->rgCapability[i].pszObjId,
          got->rgCapability[i].pszObjId);
         ok(expected->rgCapability[i].Parameters.cbData ==
          got->rgCapability[i].Parameters.cbData,
-         "%s[%d]: expected %d bytes, got %d\n", header, i,
+         "%s[%ld]: expected %ld bytes, got %ld\n", header, i,
          expected->rgCapability[i].Parameters.cbData,
          got->rgCapability[i].Parameters.cbData);
         if (expected->rgCapability[i].Parameters.cbData)
             ok(!memcmp(expected->rgCapability[i].Parameters.pbData,
              got->rgCapability[i].Parameters.pbData,
              expected->rgCapability[i].Parameters.cbData),
-             "%s[%d]: unexpected value\n", header, i);
+             "%s[%ld]: unexpected value\n", header, i);
     }
 }
 
@@ -6608,7 +6608,7 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES,
      emptySequence, sizeof(emptySequence),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &ptr, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         capabilities.cCapability = 0;
@@ -6619,7 +6619,7 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES,
      singleCapability, sizeof(singleCapability), CRYPT_DECODE_ALLOC_FLAG, NULL,
      &ptr, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         capability[0].pszObjId = oid1;
@@ -6633,7 +6633,7 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES,
      singleCapabilitywithNULL, sizeof(singleCapabilitywithNULL),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &ptr, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         BYTE NULLparam[] = {0x05, 0x00};
@@ -6650,7 +6650,7 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES,
     twoCapabilities, sizeof(twoCapabilities), CRYPT_DECODE_ALLOC_FLAG, NULL,
     &ptr, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         capability[0].Parameters.cbData = 0;
@@ -6663,14 +6663,14 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding)
     SetLastError(0xdeadbeef);
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES,
      twoCapabilities, sizeof(twoCapabilities), 0, NULL, NULL, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
     if (ptr)
     {
         SetLastError(0xdeadbeef);
         ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES,
          twoCapabilities, sizeof(twoCapabilities), 0, NULL, ptr, &size);
-        ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
         HeapFree(GetProcessHeap(), 0, ptr);
     }
 }
@@ -6734,7 +6734,7 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding)
     }
     ok(!ret && (GetLastError() == E_INVALIDARG ||
      GetLastError() == OSS_LIMITED /* Win9x */),
-     "Expected E_INVALIDARG or OSS_LIMITED, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG or OSS_LIMITED, got %08lx\n", GetLastError());
     /* To be encoded, a signer must have an issuer at least, and the encoding
      * must include PKCS_7_ASN_ENCODING.  (That isn't enough to be decoded,
      * see decoding tests.)
@@ -6746,14 +6746,14 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (!(dwEncoding & PKCS_7_ASN_ENCODING))
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     else
     {
         ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */),
-         "CryptEncodeObjectEx failed: %x\n", GetLastError());
+         "CryptEncodeObjectEx failed: %lx\n", GetLastError());
         if (ret)
         {
-            ok(size == sizeof(minimalPKCSSigner), "Unexpected size %d\n", size);
+            ok(size == sizeof(minimalPKCSSigner), "Unexpected size %ld\n", size);
             if (size == sizeof(minimalPKCSSigner))
                 ok(!memcmp(buf, minimalPKCSSigner, size), "Unexpected value\n");
             else
@@ -6768,14 +6768,14 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (!(dwEncoding & PKCS_7_ASN_ENCODING))
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     else
     {
         ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */),
-         "CryptEncodeObjectEx failed: %x\n", GetLastError());
+         "CryptEncodeObjectEx failed: %lx\n", GetLastError());
         if (ret)
         {
-            ok(size == sizeof(PKCSSignerWithSerial), "Unexpected size %d\n",
+            ok(size == sizeof(PKCSSignerWithSerial), "Unexpected size %ld\n",
              size);
             if (size == sizeof(PKCSSignerWithSerial))
                 ok(!memcmp(buf, PKCSSignerWithSerial, size),
@@ -6791,14 +6791,14 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (!(dwEncoding & PKCS_7_ASN_ENCODING))
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     else
     {
         ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */),
-         "CryptEncodeObjectEx failed: %x\n", GetLastError());
+         "CryptEncodeObjectEx failed: %lx\n", GetLastError());
         if (ret)
         {
-            ok(size == sizeof(PKCSSignerWithHashAlgo), "Unexpected size %d\n",
+            ok(size == sizeof(PKCSSignerWithHashAlgo), "Unexpected size %ld\n",
              size);
             if (size == sizeof(PKCSSignerWithHashAlgo))
                 ok(!memcmp(buf, PKCSSignerWithHashAlgo, size),
@@ -6814,14 +6814,14 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (!(dwEncoding & PKCS_7_ASN_ENCODING))
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     else
     {
-        ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
         if (ret)
         {
             ok(size == sizeof(PKCSSignerWithHashAndEncryptionAlgo),
-             "Unexpected size %d\n", size);
+             "Unexpected size %ld\n", size);
             if (size == sizeof(PKCSSignerWithHashAndEncryptionAlgo))
                 ok(!memcmp(buf, PKCSSignerWithHashAndEncryptionAlgo, size),
                  "Unexpected value\n");
@@ -6837,13 +6837,13 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (!(dwEncoding & PKCS_7_ASN_ENCODING))
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     else
     {
-        ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
         if (ret)
         {
-            ok(size == sizeof(PKCSSignerWithHash), "Unexpected size %d\n",
+            ok(size == sizeof(PKCSSignerWithHash), "Unexpected size %ld\n",
              size);
             if (size == sizeof(PKCSSignerWithHash))
                 ok(!memcmp(buf, PKCSSignerWithHash, size),
@@ -6860,13 +6860,13 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (!(dwEncoding & PKCS_7_ASN_ENCODING))
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     else
     {
-        ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
         if (ret)
         {
-            ok(size == sizeof(PKCSSignerWithAuthAttr), "Unexpected size %d\n",
+            ok(size == sizeof(PKCSSignerWithAuthAttr), "Unexpected size %ld\n",
              size);
             if (size == sizeof(PKCSSignerWithAuthAttr))
                 ok(!memcmp(buf, PKCSSignerWithAuthAttr, size),
@@ -6892,24 +6892,24 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding)
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT ||
      GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %x\n",
+     "Expected CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %lx\n",
      GetLastError());
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO,
      PKCSSignerWithSerial, sizeof(PKCSSignerWithSerial),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR),
-     "CryptDecodeObjectEx failed: %x\n", GetLastError());
+     "CryptDecodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
         info = (CMSG_SIGNER_INFO *)buf;
-        ok(info->dwVersion == 0, "Expected version 0, got %d\n",
+        ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
          info->dwVersion);
         ok(info->Issuer.cbData == sizeof(encodedCommonNameNoNull),
-         "Unexpected size %d\n", info->Issuer.cbData);
+         "Unexpected size %ld\n", info->Issuer.cbData);
         ok(!memcmp(info->Issuer.pbData, encodedCommonNameNoNull,
          info->Issuer.cbData), "Unexpected value\n");
         ok(info->SerialNumber.cbData == sizeof(serialNum),
-         "Unexpected size %d\n", info->SerialNumber.cbData);
+         "Unexpected size %ld\n", info->SerialNumber.cbData);
         ok(!memcmp(info->SerialNumber.pbData, serialNum, sizeof(serialNum)),
          "Unexpected value\n");
         LocalFree(buf);
@@ -6920,14 +6920,14 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding)
     if (ret)
     {
         info = (CMSG_SIGNER_INFO *)buf;
-        ok(info->dwVersion == 0, "Expected version 0, got %d\n",
+        ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
          info->dwVersion);
         ok(info->Issuer.cbData == sizeof(encodedCommonNameNoNull),
-         "Unexpected size %d\n", info->Issuer.cbData);
+         "Unexpected size %ld\n", info->Issuer.cbData);
         ok(!memcmp(info->Issuer.pbData, encodedCommonNameNoNull,
          info->Issuer.cbData), "Unexpected value\n");
         ok(info->SerialNumber.cbData == sizeof(serialNum),
-         "Unexpected size %d\n", info->SerialNumber.cbData);
+         "Unexpected size %ld\n", info->SerialNumber.cbData);
         ok(!memcmp(info->SerialNumber.pbData, serialNum, sizeof(serialNum)),
          "Unexpected value\n");
         ok(!strcmp(info->HashAlgorithm.pszObjId, "1.2.3"),
@@ -6941,14 +6941,14 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding)
     if (ret)
     {
         info = (CMSG_SIGNER_INFO *)buf;
-        ok(info->dwVersion == 0, "Expected version 0, got %d\n",
+        ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
          info->dwVersion);
         ok(info->Issuer.cbData == sizeof(encodedCommonNameNoNull),
-         "Unexpected size %d\n", info->Issuer.cbData);
+         "Unexpected size %ld\n", info->Issuer.cbData);
         ok(!memcmp(info->Issuer.pbData, encodedCommonNameNoNull,
          info->Issuer.cbData), "Unexpected value\n");
         ok(info->SerialNumber.cbData == sizeof(serialNum),
-         "Unexpected size %d\n", info->SerialNumber.cbData);
+         "Unexpected size %ld\n", info->SerialNumber.cbData);
         ok(!memcmp(info->SerialNumber.pbData, serialNum, sizeof(serialNum)),
          "Unexpected value\n");
         ok(!strcmp(info->HashAlgorithm.pszObjId, "1.2.3"),
@@ -6963,21 +6963,21 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding)
     if (ret)
     {
         info = (CMSG_SIGNER_INFO *)buf;
-        ok(info->dwVersion == 0, "Expected version 0, got %d\n",
+        ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
          info->dwVersion);
         ok(info->Issuer.cbData == sizeof(encodedCommonNameNoNull),
-         "Unexpected size %d\n", info->Issuer.cbData);
+         "Unexpected size %ld\n", info->Issuer.cbData);
         ok(!memcmp(info->Issuer.pbData, encodedCommonNameNoNull,
          info->Issuer.cbData), "Unexpected value\n");
         ok(info->SerialNumber.cbData == sizeof(serialNum),
-         "Unexpected size %d\n", info->SerialNumber.cbData);
+         "Unexpected size %ld\n", info->SerialNumber.cbData);
         ok(!memcmp(info->SerialNumber.pbData, serialNum, sizeof(serialNum)),
          "Unexpected value\n");
         ok(!strcmp(info->HashAlgorithm.pszObjId, "1.2.3"),
          "Expected 1.2.3, got %s\n", info->HashAlgorithm.pszObjId);
         ok(!strcmp(info->HashEncryptionAlgorithm.pszObjId, "1.5.6"),
          "Expected 1.5.6, got %s\n", info->HashEncryptionAlgorithm.pszObjId);
-        ok(info->EncryptedHash.cbData == sizeof(hash), "Unexpected size %d\n",
+        ok(info->EncryptedHash.cbData == sizeof(hash), "Unexpected size %ld\n",
          info->EncryptedHash.cbData);
         ok(!memcmp(info->EncryptedHash.pbData, hash, sizeof(hash)),
          "Unexpected value\n");
@@ -6989,15 +6989,15 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding)
     if (ret)
     {
         info = (CMSG_SIGNER_INFO *)buf;
-        ok(info->AuthAttrs.cAttr == 1, "Expected 1 attribute, got %d\n",
+        ok(info->AuthAttrs.cAttr == 1, "Expected 1 attribute, got %ld\n",
          info->AuthAttrs.cAttr);
         ok(!strcmp(info->AuthAttrs.rgAttr[0].pszObjId, szOID_COMMON_NAME),
          "Expected %s, got %s\n", szOID_COMMON_NAME,
          info->AuthAttrs.rgAttr[0].pszObjId);
-        ok(info->AuthAttrs.rgAttr[0].cValue == 1, "Expected 1 value, got %d\n",
+        ok(info->AuthAttrs.rgAttr[0].cValue == 1, "Expected 1 value, got %ld\n",
          info->AuthAttrs.rgAttr[0].cValue);
         ok(info->AuthAttrs.rgAttr[0].rgValue[0].cbData ==
-         sizeof(encodedCommonName), "Unexpected size %d\n",
+         sizeof(encodedCommonName), "Unexpected size %ld\n",
          info->AuthAttrs.rgAttr[0].rgValue[0].cbData);
         ok(!memcmp(info->AuthAttrs.rgAttr[0].rgValue[0].pbData,
          encodedCommonName, sizeof(encodedCommonName)), "Unexpected value\n");
@@ -7027,7 +7027,7 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding)
         return;
     }
     ok(GetLastError() == E_INVALIDARG,
-       "Expected E_INVALIDARG, got %08x\n", GetLastError());
+       "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     info.SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER;
     SetLastError(0xdeadbeef);
     ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info,
@@ -7039,7 +7039,7 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding)
         return;
     }
     ok(GetLastError() == E_INVALIDARG,
-       "Expected E_INVALIDARG, got %08x\n", GetLastError());
+       "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* To be encoded, a signer must have a valid cert ID, where a valid ID may
      * be a key id or an issuer serial number with at least the issuer set, and
      * the encoding must include PKCS_7_ASN_ENCODING.
@@ -7053,13 +7053,13 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (!(dwEncoding & PKCS_7_ASN_ENCODING))
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     else
     {
-        ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
         if (ret)
         {
-            ok(size == sizeof(minimalPKCSSigner), "Unexpected size %d\n", size);
+            ok(size == sizeof(minimalPKCSSigner), "Unexpected size %ld\n", size);
             ok(!memcmp(buf, minimalPKCSSigner, size), "Unexpected value\n");
             LocalFree(buf);
         }
@@ -7071,13 +7071,13 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (!(dwEncoding & PKCS_7_ASN_ENCODING))
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     else
     {
-        ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
         if (ret)
         {
-            ok(size == sizeof(PKCSSignerWithSerial), "Unexpected size %d\n",
+            ok(size == sizeof(PKCSSignerWithSerial), "Unexpected size %ld\n",
              size);
             ok(!memcmp(buf, PKCSSignerWithSerial, size), "Unexpected value\n");
             LocalFree(buf);
@@ -7091,13 +7091,13 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (!(dwEncoding & PKCS_7_ASN_ENCODING))
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     else
     {
-        ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
         if (ret)
         {
-            ok(size == sizeof(CMSSignerWithKeyId), "Unexpected size %d\n",
+            ok(size == sizeof(CMSSignerWithKeyId), "Unexpected size %ld\n",
              size);
             ok(!memcmp(buf, CMSSignerWithKeyId, size), "Unexpected value\n");
             LocalFree(buf);
@@ -7114,7 +7114,7 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, CMS_SIGNER_INFO, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* Now with a hash algo */
     info.SignerId.dwIdChoice = CERT_ID_ISSUER_SERIAL_NUMBER;
     U(info.SignerId).IssuerSerialNumber.Issuer.cbData =
@@ -7126,13 +7126,13 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (!(dwEncoding & PKCS_7_ASN_ENCODING))
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     else
     {
-        ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
         if (ret)
         {
-            ok(size == sizeof(PKCSSignerWithHashAlgo), "Unexpected size %d\n",
+            ok(size == sizeof(PKCSSignerWithHashAlgo), "Unexpected size %ld\n",
              size);
             ok(!memcmp(buf, PKCSSignerWithHashAlgo, size),
              "Unexpected value\n");
@@ -7145,14 +7145,14 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (!(dwEncoding & PKCS_7_ASN_ENCODING))
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     else
     {
-        ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
         if (ret)
         {
             ok(size == sizeof(PKCSSignerWithHashAndEncryptionAlgo),
-             "Unexpected size %d\n", size);
+             "Unexpected size %ld\n", size);
             ok(!memcmp(buf, PKCSSignerWithHashAndEncryptionAlgo, size),
              "Unexpected value\n");
             LocalFree(buf);
@@ -7165,13 +7165,13 @@ static void test_encodeCMSSignerInfo(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     if (!(dwEncoding & PKCS_7_ASN_ENCODING))
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     else
     {
-        ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %lx\n", GetLastError());
         if (ret)
         {
-            ok(size == sizeof(PKCSSignerWithHash), "Unexpected size %d\n",
+            ok(size == sizeof(PKCSSignerWithHash), "Unexpected size %ld\n",
              size);
             ok(!memcmp(buf, PKCSSignerWithHash, size), "Unexpected value\n");
             LocalFree(buf);
@@ -7199,28 +7199,28 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding)
         return;
     }
     ok(GetLastError() == CRYPT_E_ASN1_CORRUPT,
-     "Expected CRYPT_E_ASN1_CORRUPT, got %x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_CORRUPT, got %lx\n", GetLastError());
     ret = pCryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO,
      PKCSSignerWithSerial, sizeof(PKCSSignerWithSerial),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
         info = (CMSG_CMS_SIGNER_INFO *)buf;
-        ok(info->dwVersion == 0, "Expected version 0, got %d\n",
+        ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
          info->dwVersion);
         ok(info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER,
-         "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %d\n",
+         "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %ld\n",
          info->SignerId.dwIdChoice);
         ok(U(info->SignerId).IssuerSerialNumber.Issuer.cbData ==
-         sizeof(encodedCommonNameNoNull), "Unexpected size %d\n",
+         sizeof(encodedCommonNameNoNull), "Unexpected size %ld\n",
          U(info->SignerId).IssuerSerialNumber.Issuer.cbData);
         ok(!memcmp(U(info->SignerId).IssuerSerialNumber.Issuer.pbData,
          encodedCommonNameNoNull,
          U(info->SignerId).IssuerSerialNumber.Issuer.cbData),
          "Unexpected value\n");
         ok(U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData ==
-         sizeof(serialNum), "Unexpected size %d\n",
+         sizeof(serialNum), "Unexpected size %ld\n",
          U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData);
         ok(!memcmp(U(info->SignerId).IssuerSerialNumber.SerialNumber.pbData,
          serialNum, sizeof(serialNum)), "Unexpected value\n");
@@ -7229,24 +7229,24 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO,
      PKCSSignerWithHashAlgo, sizeof(PKCSSignerWithHashAlgo),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
         info = (CMSG_CMS_SIGNER_INFO *)buf;
-        ok(info->dwVersion == 0, "Expected version 0, got %d\n",
+        ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
          info->dwVersion);
         ok(info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER,
-         "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %d\n",
+         "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %ld\n",
          info->SignerId.dwIdChoice);
         ok(U(info->SignerId).IssuerSerialNumber.Issuer.cbData ==
-         sizeof(encodedCommonNameNoNull), "Unexpected size %d\n",
+         sizeof(encodedCommonNameNoNull), "Unexpected size %ld\n",
          U(info->SignerId).IssuerSerialNumber.Issuer.cbData);
         ok(!memcmp(U(info->SignerId).IssuerSerialNumber.Issuer.pbData,
          encodedCommonNameNoNull,
          U(info->SignerId).IssuerSerialNumber.Issuer.cbData),
          "Unexpected value\n");
         ok(U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData ==
-         sizeof(serialNum), "Unexpected size %d\n",
+         sizeof(serialNum), "Unexpected size %ld\n",
          U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData);
         ok(!memcmp(U(info->SignerId).IssuerSerialNumber.SerialNumber.pbData,
          serialNum, sizeof(serialNum)), "Unexpected value\n");
@@ -7258,24 +7258,24 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding)
      PKCSSignerWithHashAndEncryptionAlgo,
      sizeof(PKCSSignerWithHashAndEncryptionAlgo), CRYPT_DECODE_ALLOC_FLAG,
      NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
         info = (CMSG_CMS_SIGNER_INFO *)buf;
-        ok(info->dwVersion == 0, "Expected version 0, got %d\n",
+        ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
          info->dwVersion);
         ok(info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER,
-         "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %d\n",
+         "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %ld\n",
          info->SignerId.dwIdChoice);
         ok(U(info->SignerId).IssuerSerialNumber.Issuer.cbData ==
-         sizeof(encodedCommonNameNoNull), "Unexpected size %d\n",
+         sizeof(encodedCommonNameNoNull), "Unexpected size %ld\n",
          U(info->SignerId).IssuerSerialNumber.Issuer.cbData);
         ok(!memcmp(U(info->SignerId).IssuerSerialNumber.Issuer.pbData,
          encodedCommonNameNoNull,
          U(info->SignerId).IssuerSerialNumber.Issuer.cbData),
          "Unexpected value\n");
         ok(U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData ==
-         sizeof(serialNum), "Unexpected size %d\n",
+         sizeof(serialNum), "Unexpected size %ld\n",
          U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData);
         ok(!memcmp(U(info->SignerId).IssuerSerialNumber.SerialNumber.pbData,
          serialNum, sizeof(serialNum)), "Unexpected value\n");
@@ -7288,24 +7288,24 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO,
      PKCSSignerWithHash, sizeof(PKCSSignerWithHash),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
         info = (CMSG_CMS_SIGNER_INFO *)buf;
-        ok(info->dwVersion == 0, "Expected version 0, got %d\n",
+        ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
          info->dwVersion);
         ok(info->SignerId.dwIdChoice == CERT_ID_ISSUER_SERIAL_NUMBER,
-         "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %d\n",
+         "Expected CERT_ID_ISSUER_SERIAL_NUMBER, got %ld\n",
          info->SignerId.dwIdChoice);
         ok(U(info->SignerId).IssuerSerialNumber.Issuer.cbData ==
-         sizeof(encodedCommonNameNoNull), "Unexpected size %d\n",
+         sizeof(encodedCommonNameNoNull), "Unexpected size %ld\n",
          U(info->SignerId).IssuerSerialNumber.Issuer.cbData);
         ok(!memcmp(U(info->SignerId).IssuerSerialNumber.Issuer.pbData,
          encodedCommonNameNoNull,
          U(info->SignerId).IssuerSerialNumber.Issuer.cbData),
          "Unexpected value\n");
         ok(U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData ==
-         sizeof(serialNum), "Unexpected size %d\n",
+         sizeof(serialNum), "Unexpected size %ld\n",
          U(info->SignerId).IssuerSerialNumber.SerialNumber.cbData);
         ok(!memcmp(U(info->SignerId).IssuerSerialNumber.SerialNumber.pbData,
          serialNum, sizeof(serialNum)), "Unexpected value\n");
@@ -7313,7 +7313,7 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding)
          "Expected %s, got %s\n", oid1, info->HashAlgorithm.pszObjId);
         ok(!strcmp(info->HashEncryptionAlgorithm.pszObjId, oid2),
          "Expected %s, got %s\n", oid2, info->HashEncryptionAlgorithm.pszObjId);
-        ok(info->EncryptedHash.cbData == sizeof(hash), "Unexpected size %d\n",
+        ok(info->EncryptedHash.cbData == sizeof(hash), "Unexpected size %ld\n",
          info->EncryptedHash.cbData);
         ok(!memcmp(info->EncryptedHash.pbData, hash, sizeof(hash)),
          "Unexpected value\n");
@@ -7322,17 +7322,17 @@ static void test_decodeCMSSignerInfo(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, CMS_SIGNER_INFO,
      CMSSignerWithKeyId, sizeof(CMSSignerWithKeyId),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %lx\n", GetLastError());
     if (ret)
     {
         info = (CMSG_CMS_SIGNER_INFO *)buf;
-        ok(info->dwVersion == 0, "Expected version 0, got %d\n",
+        ok(info->dwVersion == 0, "Expected version 0, got %ld\n",
          info->dwVersion);
         ok(info->SignerId.dwIdChoice == CERT_ID_KEY_IDENTIFIER,
-         "Expected CERT_ID_KEY_IDENTIFIER, got %d\n",
+         "Expected CERT_ID_KEY_IDENTIFIER, got %ld\n",
          info->SignerId.dwIdChoice);
         ok(U(info->SignerId).KeyId.cbData == sizeof(serialNum),
-         "Unexpected size %d\n", U(info->SignerId).KeyId.cbData);
+         "Unexpected size %ld\n", U(info->SignerId).KeyId.cbData);
         ok(!memcmp(U(info->SignerId).KeyId.pbData, serialNum, sizeof(serialNum)),
          "Unexpected value\n");
         LocalFree(buf);
@@ -7375,7 +7375,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding)
         skip("no X509_NAME_CONSTRAINTS encode support\n");
         return;
     }
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(size == sizeof(emptySequence), "Unexpected size\n");
@@ -7388,11 +7388,11 @@ static void test_encodeNameConstraints(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     permitted.Base.dwAltNameChoice = CERT_ALT_NAME_DNS_NAME;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(size == sizeof(emptyDNSPermittedConstraints), "Unexpected size\n");
@@ -7406,7 +7406,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding)
     excluded.Base.dwAltNameChoice = CERT_ALT_NAME_DNS_NAME;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(size == sizeof(emptyDNSExcludedConstraints), "Unexpected size\n");
@@ -7417,7 +7417,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding)
     U(excluded.Base).pwszURL = (LPWSTR)url;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(size == sizeof(DNSExcludedConstraints), "Unexpected size\n");
@@ -7431,7 +7431,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding)
     constraints.cPermittedSubtree = 1;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(size == sizeof(permittedAndExcludedConstraints),
@@ -7443,7 +7443,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding)
     permitted.dwMinimum = 5;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(size == sizeof(permittedAndExcludedWithMinConstraints),
@@ -7457,7 +7457,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding)
     SetLastError(0xdeadbeef);
     ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(size == sizeof(permittedAndExcludedWithMinMaxConstraints),
@@ -7529,14 +7529,14 @@ static void test_decodeNameConstraints(DWORD dwEncoding)
             skip("no X509_NAME_CONSTRAINTS decode support\n");
             return;
         }
-        ok(ret, "%d: CryptDecodeObjectEx failed: %08x\n", i, GetLastError());
+        ok(ret, "%ld: CryptDecodeObjectEx failed: %08lx\n", i, GetLastError());
         if (ret)
         {
             DWORD j;
 
             if (constraints->cPermittedSubtree !=
              encodedNameConstraints[i].constraints.cPermittedSubtree)
-                fprintf(stderr, "%d: expected %u permitted, got %u\n", i,
+                fprintf(stderr, "%ld: expected %lu permitted, got %lu\n", i,
                  encodedNameConstraints[i].constraints.cPermittedSubtree,
                  constraints->cPermittedSubtree);
             if (constraints->cPermittedSubtree ==
@@ -7550,7 +7550,7 @@ static void test_decodeNameConstraints(DWORD dwEncoding)
             }
             if (constraints->cExcludedSubtree !=
              encodedNameConstraints[i].constraints.cExcludedSubtree)
-                fprintf(stderr, "%d: expected %u excluded, got %u\n", i,
+                fprintf(stderr, "%ld: expected %lu excluded, got %lu\n", i,
                  encodedNameConstraints[i].constraints.cExcludedSubtree,
                  constraints->cExcludedSubtree);
             if (constraints->cExcludedSubtree ==
@@ -7600,10 +7600,10 @@ static void test_encodePolicyQualifierUserNotice(DWORD dwEncoding)
         skip("no X509_PKIX_POLICY_QUALIFIER_USERNOTICE encode support\n");
         return;
     }
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(sizeof(emptySequence) == size, "unexpected size %d\n", size);
+        ok(sizeof(emptySequence) == size, "unexpected size %ld\n", size);
         ok(!memcmp(buf, emptySequence, size), "unexpected value\n");
         LocalFree(buf);
     }
@@ -7611,10 +7611,10 @@ static void test_encodePolicyQualifierUserNotice(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding,
      X509_PKIX_POLICY_QUALIFIER_USERNOTICE, &notice, CRYPT_ENCODE_ALLOC_FLAG,
      NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(sizeof(noticeWithDisplayText) == size, "unexpected size %d\n", size);
+        ok(sizeof(noticeWithDisplayText) == size, "unexpected size %ld\n", size);
         ok(!memcmp(buf, noticeWithDisplayText, size), "unexpected value\n");
         LocalFree(buf);
     }
@@ -7625,10 +7625,10 @@ static void test_encodePolicyQualifierUserNotice(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding,
      X509_PKIX_POLICY_QUALIFIER_USERNOTICE, &notice, CRYPT_ENCODE_ALLOC_FLAG,
      NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(sizeof(noticeWithReference) == size, "unexpected size %d\n", size);
+        ok(sizeof(noticeWithReference) == size, "unexpected size %ld\n", size);
         ok(!memcmp(buf, noticeWithReference, size), "unexpected value\n");
         LocalFree(buf);
     }
@@ -7649,7 +7649,7 @@ static void test_decodePolicyQualifierUserNotice(DWORD dwEncoding)
         skip("no X509_PKIX_POLICY_QUALIFIER_USERNOTICE decode support\n");
         return;
     }
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(notice->pszDisplayText == NULL, "unexpected display text\n");
@@ -7660,7 +7660,7 @@ static void test_decodePolicyQualifierUserNotice(DWORD dwEncoding)
      X509_PKIX_POLICY_QUALIFIER_USERNOTICE,
      noticeWithDisplayText, sizeof(noticeWithDisplayText),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &notice, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(!lstrcmpW(notice->pszDisplayText, noticeText),
@@ -7672,7 +7672,7 @@ static void test_decodePolicyQualifierUserNotice(DWORD dwEncoding)
      X509_PKIX_POLICY_QUALIFIER_USERNOTICE,
      noticeWithReference, sizeof(noticeWithReference),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &notice, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(!lstrcmpW(notice->pszDisplayText, noticeText),
@@ -7684,7 +7684,7 @@ static void test_decodePolicyQualifierUserNotice(DWORD dwEncoding)
              "unexpected organization %s\n",
              notice->pNoticeReference->pszOrganization);
             ok(notice->pNoticeReference->cNoticeNumbers == 2,
-             "expected 2 notice numbers, got %d\n",
+             "expected 2 notice numbers, got %ld\n",
              notice->pNoticeReference->cNoticeNumbers);
             ok(notice->pNoticeReference->rgNoticeNumbers[0] == noticeNumbers[0],
              "unexpected notice number %d\n",
@@ -7724,10 +7724,10 @@ static void test_encodeCertPolicies(DWORD dwEncoding)
     memset(&info, 0, sizeof(info));
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(sizeof(emptySequence) == size, "unexpected size %d\n", size);
+        ok(sizeof(emptySequence) == size, "unexpected size %ld\n", size);
         ok(!memcmp(buf, emptySequence, size), "unexpected value\n");
         LocalFree(buf);
     }
@@ -7738,14 +7738,14 @@ static void test_encodeCertPolicies(DWORD dwEncoding)
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(!ret && (GetLastError() == E_INVALIDARG ||
      GetLastError() == OSS_LIMITED /* Win9x/NT4 */),
-     "expected E_INVALIDARG or OSS_LIMITED, got %08x\n", GetLastError());
+     "expected E_INVALIDARG or OSS_LIMITED, got %08lx\n", GetLastError());
     policy[0].pszPolicyIdentifier = oid_any_policy;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(sizeof(policiesWithAnyPolicy) == size, "unexpected size %d\n", size);
+        ok(sizeof(policiesWithAnyPolicy) == size, "unexpected size %ld\n", size);
         ok(!memcmp(buf, policiesWithAnyPolicy, size), "unexpected value\n");
         LocalFree(buf);
     }
@@ -7759,10 +7759,10 @@ static void test_encodeCertPolicies(DWORD dwEncoding)
     info.cPolicyInfo = 2;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_POLICIES, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(sizeof(twoPolicies) == size, "unexpected size %d\n", size);
+        ok(sizeof(twoPolicies) == size, "unexpected size %ld\n", size);
         ok(!memcmp(buf, twoPolicies, size), "unexpected value\n");
         LocalFree(buf);
     }
@@ -7777,55 +7777,55 @@ static void test_decodeCertPolicies(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES,
      emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL,
      &info, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(info->cPolicyInfo == 0, "unexpected policy info %d\n",
+        ok(info->cPolicyInfo == 0, "unexpected policy info %ld\n",
          info->cPolicyInfo);
         LocalFree(info);
     }
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES,
      policiesWithAnyPolicy, sizeof(policiesWithAnyPolicy),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(info->cPolicyInfo == 1, "unexpected policy info %d\n",
+        ok(info->cPolicyInfo == 1, "unexpected policy info %ld\n",
          info->cPolicyInfo);
         ok(!strcmp(info->rgPolicyInfo[0].pszPolicyIdentifier, oid_any_policy),
          "unexpected policy id %s\n",
          info->rgPolicyInfo[0].pszPolicyIdentifier);
         ok(info->rgPolicyInfo[0].cPolicyQualifier == 0,
-         "unexpected policy qualifier count %d\n",
+         "unexpected policy qualifier count %ld\n",
          info->rgPolicyInfo[0].cPolicyQualifier);
         LocalFree(info);
     }
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES,
      twoPolicies, sizeof(twoPolicies),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(info->cPolicyInfo == 2, "unexpected policy info %d\n",
+        ok(info->cPolicyInfo == 2, "unexpected policy info %ld\n",
          info->cPolicyInfo);
         ok(!strcmp(info->rgPolicyInfo[0].pszPolicyIdentifier, oid_any_policy),
          "unexpected policy id %s\n",
          info->rgPolicyInfo[0].pszPolicyIdentifier);
         ok(info->rgPolicyInfo[0].cPolicyQualifier == 0,
-         "unexpected policy qualifier count %d\n",
+         "unexpected policy qualifier count %ld\n",
          info->rgPolicyInfo[0].cPolicyQualifier);
         ok(!strcmp(info->rgPolicyInfo[1].pszPolicyIdentifier, oid1),
          "unexpected policy id %s\n",
          info->rgPolicyInfo[1].pszPolicyIdentifier);
         ok(info->rgPolicyInfo[1].cPolicyQualifier == 1,
-         "unexpected policy qualifier count %d\n",
+         "unexpected policy qualifier count %ld\n",
          info->rgPolicyInfo[1].cPolicyQualifier);
         ok(!strcmp(
          info->rgPolicyInfo[1].rgPolicyQualifier[0].pszPolicyQualifierId,
          oid_user_notice), "unexpected policy qualifier id %s\n",
          info->rgPolicyInfo[1].rgPolicyQualifier[0].pszPolicyQualifierId);
         ok(info->rgPolicyInfo[1].rgPolicyQualifier[0].Qualifier.cbData ==
-         sizeof(noticeWithReference), "unexpected qualifier size %d\n",
+         sizeof(noticeWithReference), "unexpected qualifier size %ld\n",
          info->rgPolicyInfo[1].rgPolicyQualifier[0].Qualifier.cbData);
         ok(!memcmp(
          info->rgPolicyInfo[1].rgPolicyQualifier[0].Qualifier.pbData,
@@ -7835,13 +7835,13 @@ static void test_decodeCertPolicies(DWORD dwEncoding)
     }
     ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES,
      twoPolicies, sizeof(twoPolicies), 0, NULL, NULL, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
     if (info)
     {
         ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES,
          twoPolicies, sizeof(twoPolicies), 0, NULL, info, &size);
-        ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
         HeapFree(GetProcessHeap(), 0, info);
     }
 }
@@ -7872,7 +7872,7 @@ static void test_encodeCertPolicyMappings(DWORD dwEncoding)
         ret = pCryptEncodeObjectEx(dwEncoding, mappingOids[i], &info,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
         ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND),
-         "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+         "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
         if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND)
         {
             win_skip("no policy mappings support\n");
@@ -7880,7 +7880,7 @@ static void test_encodeCertPolicyMappings(DWORD dwEncoding)
         }
         if (ret)
         {
-            ok(size == sizeof(emptySequence), "unexpected size %d\n", size);
+            ok(size == sizeof(emptySequence), "unexpected size %ld\n", size);
             ok(!memcmp(buf, emptySequence, sizeof(emptySequence)),
              "unexpected value\n");
             LocalFree(buf);
@@ -7893,16 +7893,16 @@ static void test_encodeCertPolicyMappings(DWORD dwEncoding)
         ret = pCryptEncodeObjectEx(dwEncoding, mappingOids[i], &info,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "expected E_INVALIDARG, got %08x\n", GetLastError());
+         "expected E_INVALIDARG, got %08lx\n", GetLastError());
         mapping[0].pszIssuerDomainPolicy = oid1;
         mapping[0].pszSubjectDomainPolicy = oid2;
         ret = pCryptEncodeObjectEx(dwEncoding, mappingOids[i], &info,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-        ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             ok(size == sizeof(policyMappingWithOneMapping),
-             "unexpected size %d\n", size);
+             "unexpected size %ld\n", size);
             ok(!memcmp(buf, policyMappingWithOneMapping, size),
              "unexpected value\n");
             LocalFree(buf);
@@ -7912,11 +7912,11 @@ static void test_encodeCertPolicyMappings(DWORD dwEncoding)
         info.cPolicyMapping = 2;
         ret = pCryptEncodeObjectEx(dwEncoding, mappingOids[i], &info,
          CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-        ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             ok(size == sizeof(policyMappingWithTwoMappings),
-             "unexpected size %d\n", size);
+             "unexpected size %ld\n", size);
             ok(!memcmp(buf, policyMappingWithTwoMappings, size),
              "unexpected value\n");
             LocalFree(buf);
@@ -7937,7 +7937,7 @@ static void test_decodeCertPolicyMappings(DWORD dwEncoding)
          emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL,
          &info, &size);
         ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND),
-         "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+         "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
         if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND)
         {
             win_skip("no policy mappings support\n");
@@ -7946,17 +7946,17 @@ static void test_decodeCertPolicyMappings(DWORD dwEncoding)
         if (ret)
         {
             ok(info->cPolicyMapping == 0,
-             "expected 0 policy mappings, got %d\n", info->cPolicyMapping);
+             "expected 0 policy mappings, got %ld\n", info->cPolicyMapping);
             LocalFree(info);
         }
         ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i],
          policyMappingWithOneMapping, sizeof(policyMappingWithOneMapping),
          CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size);
-        ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             ok(info->cPolicyMapping == 1,
-             "expected 1 policy mappings, got %d\n", info->cPolicyMapping);
+             "expected 1 policy mappings, got %ld\n", info->cPolicyMapping);
             ok(!strcmp(info->rgPolicyMapping[0].pszIssuerDomainPolicy, "1.2.3"),
              "unexpected issuer policy %s\n",
              info->rgPolicyMapping[0].pszIssuerDomainPolicy);
@@ -7968,11 +7968,11 @@ static void test_decodeCertPolicyMappings(DWORD dwEncoding)
         ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i],
          policyMappingWithTwoMappings, sizeof(policyMappingWithTwoMappings),
          CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size);
-        ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
         if (ret)
         {
             ok(info->cPolicyMapping == 2,
-             "expected 2 policy mappings, got %d\n", info->cPolicyMapping);
+             "expected 2 policy mappings, got %ld\n", info->cPolicyMapping);
             ok(!strcmp(info->rgPolicyMapping[0].pszIssuerDomainPolicy, "1.2.3"),
              "unexpected issuer policy %s\n",
              info->rgPolicyMapping[0].pszIssuerDomainPolicy);
@@ -7990,14 +7990,14 @@ static void test_decodeCertPolicyMappings(DWORD dwEncoding)
         ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i],
          policyMappingWithTwoMappings, sizeof(policyMappingWithTwoMappings), 0,
          NULL, NULL, &size);
-        ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
         info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
         if (info)
         {
             ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i],
              policyMappingWithTwoMappings, sizeof(policyMappingWithTwoMappings), 0,
              NULL, info, &size);
-            ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+            ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
             HeapFree(GetProcessHeap(), 0, info);
         }
     }
@@ -8023,7 +8023,7 @@ static void test_encodeCertPolicyConstraints(DWORD dwEncoding)
     ret = pCryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
     ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND),
-     "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+     "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND)
     {
         win_skip("no policy constraints support\n");
@@ -8031,7 +8031,7 @@ static void test_encodeCertPolicyConstraints(DWORD dwEncoding)
     }
     if (ret)
     {
-        ok(size == sizeof(emptySequence), "unexpected size %d\n", size);
+        ok(size == sizeof(emptySequence), "unexpected size %ld\n", size);
         ok(!memcmp(buf, emptySequence, sizeof(emptySequence)),
          "unexpected value\n");
         LocalFree(buf);
@@ -8042,11 +8042,11 @@ static void test_encodeCertPolicyConstraints(DWORD dwEncoding)
     info.fRequireExplicitPolicy = TRUE;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(size == sizeof(policyConstraintsWithRequireExplicit),
-         "unexpected size %d\n", size);
+         "unexpected size %ld\n", size);
         ok(!memcmp(buf, policyConstraintsWithRequireExplicit,
          sizeof(policyConstraintsWithRequireExplicit)), "unexpected value\n");
         LocalFree(buf);
@@ -8058,11 +8058,11 @@ static void test_encodeCertPolicyConstraints(DWORD dwEncoding)
     info.dwInhibitPolicyMappingSkipCerts = 1;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(size == sizeof(policyConstraintsWithInhibitMapping),
-         "unexpected size %d\n", size);
+         "unexpected size %ld\n", size);
         ok(!memcmp(buf, policyConstraintsWithInhibitMapping,
          sizeof(policyConstraintsWithInhibitMapping)), "unexpected value\n");
         LocalFree(buf);
@@ -8072,10 +8072,10 @@ static void test_encodeCertPolicyConstraints(DWORD dwEncoding)
     info.dwRequireExplicitPolicySkipCerts = 1;
     ret = pCryptEncodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS, &info,
      CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
-    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
-        ok(size == sizeof(policyConstraintsWithBoth), "unexpected size %d\n",
+        ok(size == sizeof(policyConstraintsWithBoth), "unexpected size %ld\n",
          size);
         ok(!memcmp(buf, policyConstraintsWithBoth,
          sizeof(policyConstraintsWithBoth)), "unexpected value\n");
@@ -8096,7 +8096,7 @@ static void test_decodeCertPolicyConstraints(DWORD dwEncoding)
      emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL,
      &info, &size);
     ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND),
-     "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+     "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND)
     {
         win_skip("no policy mappings support\n");
@@ -8114,12 +8114,12 @@ static void test_decodeCertPolicyConstraints(DWORD dwEncoding)
      policyConstraintsWithRequireExplicit,
      sizeof(policyConstraintsWithRequireExplicit), CRYPT_DECODE_ALLOC_FLAG,
      NULL, &info, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(info->fRequireExplicitPolicy,
          "expected require explicit = TRUE\n");
-        ok(info->dwRequireExplicitPolicySkipCerts == 0, "expected 0, got %d\n",
+        ok(info->dwRequireExplicitPolicySkipCerts == 0, "expected 0, got %ld\n",
          info->dwRequireExplicitPolicySkipCerts);
         ok(!info->fInhibitPolicyMapping,
          "expected implicit mapping = FALSE\n");
@@ -8129,30 +8129,30 @@ static void test_decodeCertPolicyConstraints(DWORD dwEncoding)
      policyConstraintsWithInhibitMapping,
      sizeof(policyConstraintsWithInhibitMapping), CRYPT_DECODE_ALLOC_FLAG,
      NULL, &info, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(!info->fRequireExplicitPolicy,
          "expected require explicit = FALSE\n");
         ok(info->fInhibitPolicyMapping,
          "expected implicit mapping = TRUE\n");
-        ok(info->dwInhibitPolicyMappingSkipCerts == 1, "expected 1, got %d\n",
+        ok(info->dwInhibitPolicyMappingSkipCerts == 1, "expected 1, got %ld\n",
          info->dwInhibitPolicyMappingSkipCerts);
         LocalFree(info);
     }
     ret = pCryptDecodeObjectEx(dwEncoding, X509_POLICY_CONSTRAINTS,
      policyConstraintsWithBoth, sizeof(policyConstraintsWithBoth),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &info, &size);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(info->fRequireExplicitPolicy,
          "expected require explicit = TRUE\n");
-        ok(info->dwRequireExplicitPolicySkipCerts == 1, "expected 1, got %d\n",
+        ok(info->dwRequireExplicitPolicySkipCerts == 1, "expected 1, got %ld\n",
          info->dwRequireExplicitPolicySkipCerts);
         ok(info->fInhibitPolicyMapping,
          "expected implicit mapping = TRUE\n");
-        ok(info->dwInhibitPolicyMappingSkipCerts == 1, "expected 1, got %d\n",
+        ok(info->dwInhibitPolicyMappingSkipCerts == 1, "expected 1, got %ld\n",
          info->dwInhibitPolicyMappingSkipCerts);
         LocalFree(info);
     }
@@ -8376,7 +8376,7 @@ static void test_decodeRsaPrivateKey(DWORD dwEncoding)
      rsaPrivKeyDer, sizeof(rsaPrivKeyDer)-10,
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD),
-     "Expected CRYPT_E_ASN1_EOD, got %08x\n",
+     "Expected CRYPT_E_ASN1_EOD, got %08lx\n",
      GetLastError());
 
     buf = NULL;
@@ -8384,7 +8384,7 @@ static void test_decodeRsaPrivateKey(DWORD dwEncoding)
     ret = pCryptDecodeObjectEx(dwEncoding, PKCS_RSA_PRIVATE_KEY,
      rsaPrivKeyDer, sizeof(rsaPrivKeyDer),
      CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize);
-    ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError());
 
     if (ret)
     {
@@ -8401,7 +8401,7 @@ static void test_decodeRsaPrivateKey(DWORD dwEncoding)
 
         ok(bufSize >= sizeof(BLOBHEADER) + sizeof(RSAPUBKEY) +
             (bitlen * 9 / 16),
-         "Wrong size %d\n", bufSize);
+         "Wrong size %ld\n", bufSize);
 
         ok(hdr->bType == PRIVATEKEYBLOB,
          "Expected type PRIVATEKEYBLOB (%d), got %d\n", PRIVATEKEYBLOB,
@@ -8415,11 +8415,11 @@ static void test_decodeRsaPrivateKey(DWORD dwEncoding)
          "Expected CALG_RSA_KEYX, got %08x\n", hdr->aiKeyAlg);
 
         ok(rsaPubKey->magic == 0x32415352,
-         "Expected magic 0x32415352, got 0x%x\n", rsaPubKey->magic);
+         "Expected magic 0x32415352, got 0x%lx\n", rsaPubKey->magic);
         ok(rsaPubKey->bitlen == bitlen,
-         "Expected bitlen %d, got %d\n", bitlen, rsaPubKey->bitlen);
+         "Expected bitlen %d, got %ld\n", bitlen, rsaPubKey->bitlen);
         ok(rsaPubKey->pubexp == 65537,
-         "Expected pubexp 65537, got %d\n", rsaPubKey->pubexp);
+         "Expected pubexp 65537, got %ld\n", rsaPubKey->pubexp);
 
         ok(!memcmp(modulus, rsaPrivKeyModulus, bitlen/8),
          "unexpected modulus\n");
@@ -8452,37 +8452,37 @@ static void testExportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO *pInfo)
      */
     ret = CryptExportPublicKeyInfoEx(0, 0, 0, NULL, 0, NULL, NULL, &size);
     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-     "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
+     "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
     ret = CryptExportPublicKeyInfoEx(0, AT_SIGNATURE, 0, NULL, 0, NULL, NULL,
      &size);
     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-     "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
+     "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
     ret = CryptExportPublicKeyInfoEx(0, 0, X509_ASN_ENCODING, NULL, 0, NULL,
      NULL, &size);
     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-     "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
+     "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
     ret = CryptExportPublicKeyInfoEx(0, AT_SIGNATURE, X509_ASN_ENCODING, NULL,
      0, NULL, NULL, &size);
     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-     "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
+     "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
     /* Test with no key */
     ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE, X509_ASN_ENCODING, NULL,
      0, NULL, NULL, &size);
-    ok(!ret && GetLastError() == NTE_NO_KEY, "Expected NTE_NO_KEY, got %08x\n",
+    ok(!ret && GetLastError() == NTE_NO_KEY, "Expected NTE_NO_KEY, got %08lx\n",
      GetLastError());
     ret = CryptGenKey(csp, AT_SIGNATURE, 0, &key);
-    ok(ret, "CryptGenKey failed: %08x\n", GetLastError());
+    ok(ret, "CryptGenKey failed: %08lx\n", GetLastError());
     if (ret)
     {
         ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE, X509_ASN_ENCODING,
          NULL, 0, NULL, NULL, &size);
-        ok(ret, "CryptExportPublicKeyInfoEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptExportPublicKeyInfoEx failed: %08lx\n", GetLastError());
         *pInfo = HeapAlloc(GetProcessHeap(), 0, size);
         if (*pInfo)
         {
             ret = CryptExportPublicKeyInfoEx(csp, AT_SIGNATURE,
              X509_ASN_ENCODING, NULL, 0, NULL, *pInfo, &size);
-            ok(ret, "CryptExportPublicKeyInfoEx failed: %08x\n",
+            ok(ret, "CryptExportPublicKeyInfoEx failed: %08lx\n",
              GetLastError());
             if (ret)
             {
@@ -8542,26 +8542,26 @@ static void testImportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO info)
      */
     ret = CryptImportPublicKeyInfoEx(0, 0, info, 0, 0, NULL, &key);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     ret = CryptImportPublicKeyInfoEx(csp, 0, info, 0, 0, NULL, &key);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     ret = CryptImportPublicKeyInfoEx(0, X509_ASN_ENCODING, info, 0, 0, NULL,
      &key);
     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-     "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
+     "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
 
     /* Export key with standard algorithm (CALG_RSA_KEYX) */
     ret = CryptImportPublicKeyInfoEx(csp, X509_ASN_ENCODING, info, 0, 0, NULL,
      &key);
-    ok(ret, "CryptImportPublicKeyInfoEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptImportPublicKeyInfoEx failed: %08lx\n", GetLastError());
 
     dwSize = sizeof(ai);
     ret = CryptGetKeyParam(key, KP_ALGID, (LPVOID)&ai, &dwSize, 0);
-    ok(ret, "CryptGetKeyParam failed: %08x\n", GetLastError());
+    ok(ret, "CryptGetKeyParam failed: %08lx\n", GetLastError());
     if(ret)
     {
-      ok(dwSize == sizeof(ai), "CryptGetKeyParam returned size %d\n",dwSize);
+      ok(dwSize == sizeof(ai), "CryptGetKeyParam returned size %ld\n",dwSize);
       ok(ai == CALG_RSA_KEYX, "Default ALG_ID is %04x (expected CALG_RSA_KEYX)\n", ai);
     }
 
@@ -8570,14 +8570,14 @@ static void testImportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO info)
     /* Repeat with forced algorithm */
     ret = CryptImportPublicKeyInfoEx(csp, X509_ASN_ENCODING, info, CALG_RSA_SIGN, 0, NULL,
      &key);
-    ok(ret, "CryptImportPublicKeyInfoEx failed: %08x\n", GetLastError());
+    ok(ret, "CryptImportPublicKeyInfoEx failed: %08lx\n", GetLastError());
 
     dwSize = sizeof(ai);
     ret = CryptGetKeyParam(key, KP_ALGID, (LPVOID)&ai, &dwSize, 0);
-    ok(ret, "CryptGetKeyParam failed: %08x\n", GetLastError());
+    ok(ret, "CryptGetKeyParam failed: %08lx\n", GetLastError());
     if(ret)
     {
-      ok(dwSize == sizeof(ai), "CryptGetKeyParam returned size %d\n",dwSize);
+      ok(dwSize == sizeof(ai), "CryptGetKeyParam returned size %ld\n",dwSize);
       ok(ai == CALG_RSA_SIGN, "ALG_ID is %04x (expected CALG_RSA_SIGN)\n", ai);
     }
 
@@ -8586,7 +8586,7 @@ static void testImportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO info)
     /* Test importing a public key from a certificate context */
     context = CertCreateCertificateContext(X509_ASN_ENCODING, expiredCert,
      sizeof(expiredCert));
-    ok(context != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
     if (context)
     {
@@ -8596,12 +8596,12 @@ static void testImportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO info)
          context->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId);
         ret = CryptImportPublicKeyInfoEx(csp, X509_ASN_ENCODING,
          &context->pCertInfo->SubjectPublicKeyInfo, 0, 0, NULL, &key);
-        ok(ret, "CryptImportPublicKeyInfoEx failed: %08x\n", GetLastError());
+        ok(ret, "CryptImportPublicKeyInfoEx failed: %08lx\n", GetLastError());
         CryptDestroyKey(key);
 
         ret = CryptImportPublicKeyInfoEx2(X509_ASN_ENCODING,
          &context->pCertInfo->SubjectPublicKeyInfo, 0, NULL, &key2);
-        ok(ret, "CryptImportPublicKeyInfoEx2 failed: %08x\n", GetLastError());
+        ok(ret, "CryptImportPublicKeyInfoEx2 failed: %08lx\n", GetLastError());
         BCryptDestroyKey(key2);
 
         CertFreeCertificateContext(context);
diff --git a/dlls/crypt32/tests/main.c b/dlls/crypt32/tests/main.c
index b594256fb39..640a50399e5 100644
--- a/dlls/crypt32/tests/main.c
+++ b/dlls/crypt32/tests/main.c
@@ -42,7 +42,7 @@ static void test_findAttribute(void)
     SetLastError(0xdeadbeef);
     ret = CertFindAttribute(NULL, 0, NULL);
     ok(ret == NULL, "Expected failure\n");
-    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
+    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
      GetLastError());
     if (0)
     {
@@ -54,25 +54,25 @@ static void test_findAttribute(void)
         SetLastError(0xdeadbeef);
         ret = CertFindAttribute(NULL, 1, &attr);
         ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-         "Expected ERROR_INVALID_PARAMETER, got %d (%08x)\n", GetLastError(),
+         "Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(),
          GetLastError());
     }
     /* returns NULL, last error not set */
     SetLastError(0xdeadbeef);
     ret = CertFindAttribute("bogus", 1, &attr);
     ok(ret == NULL, "Expected failure\n");
-    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
+    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
      GetLastError());
     /* returns NULL, last error not set */
     SetLastError(0xdeadbeef);
     ret = CertFindAttribute("1.2.4", 1, &attr);
     ok(ret == NULL, "Expected failure\n");
-    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
+    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
      GetLastError());
     /* succeeds, last error not set */
     SetLastError(0xdeadbeef);
     ret = CertFindAttribute("1.2.3", 1, &attr);
-    ok(ret != NULL, "CertFindAttribute failed: %08x\n", GetLastError());
+    ok(ret != NULL, "CertFindAttribute failed: %08lx\n", GetLastError());
 }
 
 static void test_findExtension(void)
@@ -86,7 +86,7 @@ static void test_findExtension(void)
     SetLastError(0xdeadbeef);
     ret = CertFindExtension(NULL, 0, NULL);
     ok(ret == NULL, "Expected failure\n");
-    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
+    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
      GetLastError());
     if (0)
     {
@@ -99,25 +99,25 @@ static void test_findExtension(void)
         SetLastError(0xdeadbeef);
         ret = CertFindExtension(NULL, 1, &ext);
         ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-         "Expected ERROR_INVALID_PARAMETER, got %d (%08x)\n", GetLastError(),
+         "Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(),
          GetLastError());
     }
     /* returns NULL, last error not set */
     SetLastError(0xdeadbeef);
     ret = CertFindExtension("bogus", 1, &ext);
     ok(ret == NULL, "Expected failure\n");
-    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
+    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
      GetLastError());
     /* returns NULL, last error not set */
     SetLastError(0xdeadbeef);
     ret = CertFindExtension("1.2.4", 1, &ext);
     ok(ret == NULL, "Expected failure\n");
-    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
+    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
      GetLastError());
     /* succeeds, last error not set */
     SetLastError(0xdeadbeef);
     ret = CertFindExtension("1.2.3", 1, &ext);
-    ok(ret != NULL, "CertFindExtension failed: %08x\n", GetLastError());
+    ok(ret != NULL, "CertFindExtension failed: %08lx\n", GetLastError());
 }
 
 static void test_findRDNAttr(void)
@@ -142,25 +142,25 @@ static void test_findRDNAttr(void)
         SetLastError(0xdeadbeef);
         ret = CertFindRDNAttr(NULL, &nameInfo);
         ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-         "Expected ERROR_INVALID_PARAMETER, got %d (%08x)\n", GetLastError(),
+         "Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(),
          GetLastError());
     }
     /* returns NULL, last error not set */
     SetLastError(0xdeadbeef);
     ret = CertFindRDNAttr("bogus", &nameInfo);
     ok(ret == NULL, "Expected failure\n");
-    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
+    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
      GetLastError());
     /* returns NULL, last error not set */
     SetLastError(0xdeadbeef);
     ret = CertFindRDNAttr("1.2.4", &nameInfo);
     ok(ret == NULL, "Expected failure\n");
-    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08x\n",
+    ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
      GetLastError());
     /* succeeds, last error not set */
     SetLastError(0xdeadbeef);
     ret = CertFindRDNAttr("1.2.3", &nameInfo);
-    ok(ret != NULL, "CertFindRDNAttr failed: %08x\n", GetLastError());
+    ok(ret != NULL, "CertFindRDNAttr failed: %08lx\n", GetLastError());
 }
 
 static void test_verifyTimeValidity(void)
@@ -178,16 +178,16 @@ static void test_verifyTimeValidity(void)
      */
     /* Check with 0 NotBefore and NotAfter */
     ret = CertVerifyTimeValidity(&fileTime, &info);
-    ok(ret == 1, "Expected 1, got %d\n", ret);
+    ok(ret == 1, "Expected 1, got %ld\n", ret);
     info.NotAfter = fileTime;
     /* Check with NotAfter equal to comparison time */
     ret = CertVerifyTimeValidity(&fileTime, &info);
-    ok(ret == 0, "Expected 0, got %d\n", ret);
+    ok(ret == 0, "Expected 0, got %ld\n", ret);
     /* Check with NotBefore after comparison time */
     info.NotBefore = fileTime;
     info.NotBefore.dwLowDateTime += 5000;
     ret = CertVerifyTimeValidity(&fileTime, &info);
-    ok(ret == -1, "Expected -1, got %d\n", ret);
+    ok(ret == -1, "Expected -1, got %ld\n", ret);
 }
 
 static void test_cryptAllocate(void)
@@ -195,12 +195,12 @@ static void test_cryptAllocate(void)
     LPVOID buf;
 
     buf = CryptMemAlloc(0);
-    ok(buf != NULL, "CryptMemAlloc failed: %08x\n", GetLastError());
+    ok(buf != NULL, "CryptMemAlloc failed: %08lx\n", GetLastError());
     CryptMemFree(buf);
     /* CryptMemRealloc(NULL, 0) fails pre-Vista */
     buf = CryptMemAlloc(0);
     buf = CryptMemRealloc(buf, 1);
-    ok(buf != NULL, "CryptMemRealloc failed: %08x\n", GetLastError());
+    ok(buf != NULL, "CryptMemRealloc failed: %08lx\n", GetLastError());
     CryptMemFree(buf);
 }
 
@@ -223,7 +223,7 @@ static void test_cryptTls(void)
 
     /* One normal pass */
     index = pI_CryptAllocTls();
-    ok(index, "I_CryptAllocTls failed: %08x\n", GetLastError());
+    ok(index, "I_CryptAllocTls failed: %08lx\n", GetLastError());
     if (index)
     {
         LPVOID ptr;
@@ -231,22 +231,22 @@ static void test_cryptTls(void)
         ptr = pI_CryptGetTls(index);
         ok(!ptr, "Expected NULL\n");
         ret = pI_CryptSetTls(index, (LPVOID)0xdeadbeef);
-        ok(ret, "I_CryptSetTls failed: %08x\n", GetLastError());
+        ok(ret, "I_CryptSetTls failed: %08lx\n", GetLastError());
         ptr = pI_CryptGetTls(index);
         ok(ptr == (LPVOID)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", ptr);
         /* This crashes
         ret = pI_CryptFreeTls(index, 1);
          */
         ret = pI_CryptFreeTls(index, 0);
-        ok(ret, "I_CryptFreeTls failed: %08x\n", GetLastError());
+        ok(ret, "I_CryptFreeTls failed: %08lx\n", GetLastError());
         ret = pI_CryptFreeTls(index, 0);
         ok(!ret, "I_CryptFreeTls succeeded\n");
         ok(GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     }
     /* Similar pass, check I_CryptDetachTls */
     index = pI_CryptAllocTls();
-    ok(index, "I_CryptAllocTls failed: %08x\n", GetLastError());
+    ok(index, "I_CryptAllocTls failed: %08lx\n", GetLastError());
     if (index)
     {
         LPVOID ptr;
@@ -254,7 +254,7 @@ static void test_cryptTls(void)
         ptr = pI_CryptGetTls(index);
         ok(!ptr, "Expected NULL\n");
         ret = pI_CryptSetTls(index, (LPVOID)0xdeadbeef);
-        ok(ret, "I_CryptSetTls failed: %08x\n", GetLastError());
+        ok(ret, "I_CryptSetTls failed: %08lx\n", GetLastError());
         ptr = pI_CryptGetTls(index);
         ok(ptr == (LPVOID)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", ptr);
         ptr = pI_CryptDetachTls(index);
@@ -299,7 +299,7 @@ static void test_readTrustedPublisherDWORD(void)
         ret = pReadDWORD(authenticodeFlags, &returnedFlags);
         ok(ret == exists, "Unexpected return value\n");
         ok(readFlags == returnedFlags,
-         "Expected flags %08x, got %08x\n", readFlags, returnedFlags);
+         "Expected flags %08lx, got %08lx\n", readFlags, returnedFlags);
     }
 }
 
@@ -337,28 +337,28 @@ static void test_getDefaultCryptProv(void)
 
     prov = pI_CryptGetDefaultCryptProv(0xdeadbeef);
     ok(prov == 0 && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     prov = pI_CryptGetDefaultCryptProv(PROV_RSA_FULL);
     ok(prov == 0 && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     prov = pI_CryptGetDefaultCryptProv(1);
     ok(prov == 0 && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     prov = pI_CryptGetDefaultCryptProv(0);
-    ok(prov != 0, "I_CryptGetDefaultCryptProv failed: %08x\n", GetLastError());
+    ok(prov != 0, "I_CryptGetDefaultCryptProv failed: %08lx\n", GetLastError());
     CryptReleaseContext(prov, 0);
 
     for (i = 0; i < ARRAY_SIZE(test_prov); i++)
     {
         if (winetest_debug > 1)
-            trace("%u: algid %#x (%s): class %u, type %u, sid %u\n", i, test_prov[i].algid, test_prov[i].name,
+            trace("%lu: algid %#x (%s): class %u, type %u, sid %u\n", i, test_prov[i].algid, test_prov[i].name,
                   GET_ALG_CLASS(test_prov[i].algid) >> 13, GET_ALG_TYPE(test_prov[i].algid) >> 9, GET_ALG_SID(test_prov[i].algid));
 
         prov = pI_CryptGetDefaultCryptProv(test_prov[i].algid);
         if (!prov)
         {
             todo_wine_if(test_prov[i].algid == CALG_DSS_SIGN || test_prov[i].algid == CALG_NO_SIGN)
-            ok(test_prov[i].optional, "%u: I_CryptGetDefaultCryptProv(%#x) failed\n", i, test_prov[i].algid);
+            ok(test_prov[i].optional, "%lu: I_CryptGetDefaultCryptProv(%#x) failed\n", i, test_prov[i].algid);
             continue;
         }
 
@@ -367,9 +367,9 @@ static void test_getDefaultCryptProv(void)
         {
             name = CryptMemAlloc(size);
             ret = CryptGetProvParam(prov, PP_NAME, (BYTE *)name, &size, 0);
-            ok(ret, "%u: CryptGetProvParam failed %#x\n", i, GetLastError());
+            ok(ret, "%lu: CryptGetProvParam failed %#lx\n", i, GetLastError());
             if (winetest_debug > 1)
-                trace("%u: algid %#x, name %s\n", i, test_prov[i].algid, name);
+                trace("%lu: algid %#x, name %s\n", i, test_prov[i].algid, name);
             CryptMemFree(name);
         }
 
@@ -417,7 +417,7 @@ static void test_format_object(void)
     SetLastError(0xdeadbeef);
     ret = CryptFormatObject(0, 0, 0, NULL, NULL, NULL, 0, NULL, &size);
     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());
 
     /* When called with the default encoding type for any undefined struct type
      * (including none), it succeeds:  the default encoding is a hex string
@@ -425,38 +425,38 @@ static void test_format_object(void)
      */
     SetLastError(0xdeadbeef);
     ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0, NULL, &size);
-    ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
-    ok(size == sizeof(WCHAR) || broken(!size) /* Win10 1709+ */, "wrong size %d\n", size);
+    ok(ret, "CryptFormatObject failed: %ld\n", GetLastError());
+    ok(size == sizeof(WCHAR) || broken(!size) /* Win10 1709+ */, "wrong size %ld\n", size);
 
     SetLastError(0xdeadbeef);
     size = 0;
     ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0, str, &size);
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == ERROR_MORE_DATA, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == ERROR_MORE_DATA, "wrong error %lu\n", GetLastError());
 
     size = sizeof(WCHAR);
     ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0, str, &size);
-    ok(ret, "CryptFormatObject failed, error %u\n", GetLastError());
+    ok(ret, "CryptFormatObject failed, error %lu\n", GetLastError());
     ok(!str[0], "expected empty string\n");
 
     ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, encodedInt,
             sizeof(encodedInt), NULL, &size);
-    ok(ret, "CryptFormatObject failed, error %u\n", GetLastError());
-    ok(size >= sizeof(L"02 01 01"), "wrong size %u\n", size);
+    ok(ret, "CryptFormatObject failed, error %lu\n", GetLastError());
+    ok(size >= sizeof(L"02 01 01"), "wrong size %lu\n", size);
 
     ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, encodedInt,
             sizeof(encodedInt), str, &size);
-    ok(ret, "CryptFormatObject failed, error %u\n", GetLastError());
+    ok(ret, "CryptFormatObject failed, error %lu\n", GetLastError());
     ok(!wcscmp(str, L"02 01 01"), "wrong string %s\n", wine_dbgstr_w(str));
 
     ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, encodedBigInt,
             sizeof(encodedBigInt), NULL, &size);
-    ok(ret, "CryptFormatObject failed, error %u\n", GetLastError());
-    ok(size >= sizeof(encodedBigIntStr), "wrong size %u\n", size);
+    ok(ret, "CryptFormatObject failed, error %lu\n", GetLastError());
+    ok(size >= sizeof(encodedBigIntStr), "wrong size %lu\n", size);
 
     ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL,
      encodedBigInt, sizeof(encodedBigInt), str, &size);
-    ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
+    ok(ret, "CryptFormatObject failed: %ld\n", GetLastError());
     ok(!wcsicmp(str, encodedBigIntStr), "wrong string %s\n", wine_dbgstr_w(str));
 
     /* When called with the default encoding type for any undefined struct
@@ -469,7 +469,7 @@ static void test_format_object(void)
     ok(!ret, "CryptFormatObject succeeded\n");
     ok(GetLastError() == ERROR_FILE_NOT_FOUND
             || GetLastError() == 0xdeadbeef, /* Vista, W2K8 */
-            "wrong error %u\n", GetLastError());
+            "wrong error %lu\n", GetLastError());
 
     /* When called to format an AUTHORITY_KEY_ID2_INFO, it fails when no
      * data are given.
@@ -478,7 +478,7 @@ static void test_format_object(void)
     ret = CryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL,
             szOID_AUTHORITY_KEY_IDENTIFIER2, NULL, 0, NULL, &size);
     ok(!ret, "expected failure\n");
-    ok(GetLastError() == E_INVALIDARG, "wrong error %u\n", GetLastError());
+    ok(GetLastError() == E_INVALIDARG, "wrong error %lu\n", GetLastError());
 }
 
 START_TEST(main)
diff --git a/dlls/crypt32/tests/message.c b/dlls/crypt32/tests/message.c
index c031718d1cc..6958c15ee36 100644
--- a/dlls/crypt32/tests/message.c
+++ b/dlls/crypt32/tests/message.c
@@ -53,40 +53,40 @@ static void test_msg_get_signer_count(void)
 
     SetLastError(0xdeadbeef);
     count = CryptGetMessageSignerCount(0, NULL, 0);
-    ok(count == -1, "Expected -1, got %d\n", count);
-    ok(GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n",
+    ok(count == -1, "Expected -1, got %ld\n", count);
+    ok(GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n",
      GetLastError());
     SetLastError(0xdeadbeef);
     count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING, NULL, 0);
-    ok(count == -1, "Expected -1, got %d\n", count);
+    ok(count == -1, "Expected -1, got %ld\n", count);
     ok(GetLastError() == CRYPT_E_ASN1_EOD ||
        GetLastError() == OSS_BAD_ARG, /* win9x */
-     "Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING,
      dataEmptyBareContent, sizeof(dataEmptyBareContent));
-    ok(count == -1, "Expected -1, got %d\n", count);
+    ok(count == -1, "Expected -1, got %ld\n", count);
     ok(GetLastError() == CRYPT_E_ASN1_BADTAG ||
        GetLastError() == OSS_PDU_MISMATCH, /* win9x */
-     "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING,
      dataEmptyContent, sizeof(dataEmptyContent));
-    ok(count == -1, "Expected -1, got %d\n", count);
+    ok(count == -1, "Expected -1, got %ld\n", count);
     ok(GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING,
      signedEmptyBareContent, sizeof(signedEmptyBareContent));
-    ok(count == -1, "Expected -1, got %d\n", count);
+    ok(count == -1, "Expected -1, got %ld\n", count);
     ok(GetLastError() == CRYPT_E_ASN1_BADTAG ||
        GetLastError() == OSS_DATA_ERROR, /* win9x */
-     "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
     count = CryptGetMessageSignerCount(PKCS_7_ASN_ENCODING,
      signedEmptyContent, sizeof(signedEmptyContent));
     ok(count == 1 ||
        broken(count == -1), /* win9x */
-       "Expected 1, got %d\n", count);
+       "Expected 1, got %ld\n", count);
 }
 
 static BYTE detachedHashContent[] = {
@@ -115,13 +115,13 @@ static void test_verify_detached_message_hash(void)
     ret = CryptVerifyDetachedMessageHash(&para, NULL, 0, 0, NULL, NULL, NULL,
      NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
     para.cbSize = sizeof(para);
     SetLastError(0xdeadbeef);
     ret = CryptVerifyDetachedMessageHash(&para, NULL, 0, 0, NULL, NULL, NULL,
      NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
     para.dwMsgEncodingType = PKCS_7_ASN_ENCODING;
     SetLastError(0xdeadbeef);
     ret = CryptVerifyDetachedMessageHash(&para, NULL, 0, 0, NULL, NULL, NULL,
@@ -129,13 +129,13 @@ static void test_verify_detached_message_hash(void)
     ok(!ret &&
      (GetLastError() == CRYPT_E_ASN1_EOD ||
       GetLastError() == OSS_BAD_ARG), /* win9x */
-     "expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
+     "expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
     para.dwMsgEncodingType = X509_ASN_ENCODING;
     SetLastError(0xdeadbeef);
     ret = CryptVerifyDetachedMessageHash(&para, NULL, 0, 0, NULL, NULL, NULL,
      NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
     para.dwMsgEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
     SetLastError(0xdeadbeef);
     ret = CryptVerifyDetachedMessageHash(&para, NULL, 0, 0, NULL, NULL, NULL,
@@ -143,18 +143,18 @@ static void test_verify_detached_message_hash(void)
     ok(!ret &&
      (GetLastError() == CRYPT_E_ASN1_EOD ||
       GetLastError() == OSS_BAD_ARG), /* win9x */
-     "expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
+     "expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
     /* Curiously, passing no data to hash succeeds.. */
     ret = CryptVerifyDetachedMessageHash(&para, detachedHashContent,
      sizeof(detachedHashContent), 0, NULL, NULL, NULL, NULL);
     todo_wine
-    ok(ret, "CryptVerifyDetachedMessageHash failed: %08x\n", GetLastError());
+    ok(ret, "CryptVerifyDetachedMessageHash failed: %08lx\n", GetLastError());
     /* as does passing the actual content of the message to hash.. */
     size = sizeof(msgData);
     pMsgData = msgData;
     ret = CryptVerifyDetachedMessageHash(&para, detachedHashContent,
      sizeof(detachedHashContent), 1, &pMsgData, &size, NULL, NULL);
-    ok(ret, "CryptVerifyDetachedMessageHash failed: %08x\n", GetLastError());
+    ok(ret, "CryptVerifyDetachedMessageHash failed: %08lx\n", GetLastError());
     /* while passing data to hash that isn't the content of the message fails.
      */
     size = sizeof(detachedHashContent);
@@ -163,7 +163,7 @@ static void test_verify_detached_message_hash(void)
     ret = CryptVerifyDetachedMessageHash(&para, detachedHashContent,
      sizeof(detachedHashContent), 1, &pMsgData, &size, NULL, NULL);
     ok(!ret && GetLastError() == CRYPT_E_HASH_VALUE,
-     "expected CRYPT_E_HASH_VALUE, got %08x\n", GetLastError());
+     "expected CRYPT_E_HASH_VALUE, got %08lx\n", GetLastError());
     /* Getting the size of the hash while passing no hash data causes the
      * hash to be checked (and fail.)
      */
@@ -171,23 +171,23 @@ static void test_verify_detached_message_hash(void)
     ret = CryptVerifyDetachedMessageHash(&para, detachedHashContent,
      sizeof(detachedHashContent), 0, NULL, NULL, NULL, &hashSize);
     ok(!ret && GetLastError() == CRYPT_E_HASH_VALUE,
-     "expected CRYPT_E_HASH_VALUE, got %08x\n", GetLastError());
+     "expected CRYPT_E_HASH_VALUE, got %08lx\n", GetLastError());
     size = sizeof(msgData);
     pMsgData = msgData;
     ret = CryptVerifyDetachedMessageHash(&para, detachedHashContent,
      sizeof(detachedHashContent), 1, &pMsgData, &size, NULL, &hashSize);
-    ok(ret, "CryptVerifyDetachedMessageHash failed: %08x\n", GetLastError());
-    ok(hashSize == sizeof(hash), "unexpected size %d\n", hashSize);
+    ok(ret, "CryptVerifyDetachedMessageHash failed: %08lx\n", GetLastError());
+    ok(hashSize == sizeof(hash), "unexpected size %ld\n", hashSize);
     hashSize = 1;
     SetLastError(0xdeadbeef);
     ret = CryptVerifyDetachedMessageHash(&para, detachedHashContent,
      sizeof(detachedHashContent), 1, &pMsgData, &size, hash, &hashSize);
     ok(!ret && GetLastError() == ERROR_MORE_DATA,
-     "expected ERROR_MORE_DATA, got %08x\n", GetLastError());
+     "expected ERROR_MORE_DATA, got %08lx\n", GetLastError());
     hashSize = sizeof(hash);
     ret = CryptVerifyDetachedMessageHash(&para, detachedHashContent,
      sizeof(detachedHashContent), 1, &pMsgData, &size, hash, &hashSize);
-    ok(ret, "CryptVerifyDetachedMessageHash failed: %08x\n", GetLastError());
+    ok(ret, "CryptVerifyDetachedMessageHash failed: %08lx\n", GetLastError());
 }
 
 static BYTE hashContent[] = {
@@ -211,31 +211,31 @@ static void test_verify_message_hash(void)
     SetLastError(0xdeadbeef);
     ret = CryptVerifyMessageHash(&para, NULL, 0, NULL, NULL, NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
     para.cbSize = sizeof(para);
     SetLastError(0xdeadbeef);
     ret = CryptVerifyMessageHash(&para, NULL, 0, NULL, NULL, NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
     para.dwMsgEncodingType = PKCS_7_ASN_ENCODING;
     SetLastError(0xdeadbeef);
     ret = CryptVerifyMessageHash(&para, NULL, 0, NULL, NULL, NULL, NULL);
     ok(!ret, "Expected 0, got %d\n", ret);
     ok(GetLastError() == CRYPT_E_ASN1_EOD ||
        GetLastError() == OSS_BAD_ARG, /* win98 */
-     "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08lx\n", GetLastError());
     /* Verifying the hash of a detached message succeeds? */
     ret = CryptVerifyMessageHash(&para, detachedHashContent,
      sizeof(detachedHashContent), NULL, NULL, NULL, NULL);
     todo_wine
-    ok(ret, "CryptVerifyMessageHash failed: %08x\n", GetLastError());
+    ok(ret, "CryptVerifyMessageHash failed: %08lx\n", GetLastError());
     /* As does verifying the hash of a regular message. */
     ret = CryptVerifyMessageHash(&para, hashContent, sizeof(hashContent),
      NULL, NULL, NULL, NULL);
-    ok(ret, "CryptVerifyMessageHash failed: %08x\n", GetLastError());
+    ok(ret, "CryptVerifyMessageHash failed: %08lx\n", GetLastError());
     ret = CryptVerifyMessageHash(&para, hashContent, sizeof(hashContent),
      NULL, &size, NULL, NULL);
-    ok(ret, "CryptVerifyMessageHash failed: %08x\n", GetLastError());
+    ok(ret, "CryptVerifyMessageHash failed: %08lx\n", GetLastError());
     if (ret)
         buf = CryptMemAlloc(size);
     if (buf)
@@ -244,11 +244,11 @@ static void test_verify_message_hash(void)
         ret = CryptVerifyMessageHash(&para, hashContent, sizeof(hashContent),
          buf, &size, NULL, NULL);
         ok(!ret && GetLastError() == ERROR_MORE_DATA,
-         "expected ERROR_MORE_DATA, got %08x\n", GetLastError());
+         "expected ERROR_MORE_DATA, got %08lx\n", GetLastError());
         ret = CryptVerifyMessageHash(&para, hashContent, sizeof(hashContent),
          buf, &size, NULL, NULL);
-        ok(ret, "CryptVerifyMessageHash failed: %08x\n", GetLastError());
-        ok(size == sizeof(msgData), "unexpected size %d\n", size);
+        ok(ret, "CryptVerifyMessageHash failed: %08lx\n", GetLastError());
+        ok(size == sizeof(msgData), "unexpected size %ld\n", size);
         ok(!memcmp(buf, msgData, size), "unexpected value\n");
         CryptMemFree(buf);
     }
@@ -338,24 +338,24 @@ static void test_verify_detached_message_signature(void)
     ret = CryptVerifyDetachedMessageSignature(NULL, 0, NULL, 0, 0, NULL,
      NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptVerifyDetachedMessageSignature(&para, 0, NULL, 0, 0, NULL,
      NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     para.cbSize = sizeof(para);
     SetLastError(0xdeadbeef);
     ret = CryptVerifyDetachedMessageSignature(&para, 0, NULL, 0, 0, NULL,
      NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     para.dwMsgAndCertEncodingType = X509_ASN_ENCODING;
     SetLastError(0xdeadbeef);
     ret = CryptVerifyDetachedMessageSignature(&para, 0, NULL, 0, 0, NULL,
      NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     para.dwMsgAndCertEncodingType = PKCS_7_ASN_ENCODING;
     SetLastError(0xdeadbeef);
     ret = CryptVerifyDetachedMessageSignature(&para, 0, NULL, 0, 0, NULL,
@@ -363,7 +363,7 @@ static void test_verify_detached_message_signature(void)
     ok(!ret, "Expected 0, got %d\n", ret);
     ok(GetLastError() == CRYPT_E_ASN1_EOD ||
      GetLastError() == OSS_BAD_ARG, /* win98 */
-     "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_EOD or OSS_BAD_ARG, got %08lx\n", GetLastError());
     /* None of these messages contains a cert in the message itself, so the
      * default callback isn't able to verify their signature.
      */
@@ -374,21 +374,21 @@ static void test_verify_detached_message_signature(void)
     todo_wine
     ok(GetLastError() == CRYPT_E_NOT_FOUND ||
      GetLastError() == OSS_DATA_ERROR, /* win98 */
-     "Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptVerifyDetachedMessageSignature(&para, 0, signedContent,
      sizeof(signedContent), 0, NULL, NULL, NULL);
     ok(!ret, "Expected 0, got %d\n", ret);
     ok(GetLastError() == CRYPT_E_NOT_FOUND ||
      GetLastError() == OSS_DATA_ERROR, /* win98 */
-     "Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptVerifyDetachedMessageSignature(&para, 0, detachedSignedContent,
      sizeof(detachedSignedContent), 0, NULL, NULL, NULL);
     ok(!ret, "Expected 0, got %d\n", ret);
     ok(GetLastError() == CRYPT_E_NOT_FOUND ||
      GetLastError() == OSS_DATA_ERROR, /* win98 */
-     "Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     pContent = msgData;
     cbContent = sizeof(msgData);
@@ -397,14 +397,14 @@ static void test_verify_detached_message_signature(void)
     ok(!ret, "Expected 0, got %d\n", ret);
     ok(GetLastError() == CRYPT_E_NOT_FOUND ||
      GetLastError() == OSS_DATA_ERROR, /* win98 */
-     "Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND or OSS_DATA_ERROR, got %08lx\n", GetLastError());
     /* Passing the correct callback results in success */
     para.pfnGetSignerCertificate = msg_get_signer_callback;
     ret = CryptVerifyDetachedMessageSignature(&para, 0, detachedSignedContent,
      sizeof(detachedSignedContent), 1, &pContent, &cbContent, NULL);
     ok(ret ||
      broken(!ret), /* win98 */
-     "CryptVerifyDetachedMessageSignature failed: %08x\n",
+     "CryptVerifyDetachedMessageSignature failed: %08lx\n",
      GetLastError());
     /* Not passing the correct data to be signed results in the signature not
      * matching.
@@ -415,7 +415,7 @@ static void test_verify_detached_message_signature(void)
     ok(!ret, "Expected 0, got %d\n", ret);
     ok(GetLastError() == NTE_BAD_SIGNATURE ||
      GetLastError() == OSS_DATA_ERROR, /* win98 */
-     "Expected NTE_BAD_SIGNATURE or OSS_DATA_ERROR, got %08x\n", GetLastError());
+     "Expected NTE_BAD_SIGNATURE or OSS_DATA_ERROR, got %08lx\n", GetLastError());
 }
 
 static const BYTE signedWithCertEmptyContent[] = {
@@ -493,42 +493,42 @@ static void test_verify_message_signature(void)
     SetLastError(0xdeadbeef);
     ret = CryptVerifyMessageSignature(NULL, 0, NULL, 0, NULL, 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* Is cbDecoded set when invalid parameters are passed? */
     cbDecoded = 0xdeadbeef;
     ret = CryptVerifyMessageSignature(NULL, 0, NULL, 0, NULL, &cbDecoded,
      NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
-    ok(cbDecoded == 0, "expected 0, got %08x\n", cbDecoded);
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
+    ok(cbDecoded == 0, "expected 0, got %08lx\n", cbDecoded);
     SetLastError(0xdeadbeef);
     ret = CryptVerifyMessageSignature(&para, 0, NULL, 0, NULL, 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     para.cbSize = sizeof(para);
     SetLastError(0xdeadbeef);
     ret = CryptVerifyMessageSignature(&para, 0, NULL, 0, NULL, 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     para.cbSize = 0;
     para.dwMsgAndCertEncodingType = PKCS_7_ASN_ENCODING;
     SetLastError(0xdeadbeef);
     ret = CryptVerifyMessageSignature(&para, 0, NULL, 0, NULL, 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     para.cbSize = sizeof(para);
     SetLastError(0xdeadbeef);
     ret = CryptVerifyMessageSignature(&para, 0, NULL, 0, NULL, 0, NULL);
     ok(!ret &&
      (GetLastError() == CRYPT_E_ASN1_EOD ||
       GetLastError() == OSS_BAD_ARG), /* win9x */
-     "Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
     /* Check whether cert is set on error */
     cert = (PCCERT_CONTEXT)0xdeadbeef;
     ret = CryptVerifyMessageSignature(&para, 0, NULL, 0, NULL, 0, &cert);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD ||
     GetLastError() == OSS_BAD_ARG /* NT40 */),
-     "Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
     ok(cert == NULL, "Expected NULL cert\n");
     /* Check whether cbDecoded is set on error */
     cbDecoded = 0xdeadbeef;
@@ -536,43 +536,43 @@ static void test_verify_message_signature(void)
      NULL);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD ||
      GetLastError() == OSS_BAD_ARG /* NT40 */),
-     "Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError());
     ok(!cbDecoded, "Expected 0\n");
     SetLastError(0xdeadbeef);
     ret = CryptVerifyMessageSignature(&para, 0, dataEmptyBareContent,
      sizeof(dataEmptyBareContent), NULL, 0, NULL);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
      GetLastError() == OSS_PDU_MISMATCH /* NT40 */),
-     "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
     ok(GetLastError() == CRYPT_E_ASN1_BADTAG ||
      GetLastError() == OSS_PDU_MISMATCH, /* win9x */
-     "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptVerifyMessageSignature(&para, 0, dataEmptyContent,
      sizeof(dataEmptyContent), NULL, 0, NULL);
     ok(!ret && GetLastError() == CRYPT_E_UNEXPECTED_MSG_TYPE,
-     "Expected CRYPT_E_UNEXPECTED_MSG_TYPE, got %08x\n", GetLastError());
+     "Expected CRYPT_E_UNEXPECTED_MSG_TYPE, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptVerifyMessageSignature(&para, 0, signedEmptyBareContent,
      sizeof(signedEmptyBareContent), NULL, 0, NULL);
     ok(!ret &&
      (GetLastError() == CRYPT_E_ASN1_BADTAG ||
       GetLastError() == OSS_DATA_ERROR), /* win9x */
-     "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptVerifyMessageSignature(&para, 0, signedEmptyContent,
      sizeof(signedEmptyContent), NULL, 0, NULL);
     ok(!ret &&
      (GetLastError() == CRYPT_E_NOT_FOUND ||
       GetLastError() == OSS_DATA_ERROR), /* win9x */
-     "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptVerifyMessageSignature(&para, 0, signedContent,
      sizeof(signedContent), NULL, 0, NULL);
     ok(!ret &&
      (GetLastError() == CRYPT_E_NOT_FOUND ||
       GetLastError() == OSS_DATA_ERROR), /* win9x */
-     "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
     /* FIXME: Windows fails with CRYPT_E_NOT_FOUND for these messages, but
      * their signer certs have invalid public keys that fail to decode.  In
      * Wine therefore the failure is an ASN error.  Need some messages with
@@ -599,22 +599,22 @@ static void test_verify_message_signature(void)
     ret = CryptVerifyMessageSignature(&para, 0,
      signedWithCertWithValidPubKeyContent,
      sizeof(signedWithCertWithValidPubKeyContent), NULL, &cbDecoded, NULL);
-    ok(ret, "CryptVerifyMessageSignature failed: %08x\n", GetLastError());
-    ok(cbDecoded == sizeof(msgData), "expected 4, got %d\n", cbDecoded);
+    ok(ret, "CryptVerifyMessageSignature failed: %08lx\n", GetLastError());
+    ok(cbDecoded == sizeof(msgData), "expected 4, got %ld\n", cbDecoded);
     cbDecoded = 0;
     ret = CryptVerifyMessageSignature(&para, 0,
      signedWithCertWithValidPubKeyContent,
      sizeof(signedWithCertWithValidPubKeyContent), NULL, &cbDecoded, NULL);
     /* Setting cbDecoded to 0 succeeds when a NULL buffer is provided */
-    ok(ret, "CryptVerifyMessageSignature failed: %08x\n", GetLastError());
-    ok(cbDecoded == sizeof(msgData), "expected 4, got %d\n", cbDecoded);
+    ok(ret, "CryptVerifyMessageSignature failed: %08lx\n", GetLastError());
+    ok(cbDecoded == sizeof(msgData), "expected 4, got %ld\n", cbDecoded);
     cbDecoded = 0;
     ret = CryptVerifyMessageSignature(&para, 0,
      signedWithCertWithValidPubKeyContent,
      sizeof(signedWithCertWithValidPubKeyContent), decoded, &cbDecoded, NULL);
     /* When a non-NULL buffer is provided, cbDecoded must not be too small */
     ok(!ret && GetLastError() == ERROR_MORE_DATA,
-     "expected ERROR_MORE_DATA, got %d (%08x)\n", GetLastError(),
+     "expected ERROR_MORE_DATA, got %ld (%08lx)\n", GetLastError(),
      GetLastError());
 }
 
@@ -653,38 +653,38 @@ static void test_hash_message(void)
     SetLastError(0xdeadbeef);
     ret = CryptHashMessage(&para, FALSE, 0, NULL, NULL, NULL, NULL, NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got 0x%08x\n", GetLastError());
+     "expected E_INVALIDARG, got 0x%08lx\n", GetLastError());
     para.cbSize = sizeof(para);
     /* Not quite sure what "success" means in this case, but it does succeed */
     SetLastError(0xdeadbeef);
     ret = CryptHashMessage(&para, FALSE, 0, NULL, NULL, NULL, NULL, NULL, NULL);
-    ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
+    ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
     /* With a bogus encoding type it "succeeds" */
     para.dwMsgEncodingType = 0xdeadbeef;
     SetLastError(0xdeadbeef);
     ret = CryptHashMessage(&para, FALSE, 0, NULL, NULL, NULL, NULL, NULL, NULL);
-    ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
+    ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
     /* According to MSDN, the third parameter (cToBeHashed) must be 1 if the
      * second parameter (fDetached) is FALSE, but again it "succeeds."
      */
     SetLastError(0xdeadbeef);
     ret = CryptHashMessage(&para, FALSE, 2, NULL, NULL, NULL, NULL, NULL, NULL);
-    ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
+    ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
     /* Even passing parameters to hash results in "success." */
     SetLastError(0xdeadbeef);
     ret = CryptHashMessage(&para, FALSE, 2, toHash, hashSize, NULL, NULL, NULL,
      NULL);
-    ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
+    ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
     /* Try again with a valid encoding type */
     para.dwMsgEncodingType = PKCS_7_ASN_ENCODING;
     SetLastError(0xdeadbeef);
     ret = CryptHashMessage(&para, FALSE, 2, NULL, NULL, NULL, NULL, NULL, NULL);
-    ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
+    ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
     /* And with valid data to hash */
     SetLastError(0xdeadbeef);
     ret = CryptHashMessage(&para, FALSE, 2, toHash, hashSize, NULL, NULL, NULL,
      NULL);
-    ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
+    ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
     /* But requesting the size of the hashed blob and indicating there's data
      * to hash results in a crash
      */
@@ -702,7 +702,7 @@ static void test_hash_message(void)
     ok(!ret &&
      (GetLastError() == CRYPT_E_UNKNOWN_ALGO ||
       GetLastError() == CRYPT_E_OID_FORMAT), /* Vista */
-     "expected CRYPT_E_UNKNOWN_ALGO or CRYPT_E_OID_FORMAT, got 0x%08x (%d)\n",
+     "expected CRYPT_E_UNKNOWN_ALGO or CRYPT_E_OID_FORMAT, got 0x%08lx (%ld)\n",
      GetLastError(), GetLastError());
     para.HashAlgorithm.pszObjId = oid_rsa_md5;
     /* With a valid hash algorithm, this succeeds, even though fDetached is
@@ -712,7 +712,7 @@ static void test_hash_message(void)
     ret = CryptHashMessage(&para, FALSE, 2, toHash, hashSize, NULL,
      &hashedBlobSize, NULL, NULL);
     todo_wine
-    ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
+    ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
     if (ret)
     {
         /* Actually attempting to get the hashed data fails, perhaps because
@@ -723,7 +723,7 @@ static void test_hash_message(void)
         ret = CryptHashMessage(&para, FALSE, 2, toHash, hashSize, hashedBlob,
          &hashedBlobSize, NULL, NULL);
         ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-         "expected CRYPT_E_MSG_ERROR, got 0x%08x (%d)\n", GetLastError(),
+         "expected CRYPT_E_MSG_ERROR, got 0x%08lx (%ld)\n", GetLastError(),
          GetLastError());
         HeapFree(GetProcessHeap(), 0, hashedBlob);
     }
@@ -731,16 +731,16 @@ static void test_hash_message(void)
     SetLastError(0xdeadbeef);
     ret = CryptHashMessage(&para, TRUE, 2, toHash, hashSize, NULL,
      &hashedBlobSize, NULL, NULL);
-    ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
+    ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
     if (ret)
     {
         hashedBlob = HeapAlloc(GetProcessHeap(), 0, hashedBlobSize);
         SetLastError(0xdeadbeef);
         ret = CryptHashMessage(&para, TRUE, 2, toHash, hashSize, hashedBlob,
          &hashedBlobSize, NULL, NULL);
-        ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
+        ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
         ok(hashedBlobSize == sizeof(detachedHashBlob),
-         "unexpected size of detached blob %d\n", hashedBlobSize);
+         "unexpected size of detached blob %ld\n", hashedBlobSize);
         ok(!memcmp(hashedBlob, detachedHashBlob, hashedBlobSize),
          "unexpected detached blob value\n");
         HeapFree(GetProcessHeap(), 0, hashedBlob);
@@ -749,15 +749,15 @@ static void test_hash_message(void)
     SetLastError(0xdeadbeef);
     ret = CryptHashMessage(&para, FALSE, 1, toHash, hashSize, NULL,
      &hashedBlobSize, NULL, NULL);
-    ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
+    ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
     if (ret)
     {
         hashedBlob = HeapAlloc(GetProcessHeap(), 0, hashedBlobSize);
         ret = CryptHashMessage(&para, FALSE, 1, toHash, hashSize, hashedBlob,
          &hashedBlobSize, NULL, NULL);
-        ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
+        ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
         ok(hashedBlobSize == sizeof(hashBlob),
-         "unexpected size of detached blob %d\n", hashedBlobSize);
+         "unexpected size of detached blob %ld\n", hashedBlobSize);
         ok(!memcmp(hashedBlob, hashBlob, hashedBlobSize),
          "unexpected detached blob value\n");
         HeapFree(GetProcessHeap(), 0, hashedBlob);
@@ -768,8 +768,8 @@ static void test_hash_message(void)
     computedHashSize = 0xdeadbeef;
     ret = CryptHashMessage(&para, TRUE, 2, toHash, hashSize, NULL,
      &hashedBlobSize, NULL, &computedHashSize);
-    ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
-    ok(computedHashSize == 16, "expected hash size of 16, got %d\n",
+    ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
+    ok(computedHashSize == 16, "expected hash size of 16, got %ld\n",
      computedHashSize);
     if (ret)
     {
@@ -777,9 +777,9 @@ static void test_hash_message(void)
         SetLastError(0xdeadbeef);
         ret = CryptHashMessage(&para, TRUE, 2, toHash, hashSize, NULL,
          &hashedBlobSize, computedHash, &computedHashSize);
-        ok(ret, "CryptHashMessage failed: 0x%08x\n", GetLastError());
+        ok(ret, "CryptHashMessage failed: 0x%08lx\n", GetLastError());
         ok(computedHashSize == sizeof(hashVal),
-         "unexpected size of hash value %d\n", computedHashSize);
+         "unexpected size of hash value %ld\n", computedHashSize);
         ok(!memcmp(computedHash, hashVal, computedHashSize),
          "unexpected value\n");
         HeapFree(GetProcessHeap(), 0, computedHash);
@@ -996,7 +996,7 @@ static void test_sign_message(void)
     ok(!ret &&
      (GetLastError() == E_INVALIDARG ||
       GetLastError() == ERROR_ARITHMETIC_OVERFLOW), /* Win7 */
-     "expected E_INVALIDARG or ERROR_ARITHMETIC_OVERFLOW, got %08x\n",
+     "expected E_INVALIDARG or ERROR_ARITHMETIC_OVERFLOW, got %08lx\n",
      GetLastError());
     para.cbSize = sizeof(para);
     para.dwMsgEncodingType = X509_ASN_ENCODING;
@@ -1004,20 +1004,20 @@ static void test_sign_message(void)
     signedBlobSize = 255;
     ret = CryptSignMessage(&para, FALSE, 0, NULL, NULL, NULL, &signedBlobSize);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
-    ok(!signedBlobSize, "unexpected size %d\n", signedBlobSize);
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
+    ok(!signedBlobSize, "unexpected size %ld\n", signedBlobSize);
     para.dwMsgEncodingType = PKCS_7_ASN_ENCODING;
     SetLastError(0xdeadbeef);
     signedBlobSize = 0;
     ret = CryptSignMessage(&para, FALSE, 0, NULL, NULL, NULL, &signedBlobSize);
-    ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
+    ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
     todo_wine
     ok(signedBlobSize, "bad size\n");
 
     SetLastError(0xdeadbeef);
     ret = CryptAcquireContextA(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
      CRYPT_VERIFYCONTEXT);
-    ok(ret, "CryptAcquireContextA failed: %08x\n", GetLastError());
+    ok(ret, "CryptAcquireContextA failed: %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptImportKey(hCryptProv, publicPrivateKeyPair,
      sizeof(publicPrivateKeyPair), 0, 0, &hKey);
@@ -1028,13 +1028,13 @@ static void test_sign_message(void)
             CryptReleaseContext(hCryptProv, 0);
         return;
     }
-    ok(ret, "CryptImportKey failed: %08x\n", GetLastError());
+    ok(ret, "CryptImportKey failed: %08lx\n", GetLastError());
 
     para.dwMsgEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
     SetLastError(0xdeadbeef);
     para.pSigningCert = CertCreateCertificateContext(X509_ASN_ENCODING |
      PKCS_7_ASN_ENCODING, cert1, sizeof(cert1));
-    ok(para.pSigningCert != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(para.pSigningCert != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
     para.HashAlgorithm.pszObjId = oid_rsa_md5;
 
@@ -1045,21 +1045,21 @@ static void test_sign_message(void)
     SetLastError(0xdeadbeef);
     ret = CertSetCertificateContextProperty(para.pSigningCert,
      CERT_KEY_CONTEXT_PROP_ID, 0, &keyContext);
-    ok(ret, "CertSetCertificateContextProperty failed: %08x\n", GetLastError());
+    ok(ret, "CertSetCertificateContextProperty failed: %08lx\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     signedBlobSize = 0;
     ret = CryptSignMessage(&para, TRUE, 0, NULL, NULL, NULL, &signedBlobSize);
-    ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
+    ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
     signedBlob = CryptMemAlloc(signedBlobSize);
     if (signedBlob)
     {
         SetLastError(0xdeadbeef);
         ret = CryptSignMessage(&para, TRUE, 0, NULL, NULL, signedBlob,
          &signedBlobSize);
-        ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
+        ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
         ok(signedBlobSize == sizeof(signedHashForEmptyMessage),
-         "unexpected size %d\n", signedBlobSize);
+         "unexpected size %ld\n", signedBlobSize);
         ok(!memcmp(signedBlob, signedHashForEmptyMessage, signedBlobSize),
          "unexpected value\n");
         CryptMemFree(signedBlob);
@@ -1068,15 +1068,15 @@ static void test_sign_message(void)
     SetLastError(0xdeadbeef);
     signedBlobSize = 0;
     ret = CryptSignMessage(&para, FALSE, 0, NULL, NULL, NULL, &signedBlobSize);
-    ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
+    ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
     signedBlob = CryptMemAlloc(signedBlobSize);
     if (signedBlob)
     {
         SetLastError(0xdeadbeef);
         ret = CryptSignMessage(&para, FALSE, 0, NULL, NULL, signedBlob,
          &signedBlobSize);
-        ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
-        ok(signedBlobSize == sizeof(signedEmptyMessage), "unexpected size %d\n",
+        ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
+        ok(signedBlobSize == sizeof(signedEmptyMessage), "unexpected size %ld\n",
          signedBlobSize);
         ok(!memcmp(signedBlob, signedEmptyMessage, signedBlobSize),
          "unexpected value\n");
@@ -1087,16 +1087,16 @@ static void test_sign_message(void)
     signedBlobSize = 0;
     ret = CryptSignMessage(&para, TRUE, 2, toSign, signSize, NULL,
      &signedBlobSize);
-    ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
+    ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
     signedBlob = CryptMemAlloc(signedBlobSize);
     if (signedBlob)
     {
         SetLastError(0xdeadbeef);
         ret = CryptSignMessage(&para, TRUE, 2, toSign, signSize, signedBlob,
          &signedBlobSize);
-        ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
+        ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
         ok(signedBlobSize == sizeof(signedHash),
-         "unexpected size of signed blob %d\n", signedBlobSize);
+         "unexpected size of signed blob %ld\n", signedBlobSize);
         ok(!memcmp(signedBlob, signedHash, signedBlobSize),
          "unexpected value\n");
         CryptMemFree(signedBlob);
@@ -1109,16 +1109,16 @@ static void test_sign_message(void)
     signedBlobSize = 0;
     ret = CryptSignMessage(&para, TRUE, 2, toSign, signSize, NULL,
      &signedBlobSize);
-    ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
+    ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
     signedBlob = CryptMemAlloc(signedBlobSize);
     if (signedBlob)
     {
         SetLastError(0xdeadbeef);
         ret = CryptSignMessage(&para, TRUE, 2, toSign, signSize, signedBlob,
          &signedBlobSize);
-        ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
+        ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
         ok(signedBlobSize == sizeof(signedHashWithCert),
-         "unexpected size of signed blob %d\n", signedBlobSize);
+         "unexpected size of signed blob %ld\n", signedBlobSize);
         ok(!memcmp(signedBlob, signedHashWithCert, signedBlobSize),
          "unexpected value\n");
         CryptMemFree(signedBlob);
@@ -1130,7 +1130,7 @@ static void test_sign_message(void)
     SetLastError(0xdeadbeef);
     crlContext = CertCreateCRLContext(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
      crl, sizeof(crl));
-    ok(crlContext != NULL, "CertCreateCRLContext failed: %08x\n",
+    ok(crlContext != NULL, "CertCreateCRLContext failed: %08lx\n",
      GetLastError());
     para.rgpMsgCrl = &crlContext;
 
@@ -1138,16 +1138,16 @@ static void test_sign_message(void)
     signedBlobSize = 0;
     ret = CryptSignMessage(&para, TRUE, 2, toSign, signSize, NULL,
      &signedBlobSize);
-    ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
+    ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
     signedBlob = CryptMemAlloc(signedBlobSize);
     if (signedBlob)
     {
         SetLastError(0xdeadbeef);
         ret = CryptSignMessage(&para, TRUE, 2, toSign, signSize, signedBlob,
          &signedBlobSize);
-        ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
+        ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
         ok(signedBlobSize == sizeof(signedHashWithCRL),
-         "unexpected size of signed blob %d\n", signedBlobSize);
+         "unexpected size of signed blob %ld\n", signedBlobSize);
         ok(!memcmp(signedBlob, signedHashWithCRL, signedBlobSize),
          "unexpected value\n");
         CryptMemFree(signedBlob);
@@ -1161,16 +1161,16 @@ static void test_sign_message(void)
     signedBlobSize = 0;
     ret = CryptSignMessage(&para, FALSE, 1, toSign, signSize, NULL,
      &signedBlobSize);
-    ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
+    ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
     signedBlob = CryptMemAlloc(signedBlobSize);
     if (signedBlob)
     {
         SetLastError(0xdeadbeef);
         ret = CryptSignMessage(&para, FALSE, 1, toSign, signSize, signedBlob,
          &signedBlobSize);
-        ok(ret, "CryptSignMessage failed: %08x\n", GetLastError());
+        ok(ret, "CryptSignMessage failed: %08lx\n", GetLastError());
         ok(signedBlobSize == sizeof(signedData),
-         "unexpected size of signed blob %d\n", signedBlobSize);
+         "unexpected size of signed blob %ld\n", signedBlobSize);
         ok(!memcmp(signedBlob, signedData, signedBlobSize),
          "unexpected value\n");
         CryptMemFree(signedBlob);
@@ -1204,17 +1204,17 @@ static void test_encrypt_message(void)
     SetLastError(0xdeadbeef);
     ret = CryptAcquireContextA(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
      CRYPT_VERIFYCONTEXT);
-    ok(ret, "CryptAcquireContextA failed: %08x\n", GetLastError());
+    ok(ret, "CryptAcquireContextA failed: %08lx\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     certs[0] = CertCreateCertificateContext(X509_ASN_ENCODING |
      PKCS_7_ASN_ENCODING, cert1, sizeof(cert1));
-    ok(certs[0] != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(certs[0] != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
     SetLastError(0xdeadbeef);
     certs[1] = CertCreateCertificateContext(X509_ASN_ENCODING |
      PKCS_7_ASN_ENCODING, cert2, sizeof(cert2));
-    ok(certs[1] != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(certs[1] != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
 
     memset(&para, 0, sizeof(para));
@@ -1223,8 +1223,8 @@ static void test_encrypt_message(void)
     ret = CryptEncryptMessage(&para, 0, NULL, NULL, 0, NULL,
      &encryptedBlobSize);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
-    ok(!encryptedBlobSize, "unexpected size %d\n", encryptedBlobSize);
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
+    ok(!encryptedBlobSize, "unexpected size %ld\n", encryptedBlobSize);
     para.cbSize = sizeof(para);
     para.dwMsgEncodingType = X509_ASN_ENCODING;
     SetLastError(0xdeadbeef);
@@ -1232,8 +1232,8 @@ static void test_encrypt_message(void)
     ret = CryptEncryptMessage(&para, 0, NULL, NULL, 0, NULL,
      &encryptedBlobSize);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
-    ok(!encryptedBlobSize, "unexpected size %d\n", encryptedBlobSize);
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
+    ok(!encryptedBlobSize, "unexpected size %ld\n", encryptedBlobSize);
     para.dwMsgEncodingType = PKCS_7_ASN_ENCODING;
     SetLastError(0xdeadbeef);
     encryptedBlobSize = 255;
@@ -1242,9 +1242,9 @@ static void test_encrypt_message(void)
     ok(!ret &&
      (GetLastError() == CRYPT_E_UNKNOWN_ALGO ||
       GetLastError() == E_INVALIDARG), /* Win9x */
-     "expected CRYPT_E_UNKNOWN_ALGO or E_INVALIDARG, got %08x\n",
+     "expected CRYPT_E_UNKNOWN_ALGO or E_INVALIDARG, got %08lx\n",
      GetLastError());
-    ok(!encryptedBlobSize, "unexpected size %d\n", encryptedBlobSize);
+    ok(!encryptedBlobSize, "unexpected size %ld\n", encryptedBlobSize);
 
     para.hCryptProv = hCryptProv;
     para.ContentEncryptionAlgorithm.pszObjId = oid_rsa_rc4;
@@ -1255,7 +1255,7 @@ static void test_encrypt_message(void)
      &encryptedBlobSize);
     ok(ret ||
      broken(!ret) /* Win9x */,
-     "CryptEncryptMessage failed: %08x\n", GetLastError());
+     "CryptEncryptMessage failed: %08lx\n", GetLastError());
     if (ret)
     {
         encryptedBlob = CryptMemAlloc(encryptedBlobSize);
@@ -1264,9 +1264,9 @@ static void test_encrypt_message(void)
             SetLastError(0xdeadbeef);
             ret = CryptEncryptMessage(&para, 0, NULL, NULL, 0, encryptedBlob,
              &encryptedBlobSize);
-            ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
+            ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError());
 	    ok(encryptedBlobSize == sizeof(encryptedMessage),
-             "unexpected size of encrypted blob %d\n", encryptedBlobSize);
+             "unexpected size of encrypted blob %ld\n", encryptedBlobSize);
             ok(!memcmp(encryptedBlob, encryptedMessage, encryptedBlobSize),
              "unexpected value\n");
             CryptMemFree(encryptedBlob);
@@ -1277,7 +1277,7 @@ static void test_encrypt_message(void)
     encryptedBlobSize = 0;
     ret = CryptEncryptMessage(&para, 2, certs, NULL, 0, NULL,
      &encryptedBlobSize);
-    ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError());
     if (ret)
     {
         encryptedBlob = CryptMemAlloc(encryptedBlobSize);
@@ -1286,7 +1286,7 @@ static void test_encrypt_message(void)
             SetLastError(0xdeadbeef);
             ret = CryptEncryptMessage(&para, 2, certs, NULL, 0, encryptedBlob,
              &encryptedBlobSize);
-            ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
+            ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError());
             CryptMemFree(encryptedBlob);
         }
     }
@@ -1297,7 +1297,7 @@ static void test_encrypt_message(void)
      &encryptedBlobSize);
     ok(ret ||
      broken(!ret) /* Win9x */,
-     "CryptEncryptMessage failed: %08x\n", GetLastError());
+     "CryptEncryptMessage failed: %08lx\n", GetLastError());
     if (ret)
     {
         encryptedBlob = CryptMemAlloc(encryptedBlobSize);
@@ -1308,11 +1308,11 @@ static void test_encrypt_message(void)
              encryptedBlob, &encryptedBlobSize);
             ok(ret ||
              broken(!ret && GetLastError() == NTE_PERM), /* some NT4 */
-             "CryptEncryptMessage failed: %08x\n", GetLastError());
+             "CryptEncryptMessage failed: %08lx\n", GetLastError());
             if (ret)
             {
                 ok(encryptedBlobSize == 55,
-                 "unexpected size of encrypted blob %d\n", encryptedBlobSize);
+                 "unexpected size of encrypted blob %ld\n", encryptedBlobSize);
             }
             CryptMemFree(encryptedBlob);
         }
@@ -1322,7 +1322,7 @@ static void test_encrypt_message(void)
     encryptedBlobSize = 0;
     ret = CryptEncryptMessage(&para, 2, certs, blob, sizeof(blob), NULL,
      &encryptedBlobSize);
-    ok(ret, "CryptEncryptMessage failed: %08x\n", GetLastError());
+    ok(ret, "CryptEncryptMessage failed: %08lx\n", GetLastError());
     if (ret)
     {
         encryptedBlob = CryptMemAlloc(encryptedBlobSize);
@@ -1333,7 +1333,7 @@ static void test_encrypt_message(void)
              encryptedBlob, &encryptedBlobSize);
             ok(ret ||
              broken(!ret), /* some Win95 and some NT4 */
-             "CryptEncryptMessage failed: %08x\n", GetLastError());
+             "CryptEncryptMessage failed: %08lx\n", GetLastError());
             CryptMemFree(encryptedBlob);
         }
     }
diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index 39cb74b751b..d66a972da05 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -49,32 +49,32 @@ static void test_msg_open_to_encode(void)
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(0, 0, 0, NULL, NULL, NULL);
     ok(!msg && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %x\n", GetLastError());
+     "Expected E_INVALIDARG, got %lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL);
     ok(!msg && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %x\n", GetLastError());
+     "Expected E_INVALIDARG, got %lx\n", GetLastError());
 
     /* Bad message types */
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, 0, NULL, NULL, NULL);
     ok(!msg && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0, 0,
      NULL, NULL, NULL);
     ok(!msg && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0,
      CMSG_SIGNED_AND_ENVELOPED, NULL, NULL, NULL);
     ok(!msg && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENCRYPTED, NULL,
      NULL, NULL);
     ok(!msg && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError());
 }
 
 static void test_msg_open_to_decode(void)
@@ -85,50 +85,50 @@ static void test_msg_open_to_decode(void)
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToDecode(0, 0, 0, 0, NULL, NULL);
     ok(!msg && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %x\n", GetLastError());
+     "Expected E_INVALIDARG, got %lx\n", GetLastError());
 
     /* Bad encodings */
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToDecode(X509_ASN_ENCODING, 0, 0, 0, NULL, NULL);
     ok(!msg && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %x\n", GetLastError());
+     "Expected E_INVALIDARG, got %lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToDecode(X509_ASN_ENCODING, 0, CMSG_DATA, 0, NULL, NULL);
     ok(!msg && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %x\n", GetLastError());
+     "Expected E_INVALIDARG, got %lx\n", GetLastError());
 
     /* The message type can be explicit... */
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL,
      NULL);
-    ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL,
      NULL);
-    ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL,
      NULL);
-    ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL,
      NULL);
-    ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0,
      CMSG_SIGNED_AND_ENVELOPED, 0, NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     /* or implicit.. */
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     /* or even invalid. */
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENCRYPTED, 0, NULL,
      NULL);
-    ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 1000, 0, NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     /* And even though the stream info parameter "must be set to NULL" for
@@ -136,7 +136,7 @@ static void test_msg_open_to_decode(void)
      */
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL,
      &streamInfo);
-    ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
 }
 
@@ -154,95 +154,95 @@ static void test_msg_get_param(void)
 
     /* Decoded messages */
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError());
     /* For decoded messages, the type is always available */
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, NULL, &size);
-    ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError());
     size = sizeof(value);
     ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size);
-    ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError());
     /* For this (empty) message, the type isn't set */
-    ok(value == 0, "Expected type 0, got %d\n", value);
+    ok(value == 0, "Expected type 0, got %ld\n", value);
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL,
      NULL);
-    ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError());
     /* For explicitly typed messages, the type is known. */
     size = sizeof(value);
     ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size);
-    ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
-    ok(value == CMSG_DATA, "Expected CMSG_DATA, got %d\n", value);
+    ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError());
+    ok(value == CMSG_DATA, "Expected CMSG_DATA, got %ld\n", value);
     for (i = CMSG_CONTENT_PARAM; !old_crypt32 && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++)
     {
         size = 0;
         ret = CryptMsgGetParam(msg, i, 0, NULL, &size);
-        ok(!ret, "Parameter %d: expected failure\n", i);
+        ok(!ret, "Parameter %ld: expected failure\n", i);
     }
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL,
      NULL);
-    ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError());
     size = sizeof(value);
     ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size);
-    ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
-    ok(value == CMSG_ENVELOPED, "Expected CMSG_ENVELOPED, got %d\n", value);
+    ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError());
+    ok(value == CMSG_ENVELOPED, "Expected CMSG_ENVELOPED, got %ld\n", value);
     for (i = CMSG_CONTENT_PARAM; !old_crypt32 && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++)
     {
         size = 0;
         ret = CryptMsgGetParam(msg, i, 0, NULL, &size);
-        ok(!ret, "Parameter %d: expected failure\n", i);
+        ok(!ret, "Parameter %ld: expected failure\n", i);
     }
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL,
      NULL);
-    ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError());
     size = sizeof(value);
     ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size);
-    ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
-    ok(value == CMSG_HASHED, "Expected CMSG_HASHED, got %d\n", value);
+    ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError());
+    ok(value == CMSG_HASHED, "Expected CMSG_HASHED, got %ld\n", value);
     for (i = CMSG_CONTENT_PARAM; !old_crypt32 && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++)
     {
         size = 0;
         ret = CryptMsgGetParam(msg, i, 0, NULL, &size);
-        ok(!ret, "Parameter %d: expected failure\n", i);
+        ok(!ret, "Parameter %ld: expected failure\n", i);
     }
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL,
      NULL);
-    ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError());
     size = sizeof(value);
     ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size);
-    ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
-    ok(value == CMSG_SIGNED, "Expected CMSG_SIGNED, got %d\n", value);
+    ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError());
+    ok(value == CMSG_SIGNED, "Expected CMSG_SIGNED, got %ld\n", value);
     for (i = CMSG_CONTENT_PARAM; !old_crypt32 && (i <= CMSG_CMS_SIGNER_INFO_PARAM); i++)
     {
         size = 0;
         ret = CryptMsgGetParam(msg, i, 0, NULL, &size);
-        ok(!ret, "Parameter %d: expected failure\n", i);
+        ok(!ret, "Parameter %ld: expected failure\n", i);
     }
     CryptMsgClose(msg);
 
     /* Explicitly typed messages get their types set, even if they're invalid */
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENCRYPTED, 0, NULL,
      NULL);
-    ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError());
     size = sizeof(value);
     ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size);
-    ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
-    ok(value == CMSG_ENCRYPTED, "Expected CMSG_ENCRYPTED, got %d\n", value);
+    ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError());
+    ok(value == CMSG_ENCRYPTED, "Expected CMSG_ENCRYPTED, got %ld\n", value);
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 1000, 0, NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToDecode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToDecode failed: %lx\n", GetLastError());
     size = sizeof(value);
     ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, &value, &size);
-    ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
-    ok(value == 1000, "Expected 1000, got %d\n", value);
+    ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError());
+    ok(value == 1000, "Expected 1000, got %ld\n", value);
     CryptMsgClose(msg);
 }
 
@@ -253,15 +253,15 @@ static void test_msg_close(void)
 
     /* NULL succeeds.. */
     ret = CryptMsgClose(NULL);
-    ok(ret, "CryptMsgClose failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgClose failed: %lx\n", GetLastError());
     /* but an arbitrary pointer crashes. */
     if (0)
         ret = CryptMsgClose((HCRYPTMSG)1);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL,
      NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     ret = CryptMsgClose(msg);
-    ok(ret, "CryptMsgClose failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgClose failed: %lx\n", GetLastError());
 }
 
 static void check_param(LPCSTR test, HCRYPTMSG msg, DWORD param,
@@ -275,16 +275,16 @@ static void check_param(LPCSTR test, HCRYPTMSG msg, DWORD param,
     ret = CryptMsgGetParam(msg, param, 0, NULL, &size);
     ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */ ||
      GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x, for some params */),
-     "%s: CryptMsgGetParam failed: %08x\n", test, GetLastError());
+     "%s: CryptMsgGetParam failed: %08lx\n", test, GetLastError());
     if (!ret)
     {
-        win_skip("parameter %d not supported, skipping tests\n", param);
+        win_skip("parameter %ld not supported, skipping tests\n", param);
         return;
     }
     buf = HeapAlloc(GetProcessHeap(), 0, size);
     ret = CryptMsgGetParam(msg, param, 0, buf, &size);
-    ok(ret, "%s: CryptMsgGetParam failed: %08x\n", test, GetLastError());
-    ok(size == expectedSize, "%s: expected size %d, got %d\n", test,
+    ok(ret, "%s: CryptMsgGetParam failed: %08lx\n", test, GetLastError());
+    ok(size == expectedSize, "%s: expected size %ld, got %ld\n", test,
      expectedSize, size);
     if (size == expectedSize && size)
         ok(!memcmp(buf, expected, size), "%s: unexpected data\n", test);
@@ -303,34 +303,34 @@ static void test_data_msg_open(void)
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, &hashInfo,
      NULL, NULL);
     ok(!msg && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %x\n", GetLastError());
+     "Expected E_INVALIDARG, got %lx\n", GetLastError());
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL,
      NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     /* An empty stream info is allowed. */
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL,
      &streamInfo);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     /* Passing a bogus inner OID succeeds for a non-streamed message.. */
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, oid,
      NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     /* and still succeeds when CMSG_DETACHED_FLAG is passed.. */
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG,
      CMSG_DATA, NULL, oid, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     /* and when a stream info is given, even though you're not supposed to be
      * able to use anything but szOID_RSA_data when streaming is being used.
      */
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG,
      CMSG_DATA, NULL, oid, &streamInfo);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
 }
 
@@ -356,28 +356,28 @@ static void test_data_msg_update(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
     ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-     "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+     "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError());
     /* Updating it with final = TRUE succeeds */
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     /* Any subsequent update will fail, as the last was final */
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
     ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-     "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+     "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL,
      NULL);
     /* Starting with Vista, can update a message with no data. */
     ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-    ok(ret || broken(!ret), "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret || broken(!ret), "CryptMsgUpdate failed: %08lx\n", GetLastError());
     if (ret)
     {
         DWORD size;
 
         ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size);
-        ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
+        ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
         if (ret)
         {
             LPBYTE buf = CryptMemAlloc(size);
@@ -386,11 +386,11 @@ static void test_data_msg_update(void)
             {
                 ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, buf,
                  &size);
-                ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
+                ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
                 if (ret)
                 {
                     ok(size == sizeof(dataEmptyBareContent),
-                     "unexpected size %d\n", size);
+                     "unexpected size %ld\n", size);
                     ok(!memcmp(buf, dataEmptyBareContent, size),
                      "unexpected value\n");
                 }
@@ -408,16 +408,16 @@ static void test_data_msg_update(void)
     ok(!ret &&
      (GetLastError() == E_INVALIDARG ||
       broken(GetLastError() == ERROR_SUCCESS)), /* Older NT4 */
-     "Expected E_INVALIDARG, got %x\n", GetLastError());
+     "Expected E_INVALIDARG, got %lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
     ok(!ret &&
      (GetLastError() == E_INVALIDARG ||
       broken(GetLastError() == ERROR_SUCCESS)), /* Older NT4 */
-     "Expected E_INVALIDARG, got %x\n", GetLastError());
+     "Expected E_INVALIDARG, got %lx\n", GetLastError());
 
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     if (!old_crypt32)
@@ -432,7 +432,7 @@ static void test_data_msg_update(void)
         ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
         ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION ||
          GetLastError() == STATUS_ILLEGAL_INSTRUCTION /* WinME */),
-         "Expected STATUS_ACCESS_VIOLATION or STATUS_ILLEGAL_INSTRUCTION, got %x\n",
+         "Expected STATUS_ACCESS_VIOLATION or STATUS_ILLEGAL_INSTRUCTION, got %lx\n",
          GetLastError());
         CryptMsgClose(msg);
     }
@@ -443,9 +443,9 @@ static void test_data_msg_update(void)
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL,
      &streamInfo);
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
 }
 
@@ -462,10 +462,10 @@ static void test_data_msg_get_param(void)
     /* Content and bare content are always gettable when not streaming */
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
     /* But for this type of message, the signer and hash aren't applicable,
      * and the type isn't available.
      */
@@ -473,14 +473,14 @@ static void test_data_msg_get_param(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError());
     ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     /* Can't get content or bare content when streaming */
@@ -489,11 +489,11 @@ static void test_data_msg_get_param(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size);
     ok((!ret && GetLastError() == E_INVALIDARG) || broken(ret /* Win9x */),
-     "Expected E_INVALIDARG, got %x\n", GetLastError());
+     "Expected E_INVALIDARG, got %lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size);
     ok((!ret && GetLastError() == E_INVALIDARG) || broken(ret /* Win9x */),
-     "Expected E_INVALIDARG, got %x\n", GetLastError());
+     "Expected E_INVALIDARG, got %lx\n", GetLastError());
     CryptMsgClose(msg);
 }
 
@@ -577,18 +577,18 @@ static void check_updates(LPCSTR header, const struct update_accum *expected,
     DWORD i;
 
     ok(expected->cUpdates == got->cUpdates,
-     "%s: expected %d updates, got %d\n", header, expected->cUpdates,
+     "%s: expected %ld updates, got %ld\n", header, expected->cUpdates,
      got->cUpdates);
     if (expected->cUpdates == got->cUpdates)
         for (i = 0; i < min(expected->cUpdates, got->cUpdates); i++)
         {
             ok(expected->updates[i].cbData == got->updates[i].cbData,
-             "%s, update %d: expected %d bytes, got %d\n", header, i,
+             "%s, update %ld: expected %ld bytes, got %ld\n", header, i,
              expected->updates[i].cbData, got->updates[i].cbData);
             if (expected->updates[i].cbData && expected->updates[i].cbData ==
              got->updates[i].cbData)
                 ok(!memcmp(expected->updates[i].pbData, got->updates[i].pbData,
-                 got->updates[i].cbData), "%s, update %d: unexpected value\n",
+                 got->updates[i].cbData), "%s, update %ld: unexpected value\n",
                  header, i);
         }
 }
@@ -620,7 +620,7 @@ static void test_data_msg_encoding(void)
     check_param("data empty content", msg, CMSG_CONTENT_PARAM, dataEmptyContent,
      sizeof(dataEmptyContent));
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     check_param("data bare content", msg, CMSG_BARE_CONTENT_PARAM,
      dataBareContent, sizeof(dataBareContent));
     check_param("data content", msg, CMSG_CONTENT_PARAM, dataContent,
@@ -634,7 +634,7 @@ static void test_data_msg_encoding(void)
     check_param("data empty content", msg, CMSG_CONTENT_PARAM, dataEmptyContent,
      sizeof(dataEmptyContent));
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     check_param("data bare content", msg, CMSG_BARE_CONTENT_PARAM,
      dataBareContent, sizeof(dataBareContent));
     check_param("data content", msg, CMSG_CONTENT_PARAM, dataContent,
@@ -648,7 +648,7 @@ static void test_data_msg_encoding(void)
     check_param("data bogus oid content", msg, CMSG_CONTENT_PARAM,
      dataEmptyContent, sizeof(dataEmptyContent));
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     check_param("data bare content", msg, CMSG_BARE_CONTENT_PARAM,
      dataBareContent, sizeof(dataBareContent));
     check_param("data content", msg, CMSG_CONTENT_PARAM, dataContent,
@@ -702,25 +702,25 @@ static void test_hash_msg_open(void)
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo,
      NULL, NULL);
     ok(!msg && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %x\n", GetLastError());
+     "Expected E_INVALIDARG, got %lx\n", GetLastError());
     hashInfo.cbSize = sizeof(hashInfo);
     SetLastError(0xdeadbeef);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo,
      NULL, NULL);
     ok(!msg && GetLastError() == CRYPT_E_UNKNOWN_ALGO,
-     "Expected CRYPT_E_UNKNOWN_ALGO, got %x\n", GetLastError());
+     "Expected CRYPT_E_UNKNOWN_ALGO, got %lx\n", GetLastError());
     hashInfo.HashAlgorithm.pszObjId = oid_rsa_md5;
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo,
      NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG,
      CMSG_HASHED, &hashInfo, NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG,
      CMSG_HASHED, &hashInfo, NULL, &streamInfo);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
 }
 
@@ -738,22 +738,22 @@ static void test_hash_msg_update(void)
      * updates..
      */
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     /* including non-final updates with no data.. */
     ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     /* and final updates with no data. */
     ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     /* But no updates are allowed after the final update. */
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
     ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-     "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+     "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
     ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-     "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+     "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError());
     CryptMsgClose(msg);
     /* Non-detached messages, in contrast, don't allow non-final updates in
      * non-streaming mode.
@@ -763,16 +763,16 @@ static void test_hash_msg_update(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
     ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-     "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+     "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError());
     /* Final updates (including empty ones) are allowed. */
     ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     /* And, of course, streaming mode allows non-final updates */
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo,
      NULL, &streamInfo);
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     /* Setting pfnStreamOutput to NULL results in no error.  (In what appears
      * to be a bug, it isn't actually used - see encoding tests.)
@@ -781,7 +781,7 @@ static void test_hash_msg_update(void)
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo,
      NULL, &streamInfo);
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     CryptMsgClose(msg);
 }
 
@@ -805,26 +805,26 @@ static void test_hash_msg_get_param(void)
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size);
     ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */),
-     "CryptMsgGetParam failed: %08x\n", GetLastError());
+     "CryptMsgGetParam failed: %08lx\n", GetLastError());
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size);
     ok(ret || broken(GetLastError() == OSS_LIMITED /* Win9x */),
-     "CryptMsgGetParam failed: %08x\n", GetLastError());
+     "CryptMsgGetParam failed: %08lx\n", GetLastError());
     /* For an encoded hash message, the hash data aren't available */
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_HASH_DATA_PARAM, 0, NULL, &size);
     ok(!ret && (GetLastError() == CRYPT_E_INVALID_MSG_TYPE ||
      GetLastError() == OSS_LIMITED /* Win9x */),
-     "Expected CRYPT_E_INVALID_MSG_TYPE or OSS_LIMITED, got %08x\n",
+     "Expected CRYPT_E_INVALID_MSG_TYPE or OSS_LIMITED, got %08lx\n",
      GetLastError());
     /* The hash is also available. */
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
-    ok(size == sizeof(buf), "Unexpected size %d\n", size);
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
+    ok(size == sizeof(buf), "Unexpected size %ld\n", size);
     ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
-    ok(size == sizeof(buf), "Unexpected size %d\n", size);
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
+    ok(size == sizeof(buf), "Unexpected size %ld\n", size);
     if (size == sizeof(buf))
         ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n");
     /* By getting the hash, further updates are not allowed */
@@ -835,24 +835,24 @@ static void test_hash_msg_get_param(void)
         GetLastError() == NTE_BAD_ALGID /* 9x */ ||
         GetLastError() == CRYPT_E_MSG_ERROR /* Vista */ ||
         broken(GetLastError() == ERROR_SUCCESS) /* Some Win9x */),
-       "Expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, got 0x%x\n", GetLastError());
+       "Expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, got 0x%lx\n", GetLastError());
 
     /* Even after a final update, the hash data aren't available */
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_HASH_DATA_PARAM, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     /* The version is also available, and should be zero for this message. */
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, NULL, &size);
     ok(ret || broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x */),
-     "CryptMsgGetParam failed: %08x\n", GetLastError());
+     "CryptMsgGetParam failed: %08lx\n", GetLastError());
     size = sizeof(value);
     ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, &value, &size);
     ok(ret || broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x */),
-     "CryptMsgGetParam failed: %08x\n", GetLastError());
+     "CryptMsgGetParam failed: %08lx\n", GetLastError());
     if (ret)
-        ok(value == 0, "Expected version 0, got %d\n", value);
+        ok(value == 0, "Expected version 0, got %ld\n", value);
     /* As usual, the type isn't available. */
     ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, NULL, &size);
     ok(!ret, "Expected failure\n");
@@ -865,19 +865,19 @@ static void test_hash_msg_get_param(void)
     ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size);
     ok(!ret && (GetLastError() == E_INVALIDARG ||
      GetLastError() == OSS_LIMITED /* Win9x */),
-     "Expected E_INVALIDARG or OSS_LIMITED, got %x\n", GetLastError());
+     "Expected E_INVALIDARG or OSS_LIMITED, got %lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size);
     ok(!ret && (GetLastError() == E_INVALIDARG ||
      GetLastError() == OSS_LIMITED /* Win9x */),
-     "Expected E_INVALIDARG or OSS_LIMITED, got %x\n", GetLastError());
+     "Expected E_INVALIDARG or OSS_LIMITED, got %lx\n", GetLastError());
     /* The hash is still available. */
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
-    ok(size == sizeof(buf), "Unexpected size %d\n", size);
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
+    ok(size == sizeof(buf), "Unexpected size %ld\n", size);
     ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, buf, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
     if (size == sizeof(buf))
         ok(!memcmp(buf, emptyHashParam, size), "Unexpected value\n");
     /* After updating the hash, further updates aren't allowed on streamed
@@ -890,7 +890,7 @@ static void test_hash_msg_get_param(void)
         GetLastError() == NTE_BAD_ALGID /* 9x */ ||
         GetLastError() == CRYPT_E_MSG_ERROR /* Vista */ ||
         broken(GetLastError() == ERROR_SUCCESS) /* Some Win9x */),
-       "Expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, got 0x%x\n", GetLastError());
+       "Expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, got 0x%lx\n", GetLastError());
 
     CryptMsgClose(msg);
 }
@@ -951,7 +951,7 @@ static void test_hash_msg_encoding(void)
     check_param("hash empty content", msg, CMSG_CONTENT_PARAM,
      hashEmptyContent, sizeof(hashEmptyContent));
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     check_param("hash bare content", msg, CMSG_BARE_CONTENT_PARAM,
      hashBareContent, sizeof(hashBareContent));
     check_param("hash content", msg, CMSG_CONTENT_PARAM,
@@ -965,7 +965,7 @@ static void test_hash_msg_encoding(void)
     check_param("hash empty content", msg, CMSG_CONTENT_PARAM,
      hashEmptyContent, sizeof(hashEmptyContent));
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     check_param("hash bare content", msg, CMSG_BARE_CONTENT_PARAM,
      hashBareContent, sizeof(hashBareContent));
     check_param("hash content", msg, CMSG_CONTENT_PARAM,
@@ -980,14 +980,14 @@ static void test_hash_msg_encoding(void)
     check_param("detached hash empty content", msg, CMSG_CONTENT_PARAM,
      hashEmptyContent, sizeof(hashEmptyContent));
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     check_param("detached hash not final bare content", msg,
      CMSG_BARE_CONTENT_PARAM, detachedHashNonFinalBareContent,
      sizeof(detachedHashNonFinalBareContent));
     check_param("detached hash not final content", msg, CMSG_CONTENT_PARAM,
      detachedHashNonFinalContent, sizeof(detachedHashNonFinalContent));
     ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     check_param("detached hash bare content", msg, CMSG_BARE_CONTENT_PARAM,
      detachedHashBareContent, sizeof(detachedHashBareContent));
     check_param("detached hash content", msg, CMSG_CONTENT_PARAM,
@@ -1003,9 +1003,9 @@ static void test_hash_msg_encoding(void)
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo,
      NULL, &streamInfo);
     ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     check_updates("empty hash message", &empty_accum, &accum);
     free_updates(&accum);
@@ -1014,7 +1014,7 @@ static void test_hash_msg_encoding(void)
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo,
      NULL, &streamInfo);
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     check_updates("hash message", &empty_accum, &accum);
     free_updates(&accum);
@@ -1023,7 +1023,7 @@ static void test_hash_msg_encoding(void)
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG,
      CMSG_HASHED, &hashInfo, NULL, &streamInfo);
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     check_updates("detached hash message", &empty_accum, &accum);
     free_updates(&accum);
@@ -1055,11 +1055,11 @@ static void test_signed_msg_open(void)
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
      NULL, NULL);
     ok(!msg && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %x\n", GetLastError());
+     "Expected E_INVALIDARG, got %lx\n", GetLastError());
     signInfo.cbSize = sizeof(signInfo);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
      NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     signInfo.cSigners = 1;
@@ -1075,7 +1075,7 @@ static void test_signed_msg_open(void)
     /* NT: E_INVALIDARG, 9x: unchanged or CRYPT_E_UNKNOWN_ALGO */
     ok(!msg && (GetLastError() == E_INVALIDARG || GetLastError() == 0xdeadbeef
      || GetLastError() == CRYPT_E_UNKNOWN_ALGO),
-     "Expected E_INVALIDARG or 0xdeadbeef or CRYPT_E_UNKNOWN_ALGO, got 0x%x\n",
+     "Expected E_INVALIDARG or 0xdeadbeef or CRYPT_E_UNKNOWN_ALGO, got 0x%lx\n",
      GetLastError());
 
     certInfo.SerialNumber.cbData = sizeof(serialNum);
@@ -1086,7 +1086,7 @@ static void test_signed_msg_open(void)
     /* NT: E_INVALIDARG, 9x: unchanged or CRYPT_E_UNKNOWN_ALGO */
     ok(!msg && (GetLastError() == E_INVALIDARG || GetLastError() == 0xdeadbeef
      || GetLastError() == CRYPT_E_UNKNOWN_ALGO),
-     "Expected E_INVALIDARG or 0xdeadbeef or CRYPT_E_UNKNOWN_ALGO, got 0x%x\n",
+     "Expected E_INVALIDARG or 0xdeadbeef or CRYPT_E_UNKNOWN_ALGO, got 0x%lx\n",
      GetLastError());
 
     certInfo.Issuer.cbData = sizeof(encodedCommonName);
@@ -1096,7 +1096,7 @@ static void test_signed_msg_open(void)
      NULL, NULL);
     ok(!msg && (GetLastError() == E_INVALIDARG ||
      GetLastError() == CRYPT_E_UNKNOWN_ALGO),
-     "Expected E_INVALIDARG or CRYPT_E_UNKNOWN_ALGO, got %x\n", GetLastError());
+     "Expected E_INVALIDARG or CRYPT_E_UNKNOWN_ALGO, got %lx\n", GetLastError());
 
     /* The signer's hCryptProv must be set to something.  Whether it's usable
      * or not will be checked after the hash algorithm is checked (see next
@@ -1107,7 +1107,7 @@ static void test_signed_msg_open(void)
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
      NULL, NULL);
     ok(!msg && GetLastError() == CRYPT_E_UNKNOWN_ALGO,
-     "Expected CRYPT_E_UNKNOWN_ALGO, got %x\n", GetLastError());
+     "Expected CRYPT_E_UNKNOWN_ALGO, got %lx\n", GetLastError());
     /* The signer's hash algorithm must also be set. */
     signer.HashAlgorithm.pszObjId = oid_rsa_md5;
     SetLastError(0xdeadbeef);
@@ -1116,7 +1116,7 @@ static void test_signed_msg_open(void)
         msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED,
          &signInfo, NULL, NULL);
         ok(!msg && GetLastError() == ERROR_INVALID_PARAMETER,
-         "Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError());
+         "Expected ERROR_INVALID_PARAMETER, got %lx\n", GetLastError());
     }
     /* The signer's hCryptProv must also be valid. */
     ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL,
@@ -1125,12 +1125,12 @@ static void test_signed_msg_open(void)
         ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL,
                                     PROV_RSA_FULL, 0);
     }
-    ok(ret, "CryptAcquireContext failed: 0x%x\n", GetLastError());
+    ok(ret, "CryptAcquireContext failed: 0x%lx\n", GetLastError());
 
     if (ret) {
         msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
                                    NULL, NULL);
-        ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+        ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
         CryptMsgClose(msg);
     }
 
@@ -1148,7 +1148,7 @@ static void test_signed_msg_open(void)
     U(signer.SignerId).IssuerSerialNumber.SerialNumber.pbData = serialNum;
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
      NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     CryptReleaseContext(signer.hCryptProv, 0);
@@ -1212,7 +1212,7 @@ static void test_signed_msg_update(void)
         ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL,
                                     PROV_RSA_FULL, 0);
     }
-    ok(ret, "CryptAcquireContext failed: 0x%x\n", GetLastError());
+    ok(ret, "CryptAcquireContext failed: 0x%lx\n", GetLastError());
 
     if (!ret) {
         skip("No context for tests\n");
@@ -1221,13 +1221,13 @@ static void test_signed_msg_update(void)
 
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING,
      CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     /* Detached CMSG_SIGNED allows non-final updates. */
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     /* Detached CMSG_SIGNED also allows non-final updates with no data. */
     ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     /* The final update requires a private key in the hCryptProv, in order to
      * generate the signature.
      */
@@ -1237,62 +1237,62 @@ static void test_signed_msg_update(void)
        (GetLastError() == NTE_BAD_KEYSET ||
         GetLastError() == NTE_NO_KEY ||
         broken(GetLastError() == ERROR_SUCCESS)), /* Some Win9x */
-     "Expected NTE_BAD_KEYSET or NTE_NO_KEY, got %x\n", GetLastError());
+     "Expected NTE_BAD_KEYSET or NTE_NO_KEY, got %lx\n", GetLastError());
     ret = CryptImportKey(signer.hCryptProv, privKey, sizeof(privKey),
      0, 0, &key);
-    ok(ret, "CryptImportKey failed: %08x\n", GetLastError());
+    ok(ret, "CryptImportKey failed: %08lx\n", GetLastError());
     /* The final update should be able to succeed now that a key exists, but
      * the previous (invalid) final update prevents it.
      */
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
     ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-     "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+     "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING,
      CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     /* Detached CMSG_SIGNED allows non-final updates. */
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     /* Detached CMSG_SIGNED also allows non-final updates with no data. */
     ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     /* Now that the private key exists, the final update can succeed (even
      * with no data.)
      */
     ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     /* But no updates are allowed after the final update. */
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
     ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-     "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+     "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
     ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-     "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+     "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
      NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     /* Non-detached messages don't allow non-final updates.. */
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
     ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-     "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+     "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError());
     /* but they do allow final ones. */
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     CryptMsgClose(msg);
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
      NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     /* They also allow final updates with no data. */
     ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     CryptDestroyKey(key);
@@ -1650,7 +1650,7 @@ static void test_signed_msg_encoding(void)
         ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL,
                                     PROV_RSA_FULL, 0);
     }
-    ok(ret, "CryptAcquireContext failed: 0x%x\n", GetLastError());
+    ok(ret, "CryptAcquireContext failed: 0x%lx\n", GetLastError());
 
     if (!ret) {
         skip("No context for tests\n");
@@ -1659,11 +1659,11 @@ static void test_signed_msg_encoding(void)
 
     ret = CryptImportKey(signer.hCryptProv, privKey, sizeof(privKey),
      0, 0, &key);
-    ok(ret, "CryptImportKey failed: %08x\n", GetLastError());
+    ok(ret, "CryptImportKey failed: %08lx\n", GetLastError());
 
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING,
      CMSG_DETACHED_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
 
     check_param("detached signed empty bare content", msg,
      CMSG_BARE_CONTENT_PARAM, signedEmptyBareContent,
@@ -1671,7 +1671,7 @@ static void test_signed_msg_encoding(void)
     check_param("detached signed empty content", msg, CMSG_CONTENT_PARAM,
      signedEmptyContent, sizeof(signedEmptyContent));
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     check_param("detached signed hash", msg, CMSG_COMPUTED_HASH_PARAM,
      signedHash, sizeof(signedHash));
     check_param("detached signed bare content", msg, CMSG_BARE_CONTENT_PARAM,
@@ -1682,7 +1682,7 @@ static void test_signed_msg_encoding(void)
     ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, NULL, &size);
     ok(!ret && (GetLastError() == CRYPT_E_INVALID_INDEX ||
      broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x */)),
-     "Expected CRYPT_E_INVALID_INDEX, got %x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_INDEX, got %lx\n", GetLastError());
     check_param("detached signed encoded signer", msg, CMSG_ENCODED_SIGNER,
      signedEncodedSigner, sizeof(signedEncodedSigner));
 
@@ -1695,7 +1695,7 @@ static void test_signed_msg_encoding(void)
     U(signer.SignerId).KeyId.pbData = serialNum;
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
      NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     check_param("signed key id empty content", msg, CMSG_CONTENT_PARAM,
      signedKeyIdEmptyContent, sizeof(signedKeyIdEmptyContent));
     CryptMsgClose(msg);
@@ -1707,14 +1707,14 @@ static void test_signed_msg_encoding(void)
     signer.SignerId.dwIdChoice = 0;
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
      NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
 
     check_param("signed empty bare content", msg, CMSG_BARE_CONTENT_PARAM,
      signedEmptyBareContent, sizeof(signedEmptyBareContent));
     check_param("signed empty content", msg, CMSG_CONTENT_PARAM,
      signedEmptyContent, sizeof(signedEmptyContent));
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     check_param("signed bare content", msg, CMSG_BARE_CONTENT_PARAM,
      signedBareContent, sizeof(signedBareContent));
     check_param("signed content", msg, CMSG_CONTENT_PARAM,
@@ -1726,7 +1726,7 @@ static void test_signed_msg_encoding(void)
     signer.rgAuthAttr = &attr;
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
      NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
 
     CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
     check_param("signed with auth attrs bare content", msg,
@@ -1740,13 +1740,13 @@ static void test_signed_msg_encoding(void)
     signInfo.cCertEncoded = 1;
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
      NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
 
     check_param("signed with cert empty bare content", msg,
      CMSG_BARE_CONTENT_PARAM, signedWithCertEmptyBareContent,
      sizeof(signedWithCertEmptyBareContent));
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     check_param("signed with cert bare content", msg, CMSG_BARE_CONTENT_PARAM,
      signedWithCertBareContent, sizeof(signedWithCertBareContent));
 
@@ -1757,13 +1757,13 @@ static void test_signed_msg_encoding(void)
     signInfo.cCrlEncoded = 1;
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
      NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
 
     check_param("signed with crl empty bare content", msg,
      CMSG_BARE_CONTENT_PARAM, signedWithCrlEmptyBareContent,
      sizeof(signedWithCrlEmptyBareContent));
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     check_param("signed with crl bare content", msg, CMSG_BARE_CONTENT_PARAM,
      signedWithCrlBareContent, sizeof(signedWithCrlBareContent));
 
@@ -1772,13 +1772,13 @@ static void test_signed_msg_encoding(void)
     signInfo.cCertEncoded = 1;
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
      NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
 
     check_param("signed with cert and crl empty bare content", msg,
      CMSG_BARE_CONTENT_PARAM, signedWithCertAndCrlEmptyBareContent,
      sizeof(signedWithCertAndCrlEmptyBareContent));
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     check_param("signed with cert and crl bare content", msg,
      CMSG_BARE_CONTENT_PARAM, signedWithCertAndCrlBareContent,
      sizeof(signedWithCertAndCrlBareContent));
@@ -1791,7 +1791,7 @@ static void test_signed_msg_encoding(void)
     encodedCert.pbData = v1CertWithPubKey;
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
      NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     check_param("signedWithCertWithPubKeyBareContent", msg,
      CMSG_BARE_CONTENT_PARAM, signedWithCertWithPubKeyBareContent,
      sizeof(signedWithCertWithPubKeyBareContent));
@@ -1801,12 +1801,12 @@ static void test_signed_msg_encoding(void)
     encodedCert.pbData = v1CertWithValidPubKey;
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
      NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     check_param("signedWithCertWithValidPubKeyEmptyContent", msg,
      CMSG_CONTENT_PARAM, signedWithCertWithValidPubKeyEmptyContent,
      sizeof(signedWithCertWithValidPubKeyEmptyContent));
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     check_param("signedWithCertWithValidPubKeyContent", msg,
      CMSG_CONTENT_PARAM, signedWithCertWithValidPubKeyContent,
      sizeof(signedWithCertWithValidPubKeyContent));
@@ -1829,12 +1829,12 @@ static void test_signed_msg_get_param(void)
 
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
      NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
 
     /* Content and bare content are always gettable */
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size);
-    ok(ret || broken(!ret /* Win9x */), "CryptMsgGetParam failed: %08x\n",
+    ok(ret || broken(!ret /* Win9x */), "CryptMsgGetParam failed: %08lx\n",
      GetLastError());
     if (!ret)
     {
@@ -1843,15 +1843,15 @@ static void test_signed_msg_get_param(void)
     }
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_BARE_CONTENT_PARAM, 0, NULL, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
     /* For "signed" messages, so is the version. */
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, NULL, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
     size = sizeof(value);
     ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, &value, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
-    ok(value == CMSG_SIGNED_DATA_V1, "Expected version 1, got %d\n", value);
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
+    ok(value == CMSG_SIGNED_DATA_V1, "Expected version 1, got %ld\n", value);
     /* But for this message, with no signers, the hash and signer aren't
      * available.
      */
@@ -1859,15 +1859,15 @@ static void test_signed_msg_get_param(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX,
-     "Expected CRYPT_E_INVALID_INDEX, got %x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_INDEX, got %lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX,
-     "Expected CRYPT_E_INVALID_INDEX, got %x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_INDEX, got %lx\n", GetLastError());
     /* As usual, the type isn't available. */
     ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError());
 
     CryptMsgClose(msg);
 
@@ -1886,7 +1886,7 @@ static void test_signed_msg_get_param(void)
         ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL,
                                     PROV_RSA_FULL, 0);
     }
-    ok(ret, "CryptAcquireContext failed: 0x%x\n", GetLastError());
+    ok(ret, "CryptAcquireContext failed: 0x%lx\n", GetLastError());
 
     if (!ret) {
         skip("No context for tests\n");
@@ -1895,29 +1895,29 @@ static void test_signed_msg_get_param(void)
 
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo,
      NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
 
     /* This message, with one signer, has the hash and signer for index 0
      * available, but not for other indexes.
      */
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 0, NULL, &size);
-    ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError());
     ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 0, NULL, &size);
-    ok(ret, "CryptMsgGetParam failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgGetParam failed: %lx\n", GetLastError());
     size = 0;
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 1, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX,
-     "Expected CRYPT_E_INVALID_INDEX, got %x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_INDEX, got %lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX,
-     "Expected CRYPT_E_INVALID_INDEX, got %x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_INDEX, got %lx\n", GetLastError());
     /* As usual, the type isn't available. */
     ret = CryptMsgGetParam(msg, CMSG_TYPE_PARAM, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError());
 
     CryptMsgClose(msg);
 
@@ -1936,35 +1936,35 @@ static void test_signed_msg_get_param(void)
     if (!ret && GetLastError() == NTE_EXISTS)
         ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL,
          PROV_RSA_FULL, 0);
-    ok(ret, "CryptAcquireContextA failed: %x\n", GetLastError());
+    ok(ret, "CryptAcquireContextA failed: %lx\n", GetLastError());
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING,
      CMSG_CRYPT_RELEASE_CONTEXT_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     /* still results in the version being 1 when the issuer and serial number
      * are used and no additional CMS fields are used.
      */
     size = sizeof(value);
     ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, &value, &size);
     ok(ret || broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE),
-     "CryptMsgGetParam failed: %08x\n", GetLastError());
+     "CryptMsgGetParam failed: %08lx\n", GetLastError());
     if (ret)
-        ok(value == CMSG_SIGNED_DATA_V1, "expected version 1, got %d\n", value);
+        ok(value == CMSG_SIGNED_DATA_V1, "expected version 1, got %ld\n", value);
     /* Apparently the encoded signer can be retrieved.. */
     ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 0, NULL, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
     /* but the signer info, CMS signer info, and cert ID can't be. */
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+     "expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+     "expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_SIGNER_CERT_ID_PARAM, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+     "expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     /* Using the KeyId field of the SignerId results in the version becoming
@@ -1978,31 +1978,31 @@ static void test_signed_msg_get_param(void)
     if (!ret && GetLastError() == NTE_EXISTS)
         ret = CryptAcquireContextA(&signer.hCryptProv, cspNameA, NULL,
          PROV_RSA_FULL, 0);
-    ok(ret, "CryptAcquireContextA failed: %x\n", GetLastError());
+    ok(ret, "CryptAcquireContextA failed: %lx\n", GetLastError());
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING,
      CMSG_CRYPT_RELEASE_CONTEXT_FLAG, CMSG_SIGNED, &signInfo, NULL, NULL);
-    ok(msg != NULL, "CryptMsgOpenToEncode failed: %x\n", GetLastError());
+    ok(msg != NULL, "CryptMsgOpenToEncode failed: %lx\n", GetLastError());
     size = sizeof(value);
     ret = CryptMsgGetParam(msg, CMSG_VERSION_PARAM, 0, &value, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
     if (ret)
-        ok(value == CMSG_SIGNED_DATA_V3, "expected version 3, got %d\n", value);
+        ok(value == CMSG_SIGNED_DATA_V3, "expected version 3, got %ld\n", value);
     /* Even for a CMS message, the signer can be retrieved.. */
     ret = CryptMsgGetParam(msg, CMSG_ENCODED_SIGNER, 0, NULL, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
     /* but the signer info, CMS signer info, and cert ID can't be. */
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+     "expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+     "expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_SIGNER_CERT_ID_PARAM, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+     "expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     CryptReleaseContext(signer.hCryptProv, 0);
@@ -2031,7 +2031,7 @@ static void test_enveloped_msg_open(void)
     msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
      &envelopedInfo, NULL, NULL);
     ok(!msg && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
 
     envelopedInfo.cbSize = sizeof(envelopedInfo);
     SetLastError(0xdeadbeef);
@@ -2040,7 +2040,7 @@ static void test_enveloped_msg_open(void)
     ok(!msg &&
      (GetLastError() == CRYPT_E_UNKNOWN_ALGO ||
       GetLastError() == E_INVALIDARG), /* Win9x */
-     "expected CRYPT_E_UNKNOWN_ALGO or E_INVALIDARG, got %08x\n", GetLastError());
+     "expected CRYPT_E_UNKNOWN_ALGO or E_INVALIDARG, got %08lx\n", GetLastError());
 
     envelopedInfo.ContentEncryptionAlgorithm.pszObjId = oid_rsa_rc4;
     SetLastError(0xdeadbeef);
@@ -2048,7 +2048,7 @@ static void test_enveloped_msg_open(void)
      &envelopedInfo, NULL, NULL);
     ok(msg != NULL ||
      broken(!msg), /* Win9x */
-     "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
+     "CryptMsgOpenToEncode failed: %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     envelopedInfo.cRecipients = 1;
@@ -2058,7 +2058,7 @@ static void test_enveloped_msg_open(void)
         msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
          &envelopedInfo, NULL, NULL);
         ok(!msg && GetLastError() == E_INVALIDARG,
-         "expected E_INVALIDARG, got %08x\n", GetLastError());
+         "expected E_INVALIDARG, got %08lx\n", GetLastError());
     }
 
     context = CertCreateCertificateContext(X509_ASN_ENCODING,
@@ -2069,16 +2069,16 @@ static void test_enveloped_msg_open(void)
         SetLastError(0xdeadbeef);
         msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
          &envelopedInfo, NULL, NULL);
-        ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
+        ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError());
         CryptMsgClose(msg);
         SetLastError(0xdeadbeef);
         ret = CryptAcquireContextA(&envelopedInfo.hCryptProv, NULL, NULL,
          PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
-        ok(ret, "CryptAcquireContextA failed: %08x\n", GetLastError());
+        ok(ret, "CryptAcquireContextA failed: %08lx\n", GetLastError());
         SetLastError(0xdeadbeef);
         msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED,
          &envelopedInfo, NULL, NULL);
-        ok(msg != NULL, "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
+        ok(msg != NULL, "CryptMsgOpenToEncode failed: %08lx\n", GetLastError());
         CryptMsgClose(msg);
         CryptReleaseContext(envelopedInfo.hCryptProv, 0);
         CertFreeCertificateContext(context);
@@ -2100,20 +2100,20 @@ static void test_enveloped_msg_update(void)
      &envelopedInfo, NULL, NULL);
     ok(msg != NULL ||
      broken(!msg), /* Win9x */
-     "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
+     "CryptMsgOpenToEncode failed: %08lx\n", GetLastError());
     if (msg)
     {
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
         ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-         "expected CRYPT_E_MSG_ERROR, got %08x\n", GetLastError());
+         "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-        ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+        ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
         ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-         "expected CRYPT_E_MSG_ERROR, got %08x\n", GetLastError());
+         "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError());
         CryptMsgClose(msg);
     }
     SetLastError(0xdeadbeef);
@@ -2121,22 +2121,22 @@ static void test_enveloped_msg_update(void)
      &envelopedInfo, NULL, NULL);
     ok(msg != NULL ||
      broken(!msg), /* Win9x */
-     "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
+     "CryptMsgOpenToEncode failed: %08lx\n", GetLastError());
     if (msg)
     {
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
         ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-         "expected CRYPT_E_MSG_ERROR, got %08x\n", GetLastError());
+         "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
         ok(ret ||
          broken(!ret && GetLastError() == NTE_PERM), /* some NT4 */
-         "CryptMsgUpdate failed: %08x\n", GetLastError());
+         "CryptMsgUpdate failed: %08lx\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
         ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-         "expected CRYPT_E_MSG_ERROR, got %08x\n", GetLastError());
+         "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError());
         CryptMsgClose(msg);
     }
     SetLastError(0xdeadbeef);
@@ -2144,16 +2144,16 @@ static void test_enveloped_msg_update(void)
      CMSG_ENVELOPED, &envelopedInfo, NULL, NULL);
     ok(msg != NULL ||
      broken(!msg), /* Win9x */
-     "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
+     "CryptMsgOpenToEncode failed: %08lx\n", GetLastError());
     if (msg)
     {
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "expected E_INVALIDARG, got %08x\n", GetLastError());
+         "expected E_INVALIDARG, got %08lx\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-        ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+        ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
         CryptMsgClose(msg);
     }
     SetLastError(0xdeadbeef);
@@ -2161,18 +2161,18 @@ static void test_enveloped_msg_update(void)
      CMSG_ENVELOPED, &envelopedInfo, NULL, NULL);
     ok(msg != NULL ||
      broken(!msg), /* Win9x */
-     "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
+     "CryptMsgOpenToEncode failed: %08lx\n", GetLastError());
     if (msg)
     {
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "expected E_INVALIDARG, got %08x\n", GetLastError());
+         "expected E_INVALIDARG, got %08lx\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
         ok(ret ||
          broken(!ret && GetLastError() == NTE_PERM), /* some NT4 */
-         "CryptMsgUpdate failed: %08x\n", GetLastError());
+         "CryptMsgUpdate failed: %08lx\n", GetLastError());
         CryptMsgClose(msg);
     }
     SetLastError(0xdeadbeef);
@@ -2180,15 +2180,15 @@ static void test_enveloped_msg_update(void)
      &envelopedInfo, NULL, &streamInfo);
     ok(msg != NULL ||
      broken(!msg), /* Win9x */
-     "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
+     "CryptMsgOpenToEncode failed: %08lx\n", GetLastError());
     if (msg)
     {
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
-        ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+        ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-        ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+        ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
         CryptMsgClose(msg);
     }
     SetLastError(0xdeadbeef);
@@ -2196,17 +2196,17 @@ static void test_enveloped_msg_update(void)
      &envelopedInfo, NULL, &streamInfo);
     ok(msg != NULL ||
      broken(!msg), /* Win9x */
-     "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
+     "CryptMsgOpenToEncode failed: %08lx\n", GetLastError());
     if (msg)
     {
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), FALSE);
-        ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+        ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
         SetLastError(0xdeadbeef);
         ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
         ok(ret ||
          broken(!ret && GetLastError() == NTE_PERM), /* some NT4 */
-         "CryptMsgUpdate failed: %08x\n", GetLastError());
+         "CryptMsgUpdate failed: %08lx\n", GetLastError());
         CryptMsgClose(msg);
     }
 }
@@ -2232,7 +2232,7 @@ static void test_enveloped_msg_encoding(void)
      &envelopedInfo, NULL, NULL);
     ok(msg != NULL ||
      broken(!msg), /* Win9x */
-     "CryptMsgOpenToEncode failed: %08x\n", GetLastError());
+     "CryptMsgOpenToEncode failed: %08lx\n", GetLastError());
     if (msg)
     {
         check_param("enveloped empty bare content", msg,
@@ -2291,12 +2291,12 @@ static void test_decode_msg_update(void)
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
     /* Update with a full message in a final update */
     ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     /* Can't update after a final update */
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), TRUE);
     ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-     "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+     "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
@@ -2305,10 +2305,10 @@ static void test_decode_msg_update(void)
     ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent),
      FALSE);
     ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-     "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+     "Expected CRYPT_E_MSG_ERROR, got %lx\n", GetLastError());
     /* A subsequent final update succeeds */
     ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     if (!old_crypt32)
@@ -2322,7 +2322,7 @@ static void test_decode_msg_update(void)
         todo_wine
         ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION ||
          GetLastError() == STATUS_ILLEGAL_INSTRUCTION /* WinME */),
-         "Expected STATUS_ACCESS_VIOLATION or STATUS_ILLEGAL_INSTRUCTION, got %x\n",
+         "Expected STATUS_ACCESS_VIOLATION or STATUS_ILLEGAL_INSTRUCTION, got %lx\n",
          GetLastError());
         /* Changing the callback pointer after the fact yields the same error (so
          * the message must copy the stream info, not just store a pointer to it)
@@ -2334,7 +2334,7 @@ static void test_decode_msg_update(void)
         todo_wine
         ok(!ret && (GetLastError() == STATUS_ACCESS_VIOLATION ||
          GetLastError() == STATUS_ILLEGAL_INSTRUCTION /* WinME */),
-         "Expected STATUS_ACCESS_VIOLATION or STATUS_ILLEGAL_INSTRUCTION, got %x\n",
+         "Expected STATUS_ACCESS_VIOLATION or STATUS_ILLEGAL_INSTRUCTION, got %lx\n",
          GetLastError());
         CryptMsgClose(msg);
     }
@@ -2342,13 +2342,13 @@ static void test_decode_msg_update(void)
     /* Empty non-final updates are allowed when streaming.. */
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo);
     ret = CryptMsgUpdate(msg, NULL, 0, FALSE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     /* but final updates aren't when not enough data has been received. */
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
     todo_wine
     ok(!ret && GetLastError() == CRYPT_E_STREAM_INSUFFICIENT_DATA,
-     "Expected CRYPT_E_STREAM_INSUFFICIENT_DATA, got %x\n", GetLastError());
+     "Expected CRYPT_E_STREAM_INSUFFICIENT_DATA, got %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     /* Updating the message byte by byte is legal */
@@ -2357,9 +2357,9 @@ static void test_decode_msg_update(void)
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo);
     for (i = 0, ret = TRUE; ret && i < sizeof(dataEmptyContent); i++)
         ret = CryptMsgUpdate(msg, &dataEmptyContent[i], 1, FALSE);
-    ok(ret, "CryptMsgUpdate failed on byte %d: %x\n", i, GetLastError());
+    ok(ret, "CryptMsgUpdate failed on byte %ld: %lx\n", i, GetLastError());
     ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-    ok(ret, "CryptMsgUpdate failed on byte %d: %x\n", i, GetLastError());
+    ok(ret, "CryptMsgUpdate failed on byte %ld: %lx\n", i, GetLastError());
     CryptMsgClose(msg);
     todo_wine
     check_updates("byte-by-byte empty content", &a4, &accum);
@@ -2371,7 +2371,7 @@ static void test_decode_msg_update(void)
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
      GetLastError() == OSS_PDU_MISMATCH /* Win9x */),
-     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %x\n",
+     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %lx\n",
      GetLastError());
     CryptMsgClose(msg);
     /* and as the final update in streaming mode.. */
@@ -2381,7 +2381,7 @@ static void test_decode_msg_update(void)
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
      GetLastError() == OSS_PDU_MISMATCH /* Win9x */),
-     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %x\n",
+     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %lx\n",
      GetLastError());
     CryptMsgClose(msg);
     /* and even as a non-final update in streaming mode. */
@@ -2392,7 +2392,7 @@ static void test_decode_msg_update(void)
     todo_wine
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
      GetLastError() == OSS_PDU_MISMATCH /* Win9x */),
-     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %x\n",
+     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %lx\n",
      GetLastError());
     CryptMsgClose(msg);
 
@@ -2400,7 +2400,7 @@ static void test_decode_msg_update(void)
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
     ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent),
      TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
     /* but decoding it as an explicitly typed message fails. */
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, 0, NULL,
@@ -2410,7 +2410,7 @@ static void test_decode_msg_update(void)
      TRUE);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
      GetLastError() == OSS_PDU_MISMATCH /* Win9x */),
-     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %x\n",
+     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %lx\n",
      GetLastError());
     CryptMsgClose(msg);
     /* On the other hand, decoding the bare content of an empty message fails
@@ -2422,7 +2422,7 @@ static void test_decode_msg_update(void)
      sizeof(dataEmptyBareContent), TRUE);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
      GetLastError() == OSS_PDU_MISMATCH /* Win9x */),
-     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %x\n",
+     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %lx\n",
      GetLastError());
     CryptMsgClose(msg);
     /* but succeeds with explicit type. */
@@ -2430,7 +2430,7 @@ static void test_decode_msg_update(void)
      NULL);
     ret = CryptMsgUpdate(msg, dataEmptyBareContent,
      sizeof(dataEmptyBareContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     /* Decoding valid content with an unsupported OID fails */
@@ -2438,7 +2438,7 @@ static void test_decode_msg_update(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, bogusOIDContent, sizeof(bogusOIDContent), TRUE);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     /* Similarly, opening an empty hash with unspecified type succeeds.. */
@@ -2446,7 +2446,7 @@ static void test_decode_msg_update(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, hashEmptyContent, sizeof(hashEmptyContent), TRUE);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "CryptMsgUpdate failed: %08x\n", GetLastError());
+     "CryptMsgUpdate failed: %08lx\n", GetLastError());
     CryptMsgClose(msg);
     /* while with specified type it fails. */
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL,
@@ -2456,7 +2456,7 @@ static void test_decode_msg_update(void)
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
      GetLastError() == OSS_PDU_MISMATCH /* some Win9x */ ||
      GetLastError() == OSS_DATA_ERROR /* some Win9x */),
-     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %x\n",
+     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %lx\n",
      GetLastError());
     CryptMsgClose(msg);
     /* On the other hand, decoding the bare content of an empty hash message
@@ -2469,7 +2469,7 @@ static void test_decode_msg_update(void)
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
      GetLastError() == OSS_PDU_MISMATCH /* some Win9x */ ||
      GetLastError() == OSS_DATA_ERROR /* some Win9x */),
-     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %x\n",
+     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %lx\n",
      GetLastError());
     CryptMsgClose(msg);
     /* but succeeds with explicit type. */
@@ -2478,7 +2478,7 @@ static void test_decode_msg_update(void)
     ret = CryptMsgUpdate(msg, hashEmptyBareContent,
      sizeof(hashEmptyBareContent), TRUE);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* win9x */),
-     "CryptMsgUpdate failed: %x\n", GetLastError());
+     "CryptMsgUpdate failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     /* And again, opening a (non-empty) hash message with unspecified type
@@ -2487,7 +2487,7 @@ static void test_decode_msg_update(void)
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, hashContent, sizeof(hashContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     CryptMsgClose(msg);
     /* while with specified type it fails.. */
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL,
@@ -2497,7 +2497,7 @@ static void test_decode_msg_update(void)
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
      GetLastError() == OSS_PDU_MISMATCH /* some Win9x */ ||
      GetLastError() == OSS_DATA_ERROR /* some Win9x */),
-     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %x\n",
+     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %lx\n",
      GetLastError());
     CryptMsgClose(msg);
     /* and decoding the bare content of a non-empty hash message fails with
@@ -2509,14 +2509,14 @@ static void test_decode_msg_update(void)
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
      GetLastError() == OSS_PDU_MISMATCH /* some Win9x */ ||
      GetLastError() == OSS_DATA_ERROR /* some Win9x */),
-     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %x\n",
+     "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH or OSS_DATA_ERROR, got %lx\n",
      GetLastError());
     CryptMsgClose(msg);
     /* but succeeds with explicit type. */
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, 0, NULL,
      NULL);
     ret = CryptMsgUpdate(msg, hashBareContent, sizeof(hashBareContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %lx\n", GetLastError());
     CryptMsgClose(msg);
 
     /* Opening a (non-empty) hash message with unspecified type and a bogus
@@ -2525,12 +2525,12 @@ static void test_decode_msg_update(void)
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, bogusHashContent, sizeof(bogusHashContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
     ret = CryptMsgUpdate(msg, signedContent, sizeof(signedContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     CryptMsgClose(msg);
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
     SetLastError(0xdeadbeef);
@@ -2538,14 +2538,14 @@ static void test_decode_msg_update(void)
      sizeof(signedWithCertAndCrlBareContent), TRUE);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_BADTAG ||
      GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "Expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08x\n",
+     "Expected CRYPT_E_ASN1_BADTAG or OSS_DATA_ERROR, got %08lx\n",
      GetLastError());
     CryptMsgClose(msg);
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL,
      NULL);
     ret = CryptMsgUpdate(msg, signedWithCertAndCrlBareContent,
      sizeof(signedWithCertAndCrlBareContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, 0, 0,
@@ -2553,31 +2553,31 @@ static void test_decode_msg_update(void)
     /* The first update succeeds.. */
     ret = CryptMsgUpdate(msg, detachedSignedContent,
      sizeof(detachedSignedContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     /* as does a second (probably to update the detached portion).. */
     ret = CryptMsgUpdate(msg, detachedSignedContent,
      sizeof(detachedSignedContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     /* while a third fails. */
     ret = CryptMsgUpdate(msg, detachedSignedContent,
      sizeof(detachedSignedContent), TRUE);
     ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-     "expected CRYPT_E_MSG_ERROR, got %08x\n", GetLastError());
+     "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, 0, 0, NULL, &streamInfo);
     ret = CryptMsgUpdate(msg, detachedSignedContent, sizeof(detachedSignedContent), FALSE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     ret = CryptMsgUpdate(msg, detachedSignedContent, sizeof(detachedSignedContent), FALSE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
 
     ret = CryptMsgUpdate(msg, detachedSignedContent, sizeof(detachedSignedContent), TRUE);
     ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
-     "expected CRYPT_E_MSG_ERROR, got %08x\n", GetLastError());
+     "expected CRYPT_E_MSG_ERROR, got %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL,
@@ -2585,7 +2585,7 @@ static void test_decode_msg_update(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, envelopedEmptyBareContent,
      sizeof(envelopedEmptyBareContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL,
@@ -2596,7 +2596,7 @@ static void test_decode_msg_update(void)
     ok(!ret &&
      (GetLastError() == CRYPT_E_ASN1_BADTAG ||
       GetLastError() == OSS_DATA_ERROR), /* Win9x */
-     "expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
+     "expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
@@ -2606,14 +2606,14 @@ static void test_decode_msg_update(void)
     ok(!ret &&
      (GetLastError() == CRYPT_E_ASN1_BADTAG ||
       GetLastError() == OSS_DATA_ERROR), /* Win9x */
-     "expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
+     "expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, envelopedEmptyContent,
      sizeof(envelopedEmptyContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL,
@@ -2621,7 +2621,7 @@ static void test_decode_msg_update(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, envelopedBareContentWithoutData,
      sizeof(envelopedBareContentWithoutData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     CryptMsgClose(msg);
 }
 
@@ -2631,15 +2631,15 @@ static const BYTE hashParam[] = { 0x08,0xd6,0xc0,0x5a,0x21,0x51,0x2a,0x79,0xa1,
 static void compare_signer_info(const CMSG_SIGNER_INFO *got,
  const CMSG_SIGNER_INFO *expected)
 {
-    ok(got->dwVersion == expected->dwVersion, "Expected version %d, got %d\n",
+    ok(got->dwVersion == expected->dwVersion, "Expected version %ld, got %ld\n",
      expected->dwVersion, got->dwVersion);
     ok(got->Issuer.cbData == expected->Issuer.cbData,
-     "Expected issuer size %d, got %d\n", expected->Issuer.cbData,
+     "Expected issuer size %ld, got %ld\n", expected->Issuer.cbData,
      got->Issuer.cbData);
     ok(!memcmp(got->Issuer.pbData, expected->Issuer.pbData, got->Issuer.cbData),
      "Unexpected issuer\n");
     ok(got->SerialNumber.cbData == expected->SerialNumber.cbData,
-     "Expected serial number size %d, got %d\n", expected->SerialNumber.cbData,
+     "Expected serial number size %ld, got %ld\n", expected->SerialNumber.cbData,
      got->SerialNumber.cbData);
     ok(!memcmp(got->SerialNumber.pbData, expected->SerialNumber.pbData,
      got->SerialNumber.cbData), "Unexpected serial number\n");
@@ -2649,10 +2649,10 @@ static void compare_signer_info(const CMSG_SIGNER_INFO *got,
 static void compare_cms_signer_info(const CMSG_CMS_SIGNER_INFO *got,
  const CMSG_CMS_SIGNER_INFO *expected)
 {
-    ok(got->dwVersion == expected->dwVersion, "Expected version %d, got %d\n",
+    ok(got->dwVersion == expected->dwVersion, "Expected version %ld, got %ld\n",
      expected->dwVersion, got->dwVersion);
     ok(got->SignerId.dwIdChoice == expected->SignerId.dwIdChoice,
-     "Expected id choice %d, got %d\n", expected->SignerId.dwIdChoice,
+     "Expected id choice %ld, got %ld\n", expected->SignerId.dwIdChoice,
      got->SignerId.dwIdChoice);
     if (got->SignerId.dwIdChoice == expected->SignerId.dwIdChoice)
     {
@@ -2660,7 +2660,7 @@ static void compare_cms_signer_info(const CMSG_CMS_SIGNER_INFO *got,
         {
             ok(U(got->SignerId).IssuerSerialNumber.Issuer.cbData ==
              U(expected->SignerId).IssuerSerialNumber.Issuer.cbData,
-             "Expected issuer size %d, got %d\n",
+             "Expected issuer size %ld, got %ld\n",
              U(expected->SignerId).IssuerSerialNumber.Issuer.cbData,
              U(got->SignerId).IssuerSerialNumber.Issuer.cbData);
             ok(!memcmp(U(got->SignerId).IssuerSerialNumber.Issuer.pbData,
@@ -2669,7 +2669,7 @@ static void compare_cms_signer_info(const CMSG_CMS_SIGNER_INFO *got,
              "Unexpected issuer\n");
             ok(U(got->SignerId).IssuerSerialNumber.SerialNumber.cbData ==
              U(expected->SignerId).IssuerSerialNumber.SerialNumber.cbData,
-             "Expected serial number size %d, got %d\n",
+             "Expected serial number size %ld, got %ld\n",
              U(expected->SignerId).IssuerSerialNumber.SerialNumber.cbData,
              U(got->SignerId).IssuerSerialNumber.SerialNumber.cbData);
             ok(!memcmp(U(got->SignerId).IssuerSerialNumber.SerialNumber.pbData,
@@ -2680,7 +2680,7 @@ static void compare_cms_signer_info(const CMSG_CMS_SIGNER_INFO *got,
         else
         {
             ok(U(got->SignerId).KeyId.cbData == U(expected->SignerId).KeyId.cbData,
-             "expected key id size %d, got %d\n",
+             "expected key id size %ld, got %ld\n",
              U(expected->SignerId).KeyId.cbData, U(got->SignerId).KeyId.cbData);
             ok(!memcmp(U(expected->SignerId).KeyId.pbData,
              U(got->SignerId).KeyId.pbData, U(got->SignerId).KeyId.cbData),
@@ -2835,9 +2835,9 @@ static void test_decode_msg_get_param(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %lx\n", GetLastError());
     ret = CryptMsgUpdate(msg, dataContent, sizeof(dataContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     check_param("data content", msg, CMSG_CONTENT_PARAM, msgData,
      sizeof(msgData));
     CryptMsgClose(msg);
@@ -2855,7 +2855,7 @@ static void test_decode_msg_get_param(void)
     CryptMsgClose(msg);
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
     ret = CryptMsgUpdate(msg, hashContent, sizeof(hashContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     check_param("hash content", msg, CMSG_CONTENT_PARAM, msgData,
      sizeof(msgData));
     check_param("hash hash data", msg, CMSG_HASH_DATA_PARAM, hashParam,
@@ -2867,7 +2867,7 @@ static void test_decode_msg_get_param(void)
      */
     ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, NULL, &size);
     ok(ret || GetLastError() == OSS_DATA_ERROR /* Win9x */,
-     "CryptMsgGetParam failed: %08x\n", GetLastError());
+     "CryptMsgGetParam failed: %08lx\n", GetLastError());
     if (ret)
         buf = CryptMemAlloc(size);
     else
@@ -2875,8 +2875,8 @@ static void test_decode_msg_get_param(void)
     if (buf)
     {
         ret = CryptMsgGetParam(msg, CMSG_COMPUTED_HASH_PARAM, 1, buf, &size);
-        ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
-        ok(size == sizeof(hashParam), "Unexpected size %d\n", size);
+        ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
+        ok(size == sizeof(hashParam), "Unexpected size %ld\n", size);
         ok(!memcmp(buf, hashParam, size), "Unexpected value\n");
         CryptMemFree(buf);
     }
@@ -2889,7 +2889,7 @@ static void test_decode_msg_get_param(void)
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
     ret = CryptMsgUpdate(msg, signedContent, sizeof(signedContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     check_param("signed content", msg, CMSG_CONTENT_PARAM, msgData,
      sizeof(msgData));
     check_param("inner content", msg, CMSG_INNER_CONTENT_TYPE_PARAM,
@@ -2897,12 +2897,12 @@ static void test_decode_msg_get_param(void)
     size = sizeof(value);
     value = 2112;
     ret = CryptMsgGetParam(msg, CMSG_SIGNER_COUNT_PARAM, 0, &value, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
-    ok(value == 1, "Expected 1 signer, got %d\n", value);
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
+    ok(value == 1, "Expected 1 signer, got %ld\n", value);
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &size);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "CryptMsgGetParam failed: %08x\n", GetLastError());
+     "CryptMsgGetParam failed: %08lx\n", GetLastError());
     if (ret)
         buf = CryptMemAlloc(size);
     else
@@ -2920,7 +2920,7 @@ static void test_decode_msg_get_param(void)
         req_size = size;
         size += 10;
         CryptMsgGetParam(msg, CMSG_SIGNER_INFO_PARAM, 0, buf, &size);
-        ok(size == req_size, "size = %u, expected %u\n", size, req_size);
+        ok(size == req_size, "size = %lu, expected %lu\n", size, req_size);
         compare_signer_info((CMSG_SIGNER_INFO *)buf, &signer);
         CryptMemFree(buf);
     }
@@ -2928,7 +2928,7 @@ static void test_decode_msg_get_param(void)
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, NULL, &size);
     ok(ret || broken(GetLastError() == CRYPT_E_INVALID_MSG_TYPE /* Win9x */),
-     "CryptMsgGetParam failed: %08x\n", GetLastError());
+     "CryptMsgGetParam failed: %08lx\n", GetLastError());
     if (ret)
         buf = CryptMemAlloc(size);
     else
@@ -2953,27 +2953,27 @@ static void test_decode_msg_get_param(void)
     /* index is ignored when getting signer count */
     size = sizeof(value);
     ret = CryptMsgGetParam(msg, CMSG_SIGNER_COUNT_PARAM, 1, &value, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
-    ok(value == 1, "Expected 1 signer, got %d\n", value);
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
+    ok(value == 1, "Expected 1 signer, got %ld\n", value);
     ret = CryptMsgGetParam(msg, CMSG_CERT_COUNT_PARAM, 0, &value, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
-    ok(value == 0, "Expected 0 certs, got %d\n", value);
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
+    ok(value == 0, "Expected 0 certs, got %ld\n", value);
     ret = CryptMsgGetParam(msg, CMSG_CRL_COUNT_PARAM, 0, &value, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
-    ok(value == 0, "Expected 0 CRLs, got %d\n", value);
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
+    ok(value == 0, "Expected 0 CRLs, got %ld\n", value);
     CryptMsgClose(msg);
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL,
      NULL);
     ret = CryptMsgUpdate(msg, signedWithCertAndCrlBareContent,
      sizeof(signedWithCertAndCrlBareContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     ret = CryptMsgGetParam(msg, CMSG_CERT_COUNT_PARAM, 0, &value, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
-    ok(value == 1, "Expected 1 cert, got %d\n", value);
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
+    ok(value == 1, "Expected 1 cert, got %ld\n", value);
     check_param("cert", msg, CMSG_CERT_PARAM, cert, sizeof(cert));
     ret = CryptMsgGetParam(msg, CMSG_CRL_COUNT_PARAM, 0, &value, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
-    ok(value == 1, "Expected 1 CRL, got %d\n", value);
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
+    ok(value == 1, "Expected 1 CRL, got %ld\n", value);
     check_param("crl", msg, CMSG_CRL_PARAM, crl, sizeof(crl));
     check_param("signed with cert and CRL computed hash", msg,
      CMSG_COMPUTED_HASH_PARAM, signedWithCertAndCrlComputedHash,
@@ -2989,17 +2989,17 @@ static void test_decode_msg_get_param(void)
         win_skip("Subsequent tests crash on some Win9x\n");
         return;
     }
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     size = sizeof(value);
     ret = CryptMsgGetParam(msg, CMSG_SIGNER_COUNT_PARAM, 0, &value, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
-    ok(value == 1, "Expected 1 signer, got %d\n", value);
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
+    ok(value == 1, "Expected 1 signer, got %ld\n", value);
     /* Getting the regular (non-CMS) signer info from a CMS message is also
      * possible..
      */
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
     if (ret)
         buf = CryptMemAlloc(size);
     else
@@ -3026,7 +3026,7 @@ static void test_decode_msg_get_param(void)
     }
     size = 0;
     ret = CryptMsgGetParam(msg, CMSG_CMS_SIGNER_INFO_PARAM, 0, NULL, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
     if (ret)
         buf = CryptMemAlloc(size);
     else
@@ -3067,7 +3067,7 @@ static void test_decode_msg_get_param(void)
      sizeof(publicPrivateKeyPair), 0, 0, &key);
     ok(ret ||
      broken(!ret && GetLastError() == NTE_PERM), /* WinME and some NT4 */
-     "CryptImportKey failed: %08x\n", GetLastError());
+     "CryptImportKey failed: %08lx\n", GetLastError());
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
     CryptMsgUpdate(msg, envelopedMessage, sizeof(envelopedMessage), TRUE);
@@ -3078,12 +3078,12 @@ static void test_decode_msg_get_param(void)
         decryptPara.hCryptProv = hCryptProv;
         SetLastError(0xdeadbeef);
         ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara);
-        ok(ret, "CryptMsgControl failed: %08x\n", GetLastError());
+        ok(ret, "CryptMsgControl failed: %08lx\n", GetLastError());
         decryptPara.hCryptProv = 0;
         SetLastError(0xdeadbeef);
         ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara);
         ok(!ret && GetLastError() == CRYPT_E_ALREADY_DECRYPTED,
-         "expected CRYPT_E_ALREADY_DECRYPTED, got %08x\n", GetLastError());
+         "expected CRYPT_E_ALREADY_DECRYPTED, got %08lx\n", GetLastError());
         check_param("enveloped message", msg, CMSG_CONTENT_PARAM, msgData,
          sizeof(msgData));
     }
@@ -3103,7 +3103,7 @@ static void test_decode_msg_get_param(void)
         decryptPara.hCryptProv = hCryptProv;
         SetLastError(0xdeadbeef);
         ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara);
-        ok(ret, "CryptMsgControl failed: %08x\n", GetLastError());
+        ok(ret, "CryptMsgControl failed: %08lx\n", GetLastError());
         check_param("enveloped bare message", msg, CMSG_CONTENT_PARAM, msgData,
          sizeof(msgData));
     }
@@ -3125,12 +3125,12 @@ static void test_decode_msg_get_param(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_RECIPIENT_INFO_PARAM, 3, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX,
-     "expected CRYPT_E_INVALID_INDEX, got %08x\n", GetLastError());
+     "expected CRYPT_E_INVALID_INDEX, got %08lx\n", GetLastError());
     size = 0;
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetParam(msg, CMSG_RECIPIENT_INFO_PARAM, 2, NULL, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
-    ok(size >= 142, "unexpected size: %u\n", size);
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
+    ok(size >= 142, "unexpected size: %lu\n", size);
     if (ret)
         buf = CryptMemAlloc(size);
     else
@@ -3141,13 +3141,13 @@ static void test_decode_msg_get_param(void)
 
         SetLastError(0xdeadbeef);
         ret = CryptMsgGetParam(msg, CMSG_RECIPIENT_INFO_PARAM, 2, buf, &size);
-        ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
+        ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
         ok(certInfo->SerialNumber.cbData == sizeof(serialNumber),
-         "unexpected serial number size: %u\n", certInfo->SerialNumber.cbData);
+         "unexpected serial number size: %lu\n", certInfo->SerialNumber.cbData);
         ok(!memcmp(certInfo->SerialNumber.pbData, serialNumber,
          sizeof(serialNumber)), "unexpected serial number\n");
         ok(certInfo->Issuer.cbData == sizeof(issuer),
-         "unexpected issuer size: %u\n", certInfo->Issuer.cbData);
+         "unexpected issuer size: %lu\n", certInfo->Issuer.cbData);
         ok(!memcmp(certInfo->Issuer.pbData, issuer, sizeof(issuer)),
          "unexpected issuer\n");
         CryptMemFree(buf);
@@ -3196,17 +3196,17 @@ static void test_msg_control(void)
         SetLastError(0xdeadbeef);
         ret = CryptMsgControl(msg, 0, i, NULL);
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     }
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     /* or after an update. */
     for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++)
     {
         SetLastError(0xdeadbeef);
         ret = CryptMsgControl(msg, 0, i, NULL);
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     }
     CryptMsgClose(msg);
 
@@ -3221,17 +3221,17 @@ static void test_msg_control(void)
         SetLastError(0xdeadbeef);
         ret = CryptMsgControl(msg, 0, i, NULL);
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     }
     ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     /* or after an update. */
     for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++)
     {
         SetLastError(0xdeadbeef);
         ret = CryptMsgControl(msg, 0, i, NULL);
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     }
     CryptMsgClose(msg);
 
@@ -3245,17 +3245,17 @@ static void test_msg_control(void)
         SetLastError(0xdeadbeef);
         ret = CryptMsgControl(msg, 0, i, NULL);
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     }
     ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     /* or after an update. */
     for (i = 1; !old_crypt32 && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++)
     {
         SetLastError(0xdeadbeef);
         ret = CryptMsgControl(msg, 0, i, NULL);
         ok(!ret && GetLastError() == E_INVALIDARG,
-         "Expected E_INVALIDARG, got %08x\n", GetLastError());
+         "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     }
     CryptMsgClose(msg);
 
@@ -3265,23 +3265,23 @@ static void test_msg_control(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgControl(msg, 0, 0, NULL);
     ok(!ret && GetLastError() == CRYPT_E_CONTROL_TYPE,
-     "Expected CRYPT_E_CONTROL_TYPE, got %08x\n", GetLastError());
+     "Expected CRYPT_E_CONTROL_TYPE, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptMsgControl(msg, 1, 0, NULL);
     ok(!ret && GetLastError() == CRYPT_E_CONTROL_TYPE,
-     "Expected CRYPT_E_CONTROL_TYPE, got %08x\n", GetLastError());
+     "Expected CRYPT_E_CONTROL_TYPE, got %08lx\n", GetLastError());
     /* Can't verify the hash of an indeterminate-type message */
     SetLastError(0xdeadbeef);
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     /* Crashes
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, NULL);
      */
     /* Can't decrypt an indeterminate-type message */
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     if (!old_crypt32)
@@ -3294,14 +3294,14 @@ static void test_msg_control(void)
         ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
         todo_wine
         ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
-         "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError());
+         "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError());
         /* Crashes
         ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, NULL);
          */
         /* Can't verify the signature of a hash message */
         ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo);
         ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-         "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+         "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
         CryptMsgUpdate(msg, hashEmptyBareContent, sizeof(hashEmptyBareContent),
          TRUE);
         /* Oddly enough, this fails, crashes on some Win9x */
@@ -3313,12 +3313,12 @@ static void test_msg_control(void)
      NULL);
     CryptMsgUpdate(msg, hashBareContent, sizeof(hashBareContent), TRUE);
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
-    ok(ret, "CryptMsgControl failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgControl failed: %08lx\n", GetLastError());
     /* Can't decrypt an indeterminate-type message */
     SetLastError(0xdeadbeef);
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, CMSG_DETACHED_FLAG, 0, 0,
@@ -3327,17 +3327,17 @@ static void test_msg_control(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     ret = CryptMsgUpdate(msg, detachedHashContent, sizeof(detachedHashContent),
      TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     /* Still can't verify the hash of a detached message with the content
      * of the detached hash given..
      */
     SetLastError(0xdeadbeef);
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
     ok(!ret && GetLastError() == CRYPT_E_HASH_VALUE,
-     "Expected CRYPT_E_HASH_VALUE, got %08x\n", GetLastError());
+     "Expected CRYPT_E_HASH_VALUE, got %08lx\n", GetLastError());
     /* and giving the content of the message after attempting to verify the
      * hash fails.
      */
@@ -3349,7 +3349,7 @@ static void test_msg_control(void)
         GetLastError() == NTE_BAD_ALGID ||    /* Win9x */
         GetLastError() == CRYPT_E_MSG_ERROR), /* Vista */
      "Expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, "
-     "got %08x\n", GetLastError());
+     "got %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     /* Finally, verifying the hash of a detached message in the correct order:
@@ -3362,12 +3362,12 @@ static void test_msg_control(void)
      NULL, NULL);
     ret = CryptMsgUpdate(msg, detachedHashContent, sizeof(detachedHashContent),
      TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
-    ok(ret, "CryptMsgControl failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgControl failed: %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL,
@@ -3376,12 +3376,12 @@ static void test_msg_control(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_HASH, NULL);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     /* Can't decrypt a signed message */
     SetLastError(0xdeadbeef);
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     /* Crash
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, NULL);
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo);
@@ -3395,7 +3395,7 @@ static void test_msg_control(void)
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo);
     ok(!ret && (GetLastError() == CRYPT_E_SIGNER_NOT_FOUND ||
      GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "Expected CRYPT_E_SIGNER_NOT_FOUND or OSS_DATA_ERROR, got %08x\n",
+     "Expected CRYPT_E_SIGNER_NOT_FOUND or OSS_DATA_ERROR, got %08lx\n",
      GetLastError());
     /* The cert info is expected to have an issuer, serial number, and public
      * key info set.
@@ -3408,7 +3408,7 @@ static void test_msg_control(void)
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo);
     ok(!ret && (GetLastError() == CRYPT_E_ASN1_EOD ||
      GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "Expected CRYPT_E_ASN1_EOD or OSS_DATA_ERROR, got %08x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_EOD or OSS_DATA_ERROR, got %08lx\n", GetLastError());
     CryptMsgClose(msg);
     /* This cert has a public key, but it's not in a usable form */
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, 0, NULL,
@@ -3424,7 +3424,7 @@ static void test_msg_control(void)
         ok(!ret &&
          (GetLastError() == CRYPT_E_ASN1_EOD ||
           GetLastError() == TRUST_E_NOSIGNATURE /* Vista */),
-         "Expected CRYPT_E_ASN1_EOD or TRUST_E_NOSIGNATURE, got %08x\n", GetLastError());
+         "Expected CRYPT_E_ASN1_EOD or TRUST_E_NOSIGNATURE, got %08lx\n", GetLastError());
         /* The public key is supposed to be in encoded form.. */
         certInfo.SubjectPublicKeyInfo.Algorithm.pszObjId = oid_rsa_rsa;
         certInfo.SubjectPublicKeyInfo.PublicKey.cbData = sizeof(aKey);
@@ -3434,7 +3434,7 @@ static void test_msg_control(void)
         ok(!ret &&
          (GetLastError() == CRYPT_E_ASN1_BADTAG ||
           GetLastError() == TRUST_E_NOSIGNATURE /* Vista */),
-         "Expected CRYPT_E_ASN1_BADTAG or TRUST_E_NOSIGNATURE, got %08x\n", GetLastError());
+         "Expected CRYPT_E_ASN1_BADTAG or TRUST_E_NOSIGNATURE, got %08lx\n", GetLastError());
         /* but not as a X509_PUBLIC_KEY_INFO.. */
         certInfo.SubjectPublicKeyInfo.Algorithm.pszObjId = NULL;
         certInfo.SubjectPublicKeyInfo.PublicKey.cbData = sizeof(encodedPubKey);
@@ -3444,7 +3444,7 @@ static void test_msg_control(void)
         ok(!ret &&
          (GetLastError() == CRYPT_E_ASN1_BADTAG ||
           GetLastError() == TRUST_E_NOSIGNATURE /* Vista */),
-         "Expected CRYPT_E_ASN1_BADTAG or TRUST_E_NOSIGNATURE, got %08x\n", GetLastError());
+         "Expected CRYPT_E_ASN1_BADTAG or TRUST_E_NOSIGNATURE, got %08lx\n", GetLastError());
         /* This decodes successfully, but it doesn't match any key in the message */
         certInfo.SubjectPublicKeyInfo.PublicKey.cbData = sizeof(mod_encoded);
         certInfo.SubjectPublicKeyInfo.PublicKey.pbData = mod_encoded;
@@ -3458,7 +3458,7 @@ static void test_msg_control(void)
         ok(!ret &&
          (GetLastError() == NTE_BAD_SIGNATURE ||
           GetLastError() == TRUST_E_NOSIGNATURE /* Vista */),
-         "Expected NTE_BAD_SIGNATURE or TRUST_E_NOSIGNATURE, got %08x\n", GetLastError());
+         "Expected NTE_BAD_SIGNATURE or TRUST_E_NOSIGNATURE, got %08lx\n", GetLastError());
     }
     CryptMsgClose(msg);
     /* A message with no data doesn't have a valid signature */
@@ -3476,7 +3476,7 @@ static void test_msg_control(void)
         ok(!ret &&
          (GetLastError() == NTE_BAD_SIGNATURE ||
           GetLastError() == TRUST_E_NOSIGNATURE /* Vista */),
-         "Expected NTE_BAD_SIGNATURE or TRUST_E_NOSIGNATURE, got %08x\n", GetLastError());
+         "Expected NTE_BAD_SIGNATURE or TRUST_E_NOSIGNATURE, got %08lx\n", GetLastError());
     }
     CryptMsgClose(msg);
     /* Finally, this succeeds */
@@ -3485,7 +3485,7 @@ static void test_msg_control(void)
      sizeof(signedWithCertWithValidPubKeyContent), TRUE);
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "CryptMsgControl failed: %08x\n", GetLastError());
+     "CryptMsgControl failed: %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     /* Test verifying signature of a detached signed message */
@@ -3493,13 +3493,13 @@ static void test_msg_control(void)
      NULL, NULL);
     ret = CryptMsgUpdate(msg, detachedSignedContent,
      sizeof(detachedSignedContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     /* Can't verify the sig without having updated the data */
     SetLastError(0xdeadbeef);
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo);
     ok(!ret && (GetLastError() == NTE_BAD_SIGNATURE ||
      GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "expected NTE_BAD_SIGNATURE or OSS_DATA_ERROR, got %08x\n",
+     "expected NTE_BAD_SIGNATURE or OSS_DATA_ERROR, got %08lx\n",
      GetLastError());
     /* Now that the signature's been checked, can't do the final update */
     SetLastError(0xdeadbeef);
@@ -3511,7 +3511,7 @@ static void test_msg_control(void)
       GetLastError() == CRYPT_E_MSG_ERROR)) || /* Vista */
       broken(ret), /* Win9x */
      "expected NTE_BAD_HASH_STATE or NTE_BAD_ALGID or CRYPT_E_MSG_ERROR, "
-     "got %08x\n", GetLastError());
+     "got %08lx\n", GetLastError());
     CryptMsgClose(msg);
     /* Updating with the detached portion of the message and the data of the
      * the message allows the sig to be verified.
@@ -3520,12 +3520,12 @@ static void test_msg_control(void)
      NULL, NULL);
     ret = CryptMsgUpdate(msg, detachedSignedContent,
      sizeof(detachedSignedContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     ret = CryptMsgUpdate(msg, msgData, sizeof(msgData), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_VERIFY_SIGNATURE, &certInfo);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "CryptMsgControl failed: %08x\n", GetLastError());
+     "CryptMsgControl failed: %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL,
@@ -3534,23 +3534,23 @@ static void test_msg_control(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
     decryptPara.cbSize = sizeof(decryptPara);
     if (!old_crypt32)
     {
         SetLastError(0xdeadbeef);
         ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara);
         ok(!ret && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-         "expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+         "expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     }
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, envelopedEmptyBareContent,
      sizeof(envelopedEmptyBareContent), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX,
-     "expected CRYPT_E_INVALID_INDEX, got %08x\n", GetLastError());
+     "expected CRYPT_E_INVALID_INDEX, got %08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, CMSG_ENVELOPED, 0, NULL,
@@ -3558,11 +3558,11 @@ static void test_msg_control(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgUpdate(msg, envelopedBareMessage,
      sizeof(envelopedBareMessage), TRUE);
-    ok(ret, "CryptMsgUpdate failed: %08x\n", GetLastError());
+    ok(ret, "CryptMsgUpdate failed: %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptMsgControl(msg, 0, CMSG_CTRL_DECRYPT, &decryptPara);
     ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
-     "expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
+     "expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError());
     CryptMsgClose(msg);
 }
 
@@ -3586,21 +3586,21 @@ static void test_msg_get_and_verify_signer(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, NULL);
     ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER,
-     "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08x\n", GetLastError());
+     "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError());
     /* The signer is cleared on error */
     signer = (PCCERT_CONTEXT)0xdeadbeef;
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, &signer, NULL);
     ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER,
-     "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08x\n", GetLastError());
+     "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError());
     ok(!signer, "expected signer to be NULL\n");
     /* The signer index is also cleared on error */
     signerIndex = 0xdeadbeef;
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, &signerIndex);
     ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER,
-     "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08x\n", GetLastError());
-    ok(!signerIndex, "expected 0, got %d\n", signerIndex);
+     "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError());
+    ok(!signerIndex, "expected 0, got %ld\n", signerIndex);
     /* An unsigned message (msgData isn't a signed message at all)
      * likewise has no signer.
      */
@@ -3608,7 +3608,7 @@ static void test_msg_get_and_verify_signer(void)
     SetLastError(0xdeadbeef);
     ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, NULL);
     ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER,
-     "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08x\n", GetLastError());
+     "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError());
     CryptMsgClose(msg);
 
     msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
@@ -3619,7 +3619,7 @@ static void test_msg_get_and_verify_signer(void)
         /* Crashes on most Win9x */
         ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, NULL);
         ok(!ret && GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER,
-         "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08x\n", GetLastError());
+         "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError());
     }
     CryptMsgClose(msg);
 
@@ -3629,19 +3629,19 @@ static void test_msg_get_and_verify_signer(void)
      sizeof(signedWithCertWithValidPubKeyContent), TRUE);
     ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, NULL);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "CryptMsgGetAndVerifySigner failed: 0x%08x\n", GetLastError());
+     "CryptMsgGetAndVerifySigner failed: 0x%08lx\n", GetLastError());
     /* the signer index can be retrieved, .. */
     signerIndex = 0xdeadbeef;
     ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, NULL, &signerIndex);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "CryptMsgGetAndVerifySigner failed: 0x%08x\n", GetLastError());
+     "CryptMsgGetAndVerifySigner failed: 0x%08lx\n", GetLastError());
     if (ret)
-        ok(signerIndex == 0, "expected 0, got %d\n", signerIndex);
+        ok(signerIndex == 0, "expected 0, got %ld\n", signerIndex);
     /* as can the signer cert. */
     signer = (PCCERT_CONTEXT)0xdeadbeef;
     ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, 0, &signer, NULL);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "CryptMsgGetAndVerifySigner failed: 0x%08x\n", GetLastError());
+     "CryptMsgGetAndVerifySigner failed: 0x%08lx\n", GetLastError());
     if (ret)
         ok(signer != NULL && signer != (PCCERT_CONTEXT)0xdeadbeef,
      "expected a valid signer\n");
@@ -3654,7 +3654,7 @@ static void test_msg_get_and_verify_signer(void)
     ret = CryptMsgGetAndVerifySigner(msg, 0, NULL, CMSG_USE_SIGNER_INDEX_FLAG,
      NULL, &signerIndex);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_INDEX,
-     "expected CRYPT_E_INVALID_INDEX, got 0x%08x\n", GetLastError());
+     "expected CRYPT_E_INVALID_INDEX, got 0x%08lx\n", GetLastError());
     /* Specifying CMSG_TRUSTED_SIGNER_FLAG and no cert stores causes the
      * message signer not to be found.
      */
@@ -3663,7 +3663,7 @@ static void test_msg_get_and_verify_signer(void)
      NULL, NULL);
     ok(!ret && (GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER ||
      broken(GetLastError() == OSS_DATA_ERROR /* Win9x */)),
-     "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08x\n", GetLastError());
+     "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError());
     /* Specifying CMSG_TRUSTED_SIGNER_FLAG and an empty cert store also causes
      * the message signer not to be found.
      */
@@ -3674,12 +3674,12 @@ static void test_msg_get_and_verify_signer(void)
      NULL, NULL);
     ok(!ret && (GetLastError() == CRYPT_E_NO_TRUSTED_SIGNER ||
      broken(GetLastError() == OSS_DATA_ERROR /* Win9x */)),
-     "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08x\n", GetLastError());
+     "expected CRYPT_E_NO_TRUSTED_SIGNER, got 0x%08lx\n", GetLastError());
     ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
      v1CertWithValidPubKey, sizeof(v1CertWithValidPubKey),
      CERT_STORE_ADD_ALWAYS, NULL);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win98 */),
-     "CertAddEncodedCertificateToStore failed: 0x%08x\n", GetLastError());
+     "CertAddEncodedCertificateToStore failed: 0x%08lx\n", GetLastError());
     /* Specifying CMSG_TRUSTED_SIGNER_FLAG with a cert store that contains
      * the signer succeeds.
      */
@@ -3687,7 +3687,7 @@ static void test_msg_get_and_verify_signer(void)
     ret = CryptMsgGetAndVerifySigner(msg, 1, &store, CMSG_TRUSTED_SIGNER_FLAG,
      NULL, NULL);
     ok(ret || broken(GetLastError() == OSS_DATA_ERROR /* Win9x */),
-     "CryptMsgGetAndVerifySigner failed: 0x%08x\n", GetLastError());
+     "CryptMsgGetAndVerifySigner failed: 0x%08lx\n", GetLastError());
     CertCloseStore(store, 0);
     CryptMsgClose(msg);
 }
diff --git a/dlls/crypt32/tests/object.c b/dlls/crypt32/tests/object.c
index 211b5423e01..8e77709b970 100644
--- a/dlls/crypt32/tests/object.c
+++ b/dlls/crypt32/tests/object.c
@@ -134,12 +134,12 @@ static void test_query_object(void)
     ret = pCryptQueryObject(0, NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL,
      NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, NULL, 0, 0, 0, NULL, NULL,
      NULL, NULL, NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* Test with a simple cert */
     blob.pbData = bigCert;
     blob.cbData = sizeof(bigCert);
@@ -147,7 +147,7 @@ static void test_query_object(void)
     ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
      CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL,
      NULL, NULL, NULL, NULL);
-    ok(ret, "CryptQueryObject failed: %08x\n", GetLastError());
+    ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError());
     /* The same cert, base64-encoded */
     blob.pbData = (BYTE *)bigCertBase64;
     blob.cbData = sizeof(bigCertBase64);
@@ -155,19 +155,19 @@ static void test_query_object(void)
     ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
      CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL,
      NULL, NULL, NULL, NULL);
-    ok(ret, "CryptQueryObject failed: %08x\n", GetLastError());
+    ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError());
     /* The same base64-encoded cert, restricting the format types */
     SetLastError(0xdeadbeef);
     ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
      CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BINARY, 0, NULL, NULL,
      NULL, NULL, NULL, NULL);
     ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
-     "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
      CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED, 0,
      NULL, NULL, NULL, NULL, NULL, NULL);
-    ok(ret, "CryptQueryObject failed: %08x\n", GetLastError());
+    ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError());
     /* The same cert, base64-encoded but as a wide character string */
     blob.pbData = (BYTE *)bigCertBase64W;
     blob.cbData = sizeof(bigCertBase64W);
@@ -176,7 +176,7 @@ static void test_query_object(void)
      CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL,
      NULL, NULL, NULL, NULL);
     ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
-     "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
     /* For brevity, not tested here, but tested on Windows:  same failure
      * (CRYPT_E_NO_MATCH) when the wide character base64-encoded cert
      * is written to a file and queried.
@@ -188,14 +188,14 @@ static void test_query_object(void)
     ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
      CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL,
      NULL, NULL, NULL, NULL);
-    ok(ret, "CryptQueryObject failed: %08x\n", GetLastError());
+    ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError());
     blob.pbData = (BYTE *)signedWithCertWithValidPubKeyContentBase64;
     blob.cbData = sizeof(signedWithCertWithValidPubKeyContentBase64);
     SetLastError(0xdeadbeef);
     ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
      CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL,
      NULL, NULL, NULL, NULL);
-    ok(ret, "CryptQueryObject failed: %08x\n", GetLastError());
+    ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError());
     /* A valid signed message, encoded as a wide character base64 string, can
      * be queried successfully.
      */
@@ -205,18 +205,18 @@ static void test_query_object(void)
     ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
      CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL,
      NULL, NULL, NULL, NULL);
-    ok(ret, "CryptQueryObject failed: %08x\n", GetLastError());
+    ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
      CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BINARY, 0, NULL, NULL,
      NULL, NULL, NULL, NULL);
     ok(!ret && GetLastError() == CRYPT_E_NO_MATCH,
-     "expected CRYPT_E_NO_MATCH, got %08x\n", GetLastError());
+     "expected CRYPT_E_NO_MATCH, got %08lx\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = pCryptQueryObject(CERT_QUERY_OBJECT_BLOB, &blob,
      CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED, 0,
      NULL, NULL, NULL, NULL, NULL, NULL);
-    ok(ret, "CryptQueryObject failed: %08x\n", GetLastError());
+    ok(ret, "CryptQueryObject failed: %08lx\n", GetLastError());
 }
 
 START_TEST(object)
diff --git a/dlls/crypt32/tests/oid.c b/dlls/crypt32/tests/oid.c
index 7e7c1310dd2..7ba68b6cceb 100644
--- a/dlls/crypt32/tests/oid.c
+++ b/dlls/crypt32/tests/oid.c
@@ -105,13 +105,13 @@ static void testOIDToAlgID(void)
 
     /* Test with a bogus one */
     alg = CertOIDToAlgId("1.2.3");
-    ok(!alg, "Expected failure, got %d\n", alg);
+    ok(!alg, "Expected failure, got %ld\n", alg);
 
     for (i = 0; i < ARRAY_SIZE(oidToAlgID); i++)
     {
         alg = CertOIDToAlgId(oidToAlgID[i].oid);
         ok(alg == oidToAlgID[i].algID || (oidToAlgID[i].altAlgID && alg == oidToAlgID[i].altAlgID),
-         "Expected %d, got %d\n", oidToAlgID[i].algID, alg);
+         "Expected %ld, got %ld\n", oidToAlgID[i].algID, alg);
     }
 }
 
@@ -124,7 +124,7 @@ static void testAlgIDToOID(void)
     SetLastError(0xdeadbeef);
     oid = CertAlgIdToOID(ALG_CLASS_SIGNATURE | ALG_TYPE_ANY | 80);
     ok(!oid && GetLastError() == 0xdeadbeef,
-     "Didn't expect last error (%08x) to be set\n", GetLastError());
+     "Didn't expect last error (%08lx) to be set\n", GetLastError());
     for (i = 0; i < ARRAY_SIZE(algIDToOID); i++)
     {
         oid = CertAlgIdToOID(algIDToOID[i].algID);
@@ -166,7 +166,7 @@ static void test_oidFunctionSet(void)
 
     /* The name doesn't mean much */
     set1 = CryptInitOIDFunctionSet("funky", 0);
-    ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError());
+    ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError());
     if (set1)
     {
         /* These crash
@@ -175,14 +175,14 @@ static void test_oidFunctionSet(void)
          */
         size = 0;
         ret = CryptGetDefaultOIDDllList(set1, 0, NULL, &size);
-        ok(ret, "CryptGetDefaultOIDDllList failed: %08x\n", GetLastError());
+        ok(ret, "CryptGetDefaultOIDDllList failed: %08lx\n", GetLastError());
         if (ret)
         {
             buf = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
             if (buf)
             {
                 ret = CryptGetDefaultOIDDllList(set1, 0, buf, &size);
-                ok(ret, "CryptGetDefaultOIDDllList failed: %08x\n",
+                ok(ret, "CryptGetDefaultOIDDllList failed: %08lx\n",
                  GetLastError());
                 ok(!*buf, "Expected empty DLL list\n");
                 HeapFree(GetProcessHeap(), 0, buf);
@@ -192,9 +192,9 @@ static void test_oidFunctionSet(void)
 
     /* MSDN says flags must be 0, but it's not checked */
     set1 = CryptInitOIDFunctionSet("", 1);
-    ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError());
+    ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError());
     set2 = CryptInitOIDFunctionSet("", 0);
-    ok(set2 != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError());
+    ok(set2 != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError());
     /* There isn't a free function, so there must be only one set per name to
      * limit leaks.  (I guess the sets are freed when crypt32 is unloaded.)
      */
@@ -208,7 +208,7 @@ static void test_oidFunctionSet(void)
 
     /* There's no installed function for a built-in encoding. */
     set1 = CryptInitOIDFunctionSet("CryptDllEncodeObject", 0);
-    ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError());
+    ok(set1 != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError());
     if (set1)
     {
         void *funcAddr;
@@ -218,7 +218,7 @@ static void test_oidFunctionSet(void)
          &funcAddr, &hFuncAddr);
         ok((!ret && GetLastError() == ERROR_FILE_NOT_FOUND) ||
          broken(ret) /* some Win98 */,
-         "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+         "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     }
 }
 
@@ -243,21 +243,21 @@ static void test_installOIDFunctionAddress(void)
     SetLastError(0xdeadbeef);
     ret = CryptInstallOIDFunctionAddress(NULL, 0, "CryptDllEncodeObject", 0,
      NULL, 0);
-    ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08x\n",
+    ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08lx\n",
      GetLastError());
 
     /* The function name doesn't much matter */
     SetLastError(0xdeadbeef);
     ret = CryptInstallOIDFunctionAddress(NULL, 0, "OhSoFunky", 0, NULL, 0);
-    ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08x\n",
+    ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08lx\n",
      GetLastError());
     SetLastError(0xdeadbeef);
     entry.pszOID = X509_CERT;
     ret = CryptInstallOIDFunctionAddress(NULL, 0, "OhSoFunky", 1, &entry, 0);
-    ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08x\n",
+    ok(ret && GetLastError() == 0xdeadbeef, "Expected success, got %08lx\n",
      GetLastError());
     set = CryptInitOIDFunctionSet("OhSoFunky", 0);
-    ok(set != 0, "CryptInitOIDFunctionSet failed: %08x\n", GetLastError());
+    ok(set != 0, "CryptInitOIDFunctionSet failed: %08lx\n", GetLastError());
     if (set)
     {
         funcY funcAddr = NULL;
@@ -271,15 +271,15 @@ static void test_installOIDFunctionAddress(void)
          (void **)&funcAddr, &hFuncAddr);
         ok(!ret && (GetLastError() == ERROR_FILE_NOT_FOUND ||
          GetLastError() == E_INVALIDARG /* some Win98 */),
-         "Expected ERROR_FILE_NOT_FOUND or E_INVALIDARG, got %d\n",
+         "Expected ERROR_FILE_NOT_FOUND or E_INVALIDARG, got %ld\n",
          GetLastError());
         ret = CryptGetOIDFunctionAddress(set, X509_ASN_ENCODING, X509_CERT, 0,
          (void **)&funcAddr, &hFuncAddr);
         ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-         "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+         "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
         ret = CryptGetOIDFunctionAddress(set, 0, X509_CERT, 0,
          (void **)&funcAddr, &hFuncAddr);
-        ok(ret, "CryptGetOIDFunctionAddress failed: %d\n", GetLastError());
+        ok(ret, "CryptGetOIDFunctionAddress failed: %ld\n", GetLastError());
         if (funcAddr)
         {
             int y = funcAddr(0xabadc0da);
@@ -306,11 +306,11 @@ static void test_registerOIDFunction(void)
     ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "foo", NULL, bogusDll,
      NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG: %d\n", GetLastError());
+     "Expected E_INVALIDARG: %ld\n", GetLastError());
     /* This has no effect, but "succeeds" on XP */
     ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "foo",
      "1.2.3.4.5.6.7.8.9.10", NULL, NULL);
-    ok(ret, "Expected pseudo-success, got %d\n", GetLastError());
+    ok(ret, "Expected pseudo-success, got %ld\n", GetLastError());
     SetLastError(0xdeadbeef);
     ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "CryptDllEncodeObject",
      "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
@@ -319,16 +319,16 @@ static void test_registerOIDFunction(void)
         skip("Need admin rights\n");
         return;
     }
-    ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError());
+    ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError());
     ret = CryptUnregisterOIDFunction(X509_ASN_ENCODING, "CryptDllEncodeObject",
      "1.2.3.4.5.6.7.8.9.10");
-    ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError());
+    ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError());
     ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "bogus",
      "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
-    ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError());
+    ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError());
     ret = CryptUnregisterOIDFunction(X509_ASN_ENCODING, "bogus",
      "1.2.3.4.5.6.7.8.9.10");
-    ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError());
+    ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError());
     /* Unwanted Cryptography\OID\EncodingType 1\bogus\ will still be there */
     ok(!RegDeleteKeyA(HKEY_LOCAL_MACHINE,
      "SOFTWARE\\Microsoft\\Cryptography\\OID\\EncodingType 1\\bogus"),
@@ -336,17 +336,17 @@ static void test_registerOIDFunction(void)
     /* Shouldn't have effect but registry keys are created */
     ret = CryptRegisterOIDFunction(PKCS_7_ASN_ENCODING, "CryptDllEncodeObject",
      "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
-    ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError());
+    ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError());
     ret = CryptUnregisterOIDFunction(PKCS_7_ASN_ENCODING, "CryptDllEncodeObject",
      "1.2.3.4.5.6.7.8.9.10");
-    ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError());
+    ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError());
     /* Check with bogus encoding type. Registry keys are still created */
     ret = CryptRegisterOIDFunction(0, "CryptDllEncodeObject",
      "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
-    ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError());
+    ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError());
     ret = CryptUnregisterOIDFunction(0, "CryptDllEncodeObject",
      "1.2.3.4.5.6.7.8.9.10");
-    ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError());
+    ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError());
     /* Unwanted Cryptography\OID\EncodingType 0\CryptDllEncodeObject\
      * will still be there
      */
@@ -358,10 +358,10 @@ static void test_registerOIDFunction(void)
      */
     ret = CryptRegisterOIDFunction(3, "CryptDllEncodeObject",
      "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL);
-    ok(ret, "CryptRegisterOIDFunction failed: %d\n", GetLastError());
+    ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError());
     ret = CryptUnregisterOIDFunction(3, "CryptDllEncodeObject",
      "1.2.3.4.5.6.7.8.9.10");
-    ok(ret, "CryptUnregisterOIDFunction failed: %d\n", GetLastError());
+    ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError());
     /* Unwanted Cryptography\OID\EncodingType 3\CryptDllEncodeObject
      * will still be there.
      */
@@ -385,7 +385,7 @@ static void test_registerDefaultOIDFunction(void)
 
     ret = CryptRegisterDefaultOIDFunction(0, NULL, 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* This succeeds on WinXP, although the bogus entry is unusable.
     ret = CryptRegisterDefaultOIDFunction(0, NULL, 0, bogusDll);
      */
@@ -398,24 +398,24 @@ static void test_registerDefaultOIDFunction(void)
         skip("Need admin rights\n");
         return;
     }
-    ok(ret, "CryptRegisterDefaultOIDFunction failed: %08x\n", GetLastError());
+    ok(ret, "CryptRegisterDefaultOIDFunction failed: %08lx\n", GetLastError());
     /* Reregistering should fail */
     ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 0,
      bogusDll);
     ok(!ret && GetLastError() == ERROR_FILE_EXISTS,
-     "Expected ERROR_FILE_EXISTS, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_EXISTS, got %08lx\n", GetLastError());
     /* Registering the same one at index 1 should also fail */
     ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 1,
      bogusDll);
     ok(!ret && GetLastError() == ERROR_FILE_EXISTS,
-     "Expected ERROR_FILE_EXISTS, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_EXISTS, got %08lx\n", GetLastError());
     /* Registering a different one at index 1 succeeds */
     ret = CryptRegisterDefaultOIDFunction(0, "CertDllOpenStoreProv", 1,
      bogus2Dll);
-    ok(ret, "CryptRegisterDefaultOIDFunction failed: %08x\n", GetLastError());
+    ok(ret, "CryptRegisterDefaultOIDFunction failed: %08lx\n", GetLastError());
     sprintf(buf, fmt, 0, func);
     rc = RegOpenKeyA(HKEY_LOCAL_MACHINE, buf, &key);
-    ok(rc == 0, "Expected key to exist, RegOpenKeyA failed: %d\n", rc);
+    ok(rc == 0, "Expected key to exist, RegOpenKeyA failed: %ld\n", rc);
     if (rc == 0)
     {
         static const CHAR dllA[] = "Dll";
@@ -428,8 +428,8 @@ static void test_registerDefaultOIDFunction(void)
         size = ARRAY_SIZE(dllBuf);
         rc = RegQueryValueExA(key, dllA, NULL, &type, (LPBYTE)dllBuf, &size);
         ok(rc == 0,
-         "Expected Dll value to exist, RegQueryValueExA failed: %d\n", rc);
-        ok(type == REG_MULTI_SZ, "Expected type REG_MULTI_SZ, got %d\n", type);
+         "Expected Dll value to exist, RegQueryValueExA failed: %ld\n", rc);
+        ok(type == REG_MULTI_SZ, "Expected type REG_MULTI_SZ, got %ld\n", type);
         /* bogusDll was registered first, so that should be first */
         ptr = dllBuf;
         ok(!lstrcmpiA(ptr, bogusDll_A), "Unexpected dll\n");
@@ -440,17 +440,17 @@ static void test_registerDefaultOIDFunction(void)
     /* Unregister both of them */
     ret = CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv",
      bogusDll);
-    ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08x\n",
+    ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08lx\n",
      GetLastError());
     ret = CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv",
      bogus2Dll);
-    ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08x\n",
+    ok(ret, "CryptUnregisterDefaultOIDFunction failed: %08lx\n",
      GetLastError());
     /* Now that they're both unregistered, unregistering should fail */
     ret = CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv",
      bogusDll);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
 
     /* Repeat a few tests on the normal encoding type */
     ret = CryptRegisterDefaultOIDFunction(X509_ASN_ENCODING,
@@ -462,7 +462,7 @@ static void test_registerDefaultOIDFunction(void)
     ret = CryptUnregisterDefaultOIDFunction(X509_ASN_ENCODING,
      "CertDllOpenStoreProv", bogusDll);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
 }
 
 static void test_getDefaultOIDFunctionAddress(void)
@@ -480,20 +480,20 @@ static void test_getDefaultOIDFunctionAddress(void)
      &hFuncAddr);
      */
     set = CryptInitOIDFunctionSet("CertDllOpenStoreProv", 0);
-    ok(set != 0, "CryptInitOIDFunctionSet failed: %d\n", GetLastError());
+    ok(set != 0, "CryptInitOIDFunctionSet failed: %ld\n", GetLastError());
     /* This crashes if hFuncAddr is not 0 to begin with */
     hFuncAddr = 0;
     ret = CryptGetDefaultOIDFunctionAddress(set, 0, NULL, 0, &funcAddr,
      &hFuncAddr);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
     /* This fails with the normal encoding too, so built-in functions aren't
      * returned.
      */
     ret = CryptGetDefaultOIDFunctionAddress(set, X509_ASN_ENCODING, NULL, 0,
      &funcAddr, &hFuncAddr);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
 
     /* Even with a registered dll, this fails (since the dll doesn't exist) */
     SetLastError(0xdeadbeef);
@@ -502,11 +502,11 @@ static void test_getDefaultOIDFunctionAddress(void)
     if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
         skip("Need admin rights\n");
     else
-        ok(ret, "CryptRegisterDefaultOIDFunction failed: %08x\n", GetLastError());
+        ok(ret, "CryptRegisterDefaultOIDFunction failed: %08lx\n", GetLastError());
     ret = CryptGetDefaultOIDFunctionAddress(set, 0, NULL, 0, &funcAddr,
      &hFuncAddr);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
     CryptUnregisterDefaultOIDFunction(0, "CertDllOpenStoreProv", bogusDll);
 }
 
@@ -591,20 +591,20 @@ static void test_findOIDInfo(void)
     {
         DWORD *data;
 
-        ok(info->cbSize == sizeof(*info), "Unexpected structure size %d.\n", info->cbSize);
+        ok(info->cbSize == sizeof(*info), "Unexpected structure size %ld.\n", info->cbSize);
         ok(!strcmp(info->pszOID, oid_ecdsa_sha256), "Expected %s, got %s\n", oid_ecdsa_sha256, info->pszOID);
         ok(!lstrcmpW(info->pwszName, sha256ECDSA), "Expected %s, got %s\n",
             wine_dbgstr_w(sha256ECDSA), wine_dbgstr_w(info->pwszName));
         ok(info->dwGroupId == CRYPT_SIGN_ALG_OID_GROUP_ID,
-           "Expected CRYPT_SIGN_ALG_OID_GROUP_ID, got %u\n", info->dwGroupId);
+           "Expected CRYPT_SIGN_ALG_OID_GROUP_ID, got %lu\n", info->dwGroupId);
         ok(U(*info).Algid == CALG_OID_INFO_CNG_ONLY,
            "Expected CALG_OID_INFO_CNG_ONLY, got %d\n", U(*info).Algid);
 
         data = (DWORD *)info->ExtraInfo.pbData;
-        ok(info->ExtraInfo.cbData == 8, "Expected 8, got %d\n", info->ExtraInfo.cbData);
-        ok(data[0] == CALG_OID_INFO_PARAMETERS, "Expected CALG_OID_INFO_PARAMETERS, got %x\n", data[0]);
+        ok(info->ExtraInfo.cbData == 8, "Expected 8, got %ld\n", info->ExtraInfo.cbData);
+        ok(data[0] == CALG_OID_INFO_PARAMETERS, "Expected CALG_OID_INFO_PARAMETERS, got %lx\n", data[0]);
         ok(data[1] == CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG,
-            "Expected CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG, got %x\n", data[1]);
+            "Expected CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG, got %lx\n", data[1]);
 
         ok(!lstrcmpW(info->pwszCNGAlgid, BCRYPT_SHA256_ALGORITHM), "Expected %s, got %s\n",
            wine_dbgstr_w(BCRYPT_SHA256_ALGORITHM), wine_dbgstr_w(info->pwszCNGAlgid));
@@ -628,26 +628,26 @@ static void test_registerOIDInfo(void)
     SetLastError(0xdeadbeef);
     ret = CryptUnregisterOIDInfo(NULL);
     ok(!ret, "should fail\n");
-    ok(GetLastError() == E_INVALIDARG, "got %#x\n", GetLastError());
+    ok(GetLastError() == E_INVALIDARG, "got %#lx\n", GetLastError());
 
     memset(&info1, 0, sizeof(info1));
     SetLastError(0xdeadbeef);
     ret = CryptUnregisterOIDInfo(&info1);
     ok(!ret, "should fail\n");
-    ok(GetLastError() == E_INVALIDARG, "got %#x\n", GetLastError());
+    ok(GetLastError() == E_INVALIDARG, "got %#lx\n", GetLastError());
 
     info1.cbSize = sizeof(info1);
     SetLastError(0xdeadbeef);
     ret = CryptUnregisterOIDInfo(&info1);
     ok(!ret, "should fail\n");
-    ok(GetLastError() == E_INVALIDARG, "got %#x\n", GetLastError());
+    ok(GetLastError() == E_INVALIDARG, "got %#lx\n", GetLastError());
 
     info1.pszOID = test_oid;
     SetLastError(0xdeadbeef);
     ret = CryptUnregisterOIDInfo(&info1);
     ok(!ret, "should fail\n");
     ok(GetLastError() == ERROR_FILE_NOT_FOUND ||
-       GetLastError() == ERROR_ACCESS_DENIED, "got %u\n", GetLastError());
+       GetLastError() == ERROR_ACCESS_DENIED, "got %lu\n", GetLastError());
 
     info2 = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, (void *)test_oid, 0);
     ok(!info2, "should fail\n");
@@ -657,10 +657,10 @@ static void test_registerOIDInfo(void)
      * registry on Windows because dwGroupId == 0.
      */
     ret = CryptRegisterOIDInfo(&info1, 0);
-    ok(ret, "got %u\n", GetLastError());
+    ok(ret, "got %lu\n", GetLastError());
 
     ret = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo\\1.2.3.4.5.6.7.8.9.10!1", &key);
-    ok(ret == ERROR_FILE_NOT_FOUND, "got %u\n", ret);
+    ok(ret == ERROR_FILE_NOT_FOUND, "got %lu\n", ret);
 
     info2 = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, (void *)test_oid, 0);
     ok(!info2, "should fail\n");
@@ -674,7 +674,7 @@ static void test_registerOIDInfo(void)
         skip("Need admin rights\n");
         return;
     }
-    ok(ret, "got %u\n", GetLastError());
+    ok(ret, "got %lu\n", GetLastError());
 
     /* It looks like crypt32 reads the OID info from registry only on load,
      * and CryptFindOIDInfo will find the registered OID on next run
@@ -683,28 +683,28 @@ static void test_registerOIDInfo(void)
     ok(!info2, "should fail\n");
 
     ret = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo\\1.2.3.4.5.6.7.8.9.10!1", &key);
-    ok(!ret, "got %u\n", ret);
+    ok(!ret, "got %lu\n", ret);
 
     memset(buf, 0, sizeof(buf));
     size = sizeof(buf);
     ret = RegQueryValueExA(key, "Name", NULL, &type, (BYTE *)buf, &size);
-    ok(!ret, "got %u\n", ret);
-    ok(type == REG_SZ, "got %u\n", type);
+    ok(!ret, "got %lu\n", ret);
+    ok(type == REG_SZ, "got %lu\n", type);
     ok(!strcmp(buf, "winetest"), "got %s\n", buf);
 
     value = 0xdeadbeef;
     size = sizeof(value);
     ret = RegQueryValueExA(key, "Flags", NULL, &type, (BYTE *)&value, &size);
-    ok(!ret, "got %u\n", ret);
-    ok(type == REG_DWORD, "got %u\n", type);
-    ok(value == 1, "got %u\n", value);
+    ok(!ret, "got %lu\n", ret);
+    ok(type == REG_DWORD, "got %lu\n", type);
+    ok(value == 1, "got %lu\n", value);
 
     RegCloseKey(key);
 
     CryptUnregisterOIDInfo(&info1);
 
     ret = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Cryptography\\OID\\EncodingType 0\\CryptDllFindOIDInfo\\1.2.3.4.5.6.7.8.9.10!1", &key);
-    ok(ret == ERROR_FILE_NOT_FOUND, "got %u\n", ret);
+    ok(ret == ERROR_FILE_NOT_FOUND, "got %lu\n", ret);
 }
 
 START_TEST(oid)
diff --git a/dlls/crypt32/tests/protectdata.c b/dlls/crypt32/tests/protectdata.c
index 70a8ba86b05..c4dfcd19a39 100644
--- a/dlls/crypt32/tests/protectdata.c
+++ b/dlls/crypt32/tests/protectdata.c
@@ -55,13 +55,13 @@ static void test_cryptprotectdata(void)
     protected = pCryptProtectData(NULL,desc,NULL,NULL,NULL,0,&cipher);
     ok(!protected, "Encrypting without plain data source.\n");
     r = GetLastError();
-    ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r);
+    ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r);
 
     SetLastError(0xDEADBEEF);
     protected = pCryptProtectData(&plain,desc,NULL,NULL,NULL,0,NULL);
     ok(!protected, "Encrypting without cipher destination.\n");
     r = GetLastError();
-    ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r);
+    ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r);
 
     cipher.pbData=NULL;
     cipher.cbData=0;
@@ -77,7 +77,7 @@ static void test_cryptprotectdata(void)
         r = GetLastError();
         ok(r == ERROR_SUCCESS ||
            r == ERROR_IO_PENDING, /* win2k */
-           "Expected ERROR_SUCCESS or ERROR_IO_PENDING, got %d\n",r);
+           "Expected ERROR_SUCCESS or ERROR_IO_PENDING, got %ld\n",r);
     }
 
     cipher_entropy.pbData=NULL;
@@ -102,7 +102,7 @@ static void test_cryptprotectdata(void)
     {
         /* fails in win2k */
         ok(GetLastError() == ERROR_INVALID_PARAMETER,
-           "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+           "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
     }
 }
 
@@ -131,13 +131,13 @@ static void test_cryptunprotectdata(void)
     okay = pCryptUnprotectData(&cipher,NULL,NULL,NULL,NULL,0,NULL);
     ok(!okay,"Decrypting without destination\n");
     r = GetLastError();
-    ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r);
+    ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r);
 
     SetLastError(0xDEADBEEF);
     okay = pCryptUnprotectData(NULL,NULL,NULL,NULL,NULL,0,&plain);
     ok(!okay,"Decrypting without source\n");
     r = GetLastError();
-    ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r);
+    ok(r == ERROR_INVALID_PARAMETER, "Wrong (%lu) GetLastError seen\n",r);
 
     plain.pbData=NULL;
     plain.cbData=0;
@@ -146,7 +146,7 @@ static void test_cryptunprotectdata(void)
     okay = pCryptUnprotectData(&cipher_entropy,NULL,NULL,NULL,NULL,0,&plain);
     ok(!okay,"Decrypting without needed entropy\n");
     r = GetLastError();
-    ok(r == ERROR_INVALID_DATA, "Wrong (%u) GetLastError seen\n", r);
+    ok(r == ERROR_INVALID_DATA, "Wrong (%lu) GetLastError seen\n", r);
 
     plain.pbData=NULL;
     plain.cbData=0;
@@ -175,7 +175,7 @@ static void test_cryptunprotectdata(void)
     okay = pCryptUnprotectData(&cipher_entropy,&data_desc,&cipher_entropy,NULL,NULL,0,&plain);
     ok(!okay,"Decrypting with wrong entropy\n");
     r = GetLastError();
-    ok(r == ERROR_INVALID_DATA, "Wrong (%u) GetLastError seen\n",r);
+    ok(r == ERROR_INVALID_DATA, "Wrong (%lu) GetLastError seen\n",r);
 
     /* with entropy */
     SetLastError(0xDEADBEEF);
@@ -234,8 +234,8 @@ static void test_simpleroundtrip(const char *plaintext)
     }
 
     res = pCryptUnprotectData(&encrypted, NULL, NULL, NULL, NULL, 0, &output);
-    ok(res != 0, "can't unprotect; last error %u\n", GetLastError());
-    ok(output.cbData == strlen(plaintext), "output wrong length %d for input '%s', wanted %d\n", output.cbData, plaintext, lstrlenA(plaintext));
+    ok(res != 0, "can't unprotect; last error %lu\n", GetLastError());
+    ok(output.cbData == strlen(plaintext), "output wrong length %ld for input '%s', wanted %d\n", output.cbData, plaintext, lstrlenA(plaintext));
     ok(!memcmp(plaintext, (char *)output.pbData, output.cbData), "output wrong contents for input '%s'\n", plaintext);
     LocalFree(output.pbData);
     LocalFree(encrypted.pbData);
diff --git a/dlls/crypt32/tests/sip.c b/dlls/crypt32/tests/sip.c
index d8d6a874450..5728065127b 100644
--- a/dlls/crypt32/tests/sip.c
+++ b/dlls/crypt32/tests/sip.c
@@ -49,7 +49,7 @@ static void test_AddRemoveProvider(void)
     ret = CryptSIPRemoveProvider(NULL);
     ok (!ret, "Expected CryptSIPRemoveProvider to fail.\n");
     ok (GetLastError() == ERROR_INVALID_PARAMETER,
-        "Expected ERROR_INVALID_PARAMETER, got %d.\n", GetLastError());
+        "Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError());
 
     /* nonexistent provider should result in a registry error */
     SetLastError(0xdeadbeef);
@@ -68,7 +68,7 @@ static void test_AddRemoveProvider(void)
          */
         if (!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());
     }
 
     /* Everything OK, pwszIsFunctionName and pwszIsFunctionNameFmt2 are left NULL
@@ -90,7 +90,7 @@ static void test_AddRemoveProvider(void)
         skip("Need admin rights\n");
         return;
     }
-    ok ( ret, "CryptSIPAddProvider should have succeeded, last error %d\n", GetLastError());
+    ok ( ret, "CryptSIPAddProvider should have succeeded, last error %ld\n", GetLastError());
 
     /* Dummy provider will be deleted, but the function still fails because
      * pwszIsFunctionName and pwszIsFunctionNameFmt2 are not present in the
@@ -105,7 +105,7 @@ static void test_AddRemoveProvider(void)
      */
     if (!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());
 
     /* Everything OK */
     memset(&newprov, 0, sizeof(SIP_ADD_NEWPROVIDER));
@@ -124,12 +124,12 @@ static void test_AddRemoveProvider(void)
 
     SetLastError(0xdeadbeef);
     ret = CryptSIPAddProvider(&newprov);
-    ok ( ret, "CryptSIPAddProvider should have succeeded, last error %d\n", GetLastError());
+    ok ( ret, "CryptSIPAddProvider should have succeeded, last error %ld\n", GetLastError());
 
     /* Dummy provider should be deleted */
     SetLastError(0xdeadbeef);
     ret = CryptSIPRemoveProvider(&actionid);
-    ok ( ret, "CryptSIPRemoveProvider should have succeeded, last error %d\n", GetLastError());
+    ok ( ret, "CryptSIPRemoveProvider should have succeeded, last error %ld\n", GetLastError());
 }
 
 static const BYTE cabFileData[] = {
@@ -164,7 +164,7 @@ static void test_SIPRetrieveSubjectGUID(void)
     ret = CryptSIPRetrieveSubjectGuid(NULL, NULL, NULL);
     ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
     ok (GetLastError() == ERROR_INVALID_PARAMETER,
-        "Expected ERROR_INVALID_PARAMETER, got %d.\n", GetLastError());
+        "Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError());
 
     /* Test with a nonexistent file (hopefully) */
     SetLastError(0xdeadbeef);
@@ -174,7 +174,7 @@ static void test_SIPRetrieveSubjectGUID(void)
     ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
     ok (GetLastError() == ERROR_FILE_NOT_FOUND ||
         GetLastError() == ERROR_PATH_NOT_FOUND,
-        "Expected ERROR_FILE_NOT_FOUND or ERROR_PATH_NOT_FOUND, got %d.\n",
+        "Expected ERROR_FILE_NOT_FOUND or ERROR_PATH_NOT_FOUND, got %ld.\n",
         GetLastError());
     ok(IsEqualGUID(&subject, &nullSubject),
        "Expected a NULL GUID for c:\\deadbeef.dbf, not %s\n", wine_dbgstr_guid(&subject));
@@ -184,7 +184,7 @@ static void test_SIPRetrieveSubjectGUID(void)
      * Use A-functions where possible as that should be available on all platforms
      */
     ret = GetEnvironmentVariableA(windir, regeditPath, MAX_PATH);
-    ok (ret > 0, "expected GEVA(windir) to succeed, last error %d\n", GetLastError());
+    ok (ret > 0, "expected GEVA(windir) to succeed, last error %ld\n", GetLastError());
     strcat(regeditPath, "\\");
     strcat(regeditPath, regeditExe);
     MultiByteToWideChar(CP_ACP, 0, regeditPath, strlen(regeditPath)+1, regeditPathW,
@@ -230,7 +230,7 @@ static void test_SIPRetrieveSubjectGUID(void)
          GetLastError() == ERROR_INVALID_PARAMETER /* Vista */ ||
          GetLastError() == ERROR_SUCCESS /* most Win98 */ ||
          GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN /* some Win98 */,
-        "Expected ERROR_FILE_INVALID, ERROR_INVALID_PARAMETER, ERROR_SUCCESS or TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08x\n", GetLastError());
+        "Expected ERROR_FILE_INVALID, ERROR_INVALID_PARAMETER, ERROR_SUCCESS or TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08lx\n", GetLastError());
     ok(IsEqualGUID(&subject, &nullSubject),
        "Expected a NULL GUID for empty file %s, not %s\n", tempfile, wine_dbgstr_guid(&subject));
 
@@ -246,7 +246,7 @@ static void test_SIPRetrieveSubjectGUID(void)
     ok ( GetLastError() == ERROR_INVALID_PARAMETER ||
          GetLastError() == ERROR_SUCCESS /* most Win98 */ ||
          GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN /* some Win98 */,
-        "Expected ERROR_INVALID_PARAMETER, ERROR_SUCCESS or TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08x\n", GetLastError());
+        "Expected ERROR_INVALID_PARAMETER, ERROR_SUCCESS or TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08lx\n", GetLastError());
     ok(IsEqualGUID(&subject, &nullSubject),
        "Expected a NULL GUID for empty file %s, not %s\n", tempfile, wine_dbgstr_guid(&subject));
 
@@ -261,7 +261,7 @@ static void test_SIPRetrieveSubjectGUID(void)
     ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
     ok ( GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN ||
          GetLastError() == ERROR_SUCCESS /* Win98 */,
-        "Expected TRUST_E_SUBJECT_FORM_UNKNOWN or ERROR_SUCCESS, got 0x%08x\n", GetLastError());
+        "Expected TRUST_E_SUBJECT_FORM_UNKNOWN or ERROR_SUCCESS, got 0x%08lx\n", GetLastError());
     ok(IsEqualGUID(&subject, &nullSubject),
        "Expected a NULL GUID for empty file %s, not %s\n", tempfile, wine_dbgstr_guid(&subject));
 
@@ -271,14 +271,14 @@ static void test_SIPRetrieveSubjectGUID(void)
     /* Create a file with just the .cab header 'MSCF' */
     SetLastError(0xdeadbeef);
     file = CreateFileA(tempfile, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
-    ok(file != INVALID_HANDLE_VALUE, "failed with %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "failed with %lu\n", GetLastError());
     WriteFile(file, cabFileData, 4, &written, NULL);
     CloseHandle(file);
 
     SetLastError(0xdeadbeef);
     memset(&subject, 1, sizeof(GUID));
     ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject);
-    ok( ret, "CryptSIPRetrieveSubjectGuid failed: %d (0x%08x)\n",
+    ok( ret, "CryptSIPRetrieveSubjectGuid failed: %ld (0x%08lx)\n",
             GetLastError(), GetLastError() );
     ok(IsEqualGUID(&subject, &cabGUID),
        "Expected GUID %s for cabinet file, not %s\n", wine_dbgstr_guid(&cabGUID), wine_dbgstr_guid(&subject));
@@ -289,14 +289,14 @@ static void test_SIPRetrieveSubjectGUID(void)
     /* Create a .cab file */
     SetLastError(0xdeadbeef);
     file = CreateFileA(tempfile, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
-    ok(file != INVALID_HANDLE_VALUE, "failed with %u\n", GetLastError());
+    ok(file != INVALID_HANDLE_VALUE, "failed with %lu\n", GetLastError());
     WriteFile(file, cabFileData, sizeof(cabFileData), &written, NULL);
     CloseHandle(file);
 
     SetLastError(0xdeadbeef);
     memset(&subject, 1, sizeof(GUID));
     ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject);
-    ok( ret, "CryptSIPRetrieveSubjectGuid failed: %d (0x%08x)\n",
+    ok( ret, "CryptSIPRetrieveSubjectGuid failed: %ld (0x%08lx)\n",
             GetLastError(), GetLastError() );
     ok(IsEqualGUID(&subject, &cabGUID),
        "Expected GUID %s for cabinet file, not %s\n", wine_dbgstr_guid(&cabGUID), wine_dbgstr_guid(&subject));
@@ -322,14 +322,14 @@ static void test_SIPLoad(void)
     ret = CryptSIPLoad(NULL, 0, NULL);
     ok ( !ret, "Expected CryptSIPLoad to fail\n");
     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
-        "Expected ERROR_INVALID_PARAMETER, got 0x%08x\n", GetLastError());
+        "Expected ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError());
 
     /* Only pSipDispatch NULL */
     SetLastError(0xdeadbeef);
     ret = CryptSIPLoad(&subject, 0, NULL);
     ok ( !ret, "Expected CryptSIPLoad to fail\n");
     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
-        "Expected ERROR_INVALID_PARAMETER, got 0x%08x\n", GetLastError());
+        "Expected ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError());
 
     /* No NULLs, but nonexistent pgSubject */
     SetLastError(0xdeadbeef);
@@ -339,7 +339,7 @@ static void test_SIPLoad(void)
     ret = CryptSIPLoad(&dummySubject, 0, &sdi);
     ok ( !ret, "Expected CryptSIPLoad to fail\n");
     ok ( GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN,
-        "Expected TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08x\n", GetLastError());
+        "Expected TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08lx\n", GetLastError());
     ok( sdi.pfGet == (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected no change to the function pointer\n");
 
     hCrypt = GetModuleHandleA("crypt32.dll");
@@ -430,7 +430,7 @@ static void test_SIPLoad(void)
     ret = CryptSIPLoad(&unknown, 1, &sdi);
     ok ( !ret, "Expected CryptSIPLoad to fail\n");
     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
-        "Expected ERROR_INVALID_PARAMETER, got 0x%08x\n", GetLastError());
+        "Expected ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError());
     ok( sdi.pfGet == (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected no change to the function pointer\n");
 }
 
diff --git a/dlls/crypt32/tests/store.c b/dlls/crypt32/tests/store.c
index 852cedaa1fe..d8669995d68 100644
--- a/dlls/crypt32/tests/store.c
+++ b/dlls/crypt32/tests/store.c
@@ -136,21 +136,21 @@ static void testMemStore(void)
     /* NULL provider */
     store1 = CertOpenStore(0, 0, 0, 0, NULL);
     ok(!store1 && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError());
     /* weird flags */
     store1 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_DELETE_FLAG, NULL);
     ok(!store1 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED,
-     "Expected ERROR_CALL_NOT_IMPLEMENTED, got %d\n", GetLastError());
+     "Expected ERROR_CALL_NOT_IMPLEMENTED, got %ld\n", GetLastError());
 
     /* normal */
     store1 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(store1 != NULL, "CertOpenStore failed: %d\n", GetLastError());
+    ok(store1 != NULL, "CertOpenStore failed: %ld\n", GetLastError());
     /* open existing doesn't */
     store2 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_OPEN_EXISTING_FLAG, NULL);
-    ok(store2 != NULL, "CertOpenStore failed: %d\n", GetLastError());
+    ok(store2 != NULL, "CertOpenStore failed: %ld\n", GetLastError());
     ok(store1 != store2, "Expected different stores\n");
 
     /* add a bogus (empty) cert */
@@ -164,24 +164,24 @@ static void testMemStore(void)
     GLE = GetLastError();
     ok(!ret && (GLE == CRYPT_E_ASN1_EOD || GLE == CRYPT_E_ASN1_CORRUPT ||
      GLE == OSS_DATA_ERROR),
-     "Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n",
+     "Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n",
      GLE);
     /* add a "signed" cert--the signature isn't a real signature, so this adds
      * without any check of the signature's validity
      */
     ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING,
      signedBigCert, sizeof(signedBigCert), CERT_STORE_ADD_ALWAYS, &context);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     ok(context != NULL, "Expected a valid cert context\n");
     if (context)
     {
         ok(context->cbCertEncoded == sizeof(signedBigCert),
-         "Wrong cert size %d\n", context->cbCertEncoded);
+         "Wrong cert size %ld\n", context->cbCertEncoded);
         ok(!memcmp(context->pbCertEncoded, signedBigCert,
          sizeof(signedBigCert)), "Unexpected encoded cert in context\n");
         /* remove it, the rest of the tests will work on an unsigned cert */
         ret = CertDeleteCertificateFromStore(context);
-        ok(ret, "CertDeleteCertificateFromStore failed: %08x\n",
+        ok(ret, "CertDeleteCertificateFromStore failed: %08lx\n",
          GetLastError());
     }
     /* try adding a "signed" CRL as a cert */
@@ -190,12 +190,12 @@ static void testMemStore(void)
     GLE = GetLastError();
     ok(!ret && (GLE == CRYPT_E_ASN1_BADTAG || GLE == CRYPT_E_ASN1_CORRUPT ||
      GLE == OSS_DATA_ERROR),
-     "Expected CRYPT_E_ASN1_BADTAG or CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08x\n",
+     "Expected CRYPT_E_ASN1_BADTAG or CRYPT_E_ASN1_CORRUPT or OSS_DATA_ERROR, got %08lx\n",
      GLE);
     /* add a cert to store1 */
     ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING, bigCert,
      sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &context);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     ok(context != NULL, "Expected a valid cert context\n");
     if (context)
     {
@@ -203,7 +203,7 @@ static void testMemStore(void)
         BYTE *buf;
 
         ok(context->cbCertEncoded == sizeof(bigCert),
-         "Wrong cert size %d\n", context->cbCertEncoded);
+         "Wrong cert size %ld\n", context->cbCertEncoded);
         ok(!memcmp(context->pbCertEncoded, bigCert, sizeof(bigCert)),
          "Unexpected encoded cert in context\n");
         ok(context->hCertStore == store1, "Unexpected store\n");
@@ -216,28 +216,28 @@ static void testMemStore(void)
          */
         /* apparently flags are ignored */
         ret = CertSerializeCertificateStoreElement(context, 1, NULL, &size);
-        ok(ret, "CertSerializeCertificateStoreElement failed: %08x\n",
+        ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n",
          GetLastError());
         buf = HeapAlloc(GetProcessHeap(), 0, size);
         if (buf)
         {
             ret = CertSerializeCertificateStoreElement(context, 0, buf, &size);
-            ok(ret, "CertSerializeCertificateStoreElement failed: %08x\n", GetLastError());
-            ok(size == sizeof(serializedCert), "Wrong size %d\n", size);
+            ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n", GetLastError());
+            ok(size == sizeof(serializedCert), "Wrong size %ld\n", size);
             ok(!memcmp(serializedCert, buf, size),
              "Unexpected serialized cert\n");
             HeapFree(GetProcessHeap(), 0, buf);
         }
 
         ret = CertFreeCertificateContext(context);
-        ok(ret, "CertFreeCertificateContext failed: %08x\n", GetLastError());
+        ok(ret, "CertFreeCertificateContext failed: %08lx\n", GetLastError());
     }
     /* verify the cert's in store1 */
     context = CertEnumCertificatesInStore(store1, NULL);
     ok(context != NULL, "Expected a valid context\n");
     context = CertEnumCertificatesInStore(store1, context);
     ok(!context && GetLastError() == CRYPT_E_NOT_FOUND,
-     "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
     /* verify store2 (the "open existing" mem store) is still empty */
     context = CertEnumCertificatesInStore(store2, NULL);
     ok(!context, "Expected an empty store\n");
@@ -254,14 +254,14 @@ static void testMemStore(void)
          */
         PCCERT_CONTEXT copy = CertDuplicateCertificateContext(context);
 
-        ok(copy != NULL, "CertDuplicateCertificateContext failed: %08x\n",
+        ok(copy != NULL, "CertDuplicateCertificateContext failed: %08lx\n",
          GetLastError());
         ret = CertDeleteCertificateFromStore(context);
-        ok(ret, "CertDeleteCertificateFromStore failed: %08x\n",
+        ok(ret, "CertDeleteCertificateFromStore failed: %08lx\n",
          GetLastError());
         /* try deleting a copy */
         ret = CertDeleteCertificateFromStore(copy);
-        ok(ret, "CertDeleteCertificateFromStore failed: %08x\n",
+        ok(ret, "CertDeleteCertificateFromStore failed: %08lx\n",
          GetLastError());
         /* check that the store is empty */
         context = CertEnumCertificatesInStore(store1, NULL);
@@ -270,32 +270,32 @@ static void testMemStore(void)
 
     /* close an empty store */
     ret = CertCloseStore(NULL, 0);
-    ok(ret, "CertCloseStore failed: %d\n", GetLastError());
+    ok(ret, "CertCloseStore failed: %ld\n", GetLastError());
     ret = CertCloseStore(store1, 0);
-    ok(ret, "CertCloseStore failed: %d\n", GetLastError());
+    ok(ret, "CertCloseStore failed: %ld\n", GetLastError());
     ret = CertCloseStore(store2, 0);
-    ok(ret, "CertCloseStore failed: %d\n", GetLastError());
+    ok(ret, "CertCloseStore failed: %ld\n", GetLastError());
 
     /* This seems nonsensical, but you can open a read-only mem store, only
      * it isn't read-only
      */
     store1 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_READONLY_FLAG, NULL);
-    ok(store1 != NULL, "CertOpenStore failed: %d\n", GetLastError());
+    ok(store1 != NULL, "CertOpenStore failed: %ld\n", GetLastError());
     /* yep, this succeeds */
     ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING, bigCert,
      sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &context);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     ok(context != NULL, "Expected a valid cert context\n");
     if (context)
     {
         ok(context->cbCertEncoded == sizeof(bigCert),
-         "Wrong cert size %d\n", context->cbCertEncoded);
+         "Wrong cert size %ld\n", context->cbCertEncoded);
         ok(!memcmp(context->pbCertEncoded, bigCert, sizeof(bigCert)),
          "Unexpected encoded cert in context\n");
         ok(context->hCertStore == store1, "Unexpected store\n");
         ret = CertDeleteCertificateFromStore(context);
-        ok(ret, "CertDeleteCertificateFromStore failed: %08x\n",
+        ok(ret, "CertDeleteCertificateFromStore failed: %08lx\n",
          GetLastError());
     }
     CertCloseStore(store1, 0);
@@ -309,16 +309,16 @@ static void compareStore(HCERTSTORE store, LPCSTR name, const BYTE *pb,
 
     ret = CertSaveStore(store, X509_ASN_ENCODING, CERT_STORE_SAVE_AS_STORE,
      CERT_STORE_SAVE_TO_MEMORY, &blob, 0);
-    ok(ret, "CertSaveStore failed: %08x\n", GetLastError());
+    ok(ret, "CertSaveStore failed: %08lx\n", GetLastError());
     todo_wine_if (todo)
-        ok(blob.cbData == cb, "%s: expected size %d, got %d\n", name, cb,
+        ok(blob.cbData == cb, "%s: expected size %ld, got %ld\n", name, cb,
          blob.cbData);
     blob.pbData = HeapAlloc(GetProcessHeap(), 0, blob.cbData);
     if (blob.pbData)
     {
         ret = CertSaveStore(store, X509_ASN_ENCODING, CERT_STORE_SAVE_AS_STORE,
          CERT_STORE_SAVE_TO_MEMORY, &blob, 0);
-        ok(ret, "CertSaveStore failed: %08x\n", GetLastError());
+        ok(ret, "CertSaveStore failed: %08lx\n", GetLastError());
         todo_wine_if (todo)
             ok(!memcmp(pb, blob.pbData, cb), "%s: unexpected value\n", name);
         HeapFree(GetProcessHeap(), 0, blob.pbData);
@@ -395,23 +395,23 @@ static void testRegStoreSavedCerts(void)
         err = GetLastError();
         if (!store)
         {
-            ok (err == ERROR_ACCESS_DENIED, "Failed to create store at %d (%08x)\n", i, err);
-            skip("Insufficient privileges for the test %d\n", i);
+            ok (err == ERROR_ACCESS_DENIED, "Failed to create store at %ld (%08lx)\n", i, err);
+            skip("Insufficient privileges for the test %ld\n", i);
             continue;
         }
-        ok (store!=NULL, "Failed to open the store at %d, %x\n", i, GetLastError());
+        ok (store!=NULL, "Failed to open the store at %ld, %lx\n", i, GetLastError());
         cert1 = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert));
-        ok (cert1 != NULL, "Create cert context failed at %d, %x\n", i, GetLastError());
+        ok (cert1 != NULL, "Create cert context failed at %ld, %lx\n", i, GetLastError());
         ret = CertAddCertificateContextToStore(store, cert1, CERT_STORE_ADD_REPLACE_EXISTING, NULL);
         /* Addittional skip per Win7, it allows opening HKLM store, but disallows adding certs */
         err = GetLastError();
         if (!ret)
         {
-            ok (err == ERROR_ACCESS_DENIED, "Failed to add certificate to store at %d (%08x)\n", i, err);
-            skip("Insufficient privileges for the test %d\n", i);
+            ok (err == ERROR_ACCESS_DENIED, "Failed to add certificate to store at %ld (%08lx)\n", i, err);
+            skip("Insufficient privileges for the test %ld\n", i);
             continue;
         }
-        ok (ret, "Adding to the store failed at %d, %x\n", i, err);
+        ok (ret, "Adding to the store failed at %ld, %lx\n", i, err);
         CertFreeCertificateContext(cert1);
         CertCloseStore(store, 0);
 
@@ -421,13 +421,13 @@ static void testRegStoreSavedCerts(void)
         if (!reg_store_saved_certs[i].appdata_file)
         {
             res = RegOpenKeyExW(reg_store_saved_certs[i].key, key_name, 0, KEY_ALL_ACCESS, &key);
-            ok (!res, "The cert hasn't been saved at %d, %x\n", i, GetLastError());
+            ok (!res, "The cert hasn't been saved at %ld, %lx\n", i, GetLastError());
             if (!res) RegCloseKey(key);
         } else
         {
             pathres = SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, 0, appdata_path);
             ok (pathres == S_OK,
-                "Failed to get app data path at %d (%x)\n", pathres, GetLastError());
+                "Failed to get app data path at %ld (%lx)\n", pathres, GetLastError());
             if (pathres == S_OK)
             {
                 PathAppendW(appdata_path, ms_certs);
@@ -438,7 +438,7 @@ static void testRegStoreSavedCerts(void)
                 cert_file = CreateFileW(appdata_path, GENERIC_READ, 0, NULL,
                     OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
                 todo_wine ok (cert_file != INVALID_HANDLE_VALUE,
-                        "Cert was not saved in AppData at %d (%x)\n", i, GetLastError());
+                        "Cert was not saved in AppData at %ld (%lx)\n", i, GetLastError());
                 CloseHandle(cert_file);
             }
         }
@@ -446,24 +446,24 @@ static void testRegStoreSavedCerts(void)
         /* deleting cert from store */
         store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0,
             reg_store_saved_certs[i].cert_store, reg_store_saved_certs[i].store_name);
-        ok (store!=NULL, "Failed to open the store at %d, %x\n", i, GetLastError());
+        ok (store!=NULL, "Failed to open the store at %ld, %lx\n", i, GetLastError());
 
         cert1 = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert));
-        ok (cert1 != NULL, "Create cert context failed at %d, %x\n", i, GetLastError());
+        ok (cert1 != NULL, "Create cert context failed at %ld, %lx\n", i, GetLastError());
 
         cert2 = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0,
             CERT_FIND_EXISTING, cert1, NULL);
-        ok (cert2 != NULL, "Failed to find cert in the store at %d, %x\n", i, GetLastError());
+        ok (cert2 != NULL, "Failed to find cert in the store at %ld, %lx\n", i, GetLastError());
 
         ret = CertDeleteCertificateFromStore(cert2);
-        ok (ret, "Failed to delete certificate from store at %d, %x\n", i, GetLastError());
+        ok (ret, "Failed to delete certificate from store at %ld, %lx\n", i, GetLastError());
 
         CertFreeCertificateContext(cert1);
         CertFreeCertificateContext(cert2);
         CertCloseStore(store, 0);
 
         res = RegOpenKeyExW(reg_store_saved_certs[i].key, key_name, 0, KEY_ALL_ACCESS, &key);
-        ok (res, "The cert's registry entry should be absent at %i, %x\n", i, GetLastError());
+        ok (res, "The cert's registry entry should be absent at %li, %lx\n", i, GetLastError());
         if (!res) RegCloseKey(key);
 
         if (reg_store_saved_certs[i].appdata_file)
@@ -471,7 +471,7 @@ static void testRegStoreSavedCerts(void)
             cert_file = CreateFileW(appdata_path, GENERIC_READ, 0, NULL,
                 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
             ok (cert_file == INVALID_HANDLE_VALUE,
-                "Cert should have been absent in AppData %d\n", i);
+                "Cert should have been absent in AppData %ld\n", i);
 
             CloseHandle(cert_file);
         }
@@ -493,30 +493,30 @@ static void testStoresInCollection(void)
 
     collection = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0,
         CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(collection != NULL, "Failed to init collection store, last error %x\n", GetLastError());
+    ok(collection != NULL, "Failed to init collection store, last error %lx\n", GetLastError());
     /* Add read-only store to collection with very high priority*/
     ro_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0,
         CERT_SYSTEM_STORE_CURRENT_USER, WineTestRO_W);
-    ok(ro_store != NULL, "Failed to init ro store %x\n", GetLastError());
+    ok(ro_store != NULL, "Failed to init ro store %lx\n", GetLastError());
 
     ret = CertAddStoreToCollection(collection, ro_store, 0, 1000);
-    ok (ret, "Failed to add read-only store to collection %x\n", GetLastError());
+    ok (ret, "Failed to add read-only store to collection %lx\n", GetLastError());
 
     cert1 = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert));
-    ok (cert1 != NULL, "Create cert context failed %x\n", GetLastError());
+    ok (cert1 != NULL, "Create cert context failed %lx\n", GetLastError());
     ret = CertAddCertificateContextToStore(collection, cert1, CERT_STORE_ADD_ALWAYS, NULL);
-    ok (!ret, "Added cert to collection with single read-only store %x\n", GetLastError());
+    ok (!ret, "Added cert to collection with single read-only store %lx\n", GetLastError());
 
     /* Add read-write store to collection with the lowest priority*/
     rw_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0,
         CERT_SYSTEM_STORE_CURRENT_USER, WineTestRW_W);
-    ok (rw_store != NULL, "Failed to open rw store %x\n", GetLastError());
+    ok (rw_store != NULL, "Failed to open rw store %lx\n", GetLastError());
     ret = CertAddStoreToCollection(collection, rw_store, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0);
-    ok (ret, "Failed to add rw store to collection %x\n", GetLastError());
+    ok (ret, "Failed to add rw store to collection %lx\n", GetLastError());
     /** Adding certificate to collection should fall into rw store,
      *  even though prioirty of the ro_store is higher */
     ret = CertAddCertificateContextToStore(collection, cert1, CERT_STORE_ADD_REPLACE_EXISTING, NULL);
-    ok (ret, "Failed to add cert to the collection %x\n", GetLastError());
+    ok (ret, "Failed to add cert to the collection %lx\n", GetLastError());
 
     tcert1 = CertEnumCertificatesInStore(ro_store, NULL);
     ok (!tcert1, "Read-only ro_store contains cert\n");
@@ -534,14 +534,14 @@ static void testStoresInCollection(void)
     /** adding one more rw store with higher priority*/
     rw_store_2 = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, 0,
         CERT_SYSTEM_STORE_CURRENT_USER, WineTestRW2_W);
-    ok (rw_store_2 != NULL, "Failed to init second rw store %x\n", GetLastError());
+    ok (rw_store_2 != NULL, "Failed to init second rw store %lx\n", GetLastError());
     ret = CertAddStoreToCollection(collection, rw_store_2, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 50);
-    ok (ret, "Failed to add rw_store_2 to collection %x\n",GetLastError());
+    ok (ret, "Failed to add rw_store_2 to collection %lx\n",GetLastError());
 
     cert2 = CertCreateCertificateContext(X509_ASN_ENCODING, signedBigCert, sizeof(signedBigCert));
-    ok (cert2 != NULL, "Failed to create cert context %x\n", GetLastError());
+    ok (cert2 != NULL, "Failed to create cert context %lx\n", GetLastError());
     ret = CertAddCertificateContextToStore(collection, cert2, CERT_STORE_ADD_REPLACE_EXISTING, NULL);
-    ok (ret, "Failed to add cert2 to the store %x\n",GetLastError());
+    ok (ret, "Failed to add cert2 to the store %lx\n",GetLastError());
 
     /** checking certificates in the stores */
     tcert1 = CertEnumCertificatesInStore(ro_store, 0);
@@ -560,12 +560,12 @@ static void testStoresInCollection(void)
     /** checking certificates in the collection */
     tcert1 = CertEnumCertificatesInStore(collection, NULL);
     ok (tcert1 && tcert1->cbCertEncoded == cert2->cbCertEncoded,
-        "cert2 expected in the collection got %p, %x\n",tcert1, GetLastError());
+        "cert2 expected in the collection got %p, %lx\n",tcert1, GetLastError());
     tcert1 = CertEnumCertificatesInStore(collection, tcert1);
     ok (tcert1 && tcert1->cbCertEncoded == cert1->cbCertEncoded,
-        "cert1 expected in the collection got %p, %x\n",tcert1, GetLastError());
+        "cert1 expected in the collection got %p, %lx\n",tcert1, GetLastError());
     tcert1 = CertEnumCertificatesInStore(collection, tcert1);
-    ok (tcert1==NULL,"Unexpected cert in the collection %p %x\n",tcert1, GetLastError());
+    ok (tcert1==NULL,"Unexpected cert in the collection %p %lx\n",tcert1, GetLastError());
 
     /* checking whether certs had been saved */
     tstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W,0,0,
@@ -636,17 +636,17 @@ static void testCollectionStore(void)
     ret = CertAddEncodedCertificateToStore(collection, X509_ASN_ENCODING,
      bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL);
     ok(!ret && GetLastError() == E_ACCESSDENIED,
-     "Expected E_ACCESSDENIED, got %08x\n", GetLastError());
+     "Expected E_ACCESSDENIED, got %08lx\n", GetLastError());
 
     /* Create and add a cert to a memory store */
     store1 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
     ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING,
      bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     /* Add the memory store to the collection, without allowing adding */
     ret = CertAddStoreToCollection(collection, store1, 0, 0);
-    ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError());
+    ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError());
     /* Verify the cert is in the collection */
     context = CertEnumCertificatesInStore(collection, NULL);
     ok(context != NULL, "Expected a valid context\n");
@@ -659,7 +659,7 @@ static void testCollectionStore(void)
     ret = CertAddEncodedCertificateToStore(collection, X509_ASN_ENCODING,
      bigCert2, sizeof(bigCert2), CERT_STORE_ADD_ALWAYS, NULL);
     ok(!ret && GetLastError() == E_ACCESSDENIED,
-     "Expected E_ACCESSDENIED, got %08x\n", GetLastError());
+     "Expected E_ACCESSDENIED, got %08lx\n", GetLastError());
 
     /* Create a new memory store */
     store2 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
@@ -668,7 +668,7 @@ static void testCollectionStore(void)
     ret = CertAddStoreToCollection(store1, store2,
      CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* Try adding some bogus stores */
     /* This crashes in Windows
     ret = pCertAddStoreToCollection(0, store2,
@@ -677,7 +677,7 @@ static void testCollectionStore(void)
     /* This "succeeds"... */
     ret = CertAddStoreToCollection(collection, 0,
      CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0);
-    ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError());
+    ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError());
     /* while this crashes.
     ret = pCertAddStoreToCollection(collection, 1,
      CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0);
@@ -686,11 +686,11 @@ static void testCollectionStore(void)
     /* Add it to the collection, this time allowing adding */
     ret = CertAddStoreToCollection(collection, store2,
      CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0);
-    ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError());
+    ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError());
     /* Check that adding to the collection is allowed */
     ret = CertAddEncodedCertificateToStore(collection, X509_ASN_ENCODING,
      bigCert2, sizeof(bigCert2), CERT_STORE_ADD_ALWAYS, NULL);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     /* Now check that it was actually added to store2 */
     context = CertEnumCertificatesInStore(store2, NULL);
     ok(context != NULL, "Expected a valid context\n");
@@ -708,7 +708,7 @@ static void testCollectionStore(void)
     {
         ok(context->hCertStore == collection, "Unexpected store\n");
         ok(context->cbCertEncoded == sizeof(bigCert),
-         "Wrong size %d\n", context->cbCertEncoded);
+         "Wrong size %ld\n", context->cbCertEncoded);
         ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded),
          "Unexpected cert\n");
         context = CertEnumCertificatesInStore(collection, context);
@@ -717,7 +717,7 @@ static void testCollectionStore(void)
         {
             ok(context->hCertStore == collection, "Unexpected store\n");
             ok(context->cbCertEncoded == sizeof(bigCert2),
-             "Wrong size %d\n", context->cbCertEncoded);
+             "Wrong size %ld\n", context->cbCertEncoded);
             ok(!memcmp(context->pbCertEncoded, bigCert2,
              context->cbCertEncoded), "Unexpected cert\n");
             context = CertEnumCertificatesInStore(collection, context);
@@ -732,7 +732,7 @@ static void testCollectionStore(void)
     {
         ok(context->hCertStore == collection, "Unexpected store\n");
         ok(context->cbCertEncoded == sizeof(bigCert),
-         "Wrong size %d\n", context->cbCertEncoded);
+         "Wrong size %ld\n", context->cbCertEncoded);
         ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded),
          "Unexpected cert\n");
         context = CertEnumCertificatesInStore(collection, context);
@@ -741,7 +741,7 @@ static void testCollectionStore(void)
         {
             ok(context->hCertStore == collection, "Unexpected store\n");
             ok(context->cbCertEncoded == sizeof(bigCert2),
-             "Wrong size %d\n", context->cbCertEncoded);
+             "Wrong size %ld\n", context->cbCertEncoded);
             ok(!memcmp(context->pbCertEncoded, bigCert2,
              context->cbCertEncoded), "Unexpected cert\n");
             context = CertEnumCertificatesInStore(collection, context);
@@ -754,7 +754,7 @@ static void testCollectionStore(void)
      CERT_STORE_CREATE_NEW_FLAG, NULL);
     ret = CertAddStoreToCollection(collection2, collection,
      CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0);
-    ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError());
+    ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError());
     /* check the contents of collection2 */
     context = CertEnumCertificatesInStore(collection2, NULL);
     ok(context != NULL, "Expected a valid context\n");
@@ -762,7 +762,7 @@ static void testCollectionStore(void)
     {
         ok(context->hCertStore == collection2, "Unexpected store\n");
         ok(context->cbCertEncoded == sizeof(bigCert),
-         "Wrong size %d\n", context->cbCertEncoded);
+         "Wrong size %ld\n", context->cbCertEncoded);
         ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded),
          "Unexpected cert\n");
         context = CertEnumCertificatesInStore(collection2, context);
@@ -771,7 +771,7 @@ static void testCollectionStore(void)
         {
             ok(context->hCertStore == collection2, "Unexpected store\n");
             ok(context->cbCertEncoded == sizeof(bigCert2),
-             "Wrong size %d\n", context->cbCertEncoded);
+             "Wrong size %ld\n", context->cbCertEncoded);
             ok(!memcmp(context->pbCertEncoded, bigCert2,
              context->cbCertEncoded), "Unexpected cert\n");
             context = CertEnumCertificatesInStore(collection2, context);
@@ -797,25 +797,25 @@ static void testCollectionStore(void)
     /* Add the same cert to two memory stores, then put them in a collection */
     store1 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(store1 != 0, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store1 != 0, "CertOpenStore failed: %08lx\n", GetLastError());
     store2 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(store2 != 0, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store2 != 0, "CertOpenStore failed: %08lx\n", GetLastError());
 
     ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING,
      bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     ret = CertAddEncodedCertificateToStore(store2, X509_ASN_ENCODING,
      bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     collection = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(collection != 0, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(collection != 0, "CertOpenStore failed: %08lx\n", GetLastError());
 
     ret = CertAddStoreToCollection(collection, store1, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0);
-    ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError());
+    ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError());
     ret = CertAddStoreToCollection(collection, store2, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0);
-    ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError());
+    ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError());
 
     /* Check that the collection has two copies of the same cert */
     context = CertEnumCertificatesInStore(collection, NULL);
@@ -824,7 +824,7 @@ static void testCollectionStore(void)
     {
         ok(context->hCertStore == collection, "Unexpected store\n");
         ok(context->cbCertEncoded == sizeof(bigCert),
-         "Wrong size %d\n", context->cbCertEncoded);
+         "Wrong size %ld\n", context->cbCertEncoded);
         ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded),
          "Unexpected cert\n");
         context = CertEnumCertificatesInStore(collection, context);
@@ -833,7 +833,7 @@ static void testCollectionStore(void)
         {
             ok(context->hCertStore == collection, "Unexpected store\n");
             ok(context->cbCertEncoded == sizeof(bigCert),
-             "Wrong size %d\n", context->cbCertEncoded);
+             "Wrong size %ld\n", context->cbCertEncoded);
             ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded),
              "Unexpected cert\n");
             context = CertEnumCertificatesInStore(collection, context);
@@ -873,7 +873,7 @@ static void testCollectionStore(void)
         {
             ok(context->hCertStore == collection, "Unexpected store\n");
             ok(context->cbCertEncoded == sizeof(bigCert),
-             "Wrong size %d\n", context->cbCertEncoded);
+             "Wrong size %ld\n", context->cbCertEncoded);
             ok(!memcmp(context->pbCertEncoded, bigCert, context->cbCertEncoded),
              "Unexpected cert\n");
         }
@@ -891,13 +891,13 @@ static void testCollectionStore(void)
     SetLastError(0xdeadbeef);
     CertRemoveStoreFromCollection(store2, collection);
     ok(GetLastError() == 0xdeadbeef,
-       "Didn't expect an error to be set: %08x\n", GetLastError());
+       "Didn't expect an error to be set: %08lx\n", GetLastError());
 
     /* After removing store2, the collection should be empty */
     SetLastError(0xdeadbeef);
     CertRemoveStoreFromCollection(collection, store2);
     ok(GetLastError() == 0xdeadbeef,
-       "Didn't expect an error to be set: %08x\n", GetLastError());
+       "Didn't expect an error to be set: %08lx\n", GetLastError());
     context = CertEnumCertificatesInStore(collection, NULL);
     ok(!context, "Unexpected cert\n");
 
@@ -913,14 +913,14 @@ static void testCollectionStore(void)
 
     ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING,
      bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &context);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     CertDeleteCertificateFromStore(context);
 
     CertAddStoreToCollection(collection, store1, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0);
 
     ret = CertAddEncodedCertificateToStore(collection, X509_ASN_ENCODING,
      bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &context);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", GetLastError());
     CertDeleteCertificateFromStore(context);
 
     CertCloseStore(collection, 0);
@@ -932,7 +932,7 @@ static void testCollectionStore(void)
 
     SetLastError(0xdeadbeef);
     ret = CertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL);
-    ok(ret, "CertControlStore failed: %08x\n", GetLastError());
+    ok(ret, "CertControlStore failed: %08lx\n", GetLastError());
 
     /* Adding a mem store that can't be committed prevents a successful commit.
      */
@@ -942,7 +942,7 @@ static void testCollectionStore(void)
     SetLastError(0xdeadbeef);
     ret = CertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL);
     ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED,
-     "expected ERROR_CALL_NOT_IMPLEMENTED, got %d\n", GetLastError());
+     "expected ERROR_CALL_NOT_IMPLEMENTED, got %ld\n", GetLastError());
     CertRemoveStoreFromCollection(collection, store1);
     CertCloseStore(store1, 0);
 
@@ -960,14 +960,14 @@ static void testCollectionStore(void)
 
     store1 = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
      CERT_FILE_STORE_COMMIT_ENABLE_FLAG, file);
-    ok(store1 != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store1 != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     CloseHandle(file);
     CertAddStoreToCollection(collection, store1, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0);
     CertCloseStore(store1, 0);
 
     ret = CertAddEncodedCertificateToStore(collection, X509_ASN_ENCODING,
      bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
     ret = CertControlStore(collection, 0, CERT_STORE_CTRL_COMMIT, NULL);
     ok(ret, "CertControlStore failed: %d\n", ret);
@@ -1023,23 +1023,23 @@ static void testRegStore(void)
     store = CertOpenStore(CERT_STORE_PROV_REG, 0, 0, 0, NULL);
     GLE = GetLastError();
     ok(!store && (GLE == ERROR_INVALID_HANDLE || GLE == ERROR_BADKEY),
-     "Expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", GLE);
+     "Expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %ld\n", GLE);
     store = CertOpenStore(CERT_STORE_PROV_REG, 0, 0, 0, key);
     GLE = GetLastError();
     ok(!store && (GLE == ERROR_INVALID_HANDLE || GLE == ERROR_BADKEY),
-     "Expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", GLE);
+     "Expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %ld\n", GLE);
 
     /* Opening up any old key works.. */
     key = HKEY_CURRENT_USER;
     store = CertOpenStore(CERT_STORE_PROV_REG, 0, 0, 0, key);
     /* Not sure if this is a bug in DuplicateHandle, marking todo_wine for now
      */
-    todo_wine ok(store != 0, "CertOpenStore failed: %08x\n", GetLastError());
+    todo_wine ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError());
     CertCloseStore(store, 0);
 
     rc = RegCreateKeyExA(HKEY_CURRENT_USER, tempKey, 0, NULL, 0, KEY_ALL_ACCESS,
      NULL, &key, NULL);
-    ok(!rc, "RegCreateKeyExA failed: %d\n", rc);
+    ok(!rc, "RegCreateKeyExA failed: %ld\n", rc);
     if (key)
     {
         BOOL ret;
@@ -1051,29 +1051,29 @@ static void testRegStore(void)
         PCCERT_CONTEXT context;
 
         store = CertOpenStore(CERT_STORE_PROV_REG, 0, 0, 0, key);
-        ok(store != 0, "CertOpenStore failed: %08x\n", GetLastError());
+        ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError());
         /* Add a certificate.  It isn't persisted right away, since it's only
          * added to the cache..
          */
         ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
          bigCert2, sizeof(bigCert2), CERT_STORE_ADD_ALWAYS, NULL);
-        ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+        ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
          GetLastError());
         /* so flush the cache to force a commit.. */
         ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
-        ok(ret, "CertControlStore failed: %08x\n", GetLastError());
+        ok(ret, "CertControlStore failed: %08lx\n", GetLastError());
         /* and check that the expected subkey was written. */
         size = sizeof(hash);
         ret = CryptHashCertificate(0, 0, 0, bigCert2, sizeof(bigCert2),
          hash, &size);
-        ok(ret, "CryptHashCertificate failed: %d\n", GetLastError());
+        ok(ret, "CryptHashCertificate failed: %ld\n", GetLastError());
         strcpy(subKeyName, certificates);
         for (i = 0, ptr = subKeyName + sizeof(certificates) - 1; i < size;
          i++, ptr += 2)
             sprintf(ptr, "%02X", hash[i]);
         rc = RegCreateKeyExA(key, subKeyName, 0, NULL, 0, KEY_ALL_ACCESS, NULL,
          &subKey, NULL);
-        ok(!rc, "RegCreateKeyExA failed: %d\n", rc);
+        ok(!rc, "RegCreateKeyExA failed: %ld\n", rc);
         if (subKey)
         {
             LPBYTE buf;
@@ -1084,7 +1084,7 @@ static void testRegStore(void)
             if (buf)
             {
                 rc = RegQueryValueExA(subKey, "Blob", NULL, NULL, buf, &size);
-                ok(!rc, "RegQueryValueExA failed: %d\n", rc);
+                ok(!rc, "RegQueryValueExA failed: %ld\n", rc);
                 if (!rc)
                 {
                     const struct CertPropIDHeader *hdr;
@@ -1095,7 +1095,7 @@ static void testRegStore(void)
                     if (hdr)
                     {
                         ok(hdr->cb == sizeof(bigCert2),
-                           "Wrong size %d of cert property\n", hdr->cb);
+                           "Wrong size %ld of cert property\n", hdr->cb);
                         ok(!memcmp((const BYTE *)hdr + sizeof(*hdr), bigCert2,
                          hdr->cb), "Unexpected cert in cert property\n");
                     }
@@ -1104,7 +1104,7 @@ static void testRegStore(void)
                     if (hdr)
                     {
                         ok(hdr->cb == sizeof(hash),
-                           "Wrong size %d of hash property\n", hdr->cb);
+                           "Wrong size %ld of hash property\n", hdr->cb);
                         ok(!memcmp((const BYTE *)hdr + sizeof(*hdr), hash,
                          hdr->cb), "Unexpected hash in cert property\n");
                     }
@@ -1120,7 +1120,7 @@ static void testRegStore(void)
         if (context)
             CertDeleteCertificateFromStore(context);
         ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
-        ok(ret, "CertControlStore failed: %08x\n", GetLastError());
+        ok(ret, "CertControlStore failed: %08lx\n", GetLastError());
 
         /* Add a serialized cert with a bogus hash directly to the registry */
         memset(hash, 0, sizeof(hash));
@@ -1130,7 +1130,7 @@ static void testRegStore(void)
             sprintf(ptr, "%02X", hash[i]);
         rc = RegCreateKeyExA(key, subKeyName, 0, NULL, 0, KEY_ALL_ACCESS, NULL,
          &subKey, NULL);
-        ok(!rc, "RegCreateKeyExA failed: %d\n", rc);
+        ok(!rc, "RegCreateKeyExA failed: %ld\n", rc);
         if (subKey)
         {
             BYTE buf[sizeof(struct CertPropIDHeader) * 2 + sizeof(hash) +
@@ -1154,10 +1154,10 @@ static void testRegStore(void)
 
             rc = RegSetValueExA(subKey, "Blob", 0, REG_BINARY, buf,
              sizeof(buf));
-            ok(!rc, "RegSetValueExA failed: %d\n", rc);
+            ok(!rc, "RegSetValueExA failed: %ld\n", rc);
 
             ret = CertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL);
-            ok(ret, "CertControlStore failed: %08x\n", GetLastError());
+            ok(ret, "CertControlStore failed: %08lx\n", GetLastError());
 
             /* Make sure the bogus hash cert gets loaded. */
             certCount = 0;
@@ -1167,7 +1167,7 @@ static void testRegStore(void)
                 if (context)
                     certCount++;
             } while (context != NULL);
-            ok(certCount == 1, "Expected 1 certificates, got %d\n", certCount);
+            ok(certCount == 1, "Expected 1 certificates, got %ld\n", certCount);
 
             RegCloseKey(subKey);
         }
@@ -1178,14 +1178,14 @@ static void testRegStore(void)
         size = sizeof(hash);
         ret = CryptHashCertificate(0, 0, 0, bigCert2,
          sizeof(bigCert2), hash, &size);
-        ok(ret, "CryptHashCertificate failed: %d\n", GetLastError());
+        ok(ret, "CryptHashCertificate failed: %ld\n", GetLastError());
         strcpy(subKeyName, certificates);
         for (i = 0, ptr = subKeyName + sizeof(certificates) - 1;
          i < sizeof(hash); i++, ptr += 2)
             sprintf(ptr, "%02X", hash[i]);
         rc = RegCreateKeyExA(key, subKeyName, 0, NULL, 0, KEY_ALL_ACCESS, NULL,
          &subKey, NULL);
-        ok(!rc, "RegCreateKeyExA failed: %d\n", rc);
+        ok(!rc, "RegCreateKeyExA failed: %ld\n", rc);
         if (subKey)
         {
             BYTE buf[sizeof(struct CertPropIDHeader) * 2 + sizeof(hash) +
@@ -1211,10 +1211,10 @@ static void testRegStore(void)
 
             rc = RegSetValueExA(subKey, "Blob", 0, REG_BINARY, buf,
              sizeof(buf));
-            ok(!rc, "RegSetValueExA failed: %d\n", rc);
+            ok(!rc, "RegSetValueExA failed: %ld\n", rc);
 
             ret = CertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL);
-            ok(ret, "CertControlStore failed: %08x\n", GetLastError());
+            ok(ret, "CertControlStore failed: %08lx\n", GetLastError());
 
             /* and make sure just one cert still gets loaded. */
             certCount = 0;
@@ -1224,7 +1224,7 @@ static void testRegStore(void)
                 if (context)
                     certCount++;
             } while (context != NULL);
-            ok(certCount == 1, "Expected 1 certificate, got %d\n", certCount);
+            ok(certCount == 1, "Expected 1 certificate, got %ld\n", certCount);
 
             /* Try again with the correct hash... */
             ptr = buf + sizeof(*hdr);
@@ -1232,10 +1232,10 @@ static void testRegStore(void)
 
             rc = RegSetValueExA(subKey, "Blob", 0, REG_BINARY, buf,
              sizeof(buf));
-            ok(!rc, "RegSetValueExA failed: %d\n", rc);
+            ok(!rc, "RegSetValueExA failed: %ld\n", rc);
 
             ret = CertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL);
-            ok(ret, "CertControlStore failed: %08x\n", GetLastError());
+            ok(ret, "CertControlStore failed: %08lx\n", GetLastError());
 
             /* and make sure two certs get loaded. */
             certCount = 0;
@@ -1245,7 +1245,7 @@ static void testRegStore(void)
                 if (context)
                     certCount++;
             } while (context != NULL);
-            ok(certCount == 2, "Expected 2 certificates, got %d\n", certCount);
+            ok(certCount == 2, "Expected 2 certificates, got %ld\n", certCount);
 
             RegCloseKey(subKey);
         }
@@ -1254,7 +1254,7 @@ static void testRegStore(void)
         store = CertOpenStore(CERT_STORE_PROV_REG, 0, 0,
          CERT_STORE_DELETE_FLAG, key);
         ok(store == NULL, "Expected NULL return from CERT_STORE_DELETE_FLAG\n");
-        ok(GetLastError() == 0, "CertOpenStore failed: %08x\n",
+        ok(GetLastError() == 0, "CertOpenStore failed: %08lx\n",
          GetLastError());
 
         RegCloseKey(key);
@@ -1264,9 +1264,9 @@ static void testRegStore(void)
      */
     rc = RegCreateKeyExA(HKEY_CURRENT_USER, tempKey, 0, NULL, 0, KEY_ALL_ACCESS,
      NULL, &key, &disp);
-    ok(!rc, "RegCreateKeyExA failed: %d\n", rc);
+    ok(!rc, "RegCreateKeyExA failed: %ld\n", rc);
     ok(disp == REG_OPENED_EXISTING_KEY,
-     "Expected REG_OPENED_EXISTING_KEY, got %d\n", disp);
+     "Expected REG_OPENED_EXISTING_KEY, got %ld\n", disp);
     if (!rc)
     {
         RegCloseKey(key);
@@ -1307,7 +1307,7 @@ static void testSystemRegStore(void)
     if (memStore)
     {
         BOOL ret = CertAddStoreToCollection(store, memStore, 0, 0);
-        ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError());
+        ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08lx\n", GetLastError());
         CertCloseStore(memStore, 0);
     }
     CertCloseStore(store, 0);
@@ -1316,34 +1316,34 @@ static void testSystemRegStore(void)
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0,
      CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, BogusW);
     ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0,
      CERT_SYSTEM_STORE_CURRENT_USER, BogusW);
-    ok(store != 0, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError());
     if (store)
         CertCloseStore(store, 0);
     /* Now check whether deleting is allowed */
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0,
      CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_DELETE_FLAG, BogusW);
-    ok(!store, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(!store, "CertOpenStore failed: %08lx\n", GetLastError());
     RegDeleteKeyW(HKEY_CURRENT_USER, BogusPathW);
 
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0, 0, NULL);
     ok(!store && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0,
      CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, MyA);
     ok(!store && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0,
      CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, MyW);
     ok(!store && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* The name is expected to be UNICODE, check with an ASCII name */
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0,
      CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, MyA);
     ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
 }
 
 static void testSystemStore(void)
@@ -1356,38 +1356,38 @@ static void testSystemStore(void)
 
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, 0, NULL);
     ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0,
      CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, MyA);
     ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0,
      CERT_SYSTEM_STORE_LOCAL_MACHINE | CERT_SYSTEM_STORE_CURRENT_USER, MyW);
     ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     /* The name is expected to be UNICODE, first check with an ASCII name */
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0,
      CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, MyA);
     ok(!store && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     /* Create the expected key */
     lstrcpyW(keyName, CERT_LOCAL_MACHINE_SYSTEM_STORE_REGPATH);
     lstrcatW(keyName, baskslashW);
     lstrcatW(keyName, MyW);
     rc = RegCreateKeyExW(HKEY_CURRENT_USER, keyName, 0, NULL, 0, KEY_READ,
      NULL, &key, NULL);
-    ok(!rc, "RegCreateKeyEx failed: %d\n", rc);
+    ok(!rc, "RegCreateKeyEx failed: %ld\n", rc);
     if (!rc)
         RegCloseKey(key);
     /* Check opening with a UNICODE name, specifying the create new flag */
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0,
      CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_CREATE_NEW_FLAG, MyW);
     ok(!store && GetLastError() == ERROR_FILE_EXISTS,
-     "Expected ERROR_FILE_EXISTS, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_EXISTS, got %08lx\n", GetLastError());
     /* Now check opening with a UNICODE name, this time opening existing */
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0,
      CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, MyW);
-    ok(store != 0, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError());
     if (store)
     {
         HCERTSTORE memStore = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
@@ -1397,7 +1397,7 @@ static void testSystemStore(void)
         if (memStore)
         {
             BOOL ret = CertAddStoreToCollection(store, memStore, 0, 0);
-            ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError());
+            ok(ret, "CertAddStoreToCollection failed: %08lx\n", GetLastError());
             CertCloseStore(memStore, 0);
         }
         CertCloseStore(store, 0);
@@ -1406,10 +1406,10 @@ static void testSystemStore(void)
     /* Check opening a bogus store */
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0,
      CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, BogusW);
-    ok(!store, "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+    ok(!store, "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0,
      CERT_SYSTEM_STORE_CURRENT_USER, BogusW);
-    ok(store != 0, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError());
     if (store)
         CertCloseStore(store, 0);
     /* Now check whether deleting is allowed */
@@ -1449,7 +1449,7 @@ static void testFileStore(void)
 
     store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, 0, NULL);
     ok(!store && GetLastError() == ERROR_INVALID_HANDLE,
-     "Expected ERROR_INVALID_HANDLE, got %08x\n", GetLastError());
+     "Expected ERROR_INVALID_HANDLE, got %08lx\n", GetLastError());
 
     if (!GetTempFileNameW(szDot, szPrefix, 0, filename))
        return;
@@ -1463,16 +1463,16 @@ static void testFileStore(void)
     store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, CERT_STORE_DELETE_FLAG,
      file);
     ok(!store && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
      CERT_FILE_STORE_COMMIT_ENABLE_FLAG | CERT_STORE_READONLY_FLAG, file);
     ok(!store && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
 
     /* A "read-only" file store.. */
     store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
      CERT_STORE_OPEN_EXISTING_FLAG | CERT_STORE_READONLY_FLAG, file);
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     if (store)
     {
         DWORD size;
@@ -1484,22 +1484,22 @@ static void testFileStore(void)
         /* but not commits.. */
         ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
         ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED,
-         "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError());
+         "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08lx\n", GetLastError());
         /* It still has certs in memory.. */
         cert = CertEnumCertificatesInStore(store, NULL);
-        ok(cert != NULL, "CertEnumCertificatesInStore failed: %08x\n",
+        ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n",
          GetLastError());
         CertFreeCertificateContext(cert);
         /* but the file size is still 0. */
         size = GetFileSize(file, NULL);
-        ok(size == 0, "Expected size 0, got %d\n", size);
+        ok(size == 0, "Expected size 0, got %ld\n", size);
         CertCloseStore(store, 0);
     }
 
     /* The create new flag is allowed.. */
     store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, file);
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     if (store)
     {
         /* but without the commit enable flag, commits don't happen. */
@@ -1508,13 +1508,13 @@ static void testFileStore(void)
         ok(ret, "CertAddEncodedCertificateToStore failed: %d\n", ret);
         ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
         ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED,
-         "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError());
+         "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08lx\n", GetLastError());
         CertCloseStore(store, 0);
     }
     /* as is the open existing flag. */
     store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
      CERT_STORE_OPEN_EXISTING_FLAG, file);
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     if (store)
     {
         /* but without the commit enable flag, commits don't happen. */
@@ -1523,18 +1523,18 @@ static void testFileStore(void)
         ok(ret, "CertAddEncodedCertificateToStore failed: %d\n", ret);
         ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
         ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED,
-         "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError());
+         "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08lx\n", GetLastError());
         CertCloseStore(store, 0);
     }
     store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
      CERT_FILE_STORE_COMMIT_ENABLE_FLAG, file);
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     if (store)
     {
         CloseHandle(file);
         ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
          bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL);
-        ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+        ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
          GetLastError());
         /* with commits enabled, commit is allowed */
         ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL);
@@ -1549,13 +1549,13 @@ static void testFileStore(void)
         return;
     store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
      CERT_FILE_STORE_COMMIT_ENABLE_FLAG, file);
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     if (store)
     {
         CloseHandle(file);
         ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL,
          sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL);
-        ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
+        ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
         compareStore(store, "serialized store with cert and CRL",
          serializedStoreWithCertAndCRL, sizeof(serializedStoreWithCertAndCRL),
          FALSE);
@@ -1656,7 +1656,7 @@ static void testFileNameStore(void)
     store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0, 0, NULL);
     GLE = GetLastError();
     ok(!store && (GLE == ERROR_PATH_NOT_FOUND || GLE == ERROR_INVALID_PARAMETER),
-     "Expected ERROR_PATH_NOT_FOUND or ERROR_INVALID_PARAMETER, got %08x\n",
+     "Expected ERROR_PATH_NOT_FOUND or ERROR_INVALID_PARAMETER, got %08lx\n",
      GLE);
 
     if (!GetTempFileNameW(szDot, szPrefix, 0, filename))
@@ -1667,7 +1667,7 @@ static void testFileNameStore(void)
     store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0,
      CERT_FILE_STORE_COMMIT_ENABLE_FLAG | CERT_STORE_READONLY_FLAG, filename);
     ok(!store && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
 
     /* In all of the following tests, the encoding type seems to be ignored */
     if (initFileFromData(filename, bigCert, sizeof(bigCert)))
@@ -1677,10 +1677,10 @@ static void testFileNameStore(void)
 
         store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0,
          CERT_STORE_READONLY_FLAG, filename);
-        ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+        ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
 
         cert = CertEnumCertificatesInStore(store, NULL);
-        ok(cert != NULL, "CertEnumCertificatesInStore failed: %08x\n",
+        ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n",
          GetLastError());
         cert = CertEnumCertificatesInStore(store, cert);
         ok(!cert, "Expected only one cert\n");
@@ -1698,10 +1698,10 @@ static void testFileNameStore(void)
 
         store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0,
          CERT_STORE_READONLY_FLAG, filename);
-        ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+        ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
 
         cert = CertEnumCertificatesInStore(store, NULL);
-        ok(cert != NULL, "CertEnumCertificatesInStore failed: %08x\n",
+        ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n",
          GetLastError());
         cert = CertEnumCertificatesInStore(store, cert);
         ok(!cert, "Expected only one cert\n");
@@ -1719,15 +1719,15 @@ static void testFileNameStore(void)
 
         store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0,
          CERT_STORE_READONLY_FLAG, filename);
-        ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+        ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
 
         cert = CertEnumCertificatesInStore(store, NULL);
-        ok(cert != NULL, "CertEnumCertificatesInStore failed: %08x\n",
+        ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n",
          GetLastError());
         cert = CertEnumCertificatesInStore(store, cert);
         ok(!cert, "Expected only one cert\n");
         crl = CertEnumCRLsInStore(store, NULL);
-        ok(crl != NULL, "CertEnumCRLsInStore failed: %08x\n", GetLastError());
+        ok(crl != NULL, "CertEnumCRLsInStore failed: %08lx\n", GetLastError());
         crl = CertEnumCRLsInStore(store, crl);
         ok(!crl, "Expected only one CRL\n");
 
@@ -1737,18 +1737,18 @@ static void testFileNameStore(void)
     /* Now that the file exists, we can open it read-only */
     store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0,
      CERT_STORE_READONLY_FLAG, filename);
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     CertCloseStore(store, 0);
     DeleteFileW(filename);
 
     store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0,
      CERT_FILE_STORE_COMMIT_ENABLE_FLAG | CERT_STORE_CREATE_NEW_FLAG, filename);
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     if (store)
     {
         ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
          bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL);
-        ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+        ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
          GetLastError());
         compareStore(store, "serialized store with cert",
          serializedStoreWithCert, sizeof(serializedStoreWithCert), FALSE);
@@ -1756,12 +1756,12 @@ static void testFileNameStore(void)
     }
     store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0,
      CERT_FILE_STORE_COMMIT_ENABLE_FLAG, filename);
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     if (store)
     {
         ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING,
          signedCRL, sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL);
-        ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
+        ok(ret, "CertAddEncodedCRLToStore failed: %08lx\n", GetLastError());
         compareStore(store, "serialized store with cert and CRL",
          serializedStoreWithCertAndCRL, sizeof(serializedStoreWithCertAndCRL),
          FALSE);
@@ -1780,10 +1780,10 @@ static void testFileNameStore(void)
 
         store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0,
          CERT_STORE_READONLY_FLAG, filename);
-        ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+        ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
 
         cert = CertEnumCertificatesInStore(store, NULL);
-        ok(cert != NULL, "CertEnumCertificatesInStore failed: %08x\n",
+        ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n",
          GetLastError());
         cert = CertEnumCertificatesInStore(store, cert);
         ok(!cert, "Expected only one cert\n");
@@ -1801,10 +1801,10 @@ static void testFileNameStore(void)
 
         store = CertOpenStore(CERT_STORE_PROV_FILENAME_W, 0, 0,
          CERT_STORE_READONLY_FLAG, filename);
-        ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+        ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
 
         cert = CertEnumCertificatesInStore(store, NULL);
-        ok(cert != NULL, "CertEnumCertificatesInStore failed: %08x\n",
+        ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n",
          GetLastError());
         cert = CertEnumCertificatesInStore(store, cert);
         ok(!cert, "Expected only one cert\n");
@@ -1882,10 +1882,10 @@ static void testMessageStore(void)
     SetLastError(0xdeadbeef);
     store = CertOpenStore(CERT_STORE_PROV_MSG, 0, 0, 0, msg);
     ok(!store && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     CryptMsgUpdate(msg, signedContent, sizeof(signedContent), TRUE);
     store = CertOpenStore(CERT_STORE_PROV_MSG, 0, 0, 0, msg);
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     if (store)
     {
         PCCERT_CONTEXT cert = NULL;
@@ -1897,7 +1897,7 @@ static void testMessageStore(void)
             if (cert)
                 count++;
         } while (cert);
-        ok(count == 0, "Expected 0 certificates, got %d\n", count);
+        ok(count == 0, "Expected 0 certificates, got %ld\n", count);
 
         count = 0;
         do {
@@ -1905,12 +1905,12 @@ static void testMessageStore(void)
             if (crl)
                 count++;
         } while (crl);
-        ok(count == 0, "Expected 0 CRLs, got %d\n", count);
+        ok(count == 0, "Expected 0 CRLs, got %ld\n", count);
 
         /* Can add certs to a message store */
         ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
          bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL);
-        ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+        ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
          GetLastError());
         count = 0;
         do {
@@ -1918,22 +1918,22 @@ static void testMessageStore(void)
             if (cert)
                 count++;
         } while (cert);
-        ok(count == 1, "Expected 1 certificate, got %d\n", count);
+        ok(count == 1, "Expected 1 certificate, got %ld\n", count);
 
         CertCloseStore(store, 0);
     }
     /* but the added certs weren't actually added to the message */
     size = sizeof(count);
     ret = CryptMsgGetParam(msg, CMSG_CERT_COUNT_PARAM, 0, &count, &size);
-    ok(ret, "CryptMsgGetParam failed: %08x\n", GetLastError());
-    ok(count == 0, "Expected 0 certificates, got %d\n", count);
+    ok(ret, "CryptMsgGetParam failed: %08lx\n", GetLastError());
+    ok(count == 0, "Expected 0 certificates, got %ld\n", count);
     CryptMsgClose(msg);
 
     /* Crashes
     store = CertOpenStore(CERT_STORE_PROV_PKCS7, 0, 0, 0, NULL);
      */
     store = CertOpenStore(CERT_STORE_PROV_PKCS7, 0, 0, 0, &blob);
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     if (store)
     {
         DWORD count = 0;
@@ -1945,7 +1945,7 @@ static void testMessageStore(void)
             if (cert)
                 count++;
         } while (cert);
-        ok(count == 1, "Expected 1 certificate, got %d\n", count);
+        ok(count == 1, "Expected 1 certificate, got %ld\n", count);
 
         count = 0;
         do {
@@ -1953,14 +1953,14 @@ static void testMessageStore(void)
             if (crl)
                 count++;
         } while (crl);
-        ok(count == 1, "Expected 1 CRL, got %d\n", count);
+        ok(count == 1, "Expected 1 CRL, got %ld\n", count);
 
         CertCloseStore(store, 0);
     }
     /* Encoding appears to be ignored */
     store = CertOpenStore(CERT_STORE_PROV_PKCS7, X509_ASN_ENCODING, 0, 0,
      &blob);
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     if (store)
         CertCloseStore(store, 0);
     /* Messages other than signed messages aren't allowed */
@@ -1969,13 +1969,13 @@ static void testMessageStore(void)
     SetLastError(0xdeadbeef);
     store = CertOpenStore(CERT_STORE_PROV_PKCS7, 0, 0, 0, &blob);
     ok(!store && GetLastError() == CRYPT_E_INVALID_MSG_TYPE,
-     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_MSG_TYPE, got %08lx\n", GetLastError());
     blob.cbData = sizeof(hashBareContent);
     blob.pbData = (LPBYTE)hashBareContent;
     SetLastError(0xdeadbeef);
     store = CertOpenStore(CERT_STORE_PROV_PKCS7, 0, 0, 0, &blob);
     ok(!store && GetLastError() == CRYPT_E_ASN1_BADTAG,
-     "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError());
+     "Expected CRYPT_E_ASN1_BADTAG, got %08lx\n", GetLastError());
 }
 
 static void testSerializedStore(void)
@@ -1995,16 +1995,16 @@ static void testSerializedStore(void)
     store = CertOpenStore(CERT_STORE_PROV_SERIALIZED, 0, 0,
      CERT_STORE_DELETE_FLAG, &blob);
     ok(!store && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED,
-     "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError());
+     "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08lx\n", GetLastError());
     store = CertOpenStore(CERT_STORE_PROV_SERIALIZED, 0, 0, 0, &blob);
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     if (store)
     {
         PCCERT_CONTEXT cert;
         PCCRL_CONTEXT crl;
 
         cert = CertEnumCertificatesInStore(store, NULL);
-        ok(cert != NULL, "CertEnumCertificatesInStore failed: %08x\n",
+        ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n",
          GetLastError());
         cert = CertEnumCertificatesInStore(store, cert);
         ok(!cert, "Expected only one cert\n");
@@ -2016,19 +2016,19 @@ static void testSerializedStore(void)
     blob.cbData = sizeof(serializedStoreWithCertAndCRL);
     blob.pbData = (BYTE *)serializedStoreWithCertAndCRL;
     store = CertOpenStore(CERT_STORE_PROV_SERIALIZED, 0, 0, 0, &blob);
-    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     if (store)
     {
         PCCERT_CONTEXT cert;
         PCCRL_CONTEXT crl;
 
         cert = CertEnumCertificatesInStore(store, NULL);
-        ok(cert != NULL, "CertEnumCertificatesInStore failed: %08x\n",
+        ok(cert != NULL, "CertEnumCertificatesInStore failed: %08lx\n",
          GetLastError());
         cert = CertEnumCertificatesInStore(store, cert);
         ok(!cert, "Expected only one cert\n");
         crl = CertEnumCRLsInStore(store, NULL);
-        ok(crl != NULL, "CertEnumCRLsInStore failed: %08x\n",
+        ok(crl != NULL, "CertEnumCRLsInStore failed: %08lx\n",
          GetLastError());
         crl = CertEnumCRLsInStore(store, crl);
         ok(!crl, "Expected only one CRL\n");
@@ -2043,12 +2043,12 @@ static void testCertOpenSystemStore(void)
 
     store = CertOpenSystemStoreW(0, NULL);
     ok(!store && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* This succeeds, and on WinXP at least, the Bogus key is created under
      * HKCU (but not under HKLM, even when run as an administrator.)
      */
     store = CertOpenSystemStoreW(0, BogusW);
-    ok(store != 0, "CertOpenSystemStore failed: %08x\n", GetLastError());
+    ok(store != 0, "CertOpenSystemStore failed: %08lx\n", GetLastError());
     if (store)
         CertCloseStore(store, 0);
     /* Delete it so other tests succeed next time around */
@@ -2095,7 +2095,7 @@ static void testCertRegisterSystemStore(void)
         }
         todo_wine_if (reg_system_store_test_data[i].todo)
             ok (ret == reg_system_store_test_data[i].expected,
-                "Store registration (dwFlags=%08x) failed, last error %x\n", cur_flag, err);
+                "Store registration (dwFlags=%08x) failed, last error %lx\n", cur_flag, err);
         if (!ret)
         {
             skip("Nothing to test without registered store at %08x\n", cur_flag);
@@ -2103,32 +2103,32 @@ static void testCertRegisterSystemStore(void)
         }
 
         hstore = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, CERT_STORE_OPEN_EXISTING_FLAG | cur_flag, WineTestW);
-        ok (hstore != NULL, "Opening just registered store at %08x failed, last error %x\n", cur_flag, GetLastError());
+        ok (hstore != NULL, "Opening just registered store at %08x failed, last error %lx\n", cur_flag, GetLastError());
 
         cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert));
-        ok (cert != NULL, "Failed creating cert at %08x, last error: %x\n", cur_flag, GetLastError());
+        ok (cert != NULL, "Failed creating cert at %08x, last error: %lx\n", cur_flag, GetLastError());
         if (cert)
         {
             ret = CertAddCertificateContextToStore(hstore, cert, CERT_STORE_ADD_NEW, NULL);
-            ok (ret, "Failed to add cert at %08x, last error: %x\n", cur_flag, GetLastError());
+            ok (ret, "Failed to add cert at %08x, last error: %lx\n", cur_flag, GetLastError());
 
             cert2 = CertEnumCertificatesInStore(hstore, NULL);
             ok (cert2 != NULL && cert2->cbCertEncoded == cert->cbCertEncoded,
-                "Unexpected cert encoded size at %08x, last error: %x\n", cur_flag, GetLastError());
+                "Unexpected cert encoded size at %08x, last error: %lx\n", cur_flag, GetLastError());
 
             ret = CertDeleteCertificateFromStore(cert2);
-            ok (ret, "Failed to delete certificate from the new store at %08x, last error: %x\n", cur_flag, GetLastError());
+            ok (ret, "Failed to delete certificate from the new store at %08x, last error: %lx\n", cur_flag, GetLastError());
 
             CertFreeCertificateContext(cert);
         }
 
         ret = CertCloseStore(hstore, 0);
-        ok (ret, "CertCloseStore failed at %08x, last error %x\n", cur_flag, GetLastError());
+        ok (ret, "CertCloseStore failed at %08x, last error %lx\n", cur_flag, GetLastError());
 
         ret = CertUnregisterSystemStore(WineTestW, cur_flag );
         todo_wine_if (reg_system_store_test_data[i].todo)
             ok( ret == reg_system_store_test_data[i].expected,
-                "Unregistering failed at %08x, last error %d\n", cur_flag, GetLastError());
+                "Unregistering failed at %08x, last error %ld\n", cur_flag, GetLastError());
      }
 
 }
@@ -2156,7 +2156,7 @@ static void testCertEnumSystemStore(void)
     SetLastError(0xdeadbeef);
     ret = CertEnumSystemStore(0, NULL, NULL, NULL);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     /* Crashes
     ret = CertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, NULL,
      NULL);
@@ -2174,7 +2174,7 @@ static void testCertEnumSystemStore(void)
     info.storeCount = 0;
     ret = CertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, &info,
      enumSystemStoreCB);
-    ok(ret, "CertEnumSystemStore failed: %08x\n", GetLastError());
+    ok(ret, "CertEnumSystemStore failed: %08lx\n", GetLastError());
     /* There should always be at least My, Root, and CA stores */
     ok(info.storeCount == 0 || info.storeCount >= 3,
      "Expected at least 3 stores\n");
@@ -2199,11 +2199,11 @@ static void testStoreProperty(void)
     SetLastError(0xdeadbeef);
     ret = CertGetStoreProperty(store, 0, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
-     "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
     /* Contrary to MSDN, CERT_ACCESS_STATE_PROP_ID is supported for stores.. */
     size = sizeof(state);
     ret = CertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size);
-    ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08x\n",
+    ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08lx\n",
      GetLastError());
     ok(!state, "Expected a non-persisted store\n");
     /* and CERT_STORE_LOCALIZED_NAME_PROP_ID isn't supported by default. */
@@ -2211,37 +2211,37 @@ static void testStoreProperty(void)
     ret = CertGetStoreProperty(store, CERT_STORE_LOCALIZED_NAME_PROP_ID, NULL,
      &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
-     "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
     /* Delete an arbitrary property on a store */
     ret = CertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, NULL);
-    ok(ret, "CertSetStoreProperty failed: %08x\n", GetLastError());
+    ok(ret, "CertSetStoreProperty failed: %08lx\n", GetLastError());
     /* Set an arbitrary property on a store */
     blob.pbData = (LPBYTE)&state;
     blob.cbData = sizeof(state);
     ret = CertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, &blob);
-    ok(ret, "CertSetStoreProperty failed: %08x\n", GetLastError());
+    ok(ret, "CertSetStoreProperty failed: %08lx\n", GetLastError());
     /* Get an arbitrary property that's been set */
     ret = CertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, NULL, &size);
-    ok(ret, "CertGetStoreProperty failed: %08x\n", GetLastError());
-    ok(size == sizeof(state), "Unexpected data size %d\n", size);
+    ok(ret, "CertGetStoreProperty failed: %08lx\n", GetLastError());
+    ok(size == sizeof(state), "Unexpected data size %ld\n", size);
     ret = CertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, &propID, &size);
-    ok(ret, "CertGetStoreProperty failed: %08x\n", GetLastError());
+    ok(ret, "CertGetStoreProperty failed: %08lx\n", GetLastError());
     ok(propID == state, "CertGetStoreProperty got the wrong value\n");
     /* Delete it again */
     ret = CertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, NULL);
-    ok(ret, "CertSetStoreProperty failed: %08x\n", GetLastError());
+    ok(ret, "CertSetStoreProperty failed: %08lx\n", GetLastError());
     /* And check that it's missing */
     SetLastError(0xdeadbeef);
     ret = CertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, NULL, &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
-     "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
     CertCloseStore(store, 0);
 
     /* Recheck on the My store.. */
     store = CertOpenSystemStoreW(0, MyW);
     size = sizeof(state);
     ret = CertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size);
-    ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08x\n",
+    ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08lx\n",
      GetLastError());
     ok(state, "Expected a persisted store\n");
     SetLastError(0xdeadbeef);
@@ -2249,7 +2249,7 @@ static void testStoreProperty(void)
     ret = CertGetStoreProperty(store, CERT_STORE_LOCALIZED_NAME_PROP_ID, NULL,
      &size);
     ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
-     "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected CRYPT_E_NOT_FOUND, got %08lx\n", GetLastError());
     CertCloseStore(store, 0);
 }
 
@@ -2265,15 +2265,15 @@ static void testAddSerialized(void)
 
     ret = CertAddSerializedElementToStore(0, NULL, 0, 0, 0, 0, NULL, NULL);
     ok(!ret && GetLastError() == ERROR_END_OF_MEDIA,
-     "Expected ERROR_END_OF_MEDIA, got %08x\n", GetLastError());
+     "Expected ERROR_END_OF_MEDIA, got %08lx\n", GetLastError());
 
     store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
-    ok(store != 0, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store != 0, "CertOpenStore failed: %08lx\n", GetLastError());
 
     ret = CertAddSerializedElementToStore(store, NULL, 0, 0, 0, 0, NULL, NULL);
     ok(!ret && GetLastError() == ERROR_END_OF_MEDIA,
-     "Expected ERROR_END_OF_MEDIA, got %08x\n", GetLastError());
+     "Expected ERROR_END_OF_MEDIA, got %08lx\n", GetLastError());
 
     /* Test with an empty property */
     hdr = (struct CertPropIDHeader *)buf;
@@ -2283,71 +2283,71 @@ static void testAddSerialized(void)
     ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0, 0,
      NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* Test with a bad size in property header */
     hdr->cb = sizeof(bigCert) - 1;
     memcpy(buf + sizeof(struct CertPropIDHeader), bigCert, sizeof(bigCert));
     ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0, 0,
      NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     ret = CertAddSerializedElementToStore(store, buf,
      sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0, 0, NULL,
      NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     ret = CertAddSerializedElementToStore(store, buf,
      sizeof(struct CertPropIDHeader) + sizeof(bigCert), CERT_STORE_ADD_NEW,
      0, 0, NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* Kosher size in property header, but no context type */
     hdr->cb = sizeof(bigCert);
     ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0, 0,
      NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     ret = CertAddSerializedElementToStore(store, buf,
      sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0, 0, NULL,
      NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     ret = CertAddSerializedElementToStore(store, buf,
      sizeof(struct CertPropIDHeader) + sizeof(bigCert), CERT_STORE_ADD_NEW,
      0, 0, NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* With a bad context type */
     ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0,
      CERT_STORE_CRL_CONTEXT_FLAG, NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     ret = CertAddSerializedElementToStore(store, buf,
      sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0,
      CERT_STORE_CRL_CONTEXT_FLAG, NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     ret = CertAddSerializedElementToStore(store, buf,
      sizeof(struct CertPropIDHeader) + sizeof(bigCert), CERT_STORE_ADD_NEW,
      0, CERT_STORE_CRL_CONTEXT_FLAG, NULL, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "Expected E_INVALIDARG, got %08x\n", GetLastError());
+     "Expected E_INVALIDARG, got %08lx\n", GetLastError());
     /* Bad unknown field, good type */
     hdr->unknown1 = 2;
     ret = CertAddSerializedElementToStore(store, buf, sizeof(buf), 0, 0,
      CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND got %08lx\n", GetLastError());
     ret = CertAddSerializedElementToStore(store, buf,
      sizeof(struct CertPropIDHeader) + sizeof(bigCert), 0, 0,
      CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND got %08lx\n", GetLastError());
     ret = CertAddSerializedElementToStore(store, buf,
      sizeof(struct CertPropIDHeader) + sizeof(bigCert), CERT_STORE_ADD_NEW,
      0, CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND got %08lx\n", GetLastError());
     /* Most everything okay, but bad add disposition */
     hdr->unknown1 = 1;
     /* This crashes
@@ -2361,13 +2361,13 @@ static void testAddSerialized(void)
     /* Everything okay, but buffer's too big */
     ret = CertAddSerializedElementToStore(store, buf, sizeof(buf),
      CERT_STORE_ADD_NEW, 0, CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL);
-    ok(ret, "CertAddSerializedElementToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddSerializedElementToStore failed: %08lx\n", GetLastError());
     /* Everything okay, check it's not re-added */
     ret = CertAddSerializedElementToStore(store, buf,
      sizeof(struct CertPropIDHeader) + sizeof(bigCert), CERT_STORE_ADD_NEW,
      0, CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL, NULL);
     ok(!ret && GetLastError() == CRYPT_E_EXISTS,
-     "Expected CRYPT_E_EXISTS, got %08x\n", GetLastError());
+     "Expected CRYPT_E_EXISTS, got %08lx\n", GetLastError());
 
     context = CertEnumCertificatesInStore(store, NULL);
     ok(context != NULL, "Expected a cert\n");
@@ -2387,7 +2387,7 @@ static void testAddSerialized(void)
     ret = CertAddSerializedElementToStore(store, buf, sizeof(buf),
      CERT_STORE_ADD_NEW, 0, CERT_STORE_CERTIFICATE_CONTEXT_FLAG, NULL,
      (const void **)&context);
-    ok(ret, "CertAddSerializedElementToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddSerializedElementToStore failed: %08lx\n", GetLastError());
     if (context)
     {
         BYTE hashVal[20], realHash[20];
@@ -2395,10 +2395,10 @@ static void testAddSerialized(void)
 
         ret = CryptHashCertificate(0, 0, 0, bigCert, sizeof(bigCert),
          realHash, &size);
-        ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError());
+        ok(ret, "CryptHashCertificate failed: %08lx\n", GetLastError());
         ret = CertGetCertificateContextProperty(context, CERT_HASH_PROP_ID,
          hashVal, &size);
-        ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
+        ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
          GetLastError());
         ok(!memcmp(hashVal, realHash, size), "Unexpected hash\n");
         CertFreeCertificateContext(context);
@@ -2504,16 +2504,16 @@ static void testAddCertificateLink(void)
     SetLastError(0xdeadbeef);
     ret = CertAddCertificateLinkToStore(store1, NULL, 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
     source = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert,
      sizeof(bigCert));
     SetLastError(0xdeadbeef);
     ret = CertAddCertificateLinkToStore(store1, source, 0, NULL);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
     ret = CertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS,
      NULL);
-    ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError());
     if (0)
     {
         /* Crashes, i.e. the source certificate is dereferenced without
@@ -2528,23 +2528,23 @@ static void testAddCertificateLink(void)
      CERT_STORE_CREATE_NEW_FLAG, NULL);
     ret = CertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS,
      &linked);
-    ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(linked->hCertStore == store1, "unexpected store\n");
         ret = CertSerializeCertificateStoreElement(linked, 0, NULL, &size);
-        ok(ret, "CertSerializeCertificateStoreElement failed: %08x\n",
+        ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n",
          GetLastError());
         buf = HeapAlloc(GetProcessHeap(), 0, size);
         if (buf)
         {
             ret = CertSerializeCertificateStoreElement(linked, 0, buf, &size);
-            ok(ret, "CertSerializeCertificateStoreElement failed: %08x\n",
+            ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n",
              GetLastError());
             /* The serialized linked certificate is identical to the serialized
              * original certificate.
              */
-            ok(size == sizeof(serializedCert), "Wrong size %d\n", size);
+            ok(size == sizeof(serializedCert), "Wrong size %ld\n", size);
             ok(!memcmp(serializedCert, buf, size),
              "Unexpected serialized cert\n");
             HeapFree(GetProcessHeap(), 0, buf);
@@ -2554,19 +2554,19 @@ static void testAddCertificateLink(void)
         blob.cbData = sizeof(WineTestW);
         ret = CertSetCertificateContextProperty(source,
          CERT_FRIENDLY_NAME_PROP_ID, 0, &blob);
-        ok(ret, "CertSetCertificateContextProperty failed: %08x\n",
+        ok(ret, "CertSetCertificateContextProperty failed: %08lx\n",
          GetLastError());
         /* and the linked certificate has the same friendly name. */
         ret = CertGetCertificateContextProperty(linked,
          CERT_FRIENDLY_NAME_PROP_ID, NULL, &size);
-        ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
+        ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
          GetLastError());
         buf = HeapAlloc(GetProcessHeap(), 0, size);
         if (buf)
         {
             ret = CertGetCertificateContextProperty(linked,
              CERT_FRIENDLY_NAME_PROP_ID, buf, &size);
-            ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
+            ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
              GetLastError());
             ok(!lstrcmpW((LPCWSTR)buf, WineTestW),
              "unexpected friendly name\n");
@@ -2591,12 +2591,12 @@ static void testAddCertificateLink(void)
 
     store1 = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
      CERT_FILE_STORE_COMMIT_ENABLE_FLAG, file);
-    ok(store1 != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store1 != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     CloseHandle(file);
 
     ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING,
      bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &source);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
 
     /* Test adding a link to a memory store. */
@@ -2604,12 +2604,12 @@ static void testAddCertificateLink(void)
      CERT_STORE_CREATE_NEW_FLAG, NULL);
     ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS,
      &linked);
-    ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(linked->hCertStore == store2, "unexpected store\n");
         ret = CertSerializeCertificateStoreElement(linked, 0, NULL, &size);
-        ok(ret, "CertSerializeCertificateStoreElement failed: %08x\n",
+        ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n",
          GetLastError());
         buf = HeapAlloc(GetProcessHeap(), 0, size);
         if (buf)
@@ -2618,8 +2618,8 @@ static void testAddCertificateLink(void)
             /* The serialized linked certificate is identical to the serialized
              * original certificate.
              */
-            ok(ret, "CertSerializeCertificateStoreElement failed: %08x\n", GetLastError());
-            ok(size == sizeof(serializedCert), "Wrong size %d\n", size);
+            ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n", GetLastError());
+            ok(size == sizeof(serializedCert), "Wrong size %ld\n", size);
             ok(!memcmp(serializedCert, buf, size),
              "Unexpected serialized cert\n");
             HeapFree(GetProcessHeap(), 0, buf);
@@ -2629,19 +2629,19 @@ static void testAddCertificateLink(void)
         blob.cbData = sizeof(WineTestW);
         ret = CertSetCertificateContextProperty(source,
          CERT_FRIENDLY_NAME_PROP_ID, 0, &blob);
-        ok(ret, "CertSetCertificateContextProperty failed: %08x\n",
+        ok(ret, "CertSetCertificateContextProperty failed: %08lx\n",
          GetLastError());
         /* and the linked certificate has the same friendly name. */
         ret = CertGetCertificateContextProperty(linked,
          CERT_FRIENDLY_NAME_PROP_ID, NULL, &size);
-        ok(ret, "CertGetCertificateContextProperty failed: %08x\n",
+        ok(ret, "CertGetCertificateContextProperty failed: %08lx\n",
          GetLastError());
         buf = HeapAlloc(GetProcessHeap(), 0, size);
         if (buf)
         {
             ret = CertGetCertificateContextProperty(linked,
              CERT_FRIENDLY_NAME_PROP_ID, buf, &size);
-            ok(ret, "CertGetCertificateContextProperty failed: %08x\n", GetLastError());
+            ok(ret, "CertGetCertificateContextProperty failed: %08lx\n", GetLastError());
             ok(!lstrcmpW((LPCWSTR)buf, WineTestW),
              "unexpected friendly name\n");
             HeapFree(GetProcessHeap(), 0, buf);
@@ -2661,29 +2661,29 @@ static void testAddCertificateLink(void)
 
     store2 = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
      CERT_FILE_STORE_COMMIT_ENABLE_FLAG, file);
-    ok(store2 != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store2 != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     CloseHandle(file);
     /* Test adding a link to a file store. */
     ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS,
      &linked);
-    ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(linked->hCertStore == store2, "unexpected store\n");
         ret = CertSerializeCertificateStoreElement(linked, 0, NULL, &size);
-        ok(ret, "CertSerializeCertificateStoreElement failed: %08x\n",
+        ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n",
          GetLastError());
         buf = HeapAlloc(GetProcessHeap(), 0, size);
         if (buf)
         {
             ret = CertSerializeCertificateStoreElement(linked, 0, buf, &size);
-            ok(ret, "CertSerializeCertificateStoreElement failed: %08x\n",
+            ok(ret, "CertSerializeCertificateStoreElement failed: %08lx\n",
              GetLastError());
             /* The serialized linked certificate now contains the friendly
              * name property.
              */
             ok(size == sizeof(serializedCertWithFriendlyName),
-             "Wrong size %d\n", size);
+             "Wrong size %ld\n", size);
             ok(!memcmp(serializedCertWithFriendlyName, buf, size),
              "Unexpected serialized cert\n");
             HeapFree(GetProcessHeap(), 0, buf);
@@ -2709,7 +2709,7 @@ static void testAddCertificateLink(void)
     ret = CertAddCertificateLinkToStore(store1, source, CERT_STORE_ADD_ALWAYS,
      &linked);
     ok(!ret && GetLastError() == E_INVALIDARG,
-     "expected E_INVALIDARG, got %08x\n", GetLastError());
+     "expected E_INVALIDARG, got %08lx\n", GetLastError());
     CertFreeCertificateContext(source);
 
     /* Test adding a link to a file store, where the linked certificate is
@@ -2717,7 +2717,7 @@ static void testAddCertificateLink(void)
      */
     ret = CertAddEncodedCertificateToStore(store1, X509_ASN_ENCODING,
      bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &source);
-    ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n",
+    ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
      GetLastError());
     if (!GetTempFileNameW(szDot, szPrefix, 0, filename1))
        return;
@@ -2730,12 +2730,12 @@ static void testAddCertificateLink(void)
 
     store2 = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0,
      CERT_FILE_STORE_COMMIT_ENABLE_FLAG, file);
-    ok(store2 != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store2 != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     CloseHandle(file);
 
     ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS,
      &linked);
-    ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(linked->hCertStore == store2, "unexpected store\n");
@@ -2755,10 +2755,10 @@ static void testAddCertificateLink(void)
      */
     store2 = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY, 0, 0,
      CERT_SYSTEM_STORE_CURRENT_USER, WineTestW);
-    ok(store2 != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    ok(store2 != NULL, "CertOpenStore failed: %08lx\n", GetLastError());
     ret = CertAddCertificateLinkToStore(store2, source, CERT_STORE_ADD_ALWAYS,
      &linked);
-    ok(ret, "CertAddCertificateLinkToStore failed: %08x\n", GetLastError());
+    ok(ret, "CertAddCertificateLinkToStore failed: %08lx\n", GetLastError());
     if (ret)
     {
         ok(linked->hCertStore == store2, "unexpected store\n");
@@ -2852,10 +2852,10 @@ static void testEmptyStore(void)
     CertFreeCertificateContext(cert3);
 
     res = CertCloseStore(cert->hCertStore, CERT_CLOSE_STORE_CHECK_FLAG);
-    ok(!res && GetLastError() == E_UNEXPECTED, "CertCloseStore returned: %x(%x)\n", res, GetLastError());
+    ok(!res && GetLastError() == E_UNEXPECTED, "CertCloseStore returned: %x(%lx)\n", res, GetLastError());
 
     res = CertCloseStore(cert->hCertStore, 0);
-    ok(!res && GetLastError() == E_UNEXPECTED, "CertCloseStore returned: %x(%x)\n", res, GetLastError());
+    ok(!res && GetLastError() == E_UNEXPECTED, "CertCloseStore returned: %x(%lx)\n", res, GetLastError());
 
     CertFreeCertificateContext(cert2);
 
@@ -2938,7 +2938,7 @@ static void testCloseStore(void)
 
     /* There is still a reference from CTL */
     res = CertCloseStore(store, CERT_CLOSE_STORE_CHECK_FLAG);
-    ok(!res && GetLastError() == CRYPT_E_PENDING_CLOSE, "CertCloseStore returned: %x(%u)\n", res, GetLastError());
+    ok(!res && GetLastError() == CRYPT_E_PENDING_CLOSE, "CertCloseStore returned: %x(%lu)\n", res, GetLastError());
 
     res = CertFreeCTLContext(ctl);
     ok(res, "CertFreeCTLContext failed\n");
@@ -2993,46 +2993,46 @@ static void test_I_UpdateStore(void)
     ret = pI_CertUpdatestore(NULL, store2, 0, 0);
      */
     ret = pI_CertUpdatestore(store1, store2, 0, 0);
-    ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError());
+    ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError());
 
     CertAddEncodedCertificateToStore(store2, X509_ASN_ENCODING, bigCert,
      sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &cert);
     /* I_CertUpdateStore adds the contexts from store2 to store1 */
     ret = pI_CertUpdatestore(store1, store2, 0, 0);
-    ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError());
+    ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError());
     certs = countCertsInStore(store1);
-    ok(certs == 1, "Expected 1 cert, got %d\n", certs);
+    ok(certs == 1, "Expected 1 cert, got %ld\n", certs);
     /* Calling it a second time has no effect */
     ret = pI_CertUpdatestore(store1, store2, 0, 0);
-    ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError());
+    ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError());
     certs = countCertsInStore(store1);
-    ok(certs == 1, "Expected 1 cert, got %d\n", certs);
+    ok(certs == 1, "Expected 1 cert, got %ld\n", certs);
 
     /* The last parameters to I_CertUpdateStore appear to be ignored */
     ret = pI_CertUpdatestore(store1, store2, 1, 0);
-    ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError());
+    ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError());
     ret = pI_CertUpdatestore(store1, store2, 0, 1);
-    ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError());
+    ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError());
 
     CertAddEncodedCRLToStore(store2, X509_ASN_ENCODING, signedCRL,
      sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL);
 
     /* I_CertUpdateStore also adds the CRLs from store2 to store1 */
     ret = pI_CertUpdatestore(store1, store2, 0, 0);
-    ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError());
+    ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError());
     certs = countCertsInStore(store1);
-    ok(certs == 1, "Expected 1 cert, got %d\n", certs);
+    ok(certs == 1, "Expected 1 cert, got %ld\n", certs);
     certs = countCRLsInStore(store1);
-    ok(certs == 1, "Expected 1 CRL, got %d\n", certs);
+    ok(certs == 1, "Expected 1 CRL, got %ld\n", certs);
 
     CertDeleteCertificateFromStore(cert);
     /* If a context is deleted from store2, I_CertUpdateStore deletes it
      * from store1
      */
     ret = pI_CertUpdatestore(store1, store2, 0, 0);
-    ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError());
+    ok(ret, "I_CertUpdateStore failed: %08lx\n", GetLastError());
     certs = countCertsInStore(store1);
-    ok(certs == 0, "Expected 0 certs, got %d\n", certs);
+    ok(certs == 0, "Expected 0 certs, got %ld\n", certs);
 
     CertCloseStore(store1, 0);
     CertCloseStore(store2, 0);
@@ -3295,66 +3295,66 @@ static void test_PFXImportCertStore(void)
     SetLastError( 0xdeadbeef );
     store = PFXImportCertStore( NULL, NULL, 0 );
     ok( store == NULL, "got %p\n", store );
-    ok( GetLastError() == ERROR_INVALID_PARAMETER, "got %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "got %lu\n", GetLastError() );
 
     pfx.pbData = (BYTE *)pfxdata;
     pfx.cbData = sizeof(pfxdata);
     store = PFXImportCertStore( &pfx, NULL, CRYPT_EXPORTABLE|CRYPT_USER_KEYSET|PKCS12_NO_PERSIST_KEY );
-    ok( store != NULL || broken(store == NULL) /* winxp */, "got %u\n", GetLastError() );
+    ok( store != NULL || broken(store == NULL) /* winxp */, "got %lu\n", GetLastError() );
     if (!store) return;
     count = countCertsInStore( store );
-    ok( count == 1, "got %u\n", count );
+    ok( count == 1, "got %lu\n", count );
 
     cert = CertFindCertificateInStore( store, X509_ASN_ENCODING, 0, CERT_FIND_ANY, NULL, NULL );
-    ok( cert != NULL, "got %u\n", GetLastError() );
-    ok( cert->dwCertEncodingType == X509_ASN_ENCODING, "got %u\n", cert->dwCertEncodingType );
+    ok( cert != NULL, "got %lu\n", GetLastError() );
+    ok( cert->dwCertEncodingType == X509_ASN_ENCODING, "got %lu\n", cert->dwCertEncodingType );
     ok( cert->pbCertEncoded != NULL, "pbCertEncoded not set\n" );
-    ok( cert->cbCertEncoded == 1123, "got %u\n", cert->cbCertEncoded );
+    ok( cert->cbCertEncoded == 1123, "got %lu\n", cert->cbCertEncoded );
     ok( cert->pCertInfo != NULL, "pCertInfo not set\n" );
     ok( cert->hCertStore == store, "got %p\n", cert->hCertStore );
 
     info = cert->pCertInfo;
-    ok( info->dwVersion == CERT_V1, "got %u\n", info->dwVersion );
+    ok( info->dwVersion == CERT_V1, "got %lu\n", info->dwVersion );
     ok( !strcmp(info->SignatureAlgorithm.pszObjId, szOID_RSA_SHA256RSA),
         "got \"%s\"\n", info->SignatureAlgorithm.pszObjId );
 
     size = sizeof(key);
     ret = CertGetCertificateContextProperty( cert, CERT_KEY_CONTEXT_PROP_ID, &key, &size );
-    ok( ret, "got %08x\n", GetLastError() );
-    ok( key.cbSize == sizeof(key), "got %u\n", key.cbSize );
+    ok( ret, "got %08lx\n", GetLastError() );
+    ok( key.cbSize == sizeof(key), "got %lu\n", key.cbSize );
     ok( key.hCryptProv, "hCryptProv not set\n" );
-    ok( key.dwKeySpec == AT_KEYEXCHANGE, "got %u\n", key.dwKeySpec );
+    ok( key.dwKeySpec == AT_KEYEXCHANGE, "got %lu\n", key.dwKeySpec );
 
     size = sizeof(buf);
     SetLastError( 0xdeadbeef );
     ret = CertGetCertificateContextProperty( cert, CERT_KEY_PROV_INFO_PROP_ID, keyprov, &size );
-    ok( !ret && GetLastError() == CRYPT_E_NOT_FOUND, "got %08x\n", GetLastError() );
+    ok( !ret && GetLastError() == CRYPT_E_NOT_FOUND, "got %08lx\n", GetLastError() );
     CertFreeCertificateContext( cert );
     CertCloseStore( store, 0 );
 
     /* without PKCS12_NO_PERSIST_KEY */
     store = PFXImportCertStore( &pfx, NULL, CRYPT_EXPORTABLE|CRYPT_USER_KEYSET );
-    ok( store != NULL, "got %u\n", GetLastError() );
+    ok( store != NULL, "got %lu\n", GetLastError() );
 
     cert = CertFindCertificateInStore( store, X509_ASN_ENCODING, 0, CERT_FIND_ANY, NULL, NULL );
-    ok( cert != NULL, "got %08x\n", GetLastError() );
+    ok( cert != NULL, "got %08lx\n", GetLastError() );
 
     size = sizeof(key);
     ret = CertGetCertificateContextProperty( cert, CERT_KEY_CONTEXT_PROP_ID, &key, &size );
-    ok( !ret && GetLastError() == CRYPT_E_NOT_FOUND, "got %08x\n", GetLastError() );
+    ok( !ret && GetLastError() == CRYPT_E_NOT_FOUND, "got %08lx\n", GetLastError() );
 
     size = sizeof(buf);
     ret = CertGetCertificateContextProperty( cert, CERT_KEY_PROV_INFO_PROP_ID, buf, &size );
-    ok(ret, "got %u\n", GetLastError());
+    ok(ret, "got %lu\n", GetLastError());
     CertFreeCertificateContext( cert );
     CertCloseStore( store, 0 );
 
     /* CRYPT_MACHINE_KEYSET */
     store = PFXImportCertStore( &pfx, NULL, CRYPT_MACHINE_KEYSET );
-    ok( store != NULL, "got %u\n", GetLastError() );
+    ok( store != NULL, "got %lu\n", GetLastError() );
 
     cert = CertFindCertificateInStore( store, X509_ASN_ENCODING, 0, CERT_FIND_ANY, NULL, NULL );
-    ok( cert != NULL, "got %08x\n", GetLastError() );
+    ok( cert != NULL, "got %08lx\n", GetLastError() );
 
     CertFreeCertificateContext( cert );
     CertCloseStore( store, 0 );
@@ -3373,7 +3373,7 @@ static void test_CryptQueryObject(void)
     ret = CryptQueryObject( CERT_QUERY_OBJECT_BLOB, NULL, CERT_QUERY_CONTENT_FLAG_ALL,
                             CERT_QUERY_FORMAT_FLAG_BINARY, 0, NULL, NULL, NULL, NULL, NULL, NULL );
     ok( !ret, "success\n" );
-    ok( GetLastError() == E_INVALIDARG, "got %u\n", GetLastError() );
+    ok( GetLastError() == E_INVALIDARG, "got %lu\n", GetLastError() );
 
     pfx.pbData = (BYTE *)pfxdata;
     pfx.cbData = sizeof(pfxdata);
@@ -3384,10 +3384,10 @@ static void test_CryptQueryObject(void)
     ret = CryptQueryObject( CERT_QUERY_OBJECT_BLOB, &pfx, CERT_QUERY_CONTENT_FLAG_ALL,
                             CERT_QUERY_FORMAT_FLAG_BINARY, 0, &encoding_type, &content_type, &format_type,
                             &store, &msg, &ctx );
-    ok( ret, "got %u\n", GetLastError() );
-    ok( encoding_type == X509_ASN_ENCODING, "got %08x\n", encoding_type );
-    ok( content_type == CERT_QUERY_CONTENT_PFX, "got %08x\n", content_type );
-    ok( format_type == CERT_QUERY_FORMAT_BINARY, "got %08x\n", format_type );
+    ok( ret, "got %lu\n", GetLastError() );
+    ok( encoding_type == X509_ASN_ENCODING, "got %08lx\n", encoding_type );
+    ok( content_type == CERT_QUERY_CONTENT_PFX, "got %08lx\n", content_type );
+    ok( format_type == CERT_QUERY_FORMAT_BINARY, "got %08lx\n", format_type );
     ok( store == NULL, "got %p\n", store );
     ok( msg == NULL, "got %p\n", msg );
     ok( ctx == NULL, "got %p\n", ctx );
diff --git a/dlls/crypt32/tests/str.c b/dlls/crypt32/tests/str.c
index d382c0e6b09..c99b5e35a91 100644
--- a/dlls/crypt32/tests/str.c
+++ b/dlls/crypt32/tests/str.c
@@ -256,7 +256,7 @@ static void test_CertRDNValueToStrA(void)
          buffer, sizeof(buffer));
         todo_wine_if (attrs[i].todo)
         {
-            ok(ret == strlen(attrs[i].str) + 1, "Expected length %d, got %d\n",
+            ok(ret == strlen(attrs[i].str) + 1, "Expected length %d, got %ld\n",
              lstrlenA(attrs[i].str) + 1, ret);
             ok(!strcmp(buffer, attrs[i].str), "Expected %s, got %s\n",
              attrs[i].str, buffer);
@@ -267,7 +267,7 @@ static void test_CertRDNValueToStrA(void)
     ret = pCertRDNValueToStrA(CERT_RDN_UTF8_STRING, &blob, buffer,
      sizeof(buffer));
     ok(ret == strlen(ePKI) + 1 || broken(ret != strlen(ePKI) + 1),
-     "Expected length %d, got %d\n", lstrlenA(ePKI), ret);
+     "Expected length %d, got %ld\n", lstrlenA(ePKI), ret);
     if (ret == strlen(ePKI) + 1)
         ok(!strcmp(buffer, ePKI), "Expected %s, got %s\n", ePKI, buffer);
 }
@@ -351,7 +351,7 @@ static void test_CertRDNValueToStrW(void)
         todo_wine_if (attrs[i].todo)
         {
             ok(ret == lstrlenW(attrs[i].str) + 1,
-             "Expected length %d, got %d\n", lstrlenW(attrs[i].str) + 1, ret);
+             "Expected length %d, got %ld\n", lstrlenW(attrs[i].str) + 1, ret);
             ok(!lstrcmpW(buffer, attrs[i].str), "Expected %s, got %s\n",
              wine_dbgstr_w(attrs[i].str), wine_dbgstr_w(buffer));
         }
@@ -361,7 +361,7 @@ static void test_CertRDNValueToStrW(void)
     ret = pCertRDNValueToStrW(CERT_RDN_UTF8_STRING, &blob, buffer,
      sizeof(buffer));
     ok(ret == lstrlenW(ePKIW) + 1 || broken(ret != lstrlenW(ePKIW) + 1),
-     "Expected length %d, got %d\n", lstrlenW(ePKIW), ret);
+     "Expected length %d, got %ld\n", lstrlenW(ePKIW), ret);
     if (ret == lstrlenW(ePKIW) + 1)
         ok(!lstrcmpW(buffer, ePKIW), "Expected %s, got %s\n",
          wine_dbgstr_w(ePKIW), wine_dbgstr_w(buffer));
@@ -375,12 +375,12 @@ static void test_NameToStrConversionA(PCERT_NAME_BLOB pName, DWORD dwStrType,
 
     i = pCertNameToStrA(X509_ASN_ENCODING, pName, dwStrType, NULL, 0);
     todo_wine_if (todo)
-        ok(i == strlen(expected) + 1, "Expected %d chars, got %d\n",
+        ok(i == strlen(expected) + 1, "Expected %d chars, got %ld\n",
          lstrlenA(expected) + 1, i);
     i = pCertNameToStrA(X509_ASN_ENCODING,pName, dwStrType, buffer,
      sizeof(buffer));
     todo_wine_if (todo)
-        ok(i == strlen(expected) + 1, "Expected %d chars, got %d\n",
+        ok(i == strlen(expected) + 1, "Expected %d chars, got %ld\n",
          lstrlenA(expected) + 1, i);
     todo_wine_if (todo)
         ok(!strcmp(buffer, expected), "Expected %s, got %s\n", expected,
@@ -441,7 +441,7 @@ static void test_CertNameToStrA(void)
 
     context = CertCreateCertificateContext(X509_ASN_ENCODING, cert,
      sizeof(cert));
-    ok(context != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
     if (context)
     {
@@ -454,13 +454,13 @@ static void test_CertNameToStrA(void)
         SetLastError(0xdeadbeef);
         ret = pCertNameToStrA(0, &context->pCertInfo->Issuer, 0, NULL, 0);
         ok(ret == 1 && GetLastError() == ERROR_FILE_NOT_FOUND,
-         "Expected retval 1 and ERROR_FILE_NOT_FOUND, got %d - %08x\n",
+         "Expected retval 1 and ERROR_FILE_NOT_FOUND, got %ld - %08lx\n",
          ret, GetLastError());
         SetLastError(0xdeadbeef);
         ret = pCertNameToStrA(X509_ASN_ENCODING, &context->pCertInfo->Issuer,
          0, NULL, 0);
         ok(ret && GetLastError() == ERROR_SUCCESS,
-         "Expected positive return and ERROR_SUCCESS, got %d - %08x\n",
+         "Expected positive return and ERROR_SUCCESS, got %ld - %08lx\n",
          ret, GetLastError());
 
         test_NameToStrConversionA(&context->pCertInfo->Issuer,
@@ -546,11 +546,11 @@ static void test_NameToStrConversionW(PCERT_NAME_BLOB pName, DWORD dwStrType,
 
     i = pCertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, NULL, 0);
     todo_wine_if (todo)
-        ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %d\n",
+        ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %ld\n",
          lstrlenW(expected) + 1, i);
     i = pCertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, buffer, ARRAY_SIZE(buffer));
     todo_wine_if (todo)
-        ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %d\n",
+        ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %ld\n",
          lstrlenW(expected) + 1, i);
     todo_wine_if (todo)
         ok(!lstrcmpW(buffer, expected), "Expected %s, got %s\n",
@@ -594,7 +594,7 @@ static void test_CertNameToStrW(void)
 
     context = CertCreateCertificateContext(X509_ASN_ENCODING, cert,
      sizeof(cert));
-    ok(context != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
     if (context)
     {
@@ -607,13 +607,13 @@ static void test_CertNameToStrW(void)
         SetLastError(0xdeadbeef);
         ret = pCertNameToStrW(0, &context->pCertInfo->Issuer, 0, NULL, 0);
         ok(ret == 1 && GetLastError() == ERROR_FILE_NOT_FOUND,
-         "Expected retval 1 and ERROR_FILE_NOT_FOUND, got %d - %08x\n",
+         "Expected retval 1 and ERROR_FILE_NOT_FOUND, got %ld - %08lx\n",
          ret, GetLastError());
         SetLastError(0xdeadbeef);
         ret = pCertNameToStrW(X509_ASN_ENCODING, &context->pCertInfo->Issuer,
          0, NULL, 0);
         ok(ret && GetLastError() == ERROR_SUCCESS,
-         "Expected positive return and ERROR_SUCCESS, got %d - %08x\n",
+         "Expected positive return and ERROR_SUCCESS, got %ld - %08lx\n",
          ret, GetLastError());
 
         test_NameToStrConversionW(&context->pCertInfo->Issuer,
@@ -746,61 +746,61 @@ static void test_CertStrToNameA(void)
     ok(!ret, "Expected failure\n");
     ret = pCertStrToNameA(0, "bogus", 0, NULL, NULL, &size, NULL);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
-     "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
     ret = pCertStrToNameA(0, "foo=1", 0, NULL, NULL, &size, NULL);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
-     "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
     ret = pCertStrToNameA(0, "CN=1", 0, NULL, NULL, &size, NULL);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1", 0, NULL, NULL, &size, NULL);
-    ok(ret, "CertStrToNameA failed: %08x\n", GetLastError());
+    ok(ret, "CertStrToNameA failed: %08lx\n", GetLastError());
     size = sizeof(buf);
     ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=\"\"1\"\"", 0, NULL, buf, &size,
      NULL);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
-     "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
     ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1+2", 0, NULL, buf,
      &size, NULL);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
-     "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
     ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1+2", CERT_NAME_STR_NO_PLUS_FLAG, NULL, buf,
                           &size, NULL);
     ok(ret && GetLastError() == ERROR_SUCCESS,
-                 "Expected ERROR_SUCCESS, got %08x\n", GetLastError());
+                 "Expected ERROR_SUCCESS, got %08lx\n", GetLastError());
     ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=1,2", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf,
                           &size, NULL);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
-                 "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
+                 "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
     ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=\"1,2;3,4\"", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf,
                           &size, NULL);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
-                 "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
+                 "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
     ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=abc", 0, NULL, buf,
                           &size, NULL);
     ok(ret && GetLastError() == ERROR_SUCCESS,
-                 "Expected ERROR_SUCCESS, got %08x\n", GetLastError());
+                 "Expected ERROR_SUCCESS, got %08lx\n", GetLastError());
     ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=abc", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf,
                           &size, NULL);
     ok(ret && GetLastError() == ERROR_SUCCESS,
-                 "Expected ERROR_SUCCESS, got %08x\n", GetLastError());
+                 "Expected ERROR_SUCCESS, got %08lx\n", GetLastError());
     ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=\"abc\"", 0, NULL, buf,
                           &size, NULL);
     ok(ret && GetLastError() == ERROR_SUCCESS,
-                 "Expected ERROR_SUCCESS, got %08x\n", GetLastError());
+                 "Expected ERROR_SUCCESS, got %08lx\n", GetLastError());
     ret = pCertStrToNameA(X509_ASN_ENCODING, "CN=\"abc\"", CERT_NAME_STR_NO_QUOTING_FLAG, NULL, buf,
                           &size, NULL);
     ok(!ret && GetLastError() == ERROR_MORE_DATA,
-                 "Expected ERROR_MORE_DATA, got %08x\n", GetLastError());
+                 "Expected ERROR_MORE_DATA, got %08lx\n", GetLastError());
     for (i = 0; i < ARRAY_SIZE(namesA); i++)
     {
         size = sizeof(buf);
         ret = pCertStrToNameA(X509_ASN_ENCODING, namesA[i].x500, 0, NULL, buf,
          &size, NULL);
-        ok(ret, "CertStrToNameA failed on string %s: %08x\n", namesA[i].x500,
+        ok(ret, "CertStrToNameA failed on string %s: %08lx\n", namesA[i].x500,
          GetLastError());
         ok(size == namesA[i].encodedSize,
-         "Expected size %d, got %d\n", namesA[i].encodedSize, size);
+         "Expected size %ld, got %ld\n", namesA[i].encodedSize, size);
         if (ret)
             ok(!memcmp(buf, namesA[i].encoded, namesA[i].encodedSize),
              "Unexpected value for string %s\n", namesA[i].x500);
@@ -866,38 +866,38 @@ static void test_CertStrToNameW(void)
     ok(!ret, "Expected failure\n");
     ret = pCertStrToNameW(0, bogusW, 0, NULL, NULL, &size, NULL);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
-     "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
     ret = pCertStrToNameW(0, fooW, 0, NULL, NULL, &size, NULL);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
-     "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
     ret = pCertStrToNameW(0, simpleCN_W, 0, NULL, NULL, &size, NULL);
     ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND,
-     "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
+     "Expected ERROR_FILE_NOT_FOUND, got %08lx\n", GetLastError());
     ret = pCertStrToNameW(X509_ASN_ENCODING, simpleCN_W, 0, NULL, NULL, &size,
      NULL);
-    ok(ret, "CertStrToNameW failed: %08x\n", GetLastError());
+    ok(ret, "CertStrToNameW failed: %08lx\n", GetLastError());
     size = sizeof(buf);
     ret = pCertStrToNameW(X509_ASN_ENCODING, badlyQuotedCN_W, 0, NULL, buf,
      &size, NULL);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
-     "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
     ret = pCertStrToNameW(X509_ASN_ENCODING, badlyQuotedCN_W, 0, NULL, buf,
      &size, &errorPtr);
     ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING,
-     "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError());
+     "Expected CRYPT_E_INVALID_X500_STRING, got %08lx\n", GetLastError());
     ok(errorPtr && *errorPtr == '1', "Expected first error character was 1\n");
     for (i = 0; i < ARRAY_SIZE(namesW); i++)
     {
         size = sizeof(buf);
         ret = pCertStrToNameW(X509_ASN_ENCODING, namesW[i].x500, 0, NULL, buf,
          &size, NULL);
-        ok(ret, "Index %d: CertStrToNameW failed: %08x\n", i, GetLastError());
+        ok(ret, "Index %ld: CertStrToNameW failed: %08lx\n", i, GetLastError());
         ok(size == namesW[i].encodedSize,
-         "Index %d: expected size %d, got %d\n", i, namesW[i].encodedSize,
+         "Index %ld: expected size %ld, got %ld\n", i, namesW[i].encodedSize,
          size);
         if (ret)
             ok(!memcmp(buf, namesW[i].encoded, size),
-             "Index %d: unexpected value for string %s\n", i, wine_dbgstr_w(namesW[i].x500));
+             "Index %ld: unexpected value for string %s\n", i, wine_dbgstr_w(namesW[i].x500));
     }
 }
 
@@ -913,7 +913,7 @@ static void test_CertGetNameStringA(void)
 
     context = CertCreateCertificateContext(X509_ASN_ENCODING, cert,
      sizeof(cert));
-    ok(context != NULL, "CertCreateCertificateContext failed: %08x\n",
+    ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
      GetLastError());
     if (context)
     {
@@ -924,16 +924,16 @@ static void test_CertGetNameStringA(void)
 
         /* Bad string types/types missing from the cert */
         len = pCertGetNameStringA(NULL, 0, 0, NULL, NULL, 0);
-        ok(len == 1, "expected 1, got %d\n", len);
+        ok(len == 1, "expected 1, got %ld\n", len);
         len = pCertGetNameStringA(context, 0, 0, NULL, NULL, 0);
-        ok(len == 1, "expected 1, got %d\n", len);
+        ok(len == 1, "expected 1, got %ld\n", len);
         len = pCertGetNameStringA(context, CERT_NAME_URL_TYPE, 0, NULL, NULL,
          0);
-        ok(len == 1, "expected 1, got %d\n", len);
+        ok(len == 1, "expected 1, got %ld\n", len);
 
         len = pCertGetNameStringA(context, CERT_NAME_EMAIL_TYPE, 0, NULL, NULL,
          0);
-        ok(len == strlen(aric) + 1, "unexpected length %d\n", len);
+        ok(len == strlen(aric) + 1, "unexpected length %ld\n", len);
         str = HeapAlloc(GetProcessHeap(), 0, len);
         if (str)
         {
@@ -945,7 +945,7 @@ static void test_CertGetNameStringA(void)
 
         len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, NULL, NULL,
          0);
-        ok(len == strlen(issuerStr) + 1, "unexpected length %d\n", len);
+        ok(len == strlen(issuerStr) + 1, "unexpected length %ld\n", len);
         str = HeapAlloc(GetProcessHeap(), 0, len);
         if (str)
         {
@@ -957,7 +957,7 @@ static void test_CertGetNameStringA(void)
         type = 0;
         len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, NULL,
          0);
-        ok(len == strlen(issuerStr) + 1, "unexpected length %d\n", len);
+        ok(len == strlen(issuerStr) + 1, "unexpected length %ld\n", len);
         str = HeapAlloc(GetProcessHeap(), 0, len);
         if (str)
         {
@@ -969,7 +969,7 @@ static void test_CertGetNameStringA(void)
         type = CERT_OID_NAME_STR;
         len = pCertGetNameStringA(context, CERT_NAME_RDN_TYPE, 0, &type, NULL,
          0);
-        ok(len == strlen(subjectStr) + 1, "unexpected length %d\n", len);
+        ok(len == strlen(subjectStr) + 1, "unexpected length %ld\n", len);
         str = HeapAlloc(GetProcessHeap(), 0, len);
         if (str)
         {
@@ -981,7 +981,7 @@ static void test_CertGetNameStringA(void)
 
         len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0, NULL, NULL,
          0);
-        ok(len == strlen(aric) + 1, "unexpected length %d\n", len);
+        ok(len == strlen(aric) + 1, "unexpected length %ld\n", len);
         str = HeapAlloc(GetProcessHeap(), 0, len);
         if (str)
         {
@@ -992,7 +992,7 @@ static void test_CertGetNameStringA(void)
         }
         len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0,
          (void *)szOID_RSA_emailAddr, NULL, 0);
-        ok(len == strlen(aric) + 1, "unexpected length %d\n", len);
+        ok(len == strlen(aric) + 1, "unexpected length %ld\n", len);
         str = HeapAlloc(GetProcessHeap(), 0, len);
         if (str)
         {
@@ -1003,7 +1003,7 @@ static void test_CertGetNameStringA(void)
         }
         len = pCertGetNameStringA(context, CERT_NAME_ATTR_TYPE, 0,
          (void *)szOID_COMMON_NAME, NULL, 0);
-        ok(len == strlen(localhost) + 1, "unexpected length %d\n", len);
+        ok(len == strlen(localhost) + 1, "unexpected length %ld\n", len);
         str = HeapAlloc(GetProcessHeap(), 0, len);
         if (str)
         {
@@ -1015,7 +1015,7 @@ static void test_CertGetNameStringA(void)
 
         len = pCertGetNameStringA(context, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0,
          NULL, NULL, 0);
-        ok(len == strlen(localhost) + 1, "unexpected length %d\n", len);
+        ok(len == strlen(localhost) + 1, "unexpected length %ld\n", len);
         str = HeapAlloc(GetProcessHeap(), 0, len);
         if (str)
         {
@@ -1027,7 +1027,7 @@ static void test_CertGetNameStringA(void)
 
         len = pCertGetNameStringA(context, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0,
          NULL, NULL, 0);
-        ok(len == strlen(localhost) + 1, "unexpected length %d\n", len);
+        ok(len == strlen(localhost) + 1, "unexpected length %ld\n", len);
         str = HeapAlloc(GetProcessHeap(), 0, len);
         if (str)
         {
@@ -1040,7 +1040,7 @@ static void test_CertGetNameStringA(void)
         len = pCertGetNameStringA(context, CERT_NAME_DNS_TYPE, 0, NULL, NULL,
          0);
         ok(len == strlen(localhost) + 1 || broken(len == 1) /* NT4 */,
-         "unexpected length %d\n", len);
+         "unexpected length %ld\n", len);
         if (len > 1)
         {
             str = HeapAlloc(GetProcessHeap(), 0, len);




More information about the wine-devel mailing list