Retrieving Network Errors

An application can call the GetLastError function to get extended data on an error, including the error value. Error data is usually provider-specific; however, the only provider supported by Windows CE is the Microsoft Windows Network provider.

The following code example shows a sample function, ErrorHandler, for application-defined error handling. This function calls GetLastError to get extended error data. The ErrorHandler takes two parameters: a window handle and the name of the function that produced the error.

BOOL WINAPI ErrorHandler (HWND hwnd, DWORD dwError, LPTSTR lpszFunction)
  DWORD dwLastError;
  TCHAR szError[256],

  // The following code performs extended error handling.
  dwLastError = GetLastError ();

  wsprintf (szError, 
            TEXT("%s failed with error code %ld \n")
            TEXT("and extended error code %ld."),
            TEXT("Microsoft Windows Network"), dwError, dwLastError);

  wsprintf (szCaption, TEXT("%s error"), lpszFunction);

  MessageBox (hwnd, szError, szCaption, MB_OK);

  return TRUE;

 Last updated on Friday, April 02, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.