Detailed use of the Clipboard

Source: Internet
Author: User

Clipboard: A global public memory area maintained by the system that allows only one process to access it at a time.
1. Open the Clipboard
Bool OpenClipboard (HWND hwndnewowner);
Specifies the window handle associated to the open clipboard, passing in null to associate to the current task. Only one process is allowed to open and access at a time, and each time it is opened it is closed, otherwise the clipboard will not be accessible to other processes.
2. Clear the Clipboard
Bool Emptryclipboard (void)
The clipboard must be emptied before it can be written for possession.
3. Allocating memory
Hglobal GlobalAlloc (UNIT uflags,size_t dwbytes);
Dynamically allocating memory regions in bytes on the heap, success points to that memory, failure null, Parameters: 1. Allocating memory properties, 2. Allocated size
4. Lock memory
LPVOID Floballock (Hglobal hmem);
Locks the memory allocated by GlobalAlloc and locks counter +1 on the memory object, successfully returning a pointer to the start address of the memory object. Failure NULL, the system maintains a lock counter for each global memory object, initially 0,globallock the counter + 1,globalunlock counter-1. Once the counter value is greater than 0, the area of memory is not allowed to be moved or deleted, and the lock on this block of memory is unlocked only if it is 0 o'clock. If the Gmem_fixed property is assigned, the counter is always 0.
5. Setting the Clipboard
HANDLE SetClipboardData (UINT uformat, HANDLE hmem);
Execution succeeds, returns a data handle, otherwise returns null
6. Unlocking the Lock
BOOL GlobalUnlock (Hglobal hmem);
Assign the GlobalAlloc property to the Gmem_moveable Memory object counter-1.
7. Close the Clipboard
Bool closeclipboard (void);
You must close the Clipboard other processes to use the Clipboard, and the current process cannot write to the data after it is closed.
8. Get Clipboard data
HANDLE GetClipboardData (UINT uformat);
Execution succeeds, returns a handle to the data handle, otherwise returns a null data format, specifying the format of the data handle

Detailed use of the Clipboard

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.