ReactOS 0.4.15-dev-7659-ga55345b
devsett.c File Reference
#include "desk.h"
#include <cfgmgr32.h>
#include <debug.h>
Include dependency graph for devsett.c:

Go to the source code of this file.

Classes

struct  _CDevSettings
 

Macros

#define NDEBUG
 
#define DEBUG_DEVSETTINGS
 
#define impl_to_interface(impl, iface)   (struct iface *)(&(impl)->lp##iface##Vtbl)
 

Typedefs

typedef struct _CDevSettings CDevSettings
 
typedef struct _CDevSettingsPCDevSettings
 

Functions

static __inline PCDevSettings impl_from_IDataObject (struct IDataObject *iface)
 
static __inline VOID pCDevSettings_FreeString (PWCHAR *psz)
 
static PWSTR pCDevSettings_AllocAndCopyString (const TCHAR *pszSrc)
 
static PWSTR pCDevSettings_GetMonitorName (const WCHAR *pszDisplayDevice)
 
static PWSTR pCDevSettings_GetMonitorDevice (const WCHAR *pszDisplayDevice)
 
static PWSTR pCDevSettings_GetDeviceInstanceId (const WCHAR *pszDevice)
 Converts a Hardware ID (DeviceID from EnumDisplayDevices) to an unique Device Instance ID.
 
static HKEY pCDevSettings_OpenDeviceKey (PCDevSettings This, BOOL ReadOnly)
 
PDEVMODEW DESK_EXT_CALLBACK CDevSettings_EnumAllModes (PVOID Context, DWORD Index)
 
PDEVMODEW DESK_EXT_CALLBACK CDevSettings_GetCurrentMode (PVOID Context)
 
BOOL DESK_EXT_CALLBACK CDevSettings_SetCurrentMode (PVOID Context, DEVMODEW *pDevMode)
 
VOID DESK_EXT_CALLBACK CDevSettings_GetPruningMode (PVOID Context, PBOOL pbModesPruned, PBOOL pbKeyIsReadOnly, PBOOL pbPruningOn)
 
VOID DESK_EXT_CALLBACK CDevSettings_SetPruningMode (PVOID Context, BOOL PruningOn)
 
static VOID pCDevSettings_ReadHardwareInfo (HKEY hKey, LPCTSTR lpValueName, LPWSTR lpBuffer)
 
static VOID pCDevSettings_InitializeExtInterface (PCDevSettings This)
 
static HRESULT pCDevSettings_Initialize (PCDevSettings This, PDISPLAY_DEVICE_ENTRY DisplayDeviceInfo)
 
static VOID pCDevSettings_Free (PCDevSettings This)
 
static HRESULT STDMETHODCALLTYPE CDevSettings_QueryInterface (IDataObject *iface, REFIID riid, void **ppvObject)
 
static ULONG STDMETHODCALLTYPE CDevSettings_AddRef (IDataObject *iface)
 
static ULONG STDMETHODCALLTYPE CDevSettings_Release (IDataObject *iface)
 
static HRESULT STDMETHODCALLTYPE CDevSettings_GetData (IDataObject *iface, FORMATETC *pformatetcIn, STGMEDIUM *pmedium)
 
static HRESULT STDMETHODCALLTYPE CDevSettings_GetDataHere (IDataObject *iface, FORMATETC *pformatetc, STGMEDIUM *pmedium)
 
static HRESULT STDMETHODCALLTYPE CDevSettings_QueryGetData (IDataObject *iface, FORMATETC *pformatetc)
 
static HRESULT STDMETHODCALLTYPE CDevSettings_GetCanonicalFormatEtc (IDataObject *iface, FORMATETC *pformatectIn, FORMATETC *pformatetcOut)
 
static HRESULT STDMETHODCALLTYPE CDevSettings_SetData (IDataObject *iface, FORMATETC *pformatetc, STGMEDIUM *pmedium, BOOL fRelease)
 
static __inline VOID pCDevSettings_FillFormatEtc (FORMATETC *pFormatEtc, CLIPFORMAT cf)
 
static HRESULT STDMETHODCALLTYPE CDevSettings_EnumFormatEtc (IDataObject *iface, DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc)
 
