Changeset 97282 in vbox for trunk/src/VBox/HostServices
- Timestamp:
- Oct 24, 2022 4:24:15 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp
r97239 r97282 152 152 } 153 153 154 /**155 * Sets (places) clipboard data into the Windows clipboard.156 *157 * @returns VBox status code.158 * @param pCtx Shared Clipboard context to use.159 * @param cfFormat Windows clipboard format to set data for.160 * @param pvData Pointer to actual clipboard data to set.161 * @param cbData Size (in bytes) of actual clipboard data to set.162 * @note163 */164 static int vboxClipboardSvcWinDataSet(PSHCLCONTEXT pCtx, UINT cfFormat, void *pvData, uint32_t cbData)165 {166 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);167 AssertPtrReturn(pvData, VERR_INVALID_POINTER);168 AssertReturn (cbData, VERR_INVALID_PARAMETER);169 170 int rc = VINF_SUCCESS;171 172 HANDLE hMem = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, cbData);173 174 LogFlowFunc(("hMem=%p\n", hMem));175 176 if (hMem)177 {178 void *pMem = GlobalLock(hMem);179 180 LogFlowFunc(("pMem=%p, GlobalSize=%zu\n", pMem, GlobalSize(hMem)));181 182 if (pMem)183 {184 LogFlowFunc(("Setting data\n"));185 186 memcpy(pMem, pvData, cbData);187 188 /* The memory must be unlocked before inserting to the Clipboard. */189 GlobalUnlock(hMem);190 191 /* 'hMem' contains the host clipboard data.192 * size is 'cb' and format is 'format'.193 */194 HANDLE hClip = SetClipboardData(cfFormat, hMem);195 196 LogFlowFunc(("hClip=%p\n", hClip));197 198 if (hClip)199 {200 /* The hMem ownership has gone to the system. Nothing to do. */201 }202 else203 rc = RTErrConvertFromWin32(GetLastError());204 }205 else206 rc = VERR_ACCESS_DENIED;207 208 GlobalFree(hMem);209 }210 else211 rc = RTErrConvertFromWin32(GetLastError());212 213 if (RT_FAILURE(rc))214 LogRel(("Shared Clipboard: Setting clipboard data for Windows host failed with %Rrc\n", rc));215 216 LogFlowFuncLeaveRC(rc);217 return rc;218 }219 220 154 static int vboxClipboardSvcWinDataRead(PSHCLCONTEXT pCtx, UINT uFormat, void **ppvData, uint32_t *pcbData) 221 155 { … … 384 318 } 385 319 386 rc = vboxClipboardSvcWinDataSet(pCtx, uFormat, pvData, cbData); 320 rc = SharedClipboardWinDataWrite(uFormat, pvData, cbData); 321 if (RT_FAILURE(rc)) 322 LogRel(("Shared Clipboard: Setting clipboard data for Windows host failed with %Rrc\n", rc)); 387 323 388 324 RTMemFree(pvData);
Note:
See TracChangeset
for help on using the changeset viewer.