ReactOS 0.4.16-dev-927-g467dec4
SHGetUnreadMailCountW.cpp File Reference
#include "shelltest.h"
Include dependency graph for SHGetUnreadMailCountW.cpp:

Go to the source code of this file.

Functions

static VOID SetUnreadMailInfo (PDWORD pdwDisposition)
 
 START_TEST (SHGetUnreadMailCountW)
 

Function Documentation

◆ SetUnreadMailInfo()

static VOID SetUnreadMailInfo ( PDWORD  pdwDisposition)
static

Definition at line 10 of file SHGetUnreadMailCountW.cpp.

11{
12 HKEY hKey;
14 HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\example.com",
15 0, NULL, 0, KEY_WRITE, NULL, &hKey, pdwDisposition);
17
18 DWORD dwCount = 1;
19 error = SHSetValueW(hKey, NULL, L"MessageCount", REG_DWORD, &dwCount, sizeof(dwCount));
21
22 FILETIME FileTime;
23 GetSystemTimeAsFileTime(&FileTime);
24 error = SHSetValueW(hKey, NULL, L"TimeStamp", REG_BINARY, &FileTime, sizeof(FileTime));
26
27 LPCWSTR pszApp = L"MyMailerApp";
28 DWORD cbValue = (lstrlenW(pszApp) + 1) * sizeof(WCHAR);
29 error = SHSetValueW(hKey, NULL, L"Application", REG_SZ, pszApp, cbValue);
31
33}
#define ok_long(expression, result)
Definition: atltest.h:133
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define NULL
Definition: types.h:112
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
#define lstrlenW
Definition: compat.h:750
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
DWORD WINAPI SHSetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD dwType, LPCVOID pvData, DWORD cbData)
Definition: reg.c:1306
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define REG_SZ
Definition: layer.c:22
#define error(str)
Definition: mkdosfs.c:1605
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_WRITE
Definition: nt_native.h:1031
#define L(x)
Definition: ntvdm.h:50
#define REG_DWORD
Definition: sdbapi.c:596
#define HKEY_CURRENT_USER
Definition: winreg.h:11
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( SHGetUnreadMailCountW  )

Definition at line 35 of file SHGetUnreadMailCountW.cpp.

36{
37 HRESULT hr;
38
39 DWORD dwDisposition;
40 SetUnreadMailInfo(&dwDisposition);
41
42 hr = SHGetUnreadMailCountW(NULL, L"example.com", NULL, NULL, NULL, 0);
43 ok_hex(hr, S_OK);
44
45 FILETIME FileTime;
46 ZeroMemory(&FileTime, sizeof(FileTime));
47 hr = SHGetUnreadMailCountW(HKEY_CURRENT_USER, L"example.com", NULL, &FileTime, NULL, 0);
48 ok_hex(hr, S_OK);
49 ok(FileTime.dwHighDateTime != 0, "FileTime.dwHighDateTime was zero\n");
50
51 DWORD dwCount = 0;
52 ZeroMemory(&FileTime, sizeof(FileTime));
53 hr = SHGetUnreadMailCountW(NULL, NULL, &dwCount, &FileTime, NULL, 0);
54 ok_hex(hr, S_OK);
55 ok_long(dwCount, 1);
56 ok_long(FileTime.dwHighDateTime, 0);
57
58 dwCount = 0;
59 hr = SHGetUnreadMailCountW(NULL, L"example.com", &dwCount, NULL, NULL, 0);
60 ok_hex(hr, S_OK);
61 ok_long(dwCount, 1);
62
63 hr = SHGetUnreadMailCountW(NULL, NULL, &dwCount, NULL, NULL, 0);
64 ok_hex(hr, S_OK);
65
67 dwCount = 0;
70 ok_long(dwCount, 0);
71
73 ok_hex(hr, S_OK);
74 ok_wstr(szAppName, L"MyMailerApp");
75
76 if (dwDisposition == REG_CREATED_NEW_KEY)
77 {
79 L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\example.com");
80 }
81}
static VOID SetUnreadMailInfo(PDWORD pdwDisposition)
#define ok_hex(expression, result)
Definition: atltest.h:94
#define ok(value,...)
Definition: atltest.h:57
#define ok_wstr(x, y)
Definition: atltest.h:130
#define E_INVALIDARG
Definition: ddrawi.h:101
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
#define MAX_PATH
Definition: compat.h:34
EXTERN_C HRESULT WINAPI SHGetUnreadMailCountW(_In_opt_ HKEY hKeyUser, _In_opt_ PCWSTR pszMailAddress, _Out_opt_ PDWORD pdwCount, _Inout_opt_ PFILETIME pFileTime, _Out_writes_opt_(cchShellExecuteCommand) PWSTR pszShellExecuteCommand, _In_ INT cchShellExecuteCommand)
Definition: utils.cpp:928
#define S_OK
Definition: intsafe.h:52
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
HRESULT hr
Definition: shlfolder.c:183
#define _countof(array)
Definition: sndvol32.h:70
TCHAR szAppName[128]
Definition: solitaire.cpp:18
DWORD dwHighDateTime
Definition: mapidefs.h:66
#define ZeroMemory
Definition: winbase.h:1743