[DUG] Is it a bug in latest version of Delphi?

Karl Reynolds kreynolds at chocfishsoft.co.nz
Tue Feb 16 19:43:43 NZDT 2010


On Tue, Feb 16, 2010 at 5:03 PM, Kyley Harris <Kyley at harrissoftware.com> wrote:
> the fact that it behaves different under delphi 7 and Delphi 2007 on the
> same machine implies that there is some strange mystery at work in the
> compiled code that is not obvious. its not a direct problem of the
> underlying windows API.
> As to using the GetLastError..
> There is issue I have with relying on that rather than the -1. The MSDN
> documentation states that not all routines need to or are required to call
> SetLastError(0) on success, and only set it on failure. the value -1 is what
> you are supposed to analyze to determine IF you should check GetLastError.
> GetLastError is not the first test. Clearly microsoft does not intend the
> storage to be used for negative values even if some appear to work.
> if you rely on GetLastError rather than the -1. you may get a true value of
> "3" but getlasterror was not reset from some other call and you can get a
> false fail.

That's true. If I were to continue down the path I was advocating I'd
have to use SetLastError(0) before starting, but rereading the docs
I'm inclined to agree with you.

I still wonder why on some machines/versions of Delphi GetLastError
isn't returning an error code for index out of bounds. Surely
SendMessage itself wouldn't be resetting the error code in D2007?
Anyway, if I'm going to check the return value I guess the point is
mostly moot.

Cheers,
Karl


More information about the Delphi mailing list