static HRESULT STDMETHODCALLTYPE CDevSettings_DAdvise (IDataObject *iface, FORMATETC *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
 
static HRESULT STDMETHODCALLTYPE CDevSettings_DUnadvise (IDataObject *iface, DWORD dwConnection)
 
static HRESULT STDMETHODCALLTYPE CDevSettings_EnumDAdvise (IDataObject *iface, IEnumSTATDATA **ppenumAdvise)
 
IDataObjectCreateDevSettings (PDISPLAY_DEVICE_ENTRY DisplayDeviceInfo)
 
LONG WINAPI DisplaySaveSettings (PVOID pContext, HWND hwndPropSheet)
 

Variables

static const struct IDataObjectVtbl vtblIDataObject
 

Macro Definition Documentation

◆ DEBUG_DEVSETTINGS

#define DEBUG_DEVSETTINGS

Definition at line 15 of file devsett.c.

◆ impl_to_interface

#define impl_to_interface (   impl,
  iface 
)    (struct iface *)(&(impl)->lp##iface##Vtbl)

Definition at line 59 of file devsett.c.

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file devsett.c.

Typedef Documentation

◆ CDevSettings

◆ PCDevSettings

Function Documentation

◆ CDevSettings_AddRef()

static ULONG STDMETHODCALLTYPE CDevSettings_AddRef ( IDataObject iface)
static

Definition at line 689 of file devsett.c.

690{
692 return (ULONG)InterlockedIncrement((PLONG)&This->ref);
693}
#define InterlockedIncrement
Definition: armddk.h:53
static __inline PCDevSettings impl_from_IDataObject(struct IDataObject *iface)
Definition: devsett.c:62
int32_t * PLONG
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59

◆ CDevSettings_DAdvise()

static HRESULT STDMETHODCALLTYPE CDevSettings_DAdvise ( IDataObject iface,
FORMATETC *  pformatetc,
DWORD  advf,
IAdviseSink pAdvSink,
DWORD pdwConnection 
)
static

Definition at line 1004 of file devsett.c.

1009{
1010 *pdwConnection = 0;
1012}
#define OLE_E_ADVISENOTSUPPORTED
Definition: winerror.h:2617

◆ CDevSettings_DUnadvise()

static HRESULT STDMETHODCALLTYPE CDevSettings_DUnadvise ( IDataObject iface,
DWORD  dwConnection 
)
static

Definition at line 1015 of file devsett.c.

1017{
1019}

◆ CDevSettings_EnumAllModes()

PDEVMODEW DESK_EXT_CALLBACK CDevSettings_EnumAllModes ( PVOID  Context,
DWORD  Index 
)

Definition at line 289 of file devsett.c.

291{
293 DWORD i, idx = 0;
294
295 DPRINT1("CDevSettings::EnumAllModes(%u)\n", Index);
296
297 if (!This->DevModes)
298 return NULL;
299
300 for (i = 0; i < This->nDevModes; i++)
301 {
302 /* FIXME: Add more sanity checks */
303 if (!This->DevModes[i])
304 continue;
305
306 if (idx == Index)
307 return This->DevModes[i];
308
309 idx++;
310 }
311
312 return NULL;
313}
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
unsigned int idx
Definition: utils.c:41
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by pCDevSettings_InitializeExtInterface().

◆ CDevSettings_EnumDAdvise()

static HRESULT STDMETHODCALLTYPE CDevSettings_EnumDAdvise ( IDataObject iface,
IEnumSTATDATA **  ppenumAdvise 
)
static

Definition at line 1022 of file devsett.c.

1024{
1025 *ppenumAdvise = NULL;
1027}

◆ CDevSettings_EnumFormatEtc()

static HRESULT STDMETHODCALLTYPE CDevSettings_EnumFormatEtc ( IDataObject iface,
DWORD  dwDirection,
IEnumFORMATETC **  ppenumFormatEtc 
)
static

Definition at line 962 of file devsett.c.

965{
966 HRESULT hr;
967 FORMATETC fetc[9];
969
970 *ppenumFormatEtc = NULL;
971
972 if (dwDirection == DATADIR_GET)
973 {
975 This->cfExtInterface);
977 This->cfDisplayDevice);
979 This->cfDisplayName);
981 This->cfDisplayId);
983 This->cfDisplayKey);
985 This->cfDisplayStateFlags);
987 This->cfMonitorName);
989 This->cfMonitorDevice);
991 This->cfPruningMode);
992
993 hr = SHCreateStdEnumFmtEtc(sizeof(fetc) / sizeof(fetc[0]),
994 fetc,
995 ppenumFormatEtc);
996 }
997 else
998 hr = E_NOTIMPL;
999
1000 return hr;
1001}
#define E_NOTIMPL
Definition: ddrawi.h:99
static __inline VOID pCDevSettings_FillFormatEtc(FORMATETC *pFormatEtc, CLIPFORMAT cf)
Definition: devsett.c:951
HRESULT WINAPI SHCreateStdEnumFmtEtc(UINT cFormats, const FORMATETC *lpFormats, LPENUMFORMATETC *ppenumFormatetc)
Definition: shellord.c:2244
HRESULT hr
Definition: shlfolder.c:183

◆ CDevSettings_GetCanonicalFormatEtc()

static HRESULT STDMETHODCALLTYPE CDevSettings_GetCanonicalFormatEtc ( IDataObject iface,
FORMATETC *  pformatectIn,
FORMATETC *  pformatetcOut 
)
static

Definition at line 906 of file devsett.c.

909{
910 HRESULT hr;
911
912 DPRINT1("CDevSettings::GetCanonicalFormatEtc\n");
913
914 hr = IDataObject_QueryGetData(iface,
915 pformatectIn);
916 if (SUCCEEDED(hr))
917 {
918 CopyMemory(pformatetcOut,
919 pformatectIn,
920 sizeof(FORMATETC));
921
922 /* Make sure the data is target device independent */
923 if (pformatectIn->ptd == NULL)
925 else
926 {
927 pformatetcOut->ptd = NULL;
928 hr = S_OK;
929 }
930 }
931 else
932 {
933 ZeroMemory(pformatetcOut,
934 sizeof(FORMATETC));
935 }
936
937 return hr;
938}
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define ZeroMemory
Definition: winbase.h:1712
#define CopyMemory
Definition: winbase.h:1710
#define DATA_S_SAMEFORMATETC
Definition: winerror.h:2674

◆ CDevSettings_GetCurrentMode()

PDEVMODEW DESK_EXT_CALLBACK CDevSettings_GetCurrentMode ( PVOID  Context)

Definition at line 316 of file devsett.c.

317{
319
320 DPRINT1("CDevSettings::GetCurrentMode\n");
321 return This->lpCurDevMode;
322}

Referenced by pCDevSettings_InitializeExtInterface().

◆ CDevSettings_GetData()

static HRESULT STDMETHODCALLTYPE CDevSettings_GetData ( IDataObject iface,
FORMATETC *  pformatetcIn,
STGMEDIUM *  pmedium 
)
static

Definition at line 708 of file devsett.c.

