WNetGetLastError

  DWORD WNetGetLastError(lpdwErrorCode, lpszDescription, cchDescription, lpszName, cchName)    
  LPDWORD lpdwErrorCode; /* pointer to error code */
  LPTSTR lpszDescription; /* pointer to string describing error */
  DWORD cchDescription; /* size of the description buffer in bytes */
  LPTSTR lpszName; /* pointer to buffer for provider name */
  DWORD cchName; /* size of the provider-name buffer */

The WNetGetLastError function returns the most recent error code set by a Windows network function.

Parameters

lpdwErrorCode

Points to the variable that receives the error code reported by the network provider.

lpszDescription

Points to the buffer for the null-terminated string describing the error.

cchDescription

Specifies the size (in characters) of the buffer pointed to by the lpszDescription parameter. If the buffer is too small for the error string, the string is truncated, but still null-terminated. A buffer of at least 256 bytes is recommended.

lpszName

Points to the buffer for the null-terminated string identifying the network provider that raised the error.

cchName

Specifies the size (in characters) of the buffer pointed to by the lpszName parameter. If the buffer is too small for the error string, the string is truncated, but still null-terminated.

Return Value

The return value is NO_ERROR if the function successfully obtains the last error reported by the provider.

The return value is ERROR_INVALID_ADDRESS if the caller supplies an invalid buffer.

Comments

The WNetGetLastError function is typically used to retrieve errors that are specific to a network provider. It should be called when a Windows network function (or the GetLastError function) returns ERROR_EXTENDED_ERROR. Like the GetLastError function, this function returns extended error information, which is maintained on a per-thread basis. Unlike GetLastError, this function can also return a string for reporting errors that are not described by any existing error code.

See Also

GetLastError