|
Handling MCI Errors
You should always check the return value of the mciSendCommand function. If it indicates an error, you can use mciGetErrorString to get a textual description of the error.
The following example passes the MCI error code specified by dwError to mciGetErrorString, and then displays the resulting textual error description using the MessageBox function.
// Uses mciGetErrorString to get a textual description of an MCI error.
// Displays the error description using MessageBox.
- oid showError(DWORD dwError)
{
char szErrorBuf[MAXERRORLENGTH];
MessageBeep(MB_ICONEXCLAMATION);
if(mciGetErrorString(dwError, (LPSTR) szErrorBuf, MAXERRORLENGTH))
MessageBox(hMainWnd, szErrorBuf, "MCI Error",
MB_ICONEXCLAMATION);
else
MessageBox(hMainWnd, "Unknown Error", "MCI Error",
MB_ICONEXCLAMATION);
}
Note To interpret an mciSendCommand error return value yourself, mask the high-order word (the low-order word
contains the error code). If you pass the error return value to mciGetErrorString, however, you must pass the entire doubleword value.
Related Links
Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET
TMS Scripter Studio Pro components for Delphi/C++Builder
More Online Helps
Win32 Programmer's Reference (win32.hlp)
OLE Programmer's Reference (ole.hlp)
Microsoft Windows Pen API Programmer's Reference (penapi.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (tapi.hlp)
Unix Manual Pages
|