711{
712 static const WCHAR szEmpty[] = {0};
713 HRESULT hr;
714 PCWSTR pszRet = NULL;
715 PWSTR pszBuf;
717
718 ZeroMemory(pmedium,
719 sizeof(STGMEDIUM));
720
721 hr = IDataObject_QueryGetData(iface,
722 pformatetcIn);
723 if (SUCCEEDED(hr))
724 {
725 /* Return the requested data back to the shell extension */
726
727 if (pformatetcIn->cfFormat == This->cfDisplayDevice)
728 {
729 pszRet = This->pDisplayDevice;
730 DPRINT1("CDevSettings::GetData returns display device %ws\n", pszRet);
731 }
732 else if (pformatetcIn->cfFormat == This->cfDisplayName)
733 {
734 pszRet = This->pDisplayName;
735 DPRINT1("CDevSettings::GetData returns display name %ws\n", pszRet);
736 }
737 else if (pformatetcIn->cfFormat == This->cfDisplayKey)
738 {
739 pszRet = This->pDisplayKey;
740 DPRINT1("CDevSettings::GetData returns display key %ws\n", pszRet);
741 }
742 else if (pformatetcIn->cfFormat == This->cfDisplayId)
743 {
744 pszRet = This->pDisplayId;
745 DPRINT1("CDevSettings::GetData returns display id %ws\n", pszRet);
746 }
747 else if (pformatetcIn->cfFormat == This->cfMonitorName)
748 {
749 pszRet = This->pMonitorName;
750 DPRINT1("CDevSettings::GetData returns monitor name %ws\n", pszRet);
751 }
752 else if (pformatetcIn->cfFormat == This->cfMonitorDevice)
753 {
754 pszRet = This->pMonitorDevice;
755 DPRINT1("CDevSettings::GetData returns monitor device %ws\n", pszRet);
756 }
757 else if (pformatetcIn->cfFormat == This->cfExtInterface)
758 {
759 PDESK_EXT_INTERFACE pIface;
760
761 pIface = GlobalAlloc(GPTR,
762 sizeof(*pIface));
763 if (pIface != NULL)
764 {
765 CopyMemory(pIface,
766 &This->ExtInterface,
767 sizeof(This->ExtInterface));
768
769 DPRINT1("CDevSettings::GetData returns the desk.cpl extension interface\n");
770
771 pmedium->tymed = TYMED_HGLOBAL;
772 pmedium->hGlobal = pIface;
773
774 return S_OK;
775 }
776 else
777 return E_OUTOFMEMORY;
778 }
779 else if (pformatetcIn->cfFormat == This->cfDisplayStateFlags)
780 {
781 PDWORD pdw;
782
783 pdw = GlobalAlloc(GPTR,
784 sizeof(*pdw));
785 if (pdw != NULL)
786 {
787 *pdw = This->StateFlags;
788
789 DPRINT1("CDevSettings::GetData returns the display state flags %x\n", This->StateFlags);
790
791 pmedium->tymed = TYMED_HGLOBAL;
792 pmedium->hGlobal = pdw;
793
794 return S_OK;
795 }
796 else
797 return E_OUTOFMEMORY;
798 }
799 else if (pformatetcIn->cfFormat == This->cfPruningMode)
800 {
801 PBYTE pb;
802
803 pb = GlobalAlloc(GPTR,
804 sizeof(*pb));
805 if (pb != NULL)
806 {
807 *pb = (This->bModesPruned && This->bPruningOn);
808
809 pmedium->tymed = TYMED_HGLOBAL;
810 pmedium->hGlobal = pb;
811
812 return S_OK;
813 }
814 else
815 return E_OUTOFMEMORY;
816 }
817
818 /* NOTE: This only returns null-terminated strings! */
819 if (pszRet == NULL)
820 pszRet = szEmpty;
821
822 pszBuf = GlobalAlloc(GPTR,
823 (wcslen(pszRet) + 1) * sizeof(WCHAR));
824 if (pszBuf != NULL)
825 {
826 hr = StringCbCopyW(pszBuf, (wcslen(pszRet) + 1) * sizeof(WCHAR), pszRet);
827 if (FAILED(hr))
828 {
829 GlobalFree(pszBuf);
830 return hr;
831 }
832
833 pmedium->tymed = TYMED_HGLOBAL;
834 pmedium->hGlobal = pszBuf;
835
836 hr = S_OK;
837 }
838 else
840 }
841
842 return hr;
843}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const WCHAR szEmpty[]
Definition: provider.c:50
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define FAILED(hr)
Definition: intsafe.h:51
BYTE * PBYTE
Definition: pedump.c:66
DWORD * PDWORD
Definition: pedump.c:68
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define GPTR
Definition: winbase.h:296
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ CDevSettings_GetDataHere()

static HRESULT STDMETHODCALLTYPE CDevSettings_GetDataHere ( IDataObject iface,
FORMATETC *  pformatetc,
STGMEDIUM *  pmedium 
)
static

Definition at line 846 of file devsett.c.

849{
850 ZeroMemory(pformatetc,
851 sizeof(*pformatetc));
852 return E_NOTIMPL;
853}

◆ CDevSettings_GetPruningMode()

VOID DESK_EXT_CALLBACK CDevSettings_GetPruningMode ( PVOID  Context,
PBOOL  pbModesPruned,
PBOOL  pbKeyIsReadOnly,
PBOOL  pbPruningOn 
)

Definition at line 353 of file devsett.c.

357{
359
360 DPRINT1("CDevSettings::GetPruningMode(%p,%p,%p)\n", pbModesPruned, pbKeyIsReadOnly, pbPruningOn);
361
362 *pbModesPruned = This->bModesPruned;
363 *pbKeyIsReadOnly = This->bKeyIsReadOnly;
364 *pbPruningOn = This->bPruningOn;
365}

Referenced by pCDevSettings_InitializeExtInterface().

◆ CDevSettings_QueryGetData()

static HRESULT STDMETHODCALLTYPE CDevSettings_QueryGetData ( IDataObject iface,
FORMATETC *  pformatetc 
)
static

Definition at line 856 of file devsett.c.

858{
859#if DEBUG
860 TCHAR szFormatName[255];
861#endif
863
864 if (pformatetc->dwAspect != DVASPECT_CONTENT)
865 return DV_E_DVASPECT;
866
867 if (pformatetc->lindex != -1)
868 return DV_E_LINDEX;
869
870 if (!(pformatetc->tymed & TYMED_HGLOBAL))
871 return DV_E_TYMED;
872
873 /* Check if the requested data can be provided */
874 if (pformatetc->cfFormat == This->cfExtInterface ||
875 pformatetc->cfFormat == This->cfDisplayDevice ||
876 pformatetc->cfFormat == This->cfDisplayName ||
877 pformatetc->cfFormat == This->cfDisplayId ||
878 pformatetc->cfFormat == This->cfDisplayKey ||
879 pformatetc->cfFormat == This->cfDisplayStateFlags ||
880 pformatetc->cfFormat == This->cfMonitorDevice ||
881 pformatetc->cfFormat == This->cfMonitorName ||
882 pformatetc->cfFormat == This->cfPruningMode)
883 {
884 return S_OK;
885 }
886#if DEBUG
887 else
888 {
889 if (GetClipboardFormatName(pformatetc->cfFormat,
890 szFormatName,
891 sizeof(szFormatName) / sizeof(szFormatName[0])))
892 {
893 DPRINT1("CDevSettings::QueryGetData(\"%ws\")\n", szFormatName);
894 }
895 else
896 {
897 DPRINT1("CDevSettings::QueryGetData(Format %u)\n", (unsigned int)pformatetc->cfFormat);
898 }
899 }
900#endif
901
902 return DV_E_FORMATETC;
903}
#define DV_E_TYMED
Definition: winerror.h:2638
#define DV_E_FORMATETC
Definition: winerror.h:2633
#define DV_E_LINDEX
Definition: winerror.h:2637
#define DV_E_DVASPECT
Definition: winerror.h:2640
#define GetClipboardFormatName
Definition: winuser.h:5783
char TCHAR
Definition: xmlstorage.h:189

◆ CDevSettings_QueryInterface()

