ReactOS 0.4.16-dev-340-g0540c21
deskcplx.h
Go to the documentation of this file.
1#ifndef __DESKCPLX__H
2#define __DESKCPLX__H
3
4#define DESK_EXT_CALLBACK CALLBACK
5
6#define DESK_EXT_EXTINTERFACE TEXT("Desk.cpl extension interface")
7#define DESK_EXT_PRUNINGMODE TEXT("Pruning Mode")
8#define DESK_EXT_DISPLAYDEVICE TEXT("Display Device")
9#define DESK_EXT_DISPLAYNAME TEXT("Display Name")
10#define DESK_EXT_DISPLAYID TEXT("Display ID")
11#define DESK_EXT_DISPLAYKEY TEXT("Display Key")
12#define DESK_EXT_DISPLAYSTATEFLAGS TEXT("Display State Flags")
13#define DESK_EXT_MONITORNAME TEXT("Monitor Name")
14#define DESK_EXT_MONITORDEVICE TEXT("Monitor Device")
15
19typedef VOID (DESK_EXT_CALLBACK *PDESK_EXT_GETPRUNINGMODE)(PVOID Context, PBOOL pbModesPruned, PBOOL pbKeyIsReadOnly, PBOOL pbPruningOn);
21
22typedef struct _DESK_EXT_INTERFACE
23{
24 /* NOTE: This structure is binary compatible to XP. The windows shell
25 extensions rely on this structure to be properly filled! */
27
28 PVOID Context; /* This value is passed on to the callback routines */
29
30 /* Callback routines called by the shell extensions */
36
37 /* HardwareInformation.* values provided in the device registry key */
44
45LONG WINAPI DisplaySaveSettings(PVOID pContext, HWND hwndPropSheet);
46
47static __inline PDESK_EXT_INTERFACE
49{
50 PDESK_EXT_INTERFACE pRecvBuffer, pExtIface = NULL;
51 FORMATETC fetc;
52 STGMEDIUM medium;
53
54 fetc.cfFormat = (CLIPFORMAT)RegisterClipboardFormat(DESK_EXT_EXTINTERFACE);
55 fetc.ptd = NULL;
56 fetc.dwAspect = DVASPECT_CONTENT;
57 fetc.lindex = -1;
58 fetc.tymed = TYMED_HGLOBAL;
59
60 if (SUCCEEDED(IDataObject_GetData(pdo, &fetc, &medium)) && medium.hGlobal != NULL)
61 {
62 /* We always receive the string in unicode! */
63 pRecvBuffer = (PDESK_EXT_INTERFACE)GlobalLock(medium.hGlobal);
64
65 if (pRecvBuffer->cbSize == sizeof(*pRecvBuffer))
66 {
67 pExtIface = LocalAlloc(LMEM_FIXED, sizeof(*pExtIface));
68 if (pExtIface != NULL)
69 {
70 CopyMemory(pExtIface,
71 pRecvBuffer,
72 sizeof(*pRecvBuffer));
73 }
74 }
75
76 GlobalUnlock(medium.hGlobal);
77 ReleaseStgMedium(&medium);
78 }
79
80 return pExtIface;
81}
82
83static __inline LPTSTR
85{
86 FORMATETC fetc;
87 STGMEDIUM medium;
89 LPWSTR lpRecvBuffer;
90 LPTSTR lpStr = NULL;
91
92 fetc.cfFormat = (CLIPFORMAT)cfFormat;
93 fetc.ptd = NULL;
94 fetc.dwAspect = DVASPECT_CONTENT;
95 fetc.lindex = -1;
96 fetc.tymed = TYMED_HGLOBAL;
97
98 if (SUCCEEDED(IDataObject_GetData(pdo, &fetc, &medium)) && medium.hGlobal != NULL)
99 {
100 /* We always receive the string in unicode! */
101 lpRecvBuffer = (LPWSTR)GlobalLock(medium.hGlobal);
102
103 BufLen = wcslen(lpRecvBuffer) + 1;
104 lpStr = LocalAlloc(LMEM_FIXED, BufLen * sizeof(TCHAR));
105 if (lpStr != NULL)
106 {
107#ifdef UNICODE
108 wcscpy(lpStr, lpRecvBuffer);
109#else
110 WideCharToMultiByte(CP_ACP, 0, lpRecvBuffer, -1, lpStr, BufLen, NULL, NULL);
111#endif
112 }
113
114 GlobalUnlock(medium.hGlobal);
115 ReleaseStgMedium(&medium);
116 }
117
118 return lpStr;
119}
120
121static __inline LONG
123 HWND hwndDlg)
124{
125 typedef LONG (WINAPI *PDISPLAYSAVESETTINGS)(PVOID, HWND);
126 HMODULE hModDeskCpl;
127 PDISPLAYSAVESETTINGS pDisplaySaveSettings;
129
130 /* We could use GetModuleHandle() instead, but then this routine
131 wouldn't work if some other application hosts the shell extension */
132 hModDeskCpl = LoadLibrary(TEXT("desk.cpl"));
133 if (hModDeskCpl != NULL)
134 {
135 pDisplaySaveSettings = (PDISPLAYSAVESETTINGS)GetProcAddress(hModDeskCpl,
136 "DisplaySaveSettings");
137 if (pDisplaySaveSettings != NULL)
138 {
139 lRet = pDisplaySaveSettings(DeskExtInterface->Context,
140 hwndDlg);
141 }
142
143 FreeLibrary(hModDeskCpl);
144 }
145
146 return lRet;
147}
148
149#endif /* __DESKCPLX__H */
#define VOID
Definition: acefi.h:82
struct _DESK_EXT_INTERFACE DESK_EXT_INTERFACE
#define DESK_EXT_CALLBACK
Definition: deskcplx.h:4
static __inline LONG DeskCplExtDisplaySaveSettings(PDESK_EXT_INTERFACE DeskExtInterface, HWND hwndDlg)
Definition: deskcplx.h:122
static __inline PDESK_EXT_INTERFACE QueryDeskCplExtInterface(IDataObject *pdo)
Definition: deskcplx.h:48
static __inline LPTSTR QueryDeskCplString(IDataObject *pdo, UINT cfFormat)
Definition: deskcplx.h:84
struct _DESK_EXT_INTERFACE * PDESK_EXT_INTERFACE
VOID(DESK_EXT_CALLBACK * PDESK_EXT_SETPRUNINGMODE)(PVOID Context, BOOL PruningOn)
Definition: deskcplx.h:20
VOID(DESK_EXT_CALLBACK * PDESK_EXT_GETPRUNINGMODE)(PVOID Context, PBOOL pbModesPruned, PBOOL pbKeyIsReadOnly, PBOOL pbPruningOn)
Definition: deskcplx.h:19
PDEVMODEW(DESK_EXT_CALLBACK * PDESK_EXT_ENUMALLMODES)(PVOID Context, DWORD Index)
Definition: deskcplx.h:16
BOOL(DESK_EXT_CALLBACK * PDESK_EXT_SETCURRENTMODE)(PVOID Context, DEVMODEW *pDevMode)
Definition: deskcplx.h:18
PDEVMODEW(DESK_EXT_CALLBACK * PDESK_EXT_GETCURRENTMODE)(PVOID Context)
Definition: deskcplx.h:17
#define DESK_EXT_EXTINTERFACE
Definition: deskcplx.h:6
LONG WINAPI DisplaySaveSettings(PVOID pContext, HWND hwndPropSheet)
Definition: devsett.c:1070
#define NULL
Definition: types.h:112
#define CP_ACP
Definition: compat.h:109
HANDLE HWND
Definition: compat.h:19
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define WideCharToMultiByte
Definition: compat.h:111
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
#define BufLen
Definition: fatfs.h:167
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define TEXT(s)
Definition: k32.h:26
unsigned int UINT
Definition: ndis.h:50
#define BOOL
Definition: nt_native.h:43
long LONG
Definition: pedump.c:60
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
PDESK_EXT_GETCURRENTMODE GetCurrentMode
Definition: deskcplx.h:33
PDESK_EXT_SETCURRENTMODE SetCurrentMode
Definition: deskcplx.h:32
WCHAR MemorySize[128]
Definition: deskcplx.h:38
PDESK_EXT_SETPRUNINGMODE SetPruningMode
Definition: deskcplx.h:34
PDESK_EXT_ENUMALLMODES EnumAllModes
Definition: deskcplx.h:31
WCHAR BiosString[128]
Definition: deskcplx.h:42
WCHAR AdapterString[128]
Definition: deskcplx.h:41
WCHAR DacType[128]
Definition: deskcplx.h:40
WCHAR ChipType[128]
Definition: deskcplx.h:39
PDESK_EXT_GETPRUNINGMODE GetPruningMode
Definition: deskcplx.h:35
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
_In_ WDFCOLLECTION _In_ ULONG Index
#define LoadLibrary
Definition: winbase.h:3887
#define CopyMemory
Definition: winbase.h:1735
#define LMEM_FIXED
Definition: winbase.h:394
BOOL * PBOOL
Definition: windef.h:161
#define WINAPI
Definition: msvc.h:6
struct _devicemodeW * PDEVMODEW
#define RegisterClipboardFormat
Definition: winuser.h:5850
#define DISP_CHANGE_BADPARAM
Definition: winuser.h:193
char TCHAR
Definition: xmlstorage.h:189
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
CHAR * LPTSTR
Definition: xmlstorage.h:192