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.   

    那不是一种类型,HGloba的含义,是指拖拉的数据从内存中提供,而不是一个文件,或者流之类的。这块内存无格式,完全由提供者填充里面的内容。假定,拖拉的是一块纯文本,那么这个内存中就是整个文本的字符串,不一定是以NULL结尾的,但是一般,提供者会提供比实际需要更大的内存,这是由于获取Windows内存的方式决定的,通常Windows都会提供更大的内存,因为它是按照页的尺寸来分配内存的。实际上,这块内存完全由提供者决定他的内部格式,完全没有固定格式。拖拉文件的结果,通常在这个内存中保留这个文件的全路径名称,如果是多个拖拉,我也不知道如何组织的,但是很显然,你可以把这块内存转换成字符串显示出来看一下,就明白了。
      

  2.   

    我知道不是文件,你知不知道哪里有相关的说明?
    最起码,要有Windows系统内的文件拖放的说明。
      

  3.   

    你注意一下Unicode和Ansi字符串的差异,在NT下面使用Unicode,很可能全路径的字符串是Unicode的,这需要注意。就好像从HTML中拖拉过来的HTML文本是UTF8编码的,需要转换。不过Unicode可以直接使用,不必转换。
      

  4.   

    恩,谢谢了,这个我已经知道了!
    98是单字符,2000是宽字符。
    我现在需要知道不单是文件拖放,例如你说的Html拖放等等的格式,
    我需要这一系列的说明。
      

  5.   

    HTML也没有格式,就是UTF8编码的字符串,你可以用API转换为Unicode或者Ansi字符串。
      

  6.   

    http://expert.csdn.net/Expert/topic/1301/1301565.xml?temp=.8205072