Announcement

Collapse
No announcement yet.

Event ID

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lance Edmonds
    replied
    you may want to look at my version of this code... it species the default language should be used for the message.

    see http://www.powerbasic.com/support/pb...ad.php?t=23095

    can't help with the event id question though... sorry!

    ------------------
    lance
    powerbasic support
    mailto:[email protected][email protected]</a>

    Leave a comment:


  • Scott Turchin
    started a topic Event ID

    Event ID

    This is a lil program to return the string value of an Err.
    Life is good, saw a shareware program that does this, thot I'd pull the dust off of this function.


    but how can you find the error description for an EventID from the NT Event log?


    Code:
    %NOANIMATE    = 1
    %NODRAGLIST   = 1
    %NOHEADER     = 1
    %NOIMAGELIST  = 1
    %NOLISTVIEW   = 1
    %NOTABCONTROL = 1
    %NOTRACKBAR   = 1
    %NOTREEVIEW   = 1
    %NOUPDOWN     = 1
    
    '------------------------------------------------------------------------------------------------------------
    #Compile Exe
    #Option Version5
    #Register None
    #Include "Win32api.inc"
    '------------------------------------------------------------------------------------------------------------
    
    Declare Function GetLastErrorDescription( ByVal ErrorCode As Long, ByVal UseLastError As Long )  As String
    '------------------------------------------------------------------------------------------------------------
    Function WinMain (ByVal hInstance     As Long, _
                      ByVal hPrevInstance As Long, _
                      lpCmdLine           As Asciiz Ptr, _
                      ByVal iCmdShow      As Long) As Long
    
    Local ErMsg As Long
    ErMsg = Val(Trim$(Command$))
    MsgBox GetLastErrorDescription(ByVal ErMsg,0)
    End Function
    
    
    '------------------------------------------------------------------------------------------------------------
    Function GetLastErrorDescription( ByVal ErrorCode As Long, ByVal UseLastError As Long ) Export As String
    Dim sRtrnCode   As Asciiz * 256
    Dim lRet        As Long
    If UseLastError Then ErrorCode = GetLastError()
    If ErrorCode = %ERROR_SUCCESS Then Exit Function
    lRet = FormatMessage( %FORMAT_MESSAGE_FROM_SYSTEM, ByVal 0&, ErrorCode, 0&, sRtrnCode, SizeOf( sRtrnCode ), 0& )
    If lRet > 0 Then Function = Left$( sRtrnCode, lRet )
    End Function
    '------------------------------------------------------------------------------------------------------------
    ------------------
    Scott
Working...
X