2 * ReactOS Win32 Applications
3 * Copyright (C) 2007 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT : See COPYING in the top level directory
21 * PROJECT : Event Log Viewer
23 * PROGRAMMER: Marc Piulachs (marc.piulachs at codexchange [dot] net)
41 #pragma warning(disable: 4996) /* 'strdup' was declared deprecated */
42 #define _CRT_SECURE_NO_DEPRECATE /* all deprecated unsafe string functions */
45 static const WCHAR szWindowClass
[] = L
"EVENTVWR"; /* the main window class name*/
46 static const WCHAR EVENTLOG_BASE_KEY
[] = L
"SYSTEM\\CurrentControlSet\\Services\\EventLog\\";
48 // MessageFile message buffer size
49 #define EVENT_MESSAGE_EVENTTEXT_BUFFER 1024*10
50 #define EVENT_MESSAGE_FILE_BUFFER 1024*10
51 #define EVENT_DLL_SEPARATOR L";"
52 #define EVENT_MESSAGE_FILE L"EventMessageFile"
53 #define EVENT_CATEGORY_MESSAGE_FILE L"CategoryMessageFile"
54 #define EVENT_PARAMETER_MESSAGE_FILE L"ParameterMessageFile"
56 #define MAX_LOADSTRING 255
57 #define ENTRY_SIZE 2056
60 HINSTANCE hInst
; /* current instance */
61 WCHAR szTitle
[MAX_LOADSTRING
]; /* The title bar text */
62 WCHAR szTitleTemplate
[MAX_LOADSTRING
]; /* The logged-on title bar text */
63 WCHAR szSaveFilter
[MAX_LOADSTRING
]; /* Filter Mask for the save Dialog */
64 HWND hwndMainWindow
; /* Main window */
65 HWND hwndListView
; /* ListView control */
66 HWND hwndStatus
; /* Status bar */
67 HMENU hMainMenu
; /* The application's main menu */
68 WCHAR szStatusBarTemplate
[MAX_LOADSTRING
]; /* The status bar text */
69 PEVENTLOGRECORD
*g_RecordPtrs
= NULL
;
70 DWORD g_TotalRecords
= 0;
73 LPWSTR lpSourceLogName
= NULL
;
74 LPWSTR lpComputerName
= NULL
;
79 /* Forward declarations of functions included in this code module: */
80 ATOM
MyRegisterClass(HINSTANCE hInstance
);
81 BOOL
InitInstance(HINSTANCE
, int);
82 LRESULT CALLBACK
WndProc(HWND
, UINT
, WPARAM
, LPARAM
);
83 INT_PTR CALLBACK
About(HWND
, UINT
, WPARAM
, LPARAM
);
84 INT_PTR CALLBACK
EventDetails(HWND
, UINT
, WPARAM
, LPARAM
);
85 static INT_PTR CALLBACK
StatusMessageWindowProc (HWND
, UINT
, WPARAM
, LPARAM
);
89 wWinMain(HINSTANCE hInstance
,
90 HINSTANCE hPrevInstance
,
96 INITCOMMONCONTROLSEX iccx
;
98 UNREFERENCED_PARAMETER(hPrevInstance
);
99 UNREFERENCED_PARAMETER(lpCmdLine
);
101 /* Whenever any of the common controls are used in your app,
102 * you must call InitCommonControlsEx() to register the classes
103 * for those controls. */
104 iccx
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
105 iccx
.dwICC
= ICC_LISTVIEW_CLASSES
;
106 InitCommonControlsEx(&iccx
);
108 /* Initialize global strings */
109 LoadStringW(hInstance
, IDS_APP_TITLE
, szTitle
, MAX_LOADSTRING
);
110 LoadStringW(hInstance
, IDS_APP_TITLE_EX
, szTitleTemplate
, MAX_LOADSTRING
);
111 LoadStringW(hInstance
, IDS_STATUS_MSG
, szStatusBarTemplate
, MAX_LOADSTRING
);
112 MyRegisterClass(hInstance
);
114 /* Perform application initialization: */
115 if (!InitInstance(hInstance
, nCmdShow
))
120 hAccelTable
= LoadAccelerators(hInstance
, MAKEINTRESOURCE(IDA_EVENTVWR
));
122 /* Main message loop: */
123 while (GetMessageW(&msg
, NULL
, 0, 0))
125 if (!TranslateAcceleratorW(msg
.hwnd
, hAccelTable
, &msg
))
127 TranslateMessage(&msg
);
128 DispatchMessage(&msg
);
132 return (int)msg
.wParam
;
135 static void FreeRecords(void)
142 for (iIndex
= 0; iIndex
< g_TotalRecords
; iIndex
++)
143 HeapFree(GetProcessHeap(), 0, g_RecordPtrs
[iIndex
]);
144 HeapFree(GetProcessHeap(), 0, g_RecordPtrs
);
149 ShowLastWin32Error(VOID
)
152 LPWSTR lpMessageBuffer
;
154 dwError
= GetLastError();
155 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
,
159 (LPWSTR
)&lpMessageBuffer
,
163 MessageBoxW(hwndMainWindow
, lpMessageBuffer
, szTitle
, MB_OK
| MB_ICONERROR
);
164 LocalFree(lpMessageBuffer
);
168 EventTimeToSystemTime(DWORD EventTime
,
169 SYSTEMTIME
*pSystemTime
)
171 SYSTEMTIME st1970
= { 1970, 1, 0, 1, 0, 0, 0, 0 };
179 uUCT
.ft
.dwHighDateTime
= 0;
180 uUCT
.ft
.dwLowDateTime
= EventTime
;
181 SystemTimeToFileTime(&st1970
, &u1970
.ft
);
182 uUCT
.ll
= uUCT
.ll
* 10000000 + u1970
.ll
;
183 FileTimeToLocalFileTime(&uUCT
.ft
, &ftLocal
);
184 FileTimeToSystemTime(&ftLocal
, pSystemTime
);
195 c
= s
+ wcslen(s
) - 1;
196 while (c
>= s
&& iswspace(*c
))
204 GetEventMessageFileDLL(IN LPCWSTR lpLogName
,
205 IN LPCWSTR SourceName
,
206 IN LPCWSTR EntryName
,
207 OUT PWCHAR ExpandedName
)
210 BYTE szModuleName
[MAX_PATH
];
211 WCHAR szKeyName
[MAX_PATH
];
213 HKEY hSourceKey
= NULL
;
214 BOOL bReturn
= FALSE
;
216 StringCbCopyW(szKeyName
, sizeof(szKeyName
), L
"SYSTEM\\CurrentControlSet\\Services\\EventLog\\");
217 StringCbCatW(szKeyName
, sizeof(szKeyName
), lpLogName
);
219 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
223 &hAppKey
) == ERROR_SUCCESS
)
225 if (RegOpenKeyExW(hAppKey
,
229 &hSourceKey
) == ERROR_SUCCESS
)
232 if (RegQueryValueExW(hSourceKey
,
236 (LPBYTE
)szModuleName
,
237 &dwSize
) == ERROR_SUCCESS
)
239 /* Returns a string containing the requested substituted environment variable. */
240 ExpandEnvironmentStringsW((LPCWSTR
)szModuleName
, ExpandedName
, MAX_PATH
);
249 ShowLastWin32Error();
252 if (hSourceKey
!= NULL
)
253 RegCloseKey(hSourceKey
);
256 RegCloseKey(hAppKey
);
263 GetEventCategory(IN LPCWSTR KeyName
,
264 IN LPCWSTR SourceName
,
265 IN EVENTLOGRECORD
*pevlr
,
266 OUT PWCHAR CategoryName
)
268 HANDLE hLibrary
= NULL
;
269 WCHAR szMessageDLL
[MAX_PATH
];
270 LPVOID lpMsgBuf
= NULL
;
272 if (GetEventMessageFileDLL (KeyName
, SourceName
, EVENT_CATEGORY_MESSAGE_FILE
, szMessageDLL
))
274 hLibrary
= LoadLibraryExW(szMessageDLL
,
276 DONT_RESOLVE_DLL_REFERENCES
| LOAD_LIBRARY_AS_DATAFILE
);
277 if (hLibrary
!= NULL
)
279 /* Retrieve the message string. */
280 if (FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_HMODULE
| FORMAT_MESSAGE_ARGUMENT_ARRAY
,
282 pevlr
->EventCategory
,
283 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
285 EVENT_MESSAGE_FILE_BUFFER
,
288 /* Trim the string */
291 /* Copy the category name */
292 StringCchCopyW(CategoryName
, MAX_PATH
, lpMsgBuf
);
296 LoadStringW(hInst
, IDS_NONE
, CategoryName
, MAX_PATH
);
299 if (hLibrary
!= NULL
)
300 FreeLibrary(hLibrary
);
302 /* Free the buffer allocated by FormatMessage */
310 LoadStringW(hInst
, IDS_NONE
, CategoryName
, MAX_PATH
);
317 GetEventMessage(IN LPCWSTR KeyName
,
318 IN LPCWSTR SourceName
,
319 IN EVENTLOGRECORD
*pevlr
,
320 OUT PWCHAR EventText
)
323 HANDLE hLibrary
= NULL
;
324 WCHAR SourceModuleName
[1000];
325 WCHAR ParameterModuleName
[1000];
326 LPWSTR lpMsgBuf
= NULL
;
327 WCHAR szStringIDNotFound
[MAX_LOADSTRING
];
333 /* TODO : GetEventMessageFileDLL can return a comma separated list of DLLs */
334 if (GetEventMessageFileDLL (KeyName
, SourceName
, EVENT_MESSAGE_FILE
, SourceModuleName
))
336 /* Get the event message */
337 szMessage
= (LPWSTR
)((LPBYTE
)pevlr
+ pevlr
->StringOffset
);
339 /* Allocate space for parameters */
340 szArguments
= malloc(sizeof(LPVOID
) * pevlr
->NumStrings
);
346 for (i
= 0; i
< pevlr
->NumStrings
; i
++)
348 if (wcsstr(szMessage
, L
"%%"))
350 if (GetEventMessageFileDLL(KeyName
, SourceName
, EVENT_PARAMETER_MESSAGE_FILE
, ParameterModuleName
))
352 /* Not yet support for reading messages from parameter message DLL */
356 szArguments
[i
] = szMessage
;
357 szMessage
+= wcslen(szMessage
) + 1;
360 szDll
= wcstok(SourceModuleName
, EVENT_DLL_SEPARATOR
);
361 while ((szDll
!= NULL
) && (!bDone
))
363 hLibrary
= LoadLibraryExW(szDll
,
365 DONT_RESOLVE_DLL_REFERENCES
| LOAD_LIBRARY_AS_DATAFILE
);
366 if (hLibrary
== NULL
)
368 /* The DLL could not be loaded try the next one (if any) */
369 szDll
= wcstok(NULL
, EVENT_DLL_SEPARATOR
);
373 /* Retrieve the message string. */
374 if (FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
|
375 FORMAT_MESSAGE_ALLOCATE_BUFFER
|
376 FORMAT_MESSAGE_FROM_HMODULE
|
377 FORMAT_MESSAGE_ARGUMENT_ARRAY
,
380 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
383 (va_list*)szArguments
) == 0)
385 /* We haven't found the string , get next DLL (if any) */
386 szDll
= wcstok(NULL
, EVENT_DLL_SEPARATOR
);
392 /* The ID was found and the message was formated */
395 /* Trim the string */
396 TrimNulls((LPWSTR
)lpMsgBuf
);
398 /* Copy the event text */
399 StringCchCopyW(EventText
, EVENT_MESSAGE_EVENTTEXT_BUFFER
, lpMsgBuf
);
403 FreeLibrary(hLibrary
);
409 LoadStringW(hInst
, IDS_EVENTSTRINGIDNOTFOUND
, szStringIDNotFound
, MAX_LOADSTRING
);
410 StringCchPrintfW(EventText
, EVENT_MESSAGE_EVENTTEXT_BUFFER
, szStringIDNotFound
, (pevlr
->EventID
& 0xFFFF), SourceName
);
415 /* No more dlls to try, return result */
419 LoadStringW(hInst
, IDS_EVENTSTRINGIDNOTFOUND
, szStringIDNotFound
, MAX_LOADSTRING
);
420 StringCchPrintfW(EventText
, EVENT_MESSAGE_EVENTTEXT_BUFFER
, szStringIDNotFound
, (pevlr
->EventID
& 0xFFFF), SourceName
);
427 GetEventType(IN WORD dwEventType
,
428 OUT PWCHAR eventTypeText
)
432 case EVENTLOG_ERROR_TYPE
:
433 LoadStringW(hInst
, IDS_EVENTLOG_ERROR_TYPE
, eventTypeText
, MAX_LOADSTRING
);
435 case EVENTLOG_WARNING_TYPE
:
436 LoadStringW(hInst
, IDS_EVENTLOG_WARNING_TYPE
, eventTypeText
, MAX_LOADSTRING
);
438 case EVENTLOG_INFORMATION_TYPE
:
439 LoadStringW(hInst
, IDS_EVENTLOG_INFORMATION_TYPE
, eventTypeText
, MAX_LOADSTRING
);
441 case EVENTLOG_AUDIT_SUCCESS
:
442 LoadStringW(hInst
, IDS_EVENTLOG_AUDIT_SUCCESS
, eventTypeText
, MAX_LOADSTRING
);
444 case EVENTLOG_AUDIT_FAILURE
:
445 LoadStringW(hInst
, IDS_EVENTLOG_AUDIT_FAILURE
, eventTypeText
, MAX_LOADSTRING
);
447 case EVENTLOG_SUCCESS
:
448 LoadStringW(hInst
, IDS_EVENTLOG_SUCCESS
, eventTypeText
, MAX_LOADSTRING
);
451 LoadStringW(hInst
, IDS_EVENTLOG_UNKNOWN_TYPE
, eventTypeText
, MAX_LOADSTRING
);
457 GetEventUserName(EVENTLOGRECORD
*pelr
,
462 WCHAR szDomain
[1024];
465 DWORD cbDomain
= 1024;
467 /* Point to the SID. */
468 lpSid
= (PSID
)((LPBYTE
)pelr
+ pelr
->UserSidOffset
);
471 if (pelr
->UserSidLength
> 0)
473 if (LookupAccountSidW(NULL
,
481 StringCchCopyW(pszUser
, MAX_PATH
, szName
);
491 ShowStatusMessageThread(IN LPVOID lpParameter
)
493 HWND
*phWnd
= (HWND
*)lpParameter
;
497 hWnd
= CreateDialogParam(hInst
,
498 MAKEINTRESOURCE(IDD_PROGRESSBOX
),
500 StatusMessageWindowProc
,
507 ShowWindow(hWnd
, SW_SHOW
);
509 /* Message loop for the Status window */
510 while (GetMessage(&Msg
, NULL
, 0, 0))
512 TranslateMessage(&Msg
);
513 DispatchMessage(&Msg
);
521 QueryEventMessages(LPWSTR lpMachineName
,
526 EVENTLOGRECORD
*pevlr
;
527 DWORD dwRead
, dwNeeded
, dwThisRecord
, dwTotalRecords
= 0, dwCurrentRecord
= 0, dwRecordsToRead
= 0, dwFlags
, dwMaxLength
;
530 LPWSTR lpComputerName
;
532 BOOL bResult
= TRUE
; /* Read succeeded. */
534 WCHAR szWindowTitle
[MAX_PATH
];
535 WCHAR szStatusText
[MAX_PATH
];
536 WCHAR szLocalDate
[MAX_PATH
];
537 WCHAR szLocalTime
[MAX_PATH
];
538 WCHAR szEventID
[MAX_PATH
];
539 WCHAR szEventTypeText
[MAX_LOADSTRING
];
540 WCHAR szCategoryID
[MAX_PATH
];
541 WCHAR szUsername
[MAX_PATH
];
542 WCHAR szEventText
[EVENT_MESSAGE_FILE_BUFFER
];
543 WCHAR szCategory
[MAX_PATH
];
544 WCHAR szData
[MAX_PATH
];
545 PWCHAR lpTitleTemplateEnd
;
548 LVITEMW lviEventItem
;
550 dwFlags
= EVENTLOG_FORWARDS_READ
| EVENTLOG_SEQUENTIAL_READ
;
552 /* Open the event log. */
553 hEventLog
= OpenEventLogW(lpMachineName
,
555 if (hEventLog
== NULL
)
557 ShowLastWin32Error();
561 lpSourceLogName
= lpLogName
;
562 lpComputerName
= lpMachineName
;
564 /* Disable listview redraw */
565 SendMessage(hwndListView
, WM_SETREDRAW
, FALSE
, 0);
567 /* Clear the list view */
568 (void)ListView_DeleteAllItems (hwndListView
);
571 GetOldestEventLogRecord(hEventLog
, &dwThisRecord
);
573 /* Get the total number of event log records. */
574 GetNumberOfEventLogRecords (hEventLog
, &dwTotalRecords
);
575 g_TotalRecords
= dwTotalRecords
;
577 if (dwTotalRecords
> 0)
579 EnableMenuItem(hMainMenu
, IDM_CLEAR_EVENTS
, MF_BYCOMMAND
| MF_ENABLED
);
580 EnableMenuItem(hMainMenu
, IDM_SAVE_PROTOCOL
, MF_BYCOMMAND
| MF_ENABLED
);
584 EnableMenuItem(hMainMenu
, IDM_CLEAR_EVENTS
, MF_BYCOMMAND
| MF_GRAYED
);
585 EnableMenuItem(hMainMenu
, IDM_SAVE_PROTOCOL
, MF_BYCOMMAND
| MF_GRAYED
);
588 g_RecordPtrs
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, dwTotalRecords
* sizeof(PVOID
));
590 /* If we have at least 1000 records show the waiting dialog */
591 if (dwTotalRecords
> 1000)
593 CloseHandle(CreateThread(NULL
,
595 ShowStatusMessageThread
,
601 while (dwCurrentRecord
< dwTotalRecords
)
603 pevlr
= HeapAlloc(GetProcessHeap(), 0, sizeof(EVENTLOGRECORD
));
604 g_RecordPtrs
[dwCurrentRecord
] = pevlr
;
606 bResult
= ReadEventLog(hEventLog
, // Event log handle
607 dwFlags
, // Sequential read
608 0, // Ignored for sequential read
609 pevlr
, // Pointer to buffer
610 sizeof(EVENTLOGRECORD
), // Size of buffer
611 &dwRead
, // Number of bytes read
612 &dwNeeded
); // Bytes in the next record
613 if((!bResult
) && (GetLastError () == ERROR_INSUFFICIENT_BUFFER
))
615 HeapFree(GetProcessHeap(), 0, pevlr
);
616 pevlr
= HeapAlloc(GetProcessHeap(), 0, dwNeeded
);
617 g_RecordPtrs
[dwCurrentRecord
] = pevlr
;
619 ReadEventLogW(hEventLog
, // event log handle
620 dwFlags
, // read flags
621 0, // offset; default is 0
622 pevlr
, // pointer to buffer
623 dwNeeded
, // size of buffer
624 &dwRead
, // number of bytes read
625 &dwNeeded
); // bytes in next record
630 LoadStringW(hInst
, IDS_NOT_AVAILABLE
, szUsername
, MAX_PATH
);
631 LoadStringW(hInst
, IDS_NOT_AVAILABLE
, szEventText
, MAX_PATH
);
632 LoadStringW(hInst
, IDS_NONE
, szCategory
, MAX_PATH
);
634 // Get the event source name.
635 lpSourceName
= (LPWSTR
)((LPBYTE
)pevlr
+ sizeof(EVENTLOGRECORD
));
637 // Get the computer name
638 lpComputerName
= (LPWSTR
)((LPBYTE
)pevlr
+ sizeof(EVENTLOGRECORD
) + (wcslen(lpSourceName
) + 1) * sizeof(WCHAR
));
640 // This ist the data section of the current event
641 lpData
= (LPSTR
)((LPBYTE
)pevlr
+ pevlr
->DataOffset
);
643 // Compute the event type
644 EventTimeToSystemTime(pevlr
->TimeWritten
, &time
);
646 // Get the username that generated the event
647 GetEventUserName(pevlr
, szUsername
);
649 GetDateFormatW(LOCALE_USER_DEFAULT
, DATE_SHORTDATE
, &time
, NULL
, szLocalDate
, MAX_PATH
);
650 GetTimeFormatW(LOCALE_USER_DEFAULT
, 0, &time
, NULL
, szLocalTime
, MAX_PATH
);
652 GetEventType(pevlr
->EventType
, szEventTypeText
);
653 GetEventCategory(lpLogName
, lpSourceName
, pevlr
, szCategory
);
655 StringCbPrintfW(szEventID
, sizeof(szEventID
), L
"%u", (pevlr
->EventID
& 0xFFFF));
656 StringCbPrintfW(szCategoryID
, sizeof(szCategoryID
), L
"%u", pevlr
->EventCategory
);
658 lviEventItem
.mask
= LVIF_IMAGE
| LVIF_TEXT
| LVIF_PARAM
;
659 lviEventItem
.iItem
= 0;
660 lviEventItem
.iSubItem
= 0;
661 lviEventItem
.lParam
= (LPARAM
)pevlr
;
662 lviEventItem
.pszText
= szEventTypeText
;
664 switch (pevlr
->EventType
)
666 case EVENTLOG_ERROR_TYPE
:
667 lviEventItem
.iImage
= 2;
670 case EVENTLOG_AUDIT_FAILURE
:
671 lviEventItem
.iImage
= 2;
674 case EVENTLOG_WARNING_TYPE
:
675 lviEventItem
.iImage
= 1;
678 case EVENTLOG_INFORMATION_TYPE
:
679 lviEventItem
.iImage
= 0;
682 case EVENTLOG_AUDIT_SUCCESS
:
683 lviEventItem
.iImage
= 0;
686 case EVENTLOG_SUCCESS
:
687 lviEventItem
.iImage
= 0;
691 lviEventItem
.iItem
= ListView_InsertItem(hwndListView
, &lviEventItem
);
693 ListView_SetItemText(hwndListView
, lviEventItem
.iItem
, 1, szLocalDate
);
694 ListView_SetItemText(hwndListView
, lviEventItem
.iItem
, 2, szLocalTime
);
695 ListView_SetItemText(hwndListView
, lviEventItem
.iItem
, 3, lpSourceName
);
696 ListView_SetItemText(hwndListView
, lviEventItem
.iItem
, 4, szCategory
);
697 ListView_SetItemText(hwndListView
, lviEventItem
.iItem
, 5, szEventID
);
698 ListView_SetItemText(hwndListView
, lviEventItem
.iItem
, 6, szUsername
); //User
699 ListView_SetItemText(hwndListView
, lviEventItem
.iItem
, 7, lpComputerName
); //Computer
700 MultiByteToWideChar(CP_ACP
,
706 ListView_SetItemText(hwndListView
, lviEventItem
.iItem
, 8, szData
); //Event Text
708 dwRead
-= pevlr
->Length
;
709 pevlr
= (EVENTLOGRECORD
*)((LPBYTE
) pevlr
+ pevlr
->Length
);
718 EndDialog(hwndDlg
, 0);
720 StringCchPrintfExW(szWindowTitle
,
721 sizeof(szWindowTitle
) / sizeof(WCHAR
),
725 szTitleTemplate
, szTitle
, lpLogName
); /* i = number of characters written */
726 /* lpComputerName can be NULL here if no records was read */
727 dwMaxLength
= (DWORD
)cchRemaining
;
729 GetComputerNameW(lpTitleTemplateEnd
, &dwMaxLength
);
731 StringCchCopyW(lpTitleTemplateEnd
, dwMaxLength
, lpComputerName
);
733 StringCbPrintfW(szStatusText
, sizeof(szStatusText
), szStatusBarTemplate
, lpLogName
, dwTotalRecords
);
735 // Update the status bar
736 SendMessageW(hwndStatus
, SB_SETTEXT
, (WPARAM
)0, (LPARAM
)szStatusText
);
738 // Set the window title
739 SetWindowTextW(hwndMainWindow
, szWindowTitle
);
741 // Resume list view redraw
742 SendMessageW(hwndListView
, WM_SETREDRAW
, TRUE
, 0);
744 // Close the event log.
745 CloseEventLog(hEventLog
);
755 WCHAR szFileName
[MAX_PATH
];
757 ZeroMemory(szFileName
, sizeof(szFileName
));
759 sfn
.lpstrFile
= szFileName
;
760 sfn
.nMaxFile
= MAX_PATH
;
762 if (!GetSaveFileNameW(&sfn
))
767 hEventLog
= OpenEventLogW(lpComputerName
, lpSourceLogName
);
770 ShowLastWin32Error();
774 if (!BackupEventLogW(hEventLog
, szFileName
))
776 ShowLastWin32Error();
779 CloseEventLog(hEventLog
);
787 WCHAR szFileName
[MAX_PATH
];
788 WCHAR szMessage
[MAX_LOADSTRING
];
790 ZeroMemory(szFileName
, sizeof(szFileName
));
791 ZeroMemory(szMessage
, sizeof(szMessage
));
793 LoadStringW(hInst
, IDS_CLEAREVENTS_MSG
, szMessage
, MAX_LOADSTRING
);
795 sfn
.lpstrFile
= szFileName
;
796 sfn
.nMaxFile
= MAX_PATH
;
798 switch (MessageBoxW(hwndMainWindow
, szMessage
, szTitle
, MB_YESNOCANCEL
| MB_ICONINFORMATION
))
807 sfn
.lpstrFile
= NULL
;
813 if (!GetSaveFileNameW(&sfn
))
821 hEventLog
= OpenEventLogW(lpComputerName
, lpSourceLogName
);
824 ShowLastWin32Error();
828 if (!ClearEventLogW(hEventLog
, sfn
.lpstrFile
))
830 ShowLastWin32Error();
831 CloseEventLog(hEventLog
);
835 CloseEventLog(hEventLog
);
844 QueryEventMessages(lpComputerName
,
850 MyRegisterClass(HINSTANCE hInstance
)
854 wcex
.cbSize
= sizeof(WNDCLASSEX
);
856 wcex
.lpfnWndProc
= WndProc
;
859 wcex
.hInstance
= hInstance
;
860 wcex
.hIcon
= LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_EVENTVWR
));
861 wcex
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
862 wcex
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
863 wcex
.lpszMenuName
= MAKEINTRESOURCE(IDM_EVENTVWR
);
864 wcex
.lpszClassName
= szWindowClass
;
865 wcex
.hIconSm
= (HICON
)LoadImage(hInstance
,
866 MAKEINTRESOURCE(IDI_EVENTVWR
),
872 return RegisterClassExW(&wcex
);
877 GetDisplayNameFile(IN LPCWSTR lpLogName
,
878 OUT PWCHAR lpModuleName
)
882 WCHAR szModuleName
[MAX_PATH
];
886 cbKeyPath
= (wcslen(EVENTLOG_BASE_KEY
) + wcslen(lpLogName
) + 1) * sizeof(WCHAR
);
887 KeyPath
= HeapAlloc(GetProcessHeap(), 0, cbKeyPath
);
893 StringCbCopyW(KeyPath
, cbKeyPath
, EVENTLOG_BASE_KEY
);
894 StringCbCatW(KeyPath
, cbKeyPath
, lpLogName
);
896 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, KeyPath
, 0, KEY_READ
, &hKey
) != ERROR_SUCCESS
)
898 HeapFree(GetProcessHeap(), 0, KeyPath
);
902 cbData
= sizeof(szModuleName
);
903 if (RegQueryValueExW(hKey
, L
"DisplayNameFile", NULL
, NULL
, (LPBYTE
)szModuleName
, &cbData
) == ERROR_SUCCESS
)
905 ExpandEnvironmentStringsW(szModuleName
, lpModuleName
, MAX_PATH
);
909 HeapFree(GetProcessHeap(), 0, KeyPath
);
914 GetDisplayNameID(IN LPCWSTR lpLogName
)
918 DWORD dwMessageID
= 0;
922 cbKeyPath
= (wcslen(EVENTLOG_BASE_KEY
) + wcslen(lpLogName
) + 1) * sizeof(WCHAR
);
923 KeyPath
= HeapAlloc(GetProcessHeap(), 0, cbKeyPath
);
929 StringCbCopyW(KeyPath
, cbKeyPath
, EVENTLOG_BASE_KEY
);
930 StringCbCatW(KeyPath
, cbKeyPath
, lpLogName
);
932 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, KeyPath
, 0, KEY_READ
, &hKey
) != ERROR_SUCCESS
)
934 HeapFree(GetProcessHeap(), 0, KeyPath
);
938 cbData
= sizeof(dwMessageID
);
939 RegQueryValueExW(hKey
, L
"DisplayNameID", NULL
, NULL
, (LPBYTE
)&dwMessageID
, &cbData
);
942 HeapFree(GetProcessHeap(), 0, KeyPath
);
955 DWORD dwMaxKeyLength
;
956 WCHAR szModuleName
[MAX_PATH
];
957 LPWSTR lpDisplayName
;
958 HANDLE hLibrary
= NULL
;
960 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, EVENTLOG_BASE_KEY
, 0, KEY_READ
, &hKey
) != ERROR_SUCCESS
)
965 if (RegQueryInfoKeyW(hKey
, NULL
, NULL
, NULL
, &dwNumLogs
, &dwMaxKeyLength
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
) != ERROR_SUCCESS
)
977 LogNames
= HeapAlloc(GetProcessHeap(), 0, (dwNumLogs
+ 1) * sizeof(WCHAR
*));
985 for (dwIndex
= 0; dwIndex
< dwNumLogs
; dwIndex
++)
987 LogNames
[dwIndex
] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, ((dwMaxKeyLength
+ 1) * sizeof(WCHAR
)));
989 if (LogNames
[dwIndex
] != NULL
)
991 lpcName
= dwMaxKeyLength
+ 1;
993 if (RegEnumKeyExW(hKey
, dwIndex
, LogNames
[dwIndex
], &lpcName
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
995 lpDisplayName
= NULL
;
997 ZeroMemory(szModuleName
, sizeof(szModuleName
));
998 GetDisplayNameFile(LogNames
[dwIndex
], szModuleName
);
999 dwMessageID
= GetDisplayNameID(LogNames
[dwIndex
]);
1001 hLibrary
= LoadLibraryExW(szModuleName
, NULL
, DONT_RESOLVE_DLL_REFERENCES
| LOAD_LIBRARY_AS_DATAFILE
);
1002 if (hLibrary
!= NULL
)
1004 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_HMODULE
, hLibrary
, dwMessageID
, 0, (LPWSTR
)&lpDisplayName
, 0, NULL
);
1005 FreeLibrary(hLibrary
);
1010 InsertMenuW(hMainMenu
, IDM_SAVE_PROTOCOL
, MF_BYCOMMAND
| MF_STRING
, ID_FIRST_LOG
+ dwIndex
, lpDisplayName
);
1014 InsertMenuW(hMainMenu
, IDM_SAVE_PROTOCOL
, MF_BYCOMMAND
| MF_STRING
, ID_FIRST_LOG
+ dwIndex
, LogNames
[dwIndex
]);
1017 LocalFree(lpDisplayName
);
1022 InsertMenuW(hMainMenu
, IDM_SAVE_PROTOCOL
, MF_BYCOMMAND
| MF_SEPARATOR
, ID_FIRST_LOG
+ dwIndex
+ 1, NULL
);
1040 for (dwIndex
= 0; dwIndex
< dwNumLogs
; dwIndex
++)
1042 if (LogNames
[dwIndex
])
1044 HeapFree(GetProcessHeap(), 0, LogNames
[dwIndex
]);
1047 DeleteMenu(hMainMenu
, ID_FIRST_LOG
+ dwIndex
, MF_BYCOMMAND
);
1050 DeleteMenu(hMainMenu
, ID_FIRST_LOG
+ dwIndex
+ 1, MF_BYCOMMAND
);
1052 HeapFree(GetProcessHeap(), 0, LogNames
);
1061 InitInstance(HINSTANCE hInstance
,
1065 LVCOLUMNW lvc
= {0};
1068 hInst
= hInstance
; // Store instance handle in our global variable
1070 hwndMainWindow
= CreateWindowW(szWindowClass
,
1072 WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
,
1073 CW_USEDEFAULT
, 0, CW_USEDEFAULT
, 0,
1078 if (!hwndMainWindow
)
1083 hwndStatus
= CreateWindowExW(0, // no extended styles
1084 STATUSCLASSNAMEW
, // status bar
1085 L
"Done.", // no text
1086 WS_CHILD
| WS_BORDER
| WS_VISIBLE
, // styles
1087 0, 0, 0, 0, // x, y, cx, cy
1088 hwndMainWindow
, // parent window
1089 (HMENU
)100, // window ID
1090 hInstance
, // instance
1091 NULL
); // window data
1093 // Create our listview child window. Note that I use WS_EX_CLIENTEDGE
1094 // and WS_BORDER to create the normal "sunken" look. Also note that
1095 // LVS_EX_ styles cannot be set in CreateWindowEx().
1096 hwndListView
= CreateWindowExW(WS_EX_CLIENTEDGE
,
1099 LVS_SHOWSELALWAYS
| WS_CHILD
| WS_VISIBLE
| LVS_REPORT
,
1109 // After the ListView is created, we can add extended list view styles.
1110 (void)ListView_SetExtendedListViewStyle (hwndListView
, LVS_EX_FULLROWSELECT
);
1112 // Create the ImageList
1113 hSmall
= ImageList_Create(GetSystemMetrics(SM_CXSMICON
),
1114 GetSystemMetrics(SM_CYSMICON
),
1119 // Add event type icons to ImageList
1120 ImageList_AddIcon (hSmall
, LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_INFORMATIONICON
)));
1121 ImageList_AddIcon (hSmall
, LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_WARNINGICON
)));
1122 ImageList_AddIcon (hSmall
, LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_ERRORICON
)));
1124 // Assign ImageList to List View
1125 (void)ListView_SetImageList (hwndListView
, hSmall
, LVSIL_SMALL
);
1127 // Now set up the listview with its columns.
1128 lvc
.mask
= LVCF_TEXT
| LVCF_WIDTH
;
1130 LoadStringW(hInstance
,
1133 sizeof(szTemp
) / sizeof(WCHAR
));
1134 lvc
.pszText
= szTemp
;
1135 (void)ListView_InsertColumn(hwndListView
, 0, &lvc
);
1138 LoadStringW(hInstance
,
1141 sizeof(szTemp
) / sizeof(WCHAR
));
1142 lvc
.pszText
= szTemp
;
1143 (void)ListView_InsertColumn(hwndListView
, 1, &lvc
);
1146 LoadStringW(hInstance
,
1149 sizeof(szTemp
) / sizeof(WCHAR
));
1150 lvc
.pszText
= szTemp
;
1151 (void)ListView_InsertColumn(hwndListView
, 2, &lvc
);
1154 LoadStringW(hInstance
,
1157 sizeof(szTemp
) / sizeof(WCHAR
));
1158 lvc
.pszText
= szTemp
;
1159 (void)ListView_InsertColumn(hwndListView
, 3, &lvc
);
1162 LoadStringW(hInstance
,
1165 sizeof(szTemp
) / sizeof(WCHAR
));
1166 lvc
.pszText
= szTemp
;
1167 (void)ListView_InsertColumn(hwndListView
, 4, &lvc
);
1170 LoadStringW(hInstance
,
1173 sizeof(szTemp
) / sizeof(WCHAR
));
1174 lvc
.pszText
= szTemp
;
1175 (void)ListView_InsertColumn(hwndListView
, 5, &lvc
);
1178 LoadStringW(hInstance
,
1181 sizeof(szTemp
) / sizeof(WCHAR
));
1182 lvc
.pszText
= szTemp
;
1183 (void)ListView_InsertColumn(hwndListView
, 6, &lvc
);
1186 LoadStringW(hInstance
,
1189 sizeof(szTemp
) / sizeof(WCHAR
));
1190 lvc
.pszText
= szTemp
;
1191 (void)ListView_InsertColumn(hwndListView
, 7, &lvc
);
1194 LoadStringW(hInstance
,
1195 IDS_COLUMNEVENTDATA
,
1197 sizeof(szTemp
) / sizeof(WCHAR
));
1198 lvc
.pszText
= szTemp
;
1199 (void)ListView_InsertColumn(hwndListView
, 8, &lvc
);
1201 // Initialize the save Dialog
1202 ZeroMemory(&sfn
, sizeof(sfn
));
1203 ZeroMemory(szSaveFilter
, sizeof(szSaveFilter
));
1205 LoadStringW(hInst
, IDS_SAVE_FILTER
, szSaveFilter
, MAX_LOADSTRING
);
1207 sfn
.lStructSize
= sizeof(sfn
);
1208 sfn
.hwndOwner
= hwndMainWindow
;
1209 sfn
.hInstance
= hInstance
;
1210 sfn
.lpstrFilter
= szSaveFilter
;
1211 sfn
.lpstrInitialDir
= NULL
;
1212 sfn
.Flags
= OFN_HIDEREADONLY
| OFN_SHAREAWARE
;
1213 sfn
.lpstrDefExt
= NULL
;
1215 ShowWindow(hwndMainWindow
, nCmdShow
);
1216 UpdateWindow(hwndMainWindow
);
1220 QueryEventMessages(lpComputerName
, LogNames
[0]);
1222 CheckMenuRadioItem(GetMenu(hwndMainWindow
), ID_FIRST_LOG
, ID_FIRST_LOG
+ dwNumLogs
, ID_FIRST_LOG
, MF_BYCOMMAND
);
1229 WndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1237 hMainMenu
= GetMenu(hWnd
);
1241 switch (((LPNMHDR
)lParam
)->code
)
1244 hdr
= (NMHDR FAR
*)lParam
;
1245 if (hdr
->hwndFrom
== hwndListView
)
1247 LPNMITEMACTIVATE lpnmitem
= (LPNMITEMACTIVATE
)lParam
;
1249 if (lpnmitem
->iItem
!= -1)
1252 MAKEINTRESOURCE(IDD_EVENTPROPERTIES
),
1262 // Parse the menu selections:
1264 if ((LOWORD(wParam
) >= ID_FIRST_LOG
) && (LOWORD(wParam
) <= ID_FIRST_LOG
+ dwNumLogs
))
1266 if (LogNames
[LOWORD(wParam
) - ID_FIRST_LOG
])
1268 if (QueryEventMessages(lpComputerName
, LogNames
[LOWORD(wParam
) - ID_FIRST_LOG
]))
1270 CheckMenuRadioItem(GetMenu(hWnd
), ID_FIRST_LOG
, ID_FIRST_LOG
+ dwNumLogs
, LOWORD(wParam
), MF_BYCOMMAND
);
1276 switch (LOWORD(wParam
))
1278 case IDM_SAVE_PROTOCOL
:
1282 case IDM_CLEAR_EVENTS
:
1294 DialogBox(hInst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hWnd
, About
);
1298 MessageBoxW(hwndMainWindow
,
1299 L
"Help not implemented yet!",
1301 MB_OK
| MB_ICONINFORMATION
);
1305 DestroyWindow(hWnd
);
1309 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
1314 // Gets the window rectangle
1315 GetClientRect(hWnd
, &rect
);
1317 // Relocate the listview
1318 MoveWindow(hwndListView
,
1325 // Resize the statusbar;
1326 SendMessage(hwndStatus
, message
, wParam
, lParam
);
1336 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
1343 // Message handler for about box.
1345 About(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1347 UNREFERENCED_PARAMETER(lParam
);
1352 return (INT_PTR
)TRUE
;
1356 if (LOWORD(wParam
) == IDOK
|| LOWORD(wParam
) == IDCANCEL
)
1358 EndDialog(hDlg
, LOWORD(wParam
));
1359 return (INT_PTR
)TRUE
;
1364 return (INT_PTR
)FALSE
;
1368 DisplayEvent(HWND hDlg
)
1370 WCHAR szEventType
[MAX_PATH
];
1371 WCHAR szTime
[MAX_PATH
];
1372 WCHAR szDate
[MAX_PATH
];
1373 WCHAR szUser
[MAX_PATH
];
1374 WCHAR szComputer
[MAX_PATH
];
1375 WCHAR szSource
[MAX_PATH
];
1376 WCHAR szCategory
[MAX_PATH
];
1377 WCHAR szEventID
[MAX_PATH
];
1378 WCHAR szEventText
[EVENT_MESSAGE_EVENTTEXT_BUFFER
];
1379 WCHAR szEventData
[MAX_PATH
];
1380 BOOL bEventData
= FALSE
;
1382 EVENTLOGRECORD
* pevlr
;
1385 // Get index of selected item
1386 iIndex
= (int)SendMessage (hwndListView
, LVM_GETNEXTITEM
, -1, LVNI_SELECTED
| LVNI_FOCUSED
);
1388 li
.mask
= LVIF_PARAM
;
1392 (void)ListView_GetItem(hwndListView
, &li
);
1394 pevlr
= (EVENTLOGRECORD
*)li
.lParam
;
1398 ListView_GetItemText(hwndListView
, iIndex
, 0, szEventType
, sizeof(szEventType
) / sizeof(WCHAR
));
1399 ListView_GetItemText(hwndListView
, iIndex
, 1, szDate
, sizeof(szDate
) / sizeof(WCHAR
));
1400 ListView_GetItemText(hwndListView
, iIndex
, 2, szTime
, sizeof(szTime
) / sizeof(WCHAR
));
1401 ListView_GetItemText(hwndListView
, iIndex
, 3, szSource
, sizeof(szSource
) / sizeof(WCHAR
));
1402 ListView_GetItemText(hwndListView
, iIndex
, 4, szCategory
, sizeof(szCategory
) / sizeof(WCHAR
));
1403 ListView_GetItemText(hwndListView
, iIndex
, 5, szEventID
, sizeof(szEventID
) / sizeof(WCHAR
));
1404 ListView_GetItemText(hwndListView
, iIndex
, 6, szUser
, sizeof(szUser
) / sizeof(WCHAR
));
1405 ListView_GetItemText(hwndListView
, iIndex
, 7, szComputer
, sizeof(szComputer
) / sizeof(WCHAR
));
1407 bEventData
= !(pevlr
->DataLength
== 0);
1409 if (pevlr
->DataLength
> 0)
1411 MultiByteToWideChar(CP_ACP
,
1413 (LPCSTR
)((LPBYTE
)pevlr
+ pevlr
->DataOffset
),
1419 GetEventMessage(lpSourceLogName
, szSource
, pevlr
, szEventText
);
1421 EnableWindow(GetDlgItem(hDlg
, IDC_BYTESRADIO
), bEventData
);
1422 EnableWindow(GetDlgItem(hDlg
, IDC_WORDRADIO
), bEventData
);
1424 SetDlgItemTextW(hDlg
, IDC_EVENTDATESTATIC
, szDate
);
1425 SetDlgItemTextW(hDlg
, IDC_EVENTTIMESTATIC
, szTime
);
1427 SetDlgItemTextW(hDlg
, IDC_EVENTUSERSTATIC
, szUser
);
1428 SetDlgItemTextW(hDlg
, IDC_EVENTSOURCESTATIC
, szSource
);
1429 SetDlgItemTextW(hDlg
, IDC_EVENTCOMPUTERSTATIC
, szComputer
);
1430 SetDlgItemTextW(hDlg
, IDC_EVENTCATEGORYSTATIC
, szCategory
);
1431 SetDlgItemTextW(hDlg
, IDC_EVENTIDSTATIC
, szEventID
);
1432 SetDlgItemTextW(hDlg
, IDC_EVENTTYPESTATIC
, szEventType
);
1433 SetDlgItemTextW(hDlg
, IDC_EVENTTEXTEDIT
, szEventText
);
1434 SetDlgItemTextW(hDlg
, IDC_EVENTDATAEDIT
, szEventData
);
1439 L
"No Items in ListView",
1441 MB_OK
| MB_ICONINFORMATION
);
1446 CopyEventEntry(HWND hWnd
)
1448 WCHAR output
[4130], tmpHeader
[512];
1449 WCHAR szEventType
[MAX_PATH
];
1450 WCHAR szSource
[MAX_PATH
];
1451 WCHAR szCategory
[MAX_PATH
];
1452 WCHAR szEventID
[MAX_PATH
];
1453 WCHAR szDate
[MAX_PATH
];
1454 WCHAR szTime
[MAX_PATH
];
1455 WCHAR szUser
[MAX_PATH
];
1456 WCHAR szComputer
[MAX_PATH
];
1457 WCHAR evtDesc
[ENTRY_SIZE
];
1460 if (!OpenClipboard(hWnd
))
1463 /* First, empty the clipboard before we begin to use it */
1466 /* Get the formatted text needed to place the content into */
1467 LoadStringW(hInst
, IDS_COPY
, tmpHeader
, sizeof(tmpHeader
) / sizeof(WCHAR
));
1469 /* Grabs all the information and get it ready for the clipboard */
1470 GetDlgItemText(hWnd
, IDC_EVENTTYPESTATIC
, szEventType
, MAX_PATH
);
1471 GetDlgItemText(hWnd
, IDC_EVENTSOURCESTATIC
, szSource
, MAX_PATH
);
1472 GetDlgItemText(hWnd
, IDC_EVENTCATEGORYSTATIC
, szCategory
, MAX_PATH
);
1473 GetDlgItemText(hWnd
, IDC_EVENTIDSTATIC
, szEventID
, MAX_PATH
);
1474 GetDlgItemText(hWnd
, IDC_EVENTDATESTATIC
, szDate
, MAX_PATH
);
1475 GetDlgItemText(hWnd
, IDC_EVENTTIMESTATIC
, szTime
, MAX_PATH
);
1476 GetDlgItemText(hWnd
, IDC_EVENTUSERSTATIC
, szUser
, MAX_PATH
);
1477 GetDlgItemText(hWnd
, IDC_EVENTCOMPUTERSTATIC
, szComputer
, MAX_PATH
);
1478 GetDlgItemText(hWnd
, IDC_EVENTTEXTEDIT
, evtDesc
, ENTRY_SIZE
);
1480 /* Consolidate the information into on big piece */
1481 wsprintfW(output
, tmpHeader
, szEventType
, szSource
, szCategory
, szEventID
, szDate
, szTime
, szUser
, szComputer
, evtDesc
);
1483 /* Sort out the memory needed to write to the clipboard */
1484 hMem
= GlobalAlloc(GMEM_MOVEABLE
, ENTRY_SIZE
);
1485 memcpy(GlobalLock(hMem
), output
, ENTRY_SIZE
);
1488 /* Write the final content to the clipboard */
1489 SetClipboardData(CF_UNICODETEXT
, hMem
);
1491 /* Close the clipboard once we're done with it */
1497 StatusMessageWindowProc(IN HWND hwndDlg
,
1502 UNREFERENCED_PARAMETER(wParam
);
1516 InitDetailsDlg(HWND hDlg
)
1518 HANDLE nextIcon
= LoadImage(hInst
, MAKEINTRESOURCE(IDI_NEXT
), IMAGE_ICON
, 16, 16, LR_DEFAULTCOLOR
);
1519 HANDLE prevIcon
= LoadImage(hInst
, MAKEINTRESOURCE(IDI_PREV
), IMAGE_ICON
, 16, 16, LR_DEFAULTCOLOR
);
1520 HANDLE copyIcon
= LoadImage(hInst
, MAKEINTRESOURCE(IDI_COPY
), IMAGE_ICON
, 16, 16, LR_DEFAULTCOLOR
);
1522 SendMessage(GetDlgItem(hDlg
, IDC_NEXT
), BM_SETIMAGE
, (WPARAM
)IMAGE_ICON
, (LPARAM
)nextIcon
);
1523 SendMessage(GetDlgItem(hDlg
, IDC_PREVIOUS
), BM_SETIMAGE
, (WPARAM
)IMAGE_ICON
, (LPARAM
)prevIcon
);
1524 SendMessage(GetDlgItem(hDlg
, IDC_COPY
), BM_SETIMAGE
, (WPARAM
)IMAGE_ICON
, (LPARAM
)copyIcon
);
1527 // Message handler for event details box.
1529 EventDetails(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1531 UNREFERENCED_PARAMETER(lParam
);
1536 InitDetailsDlg(hDlg
);
1538 // Show event info on dialog box
1540 return (INT_PTR
)TRUE
;
1543 switch (LOWORD(wParam
))
1547 EndDialog(hDlg
, LOWORD(wParam
));
1548 return (INT_PTR
)TRUE
;
1551 SendMessage(hwndListView
, WM_KEYDOWN
, VK_UP
, 0);
1553 // Show event info on dialog box
1555 return (INT_PTR
)TRUE
;
1558 SendMessage(hwndListView
, WM_KEYDOWN
, VK_DOWN
, 0);
1560 // Show event info on dialog box
1562 return (INT_PTR
)TRUE
;
1565 CopyEventEntry(hDlg
);
1566 return (INT_PTR
)TRUE
;
1568 case IDC_BYTESRADIO
:
1569 return (INT_PTR
)TRUE
;
1572 return (INT_PTR
)TRUE
;
1576 L
"Help not implemented yet!",
1578 MB_OK
| MB_ICONINFORMATION
);
1579 return (INT_PTR
)TRUE
;
1587 return (INT_PTR
)FALSE
;