Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2005.02.20;
Скачать: [xml.tar.bz2];

Вниз

Запись сообщений сервиса в EventLog.   Найти похожие ветки 

 
Edge   (2005-02-07 10:56) [0]

У меня из сервиса записываются сообщения:
LogMessage("Info", EVENTLOG_INFORMATION_TYPE, 0, 0);
В EventLog Кроме информации добавляется:
Не найдено описание для события с кодом ( 0 ) в источнике ( Service1 ). Возможно, на локальном компьютере нет нужных данных в реестре или файлов DLL сообщений для отображения сообщений удаленного компьютера. Попробуйте использовать ключ /AUXSOURCE= для получения этого описания, - дополнительные сведения об этом содержатся в справке. В записи события содержится следующая информация:
- в WinXP.
Как сделать чтобы этот тект не добавлялся?


 
Erik1 ©   (2005-02-07 13:16) [1]

Можно написать так, но это не все!
LogMessage(MyMessage,EVENTLOG_INFORMATION_TYPE,0,Message_ServiceStarted);

ConstMessages.pas:
const
 Message_ServiceStarted = $400003F8;
 Message_ServiceStopped = $400003F9;
 Msg_ServiceError = $C00003FF;
 Msg_ServiceStatictic = $800003FD;

Дальше самое интересное, надо создать message.h такого содержания:
//
//  Values are 32 bit values layed out as follows:
//
//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
//  +---+-+-+-----------------------+-------------------------------+
//  |Sev|C|R|     Facility          |               Code            |
//  +---+-+-+-----------------------+-------------------------------+
//
//  where
//
//      Sev - is the severity code
//
//          00 - Success
//          01 - Informational
//          10 - Warning
//          11 - Error
//
//      C - is the Customer code flag
//
//      R - is a reserved bit
//
//      Facility - is the facility code
//
//      Code - is the facility"s status code
//
//
// Define the facility codes
//

//
// Define the severity codes
//
#define STATUS_SEVERITY_WARNING          0x2
#define STATUS_SEVERITY_SUCCESS          0x0
#define STATUS_SEVERITY_INFORMATIONAL    0x1
#define STATUS_SEVERITY_ERROR            0x3

//
// MessageId: Msg_ServiceInfo
//
// MessageText:
//
//  Info %1!s!
//
#define Msg_ServiceInfo                  0x400003F7L

//
// MessageId: Message_ServiceStarted
//
// MessageText:
//
//  Service started
//
#define Message_ServiceStarted           0x400003F8L

//
// MessageId: Message_ServiceStopped
//
// MessageText:
//
//  Service shotdown
//
#define Message_ServiceStopped           0x400003F9L

//
// MessageId: Message_ServicePaused
//
// MessageText:
//
//  Service paused
//
#define Message_ServicePaused            0x400003FAL

//
// MessageId: Message_ServiceResumed
//
// MessageText:
//
//  Service resume
//
#define Message_ServiceResumed           0x400003FBL

//
// MessageId: Msg_ServiceStatictic
//
// MessageText:
//
//  Current status: %1!s!
//
#define Msg_ServiceStatictic             0x800003FDL

//
// MessageId: Msg_ServiceError
//
// MessageText:
//
//  Error : %1!s!
//
#define Msg_ServiceError                 0xC00003FFL

и Messages.mc
SeverityNames=(Success=0x0:STATUS_SEVERITY_SUCCESS
              Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
              Warning=0x2:STATUS_SEVERITY_WARNING
              Error=0x3:STATUS_SEVERITY_ERROR
             )

MessageID=1015
Severity=Informational
SymbolicName=Msg_ServiceInfo
Language=English
Info %1!s!
.

MessageID=1016
Severity=Informational
SymbolicName=Message_ServiceStarted
Language=English
Service started
.
MessageID=1017
Severity=Informational
SymbolicName=Message_ServiceStopped
Language=English
Service shotdown
.
MessageID=1018
Severity=Informational
SymbolicName=Message_ServicePaused
Language=English
Service paused
.
MessageID=1019
Severity=Informational
SymbolicName=Message_ServiceResumed
Language=English
Service resume
.
MessageID=1021
Severity=Warning
SymbolicName=Msg_ServiceStatictic
Language=English
Current status: %1!s!
.
MessageID=1023
Severity=Error
SymbolicName=Msg_ServiceError
Language=English
Error : %1!s!
.
Далее Messages.rc
LANGUAGE 0x9,0x1
1 11 MSG00001.bin

MSG00001.bin получается при компиляции messages.mc "Microsoft (R) Message Compiler" mc.exe из комплекта VC++.

И после этого надо из Messages.rc создать dll:
library Mesages;
{$R "messages.res" "messages.rc"}
uses
 ConstMessages in "ConstMessages.pas";
begin
end.
И в завершении наших усилий надо рарегестрировать наш ресурс
Messages.reg:
REGEDIT4

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\fDJP]
"EventMessageFile"="c:\\Borland\\Delphi5\\Projects\\Starvara\\Messages\\Mesages.dll"
"TypesSupported"=dword:00000007


 
Erik1 ©   (2005-02-07 13:18) [2]

Тут конечно куча нюансов, но это мало кому нужно, чтобы писать статью. Добавлю, что fDJP название сервиса.



Страницы: 1 вся ветка

Форум: "Основная";
Текущий архив: 2005.02.20;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.042 c
1-1107872707
Stype
2005-02-08 17:25
2005.02.20
Директория Windows


14-1106903067
stud
2005-01-28 12:04
2005.02.20
борьба с виндой 2000


14-1106762330
Nic87
2005-01-26 20:58
2005.02.20
Появился новый сайт по программированию!


3-1106078305
Eraser
2005-01-18 22:58
2005.02.20
Восстановление базы данных mdb (Access)


10-1082101998
pirat
2004-04-16 11:53
2005.02.20
интерфейсы Explorer





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский