Problem with message files connected to an EXE file 
Author Message
 Problem with message files connected to an EXE file

I'm currently writing a Win32 console application using VC++ 6.0. It
should later on be translated into a service, but currently it's just
a normal EXE file that can be started from a cmd prompt.

My question is: How do I connect a .mc file and get it compiled and
linked into an EXE file? I'm using VC++6.0 SP2. Here's what I've done
so far.

Now i wanted to do some eventlogging using custom message files, which
I had tried before using an empty DLL with DllMain() returning true,
and that worked. Now I tried to do the same with my EXE file.

I first created my .mc file, which looks like this:

MessageId=0x1000
Severity=Informational
Facility=Application
SymbolicName=SBI_FEED_SERVICE_STARTED
Language=English
SBI feed service started.
.

followed by approximately 50 different messages (with severtiy set to
Informational, Warning and Error). I compiled this using mc, and got
no warnings.

Then I added the .bin and .mc files to my VC++ project, and set up a
custom build for the .mc file.

I compile, and it compiles the .mc file as well, but it doesn't seem
to link in the messagefile.

I've tried doing some testlogging, which worked before, and the code
looks like this (I cut out some of the code from the class):

MAEventLog::MAEventLog(char *uncServerName, char *sourceName)
{
        eventlogHandle = RegisterEventSource(uncServerName,
sourceName);

        if (!eventlogHandle) {
                //Can't create eventlog handle
        }

Quote:
}

MAEventLog::~MAEventLog()
{
        if (eventlogHandle)
                DeregisterEventSource(eventlogHandle);

Quote:
}

int MAEventLog::logEvent(int type, DWORD msgid, char *msg1, char
*msg2)
{
        char *eventstrings[3];
        int rc;

        eventstrings[0] = msg1;
        eventstrings[1] = msg2;

        rc = (int) ReportEvent(eventlogHandle, (WORD) type, 0,
                        msgid, NULL, 0, 0, (const char **)
eventstrings, NULL);

        return(rc);

Quote:
}

If I do a logEvent() with one of the ID:s as input, and msg1=null and
msg2=null, it reports an event, but it says:

The description for Event ID ( 4096 ) in Source ( SBI_feed_service )
could not be found. It contains the following insertion string(s): .

I've set up the registry with an entry for
Application/SBI_feed_service containing two parameters;
EventMessageFile which points to my EXE file, and TypesSupported set
to 7 (since I want to allow information, warning and error types).

It looks like the event viewer locks the EXE file correctly, since if
I start my program so it logs one event, then exit it and open the
eventviewer, and after that recompiles, it says it can't write to the
output file since it's currently locked. If I close the eventviewer I
can link and create the EXE file again.

What do I have to do to make VC++ link the message file to my EXE and
get the eventviewer to get the strings from my EXE?

--
mvh Mathias Axelsson



Mon, 12 Nov 2001 03:00:00 GMT  
 Problem with message files connected to an EXE file
Hace you included the generated .rc file in the project?  You can either
include it directly in the project or include it in your project resource
file.  You also need to register your message file with the event logger.
Quote:

>I'm currently writing a Win32 console application using VC++ 6.0. It
>should later on be translated into a service, but currently it's just
>a normal EXE file that can be started from a cmd prompt.

>My question is: How do I connect a .mc file and get it compiled and
>linked into an EXE file? I'm using VC++6.0 SP2. Here's what I've done
>so far.

>Now i wanted to do some eventlogging using custom message files, which
>I had tried before using an empty DLL with DllMain() returning true,
>and that worked. Now I tried to do the same with my EXE file.

>I first created my .mc file, which looks like this:

>MessageId=0x1000
>Severity=Informational
>Facility=Application
>SymbolicName=SBI_FEED_SERVICE_STARTED
>Language=English
>SBI feed service started.
>.

>followed by approximately 50 different messages (with severtiy set to
>Informational, Warning and Error). I compiled this using mc, and got
>no warnings.

>Then I added the .bin and .mc files to my VC++ project, and set up a
>custom build for the .mc file.

>I compile, and it compiles the .mc file as well, but it doesn't seem
>to link in the messagefile.

>I've tried doing some testlogging, which worked before, and the code
>looks like this (I cut out some of the code from the class):

>MAEventLog::MAEventLog(char *uncServerName, char *sourceName)
>{
> eventlogHandle = RegisterEventSource(uncServerName,
>sourceName);

> if (!eventlogHandle) {
> //Can't create eventlog handle
> }
>}

>MAEventLog::~MAEventLog()
>{
> if (eventlogHandle)
> DeregisterEventSource(eventlogHandle);
>}

>int MAEventLog::logEvent(int type, DWORD msgid, char *msg1, char
>*msg2)
>{
> char *eventstrings[3];
> int rc;

> eventstrings[0] = msg1;
> eventstrings[1] = msg2;

> rc = (int) ReportEvent(eventlogHandle, (WORD) type, 0,
> msgid, NULL, 0, 0, (const char **)
>eventstrings, NULL);

> return(rc);
>}

>If I do a logEvent() with one of the ID:s as input, and msg1=null and
>msg2=null, it reports an event, but it says:

>The description for Event ID ( 4096 ) in Source ( SBI_feed_service )
>could not be found. It contains the following insertion string(s): .

>I've set up the registry with an entry for
>Application/SBI_feed_service containing two parameters;
>EventMessageFile which points to my EXE file, and TypesSupported set
>to 7 (since I want to allow information, warning and error types).

>It looks like the event viewer locks the EXE file correctly, since if
>I start my program so it logs one event, then exit it and open the
>eventviewer, and after that recompiles, it says it can't write to the
>output file since it's currently locked. If I close the eventviewer I
>can link and create the EXE file again.

>What do I have to do to make VC++ link the message file to my EXE and
>get the eventviewer to get the strings from my EXE?

>--
>mvh Mathias Axelsson



Mon, 12 Nov 2001 03:00:00 GMT  
 Problem with message files connected to an EXE file
On Thu, 27 May 1999 08:15:43 -0400, "Andrew E. Walldorff"

Quote:

> Hace you included the generated .rc file in the project?  You can either
> include it directly in the project or include it in your project resource
> file.  You also need to register your message file with the event logger.

That was the part (including the .rc file) that I had forgotten.
Thanks for the help.

--
mvh Mathias Axelsson



Mon, 12 Nov 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. connecting gif-files to one file

2. Compiler error messages in .exe file

3. Q: exchange Messages between two files(.exe)

4. Q: exchange Messages between two files(.exe)

5. Using Resource .RES files to stick .bmp's and .wav files into .exe

6. howto: include AVI file into *.exe file

7. How to integrate dll files into EXE file?

8. Link new resource file with existing *.exe file ??

9. My exe file needs to access files at an FTP site

10. howto: include AVI file into *.exe file

11. Save a cursor file from exe file

12. Text file linked into exe-file

 

 
Powered by phpBB® Forum Software