static HRESULT STDMETHODCALLTYPE CDevSettings_QueryInterface ( IDataObject iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 664 of file devsett.c.

667{
669
670 *ppvObject = NULL;
671
672 if (IsEqualGUID(riid,
673 &IID_IUnknown) ||
676 {
678 return S_OK;
679 }
680 else
681 {
682 DPRINT1("CDevSettings::QueryInterface: Queried unknown interface\n");
683 }
684
685 return E_NOINTERFACE;
686}
const GUID IID_IUnknown
#define impl_to_interface(impl, iface)
Definition: devsett.c:59
REFIID riid
Definition: atlbase.h:39
const GUID IID_IDataObject
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
void * PVOID
Definition: typedefs.h:50
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ CDevSettings_Release()

static ULONG STDMETHODCALLTYPE CDevSettings_Release ( IDataObject iface)
static

Definition at line 696 of file devsett.c.

697{
698 ULONG refs;
700 refs = (ULONG)InterlockedDecrement((PLONG)&This->ref);
701 if (refs == 0)
703
704 return refs;
705}
#define InterlockedDecrement
Definition: armddk.h:52
static VOID pCDevSettings_Free(PCDevSettings This)
Definition: devsett.c:644

Referenced by CreateDevSettings().

◆ CDevSettings_SetCurrentMode()

BOOL DESK_EXT_CALLBACK CDevSettings_SetCurrentMode ( PVOID  Context,
DEVMODEW pDevMode 
)

Definition at line 325 of file devsett.c.

327{
329 DWORD i;
330
331 DPRINT1("CDevSettings::SetCurrentMode(0x%p)\n", pDevMode);
332
333 if (!This->DevModes)
334 return FALSE;
335
336 for (i = 0; i < This->nDevModes; i++)
337 {
338 /* FIXME: Add more sanity checks */
339 if (!This->DevModes[i])
340 continue;
341
342 if (This->DevModes[i] == pDevMode)
343 {
344 This->lpCurDevMode = pDevMode;
345 return TRUE;
346 }
347 }
348
349 return FALSE;
350}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117

Referenced by pCDevSettings_InitializeExtInterface().

◆ CDevSettings_SetData()

static HRESULT STDMETHODCALLTYPE CDevSettings_SetData ( IDataObject iface,
FORMATETC *  pformatetc,
STGMEDIUM *  pmedium,
BOOL  fRelease 
)
static

Definition at line 941 of file devsett.c.

945{
946 DPRINT1("CDevSettings::SetData UNIMPLEMENTED\n");
947 return E_NOTIMPL;
948}

◆ CDevSettings_SetPruningMode()

VOID DESK_EXT_CALLBACK CDevSettings_SetPruningMode ( PVOID  Context,
BOOL  PruningOn 
)

Definition at line 368 of file devsett.c.

370{
371 HKEY hKey;
372 DWORD dwValue;
374
375 DPRINT1("CDevSettings::SetPruningMode(%d)\n", PruningOn);
376
377 if (This->bModesPruned && !This->bKeyIsReadOnly &&
378 PruningOn != This->bPruningOn)
379 {
380 This->bPruningOn = (PruningOn != FALSE);
381
383 FALSE);
384 if (hKey != NULL)
385 {
386 dwValue = (DWORD)This->bPruningOn;
387
389 TEXT("PruningMode"),
390 0,
391 REG_DWORD,
392 (const BYTE *)&dwValue,
393 sizeof(dwValue));
394
396 }
397 }
398}
#define RegCloseKey(hKey)
Definition: registry.h:49
static HKEY pCDevSettings_OpenDeviceKey(PCDevSettings This, BOOL ReadOnly)
Definition: devsett.c:253
FxAutoRegKey hKey
#define TEXT(s)
Definition: k32.h:26
#define DWORD
Definition: nt_native.h:44
#define REG_DWORD
Definition: sdbapi.c:596
#define RegSetValueEx
Definition: winreg.h:533
unsigned char BYTE
Definition: xxhash.c:193

Referenced by pCDevSettings_InitializeExtInterface().

◆ CreateDevSettings()

IDataObject * CreateDevSettings ( PDISPLAY_DEVICE_ENTRY  DisplayDeviceInfo)

Definition at line 1045 of file devsett.c.

1046{
1048
1050 0,
1051 sizeof(*This));
1052 if (This != NULL)
1053 {
1054 This->lpIDataObjectVtbl = &vtblIDataObject;
1055 This->ref = 1;
1056
1058 DisplayDeviceInfo)))
1059 {
1061 }
1062
1064 }
1065
1066 return NULL;
1067}
static const struct IDataObjectVtbl vtblIDataObject
Definition: devsett.c:1029
static ULONG STDMETHODCALLTYPE CDevSettings_Release(IDataObject *iface)
Definition: devsett.c:696
static HRESULT pCDevSettings_Initialize(PCDevSettings This, PDISPLAY_DEVICE_ENTRY DisplayDeviceInfo)
Definition: devsett.c:493
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733

Referenced by DisplayAdvancedSettings().

◆ DisplaySaveSettings()

LONG WINAPI DisplaySaveSettings ( PVOID  pContext,
HWND  hwndPropSheet 
)

Definition at line 1070 of file devsett.c.

1072{
1075
1076 if (This->lpCurDevMode != This->lpOrigDevMode)
1077 {
1078 SETTINGS_ENTRY seOrig, seCur;
1079 BOOL Ret;
1080
1081 seOrig.dmPelsWidth = This->lpOrigDevMode->dmPelsWidth;
1082 seOrig.dmPelsHeight = This->lpOrigDevMode->dmPelsHeight;
1083 seOrig.dmBitsPerPel = This->lpOrigDevMode->dmBitsPerPel;
1084 seOrig.dmDisplayFrequency = This->lpOrigDevMode->dmDisplayFrequency;
1085
1086 seCur.dmPelsWidth = This->lpCurDevMode->dmPelsWidth;
1087 seCur.dmPelsHeight = This->lpCurDevMode->dmPelsHeight;
1088 seCur.dmBitsPerPel = This->lpCurDevMode->dmBitsPerPel;
1089 seCur.dmDisplayFrequency = This->lpCurDevMode->dmDisplayFrequency;
1090
1091 Ret = SwitchDisplayMode(hwndPropSheet,
1092 This->pDisplayDevice,
1093 &seOrig,
1094 &seCur,
1095 &rc);
1096
1097 if (rc == DISP_CHANGE_SUCCESSFUL)
1098 {
1099 if (Ret)
1100 This->lpOrigDevMode = This->lpCurDevMode;
1101 else
1102 This->lpCurDevMode = This->lpOrigDevMode;
1103 }
1104 }
1105
1106 return rc;
1107}
BOOL SwitchDisplayMode(HWND hwndDlg, PWSTR DeviceName, PSETTINGS_ENTRY seInit, PSETTINGS_ENTRY seNew, OUT PLONG rc)
Definition: settings.c:771
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
Definition: precomp.h:59
DWORD dmPelsHeight
Definition: precomp.h:64
DWORD dmDisplayFrequency
Definition: desk.h:138
DWORD dmBitsPerPel
Definition: precomp.h:62
DWORD dmPelsWidth
Definition: precomp.h:63
#define DISP_CHANGE_SUCCESSFUL
Definition: winuser.h:190

