IDataObject有个方法GetData
其声明如下
HRESULT GetData(
  FORMATETC * pFormatetc,  //Pointer to the FORMATETC structure
  STGMEDIUM * pmedium  //Pointer to the STGMEDIUM structure
);对于STGMEDIUM结构的说明,MSDN上的资料如下:
STGMEDIUM
The STGMEDIUM structure is a generalized global memory handle used for data transfer operations by the IAdviseSink, IDataObject, and IOleCache interfaces.typedef struct tagSTGMEDIUM 

    DWORD tymed; 
    [switch_type(DWORD), switch_is((DWORD) tymed)] 
    union { 
        [case(TYMED_GDI)]      HBITMAP        hBitmap; 
        [case(TYMED_MFPICT)]   HMETAFILEPICT  hMetaFilePict; 
        [case(TYMED_ENHMF)]    HENHMETAFILE   hEnhMetaFile; 
        [case(TYMED_HGLOBAL)]  HGLOBAL        hGlobal; 
        [case(TYMED_FILE)]     LPWSTR         lpszFileName; 
        [case(TYMED_ISTREAM)]  IStream        *pstm; 
        [case(TYMED_ISTORAGE)] IStorage       *pstg; 
        [default] ; 
    }; 
    [unique] IUnknown *pUnkForRelease; 
}STGMEDIUM; 
typedef STGMEDIUM *LPSTGMEDIUM; 
 
Members
tymed 
Type of storage medium. The marshaling and unmarshaling routines use this value to determine which union member was used. This value must be one of the elements of the TYMED enumeration. 
union member 
Handle, string, or interface pointer that the receiving process can use to access the data being transferred. If tymed is TYMED_NULL, the union member is undefined; otherwise, it is one of the following: 
hBitmapBitmap handle. The tymed member is TYMED_GDI.hMetaFilePictMetafile handle. The tymed member is TYMED_MFPICT.hEnhMetaFileEnhanced metafile handle. The tymed member is TYMED_ENHMF.hGlobalGlobal memory handle. The tymed member is TYMED_HGLOBAL.lpszFileNamePointer to the path of a disk file that contains the data. The tymed member is TYMED_FILE.pstmPointer to an IStream interface. The tymed member is TYMED_ISTREAM.pstgPointer to an IStorage interface. The tymed member is TYMED_ISTORAGE.pUnkForRelease 
Pointer to an interface instance that allows the sending process to control the way the storage is released when the receiving process calls the ReleaseStgMedium function. If pUnkForRelease is NULL, ReleaseStgMedium uses default procedures to release the storage; otherwise, ReleaseStgMedium uses the specified IUnknown interface. 但是,对于hGlobal类型,那块内存数据的具体格式却没讲,
我现在是想做OLE拖动,也就是从桌面,或者资源管理器里面拖文件到我的程序的主窗口
希望获得拖动的文件的信息。
所以很希望知道hGlobal的具体格式说明!谢谢了,解决问题后200分丰上。

解决方案 »

  1.   

    找到了一个例子程序,这是相关部分。
    我在WIN2000下试过的,可行。
    通过GlobalLock返回一个TDropFiles的结构指针,(SHLOBJ UNIT)
      _DROPFILES = record
        pFiles: DWORD;      { offset of file list }
        pt: TPoint;        { drop point (client coords) }
        fNC: BOOL;          { is it on NonClient area }
                            { and pt is in screen coords }
        fWide: BOOL;        { WIDE character switch }
      end;
    相信只说这些你就已经能清楚了。//-------------------------------------
    procedure TForm1.HandleHDrop(  dataObj : IDataObject;  fetc : TFormatEtc  );
    var
       pdf : PDropFiles;
       stgm : TSTGMEDIUM;
       pFiles : PChar;
       cf:word;
    begin
       if(  dataObj.QueryGetData(  fetc  ) = NOERROR  ) then
       begin
          dataObj.GetData(  fetc,  stgm  );
             {Get TDropFiles structure}
          cf:=fetc.cfFormat;
          ShowMessage(intToStr(cf));      pdf := GlobalLock(  stgm.hGlobal  );
             {Pointer to first file}
          pFiles := pointer(integer(pointer(pdf)) + pdf^.pFiles);      repeat
                {Get this file}
             lbox_HDrop.Items.Add(  string(pFiles)  );
                {Next file}
             pFiles := pointer(integer(pFiles) + Length(  string(pFiles)  ) + 1);         {if NULL then stop}
          until(  pFiles^ = #0  );      GlobalFree(  stgm.hGlobal  );
          ReleaseStgMedium(  stgm  );
       end;
    end;
      

  2.   

    to halfdream(哈欠) 
    非常感谢,这些我已经解决了98下获取就是通过以上方法,2000下我也明白了
    是因为宽字符的原因,但是我希望知道这一系列的格式说明。
    例如拖放的是一段html,或者Word的文字等等。
      

  3.   

    不知道你看过这篇文章没有,再看看它的例子源码,还比较全面。
    http://www.hardcoredelphi.com/dd/DDMag.nsf/WebIndexByIssue/6111181A97C187F3852568F600575A3E?opendocument
      

  4.   

    非常感谢,你去一下
    http://expert.csdn.net/Expert/topic/1301/1301480.xml?temp=.4950067
    我给分你,周一来给,下班了,88!
      

  5.   

    halfdream(哈欠) 再去一下:
    http://expert.csdn.net/Expert/topic/1301/1301573.xml?temp=.5213434
    那里还有20分,:)