ReactOS 0.4.16-dev-1339-gd8bfa93
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
30 _In_ UINT uType,
31 _In_ UINT uCaption,
32 _In_ UINT uText,
33 ...)
34{
36 WCHAR szCaption[MAX_STR_LENGTH];
37 WCHAR szText[MAX_STR_LENGTH];
38 WCHAR szCookedText[2*MAX_STR_LENGTH];
39
40 LoadStringW(hInstance, uCaption, szCaption, _countof(szCaption));
41 LoadStringW(hInstance, uText, szText, _countof(szText));
42
43 va_start(args, uText);
44 StringCchVPrintfW(szCookedText, _countof(szCookedText),
45 szText, args);
46 va_end(args);
47
48 return MessageBoxW(hwnd,
49 szCookedText,
50 szCaption,
51 uType);
52}
53
54
55static BOOL CALLBACK
57{
59 if (ppsh != NULL && ppsh->nPages < MAX_SYSTEM_PAGES)
60 {
61 ppsh->phpage[ppsh->nPages++] = hpage;
62 return TRUE;
63 }
64
65 return FALSE;
66}
67
68static BOOL
70{
71 HPROPSHEETPAGE hPage;
72 PROPSHEETPAGE psp;
73
74 if (ppsh->nPages < MAX_SYSTEM_PAGES)
75 {
76 ZeroMemory(&psp, sizeof(psp));
77 psp.dwSize = sizeof(psp);
78 psp.dwFlags = PSP_DEFAULT;
79 psp.hInstance = hApplet;
80 psp.pszTemplate = MAKEINTRESOURCE(idDlg);
81 psp.pfnDlgProc = DlgProc;
82
83 hPage = CreatePropertySheetPage(&psp);
84 if (hPage != NULL)
85 {
86 return PropSheetAddPage(hPage, (LPARAM)ppsh);
87 }
88 }
89
90 return FALSE;
91}
92
94
95static HMODULE
97{
98 HPROPSHEETPAGE hPage;
99 HMODULE hMod;
100 PCreateNetIDPropertyPage pCreateNetIdPage;
101
102 hMod = LoadLibrary(TEXT("netid.dll"));
103 if (hMod != NULL)
104 {
105 pCreateNetIdPage = (PCreateNetIDPropertyPage)GetProcAddress(hMod,
106 "CreateNetIDPropertyPage");
107 if (pCreateNetIdPage != NULL)
108 {
109 hPage = pCreateNetIdPage();
110 if (hPage == NULL)
111 goto Fail;
112
113 if (!PropSheetAddPage(hPage, (LPARAM)ppsh))
114 {
116 goto Fail;
117 }
118 }
119 else
120 {
121Fail:
122 FreeLibrary(hMod);
123 hMod = NULL;
124 }
125 }
126
127 return hMod;
128}
129
130static int CALLBACK
132{
133 // NOTE: This callback is needed to set large icon correctly.
134 HICON hIcon;
135 switch (uMsg)
136 {
137 case PSCB_INITIALIZED:
138 {
140 SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
141 break;
142 }
143 }
144 return 0;
145}
146
147/* First Applet */
150{
152 PROPSHEETHEADER psh;
153 HMODULE hNetIdDll;
154 HPSXA hpsxa = NULL;
155 INT nPage = 0;
156 LONG Ret;
158
159 if (!InitCommonControlsEx(&icc))
160 return 0;
161
162 if (uMsg == CPL_STARTWPARMSW && lParam != 0)
163 {
164 nPage = _wtoi((PWSTR)lParam);
165 }
166
167 if (nPage == -1)
168 {
170 return TRUE;
171 }
172
173 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
174 psh.dwSize = sizeof(PROPSHEETHEADER);
176 psh.hwndParent = hwnd;
177 psh.hInstance = hApplet;
178 psh.pszIcon = MAKEINTRESOURCEW(IDI_CPLSYSTEM);
179 psh.pszCaption = MAKEINTRESOURCE(IDS_CPLSYSTEMNAME);
180 psh.nPages = 0;
181 psh.nStartPage = 0;
182 psh.phpage = hpsp;
183 psh.pfnCallback = PropSheetProc;
184
186 hNetIdDll = AddNetIdPage(&psh);
189
190 /* Load additional pages provided by shell extensions */
192 if (hpsxa != NULL)
193 {
195 }
196
197 if (nPage != 0 && nPage <= psh.nPages)
198 psh.nStartPage = nPage;
199
200 Ret = (LONG)(PropertySheet(&psh) != -1);
201
202 if (hpsxa != NULL)
203 {
205 }
206
207 if (hNetIdDll != NULL)
208 FreeLibrary(hNetIdDll);
209
210 return Ret;
211}
212
213/* Control Panel Callback */
216 UINT uMsg,
217 LPARAM lParam1,
218 LPARAM lParam2)
219{
220 UINT i = (UINT)lParam1;
221
222 UNREFERENCED_PARAMETER(hwndCPl);
223
224 switch (uMsg)
225 {
226 case CPL_INIT:
227 return TRUE;
228
229 case CPL_GETCOUNT:
230 return NUM_APPLETS;
231
232 case CPL_INQUIRE:
233 if (i < NUM_APPLETS)
234 {
235 CPLINFO *CPlInfo = (CPLINFO*)lParam2;
236 CPlInfo->lData = 0;
237 CPlInfo->idIcon = Applets[i].idIcon;
238 CPlInfo->idName = Applets[i].idName;
239 CPlInfo->idInfo = Applets[i].idDescription;
240 }
241 else
242 {
243 return TRUE;
244 }
245 break;
246
247 case CPL_DBLCLK:
248 if (i < NUM_APPLETS)
249 Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
250 else
251 return TRUE;
252 break;
253
254 case CPL_STARTWPARMSW:
255 if (i < NUM_APPLETS)
256 return Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
257 break;
258 }
259
260 return FALSE;
261}
262
263
268{
270
271 switch (dwReason)
272 {
275 hApplet = hinstDLL;
276 break;
277 }
278
279 return TRUE;
280}
#define __cdecl
Definition: accygwin.h:79
#define VOID
Definition: acefi.h:82
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
INT_PTR CALLBACK GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
DWORD dwReason
Definition: misc.cpp:135
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:904
#define CPL_INQUIRE
Definition: cpl.h:14
#define CPL_DBLCLK
Definition: cpl.h:16
#define CPL_STARTWPARMSW
Definition: cpl.h:21
#define CPL_INIT
Definition: cpl.h:12
#define CPL_GETCOUNT
Definition: cpl.h:13
#define DLGPROC
Definition: maze.c:62
WORD idDlg
Definition: desk.c:121
DLGPROC DlgProc
Definition: desk.c:122
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NUM_APPLETS
Definition: access.c:14
#define IDS_CPLSYSTEMNAME
Definition: resource.h:23
#define IDS_CPLSYSTEMDESCRIPTION
Definition: resource.h:24
#define IDD_PROPPAGEGENERAL
Definition: resource.h:10
#define IDI_CPLSYSTEM
Definition: resource.h:4
INT_PTR CALLBACK AdvancedPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: advanced.c:422
#define IDD_PROPPAGEADVANCED
Definition: resource.h:18
INT_PTR CALLBACK HardwarePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: hardware.c:68
#define MAX_STR_LENGTH
Definition: precomp.h:60
#define IDD_PROPPAGEHARDWARE
Definition: resource.h:88
#define APIENTRY
Definition: api.h:79
BOOL WINAPI DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage)
Definition: propsheet.c:3155
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define CALLBACK
Definition: compat.h:35
#define DLL_THREAD_ATTACH
Definition: compat.h:132
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
Definition: string.c:1220
int Fail
Definition: ehthrow.cxx:24
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
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
#define TEXT(s)
Definition: k32.h:28
static IN DWORD IN LPVOID lpvReserved
static HICON
Definition: imagelist.c:80
HICON hIcon
Definition: msconfig.c:44
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
unsigned int UINT
Definition: ndis.h:50
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
long LONG
Definition: pedump.c:60
VOID ShowPerformanceOptions(HWND hDlg)
Definition: performance.c:137
#define PROPSHEETHEADER
Definition: prsht.h:392
#define PSH_PROPTITLE
Definition: prsht.h:40
#define CreatePropertySheetPage
Definition: prsht.h:399
#define PSH_USECALLBACK
Definition: prsht.h:48
#define PSP_DEFAULT
Definition: prsht.h:22
#define PropertySheet
Definition: prsht.h:400
#define PSH_USEICONID
Definition: prsht.h:42
#define PSCB_INITIALIZED
Definition: prsht.h:75
#define PROPSHEETPAGE
Definition: prsht.h:389
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
#define ICC_LINK_CLASS
Definition: commctrl.h:74
#define REGSTR_PATH_CONTROLSFOLDER
Definition: regstr.h:76
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define args
Definition: format.c:66
void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
Definition: shellord.c:2396
UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
Definition: shellord.c:2219
HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
Definition: shellord.c:2249
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchVPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat, va_list argList)
Definition: strsafe.h:490
Definition: hotplug.h:34
int idDescription
Definition: hotplug.h:37
int idName
Definition: hotplug.h:36
int idIcon
Definition: hotplug.h:35
APPLET_PROC AppletProc
Definition: hotplug.h:38
Definition: match.c:390
Definition: cpl.h:24
LONG_PTR lData
Definition: cpl.h:28
int idName
Definition: cpl.h:26
int idInfo
Definition: cpl.h:27
int idIcon
Definition: cpl.h:25
static BOOL InitPropSheetPage(PROPSHEETHEADER *ppsh, WORD idDlg, DLGPROC DlgProc)
Definition: sysdm.c:69
static BOOL CALLBACK PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
Definition: sysdm.c:56
INT __cdecl ResourceMessageBox(_In_opt_ HINSTANCE hInstance, _In_opt_ HWND hwnd, _In_ UINT uType, _In_ UINT uCaption, _In_ UINT uText,...)
Definition: sysdm.c:27
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
Definition: sysdm.c:131
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
Definition: sysdm.c:265
HPROPSHEETPAGE(WINAPI * PCreateNetIDPropertyPage)(VOID)
Definition: sysdm.c:93
static LONG APIENTRY SystemApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
Definition: sysdm.c:149
static HMODULE AddNetIdPage(PROPSHEETHEADER *ppsh)
Definition: sysdm.c:96
#define MAX_SYSTEM_PAGES
Definition: sysdm.c:23
APPLET Applets[NUM_APPLETS]
Definition: sysdm.c:18
HINSTANCE hApplet
Definition: sysdm.c:15
#define ICON_BIG
Definition: tnclass.cpp:51
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
#define ZeroMemory
Definition: winbase.h:1753
#define LoadLibrary
Definition: winbase.h:3903
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
#define WINAPI
Definition: msvc.h:6
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2412
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180