◆ impl_from_IDataObject()

◆ pCDevSettings_AllocAndCopyString()

static PWSTR pCDevSettings_AllocAndCopyString ( const TCHAR pszSrc)
static

Definition at line 79 of file devsett.c.

80{
81 SIZE_T c;
82 PWSTR str;
83
84 c = _tcslen(pszSrc) + 1;
86 c * sizeof(WCHAR));
87 if (str != NULL)
88 {
89#ifdef UNICODE
90 StringCbCopyW(str, c * sizeof(WCHAR),
91 pszSrc);
92#else
94 0,
95 pszSrc,
96 -1,
97 str,
98 c);
99#endif
100 }
101
102 return str;
103}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
const GLubyte * c
Definition: glext.h:8905
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
#define c
Definition: ke_i.h:80
const WCHAR * str
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define LMEM_FIXED
Definition: winbase.h:368
#define _tcslen
Definition: xmlstorage.h:198

Referenced by pCDevSettings_Initialize().

◆ pCDevSettings_FillFormatEtc()

static __inline VOID pCDevSettings_FillFormatEtc ( FORMATETC *  pFormatEtc,
CLIPFORMAT  cf 
)
static

Definition at line 951 of file devsett.c.

953{
954 pFormatEtc->cfFormat = cf;
955 pFormatEtc->ptd = NULL;
956 pFormatEtc->dwAspect = DVASPECT_CONTENT;
957 pFormatEtc->lindex = -1;
958 pFormatEtc->tymed = TYMED_HGLOBAL;
959}

Referenced by CDevSettings_EnumFormatEtc().

◆ pCDevSettings_Free()

static VOID pCDevSettings_Free ( PCDevSettings  This)
static

Definition at line 644 of file devsett.c.

645{
646 This->lpOrigDevMode = NULL;
647 This->lpCurDevMode = NULL;
648 while (This->nDevModes)
649 {
650 LocalFree(This->DevModes[--This->nDevModes]);
651 }
652 LocalFree(This->DevModes);
653 This->DevModes = NULL;
654
655 pCDevSettings_FreeString(&This->pDisplayDevice);
656 pCDevSettings_FreeString(&This->pDisplayName);
657 pCDevSettings_FreeString(&This->pDisplayKey);
658 pCDevSettings_FreeString(&This->pDisplayId);
659 pCDevSettings_FreeString(&This->pMonitorName);
660 pCDevSettings_FreeString(&This->pMonitorDevice);
661}
static __inline VOID pCDevSettings_FreeString(PWCHAR *psz)
Definition: devsett.c:69
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594

Referenced by CDevSettings_Release().

◆ pCDevSettings_FreeString()

static __inline VOID pCDevSettings_FreeString ( PWCHAR psz)
static

Definition at line 69 of file devsett.c.

70{
71 if (*psz != NULL)
72 {
73 LocalFree((HLOCAL)*psz);
74 *psz = NULL;
75 }
76}

Referenced by pCDevSettings_Free().

◆ pCDevSettings_GetDeviceInstanceId()

static PWSTR pCDevSettings_GetDeviceInstanceId ( const WCHAR pszDevice)
static

Converts a Hardware ID (DeviceID from EnumDisplayDevices) to an unique Device Instance ID.

Parameters
[in]pszDeviceA pointer to a null-terminated Unicode string containing a Hardware ID. e.g. "PCI\VEN_80EE&DEV_BEEF&SUBSYS_00000000&REV_00"
Returns
A pointer to a null-terminated Unicode string containing an unique Device Instance ID or NULL in case of error. e.g. "PCI\VEN_80EE&DEV_BEEF&SUBSYS_00000000&REV_00\3&267A616A&0&10"
Remarks
The caller must free the returned string with LocalFree.

Definition at line 195 of file devsett.c.

196{
197 HDEVINFO DevInfo;
198 SP_DEVINFO_DATA InfoData;
200 LPWSTR lpDevInstId = NULL;
201
202 DPRINT("CDevSettings::GetDeviceInstanceId(%ws)!\n", pszDevice);
203
205 if (DevInfo == INVALID_HANDLE_VALUE)
206 {
207 DPRINT1("SetupDiGetClassDevsW(\"%ws\") failed: %d\n", pszDevice, GetLastError());
208 return NULL;
209 }
210
211 ZeroMemory(&InfoData, sizeof(InfoData));
212 InfoData.cbSize = sizeof(InfoData);
213
214 /* Try to enumerate the first matching device */
215 if (!SetupDiEnumDeviceInfo(DevInfo, 0, &InfoData))
216 {
217 DPRINT1("SetupDiEnumDeviceInfo failed: %d\n", GetLastError());
218 return NULL;
219 }
220
221 if (SetupDiGetDeviceInstanceId(DevInfo, &InfoData, NULL, 0, &BufLen) ||
223 {
224 DPRINT1("SetupDiGetDeviceInstanceId failed: %d\n", GetLastError());
225 return NULL;
226 }
227
228 lpDevInstId = LocalAlloc(LMEM_FIXED,
229 (BufLen + 1) * sizeof(WCHAR));
230
231 if (lpDevInstId == NULL)
232 {
233 DPRINT1("LocalAlloc failed\n");
234 return NULL;
235 }
236
237 if (!SetupDiGetDeviceInstanceId(DevInfo, &InfoData, lpDevInstId, BufLen, NULL))
238 {
239 DPRINT1("SetupDiGetDeviceInstanceId failed: %d\n", GetLastError());
240 LocalFree((HLOCAL)lpDevInstId);
241 lpDevInstId = NULL;
242 }
243 else
244 {
245 DPRINT("instance id: %ws\n", lpDevInstId);
246 }
247
248 return lpDevInstId;
249}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
BOOL WINAPI SetupDiEnumDeviceInfo(HDEVINFO devinfo, DWORD index, PSP_DEVINFO_DATA info)
Definition: devinst.c:1787
HDEVINFO WINAPI SetupDiGetClassDevsW(CONST GUID *class, LPCWSTR enumstr, HWND parent, DWORD flags)
Definition: devinst.c:2292
#define BufLen
Definition: fatfs.h:167
#define SetupDiGetDeviceInstanceId
Definition: setupapi.h:2600
#define DIGCF_ALLCLASSES
Definition: setupapi.h:172
#define DIGCF_PRESENT
Definition: setupapi.h:171
#define DPRINT
Definition: sndvol32.h:71
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by pCDevSettings_Initialize().

◆ pCDevSettings_GetMonitorDevice()

static PWSTR pCDevSettings_GetMonitorDevice ( const WCHAR pszDisplayDevice)
static

Definition at line 152 of file devsett.c.

153{
155 PWSTR str = NULL;
156
157 dd.cb = sizeof(dd);
158 if (EnumDisplayDevicesW(pszDisplayDevice,
159 0,
160 &dd,
161 0))
162 {
164 (wcslen(dd.DeviceName) + 1) * sizeof(WCHAR));
165 if (str != NULL)
166 {
167 wcscpy(str,
168 dd.DeviceName);
169 }
170 }
171
172 return str;
173}
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
WCHAR DeviceName[32]
Definition: wingdi.h:2818
BOOL WINAPI EnumDisplayDevicesW(LPCWSTR lpDevice, DWORD iDevNum, PDISPLAY_DEVICEW lpDisplayDevice, DWORD dwFlags)
Definition: display.c:78

