ReactOS  0.4.15-dev-1638-gc0caa5c
intl.c File Reference
#include "intl.h"
#include <debug.h>
Include dependency graph for intl.c:

Go to the source code of this file.

Macros

#define NUM_APPLETS   (1)
 
#define BUFFERSIZE   512
 

Functions

static LONG APIENTRY Applet (HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
 
VOID PrintErrorMsgBox (UINT msg)
 
INT ResourceMessageBox (HWND hwnd, UINT uType, UINT uCaptionId, UINT uMessageId)
 
static VOID InitIntlPropSheetPage (PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, LPARAM lParam)
 
BOOL OpenSetupInf (VOID)
 
VOID ParseSetupInf (VOID)
 
static int CALLBACK PropSheetProc (HWND hwndDlg, UINT uMsg, LPARAM lParam)
 
LONG APIENTRY CPlApplet (HWND hwndCpl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
 
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved)
 

Variables

HINSTANCE hApplet = 0
 
HINF hSetupInf = INVALID_HANDLE_VALUE
 
DWORD IsUnattendedSetupEnabled = 0
 
DWORD UnattendLCID = 0
 
APPLET Applets [NUM_APPLETS]
 

Macro Definition Documentation

◆ BUFFERSIZE

#define BUFFERSIZE   512

Definition at line 32 of file intl.c.

◆ NUM_APPLETS

#define NUM_APPLETS   (1)

Definition at line 30 of file intl.c.

Function Documentation

◆ Applet()

static LONG APIENTRY Applet ( HWND  hwnd,
UINT  uMsg,
LPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 169 of file intl.c.

170 {
171  TCHAR Caption[BUFFERSIZE];
172  PROPSHEETPAGE psp[3];
173  PROPSHEETHEADER psh;
174  PGLOBALDATA pGlobalData;
175  INT nPage = 0;
176  LONG ret;
177 
178  if (OpenSetupInf())
179  {
180  ParseSetupInf();
181  }
182 
183  if (uMsg == CPL_STARTWPARMSW && lParam != 0)
184  nPage = _wtoi((PWSTR)lParam);
185 
186  pGlobalData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLOBALDATA));
187  if (pGlobalData == NULL)
188  return FALSE;
189 
190  pGlobalData->SystemLCID = GetSystemDefaultLCID();
191  pGlobalData->bIsUserAdmin = IsUserAdmin();
192 
193  LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
194 
195  ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
196  psh.dwSize = sizeof(PROPSHEETHEADER);
198  psh.hwndParent = hwnd;
199  psh.hInstance = hApplet;
200  psh.pszIcon = MAKEINTRESOURCEW(IDC_CPLICON);
201  psh.pszCaption = Caption;
202  psh.nPages = 0;
203  psh.nStartPage = 0;
204  psh.ppsp = psp;
205  psh.pfnCallback = PropSheetProc;
206 
208  psh.nPages++;
210  psh.nPages++;
211 
212  if (pGlobalData->bIsUserAdmin)
213  {
215  psh.nPages++;
216  }
217 
218  if (nPage != 0 && nPage <= psh.nPages)
219  psh.nStartPage = nPage;
220 
221  ret = (LONG)(PropertySheet(&psh) != -1);
222  if (ret > 0)
224 
225  HeapFree(GetProcessHeap(), 0, pGlobalData);
226 
227  return ret;
228 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL OpenSetupInf(VOID)
Definition: intl.c:91
BOOL bIsUserAdmin
Definition: intl.h:122
uint16_t * PWSTR
Definition: typedefs.h:56
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
HINSTANCE hApplet
Definition: intl.c:38
#define IDD_ADVANCEDPAGE
Definition: resource.h:13
#define ZeroMemory
Definition: winbase.h:1648
#define PSH_USECALLBACK
Definition: prsht.h:48
#define IDC_CPLICON
Definition: resource.h:7
int32_t INT
Definition: typedefs.h:58
#define WM_SETTINGCHANGE
Definition: winuser.h:1611
#define IDS_CPLNAME
Definition: resource.h:8
#define PSH_USEICONID
Definition: prsht.h:42
#define FALSE
Definition: types.h:117
INT_PTR CALLBACK GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
long LONG
Definition: pedump.c:60
static BOOL IsUserAdmin(VOID)
Definition: netid.c:163
#define PROPSHEETHEADER
Definition: prsht.h:392
LONG_PTR LPARAM
Definition: windef.h:208
LCID WINAPI GetSystemDefaultLCID(void)
Definition: lang.c:787
char TCHAR
Definition: xmlstorage.h:189
INT_PTR CALLBACK LanguagesPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: languages.c:7
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LCID SystemLCID
Definition: intl.h:114
VOID ParseSetupInf(VOID)
Definition: intl.c:123
#define CPL_STARTWPARMSW
Definition: cpl.h:21
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define IDD_LANGUAGESPAGE
Definition: resource.h:12
static VOID InitIntlPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, LPARAM lParam)
Definition: intl.c:79
#define IDD_GENERALPAGE
Definition: resource.h:9
#define PSH_PROPSHEETPAGE
Definition: prsht.h:43
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define PropertySheet
Definition: prsht.h:400
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
Definition: intl.c:152
#define BUFFERSIZE
Definition: intl.c:32
#define HWND_BROADCAST
Definition: winuser.h:1190
LPARAM lParam
Definition: combotst.c:139
#define HeapFree(x, y, z)
Definition: compat.h:594
INT_PTR CALLBACK AdvancedPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: advanced.c:422
#define LoadString
Definition: winuser.h:5794
#define PROPSHEETPAGE
Definition: prsht.h:389

