French translations updates for newdev and taskmgr.
[reactos.git] / rostests / rosautotest / misc.cpp
1 /*
2 * PROJECT: ReactOS Automatic Testing Utility
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/rapps/misc.c
5 * PURPOSE: Misc functions
6 * PROGRAMMERS: Dmitry Chapyshev (dmitry@reactos.org)
7 */
8
9 #include "precomp.h"
10 HANDLE hLog = NULL;
11
12 VOID
13 InitLogs(VOID)
14 {
15 WCHAR szBuf[MAX_PATH] = L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\RosAutotest";
16 WCHAR szPath[MAX_PATH];
17 DWORD dwCategoryNum = 1;
18 DWORD dwDisp, dwData;
19 HKEY hKey;
20
21 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE,
22 szBuf, 0, NULL,
23 REG_OPTION_NON_VOLATILE,
24 KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS)
25 {
26 return;
27 }
28
29 if (!GetModuleFileName(NULL, szPath, sizeof(szPath) / sizeof(szPath[0])))
30 return;
31
32 if (RegSetValueExW(hKey,
33 L"EventMessageFile",
34 0,
35 REG_EXPAND_SZ,
36 (LPBYTE)szPath,
37 (DWORD)(wcslen(szPath) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
38 {
39 RegCloseKey(hKey);
40 return;
41 }
42
43 dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
44 EVENTLOG_INFORMATION_TYPE;
45
46 if (RegSetValueExW(hKey,
47 L"TypesSupported",
48 0,
49 REG_DWORD,
50 (LPBYTE)&dwData,
51 sizeof(DWORD)) != ERROR_SUCCESS)
52 {
53 RegCloseKey(hKey);
54 return;
55 }
56
57 if (RegSetValueExW(hKey,
58 L"CategoryMessageFile",
59 0,
60 REG_EXPAND_SZ,
61 (LPBYTE)szPath,
62 (DWORD)(wcslen(szPath) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
63 {
64 RegCloseKey(hKey);
65 return;
66 }
67
68 if (RegSetValueExW(hKey,
69 L"CategoryCount",
70 0,
71 REG_DWORD,
72 (LPBYTE)&dwCategoryNum,
73 sizeof(DWORD)) != ERROR_SUCCESS)
74 {
75 RegCloseKey(hKey);
76 return;
77 }
78
79 RegCloseKey(hKey);
80
81 hLog = RegisterEventSourceW(NULL, L"RosAutotest");
82 }
83
84
85 VOID
86 FreeLogs(VOID)
87 {
88 if (hLog) DeregisterEventSource(hLog);
89 }
90
91
92 BOOL
93 WriteLogMessage(WORD wType, DWORD dwEventID, LPWSTR lpMsg)
94 {
95 if (!ReportEventW(hLog,
96 wType,
97 0,
98 dwEventID,
99 NULL,
100 1,
101 0,
102 (LPCWSTR*)&lpMsg,
103 NULL))
104 {
105 return FALSE;
106 }
107
108 return TRUE;
109 }