0

私の要件は、Outlook 2007 からドラッグされているアイテムの詳細を取得することです。

Windows API を使用して Outlook 2007 に次のようにドラッグ ドロップ イベントを登録し ( public static extern int RegisterDragDrop(IntPtr hwnd, IOleDropTarget target);)、IOleDropTargetドラッグ ドロップ イベントが発生したときに情報を取得するインターフェイスを使用しました。

以下は私がこれまでに行ったことです

IOleDropTarget インターフェイス

[ComImport, Guid("00000122-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleDropTarget
{
    [PreserveSig]
    int OleDragEnter([In, MarshalAs(UnmanagedType.Interface)] object pDataObj, [In, MarshalAs(UnmanagedType.U4)] int grfKeyState, [In, MarshalAs(UnmanagedType.U8)] long pt, [In, Out] ref int pdwEffect);
    [PreserveSig]
    int OleDragOver([In, MarshalAs(UnmanagedType.U4)] int grfKeyState, [In, MarshalAs(UnmanagedType.U8)] long pt, [In, Out] ref int pdwEffect);
    [PreserveSig]
    int OleDragLeave();
    [PreserveSig]
    int OleDrop([In, MarshalAs(UnmanagedType.Interface)] object pDataObj, [In, MarshalAs(UnmanagedType.U4)] int grfKeyState, [In, MarshalAs(UnmanagedType.U8)] long pt, [In, Out] ref int pdwEffect);
}

アイテムが Outlook からドラッグされるイベントでは、メソッドに渡されたすべてのパラメーターを使用して次のメソッドが起動します。

int IOleDropTarget.OleDragEnter(object pDataObj, int grfKeyState, long pt, ref int pdwEffect)
    {           
      retirn 0;
    }

を使用してドラッグされているアイテムに関する情報を取得することは可能pDataObjですか?

これまでのところ、このオブジェクトから情報を取得するために次のことを試みましたが、ドラッグされているアイテムに関する情報はありませんでした。

Type myType = pDataObj.GetType();

必要な情報を得るために他にすべきことはありますか?

コード例は高く評価されます

ありがとうございました

4

1 に答える 1

1

You need to get the running Outlook instance and then get the Selection object from the active explorer window. It will contain the dragged data.

 // Check whether there is an Outlook process running.
 if (Process.GetProcessesByName("OUTLOOK").Count() > 0)
 {
    // If so, use the GetActiveObject method to obtain the process and cast it to an Application object.
   application = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
  }

See How to: Get and Log On to an Instance of Outlook for more information.

于 2015-06-29T09:30:16.920 に答える