Reactos
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Test for SHSetUnreadMailCountW
5 * COPYRIGHT: Copyright 2025 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6 */
7
8#include "shelltest.h"
9
10START_TEST(SHSetUnreadMailCountW)
11{
12 HKEY hKey;
13 LSTATUS error;
14 DWORD dwDisposition;
15 error = RegCreateKeyExW(HKEY_CURRENT_USER,
16 L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\example.com",
17 0, NULL, 0, KEY_WRITE, NULL, &hKey, &dwDisposition);
18 ok_long(error, ERROR_SUCCESS);
19 RegCloseKey(hKey);
20
21 HRESULT hr = SHSetUnreadMailCountW(L"example.com", 1, L"MyMailerApp");
22 ok_hex(hr, S_OK);
23
24 error = RegOpenKeyExW(HKEY_CURRENT_USER,
25 L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\example.com",
26 0,
27 KEY_READ,
28 &hKey);
29 ok_long(error, ERROR_SUCCESS);
30
31 DWORD dwValue, cbValue = sizeof(dwValue);
32 error = RegQueryValueExW(hKey, L"MessageCount", NULL, NULL, (PBYTE)&dwValue, &cbValue);
33 ok_long(error, ERROR_SUCCESS);
34 ok_long(dwValue, 1);
35
36 FILETIME FileTime;
37 cbValue = sizeof(FileTime);
38 error = RegQueryValueExW(hKey, L"TimeStamp", NULL, NULL, (PBYTE)&FileTime, &cbValue);
39 ok_long(error, ERROR_SUCCESS);
40 ok(FileTime.dwHighDateTime != 0, "FileTime.dwHighDateTime was zero\n");
41
42 WCHAR szValue[MAX_PATH];
43 cbValue = sizeof(szValue);
44 error = RegQueryValueExW(hKey, L"Application", NULL, NULL, (PBYTE)szValue, &cbValue);
45 ok_long(error, ERROR_SUCCESS);
46 ok_wstr(szValue, L"MyMailerApp");
47
48 RegCloseKey(hKey);
49
50 hr = SHSetUnreadMailCountW(L"example.com", 0, L"MyMailerApp");
51 ok_hex(hr, S_OK);
52
53 if (dwDisposition == REG_CREATED_NEW_KEY)
54 {
55 RegDeleteKeyW(HKEY_CURRENT_USER,
56 L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\example.com");
57 }
58}