これはCOMオブジェクトです。あなたはそれを作成し、それを機能させるために(その背後に十分な実装がある)インターフェースを渡す必要があります。
エクスプローラー(つまりあなた)は、シェル拡張機能にアイテムを別のHMENUに追加するように要求します。次に、Explorer(つまりあなた)はユーザーに応じてメニュー項目を呼び出します。
幸いなことに、シェル内のすべてがインターフェースであるため、好きなように見せかけることができます。反対側からSDKコントラクトを読み取る必要があります。
注意:シェル拡張機能は、エクスプローラーでホストする必要はありません。多くはそうではありません。CommCtrlの[名前を付けて保存]ダイアログで多くのホストがホストされています。
あなたの場合、それはさらに簡単です。
- COMオブジェクトを作成する
IShellExtInitそのインターフェースを照会し、を呼び出します.Initialize。
IContextMenuそのインターフェースのクエリ
- を呼び出し
IContextMenu.QueryContextMenu、アイテムをに追加できるようにしますHMENU
- 電話
IContextMenu.Invoke
繰り返しますが、反対側から契約書を読んだ場合。
いくつかの擬似コード:
var
ClassID: TGUID;
unk: IUnknown;
shellext: IShellExtInit;
dataObject: IDataObject;
hkeyProgID: HKEY;
contextMenu: IContextMenu;
commandInfo: CMINVOKECOMMANDINFO;
begin
ClassID := ProgIDToClassID('PDFTransformer3.PDFTContextMenu');
unk := CreateComObject(ClassID);
shellExt := unk as IShellExtInit;
{
For shortcut menu extensions,
pdtobj identifies the selected file objects,
hkeyProgID identifies the file type of the object with focus, and
pidlFolder is either NULL (for file objects) or specifies the folder
for which the shortcut menu is being requested
(for folder background shortcut menus).
}
shellExt.Initialize(
nil, //pidlFolder, null for file objects
dataObject, //IDataObject of the selected file
hkeyProgID); //HKEY of the file type of the object with focus
contextMenu := unk as IContextMenu;
contextMenu.QueryContextMenu(
menuHandle, //HMENU, A handle to the shortcut menu. The handler should specify this handle when adding menu items.
0, //integer, The zero-based position at which to insert the first new menu item.
100, //The minimum value that the handler can specify for a menu item identifier.
200, //The maximum value that the handler can specify for a menu item identifier.
CMF_NORMAL); //optional flags
contextMenu.InvokeCommand(commandInfo);
それは私がドキュメントを読んで何をすべきかを推測することから得られる限りです。今、私はおしっこをしなければなりません、そしてポータル2をプレイするために家に帰ります