🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #433

Using ReadEventLog()

#433
From: St�phane Lambert
Date: Mon, 14 Apr 2008 01:25
49 lines
2081 bytes
Hi,

I wish to read the "Application" or "Service" event log on a Windows XP Pro.
system using the following code:

// CODE START:

HANDLE hSystemEventLog = OpenEventLog( NULL, "Application" );
//HANDLE hSystemEventLog = OpenEventLog( NULL, "System" );
//HANDLE hSystemEventLog = OpenEventLog( NULL, "Service Control Manager" );

if ( hSystemEventLog != NULL )
{
  EVENTLOGRECORD CurrentEventLogRecord = {0};
  DWORD dwBytesRead = 0;
  DWORD dwBytesNeeded = 0;

  bool bSucceeded = ReadEventLog( hSystemEventLog,
                                  EVENTLOG_BACKWARDS_READ |
EVENTLOG_SEQUENTIAL_READ,
                                  0,
                                  &CurrentEventLogRecord,
                                  sizeof( CurrentEventLogRecord ),
                                  &dwBytesRead,
                                  &dwBytesNeeded );

  if ( bSucceeded == false )
  {
   showWindowsLastErrorMessage();
  }
  else
  {
   printf( "\nEvent ID: %d\n", CurrentEventLogRecord.EventID );
  }

  CloseEventLog( hSystemEventLog );
}

// CODE END.

When this code is executed, I get the following error:

 The data area passed to a system call is too small.

What's the problem with this code?

Thanks,

Stephane Lambert
Technical Details
Message-ID: <4802a44b@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!news.isoc.lu!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,4de00153f8983ebf,start
X-Google-Attributes: gid10cc67,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "St�phane Lambert" <slamb66@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Using ReadEventLog()
Date: Sun, 13 Apr 2008 20:25:03 -0500
Lines: 51
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1478
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478
NNTP-Posting-Host: 65.93.5.123
Message-ID: <4802a44b@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1208132683 65.93.5.123 (13 Apr 2008 17:24:43 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!news.isoc.lu!newsgroups.borland.com!not-for-mail