// [MoreWindows work Note 10] OleGetClipboard access to the file information on the clipboard // http://blog.csdn.net/morewindows/article/details/17655057// By MoreWindows (http://blog.csdn.net/MoreWindows) # include <Windows. h> # include <ObjBase. h ># include <iostream> using namespace std; void DisplayDataObject (IDataObject * pDataObject) {FORMATETC fmtetc = {cf_hddrop, 0, DVASPECT_CONTENT,-1, TYMED_HGLOBAL}; STGMEDIUM stgmedium; if (pDataObject-> G EtData (& fmtetc, & stgmedium) = S_ OK) {cout <"the data format of the clipboard is CF_HDROP. The data content is as follows:" <endl; HDROP hdrop = (HDROP) globalLock (stgmedium. hGlobal); int count = DragQueryFile (hdrop, 0 xFFFFFFFF, NULL, 0); for (int I = 0; I <count; ++ I) {char path [_ MAX_PATH]; DragQueryFile (hddrop, I, path, _ MAX_PATH); cout <path <endl;} GlobalUnlock (stgmedium. hGlobal); ReleaseStgMedium (& stgmedium);} else {cout <"Error! The Clipboard data format is not CF_HDROP "<endl ;}int main () {printf (" [MoreWindows work Note 10] OleGetClipboard access the clipboard text content \ n "); printf ("-http://blog.csdn.net/morewindows/article/details/17655053-\ n"); printf ("-- By MoreWindows (http://blog.csdn.net/MoreWindows) -- \ n"); if (OleInitialize (0 )! = S_ OK) return 0; IDataObject * pDataObject; if (OleGetClipboard (& pDataObject) = S_ OK) {DisplayDataObject (pDataObject); pDataObject-> Release ();} OleUninitialize (); return 0 ;}