ReactOS  0.4.15-dev-494-g1d8c567
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 <regstr.h>
13 
16 
17 /* Applets */
19 {
21 };
22 
23 #define MAX_SYSTEM_PAGES 32
24 
25 
26 INT
29  IN HWND hwnd,
30  IN UINT uType,
31  IN UINT uCaption,
32  IN UINT uText)
33 {
34  WCHAR szCaption[256];
35  WCHAR szText[256];
36 
37  LoadStringW(hInstance, uCaption, szCaption, 256);
38  LoadStringW(hInstance, uText, szText, 256);
39 
40  return MessageBoxW(hwnd,
41  szText,
42  szCaption,
43  uType);
44 }
45 
46 
47 static BOOL CALLBACK
49 {
51  if (ppsh != NULL && ppsh->nPages < MAX_SYSTEM_PAGES)
52  {
53  ppsh->phpage[ppsh->nPages++] = hpage;
54  return TRUE;
55  }
56 
57  return FALSE;
58 }
59 
60 static BOOL
62 {
63  HPROPSHEETPAGE hPage;
64  PROPSHEETPAGE psp;
65 
66  if (ppsh->nPages < MAX_SYSTEM_PAGES)
67  {
68  ZeroMemory(&psp, sizeof(psp));
69  psp.dwSize = sizeof(psp);
70  psp.dwFlags = PSP_DEFAULT;
71  psp.hInstance = hApplet;
72  psp.pszTemplate = MAKEINTRESOURCE(idDlg);
73  psp.pfnDlgProc = DlgProc;
74 
75  hPage = CreatePropertySheetPage(&psp);
76  if (hPage != NULL)
77  {
78  return PropSheetAddPage(hPage, (LPARAM)ppsh);
79  }
80  }
81 
82  return FALSE;
83 }
84 
86 
87 static HMODULE
89 {
90  HPROPSHEETPAGE hPage;
91  HMODULE hMod;
92  PCreateNetIDPropertyPage pCreateNetIdPage;
93 
94  hMod = LoadLibrary(TEXT("netid.dll"));
95  if (hMod != NULL)
96  {
97  pCreateNetIdPage = (PCreateNetIDPropertyPage)GetProcAddress(hMod,
98  "CreateNetIDPropertyPage");
99  if (pCreateNetIdPage != NULL)
100  {
101  hPage = pCreateNetIdPage();
102  if (hPage == NULL)
103  goto Fail;
104 
105  if (!PropSheetAddPage(hPage, (LPARAM)ppsh))
106  {
108  goto Fail;
109  }
110  }
111  else
112  {
113 Fail:
114  FreeLibrary(hMod);
115  hMod = NULL;
116  }
117  }
118 
119  return hMod;
120 }
121 
122 static int CALLBACK
124 {
125  // NOTE: This callback is needed to set large icon correctly.
126  HICON hIcon;
127  switch (uMsg)
128  {
129  case PSCB_INITIALIZED:
130  {
132  SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
133  break;
134  }
135  }
136  return 0;
137 }
138 
139 /* First Applet */
142 {
144  PROPSHEETHEADER psh;
145  HMODULE hNetIdDll;
146  HPSXA hpsxa = NULL;
147  INT nPage = 0;
148  LONG Ret;
150 
151  if (!InitCommonControlsEx(&icc))
152  return 0;
153 
154  if (uMsg == CPL_STARTWPARMSW && lParam != 0)
155  {
156  nPage = _wtoi((PWSTR)lParam);
157  }
158 
159  ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
160  psh.dwSize = sizeof(PROPSHEETHEADER);
161  psh.dwFlags = PSH_PROPTITLE | PSH_USEICONID | PSH_USECALLBACK;
162  psh.hwndParent = hwnd;
163  psh.hInstance = hApplet;
164  psh.pszIcon = MAKEINTRESOURCEW(IDI_CPLSYSTEM);
165  psh.pszCaption = MAKEINTRESOURCE(IDS_CPLSYSTEMNAME);
166  psh.nPages = 0;
167  psh.nStartPage = 0;
168  psh.phpage = hpsp;
169  psh.pfnCallback = PropSheetProc;
170 
172  hNetIdDll = AddNetIdPage(&psh);
175 
176  /* Load additional pages provided by shell extensions */
178  if (hpsxa != NULL)
179  {
181  }
182 
183  if (nPage != 0 && nPage <= psh.nPages)
184  psh.nStartPage = nPage;
185 
186  Ret = (LONG)(PropertySheet(&psh) != -1);
187 
188  if (hpsxa != NULL)
189  {
191  }
192 
193  if (hNetIdDll != NULL)
194  FreeLibrary(hNetIdDll);
195 
196  return Ret;
197 }
198 
199 /* Control Panel Callback */
201 CPlApplet(HWND hwndCPl,
202  UINT uMsg,
203  LPARAM lParam1,
204  LPARAM lParam2)
205 {
206  INT i = (INT)lParam1;
207 
208  UNREFERENCED_PARAMETER(hwndCPl);
209 
210  switch (uMsg)
211  {
212  case CPL_INIT:
213  return TRUE;
214 
215  case CPL_GETCOUNT:
216  return NUM_APPLETS;
217 
218  case CPL_INQUIRE:
219  {
220  CPLINFO *CPlInfo = (CPLINFO*)lParam2;
221  CPlInfo->lData = 0;
222  CPlInfo->idIcon = Applets[i].idIcon;
223  CPlInfo->idName = Applets[i].idName;
224  CPlInfo->idInfo = Applets[i].idDescription;
225  }
226  break;
227 
228  case CPL_DBLCLK:
229  Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
230  break;
231 
232  case CPL_STARTWPARMSW:
233  return Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
234 
235  }
236 
237  return FALSE;
238 }
239 
240 
241 BOOL WINAPI
243  DWORD dwReason,
245 {
247 
248  switch (dwReason)
249  {
250  case DLL_PROCESS_ATTACH:
251  case DLL_THREAD_ATTACH:
252  hApplet = hinstDLL;
253  break;
254  }
255 
256  return TRUE;
257 }
void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
Definition: shellord.c:2057
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
WORD idDlg
Definition: desk.c:110
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IN
Definition: typedefs.h:39
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
Definition: cpl.h:24
#define LoadLibrary
Definition: winbase.h:3702
#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:1879
BOOL WINAPI DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage)
Definition: propsheet.c:3144
uint16_t * PWSTR
Definition: typedefs.h:55
HINSTANCE hApplet
Definition: sysdm.c:15
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
int idName
Definition: hotplug.h:36
#define REGSTR_PATH_CONTROLSFOLDER
Definition: regstr.h:76
#define INT
Definition: polytest.cpp:20
int idIcon
Definition: hotplug.h:35
#define CALLBACK
Definition: compat.h:27
int idInfo
Definition: cpl.h:27
#define ZeroMemory
Definition: winbase.h:1648
static HMODULE AddNetIdPage(PROPSHEETHEADER *ppsh)
Definition: sysdm.c:88
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
Definition: sysdm.c:123
#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
static LONG APIENTRY SystemApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
Definition: sysdm.c:141
int32_t INT
Definition: typedefs.h:57
WPARAM wParam
Definition: combotst.c:138
static IN DWORD IN LPVOID lpvReserved
int idIcon
Definition: cpl.h:25
int idDescription
Definition: hotplug.h:37
#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:61
smooth NULL
Definition: ftsmooth.c:416
#define PROPSHEETHEADER
Definition: prsht.h:392
LONG_PTR LPARAM
Definition: windef.h:208
#define CreatePropertySheetPage
Definition: prsht.h:399
#define IDS_CPLSYSTEMNAME
Definition: resource.h:23
#define PSP_DEFAULT
Definition: prsht.h:22
#define FreeLibrary(x)
Definition: compat.h:414
#define MAX_SYSTEM_PAGES
Definition: sysdm.c:23
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:38
#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:27
#define CPL_STARTWPARMSW
Definition: cpl.h:21
#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:201
static BOOL CALLBACK PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
Definition: sysdm.c:48
#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:85
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)
#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:242
#define PropertySheet
Definition: prsht.h:400
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:419
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
Definition: shellord.c:1909
#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:111
INT_PTR CALLBACK AdvancedPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: advanced.c:422
#define CPL_GETCOUNT
Definition: cpl.h:13
APPLET Applets[NUM_APPLETS]
Definition: sysdm.c:18
#define ICC_LINK_CLASS
Definition: commctrl.h:74
#define PROPSHEETPAGE
Definition: prsht.h:389
#define APIENTRY
Definition: api.h:79
#define ICON_BIG
Definition: tnclass.cpp:51
Definition: hotplug.h:33
#define IDD_PROPPAGEHARDWARE
Definition: resource.h:80
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12