◆ CPlApplet()

LONG APIENTRY CPlApplet ( HWND  hwndCpl,
UINT  uMsg,
LPARAM  lParam1,
LPARAM  lParam2 
)

Definition at line 233 of file intl.c.

237 {
238  switch (uMsg)
239  {
240  case CPL_INIT:
241  return TRUE;
242 
243  case CPL_GETCOUNT:
244  return NUM_APPLETS;
245 
246  case CPL_INQUIRE:
247  {
248  CPLINFO *CPlInfo = (CPLINFO*)lParam2;
249  UINT uAppIndex = (UINT)lParam1;
250 
251  CPlInfo->lData = 0;
252  CPlInfo->idIcon = Applets[uAppIndex].idIcon;
253  CPlInfo->idName = Applets[uAppIndex].idName;
254  CPlInfo->idInfo = Applets[uAppIndex].idDescription;
255  break;
256  }
257 
258  case CPL_DBLCLK:
259  Applets[(UINT)lParam1].AppletProc(hwndCpl, uMsg, lParam1, lParam2);
260  break;
261 
262  case CPL_STARTWPARMSW:
263  return Applets[(UINT)lParam1].AppletProc(hwndCpl, uMsg, lParam1, lParam2);
264  }
265 
266  return FALSE;
267 }
Definition: cpl.h:24
#define TRUE
Definition: types.h:120
int idName
Definition: hotplug.h:36
int idIcon
Definition: hotplug.h:35
int idInfo
Definition: cpl.h:27
int idIcon
Definition: cpl.h:25
int idDescription
Definition: hotplug.h:37
#define CPL_DBLCLK
Definition: cpl.h:16
#define NUM_APPLETS
Definition: intl.c:30
#define FALSE
Definition: types.h:117
APPLET Applets[NUM_APPLETS]
Definition: intl.c:45
#define CPL_STARTWPARMSW
Definition: cpl.h:21
#define CPL_INIT
Definition: cpl.h:12
#define CPL_INQUIRE
Definition: cpl.h:14
LONG_PTR lData
Definition: cpl.h:28
int idName
Definition: cpl.h:26
unsigned int UINT
Definition: ndis.h:50
#define CPL_GETCOUNT
Definition: cpl.h:13

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinstDLL,
DWORD  dwReason,
LPVOID  lpReserved 
)

Definition at line 271 of file intl.c.

