ReactOS 0.4.15-dev-8241-g63935f8
misc.cpp File Reference
#include "precomp.h"
Include dependency graph for misc.cpp:

Go to the source code of this file.

Functions

VOID InitLogs (VOID)
 
VOID FreeLogs (VOID)
 
BOOL WriteLogMessage (WORD wType, DWORD dwEventID, LPWSTR lpMsg)
 

Variables

HANDLE hLog = NULL
 

Function Documentation

◆ FreeLogs()

VOID FreeLogs ( VOID  )

Definition at line 85 of file misc.cpp.

86{
88}
BOOL WINAPI DeregisterEventSource(IN HANDLE hEventLog)
Definition: eventlog.c:473
HANDLE hLog
Definition: misc.cpp:9

◆ InitLogs()

VOID InitLogs ( VOID  )

Definition at line 12 of file misc.cpp.

13{
14 WCHAR szBuf[MAX_PATH] = L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\RosAutotest";
16 DWORD dwCategoryNum = 1;
17 DWORD dwDisp, dwData;
18 HKEY hKey;
19
21 szBuf, 0, NULL,
23 KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS)
24 {
25 return;
26 }
27
28 if (!GetModuleFileName(NULL, szPath, sizeof(szPath) / sizeof(szPath[0])))
29 return;
30
32 L"EventMessageFile",
33 0,
36 (DWORD)(wcslen(szPath) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
37 {
39 return;
40 }
41
44
46 L"TypesSupported",
47 0,
49 (LPBYTE)&dwData,
50 sizeof(DWORD)) != ERROR_SUCCESS)
51 {
53 return;
54 }
55
57 L"CategoryMessageFile",
58 0,
61 (DWORD)(wcslen(szPath) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
62 {
64 return;
65 }
66
68 L"CategoryCount",
69 0,
71 (LPBYTE)&dwCategoryNum,
72 sizeof(DWORD)) != ERROR_SUCCESS)
73 {
75 return;
76 }
77
79
80 hLog = RegisterEventSourceW(NULL, L"RosAutotest");
81}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#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
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
HANDLE WINAPI RegisterEventSourceW(IN LPCWSTR lpUNCServerName, IN LPCWSTR lpSourceName)
Definition: eventlog.c:1295
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
LPCWSTR szPath
Definition: env.c:37
static HANDLE ULONG_PTR dwData
Definition: file.c:35
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define L(x)
Definition: ntvdm.h:50
#define REG_DWORD
Definition: sdbapi.c:596
unsigned char * LPBYTE
Definition: typedefs.h:53
#define GetModuleFileName
Definition: winbase.h:3831
#define EVENTLOG_ERROR_TYPE
Definition: winnt_old.h:2834
#define EVENTLOG_INFORMATION_TYPE
Definition: winnt_old.h:2836
#define EVENTLOG_WARNING_TYPE
Definition: winnt_old.h:2835
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ WriteLogMessage()

BOOL WriteLogMessage ( WORD  wType,
DWORD  dwEventID,
LPWSTR  lpMsg 
)

Definition at line 92 of file misc.cpp.

93{
94 if (!ReportEventW(hLog,
95 wType,
96 0,
97 dwEventID,
98 NULL,
99 1,
100 0,
101 (LPCWSTR*)&lpMsg,
102 NULL))
103 {
104 return FALSE;
105 }
106
107 return TRUE;
108}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI ReportEventW(IN HANDLE hEventLog, IN WORD wType, IN WORD wCategory, IN DWORD dwEventID, IN PSID lpUserSid, IN WORD wNumStrings, IN DWORD dwDataSize, IN LPCWSTR *lpStrings, IN LPVOID lpRawData)
Definition: eventlog.c:1516
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Variable Documentation

◆ hLog

HANDLE hLog = NULL

Definition at line 9 of file misc.cpp.

Referenced by FreeLogs(), InitLogs(), and WriteLogMessage().