21.6. Error Handling

TheGetLastError andBeep functions have been used throughout this book. There are several other error-handling functions, however, and you will find them useful for special situations or when trying to polish an application or DLL.

GetLastErrorReturns the error code of the most recent error
DWORD GetLastError(VOID)
Returns the error code of the last error
BeepBeeps the systems speaker at the specified frequency for the specified time
BOOL Beep(
   DWORD freq,
   DWORD duration)
freqFrequency of the sound
durationTime in milliseconds for beep
Returns TRUE on success

For example, in certain cases you want a window that does not currently have focus to be able to get the user's attention. If it beeps it confuses the user because ...

Get Win32 System Services: The Heart of Windows® 98 and Windows® 2000 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.