考虑以下代码:
uses
{... }
ComObj,
ShlObj;
type
TContextMenu = class(TComObject, IShellExtInit, IContextMenu)
private
{(*}
const
GUID: TGUID = '{99D8B139-0855-4C5D-95E7-BC8EC6254B3D}';
{*)}
private
FCmdCount: LongWord;
FDm: Tdm_ContextMenu;
protected
function IShellExtInit.Initialize = IShellExtInit_Initialize;
function IShellExtInit_Initialize(_pidlFolder: PItemIDList; _lpdobj: IDataObject;
_HKeyProgID: HKEY): HResult; stdcall;
function QueryContextMenu(_Menu: HMENU; _indexMenu, _idCmdFirst, _idCmdLast,
_UFlags: UINT): HResult; stdcall;
function InvokeCommand(var _ici: TCMInvokeCommandInfo): HResult; stdcall;
function GetCommandString(_idCmd, _uType: UINT; _pwReserved: PUINT;
_PszName: LPSTR; _cchMax: UINT): HResult; stdcall;
public
procedure Initialize; override;
destructor Destroy; override;
end;
这在 Delphi 2007 和 XE 中编译得很好,但 Delphi XE2 给了我错误:“[DCC Error] u_ContextMenuHandler.pas(16): E2291 Missing implementation of interface method IContextMenu.GetCommandString”
这让我很困惑。我检查了接口声明,我的 GetCommandString 函数与接口的声明完全相同。有什么提示吗?