274 {
275  switch(dwReason)
276  {
277  case DLL_PROCESS_ATTACH:
278  case DLL_THREAD_ATTACH:
279  hApplet = hinstDLL;
280  break;
281  }
282 
283  return TRUE;
284 }
#define TRUE
Definition: types.h:120
#define DLL_THREAD_ATTACH
Definition: compat.h:132
HINSTANCE hApplet
Definition: intl.c:38
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
DWORD dwReason
Definition: misc.cpp:154

◆ InitIntlPropSheetPage()

static VOID InitIntlPropSheetPage ( PROPSHEETPAGE psp,
WORD  idDlg,
DLGPROC  DlgProc,
LPARAM  lParam 
)
static

Definition at line 79 of file intl.c.

80 {
81  ZeroMemory(psp, sizeof(PROPSHEETPAGE));
82  psp->dwSize = sizeof(PROPSHEETPAGE);
83  psp->dwFlags = PSP_DEFAULT;
84  psp->hInstance = hApplet;
85  psp->pszTemplate = MAKEINTRESOURCE(idDlg);
86  psp->pfnDlgProc = DlgProc;
87  psp->lParam = lParam;
88 }
WORD idDlg
Definition: desk.c:110
#define MAKEINTRESOURCE
Definition: winuser.h:591
HINSTANCE hApplet
Definition: intl.c:38
#define ZeroMemory
Definition: winbase.h:1648
#define PSP_DEFAULT
Definition: prsht.h:22
LPARAM lParam
Definition: combotst.c:139
DLGPROC DlgProc
Definition: desk.c:111
#define PROPSHEETPAGE
Definition: prsht.h:389

Referenced by Applet().

◆ OpenSetupInf()

BOOL OpenSetupInf ( VOID  )

Definition at line 91 of file intl.c.

92 {
93  PWSTR lpCmdLine;
94  PWSTR lpSwitch;
95  size_t len;
96 
97  lpCmdLine = GetCommandLineW();
98 
99  lpSwitch = wcsstr(lpCmdLine, L"/f:\"");
100  if (!lpSwitch)
101  return FALSE;
102 
103  len = wcslen(lpSwitch);
104  if (len < 5 || lpSwitch[len-1] != L'\"')
105  {
106  DPRINT1("Invalid switch: %ls\n", lpSwitch);
107  return FALSE;
108  }
109 
110  lpSwitch[len-1] = L'\0';
111 
114  {
115  DPRINT1("Failed to open INF file: %ls\n", &lpSwitch[4]);
116  return FALSE;
117  }
118 
119  return TRUE;
120 }
HINF hSetupInf
Definition: intl.c:39
#define TRUE
Definition: types.h:120
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
uint16_t * PWSTR
Definition: typedefs.h:56
#define INF_STYLE_OLDNT
Definition: infsupp.h:37
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
#define FALSE
Definition: types.h:117
LPWSTR WINAPI GetCommandLineW(VOID)
Definition: proc.c:2014
static const WCHAR L[]
Definition: oid.c:1250
GLenum GLsizei len
Definition: glext.h:6722
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by Applet().

◆ ParseSetupInf()

VOID ParseSetupInf ( VOID  )

Definition at line 123 of file intl.c.

124 {
125  INFCONTEXT InfContext;
126  WCHAR szBuffer[30];
127 
129  L"Unattend",
130  L"LocaleID",
131  &InfContext))
132  {
134  DPRINT1("SetupFindFirstLine failed\n");
135  return;
136  }
137 
138  if (!SetupGetStringFieldW(&InfContext, 1, szBuffer,
139  sizeof(szBuffer) / sizeof(WCHAR), NULL))
140  {
142  DPRINT1("SetupGetStringField failed\n");
143  return;
144  }
145 
146  UnattendLCID = wcstoul(szBuffer, NULL, 16);
149 }
DWORD IsUnattendedSetupEnabled
Definition: intl.c:40
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:54
HINF hSetupInf
Definition: intl.c:39
DWORD UnattendLCID
Definition: intl.c:41
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:43
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:184

Referenced by Applet().

◆ PrintErrorMsgBox()

VOID PrintErrorMsgBox ( UINT  msg)

