hi, this is very strange. same app, same code, but GetLastError returning different values when it's in VB debug mode (inside the VB dev environment) than in standalone EXE. here's the code:

option Explicit

private Declare Function GetLastError Lib "kernel32" () as Long
private Declare Sub SetLastError Lib "kernel32" (byval dwErrCode as Long)

private Sub Command1_Click()
SetLastError 0
SetLastError 123
If GetLastError() = 123 then
MsgBox "last error was set"
else
MsgBox "last error was not set"
End If
End Sub




very simple. but in vb environment, last error was always set and the result is "last error was set". however, if you compile it and run in standalone exe, it will always say "last error was not set"..

any idea??? please help.

thanks.