Referenced by pCDevSettings_Initialize().

◆ pCDevSettings_GetMonitorName()

static PWSTR pCDevSettings_GetMonitorName ( const WCHAR pszDisplayDevice)
static

Definition at line 106 of file devsett.c.

107{
108 DISPLAY_DEVICEW dd, dd2;
109 PWSTR str = NULL;
110
111 dd.cb = sizeof(dd);
112 if (EnumDisplayDevicesW(pszDisplayDevice,
113 0,
114 &dd,
115 0))
116 {
117 dd2.cb = sizeof(dd2);
118 if (EnumDisplayDevicesW(pszDisplayDevice,
119 1,
120 &dd2,
121 0))
122 {
123 /* There's more than one monitor connected... */
126 dd.DeviceString,
127 sizeof(dd.DeviceString) / sizeof(dd.DeviceString[0]));
128 }
129 }
130 else
131 {
132 /* We can't enumerate a monitor, make sure this fact is reported
133 to the user! */
136 dd.DeviceString,
137 sizeof(dd.DeviceString) / sizeof(dd.DeviceString[0]));
138 }
139
141 (wcslen(dd.DeviceString) + 1) * sizeof(WCHAR));
142 if (str != NULL)
143 {
144 wcscpy(str,
145 dd.DeviceString);
146 }
147
148 return str;
149}
HINSTANCE hApplet
Definition: access.c:17
#define IDS_UNKNOWNMONITOR
Definition: resource.h:158
#define IDS_MULTIPLEMONITORS
Definition: resource.h:157
WCHAR DeviceString[128]
Definition: wingdi.h:2819
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)

Referenced by pCDevSettings_Initialize().

◆ pCDevSettings_Initialize()

static HRESULT pCDevSettings_Initialize ( PCDevSettings  This,
PDISPLAY_DEVICE_ENTRY  DisplayDeviceInfo 
)
static

Definition at line 493 of file devsett.c.

