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.<div>
<br></div><div>As to using the GetLastError.. </div><div><br></div><div>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.</div>
<div><br></div><div>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.</div><div><br></div><div><br>
<br><div class="gmail_quote">On Tue, Feb 16, 2010 at 4:55 PM, Karl Reynolds <span dir="ltr"><<a href="mailto:kreynolds@chocfishsoft.co.nz">kreynolds@chocfishsoft.co.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Tue, Feb 16, 2010 at 4:43 PM, Kyley Harris <<a href="mailto:Kyley@harrissoftware.com">Kyley@harrissoftware.com</a>> wrote:<br>
</div><div class="im">> I'll add my cents..<br>
> under Delphi 7, getlasterror returns error 1413 as Karl said.. under Delphi<br>
> 2007 no errors whatsoever. whats clear is that Getlasterror is unlreliable<br>
> in this situation as Microsoft says, because microsoft online help says the<br>
> getlasterror value cannot be controlled depending on OS and device and only<br>
> the -1 is reliable as an answer.<br>
<br>
</div>Except that -1 isn't reliable because, as already discussed, it could<br>
be a valid data value. I would in fact expect the code returned to<br>
vary by OS and device (and that's what RaiseLastOSError is for) but I<br>
really didn't expect there to be an OS or device on which an<br>
LB_GETITEMDATA request out of the range of the listbox wasn't an<br>
error! Evidently I'm too trusting or something.<br>
<br>
Under the circumstances, checking the bounds first seems necessary.<br>
<div><div></div><div class="h5"><br>
Cheers,<br>
Karl<br>
_______________________________________________<br>
NZ Borland Developers Group - Delphi mailing list<br>
Post: <a href="mailto:delphi@delphi.org.nz">delphi@delphi.org.nz</a><br>
Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
Unsubscribe: send an email to <a href="mailto:delphi-request@delphi.org.nz">delphi-request@delphi.org.nz</a> with Subject: unsubscribe<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Kyley Harris<br>Harris Software<br>+64-21-671-821<br>
</div>