Hello all,
I have written a code to retrieve the error code of an FTP failure, but i am unable to retrieve the error message from it. I tried all the possible ways shown in google but iam not able to do it. Can anyone please share the code snippet or tell me how to do this. Please check the below code and tell em if i have done anything wrong:
The scenario iam trying is i am trying to retrieve a file from a particular location which is not present, using FTPGetFile API which raises error code "12003" but when iam trying to get the error message iam getting only blank msg.
My CODE:
Public Declare Function FormatMessage Lib "kernel32" Alias "FormatMessageA" (ByVal dwFlags As Long, lpSource As Any, ByVal dwMessageId As Long, ByVal dwLanguageId As Long, ByVal lpBuffer As String, ByVal nSize As Long, Arguments As Long) As Long
Public Function ErrorDescriptionDLL(Optional ByVal lLastDLLError As Long) As String
Dim sBuff As String * 1024
Dim lCount As Long
Const FORMAT_MESSAGE_ALLOCATE_BUFFER = &H100, FORMAT_MESSAGE_ARGUMENT_ARRAY = &H2000
Const FORMAT_MESSAGE_FROM_HMODULE = &H800, FORMAT_MESSAGE_FROM_STRING = &H400
Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000, FORMAT_MESSAGE_IGNORE_INSERTS = &H200
Const FORMAT_MESSAGE_MAX_WIDTH_MASK = &HFF
If lLastDLLError = 0 Then
lLastDLLError = Err.LastDllError
End If
lCount = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM Or FORMAT_MESSAGE_IGNORE_INSERTS, 0, lLastDLLError, 0&, sBuff, Len(sBuff), ByVal 0)
If lCount Then
ErrorDescriptionDLL = Left$(sBuff, lCount - 2)
End If
End Function
Please help me out. I also tried the GetLastError method but thats not even returning me error code unlike Err.LastDLLError