不想用Hook

解决方案 »

  1.   

    用shell扩展来实现
    下面是上下文菜单(ContextMenu)的部分内容
    type
      TContextMenu = class(TComObject, IContextMenu, IShellExtInit)
      private
        FFileList: TStrings;
        FMenuIndex: UINT;
      protected
      { IShellExtInit}
      { why use keyword-reintroduce here??? }
        function Initialize(pidlFolder: PItemIDList; lpdobj: IDataObject; hKeyProgID:
          HKEY): HResult; reintroduce; stdcall;
      { IContextMenu}
        function QueryContextMenu(Menu: HMENU; indexMenu, idCmdFirst, idCmdLast, uFlags:
          UINT): HResult; stdcall;
        function InvokeCommand(var lpici: TCMInvokeCommandInfo): HResult; stdcall;
        function GetCommandString(idCmd, uType: UINT; pwReserved: PUINT; pszName: LPSTR;
          cchMax: UINT): HResult; stdcall;    function DoCheckFile(FileName: string): Boolean;
        procedure DoCommand(Parent: HWND; Files: TStrings);
      public
        destructor Destroy; override;
      end;type
      TContextMenuFactory = class(TComObjectFactory)
      private
        function SGUID: string;
      protected
        procedure DoRegistry(Register: Boolean);
      public
        procedure UpdateRegistry(Register: Boolean); override;
      end;
      

  2.   

    subclass a window(use global hook)
      

  3.   

    不想用Hook,因为这要另外起一个进程