ReactOS 0.4.15-dev-7931-gfd331f1
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 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
168 psh.dwSize = sizeof(PROPSHEETHEADER);
170 psh.hwndParent = hwnd;
171 psh.hInstance = hApplet;
172 psh.pszIcon = MAKEINTRESOURCEW(IDI_CPLSYSTEM);
173 psh.pszCaption = MAKEINTRESOURCE(IDS_CPLSYSTEMNAME);
174 psh.nPages = 0;
175 psh.nStartPage = 0;
176 psh.phpage = hpsp;
177 psh.pfnCallback = PropSheetProc;
178
180 hNetIdDll = AddNetIdPage(&psh);
183
184 /* Load additional pages provided by shell extensions */
186 if (hpsxa != NULL)
187 {
189 }
190
191 if (nPage != 0 && nPage <= psh.nPages)
192 psh.nStartPage = nPage;
193
194 Ret = (LONG)(PropertySheet(&psh) != -1);
195
196 if (hpsxa != NULL)
197 {
199 }
200
201 if (hNetIdDll != NULL)
202 FreeLibrary(hNetIdDll);
203
204 return Ret;
205}
206
207/* Control Panel Callback */
210 UINT uMsg,
211 LPARAM lParam1,
212 LPARAM lParam2)
213{
214 UINT i = (UINT)lParam1;
215
216 UNREFERENCED_PARAMETER(hwndCPl);
217
218 switch (uMsg)
219 {
220 case CPL_INIT:
221 return TRUE;
222
223 case CPL_GETCOUNT:
224 return NUM_APPLETS;
225
226 case CPL_INQUIRE:
227 if (i < NUM_APPLETS)
228 {
229 CPLINFO *CPlInfo = (CPLINFO*)lParam2;
230 CPlInfo->lData = 0;
231 CPlInfo->idIcon = Applets[i].idIcon;
232 CPlInfo->idName = Applets[i].idName;
233 CPlInfo->idInfo = Applets[i].idDescription;
234 }
235 else
236 {
237 return TRUE;
238 }
239 break;
240
241 case CPL_DBLCLK:
242 if (i < NUM_APPLETS)
243 Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
244 else
245 return TRUE;
246 break;
247
248 case CPL_STARTWPARMSW:
249 if (i < NUM_APPLETS)
250 return Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
251 break;
252 }
253
254 return FALSE;
255}
256
257
262{
264
265 switch (dwReason)
266 {
269 hApplet = hinstDLL;
270 break;
271 }
272
273 return TRUE;
274}
#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:154
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:893
#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:58
#define IDD_PROPPAGEHARDWARE
Definition: resource.h:86
#define APIENTRY
Definition: api.h:79
BOOL WINAPI DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage)
Definition: propsheet.c:3152
#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 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
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define TEXT(s)
Definition: k32.h:26
static IN DWORD IN LPVOID lpvReserved
static HICON
Definition: imagelist.c:84
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
HICON hIcon
Definition: msconfig.c:44
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
unsigned int UINT
Definition: ndis.h:50
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
long LONG
Definition: pedump.c:60
#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
#define args
Definition: format.c:66
void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
Definition: shellord.c:2190
UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
Definition: shellord.c:2013
HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
Definition: shellord.c:2043
#define _countof(array)
Definition: sndvol32.h:68
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:259
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:1712
#define LoadLibrary
Definition: winbase.h:3862
_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 LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
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
#define MAKEINTRESOURCE
Definition: winuser.h:591
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2075
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180