I don't get this ... all I'm asking is for it to give me the value again, so
why would it have a problem???
I can rework my code to get around this, but I just don't understand why
this is a problem on NT (it doesn't cause a problem on win95, it just gives
me the error code as many times as I ask for it). Any idea why NT does
this??
Here's code:
protected Function ulong GetLastError ( ) Library "KERNEL32.DLL"
protected SubRoutine SetLastError ( ulong dwErrCode ) Library "KERNEL32.DLL"
ulong ul_err
ul_err = getlasterror()
messagebox('cb_get', '1st getlasterror=' + string(ul_err)) //will return 5,
or whatever the error code is
ul_err = getlasterror()
messagebox('cb_get', '2nd getlasterror=' + string(ul_err)) //returns 1813
If I insert a setlasterror(ul_err) between the two getlasterror calls, then
it's alright.
Thanks,
Trish Gorr
The last error code is set by API function when they complete. If the
function completes successfully, it is typically set to zero, so what *
should * happen is that the second call return 0, as the previous call to
GetLastError would have set the error code to zero after returning
successfully.
I could not find anything in the SDK docs about possible causes to error
1813, but there is definitely no need to call it twice, because the error
code is not persistant between any two calls.
--
pbm_hopethishelps,
Roy Kiesler [TeamSybase]
Sybase Developer Network (SDN) - http://sdn.sybase.com
MySybase - http://my.sybase.com
"Trisha Gorr" <trisha.gorr@SPAM_FREE.moh.gov.on.ca> wrote in message
news:qmmpiTo...@forums.sybase.com...
On Win95, if I do a CopyFile() and it fails because I don't have the proper
security, the GetLastError() will return a 5. If I call GetLastError()
again, it still returns a 5.
As for why I call it twice, it only happens in a few circumstances. My user
object is doing a bunch of api calls, so I centralized the error checking in
1 function so I'm not duplicating code everywhere. My of_error_check() will
call the GetLastError(), FormatMessage(), and then depending on what the
calling function wants, it will display the error message or not.
But because of the quirks with some of the API's, this could give misleading
results. For example, if I do a CopyFile() and specify to overwrite an
existing file, GetLastError() returns the ERROR_ALREADY_EXISTS even though
the Api worked successfully for what I asked. So in these instances, I'm
checking GetLastError and setting it to 0 before I call my of_error_check()
to do the error handling.
As I said, I can rework the code to get around this ... but am just
curious/frustrated that I get this result on NT and not 95.
Thanks, Trish
Roy Kiesler [TeamSybase] wrote in message ...
--
Windows 95/98: Because SetLastError is a 32-bit function only, Win32
functions that are actually implemented in 16-bit code do not set the
last-error code. You should ignore the last-error code when you call these
functions. They include window management functions, GDI functions, and
Multimedia functions.
--
--
pbm_hopethishelps,
Roy Kiesler [TeamSybase]
Sybase Developer Network (SDN) - http://sdn.sybase.com
MySybase - http://my.sybase.com
"Trisha Gorr" <trisha.gorr@SPAM_FREE.moh.gov.on.ca> wrote in message
news:g#qwNfpE...@forums.sybase.com...