Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
2.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993 - 2000.
  5. //
  6. // File: cpl.cpp
  7. //
  8. // Contents: Control Panel entry point (CPlApplet)
  9. //
  10. //----------------------------------------------------------------------------
  11. #include "stdafx.h"
  12. #include <regstr.h> // REGSTR_PATH_POLICIES
  13. #include <lm.h> // NetGetJoinInformation
  14. #include <cpl.h>
  15. #include "resource.h"
  16. const struct
  17. {
  18. LPCTSTR pszApp;
  19. LPCTSTR pszCommand;
  20. }
  21. s_rgCommands[] =
  22. {
  23. { TEXT("%SystemRoot%\\system32\\rundll32.exe"), TEXT("rundll32.exe \"%SystemRoot%\\system32\\netplwiz.dll\",UsersRunDll") },
  24. { TEXT("%SystemRoot%\\system32\\mshta.exe"), TEXT("mshta.exe \"res://%SystemRoot%\\system32\\nusrmgr.cpl/nusrmgr.hta\"") },
  25. };
  26. TCHAR const c_szPolicyKey[] = REGSTR_PATH_POLICIES TEXT("\\Explorer");
  27. TCHAR const c_szPolicyVal[] = TEXT("UserPasswordsVer");
  28. HRESULT StartUserManager(LPCTSTR pszParams)
  29. {
  30. TCHAR szApp[MAX_PATH];
  31. TCHAR szCommand[MAX_PATH];
  32. int iCommandIndex;
  33. STARTUPINFO rgStartup = {0};
  34. PROCESS_INFORMATION rgProcess = {0};
  35. // Default is to use the old UI
  36. iCommandIndex = 0;
  37. #ifndef _WIN64
  38. if (IsOS(OS_PERSONAL) || (IsOS(OS_PROFESSIONAL) && !IsOS(OS_DOMAINMEMBER)))
  39. {
  40. // Switch to the friendly UI.
  41. iCommandIndex = 1;
  42. }
  43. #endif
  44. ExpandEnvironmentStrings(s_rgCommands[iCommandIndex].pszApp, szApp, MAX_PATH);
  45. ExpandEnvironmentStrings(s_rgCommands[iCommandIndex].pszCommand, szCommand, MAX_PATH);
  46. if (pszParams && *pszParams != TEXT('\0'))
  47. {
  48. StrCatBuff(szCommand, TEXT(" "), MAX_PATH);
  49. StrCatBuff(szCommand, pszParams, MAX_PATH);
  50. }
  51. rgStartup.cb = sizeof(rgStartup);
  52. rgStartup.wShowWindow = SW_SHOWNORMAL;
  53. if (CreateProcess(szApp,
  54. szCommand,
  55. NULL,
  56. NULL,
  57. FALSE,
  58. 0,
  59. NULL,
  60. NULL,
  61. &rgStartup,
  62. &rgProcess))
  63. {
  64. WaitForInputIdle( rgProcess.hProcess, 10000 );
  65. CloseHandle( rgProcess.hProcess );
  66. CloseHandle( rgProcess.hThread );
  67. return S_OK;
  68. }
  69. return E_FAIL;
  70. }
  71. LONG APIENTRY CPlApplet(HWND hwnd, UINT Msg, LPARAM lParam1, LPARAM lParam2)
  72. {
  73. LPCPLINFO lpCplInfo;
  74. switch (Msg)
  75. {
  76. case CPL_INIT:
  77. return TRUE;
  78. case CPL_GETCOUNT:
  79. return 1;
  80. case CPL_INQUIRE:
  81. lpCplInfo = (LPCPLINFO)lParam2;
  82. lpCplInfo->idIcon = IDI_CPLICON;
  83. lpCplInfo->idName = IDS_NAME;
  84. lpCplInfo->idInfo = IDS_INFO;
  85. lpCplInfo->lData = 0;
  86. break;
  87. case CPL_DBLCLK:
  88. StartUserManager(NULL);
  89. return TRUE;
  90. case CPL_STARTWPARMS:
  91. StartUserManager((LPCTSTR)lParam2);
  92. return TRUE;
  93. }
  94. return 0;
  95. }