495{
496 HKEY hKey;
497 DWORD i = 0, dwSize;
499
500 This->lpOrigDevMode = NULL;
501 This->lpCurDevMode = NULL;
502 This->DevModes = NULL;
503 This->nDevModes = 0;
504 This->Flags = 0;
505 This->StateFlags = DisplayDeviceInfo->DeviceStateFlags;
506 DPRINT1("This->StateFlags: %x\n", This->StateFlags);
507
508 /* Register clipboard formats */
518
519 /* Copy the device name */
520 This->pDisplayDevice = pCDevSettings_AllocAndCopyString(DisplayDeviceInfo->DeviceName);
521 DPRINT1("This->pDisplayDevice: %ws\n", This->pDisplayDevice);
522 This->pDisplayName = pCDevSettings_AllocAndCopyString(DisplayDeviceInfo->DeviceDescription);
523 DPRINT1("This->pDisplayName: %ws\n", This->pDisplayName);
524 This->pDisplayKey = pCDevSettings_AllocAndCopyString(DisplayDeviceInfo->DeviceKey);
525 DPRINT1("This->pDisplayKey: %ws\n", This->pDisplayKey);
526 This->pDisplayId = pCDevSettings_GetDeviceInstanceId(DisplayDeviceInfo->DeviceID);
527 DPRINT1("This->pDisplayId: %ws\n", This->pDisplayId);
528 This->pMonitorName = pCDevSettings_GetMonitorName(This->pDisplayDevice);
529 DPRINT1("This->pMonitorName: %ws\n", This->pMonitorName);
530 This->pMonitorDevice = pCDevSettings_GetMonitorDevice(This->pDisplayDevice);
531 DPRINT1("This->pMonitorDevice: %ws\n", This->pMonitorDevice);
532
533 /* Check pruning mode */
534 This->bModesPruned = ((DisplayDeviceInfo->DeviceStateFlags & DISPLAY_DEVICE_MODESPRUNED) != 0);
536 FALSE);
537 if (hKey == NULL)
538 {
540 FALSE);
541 This->bKeyIsReadOnly = TRUE;
542 }
543 if (hKey != NULL)
544 {
545 DWORD dw = 0;
546 DWORD dwType;
547
548 dwSize = sizeof(dw);
550 TEXT("PruningMode"),
551 NULL,
552 &dwType,
553 (PBYTE)&dw,
555 {
556 if (dwType == REG_DWORD && dwSize == sizeof(dw))
557 This->bPruningOn = (dw != 0);
558 }
559
561 }
562
563 /* Initialize display modes */
564 ZeroMemory(&devmode, sizeof(devmode));
565 devmode.dmSize = (WORD)sizeof(devmode);
566 while (EnumDisplaySettingsExW(This->pDisplayDevice, i, &devmode, EDS_RAWMODE))
567 {
570 PDEVMODEW * DevModesNew = NULL;
571
572 if (pDevMode)
573 {
574 CopyMemory(pDevMode,
575 &devmode,
576 dwSize);
577
578 dwSize = (This->nDevModes + 1) * sizeof(pDevMode);
579 DevModesNew = LocalAlloc(LMEM_FIXED, dwSize);
580 if (DevModesNew)
581 {
582 if (This->DevModes)
583 {
584 CopyMemory(DevModesNew,
585 This->DevModes,
586 This->nDevModes * sizeof(pDevMode));
587
588 LocalFree(This->DevModes);
589 }
590
591 This->DevModes = DevModesNew;
592 This->DevModes[This->nDevModes++] = pDevMode;
593 }
594 else
595 {
596 DPRINT1("LocalAlloc failed to allocate %d bytes\n", dwSize);
597 return E_OUTOFMEMORY;
598 }
599 }
600 else
601 {
602 DPRINT1("LocalAlloc failed to allocate %d bytes\n", dwSize);
603 return E_OUTOFMEMORY;
604 }
605
607 i++;
608 }
609
610 /* FIXME: Detect duplicated modes and mark them.
611 * Enumeration functions should check these marks
612 * and skip corresponding array entries. */
613
614 /* Get current display mode */
615 ZeroMemory(&devmode, sizeof(devmode));
616 devmode.dmSize = (WORD)sizeof(devmode);
617 if (EnumDisplaySettingsExW(This->pDisplayDevice, ENUM_CURRENT_SETTINGS, &devmode, 0))
618 {
619 for (i = 0; i < This->nDevModes; i++)
620 {
621 PDEVMODEW CurMode = This->DevModes[i];
622
623 if (!CurMode)
624 continue;
625
626 if (((CurMode->dmFields & DM_PELSWIDTH) && devmode.dmPelsWidth == CurMode->dmPelsWidth) &&
627 ((CurMode->dmFields & DM_PELSHEIGHT) && devmode.dmPelsHeight == CurMode->dmPelsHeight) &&
628 ((CurMode->dmFields & DM_BITSPERPEL) && devmode.dmBitsPerPel == CurMode->dmBitsPerPel) &&
630 {
631 This->lpOrigDevMode = This->lpCurDevMode = CurMode;
632 break;
633 }
634 }
635 }
636
637 /* Initialize the shell extension interface */
639
640 return S_OK;
641}
DEVMODEW devmode
#define ERROR_SUCCESS
Definition: deptool.c:10
#define DESK_EXT_MONITORNAME
Definition: deskcplx.h:13
#define DESK_EXT_DISPLAYSTATEFLAGS
Definition: deskcplx.h:12
#define DESK_EXT_DISPLAYDEVICE
Definition: deskcplx.h:8
#define DESK_EXT_PRUNINGMODE
Definition: deskcplx.h:7
#define DESK_EXT_EXTINTERFACE
Definition: deskcplx.h:6
#define DESK_EXT_DISPLAYNAME
Definition: deskcplx.h:9
#define DESK_EXT_DISPLAYID
Definition: deskcplx.h:10
#define DESK_EXT_DISPLAYKEY
Definition: deskcplx.h:11
#define DESK_EXT_MONITORDEVICE
Definition: deskcplx.h:14
static PWSTR pCDevSettings_GetMonitorDevice(const WCHAR *pszDisplayDevice)
Definition: devsett.c:152
static PWSTR pCDevSettings_AllocAndCopyString(const TCHAR *pszSrc)
Definition: devsett.c:79
static VOID pCDevSettings_InitializeExtInterface(PCDevSettings This)
Definition: devsett.c:416
static PWSTR pCDevSettings_GetDeviceInstanceId(const WCHAR *pszDevice)
Converts a Hardware ID (DeviceID from EnumDisplayDevices) to an unique Device Instance ID.
Definition: devsett.c:195
static PWSTR pCDevSettings_GetMonitorName(const WCHAR *pszDisplayDevice)
Definition: devsett.c:106
unsigned short WORD
Definition: ntddk_ex.h:93
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
DWORD DeviceStateFlags
Definition: precomp.h:74
LPWSTR DeviceID
Definition: precomp.h:73
LPWSTR DeviceDescription
Definition: precomp.h:70
LPWSTR DeviceKey
Definition: precomp.h:72
LPWSTR DeviceName
Definition: precomp.h:71
DWORD dmBitsPerPel
Definition: wingdi.h:1647
DWORD dmFields
Definition: wingdi.h:1622
DWORD dmPelsWidth
Definition: wingdi.h:1648
WORD dmDriverExtra
Definition: wingdi.h:1621
DWORD dmPelsHeight
Definition: wingdi.h:1649
DWORD dmDisplayFrequency
Definition: wingdi.h:1654
WORD dmSize
Definition: wingdi.h:1620
BOOL WINAPI EnumDisplaySettingsExW(LPCWSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEW lpDevMode, DWORD dwFlags)
Definition: display.c:330
#define DM_DISPLAYFREQUENCY
Definition: wingdi.h:1272
#define DM_PELSWIDTH
Definition: wingdi.h:1269
#define DM_BITSPERPEL
Definition: wingdi.h:1268
#define DM_PELSHEIGHT
Definition: wingdi.h:1270
#define DISPLAY_DEVICE_MODESPRUNED
Definition: wingdi.h:1404
#define RegQueryValueEx
Definition: winreg.h:524
#define RegisterClipboardFormat
Definition: winuser.h:5837
#define ENUM_CURRENT_SETTINGS
Definition: winuser.h:179

Referenced by CreateDevSettings().

◆ pCDevSettings_InitializeExtInterface()

static VOID pCDevSettings_InitializeExtInterface ( PCDevSettings  This)
static

Definition at line 416 of file devsett.c.

