You haven't specified the error number, but when I tried to duplicate the steps, the OleCheck
call failed with 0x80270000
. The high word part, save the error bit, is 0x27
(39), that's FACILTY_SHELL
as defined in 'winerror.h'. As you can see, the low word is '0', the shell does not give any specific error code, in fact the code is identical with ERROR_SUCCESS
or NO_ERROR
.
My interpretation is, the shell is just notifying that the command (the delete operation) failed. The fail is due to the user canceling the operation. My suggestion is, modify the code accordingly as you see fit. You have the knowledge that the operation failed, but you may choose to ignore it, or perhaps notify the user. Maybe something like this:
var
...
InvokeResult: HRESULT;
begin
...
// OleCheck(ContextMenu.InvokeCommand(CommandInfo));
InvokeResult := ContextMenu.InvokeCommand(CommandInfo);
if not Succeeded(InvokeResult) then begin
if LoWord(InvokeResult) = NO_ERROR then
ShowMessage('Command did not carried out')
else
OleError(InvokeResult);
end;
...