Author: weiden Date: Wed Sep 26 23:42:39 2007 New Revision: 29216
URL: http://svn.reactos.org/svn/reactos?rev=29216&view=rev Log: Move routines that can be shared between desk.cpl shell extensions to common header as inlined functions
Modified: trunk/reactos/dll/cpl/desk/advmon.c trunk/reactos/include/reactos/dll/desk/deskcplx.h
Modified: trunk/reactos/dll/cpl/desk/advmon.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/advmon.c?rev=2... ============================================================================== --- trunk/reactos/dll/cpl/desk/advmon.c (original) +++ trunk/reactos/dll/cpl/desk/advmon.c Wed Sep 26 23:42:39 2007 @@ -73,44 +73,6 @@ return Ret; }
-static LPTSTR -QueryDevSettingsString(IDataObject *pdo, UINT cfFormat) -{ - FORMATETC fetc; - STGMEDIUM medium; - SIZE_T BufLen; - LPWSTR lpRecvBuffer; - LPTSTR lpStr = NULL; - - fetc.cfFormat = (CLIPFORMAT)cfFormat; - fetc.ptd = NULL; - fetc.dwAspect = DVASPECT_CONTENT; - fetc.lindex = -1; - fetc.tymed = TYMED_HGLOBAL; - - if (SUCCEEDED(IDataObject_GetData(pdo, &fetc, &medium)) && medium.hGlobal != NULL) - { - /* We always receive the string in unicode! */ - lpRecvBuffer = (LPWSTR)GlobalLock(medium.hGlobal); - - BufLen = wcslen(lpRecvBuffer) + 1; - lpStr = LocalAlloc(LMEM_FIXED, BufLen * sizeof(TCHAR)); - if (lpStr != NULL) - { -#ifdef UNICODE - wcscpy(lpStr, lpRecvBuffer); -#else - WideCharToMultiByte(CP_APC, 0, lpRecvBuffer, -1, lpStr, BufLen, NULL, NULL); -#endif - } - - GlobalUnlock(medium.hGlobal); - ReleaseStgMedium(&medium); - } - - return lpStr; -} - static VOID BuildAdvPropTitle(IDataObject *pdo, LPTSTR lpBuffer, DWORD dwBufferLen) { @@ -126,8 +88,8 @@ uiMonitorName = RegisterClipboardFormat(DESK_EXT_MONITORNAME); uiDisplayName = RegisterClipboardFormat(DESK_EXT_DISPLAYNAME);
- lpMonitorName = QueryDevSettingsString(pdo, uiMonitorName); - lpDisplayName = QueryDevSettingsString(pdo, uiDisplayName); + lpMonitorName = QueryDeskCplString(pdo, uiMonitorName); + lpDisplayName = QueryDeskCplString(pdo, uiDisplayName);
_sntprintf(lpBuffer, dwBufferLen, szFormatBuff, lpMonitorName, lpDisplayName);
Modified: trunk/reactos/include/reactos/dll/desk/deskcplx.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/dll/desk/de... ============================================================================== --- trunk/reactos/include/reactos/dll/desk/deskcplx.h (original) +++ trunk/reactos/include/reactos/dll/desk/deskcplx.h Wed Sep 26 23:42:39 2007 @@ -43,4 +43,78 @@ WCHAR BiosString[128]; } DESK_EXT_INTERFACE, *PDESK_EXT_INTERFACE;
+static PDESK_EXT_INTERFACE __inline +QueryDeskCplExtInterface(IDataObject *pdo) +{ + PDESK_EXT_INTERFACE pRecvBuffer, pExtIface = NULL; + FORMATETC fetc; + STGMEDIUM medium; + + fetc.cfFormat = (CLIPFORMAT)RegisterClipboardFormat(DESK_EXT_EXTINTERFACE); + fetc.ptd = NULL; + fetc.dwAspect = DVASPECT_CONTENT; + fetc.lindex = -1; + fetc.tymed = TYMED_HGLOBAL; + + if (SUCCEEDED(IDataObject_GetData(pdo, &fetc, &medium)) && medium.hGlobal != NULL) + { + /* We always receive the string in unicode! */ + pRecvBuffer = (PDESK_EXT_INTERFACE)GlobalLock(medium.hGlobal); + + if (pRecvBuffer->cbSize == sizeof(*pRecvBuffer)) + { + pExtIface = LocalAlloc(LMEM_FIXED, sizeof(*pExtIface)); + if (pExtIface != NULL) + { + CopyMemory(pExtIface, + pRecvBuffer, + sizeof(*pRecvBuffer)); + } + } + + GlobalUnlock(medium.hGlobal); + ReleaseStgMedium(&medium); + } + + return pExtIface; +} + +static LPTSTR __inline +QueryDeskCplString(IDataObject *pdo, UINT cfFormat) +{ + FORMATETC fetc; + STGMEDIUM medium; + SIZE_T BufLen; + LPWSTR lpRecvBuffer; + LPTSTR lpStr = NULL; + + fetc.cfFormat = (CLIPFORMAT)cfFormat; + fetc.ptd = NULL; + fetc.dwAspect = DVASPECT_CONTENT; + fetc.lindex = -1; + fetc.tymed = TYMED_HGLOBAL; + + if (SUCCEEDED(IDataObject_GetData(pdo, &fetc, &medium)) && medium.hGlobal != NULL) + { + /* We always receive the string in unicode! */ + lpRecvBuffer = (LPWSTR)GlobalLock(medium.hGlobal); + + BufLen = wcslen(lpRecvBuffer) + 1; + lpStr = LocalAlloc(LMEM_FIXED, BufLen * sizeof(TCHAR)); + if (lpStr != NULL) + { +#ifdef UNICODE + wcscpy(lpStr, lpRecvBuffer); +#else + WideCharToMultiByte(CP_APC, 0, lpRecvBuffer, -1, lpStr, BufLen, NULL, NULL); +#endif + } + + GlobalUnlock(medium.hGlobal); + ReleaseStgMedium(&medium); + } + + return lpStr; +} + #endif /* __DESKCPLX__H */