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