- Set flag unicode="yes"

- Use WCHARs instead of TCHAR

svn path=/trunk/; revision=37589
This commit is contained in:
Dmitry Chapyshev 2008-11-23 14:16:46 +00:00
parent 4398dce305
commit cee7f49628
2 changed files with 57 additions and 57 deletions

View file

@ -28,7 +28,7 @@
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <tchar.h> #include <wchar.h>
#include <setupapi.h> #include <setupapi.h>
#include <initguid.h> #include <initguid.h>
#include <devguid.h> #include <devguid.h>
@ -42,23 +42,23 @@ HFONT hTitleFont;
typedef struct _LANG typedef struct _LANG
{ {
TCHAR LangId[9]; WCHAR LangId[9];
TCHAR LangName[128]; WCHAR LangName[128];
} LANG, *PLANG; } LANG, *PLANG;
typedef struct _KBLAYOUT typedef struct _KBLAYOUT
{ {
TCHAR LayoutId[9]; WCHAR LayoutId[9];
TCHAR LayoutName[128]; WCHAR LayoutName[128];
TCHAR DllName[128]; WCHAR DllName[128];
} KBLAYOUT, *PKBLAYOUT; } KBLAYOUT, *PKBLAYOUT;
// generic entries with simple 1:1 mapping // generic entries with simple 1:1 mapping
typedef struct _GENENTRY typedef struct _GENENTRY
{ {
TCHAR Id[24]; WCHAR Id[24];
TCHAR Value[128]; WCHAR Value[128];
} GENENTRY, *PGENENTRY; } GENENTRY, *PGENENTRY;
struct struct
@ -72,7 +72,7 @@ struct
LONG FormatPart; // type of format the partition LONG FormatPart; // type of format the partition
LONG SelectedLangId; // selected language (table index) LONG SelectedLangId; // selected language (table index)
LONG SelectedKBLayout; // selected keyboard layout (table index) LONG SelectedKBLayout; // selected keyboard layout (table index)
TCHAR InstallDir[MAX_PATH]; // installation directory on hdd WCHAR InstallDir[MAX_PATH]; // installation directory on hdd
LONG SelectedComputer; // selected computer type (table index) LONG SelectedComputer; // selected computer type (table index)
LONG SelectedDisplay; // selected display type (table index) LONG SelectedDisplay; // selected display type (table index)
LONG SelectedKeyboard; // selected keyboard type (table index) LONG SelectedKeyboard; // selected keyboard type (table index)
@ -99,7 +99,7 @@ typedef struct _IMGINFO
INT cySource; INT cySource;
} IMGINFO, *PIMGINFO; } IMGINFO, *PIMGINFO;
TCHAR abort_msg[512], abort_title[64]; WCHAR abort_msg[512], abort_title[64];
HINSTANCE hInstance; HINSTANCE hInstance;
BOOL isUnattend; BOOL isUnattend;
@ -142,7 +142,7 @@ CreateTitleFont(VOID)
LogFont = ncm.lfMessageFont; LogFont = ncm.lfMessageFont;
LogFont.lfWeight = FW_BOLD; LogFont.lfWeight = FW_BOLD;
_tcscpy(LogFont.lfFaceName, _T("MS Shell Dlg")); wcscpy(LogFont.lfFaceName, L"MS Shell Dlg");
hdc = GetDC(NULL); hdc = GetDC(NULL);
FontSize = 12; FontSize = 12;
@ -359,20 +359,20 @@ LangSelDlgProc(HWND hwndDlg,
case PSN_WIZNEXT: // set the selected data case PSN_WIZNEXT: // set the selected data
{ {
hList =GetDlgItem(hwndDlg, IDC_LANGUAGES); hList = GetDlgItem(hwndDlg, IDC_LANGUAGES);
tindex = SendMessage(hList,CB_GETCURSEL, (WPARAM)0, (LPARAM)0); tindex = SendMessage(hList, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
if (tindex != CB_ERR) if (tindex != CB_ERR)
{ {
SetupData.SelectedLangId = SendMessage(hList, CB_GETITEMDATA, (WPARAM) tindex, (LPARAM) 0); SetupData.SelectedLangId = SendMessage(hList, CB_GETITEMDATA, (WPARAM) tindex, (LPARAM) 0);
WORD LangID = strtol(SetupData.pLanguages[SetupData.SelectedLangId].LangId, NULL, 16); WORD LangID = wcstol(SetupData.pLanguages[SetupData.SelectedLangId].LangId, NULL, 16);
SetThreadLocale(MAKELCID(LangID, SORT_DEFAULT)); SetThreadLocale(MAKELCID(LangID, SORT_DEFAULT));
// FIXME: need to reload all resource to force // FIXME: need to reload all resource to force
// the new language setting // the new language setting
} }
hList = GetDlgItem(hwndDlg, IDC_KEYLAYOUT); hList = GetDlgItem(hwndDlg, IDC_KEYLAYOUT);
tindex = SendMessage(hList,CB_GETCURSEL, (WPARAM)0, (LPARAM)0); tindex = SendMessage(hList, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
if (tindex != CB_ERR) if (tindex != CB_ERR)
{ {
SetupData.SelectedKBLayout = SendMessage(hList, CB_GETITEMDATA, (WPARAM) tindex, (LPARAM) 0); SetupData.SelectedKBLayout = SendMessage(hList, CB_GETITEMDATA, (WPARAM) tindex, (LPARAM) 0);
@ -614,7 +614,7 @@ MoreOptDlgProc(HWND hwndDlg,
{ {
SendMessage(GetDlgItem(hwndDlg, IDC_PATH), SendMessage(GetDlgItem(hwndDlg, IDC_PATH),
WM_GETTEXT, WM_GETTEXT,
(WPARAM) sizeof(SetupData.InstallDir) / sizeof(TCHAR), (WPARAM) sizeof(SetupData.InstallDir) / sizeof(WCHAR),
(LPARAM) SetupData.InstallDir); (LPARAM) SetupData.InstallDir);
EndDialog(hwndDlg, IDOK); EndDialog(hwndDlg, IDOK);
@ -976,11 +976,11 @@ RestartDlgProc(HWND hwndDlg,
void LoadSetupData() void LoadSetupData()
{ {
WCHAR szPath[MAX_PATH]; WCHAR szPath[MAX_PATH];
TCHAR tmp[10]; WCHAR tmp[10];
WCHAR *ch; WCHAR *ch;
HINF hTxtsetupSif; HINF hTxtsetupSif;
INFCONTEXT InfContext; INFCONTEXT InfContext;
//TCHAR szValue[MAX_PATH]; //WCHAR szValue[MAX_PATH];
DWORD LineLength; DWORD LineLength;
LONG Count; LONG Count;
@ -994,7 +994,7 @@ void LoadSetupData()
if (hTxtsetupSif != INVALID_HANDLE_VALUE) if (hTxtsetupSif != INVALID_HANDLE_VALUE)
{ {
// get language list // get language list
Count = SetupGetLineCount(hTxtsetupSif, _T("Language")); Count = SetupGetLineCount(hTxtsetupSif, L"Language");
if (Count > 0) if (Count > 0)
{ {
SetupData.pLanguages = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LANG) * Count); SetupData.pLanguages = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LANG) * Count);
@ -1002,20 +1002,20 @@ void LoadSetupData()
{ {
SetupData.LangCount = Count; SetupData.LangCount = Count;
Count = 0; Count = 0;
if (SetupFindFirstLine(hTxtsetupSif, _T("Language"), NULL, &InfContext)) if (SetupFindFirstLine(hTxtsetupSif, L"Language", NULL, &InfContext))
{ {
do do
{ {
SetupGetStringField(&InfContext, SetupGetStringField(&InfContext,
0, 0,
SetupData.pLanguages[Count].LangId, SetupData.pLanguages[Count].LangId,
sizeof(SetupData.pLanguages[Count].LangId) / sizeof(TCHAR), sizeof(SetupData.pLanguages[Count].LangId) / sizeof(WCHAR),
&LineLength); &LineLength);
SetupGetStringField(&InfContext, SetupGetStringField(&InfContext,
1, 1,
SetupData.pLanguages[Count].LangName, SetupData.pLanguages[Count].LangName,
sizeof(SetupData.pLanguages[Count].LangName) / sizeof(TCHAR), sizeof(SetupData.pLanguages[Count].LangName) / sizeof(WCHAR),
&LineLength); &LineLength);
++Count; ++Count;
} }
@ -1025,7 +1025,7 @@ void LoadSetupData()
} }
// get keyboard layout list // get keyboard layout list
Count = SetupGetLineCount(hTxtsetupSif, _T("KeyboardLayout")); Count = SetupGetLineCount(hTxtsetupSif, L"KeyboardLayout");
if (Count > 0) if (Count > 0)
{ {
SetupData.pKbLayouts = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(KBLAYOUT) * Count); SetupData.pKbLayouts = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(KBLAYOUT) * Count);
@ -1033,20 +1033,20 @@ void LoadSetupData()
{ {
SetupData.KbLayoutCount = Count; SetupData.KbLayoutCount = Count;
Count = 0; Count = 0;
if (SetupFindFirstLine(hTxtsetupSif, _T("KeyboardLayout"), NULL, &InfContext)) if (SetupFindFirstLine(hTxtsetupSif, L"KeyboardLayout", NULL, &InfContext))
{ {
do do
{ {
SetupGetStringField(&InfContext, SetupGetStringField(&InfContext,
0, 0,
SetupData.pKbLayouts[Count].LayoutId, SetupData.pKbLayouts[Count].LayoutId,
sizeof(SetupData.pKbLayouts[Count].LayoutId) / sizeof(TCHAR), sizeof(SetupData.pKbLayouts[Count].LayoutId) / sizeof(WCHAR),
&LineLength); &LineLength);
SetupGetStringField(&InfContext, SetupGetStringField(&InfContext,
1, 1,
SetupData.pKbLayouts[Count].LayoutName, SetupData.pKbLayouts[Count].LayoutName,
sizeof(SetupData.pKbLayouts[Count].LayoutName) / sizeof(TCHAR), sizeof(SetupData.pKbLayouts[Count].LayoutName) / sizeof(WCHAR),
&LineLength); &LineLength);
++Count; ++Count;
} }
@ -1060,22 +1060,22 @@ void LoadSetupData()
SetupData.DefaultLang = -1; SetupData.DefaultLang = -1;
// TODO: get defaults from underlaying running system // TODO: get defaults from underlaying running system
if (SetupFindFirstLine(hTxtsetupSif, _T("NLS"), _T("DefaultLayout"), &InfContext)) if (SetupFindFirstLine(hTxtsetupSif, L"NLS", L"DefaultLayout", &InfContext))
{ {
SetupGetStringField(&InfContext, 1, tmp, sizeof(tmp) / sizeof(TCHAR), &LineLength); SetupGetStringField(&InfContext, 1, tmp, sizeof(tmp) / sizeof(WCHAR), &LineLength);
for (Count = 0; Count < SetupData.KbLayoutCount; Count++) for (Count = 0; Count < SetupData.KbLayoutCount; Count++)
if (_tcscmp(tmp, SetupData.pKbLayouts[Count].LayoutId) == 0) if (wcscmp(tmp, SetupData.pKbLayouts[Count].LayoutId) == 0)
{ {
SetupData.DefaultKBLayout = Count; SetupData.DefaultKBLayout = Count;
break; break;
} }
} }
if (SetupFindFirstLine(hTxtsetupSif, _T("NLS"), _T("DefaultLanguage"), &InfContext)) if (SetupFindFirstLine(hTxtsetupSif, L"NLS", L"DefaultLanguage", &InfContext))
{ {
SetupGetStringField(&InfContext, 1, tmp, sizeof(tmp) / sizeof(TCHAR), &LineLength); SetupGetStringField(&InfContext, 1, tmp, sizeof(tmp) / sizeof(WCHAR), &LineLength);
for (Count = 0; Count < SetupData.LangCount; Count++) for (Count = 0; Count < SetupData.LangCount; Count++)
if (_tcscmp(tmp, SetupData.pLanguages[Count].LangId) == 0) if (wcscmp(tmp, SetupData.pLanguages[Count].LangId) == 0)
{ {
SetupData.DefaultLang = Count; SetupData.DefaultLang = Count;
break; break;
@ -1083,7 +1083,7 @@ void LoadSetupData()
} }
// get computers list // get computers list
Count = SetupGetLineCount(hTxtsetupSif, _T("Computer")); Count = SetupGetLineCount(hTxtsetupSif, L"Computer");
if (Count > 0) if (Count > 0)
{ {
SetupData.pComputers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GENENTRY) * Count); SetupData.pComputers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GENENTRY) * Count);
@ -1091,20 +1091,20 @@ void LoadSetupData()
{ {
SetupData.CompCount = Count; SetupData.CompCount = Count;
Count = 0; Count = 0;
if (SetupFindFirstLine(hTxtsetupSif, _T("Computer"), NULL, &InfContext)) if (SetupFindFirstLine(hTxtsetupSif, L"Computer", NULL, &InfContext))
{ {
do do
{ {
SetupGetStringField(&InfContext, SetupGetStringField(&InfContext,
0, 0,
SetupData.pComputers[Count].Id, SetupData.pComputers[Count].Id,
sizeof(SetupData.pComputers[Count].Id) / sizeof(TCHAR), sizeof(SetupData.pComputers[Count].Id) / sizeof(WCHAR),
&LineLength); &LineLength);
SetupGetStringField(&InfContext, SetupGetStringField(&InfContext,
1, 1,
SetupData.pComputers[Count].Value, SetupData.pComputers[Count].Value,
sizeof(SetupData.pComputers[Count].Value) / sizeof(TCHAR), sizeof(SetupData.pComputers[Count].Value) / sizeof(WCHAR),
&LineLength); &LineLength);
++Count; ++Count;
} }
@ -1114,7 +1114,7 @@ void LoadSetupData()
} }
// get display list // get display list
Count = SetupGetLineCount(hTxtsetupSif, _T("Display")); Count = SetupGetLineCount(hTxtsetupSif, L"Display");
if (Count > 0) if (Count > 0)
{ {
SetupData.pDisplays = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GENENTRY) * Count); SetupData.pDisplays = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GENENTRY) * Count);
@ -1123,20 +1123,20 @@ void LoadSetupData()
SetupData.DispCount = Count; SetupData.DispCount = Count;
Count = 0; Count = 0;
if (SetupFindFirstLine(hTxtsetupSif, _T("Display"), NULL, &InfContext)) if (SetupFindFirstLine(hTxtsetupSif, L"Display", NULL, &InfContext))
{ {
do do
{ {
SetupGetStringField(&InfContext, SetupGetStringField(&InfContext,
0, 0,
SetupData.pDisplays[Count].Id, SetupData.pDisplays[Count].Id,
sizeof(SetupData.pDisplays[Count].Id) / sizeof(TCHAR), sizeof(SetupData.pDisplays[Count].Id) / sizeof(WCHAR),
&LineLength); &LineLength);
SetupGetStringField(&InfContext, SetupGetStringField(&InfContext,
1, 1,
SetupData.pDisplays[Count].Value, SetupData.pDisplays[Count].Value,
sizeof(SetupData.pDisplays[Count].Value) / sizeof(TCHAR), sizeof(SetupData.pDisplays[Count].Value) / sizeof(WCHAR),
&LineLength); &LineLength);
++Count; ++Count;
} }
@ -1146,7 +1146,7 @@ void LoadSetupData()
} }
// get keyboard list // get keyboard list
Count = SetupGetLineCount(hTxtsetupSif, _T("Keyboard")); Count = SetupGetLineCount(hTxtsetupSif, L"Keyboard");
if (Count > 0) if (Count > 0)
{ {
SetupData.pKeyboards = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GENENTRY) * Count); SetupData.pKeyboards = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GENENTRY) * Count);
@ -1155,20 +1155,20 @@ void LoadSetupData()
SetupData.KeybCount = Count; SetupData.KeybCount = Count;
Count = 0; Count = 0;
if (SetupFindFirstLine(hTxtsetupSif, _T("Keyboard"), NULL, &InfContext)) if (SetupFindFirstLine(hTxtsetupSif, L"Keyboard", NULL, &InfContext))
{ {
do do
{ {
SetupGetStringField(&InfContext, SetupGetStringField(&InfContext,
0, 0,
SetupData.pKeyboards[Count].Id, SetupData.pKeyboards[Count].Id,
sizeof(SetupData.pKeyboards[Count].Id) / sizeof(TCHAR), sizeof(SetupData.pKeyboards[Count].Id) / sizeof(WCHAR),
&LineLength); &LineLength);
SetupGetStringField(&InfContext, SetupGetStringField(&InfContext,
1, 1,
SetupData.pKeyboards[Count].Value, SetupData.pKeyboards[Count].Value,
sizeof(SetupData.pKeyboards[Count].Value) / sizeof(TCHAR), sizeof(SetupData.pKeyboards[Count].Value) / sizeof(WCHAR),
&LineLength); &LineLength);
++Count; ++Count;
} }
@ -1178,12 +1178,12 @@ void LoadSetupData()
} }
// get install directory // get install directory
if (SetupFindFirstLine(hTxtsetupSif, _T("SetupData"), _T("DefaultPath"), &InfContext)) if (SetupFindFirstLine(hTxtsetupSif, L"SetupData", L"DefaultPath", &InfContext))
{ {
SetupGetStringField(&InfContext, SetupGetStringField(&InfContext,
1, 1,
SetupData.InstallDir, SetupData.InstallDir,
sizeof(SetupData.InstallDir) / sizeof(TCHAR), sizeof(SetupData.InstallDir) / sizeof(WCHAR),
&LineLength); &LineLength);
} }
SetupCloseInfFile(hTxtsetupSif); SetupCloseInfFile(hTxtsetupSif);
@ -1196,7 +1196,7 @@ BOOL isUnattendSetup()
WCHAR *ch; WCHAR *ch;
HINF hUnattendedInf; HINF hUnattendedInf;
INFCONTEXT InfContext; INFCONTEXT InfContext;
TCHAR szValue[MAX_PATH]; WCHAR szValue[MAX_PATH];
DWORD LineLength; DWORD LineLength;
//HKEY hKey; //HKEY hKey;
BOOL result = 0; BOOL result = 0;
@ -1211,13 +1211,13 @@ BOOL isUnattendSetup()
if (hUnattendedInf != INVALID_HANDLE_VALUE) if (hUnattendedInf != INVALID_HANDLE_VALUE)
{ {
if (SetupFindFirstLine(hUnattendedInf, _T("Unattend"), _T("UnattendSetupEnabled"),&InfContext)) if (SetupFindFirstLine(hUnattendedInf, L"Unattend", L"UnattendSetupEnabled",&InfContext))
{ {
if (SetupGetStringField(&InfContext, if (SetupGetStringField(&InfContext,
1, 1,
szValue, szValue,
sizeof(szValue) / sizeof(TCHAR), sizeof(szValue) / sizeof(WCHAR),
&LineLength) && (_tcsicmp(szValue, _T("yes")) == 0)) &LineLength) && (_wcsicmp(szValue, L"yes") == 0))
{ {
result = 1; // unattendSetup enabled result = 1; // unattendSetup enabled
// read values and store in SetupData // read values and store in SetupData
@ -1230,10 +1230,10 @@ BOOL isUnattendSetup()
} }
int WINAPI int WINAPI
WinMain(HINSTANCE hInst, wWinMain(HINSTANCE hInst,
HINSTANCE hPrevInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, LPWSTR lpszCmdLine,
int nCmdShow) int nCmdShow)
{ {
PROPSHEETHEADER psh; PROPSHEETHEADER psh;
HPROPSHEETPAGE ahpsp[8]; HPROPSHEETPAGE ahpsp[8];
@ -1244,8 +1244,8 @@ WinMain(HINSTANCE hInst,
if (!isUnattend) if (!isUnattend)
{ {
LoadString(hInst,IDS_ABORTSETUP, abort_msg, sizeof(abort_msg)/sizeof(TCHAR)); LoadString(hInst, IDS_ABORTSETUP, abort_msg, sizeof(abort_msg) / sizeof(WCHAR));
LoadString(hInst,IDS_ABORTSETUP2, abort_title,sizeof(abort_title)/sizeof(TCHAR)); LoadString(hInst, IDS_ABORTSETUP2, abort_title, sizeof(abort_title) / sizeof(WCHAR));
LoadSetupData(); LoadSetupData();

View file

@ -1,6 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd"> <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
<module name="reactos" type="win32gui"> <module name="reactos" type="win32gui" unicode="yes">
<bootstrap installbase="$(CDOUTPUT)" /> <bootstrap installbase="$(CDOUTPUT)" />
<include base="reactos">.</include> <include base="reactos">.</include>
<library>kernel32</library> <library>kernel32</library>