Click here to Skip to main content
15,912,400 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCalling Variable Pin
knowvc31-Aug-08 22:27
knowvc31-Aug-08 22:27 
AnswerRe: Calling Variable Pin
Cedric Moonen31-Aug-08 22:49
Cedric Moonen31-Aug-08 22:49 
QuestionInitializing inside a thread error Pin
monsieur_jj31-Aug-08 22:17
monsieur_jj31-Aug-08 22:17 
AnswerRe: Initializing inside a thread error Pin
Mckay.Lai31-Aug-08 22:21
Mckay.Lai31-Aug-08 22:21 
GeneralRe: Initializing inside a thread error Pin
monsieur_jj31-Aug-08 23:27
monsieur_jj31-Aug-08 23:27 
GeneralRe: Initializing inside a thread error Pin
Mckay.Lai1-Sep-08 0:04
Mckay.Lai1-Sep-08 0:04 
GeneralRe: Initializing inside a thread error Pin
monsieur_jj1-Sep-08 15:19
monsieur_jj1-Sep-08 15:19 
QuestionProgramming the Windows Vista Event Log Pin
Shashi.Shinde31-Aug-08 22:15
Shashi.Shinde31-Aug-08 22:15 
Hello,



This is with reference to an article at http://www.developer.com/net/cplus/article.php/3624581 about Programming the Windows Vista Event Log.



We build and run the application as per information found in this article. And getting the Operational and Debug events.

Thats great.

Now, we have made some changes and getting some wrong output.

I request you to have quick look on the following stuff and let us know where we are wrong.



We have made some changes in the code as follows –

The manifest.h file contains –

#pragma once

EXTERN_C __declspec(selectany) const GUID MYCOMPANY_HPFS_PUBLISHER = {0x9cde86c9, 0xdfb9, 0x463f, {0xb2, 0xc5,0x71,0xee,0xc2,0x32,0xa6,0x9c}};

#define MYCOMPANYOP 0x10

#define MYCOMPANYDEBUG 0x0

EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR DNP_OP_EVENT = {0x1, 0x0, 0x10, 0x4, 0x0, 0x0, 0x8000000000000000};

#define DNP_OP_EVENT_value 0x1

EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR DNP_DEBUG_EVENT = {0x2, 0x0, 0x0, 0x4, 0x0, 0x0, 0x4000000000000000};

#define DNP_DEBUG_EVENT_value 0x2

#define MSG_SimpleMessage                0xB0000001L

Here, we have just renamed #define values.


Also, we have made some changes in EventLogging.Cpp as follows –

// EventLogging.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <evntprov.h>           // ETW Publishing header
#include <winevt.h>             // EventLog Header.
#include "Manifest\manifest.h"
# pragma comment (lib, "wevtapi.lib")

int _tmain(int argc, _TCHAR* argv[])

{

 //first step - register the event

 REGHANDLE hPub = NULL;

 ULONG res = EventRegister(&MYCOMPANY_HPFS_PUBLISHER, NULL, NULL, &hPub);    

 if (ERROR_SUCCESS == res){
  _tprintf(_T("Event registered successfully\n"));
 }

 else{
  _tprintf(_T("Could not register event\n"));
 }

 EVENT_DATA_DESCRIPTOR opEventDesc;

 PWSTR pwsOp = L"HPFS : My Operational Event";

 EventDataDescCreate(&opEventDesc, pwsOp, ((ULONG)wcslen(pwsOp)+1)*sizeof(WCHAR));

 res = EventWrite(hPub, &DNP_OP_EVENT, 1, &opEventDesc);

 if (ERROR_SUCCESS == res){
  _tprintf(_T("Operational event successfully raised\n"));
 }

 else{

  _tprintf(_T("Could not raise operational event  Error = %i\n"), res);

 }

 EVENT_DATA_DESCRIPTOR debugEventDesc;

 PWSTR pwsDebug = L"HPFS : My Debug Event";

 EventDataDescCreate(&debugEventDesc, pwsDebug, ((ULONG)wcslen(pwsDebug)+1)*sizeof(WCHAR));

 res = EventWrite(hPub, &DNP_DEBUG_EVENT, 1, &debugEventDesc);

 if (ERROR_SUCCESS == res){
  _tprintf(_T("Debug event successfully raised\n"));
 }

 else{
  _tprintf(_T("Could not raise debug event.  Error = %i\n"), res);
 }

 EventUnregister(hPub);
      return 0;
}

