ReactOS  0.4.15-dev-3299-gbe8e5fc
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 }
HANDLE hLog
Definition: misc.cpp:9
BOOL WINAPI DeregisterEventSource(IN HANDLE hEventLog)
Definition: eventlog.c:473

◆ 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 
31  if (RegSetValueExW(hKey,
32  L"EventMessageFile",
33  0,
35  (LPBYTE)szPath,
36  (DWORD)(wcslen(szPath) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
37  {
39  return;
40  }
41 
44 
45  if (RegSetValueExW(hKey,
46  L"TypesSupported",
47  0,
48  REG_DWORD,
49  (LPBYTE)&dwData,
50  sizeof(DWORD)) != ERROR_SUCCESS)
51  {
53  return;
54  }
55 
56  if (RegSetValueExW(hKey,
57  L"CategoryMessageFile",
58  0,
60  (LPBYTE)szPath,
61  (DWORD)(wcslen(szPath) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
62  {
64  return;
65  }
66 
67  if (RegSetValueExW(hKey,
68  L"CategoryCount",
69  0,
70  REG_DWORD,
71  (LPBYTE)&dwCategoryNum,
72  sizeof(DWORD)) != ERROR_SUCCESS)
73  {
75  return;
76  }
77 
79 
80  hLog = RegisterEventSourceW(NULL, L"RosAutotest");
81 }
#define ERROR_SUCCESS
Definition: deptool.c:10
static HANDLE ULONG_PTR dwData
Definition: file.c:35
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:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define EVENTLOG_ERROR_TYPE
Definition: winnt_old.h:2754
HANDLE hLog
Definition: misc.cpp:9
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
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:4895
#define EVENTLOG_INFORMATION_TYPE
Definition: winnt_old.h:2756
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define EVENTLOG_WARNING_TYPE
Definition: winnt_old.h:2755
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GetModuleFileName
Definition: winbase.h:3687
static const WCHAR L[]
Definition: oid.c:1250
FxAutoRegKey hKey
LPCWSTR szPath
Definition: env.c:37
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
HANDLE WINAPI RegisterEventSourceW(IN LPCWSTR lpUNCServerName, IN LPCWSTR lpSourceName)
Definition: eventlog.c:1295
#define REG_DWORD
Definition: sdbapi.c:596
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ 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 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HANDLE hLog
Definition: misc.cpp:9
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
#define NULL
Definition: types.h:112

Variable Documentation

◆ hLog

HANDLE hLog = NULL

Definition at line 9 of file misc.cpp.

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