ReactOS  0.4.14-dev-315-gbb6fece
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
 
HWND hCPLWindow
 
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 170 of file intl.c.

171 {
172  TCHAR Caption[BUFFERSIZE];
173  PROPSHEETPAGE psp[3];
174  PROPSHEETHEADER psh;
175  PGLOBALDATA pGlobalData;
176  LONG ret;
177 
178  if (OpenSetupInf())
179  {
180  ParseSetupInf();
181  }
182 
183  pGlobalData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLOBALDATA));
184  if (pGlobalData == NULL)
185  return FALSE;
186 
187  pGlobalData->SystemLCID = GetSystemDefaultLCID();
188  pGlobalData->bIsUserAdmin = IsUserAdmin();
189 
190  LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
191 
192  ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
193  psh.dwSize = sizeof(PROPSHEETHEADER);
195  psh.hwndParent = hCPLWindow;
196  psh.hInstance = hApplet;
197  psh.pszIcon = MAKEINTRESOURCEW(IDC_CPLICON);
198  psh.pszCaption = Caption;
199  psh.nPages = 0; //sizeof(psp) / sizeof(PROPSHEETPAGE);
200  psh.nStartPage = 0;
201  psh.ppsp = psp;
202  psh.pfnCallback = PropSheetProc;
203 
205  psh.nPages++;
207  psh.nPages++;
208 
209  if (pGlobalData->bIsUserAdmin)
210  {
212  psh.nPages++;
213  }
214 
215  ret = (LONG)(PropertySheet(&psh) != -1);
216 
217  HeapFree(GetProcessHeap(), 0, pGlobalData);
218 
219  return ret;
220 }
BOOL OpenSetupInf(VOID)
Definition: intl.c:92
BOOL bIsUserAdmin
Definition: intl.h:122
BOOL WINAPI IsUserAdmin(VOID)
HINSTANCE hApplet
Definition: intl.c:38
#define IDD_ADVANCEDPAGE
Definition: resource.h:13
#define ZeroMemory
Definition: winbase.h:1642
#define PSH_USECALLBACK
Definition: prsht.h:48
#define IDC_CPLICON
Definition: resource.h:7
#define IDS_CPLNAME
Definition: resource.h:8
#define PSH_USEICONID
Definition: prsht.h:42
INT_PTR CALLBACK GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define PROPSHEETHEADER
Definition: prsht.h:374
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:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LCID SystemLCID
Definition: intl.h:114
VOID ParseSetupInf(VOID)
Definition: intl.c:124
int ret
#define IDD_LANGUAGESPAGE
Definition: resource.h:12
static VOID InitIntlPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, LPARAM lParam)
Definition: intl.c:80
#define IDD_GENERALPAGE
Definition: resource.h:9
#define PSH_PROPSHEETPAGE
Definition: prsht.h:43
HWND hCPLWindow
Definition: intl.c:39
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define PropertySheet
Definition: prsht.h:382
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
Definition: intl.c:153
#define BUFFERSIZE
Definition: intl.c:32
#define HeapFree(x, y, z)
Definition: compat.h:394
INT_PTR CALLBACK AdvancedPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: advanced.c:423
#define LoadString
Definition: winuser.h:5720
#define PROPSHEETPAGE
Definition: prsht.h:371

◆ CPlApplet()

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

Definition at line 225 of file intl.c.

229 {
230  switch(uMsg)
231  {
232  case CPL_INIT:
233  return TRUE;
234 
235  case CPL_GETCOUNT:
236  return NUM_APPLETS;
237 
238  case CPL_INQUIRE:
239  {
240  CPLINFO *CPlInfo = (CPLINFO*)lParam2;
241  UINT uAppIndex = (UINT)lParam1;
242 
243  CPlInfo->lData = 0;
244  CPlInfo->idIcon = Applets[uAppIndex].idIcon;
245  CPlInfo->idName = Applets[uAppIndex].idName;
246  CPlInfo->idInfo = Applets[uAppIndex].idDescription;
247  break;
248  }
249 
250  case CPL_DBLCLK:
251  {
252  UINT uAppIndex = (UINT)lParam1;
253  hCPLWindow = hwndCpl;
254  Applets[uAppIndex].AppletProc(hwndCpl, uMsg, lParam1, lParam2);
255  break;
256  }
257  }
258 
259  return FALSE;
260 }
#define TRUE
Definition: types.h:120
Definition: cpl.h:24
int idName
Definition: hotplug.h:27
int idIcon
Definition: hotplug.h:26
int idInfo
Definition: cpl.h:27
int idIcon
Definition: cpl.h:25
int idDescription
Definition: hotplug.h:28
#define CPL_DBLCLK
Definition: cpl.h:16
#define NUM_APPLETS
Definition: intl.c:30
APPLET_PROC AppletProc
Definition: hotplug.h:29
APPLET Applets[NUM_APPLETS]
Definition: intl.c:46
#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
HWND hCPLWindow
Definition: intl.c:39
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 264 of file intl.c.

