Обработка исключения.

Приветствую всех форумчан. Есть вопрос относительно обработки исключений для ShellExecute.открываю файл:try  ShellExecute(Handle,'open','D:\Folder\file.xls, nil, nil,SW_SHOWNORMAL);  except on EFOpenError  //если файла нет на месте   do  begin  messagedlg('Файл не найден.', mtInformation, [mbOK], 0); //сообщение не появляется, т.е. в ответ на щелчок по кнопке ничего не происходитend; Как указать дескриптор ShellExecute?или нужно что-то другое?
2 ответа

А с чего вы взяли, что системная функция ShellExecute возбуждает Delphi-вые исключения?Смотрим справку:
If the function succeeds, it returns a value greater than 32. If the function fails, it returns an error value that indicates the cause of the failure. The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. It is not a true HINSTANCE, however. It can be cast only to an int and compared to either 32 or the following error codes below.Return code - Description0 - The operating system is out of memory or resources.ERROR_FILE_NOT_FOUND - The specified file was not found.ERROR_PATH_NOT_FOUND - The specified path was not found.ERROR_BAD_FORMAT - The .exe file is invalid (non-Win32 .exe or error in .exe image).SE_ERR_ACCESSDENIED - The operating system denied access to the specified file.SE_ERR_ASSOCINCOMPLETE - The file name association is incomplete or invalid.SE_ERR_DDEBUSY - The DDE transaction could not be completed because other DDE transactions were being processed.SE_ERR_DDEFAIL - The DDE transaction failed.SE_ERR_DDETIMEOUT - The DDE transaction could not be completed because the request timed out.SE_ERR_DLLNOTFOUND - The specified DLL was not found.SE_ERR_FNF - The specified file was not found.SE_ERR_NOASSOC - There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable.SE_ERR_OOM - There was not enough memory to complete the operation.SE_ERR_PNF - The specified path was not found.SE_ERR_SHARE - A sharing violation occurred.
Хотите исключений - возбуждайте:
Res := ShellExecute(Handle,'open','D:\Folder\file.xls', nil, nil,SW_SHOWNORMAL);case Res of   ERROR_FILE_NOT_FOUND: raise EFOpenError.Create(Format('Файл %s не найден', ['D:\Folder\file.xls']));  ...end;
Впрочем, гораздо приятнее в этом плане выглядит ShellExecuteEx:
Returns TRUE if successful; otherwise, FALSE. Call GetLastError for extended error information.
Тогда:
if not ShellExecuteEx(...) then  RaiseLastOSError;


Спасибо CodeMonkeyВопрос решен.