Also we have made some changes to manifest.xml file as follows –

      <!--Publisher Info -->

      <provider name="MYCOMPANY-HPFS"
                   guid="{9CDE86C9-DFB9-463f-B2C5-71EEC232A69C}" 
                   symbol="MYCOMPANY-HPFS_PUBLISHER" 

resourceFileName="C:\Work_Shashi\EventLoggingCode\Debug\EventLogging.exe" messageFileName="C:\Work_Shashi\EventLoggingCode\Debug\EventLogging.exe">

        <!--Channel to which this Publisher can publish -->

        <channels>

          <channel chid="MyOpChannel" 
                             name="MYCOMPANY-HPFS/Operational" 
                             type="Operational" 
                             symbol="MYCOMPANYOP" 
                             isolation="Application" enabled="true"/>

          <channel chid="MyDebugChannel" 
                             name="MYCOMPANY-HPFS/Debug" 
                             type="Debug" 
                             symbol="MYCOMPANYDEBUG" 
                             isolation="Application" enabled="true"/>

        </channels>

Where "C:\Work_Shashi\EventLoggingCode\Debug\EventLogging.exe" this is my .exe address.

Now, we are getting Debug events properly. But, we are not able to get Operational events. We can see “Operational” tab but no event added in that.

Actually, our intention is to create a tab structure in Event viewer “Applications and Services Logs > MYCOMPANY > HPFS > Operational” and read and write operational events.

Kindly let us know what is the problem in our code.

Thank you.

With regards,

Shashikant
Questionsame name in two DLL Pin
hanlei000000000931-Aug-08 22:05
hanlei000000000931-Aug-08 22:05 
AnswerRe: same name in two DLL Pin
Naveen31-Aug-08 22:14
Naveen31-Aug-08 22:14 
AnswerRe: same name in two DLL Pin
Nibu babu thomas31-Aug-08 22:16
Nibu babu thomas31-Aug-08 22:16 
QuestionImages to Treectrl Pin
Preethi_12331-Aug-08 21:45
Preethi_12331-Aug-08 21:45 
AnswerRe: Images to Treectrl Pin
Nibu babu thomas31-Aug-08 22:12
Nibu babu thomas31-Aug-08 22:12 
QuestionClass constructor question Pin
monsieur_jj31-Aug-08 21:19
monsieur_jj31-Aug-08 21:19 
AnswerRe: Class constructor question Pin
Mckay.Lai31-Aug-08 21:29
Mckay.Lai31-Aug-08 21:29 
GeneralRe: Class constructor question Pin
monsieur_jj31-Aug-08 21:36
monsieur_jj31-Aug-08 21:36 
GeneralRe: Class constructor question Pin
Cedric Moonen31-Aug-08 21:47
Cedric Moonen31-Aug-08 21:47 
GeneralRe: Class constructor question Pin
monsieur_jj31-Aug-08 21:52
monsieur_jj31-Aug-08 21:52 
GeneralRe: Class constructor question Pin
Mckay.Lai31-Aug-08 22:04
Mckay.Lai31-Aug-08 22:04 
News[OT] Re: Class constructor question Pin
Roger Stoltz31-Aug-08 22:47
Roger Stoltz31-Aug-08 22:47 
Questionhow to overcome/solve warnings such as " warning C4996: 'strcat' was declared deprecated " ? Pin
kapardhi31-Aug-08 20:37
kapardhi31-Aug-08 20:37 
AnswerRe: how to overcome/solve warnings such as " warning C4996: 'strcat' was declared deprecated " ? Pin
Cedric Moonen31-Aug-08 20:40
Cedric Moonen31-Aug-08 20:40 
GeneralRe: how to overcome/solve warnings such as " warning C4996: 'strcat' was declared deprecated " ? Pin
Rane31-Aug-08 21:02
Rane31-Aug-08 21:02 
QuestionRead and Write to TextFile With Visual c++ 6.0 MFC Pin
mikobi31-Aug-08 20:03
mikobi31-Aug-08 20:03 
AnswerRe: Read and Write to TextFile With Visual c++ 6.0 MFC Pin
Rane31-Aug-08 20:32
Rane31-Aug-08 20:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.