sync with trunk r46493
[reactos.git] / dll / win32 / syssetup / install.c
index df20011..c212916 100644 (file)
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 /*
  * COPYRIGHT:         See COPYING in the top level directory
  * PROJECT:           ReactOS system libraries
  * PURPOSE:           System setup
- * FILE:              lib/syssetup/install.c
+ * FILE:              dll/win32/syssetup/install.c
  * PROGRAMER:         Eric Kohl
  */
 
@@ -304,13 +304,13 @@ static VOID
 CreateTempDir(
     IN LPCWSTR VarName)
 {
-    TCHAR szTempDir[MAX_PATH];
-    TCHAR szBuffer[MAX_PATH];
+    WCHAR szTempDir[MAX_PATH];
+    WCHAR szBuffer[MAX_PATH];
     DWORD dwLength;
     HKEY hKey;
 
-    if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
-                     _T("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"),
+    if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+                     L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",
                      0,
                      KEY_QUERY_VALUE,
                      &hKey))
@@ -320,8 +320,8 @@ CreateTempDir(
     }
 
     /* Get temp dir */
-    dwLength = MAX_PATH * sizeof(TCHAR);
-    if (RegQueryValueEx(hKey,
+    dwLength = MAX_PATH * sizeof(WCHAR);
+    if (RegQueryValueExW(hKey,
                         VarName,
                         NULL,
                         NULL,
@@ -334,7 +334,7 @@ CreateTempDir(
     }
 
     /* Expand it */
-    if (!ExpandEnvironmentStrings(szBuffer,
+    if (!ExpandEnvironmentStringsW(szBuffer,
                                   szTempDir,
                                   MAX_PATH))
     {
@@ -344,7 +344,7 @@ CreateTempDir(
     }
 
     /* Create profiles directory */
-    if (!CreateDirectory(szTempDir, NULL))
+    if (!CreateDirectoryW(szTempDir, NULL))
     {
         if (GetLastError() != ERROR_ALREADY_EXISTS)
         {
@@ -362,11 +362,11 @@ BOOL
 InstallSysSetupInfDevices(VOID)
 {
     INFCONTEXT InfContext;
-    TCHAR LineBuffer[256];
+    WCHAR LineBuffer[256];
     DWORD LineLength;
 
-    if (!SetupFindFirstLine(hSysSetupInf,
-                            _T("DeviceInfsToInstall"),
+    if (!SetupFindFirstLineW(hSysSetupInf,
+                            L"DeviceInfsToInstall",
                             NULL,
                             &InfContext))
     {
@@ -375,7 +375,7 @@ InstallSysSetupInfDevices(VOID)
 
     do
     {
-        if (!SetupGetStringField(&InfContext,
+        if (!SetupGetStringFieldW(&InfContext,
                                  0,
                                  LineBuffer,
                                  sizeof(LineBuffer)/sizeof(LineBuffer[0]),
@@ -384,7 +384,7 @@ InstallSysSetupInfDevices(VOID)
             return FALSE;
         }
 
-        if (!SetupDiInstallClass(NULL, LineBuffer, DI_QUIETINSTALL, NULL))
+        if (!SetupDiInstallClassW(NULL, LineBuffer, DI_QUIETINSTALL, NULL))
         {
             return FALSE;
         }
@@ -397,12 +397,12 @@ BOOL
 InstallSysSetupInfComponents(VOID)
 {
     INFCONTEXT InfContext;
-    TCHAR NameBuffer[256];
-    TCHAR SectionBuffer[256];
+    WCHAR NameBuffer[256];
+    WCHAR SectionBuffer[256];
     HINF hComponentInf = INVALID_HANDLE_VALUE;
 
-    if (!SetupFindFirstLine(hSysSetupInf,
-                            _T("Infs.Always"),
+    if (!SetupFindFirstLineW(hSysSetupInf,
+                            L"Infs.Always",
                             NULL,
                             &InfContext))
     {
@@ -412,7 +412,7 @@ InstallSysSetupInfComponents(VOID)
     {
         do
         {
-            if (!SetupGetStringField(&InfContext,
+            if (!SetupGetStringFieldW(&InfContext,
                                      1, // Get the component name
                                      NameBuffer,
                                      sizeof(NameBuffer)/sizeof(NameBuffer[0]),
@@ -422,7 +422,7 @@ InstallSysSetupInfComponents(VOID)
                 return FALSE;
             }
 
-            if (!SetupGetStringField(&InfContext,
+            if (!SetupGetStringFieldW(&InfContext,
                                      2, // Get the component install section
                                      SectionBuffer,
                                      sizeof(SectionBuffer)/sizeof(SectionBuffer[0]),
@@ -445,7 +445,7 @@ InstallSysSetupInfComponents(VOID)
                 return FALSE;
             }
 
-            if (!SetupInstallFromInfSection(NULL,
+            if (!SetupInstallFromInfSectionW(NULL,
                                             hComponentInf,
                                             SectionBuffer,
                                             SPINST_ALL,
@@ -481,18 +481,22 @@ EnableUserModePnpManager(VOID)
     if (hSCManager == NULL)
         goto cleanup;
 
-    hService = OpenService(hSCManager, _T("PlugPlay"), SERVICE_CHANGE_CONFIG | SERVICE_START);
+    hService = OpenServiceW(hSCManager,
+                            L"PlugPlay",
+                            SERVICE_CHANGE_CONFIG | SERVICE_START);
     if (hService == NULL)
         goto cleanup;
 
-    ret = ChangeServiceConfig(
-        hService,
-        SERVICE_NO_CHANGE, SERVICE_AUTO_START, SERVICE_NO_CHANGE,
-        NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+    ret = ChangeServiceConfigW(hService,
+                               SERVICE_NO_CHANGE,
+                               SERVICE_AUTO_START,
+                               SERVICE_NO_CHANGE,
+                               NULL, NULL, NULL,
+                               NULL, NULL, NULL, NULL);
     if (!ret)
         goto cleanup;
 
-    ret = StartService(hService, 0, NULL);
+    ret = StartServiceW(hService, 0, NULL);
     if (!ret)
         goto cleanup;
 
@@ -507,7 +511,7 @@ cleanup:
 }
 
 
-static BOOL CALLBACK
+static INT_PTR CALLBACK
 StatusMessageWindowProc(
     IN HWND hwndDlg,
     IN UINT uMsg,
@@ -520,11 +524,11 @@ StatusMessageWindowProc(
     {
         case WM_INITDIALOG:
         {
-            TCHAR szMsg[256];
+            WCHAR szMsg[256];
 
-            if (!LoadString(hDllInstance, IDS_STATUS_INSTALL_DEV, szMsg, sizeof(szMsg)/sizeof(szMsg[0])))
+            if (!LoadStringW(hDllInstance, IDS_STATUS_INSTALL_DEV, szMsg, sizeof(szMsg)/sizeof(szMsg[0])))
                 return FALSE;
-            SetDlgItemText(hwndDlg, IDC_STATUSLABEL, szMsg);
+            SetDlgItemTextW(hwndDlg, IDC_STATUSLABEL, szMsg);
             return TRUE;
         }
     }
@@ -705,7 +709,7 @@ CommonInstall(VOID)
 DWORD WINAPI
 InstallLiveCD(IN HINSTANCE hInstance)
 {
-    STARTUPINFO StartupInfo;
+    STARTUPINFOW StartupInfo;
     PROCESS_INFORMATION ProcessInformation;
     BOOL res;
 
@@ -714,15 +718,15 @@ InstallLiveCD(IN HINSTANCE hInstance)
     SetupCloseInfFile(hSysSetupInf);
 
     /* Run the shell */
-    StartupInfo.cb = sizeof(StartupInfo);
+    StartupInfo.cb = sizeof(STARTUPINFOW);
     StartupInfo.lpReserved = NULL;
     StartupInfo.lpDesktop = NULL;
     StartupInfo.lpTitle = NULL;
     StartupInfo.dwFlags = 0;
     StartupInfo.cbReserved2 = 0;
     StartupInfo.lpReserved2 = 0;
-    res = CreateProcess(
-        _T("userinit.exe"),
+    res = CreateProcessW(
+        L"userinit.exe",
         NULL,
         NULL,
         NULL,
@@ -738,10 +742,10 @@ InstallLiveCD(IN HINSTANCE hInstance)
     return 0;
 
 cleanup:
-    MessageBoxA(
+    MessageBoxW(
         NULL,
-        "You can shutdown your computer, or press ENTER to reboot",
-        "ReactOS LiveCD",
+        L"You can shutdown your computer, or press ENTER to reboot",
+        L"ReactOS LiveCD",
         MB_OK);
     return 0;
 }
@@ -759,11 +763,13 @@ CreateShortcuts(VOID)
 
     /* Create program startmenu shortcuts */
     CreateShortcut(CSIDL_PROGRAMS, NULL, IDS_SHORT_EXPLORER, _T("%SystemRoot%\\explorer.exe"), IDS_CMT_EXPLORER, TRUE);
-    CreateShortcut(CSIDL_PROGRAMS, NULL, IDS_SHORT_DOWNLOADER, _T("%SystemRoot%\\system32\\downloader.exe"), IDS_CMT_DOWNLOADER, TRUE);
+    CreateShortcut(CSIDL_PROGRAMS, NULL, IDS_SHORT_DOWNLOADER, _T("%SystemRoot%\\system32\\rapps.exe"), IDS_CMT_DOWNLOADER, TRUE);
 
     /* Create administrative tools startmenu shortcuts */
     CreateShortcut(CSIDL_COMMON_ADMINTOOLS, NULL, IDS_SHORT_SERVICE, _T("%SystemRoot%\\system32\\servman.exe"), IDS_CMT_SERVMAN, TRUE);
     CreateShortcut(CSIDL_COMMON_ADMINTOOLS, NULL, IDS_SHORT_DEVICE, _T("%SystemRoot%\\system32\\devmgmt.exe"), IDS_CMT_DEVMGMT, TRUE);
+    CreateShortcut(CSIDL_COMMON_ADMINTOOLS, NULL, IDS_SHORT_EVENTVIEW, _T("%SystemRoot%\\system32\\eventvwr.exe"), IDS_CMT_EVENTVIEW, TRUE);
+    CreateShortcut(CSIDL_COMMON_ADMINTOOLS, NULL, IDS_SHORT_MSCONFIG, _T("%SystemRoot%\\system32\\msconfig.exe"), IDS_CMT_MSCONFIG, TRUE);
 
     /* Create and fill Accessories subfolder */
     if (CreateShortcutFolder(CSIDL_PROGRAMS, IDS_ACCESSORIES, szFolder, sizeof(szFolder)/sizeof(szFolder[0])))
@@ -771,30 +777,41 @@ CreateShortcuts(VOID)
         CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_CALC, _T("%SystemRoot%\\system32\\calc.exe"), IDS_CMT_CALC, TRUE);
         CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_CMD, _T("%SystemRoot%\\system32\\cmd.exe"), IDS_CMT_CMD, TRUE);
         CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_NOTEPAD, _T("%SystemRoot%\\system32\\notepad.exe"), IDS_CMT_NOTEPAD, TRUE);
-        CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_WORDPAD, _T("%SystemRoot%\\system32\\wordpad.exe"), IDS_CMT_WORDPAD, TRUE);
-        CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_SNAP, _T("%SystemRoot%\\system32\\screenshot.exe"), IDS_CMT_SCREENSHOT, TRUE);
         CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_RDESKTOP, _T("%SystemRoot%\\system32\\mstsc.exe"), IDS_CMT_RDESKTOP, TRUE);
+        CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_SNAP, _T("%SystemRoot%\\system32\\screenshot.exe"), IDS_CMT_SCREENSHOT, TRUE);
+        CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_WORDPAD, _T("%SystemRoot%\\system32\\wordpad.exe"), IDS_CMT_WORDPAD, TRUE);
+        CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_PAINT, _T("%SystemRoot%\\system32\\paint.exe"), IDS_CMT_PAINT, TRUE);
     }
 
-    /* Creacte System Tools subfolder and fill if the exe is available */
+    /* Create System Tools subfolder and fill if the exe is available */
     if (CreateShortcutFolder(CSIDL_PROGRAMS, IDS_SYS_TOOLS, szFolder, sizeof(szFolder)/sizeof(szFolder[0])))
     {
         CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_CHARMAP, _T("%SystemRoot%\\system32\\charmap.exe"), IDS_CMT_CHARMAP, TRUE);
         CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_KBSWITCH, _T("%SystemRoot%\\system32\\kbswitch.exe"), IDS_CMT_KBSWITCH, TRUE);
         CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_REGEDIT, _T("%SystemRoot%\\regedit.exe"), IDS_CMT_REGEDIT, TRUE);
+        CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_DXDIAG, _T("%SystemRoot%\\system32\\dxdiag.exe"), IDS_CMT_DXDIAG, TRUE);
     }
 
-    /* Creacte Accessibility subfolder and fill if the exe is available */
+    /* Create Accessibility subfolder and fill if the exe is available */
     if (CreateShortcutFolder(CSIDL_PROGRAMS, IDS_SYS_ACCESSIBILITY, szFolder, sizeof(szFolder)/sizeof(szFolder[0])))
     {
         CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_MAGNIFY, _T("%SystemRoot%\\system32\\magnify.exe"), IDS_CMT_MAGNIFY, TRUE);
     }
 
+    /* Create Entertainment subfolder and fill if the exe is available */
+    if (CreateShortcutFolder(CSIDL_PROGRAMS, IDS_SYS_ENTERTAINMENT, szFolder, sizeof(szFolder)/sizeof(szFolder[0])))
+    {
+        CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_MPLAY32, _T("%SystemRoot%\\system32\\mplay32.exe"), IDS_CMT_MPLAY32, TRUE);
+        CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_SNDVOL32, _T("%SystemRoot%\\system32\\sndvol32.exe"), IDS_CMT_SNDVOL32, TRUE);
+        CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_SNDREC32, _T("%SystemRoot%\\system32\\sndrec32.exe"), IDS_CMT_SNDREC32, TRUE);
+    }
+
     /* Create Games subfolder and fill if the exe is available */
     if (CreateShortcutFolder(CSIDL_PROGRAMS, IDS_GAMES, szFolder, sizeof(szFolder)/sizeof(szFolder[0])))
     {
         CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_SOLITAIRE, _T("%SystemRoot%\\system32\\sol.exe"), IDS_CMT_SOLITAIRE, TRUE);
         CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_WINEMINE, _T("%SystemRoot%\\system32\\winemine.exe"), IDS_CMT_WINEMINE, TRUE);
+        CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_SPIDER, _T("%SystemRoot%\\system32\\spider.exe"), IDS_CMT_SPIDER, TRUE);
     }
 
     CoUninitialize();
@@ -879,6 +896,21 @@ InstallReactOS(HINSTANCE hInstance)
     /* Append the Admin-RID */
     AppendRidToSid(&AdminSid, DomainSid, DOMAIN_USER_RID_ADMIN);
 
+    CreateTempDir(L"TEMP");
+    CreateTempDir(L"TMP");
+
+    if (GetWindowsDirectory(szBuffer, sizeof(szBuffer) / sizeof(TCHAR)))
+    {
+        PathAddBackslash(szBuffer);
+        _tcscat(szBuffer, _T("system"));
+        CreateDirectory(szBuffer, NULL);
+    }
+
+    if (!CommonInstall())
+        return 0;
+
+    InstallWizard();
+
     /* Create the Administrator account */
     if (!SamCreateUser(L"Administrator", L"", AdminSid))
     {
@@ -930,21 +962,6 @@ InstallReactOS(HINSTANCE hInstance)
     }
     /* END OF ROS HACK */
 
-    CreateTempDir(L"TEMP");
-    CreateTempDir(L"TMP");
-
-    if (GetWindowsDirectory(szBuffer, sizeof(szBuffer) / sizeof(TCHAR)))
-    {
-        PathAddBackslash(szBuffer);
-        _tcscat(szBuffer, _T("system"));
-        CreateDirectory(szBuffer, NULL);
-    }
-
-    if (!CommonInstall())
-        return 0;
-
-    InstallWizard();
-
     SetupCloseInfFile(hSysSetupInf);
     SetSetupType(0);
 
@@ -987,7 +1004,7 @@ InstallReactOS(HINSTANCE hInstance)
 /*
  * @unimplemented
  */
-DWORD STDCALL
+DWORD WINAPI
 SetupChangeFontSize(
     IN HANDLE hWnd,
     IN LPCWSTR lpszFontSize)
@@ -995,3 +1012,27 @@ SetupChangeFontSize(
     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
     return FALSE;
 }
+
+/*
+ * @unimplemented
+ */
+DWORD WINAPI
+SetupChangeLocaleEx(HWND hWnd,
+                    LCID Lcid,
+                    LPCWSTR lpSrcRootPath,
+                    char Unknown,
+                    DWORD dwUnused1,
+                    DWORD dwUnused2)
+{
+    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+    return FALSE;
+}
+
+/*
+ * @implemented
+ */
+DWORD WINAPI
+SetupChangeLocale(HWND hWnd, LCID Lcid)
+{
+    return SetupChangeLocaleEx(hWnd, Lcid, NULL, 0, 0, 0);
+}