417{
418 PDESK_EXT_INTERFACE Interface = &This->ExtInterface;
419 HKEY hKeyDev;
420
422 sizeof(*Interface));
423 Interface->cbSize = sizeof(*Interface);
424
425 /* Initialize the callback table */
427 Interface->EnumAllModes = CDevSettings_EnumAllModes;
428 Interface->SetCurrentMode = CDevSettings_SetCurrentMode;
429 Interface->GetCurrentMode = CDevSettings_GetCurrentMode;
430 Interface->SetPruningMode = CDevSettings_SetPruningMode;
431 Interface->GetPruningMode = CDevSettings_GetPruningMode;
432
433 /* Read the HardwareInformation.* values from the registry key */
435 TRUE);
436 if (hKeyDev != NULL)
437 {
438 DWORD dwType, dwMemSize = 0;
439 DWORD dwSize = sizeof(dwMemSize);
440
441 if (RegQueryValueEx(hKeyDev,
442 TEXT("HardwareInformation.MemorySize"),
443 NULL,
444 &dwType,
445 (PBYTE)&dwMemSize,
446 &dwSize) == ERROR_SUCCESS &&
447 (dwType == REG_BINARY || dwType == REG_DWORD) &&
448 dwSize == sizeof(dwMemSize))
449 {
450 dwMemSize /= 1024;
451
452 if (dwMemSize > 1024)
453 {
454 dwMemSize /= 1024;
455 if (dwMemSize > 1024)
456 {
457 wsprintf(Interface->MemorySize,
458 _T("%u GB"),
459 dwMemSize / 1024);
460 }
461 else
462 {
463 wsprintf(Interface->MemorySize,
464 _T("%u MB"),
465 dwMemSize);
466 }
467 }
468 else
469 {
470 wsprintf(Interface->MemorySize,
471 _T("%u KB"),
472 dwMemSize);
473 }
474 }
475
477 TEXT("HardwareInformation.ChipType"),
478 Interface->ChipType);
480 TEXT("HardwareInformation.DacType"),
481 Interface->DacType);
483 TEXT("HardwareInformation.AdapterString"),
484 Interface->AdapterString);
486 TEXT("HardwareInformation.BiosString"),
487 Interface->BiosString);
488 RegCloseKey(hKeyDev);
489 }
490}
VOID DESK_EXT_CALLBACK CDevSettings_GetPruningMode(PVOID Context, PBOOL pbModesPruned, PBOOL pbKeyIsReadOnly, PBOOL pbPruningOn)
Definition: devsett.c:353
PDEVMODEW DESK_EXT_CALLBACK CDevSettings_EnumAllModes(PVOID Context, DWORD Index)
Definition: devsett.c:289
BOOL DESK_EXT_CALLBACK CDevSettings_SetCurrentMode(PVOID Context, DEVMODEW *pDevMode)
Definition: devsett.c:325
VOID DESK_EXT_CALLBACK CDevSettings_SetPruningMode(PVOID Context, BOOL PruningOn)
Definition: devsett.c:368
PDEVMODEW DESK_EXT_CALLBACK CDevSettings_GetCurrentMode(PVOID Context)
Definition: devsett.c:316
static VOID pCDevSettings_ReadHardwareInfo(HKEY hKey, LPCTSTR lpValueName, LPWSTR lpBuffer)
Definition: devsett.c:401
#define REG_BINARY
Definition: nt_native.h:1496
#define _T(x)
Definition: vfdio.h:22
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
#define wsprintf
Definition: winuser.h:5864

Referenced by pCDevSettings_Initialize().

◆ pCDevSettings_OpenDeviceKey()

static HKEY pCDevSettings_OpenDeviceKey ( PCDevSettings  This,
BOOL  ReadOnly 
)
static

Definition at line 253 of file devsett.c.

255{
256 static const WCHAR szRegPrefix[] = L"\\Registry\\Machine\\";
257 PWSTR lpRegKey;
258 REGSAM Access = KEY_READ;
259 HKEY hKey;
260
261 lpRegKey = This->pDisplayKey;
262 if (lpRegKey != NULL)
263 {
264 if (wcslen(lpRegKey) >= wcslen(szRegPrefix) &&
265 !_wcsnicmp(lpRegKey,
266 szRegPrefix,
267 wcslen(szRegPrefix)))
268 {
269 lpRegKey += wcslen(szRegPrefix);
270 }
271
272 if (!ReadOnly)
273 Access |= KEY_WRITE;
274
276 lpRegKey,
277 0,
278 Access,
279 &hKey) == ERROR_SUCCESS)
280 {
281 return hKey;
282 }
283 }
284
285 return NULL;
286}
#define KEY_READ
Definition: nt_native.h:1023
#define KEY_WRITE
Definition: nt_native.h:1031
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
@ ReadOnly
Definition: arc.h:80
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RegOpenKeyEx
Definition: winreg.h:520
ACCESS_MASK REGSAM
Definition: winreg.h:69

Referenced by CDevSettings_SetPruningMode(), pCDevSettings_Initialize(), and pCDevSettings_InitializeExtInterface().

◆ pCDevSettings_ReadHardwareInfo()

static VOID pCDevSettings_ReadHardwareInfo ( HKEY  hKey,
LPCTSTR  lpValueName,
LPWSTR  lpBuffer 
)
static

Definition at line 401 of file devsett.c.

404{
406 DWORD size = 128 * sizeof(WCHAR);
408 lpValueName,
409 NULL,
410 &type,
412 &size);
413}
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919

Referenced by pCDevSettings_InitializeExtInterface().

Variable Documentation

◆ vtblIDataObject

const struct IDataObjectVtbl vtblIDataObject
static
Initial value:
= {
}
static HRESULT STDMETHODCALLTYPE CDevSettings_QueryInterface(IDataObject *iface, REFIID riid, void **ppvObject)
Definition: devsett.c:664
static HRESULT STDMETHODCALLTYPE CDevSettings_QueryGetData(IDataObject *iface, FORMATETC *pformatetc)
Definition: devsett.c:856
static HRESULT STDMETHODCALLTYPE CDevSettings_SetData(IDataObject *iface, FORMATETC *pformatetc, STGMEDIUM *pmedium, BOOL fRelease)
Definition: devsett.c:941
static HRESULT STDMETHODCALLTYPE CDevSettings_GetData(IDataObject *iface, FORMATETC *pformatetcIn, STGMEDIUM *pmedium)
Definition: devsett.c:708
static HRESULT STDMETHODCALLTYPE CDevSettings_EnumFormatEtc(IDataObject *iface, DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc)
Definition: devsett.c:962
static HRESULT STDMETHODCALLTYPE CDevSettings_GetDataHere(IDataObject *iface, FORMATETC *pformatetc, STGMEDIUM *pmedium)
Definition: devsett.c:846
static ULONG STDMETHODCALLTYPE CDevSettings_AddRef(IDataObject *iface)
Definition: devsett.c:689
static HRESULT STDMETHODCALLTYPE CDevSettings_GetCanonicalFormatEtc(IDataObject *iface, FORMATETC *pformatectIn, FORMATETC *pformatetcOut)
Definition: devsett.c:906
static HRESULT STDMETHODCALLTYPE CDevSettings_DUnadvise(IDataObject *iface, DWORD dwConnection)
Definition: devsett.c:1015
static HRESULT STDMETHODCALLTYPE CDevSettings_DAdvise(IDataObject *iface, FORMATETC *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
Definition: devsett.c:1004
static HRESULT STDMETHODCALLTYPE CDevSettings_EnumDAdvise(IDataObject *iface, IEnumSTATDATA **ppenumAdvise)
Definition: devsett.c:1022

Definition at line 1029 of file devsett.c.

Referenced by CreateDevSettings().