ReactOS  0.4.14-dev-606-g14ebc0b
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 
19 typedef VOID (DESK_EXT_CALLBACK *PDESK_EXT_GETPRUNINGMODE)(PVOID Context, PBOOL pbModesPruned, PBOOL pbKeyIsReadOnly, PBOOL pbPruningOn);
21 
22 typedef 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 */
40  WCHAR DacType[128];
44 
45 LONG WINAPI DisplaySaveSettings(PVOID pContext, HWND hwndPropSheet);
46 
47 static __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 
83 static __inline LPTSTR
85 {
86  FORMATETC fetc;
87  STGMEDIUM medium;
88  SIZE_T BufLen;
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 
121 static __inline LONG
123  HWND hwndDlg)
124 {
125  typedef LONG (WINAPI *PDISPLAYSAVESETTINGS)(PVOID, HWND);
126  HMODULE hModDeskCpl;
127  PDISPLAYSAVESETTINGS pDisplaySaveSettings;
128  LONG lRet = DISP_CHANGE_BADPARAM;
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 */
PDESK_EXT_SETCURRENTMODE SetCurrentMode
Definition: deskcplx.h:32
struct _DESK_EXT_INTERFACE * PDESK_EXT_INTERFACE
struct _devicemodeW * PDEVMODEW
#define WideCharToMultiByte
Definition: compat.h:101
#define LoadLibrary
Definition: winbase.h:3696
#define BufLen
Definition: fatfs.h:167
PDESK_EXT_SETPRUNINGMODE SetPruningMode
Definition: deskcplx.h:34
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
#define CP_ACP
Definition: compat.h:99
static __inline PDESK_EXT_INTERFACE QueryDeskCplExtInterface(IDataObject *pdo)
Definition: deskcplx.h:48
PDESK_EXT_GETCURRENTMODE GetCurrentMode
Definition: deskcplx.h:33
VOID(DESK_EXT_CALLBACK * PDESK_EXT_SETPRUNINGMODE)(PVOID Context, BOOL PruningOn)
Definition: deskcplx.h:20
HANDLE HWND
Definition: compat.h:13
static __inline LONG DeskCplExtDisplaySaveSettings(PDESK_EXT_INTERFACE DeskExtInterface, HWND hwndDlg)
Definition: deskcplx.h:122
#define BOOL
Definition: nt_native.h:43
CHAR * LPTSTR
Definition: xmlstorage.h:192
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define DISP_CHANGE_BADPARAM
Definition: winuser.h:193
smooth NULL
Definition: ftsmooth.c:416
#define DESK_EXT_CALLBACK
Definition: deskcplx.h:4
void * PVOID
Definition: retypes.h:9
BOOL * PBOOL
Definition: windef.h:161
PDEVMODEW(DESK_EXT_CALLBACK * PDESK_EXT_ENUMALLMODES)(PVOID Context, DWORD Index)
Definition: deskcplx.h:16
#define LMEM_FIXED
Definition: winbase.h:349
char TCHAR
Definition: xmlstorage.h:189
#define FreeLibrary(x)
Definition: compat.h:413
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define DESK_EXT_EXTINTERFACE
Definition: deskcplx.h:6
#define WINAPI
Definition: msvc.h:6
PDESK_EXT_GETPRUNINGMODE GetPruningMode
Definition: deskcplx.h:35
#define CopyMemory
Definition: winbase.h:1640
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
PDEVMODEW(DESK_EXT_CALLBACK * PDESK_EXT_GETCURRENTMODE)(PVOID Context)
Definition: deskcplx.h:17
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define VOID
Definition: acefi.h:82
WCHAR AdapterString[128]
Definition: deskcplx.h:41
#define RegisterClipboardFormat
Definition: winuser.h:5813
ULONG_PTR SIZE_T
Definition: typedefs.h:78
WCHAR BiosString[128]
Definition: deskcplx.h:42
#define TEXT(s)
Definition: k32.h:26
PDESK_EXT_ENUMALLMODES EnumAllModes
Definition: deskcplx.h:31
WCHAR MemorySize[128]
Definition: deskcplx.h:38
unsigned int UINT
Definition: ndis.h:50
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
struct _DESK_EXT_INTERFACE DESK_EXT_INTERFACE
static __inline LPTSTR QueryDeskCplString(IDataObject *pdo, UINT cfFormat)
Definition: deskcplx.h:84
struct tagContext Context
Definition: acpixf.h:1030
#define GetProcAddress(x, y)
Definition: compat.h:418
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
WCHAR * LPWSTR
Definition: xmlstorage.h:184
BOOL(DESK_EXT_CALLBACK * PDESK_EXT_SETCURRENTMODE)(PVOID Context, const DEVMODEW *pDevMode)
Definition: deskcplx.h:18
WCHAR DacType[128]
Definition: deskcplx.h:40
WCHAR ChipType[128]
Definition: deskcplx.h:39
VOID(DESK_EXT_CALLBACK * PDESK_EXT_GETPRUNINGMODE)(PVOID Context, PBOOL pbModesPruned, PBOOL pbKeyIsReadOnly, PBOOL pbPruningOn)
Definition: deskcplx.h:19
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define SUCCEEDED(hr)
Definition: intsafe.h:57
LONG WINAPI DisplaySaveSettings(PVOID pContext, HWND hwndPropSheet)
Definition: devsett.c:912