[MoreWindows work Note 10] OleGetClipboard access the file information on the clipboard

Source: Internet
Author: User

// [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 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.