ReactOS  0.4.14-dev-833-g5f692ed
sysdm.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS System Control Panel Applet
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: dll/cpl/sysdm/sysdm.c
5  * PURPOSE: dll entry file
6  * COPYRIGHT: Copyright Thomas Weidenmueller <w3seek@reactos.org>
7  *
8  */
9 
10 #include "precomp.h"
11 
12 #include <cpl.h>
13 #include <regstr.h>
14 
18 
19 /* Applets */
21 {
23 };
24 
25 #define MAX_SYSTEM_PAGES 32
26 
27 
28 INT
31  IN HWND hwnd,
32  IN UINT uType,
33  IN UINT uCaption,
34  IN UINT uText)
35 {
36  WCHAR szCaption[256];
37  WCHAR szText[256];
38 
39  LoadStringW(hInstance, uCaption, szCaption, 256);
40  LoadStringW(hInstance, uText, szText, 256);
41 
42  return MessageBoxW(hwnd,
43  szText,
44  szCaption,
45  uType);
46 }
47 
48 
49 static BOOL CALLBACK
51 {
53  if (ppsh != NULL && ppsh->nPages < MAX_SYSTEM_PAGES)
54  {
55  ppsh->phpage[ppsh->nPages++] = hpage;
56  return TRUE;
57  }
58 
59  return FALSE;
60 }
61 
62 static BOOL
64 {
65  HPROPSHEETPAGE hPage;
66  PROPSHEETPAGE psp;
67 
68  if (ppsh->nPages < MAX_SYSTEM_PAGES)
69  {
70  ZeroMemory(&psp, sizeof(psp));
71  psp.dwSize = sizeof(psp);
72  psp.dwFlags = PSP_DEFAULT;
73  psp.hInstance = hApplet;
74  psp.pszTemplate = MAKEINTRESOURCE(idDlg);
75  psp.pfnDlgProc = DlgProc;
76 
77  hPage = CreatePropertySheetPage(&psp);
78  if (hPage != NULL)
79  {
80  return PropSheetAddPage(hPage, (LPARAM)ppsh);
81  }
82  }
83 
84  return FALSE;
85 }
86 
88 
89 static HMODULE
91 {
92  HPROPSHEETPAGE hPage;
93  HMODULE hMod;
94  PCreateNetIDPropertyPage pCreateNetIdPage;
95 
96  hMod = LoadLibrary(TEXT("netid.dll"));
97  if (hMod != NULL)
98  {
99  pCreateNetIdPage = (PCreateNetIDPropertyPage)GetProcAddress(hMod,
100  "CreateNetIDPropertyPage");
101  if (pCreateNetIdPage != NULL)
102  {
103  hPage = pCreateNetIdPage();
104  if (hPage == NULL)
105  goto Fail;
106 
107  if (!PropSheetAddPage(hPage, (LPARAM)ppsh))
108  {
110  goto Fail;
111  }
112  }
113  else
114  {
115 Fail:
116  FreeLibrary(hMod);
117  hMod = NULL;
118  }
119  }
120 
121  return hMod;
122 }
123 
124 static int CALLBACK
126 {
127  // NOTE: This callback is needed to set large icon correctly.
128  HICON hIcon;
129  switch (uMsg)
130  {
131  case PSCB_INITIALIZED:
132  {
134  SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
135  break;
136  }
137  }
138  return 0;
139 }
140 
141 /* First Applet */
144 {
146  PROPSHEETHEADER psh;
147  HMODULE hNetIdDll;
148  HPSXA hpsxa = NULL;
149  LONG Ret;
151 
152  if (!InitCommonControlsEx(&icc))
153  return 0;
154 
155  ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
156  psh.dwSize = sizeof(PROPSHEETHEADER);
157  psh.dwFlags = PSH_PROPTITLE | PSH_USEICONID | PSH_USECALLBACK;
158  psh.hwndParent = hCPLWindow;
159  psh.hInstance = hApplet;
160  psh.pszIcon = MAKEINTRESOURCEW(IDI_USERPROF);
161  psh.pszCaption = MAKEINTRESOURCE(IDS_CPLSYSTEMNAME);
162  psh.nPages = 0;
163  psh.nStartPage = 0;
164  psh.phpage = hpsp;
165  psh.pfnCallback = PropSheetProc;
166 
168  hNetIdDll = AddNetIdPage(&psh);
171 
172  /* Load additional pages provided by shell extensions */
174  if (hpsxa != NULL)
175  {
177  }
178 
179  Ret = (LONG)(PropertySheet(&psh) != -1);
180 
181  if (hpsxa != NULL)
182  {
184  }
185 
186  if (hNetIdDll != NULL)
187  FreeLibrary(hNetIdDll);
188 
189  return Ret;
190 }
191 
192 /* Control Panel Callback */
194 CPlApplet(HWND hwndCPl,
195  UINT uMsg,
196  LPARAM lParam1,
197  LPARAM lParam2)
198 {
199  INT i = (INT)lParam1;
200 
201  UNREFERENCED_PARAMETER(hwndCPl);
202 
203  switch (uMsg)
204  {
205  case CPL_INIT:
206  return TRUE;
207 
208  case CPL_GETCOUNT:
209  return NUM_APPLETS;
210 
211  case CPL_INQUIRE:
212  {
213  CPLINFO *CPlInfo = (CPLINFO*)lParam2;
214  CPlInfo->lData = 0;
215  CPlInfo->idIcon = Applets[i].idIcon;
216  CPlInfo->idName = Applets[i].idName;
217  CPlInfo->idInfo = Applets[i].idDescription;
218  }
219  break;
220 
221  case CPL_DBLCLK:
222  hCPLWindow = hwndCPl;
223  Applets[i].AppletProc();
224  break;
225  }
226 
227  return FALSE;
228 }
229 
230 
231 BOOL WINAPI
233  DWORD dwReason,
235 {
237 
238  switch (dwReason)
239  {
240  case DLL_PROCESS_ATTACH:
241  case DLL_THREAD_ATTACH:
242  hApplet = hinstDLL;
243  break;
244  }
245 
246  return TRUE;
247 }
void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
Definition: shellord.c:1755
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
WORD idDlg
Definition: desk.c:109
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IN
Definition: typedefs.h:38
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
Definition: cpl.h:24
#define LoadLibrary
Definition: winbase.h:3696
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define DLL_THREAD_ATTACH
Definition: compat.h:121
#define IDI_CPLSYSTEM
Definition: resource.h:4
UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
Definition: shellord.c:1577
BOOL WINAPI DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage)
Definition: propsheet.c:3144
HINSTANCE hApplet
Definition: sysdm.c:16
int idName
Definition: hotplug.h:27
#define REGSTR_PATH_CONTROLSFOLDER
Definition: regstr.h:76
#define INT
Definition: polytest.cpp:20
int idIcon
Definition: hotplug.h:26
#define CALLBACK
Definition: compat.h:27
int idInfo
Definition: cpl.h:27
#define ZeroMemory
Definition: winbase.h:1642
static HMODULE AddNetIdPage(PROPSHEETHEADER *ppsh)
Definition: sysdm.c:90
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
Definition: sysdm.c:125
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
#define PSH_USECALLBACK
Definition: prsht.h:48
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
int32_t INT
Definition: typedefs.h:56
static IN DWORD IN LPVOID lpvReserved
int idIcon
Definition: cpl.h:25
int idDescription
Definition: hotplug.h:28
#define CPL_DBLCLK
Definition: cpl.h:16
DWORD dwReason
Definition: misc.cpp:154
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
HINSTANCE hInstance
Definition: charmap.c:20
#define PSH_USEICONID
Definition: prsht.h:42
INT_PTR CALLBACK GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
static const WCHAR szText[]
Definition: dialog.c:139
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
static BOOL InitPropSheetPage(PROPSHEETHEADER *ppsh, WORD idDlg, DLGPROC DlgProc)
Definition: sysdm.c:63
smooth NULL
Definition: ftsmooth.c:416
#define PROPSHEETHEADER
Definition: prsht.h:374
LONG_PTR LPARAM
Definition: windef.h:208
#define CreatePropertySheetPage
Definition: prsht.h:381
#define IDS_CPLSYSTEMNAME
Definition: resource.h:23
#define PSP_DEFAULT
Definition: prsht.h:22
#define FreeLibrary(x)
Definition: compat.h:413
#define MAX_SYSTEM_PAGES
Definition: sysdm.c:25
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define PSH_PROPTITLE
Definition: prsht.h:40
APPLET_PROC AppletProc
Definition: hotplug.h:29
#define WINAPI
Definition: msvc.h:6
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
INT ResourceMessageBox(IN HINSTANCE hInstance, IN HWND hwnd, IN UINT uType, IN UINT uCaption, IN UINT uText)
Definition: sysdm.c:29
#define CPL_INIT
Definition: cpl.h:12
#define IDD_PROPPAGEGENERAL
Definition: resource.h:10
#define CPL_INQUIRE
Definition: cpl.h:14
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
LONG CALLBACK CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Definition: sysdm.c:194
static BOOL CALLBACK PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
Definition: sysdm.c:50
#define VOID
Definition: acefi.h:82
LONG_PTR lData
Definition: cpl.h:28
int idName
Definition: cpl.h:26
HPROPSHEETPAGE(WINAPI * PCreateNetIDPropertyPage)(VOID)
Definition: sysdm.c:87
#define IDI_USERPROF
Definition: resource.h:8
INT_PTR(CALLBACK * DLGPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2871
Definition: hiveinit.c:368
#define TEXT(s)
Definition: k32.h:26
#define PSCB_INITIALIZED
Definition: prsht.h:75
HICON hIcon
Definition: msconfig.c:44
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HWND hCPLWindow
Definition: sysdm.c:17
#define IDS_CPLSYSTEMDESCRIPTION
Definition: resource.h:24
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
Definition: sysdm.c:232
#define PropertySheet
Definition: prsht.h:382
INT_PTR CALLBACK HardwarePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: hardware.c:68
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define GetProcAddress(x, y)
Definition: compat.h:418
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
Definition: shellord.c:1607
#define IDD_PROPPAGEADVANCED
Definition: resource.h:18
#define NUM_APPLETS
Definition: access.c:14
LPARAM lParam
Definition: combotst.c:139
DLGPROC DlgProc
Definition: desk.c:110
INT_PTR CALLBACK AdvancedPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: advanced.c:423
#define CPL_GETCOUNT
Definition: cpl.h:13
APPLET Applets[NUM_APPLETS]
Definition: sysdm.c:20
#define ICC_LINK_CLASS
Definition: commctrl.h:74
#define PROPSHEETPAGE
Definition: prsht.h:371
#define ICON_BIG
Definition: tnclass.cpp:51
Definition: hotplug.h:24
#define IDD_PROPPAGEHARDWARE
Definition: resource.h:80
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
LONG CALLBACK SystemApplet(VOID)
Definition: sysdm.c:143