Definition at line 51 of file intl.c.

52 {
53  WCHAR szErrorText[BUFFERSIZE];
54  WCHAR szErrorCaption[BUFFERSIZE];
55 
56  LoadStringW(hApplet, msg, szErrorText, sizeof(szErrorText) / sizeof(WCHAR));
57  LoadStringW(hApplet, IDS_ERROR, szErrorCaption, sizeof(szErrorCaption) / sizeof(WCHAR));
58 
59  MessageBoxW(NULL, szErrorText, szErrorCaption, MB_OK | MB_ICONERROR);
60 }
HINSTANCE hApplet
Definition: intl.c:38
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, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MB_ICONERROR
Definition: winuser.h:781
#define NULL
Definition: types.h:112
#define MB_OK
Definition: winuser.h:784
#define msg(x)
Definition: auth_time.c:54
#define IDS_ERROR
Definition: resource.h:18
#define BUFFERSIZE
Definition: intl.c:32

Referenced by LanguagesPageProc(), LoadCurrentLocale(), SaveCurrentLocale(), SaveFontSubstitutionSettings(), SaveGeoID(), SaveSystemSettings(), SetLongDateFormat(), SetShortDateFormat(), and SetShortDateSep().

◆ PropSheetProc()

static int CALLBACK PropSheetProc ( HWND  hwndDlg,
UINT  uMsg,
LPARAM  lParam 
)
static

Definition at line 152 of file intl.c.

153 {
154  // NOTE: This callback is needed to set large icon correctly.
155  HICON hIcon;
156  switch (uMsg)
157  {
158  case PSCB_INITIALIZED:
159  {
161  SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
162  break;
163  }
164  }
165  return 0;
166 }
static HICON
Definition: imagelist.c:84
HINSTANCE hApplet
Definition: intl.c:38
#define IDC_CPLICON
Definition: resource.h:7
LONG_PTR LPARAM
Definition: windef.h:208
#define PSCB_INITIALIZED
Definition: prsht.h:75
HICON hIcon
Definition: msconfig.c:44
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define ICON_BIG
Definition: tnclass.cpp:51

Referenced by Applet().

◆ ResourceMessageBox()

INT ResourceMessageBox ( HWND  hwnd,
UINT  uType,
UINT  uCaptionId,
UINT  uMessageId 
)

Definition at line 63 of file intl.c.

68 {
69  WCHAR szErrorText[BUFFERSIZE];
70  WCHAR szErrorCaption[BUFFERSIZE];
71 
72  LoadStringW(hApplet, uMessageId, szErrorText, sizeof(szErrorText) / sizeof(WCHAR));
73  LoadStringW(hApplet, uCaptionId, szErrorCaption, sizeof(szErrorCaption) / sizeof(WCHAR));
74 
75  return MessageBoxW(hwnd, szErrorText, szErrorCaption, uType);
76 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HINSTANCE hApplet
Definition: intl.c:38
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, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define BUFFERSIZE
Definition: intl.c:32

Variable Documentation

◆ Applets

APPLET Applets[NUM_APPLETS]
Initial value:
=
{
}
#define IDC_CPLICON
Definition: resource.h:7
#define IDS_CPLNAME
Definition: resource.h:8
#define IDS_CPLDESCRIPTION
Definition: resource.h:9
static LONG APIENTRY Applet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
Definition: intl.c:169

Definition at line 45 of file intl.c.

Referenced by CPlApplet().

◆ hApplet

HINSTANCE hApplet = 0

◆ hSetupInf

Definition at line 39 of file intl.c.

Referenced by DeviceInstallThread(), OpenSetupInf(), and ParseSetupInf().

◆ IsUnattendedSetupEnabled

DWORD IsUnattendedSetupEnabled = 0

Definition at line 40 of file intl.c.

Referenced by GeneralPageProc(), and ParseSetupInf().

◆ UnattendLCID

DWORD UnattendLCID = 0

Definition at line 41 of file intl.c.

Referenced by GeneralPageProc(), ParseSetupInf(), and VerifyUnattendLCID().