Hi Peter, 

I have installed MC and, using the text you supplied, it produces an .rc
file, D5 says "Unsupported 16 bit resource". Is there some undocumented
switch for mc? or have I got the wrong version? I have installed VC++ 6.0
from August 1998.

Ta,
Dave.

-----Original Message-----
From: Peter G Jones [mailto:[EMAIL PROTECTED]]
Sent: Saturday, 20 November 1999 5:32 a.m.
To: Multiple recipients of list delphi
Subject: Re: [DUG]: Service.LogMessage


It's an easy question and a long answer.

1:  You need to get hold of the MS message compiler.  It comes with VC++ and

I think it's in the Platform SDK somewhere.
2:  You need to create a .MC file with your messages in it.  I created a 
simple one with generic messages.
3:  Compile the .MC with MC.EXE and include the resultant .res file into 
your service exe.
4:  In the LogMessage calls pass in the extra params identifying the message

id and severity etc.

An example .mc file for you :


MessageIdTypedef=DWORD
SeverityNames=(Success=0x0:STATUS_SEVERITY_SUCCESS
               Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
               Warning=0x2:STATUS_SEVERITY_WARNING
               Error=0x3:STATUS_SEVERITY_ERROR
              )
FacilityNames=(System=0x0:FACILITY_SYSTEM
               Runtime=0x2:FACILITY_RUNTIME
               Stubs=0x3:FACILITY_STUBS
               Io=0x4:FACILITY_IO_ERROR_CODE
              )

LanguageNames=(English=0x409:MSG00409)

MessageId=0x1
Severity=Informational
Facility=Runtime
SymbolicName=MSG_GENERAL_INFO
Language=English
%1
.

MessageId=0x2
Severity=Error
Facility=Runtime
SymbolicName=MSG_GENERAL_ERROR
Language=English
%1
.

MessageId=0x3
Severity=Warning
Facility=Runtime
SymbolicName=MSG_GENERAL_WARNING
Language=English
%1
.



You also need a .h file:

//
//  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 FACILITY_SYSTEM                  0x0
#define FACILITY_STUBS                   0x3
#define FACILITY_RUNTIME                 0x2
#define FACILITY_IO_ERROR_CODE           0x4


//
// 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_GENERAL_INFO
//
// MessageText:
//
//  %1
//
#define MSG_GENERAL_INFO                 ((DWORD)0x40020001L)

//
// MessageId: MSG_GENERAL_ERROR
//
// MessageText:
//
//  %1
//
#define MSG_GENERAL_ERROR                ((DWORD)0xC0020002L)

//
// MessageId: MSG_GENERAL_WARNING
//
// MessageText:
//
//  %1
//
#define MSG_GENERAL_WARNING              ((DWORD)0x80020003L)


Now in your delphi code, do this:

...

{$R messages.res}

...

LogMessage('Starting service.',
    EVENTLOG_INFORMATION_TYPE, 0, MSG_GENERAL_INFO);





>From: David O'Brien <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
>Subject: [DUG]:  Service.LogMessage
>Date: Thu, 18 Nov 1999 15:31:37 +1300
>
>Hi there....
>
>Another silly service question.
>
>When I log a message to the event log, how do I assign a description to the
>event? The log seems to want to look in my application for the description.
>
>Any Ideas?
>
>Ta,
>Dave.
>---------------------------------------------------------------------------
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to