查看CodeProject Outlook Drag-n-Drop 示例。它IDataObject
在包装类中使用OutlookDataObject
,但它与剪贴板使用的接口相同。在 C# 中,您可以执行以下操作...
// IDataObject wrapper
OutlookDataObject dataObject = new OutlookDataObject(Clipboard.GetDataObject());
// retrieving filenames
string[] filenames = (string[])dataObject.GetData("FileGroupDescriptorW");
this.label1.Text = "filenames:\n " + string.Join(",", filenames) + "\n";
// writing out file contents
MemoryStream[] filestreams = (MemoryStream[])dataObject.GetData("FileContents");
this.label1.Text += "Files:\n";
for (int fileIndex = 0; fileIndex < filenames.Length; fileIndex++)
{
//use the fileindex to get the name and data stream
string filename = filenames[fileIndex];
MemoryStream filestream = filestreams[fileIndex];
this.label1.Text += " " + filename + "\n";
//save the file stream using its name to the application path
FileStream outputStream = File.Create(filename);
filestream.WriteTo(outputStream);
outputStream.Close();
}
查看OutlookDataObject
包装类,您应该能够在 C++ 中实现类似的东西。