🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: [C++ Error] E2034 Cannot convert 'int' to 'void *'

#4338
From: Darko Miletic
Date: Fri, 17 Feb 2006 19:20
46 lines
2311 bytes
Michael Gillen wrote:
> The complaint is on the pBuf in the ReadEventLog funcion. Any ideas why?

Because your code is completely wrong.

> char buf[BUFFER_SIZE+1];

Why this?

> LPVOID pBuf = &buf;

Unneeded.

> DWORD nBytes = 1024;

You used first BUFFER_SIZE and then 1024?? Why?

> DWORD* pnBytes = &nBytes;
> DWORD *pnBytesRead = &nBytesRead;
> DWORD *pnBytesRequired = &nBytesRequired;

Unneeded code.

> 
> if ( !ReadEventLog(logHandle, EVENTLOG_BACKWARDS_READ  + EVENTLOG_SEQUENTIAL_READ, 0, pBuf, nBytes,
> pnBytesRead, pnBytesRequired) )

You can not do EVENTLOG_BACKWARDS_READ  + EVENTLOG_SEQUENTIAL_READ
because it is incorrect in this case. In C/C++ you use |.

More appropriate code would be like this:

BYTE bBuffer[BUFFER_SIZE]={0};
PEVENTLOGRECORD rec=(PEVENTLOGRECORD)&bBuffer;
DWORD nBytesRead;
DWORD nBytesRequired;

  if (!ReadEventLog( logHandle,
                EVENTLOG_BACKWARDS_READ  | EVENTLOG_SEQUENTIAL_READ,
                0,
                rec,
                BUFFER_SIZE,
                &nBytesRead,
                &nBytesRequired)) {
   //do something
  }
Technical Details
Message-ID: <43f62100$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsfeed.gamma.ru!Gamma.RU!news-lond.gip.net!news-raspail.gip.net!news.gsl.net!gip.net!grolier!194.74.65.66.MISMATCH!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <43f616d2$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,8ec6b60facd951bc
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Fri, 17 Feb 2006 16:20:17 -0300
From: Darko Miletic <darko@uvcms.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051201 Thunderbird/1.5 Mnenhy/0.7.3.0
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: [C++ Error] E2034 Cannot convert 'int' to 'void *'
References: <43f616d2$1@newsgroups.borland.com>
In-Reply-To: <43f616d2$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Antivirus: avast! (VPS 0607-2, 02/16/2006), Outbound message
X-Antivirus-Status: Clean
NNTP-Posting-Host: 201.252.12.146
Message-ID: <43f62100$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1140203776 201.252.12.146 (17 Feb 2006 11:16:16 -0700)
Lines: 46
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsfeed.gamma.ru!Gamma.RU!news-lond.gip.net!news-raspail.gip.net!news.gsl.net!gip.net!grolier!194.74.65.66.MISMATCH!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail