TCHAR EvtKey[] = _T("SYSTEM\\CurrentControlSet\\Services\\EventLog\\MyCustLog\\C:/App1.exe");
TCHAR EvtSrc[] = _T("C:/App1.exe");
TCHAR EvtFil[] = _T("C:\\MyFolder\\App1.evtx");
DWORD dwSize = (_tcslen(EvtFil) + 1) * sizeof(TCHAR);//including terminating NULL
DWORD dwRet = RegSetKeyValue(HKEY_LOCAL_MACHINE, EvtKey, _T("File"), REG_SZ, (PVOID)EvtFil, dwSize);
...
HANDLE hEvtSrc = RegisterEventSource(0, EvtSrc);
BOOL bRet = ReportEvent(hEvtSrc, EVENTLOG_ERROR_TYPE, ...);
This code successfully runs OK, and adds an event log to the Windows Event Log Viewer.
However, it does NOT create the C:\MyFolder\App1.evtx
file at all. No error or whatsoever at all, but no file created.
What is missing here to create the event log file?
@mutantkeyboard suggested the following answer, but it did not explain anything about the File
value. So it is not an answer to my question unfortunately: