mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 01:15:09 +00:00
Move routines that can be shared between desk.cpl shell extensions to common header as inlined functions
svn path=/trunk/; revision=29216
This commit is contained in:
parent
04931ef194
commit
8e049e50a4
2 changed files with 76 additions and 40 deletions
|
@ -73,44 +73,6 @@ AdvGeneralPageProc(HWND hwndDlg,
|
|||
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 @@ BuildAdvPropTitle(IDataObject *pdo, LPTSTR lpBuffer, DWORD dwBufferLen)
|
|||
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);
|
||||
|
||||
|
|
|
@ -43,4 +43,78 @@ typedef struct _DESK_EXT_INTERFACE
|
|||
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 */
|
||||
|
|
Loading…
Reference in a new issue