Modify

Opened 14 years ago

Closed 14 years ago

#2030 closed Feature Request (Rejected)

_WinAPI_GetLastErrorMessage - accept specified error code parameter

Reported by: anonymous Owned by: Gary
Milestone: Component: Standard UDFs
Version: Severity: None
Keywords: fuvalik Cc:

Description

; #FUNCTION# ====================================================================================================================
; Name...........: _WinAPI_GetLastErrorMessage
; Description ...: Returns the calling threads last error message
; Syntax.........: _WinAPI_GetLastErrorMessage([$iError])
; Parameters ....: $iError 
; Return values .: Success      - Last error message
; Author ........: Paul Campbell (PaulIA)
; Modified.......: jpm, danielkza, Valik
; Remarks .......:
; Related .......: _WinAPI_GetLastError
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _WinAPI_GetLastErrorMessage($nError = False)
    Local $tBufferPtr = DllStructCreate("ptr")
	Local $pBufferPtr = DllStructGetPtr($tBufferPtr)
	
	If Not $nError Then $iError = _WinAPI_GetLastError()

	Local $nCount = _WinAPI_FormatMessage(BitOR($__WINAPICONSTANT_FORMAT_MESSAGE_ALLOCATE_BUFFER, $__WINAPICONSTANT_FORMAT_MESSAGE_FROM_SYSTEM), _
		0, $nError, 0, $pBufferPtr, 0, 0)
    If @error Then Return SetError(@error, 0, "")

     Local $sText = ""
    Local $pBuffer = DllStructGetData($tBufferPtr, 1)
    If $pBuffer Then
        If $nCount > 0 Then
            Local $tBuffer = DllStructCreate("wchar[" & ($nCount+1) & "]", $pBuffer)
            $sText = DllStructGetData($tBuffer, 1)
        EndIf
        _WinAPI_LocalFree($pBuffer)
    EndIf

    Return $sText
EndFunc   ;==>_WinAPI_GetLastErrorMessage

Attachments (0)

Change History (2)

comment:1 by TicketCleanup, 14 years ago

Version: 3.3.6.1

Automatic ticket cleanup.

comment:2 by trancexx, 14 years ago

Resolution: Rejected
Status: newclosed

Why?

Don't reply.

Modify Ticket

Action
as closed The owner will remain Gary.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.