267 {
268  switch(dwReason)
269  {
270  case DLL_PROCESS_ATTACH:
271  case DLL_THREAD_ATTACH:
272  hApplet = hinstDLL;
273  break;
274  }
275 
276  return TRUE;
277 }
#define TRUE
Definition: types.h:120
#define DLL_THREAD_ATTACH
Definition: compat.h:121
HINSTANCE hApplet
Definition: intl.c:38
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
DWORD dwReason
Definition: misc.cpp:154

◆ InitIntlPropSheetPage()

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

Definition at line 80 of file intl.c.

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

Referenced by Applet().

◆ OpenSetupInf()

BOOL OpenSetupInf ( VOID  )

Definition at line 92 of file intl.c.

93 {
94  PWSTR lpCmdLine;
95  PWSTR lpSwitch;
96  size_t len;
97 
98  lpCmdLine = GetCommandLineW();
99 
100  lpSwitch = wcsstr(lpCmdLine, L"/f:\"");
101  if (!lpSwitch)
102  return FALSE;
103 
104  len = wcslen(lpSwitch);
105  if (len < 5 || lpSwitch[len-1] != L'\"')
106  {
107  DPRINT1("Invalid switch: %ls\n", lpSwitch);
108  return FALSE;
109  }
110 
111  lpSwitch[len-1] = L'\0';
112 
115  {
116  DPRINT1("Failed to open INF file: %ls\n", &lpSwitch[4]);
117  return FALSE;
118  }
119 
120  return TRUE;
121 }
HINF hSetupInf
Definition: intl.c:40
#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:54
#define INF_STYLE_OLDNT
Definition: infsupp.h:37
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
LPWSTR WINAPI GetCommandLineW(VOID)
Definition: proc.c:2013
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR L[]
Definition: oid.c:1250
GLenum GLsizei len
Definition: glext.h:6722
#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 124 of file intl.c.

125 {
126  INFCONTEXT InfContext;
127  WCHAR szBuffer[30];
128 
130  L"Unattend",
131  L"LocaleID",
132  &InfContext))
133  {
135  DPRINT1("SetupFindFirstLine failed\n");
136  return;
137  }
138 
139  if (!SetupGetStringFieldW(&InfContext, 1, szBuffer,
140  sizeof(szBuffer) / sizeof(WCHAR), NULL))
141  {
143  DPRINT1("SetupGetStringField failed\n");
144  return;
145  }
146 
147  UnattendLCID = wcstoul(szBuffer, NULL, 16);
150 }
DWORD IsUnattendedSetupEnabled
Definition: intl.c:41
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:40
DWORD UnattendLCID
Definition: intl.c:42
_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
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
#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 52 of file intl.c.

53 {
54  WCHAR szErrorText[BUFFERSIZE];
55  WCHAR szErrorCaption[BUFFERSIZE];
56 
57  LoadStringW(hApplet, msg, szErrorText, sizeof(szErrorText) / sizeof(WCHAR));
58  LoadStringW(hApplet, IDS_ERROR, szErrorCaption, sizeof(szErrorCaption) / sizeof(WCHAR));
59 
60  MessageBoxW(NULL, szErrorText, szErrorCaption, MB_OK | MB_ICONERROR);
61 }
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)
smooth NULL
Definition: ftsmooth.c:416
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 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(), SaveGeoID(), SaveSystemSettings(), SetLongDateFormat(), SetShortDateFormat(), and SetShortDateSep().

◆ PropSheetProc()

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

Definition at line 153 of file intl.c.

154 {
155  // NOTE: This callback is needed to set large icon correctly.
156  HICON hIcon;
157  switch (uMsg)
158  {
159  case PSCB_INITIALIZED:
160  {
162  SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
163  break;
164  }
165  }
166  return 0;
167 }
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 64 of file intl.c.

69 {
70  WCHAR szErrorText[BUFFERSIZE];
71  WCHAR szErrorCaption[BUFFERSIZE];
72 
73  LoadStringW(hApplet, uMessageId, szErrorText, sizeof(szErrorText) / sizeof(WCHAR));
74  LoadStringW(hApplet, uCaptionId, szErrorCaption, sizeof(szErrorCaption) / sizeof(WCHAR));
75 
76  return MessageBoxW(hwnd, szErrorText, szErrorCaption, uType);
77 }
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:170

Definition at line 46 of file intl.c.

Referenced by CPlApplet().

◆ hApplet

HINSTANCE hApplet = 0

◆ hCPLWindow

HWND hCPLWindow

Definition at line 39 of file intl.c.

Referenced by Applet(), and CPlApplet().

◆ hSetupInf

Definition at line 40 of file intl.c.

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

◆ IsUnattendedSetupEnabled

DWORD IsUnattendedSetupEnabled = 0

Definition at line 41 of file intl.c.

Referenced by GeneralPageProc(), and ParseSetupInf().

◆ UnattendLCID

DWORD UnattendLCID = 0

Definition at line 42 of file intl.c.

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