mirror of
https://github.com/reactos/reactos.git
synced 2024-09-28 13:34:53 +00:00
[EVENTLOG]
Log product info upon startup. svn path=/trunk/; revision=51670
This commit is contained in:
parent
58b0d6b369
commit
72c25cca5a
|
@ -135,6 +135,71 @@ ServiceInit(VOID)
|
|||
}
|
||||
|
||||
|
||||
static VOID
|
||||
ReportProductInfoEvent(VOID)
|
||||
{
|
||||
OSVERSIONINFOW versionInfo;
|
||||
WCHAR szBuffer[512];
|
||||
DWORD dwLength;
|
||||
HKEY hKey;
|
||||
DWORD dwValueLength;
|
||||
DWORD dwType;
|
||||
LONG lResult = ERROR_SUCCESS;
|
||||
|
||||
ZeroMemory(&versionInfo, sizeof(OSVERSIONINFO));
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
|
||||
/* Get version information */
|
||||
if (!GetVersionExW(&versionInfo))
|
||||
return;
|
||||
|
||||
ZeroMemory(szBuffer, 512 * sizeof(WCHAR));
|
||||
|
||||
/* Write version into the buffer */
|
||||
dwLength = swprintf(szBuffer,
|
||||
L"%lu.%lu",
|
||||
versionInfo.dwMajorVersion,
|
||||
versionInfo.dwMinorVersion) + 1;
|
||||
|
||||
/* Write build number into the buffer */
|
||||
dwLength += swprintf(&szBuffer[dwLength],
|
||||
L"%lu",
|
||||
versionInfo.dwBuildNumber) + 1;
|
||||
|
||||
/* Write service pack info into the buffer */
|
||||
wcscpy(&szBuffer[dwLength], versionInfo.szCSDVersion);
|
||||
dwLength += wcslen(versionInfo.szCSDVersion) + 1;
|
||||
|
||||
/* Read 'CurrentType' from the registry and write it into the buffer */
|
||||
lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
|
||||
0,
|
||||
KEY_QUERY_VALUE,
|
||||
&hKey);
|
||||
if (lResult == ERROR_SUCCESS)
|
||||
{
|
||||
dwValueLength = 512 - dwLength;
|
||||
lResult = RegQueryValueEx(hKey,
|
||||
L"CurrentType",
|
||||
NULL,
|
||||
&dwType,
|
||||
(LPBYTE)&szBuffer[dwLength],
|
||||
&dwValueLength);
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
/* Log the product information */
|
||||
LogfReportEvent(EVENTLOG_INFORMATION_TYPE,
|
||||
0,
|
||||
EVENT_EventLogProductInfo,
|
||||
4,
|
||||
szBuffer,
|
||||
0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
static VOID CALLBACK
|
||||
ServiceMain(DWORD argc,
|
||||
LPWSTR *argv)
|
||||
|
@ -169,9 +234,15 @@ ServiceMain(DWORD argc,
|
|||
DPRINT("Service started\n");
|
||||
UpdateServiceStatus(SERVICE_RUNNING);
|
||||
|
||||
ReportProductInfoEvent();
|
||||
|
||||
LogfReportEvent(EVENTLOG_INFORMATION_TYPE,
|
||||
0,
|
||||
EVENT_EventlogStarted);
|
||||
EVENT_EventlogStarted,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
DPRINT("ServiceMain() done\n");
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#define NDEBUG
|
||||
#define WIN32_NO_STATUS
|
||||
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <netevent.h>
|
||||
#include <lpctypes.h>
|
||||
|
@ -181,7 +182,11 @@ PBYTE LogfAllocAndBuildNewRecord(LPDWORD lpRecSize,
|
|||
VOID
|
||||
LogfReportEvent(WORD wType,
|
||||
WORD wCategory,
|
||||
DWORD dwEventId);
|
||||
DWORD dwEventId,
|
||||
WORD wNumStrings,
|
||||
WCHAR *lpStrings,
|
||||
DWORD dwDataSize,
|
||||
LPVOID lpRawData);
|
||||
|
||||
/* eventlog.c */
|
||||
extern HANDLE MyHeap;
|
||||
|
|
|
@ -1054,7 +1054,11 @@ PBYTE LogfAllocAndBuildNewRecord(LPDWORD lpRecSize,
|
|||
VOID
|
||||
LogfReportEvent(WORD wType,
|
||||
WORD wCategory,
|
||||
DWORD dwEventId)
|
||||
DWORD dwEventId,
|
||||
WORD wNumStrings,
|
||||
WCHAR *lpStrings,
|
||||
DWORD dwDataSize,
|
||||
LPVOID lpRawData)
|
||||
{
|
||||
WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
|
||||
DWORD dwComputerNameLength = MAX_COMPUTERNAME_LENGTH + 1;
|
||||
|
@ -1086,10 +1090,10 @@ LogfReportEvent(WORD wType,
|
|||
(LPCWSTR)szComputerName,
|
||||
0,
|
||||
NULL,
|
||||
0, //wNumStrings,
|
||||
NULL, //lpStrings,
|
||||
0, //dwDataSize,
|
||||
NULL); //lpRawData);
|
||||
wNumStrings,
|
||||
lpStrings,
|
||||
dwDataSize,
|
||||
lpRawData);
|
||||
|
||||
dwError = LogfWriteData(pEventSource->LogFile, recSize, logBuffer);
|
||||
if (!dwError)
|
||||
|
|
Loading…
Reference in a new issue