Leaked source code of windows server 2003
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.

707 lines
19 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. #include "precomp.h"
  3. #include "..\Common\ServiceThread.h"
  4. #include "..\MMFUtil\MsgDlg.h"
  5. #include "helpid.h"
  6. #ifdef EXT_DEBUG
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. #include "GeneralPage.h"
  11. // avoid some warnings.
  12. #undef HDS_HORZ
  13. #undef HDS_BUTTONS
  14. #undef HDS_HIDDEN
  15. #include "resource.h"
  16. #include "..\Common\util.h"
  17. #include <windowsx.h>
  18. //--------------------------------------------------------------
  19. GeneralPage::GeneralPage(WbemServiceThread *serviceThread,
  20. LONG_PTR lNotifyHandle, bool bDeleteHandle, TCHAR* pTitle,
  21. IDataObject* pDataObject)
  22. : WBEMPageHelper(serviceThread),
  23. CSnapInPropertyPageImpl<GeneralPage> (pTitle),
  24. m_lNotifyHandle(lNotifyHandle),
  25. m_bDeleteHandle(bDeleteHandle) // Should be true for only page.
  26. {
  27. m_inited = false;
  28. m_pDataObject = pDataObject;
  29. }
  30. //--------------------------------------------------------------
  31. GeneralPage::~GeneralPage()
  32. {
  33. if (m_bDeleteHandle)
  34. MMCFreeNotifyHandle(m_lNotifyHandle);
  35. }
  36. //-------------------------------------------------------------
  37. bool GeneralPage::CimomIsReady()
  38. {
  39. m_hDlg = m_hWnd;
  40. bool retval = ServiceIsReady(IDS_DISPLAY_NAME,
  41. IDS_CONNECTING,
  42. IDS_BAD_CONNECT);
  43. if(retval)
  44. {
  45. if((bool)m_WbemServices)
  46. {
  47. IWbemClassObject *pInst = NULL;
  48. m_WbemServices.SetPriv();
  49. if((pInst = FirstInstanceOf((bstr_t)"Win32_OperatingSystem")) != NULL)
  50. {
  51. m_OS = pInst;
  52. }
  53. if((pInst = FirstInstanceOf("Win32_Processor")) != NULL)
  54. {
  55. m_processor = pInst;
  56. }
  57. if((pInst = FirstInstanceOf("Win32_LogicalMemoryConfiguration")) != NULL)
  58. {
  59. m_memory = pInst;
  60. }
  61. if((pInst = FirstInstanceOf("Win32_ComputerSystem")) != NULL)
  62. {
  63. m_computer = pInst;
  64. }
  65. }
  66. else
  67. {
  68. retval = false;
  69. }
  70. }
  71. return retval;
  72. }
  73. //-------------------------------------------------------------
  74. void GeneralPage::ConfigureProductID(LPTSTR lpPid)
  75. {
  76. TCHAR szBuf[64] = {0};
  77. // is it formatted already.
  78. if(lstrlen(lpPid) > 20)
  79. {
  80. return;
  81. }
  82. if (!lpPid || !(*lpPid) || (lstrlen(lpPid) < 20) ) {
  83. return;
  84. }
  85. szBuf[0] = lpPid[0];
  86. szBuf[1] = lpPid[1];
  87. szBuf[2] = lpPid[2];
  88. szBuf[3] = lpPid[3];
  89. szBuf[4] = lpPid[4];
  90. szBuf[5] = TEXT('-');
  91. szBuf[6] = lpPid[5];
  92. szBuf[7] = lpPid[6];
  93. szBuf[8] = lpPid[7];
  94. szBuf[9] = TEXT('-');
  95. szBuf[10] = lpPid[8];
  96. szBuf[11] = lpPid[9];
  97. szBuf[12] = lpPid[10];
  98. szBuf[13] = lpPid[11];
  99. szBuf[14] = lpPid[12];
  100. szBuf[15] = lpPid[13];
  101. szBuf[16] = lpPid[14];
  102. szBuf[17] = TEXT('-');
  103. szBuf[18] = lpPid[15];
  104. szBuf[19] = lpPid[16];
  105. szBuf[20] = lpPid[17];
  106. szBuf[21] = lpPid[18];
  107. szBuf[22] = lpPid[19];
  108. szBuf[23] = TEXT('\0');
  109. lstrcpy (lpPid, szBuf);
  110. }
  111. //Helper to split the caption of the OS to two controls to match the way shell displays it
  112. void WrapTextToTwoControls(HWND hwndLine1, HWND hwndLine2, LPCTSTR szText)
  113. {
  114. RECT rcCtl;
  115. SIZE size;
  116. int fit = 0;
  117. int length = 0;
  118. HDC hDC = NULL;
  119. HFONT hFont = NULL;
  120. HFONT hOldFont = NULL;
  121. LPTSTR pszTempBuffer = NULL;
  122. LPTSTR pszLineBreak = NULL;
  123. // Validate the arguments
  124. if(NULL == hwndLine1 || NULL == hwndLine2 || NULL == szText)
  125. goto FAIL;
  126. // Make sure we don't have a zero length string
  127. if(0 == (length = lstrlen(szText)))
  128. goto FAIL;
  129. // Get the size of the control for line 1
  130. if(!GetClientRect(hwndLine1, &rcCtl))
  131. goto FAIL;
  132. // Get the DC of line 1
  133. if(NULL == (hDC = ::GetDC(hwndLine1)))
  134. goto FAIL;
  135. // Get the font that is in use for line 1
  136. if(NULL == (hFont = (HFONT)::SendMessage(hwndLine1, WM_GETFONT, 0, 0)))
  137. goto FAIL;
  138. // Select the correct font into the DC
  139. if(NULL == (hOldFont = (HFONT)::SelectObject(hDC, hFont)))
  140. goto FAIL;
  141. // Find out how many characters of our string would fit into the control
  142. if(!GetTextExtentExPoint(hDC, szText, length, rcCtl.right, &fit, NULL, &size))
  143. goto FAIL;
  144. // If the 'fit' is not greater than 0 and less than length, just display everything on line 1
  145. if(fit <= 0 || fit >= length)
  146. goto FAIL;
  147. // Allocate a buffer to play with
  148. if(NULL == (pszTempBuffer = new TCHAR[length+1]))
  149. goto FAIL;
  150. // Copy text into temporary buffer
  151. lstrcpy(pszTempBuffer, szText);
  152. // We will try to break line 1 right at the maximum number of characters
  153. pszLineBreak = pszTempBuffer + fit;
  154. // See if the natural break falls directly on a 'space'
  155. if(*pszLineBreak != _TEXT(' '))
  156. {
  157. // The number of characters that fit into line 1 falls in the middle of a word. Find
  158. // the last space that fits in the control. If we do not find a space that fits in
  159. // line 1, just use the default behavior.
  160. // Terminate line 1 at the maximum characters
  161. *pszLineBreak = _TEXT('\0');
  162. // Find the last 'sace' on line 1
  163. if(NULL == (pszLineBreak = _tcsrchr(pszTempBuffer, _TEXT(' '))))
  164. goto FAIL;
  165. // Copy text into the temporary buffer again
  166. lstrcpy(pszTempBuffer, szText);
  167. }
  168. // Terminate line 1 right on the 'last' space that fits into the control
  169. *pszLineBreak = _TEXT('\0');
  170. // Set line one to everything up to the 'last' space that fits into the control
  171. SetWindowText(hwndLine1, pszTempBuffer);
  172. // Set line two to everything after the 'last' space that fit into line 1
  173. SetWindowText(hwndLine2, pszLineBreak+1);
  174. // Everything went OK;
  175. goto CLEANUP;
  176. FAIL:
  177. // Default to putting all the text on line 1 if anything goes wrong
  178. ::SetWindowText(hwndLine1, szText);
  179. ::SetWindowText(hwndLine2, _TEXT(""));
  180. CLEANUP:
  181. if(pszTempBuffer)
  182. delete[] pszTempBuffer;
  183. if(hOldFont && hDC)
  184. SelectObject(hDC, hOldFont);
  185. if(hDC && hwndLine1)
  186. ReleaseDC(hwndLine1, hDC);
  187. }
  188. //--------------------------------------------------------------
  189. void GeneralPage::Init()
  190. {
  191. TCHAR _scr1[640] = {0};
  192. TCHAR _scr2[640] = {0};
  193. TCHAR szNumBuf1[64] = {0};
  194. int ctlid;
  195. // Set the default bitmap
  196. SetClearBitmap(GetDlgItem(IDC_GEN_WINDOWS_IMAGE ),
  197. MAKEINTRESOURCE( IDB_WINDOWS ), 0 );
  198. //
  199. // The caption is in the form:
  200. // Microsoft Windows XP Server
  201. //
  202. // This is actually the caption + the product suite type.
  203. // Wrap the product suite type (Server above) into the
  204. // next static control.
  205. //
  206. // IDC_GEN_VERSION_0: Major branding ("Windows XP")
  207. // Default to Win32_OperatingSystem::Caption.
  208. //
  209. HWND hwndCtl1 = ::GetDlgItem(m_hWnd, IDC_GEN_VERSION_0);
  210. HWND hwndCtl2 = ::GetDlgItem(m_hWnd, IDC_GEN_VERSION_1);
  211. WrapTextToTwoControls(hwndCtl1, hwndCtl2, m_OS.GetString("Caption"));
  212. // Build and set the serial number string
  213. if (m_OS.GetBool("Debug"))
  214. {
  215. _scr1[0] = TEXT(' ');
  216. LoadString(HINST_THISDLL,
  217. IDS_DEBUG,
  218. &_scr1[1],
  219. ARRAYSIZE(_scr1));
  220. }
  221. else
  222. {
  223. _scr1[0] = TEXT('\0');
  224. }
  225. // IDC_GEN_VERSION_2: Version year ("Version 2002")
  226. //
  227. // Determine if we are targeting XP. If not, default to
  228. // Win32_OperatingSystem::Version.
  229. //
  230. // Instead of checking if this is XP (based on "5.1" version), a safer bet
  231. // is to do this only if we are on the local box. Otherwise display the version from WMI.
  232. if(m_serviceThread->m_machineName.length() == 0)
  233. {
  234. LoadString(HINST_THISDLL, IDS_WINVER_YEAR, _scr2, ARRAYSIZE(_scr2));
  235. wcscat(_scr2, _scr1);
  236. SetDlgItemText(IDC_GEN_VERSION_2, _scr2);
  237. }
  238. else
  239. {
  240. wcscpy(_scr2, (wchar_t *)m_OS.GetString("Version"));
  241. wcscat(_scr2, _scr1);
  242. SetDlgItemText(IDC_GEN_VERSION_2, _scr2);
  243. }
  244. // IDC_GEN_SERVICE_PACK: Service pack (if any)
  245. SetDlgItemText(IDC_GEN_SERVICE_PACK, m_OS.GetString("CSDVersion"));
  246. // Do registered user info
  247. ctlid = IDC_GEN_REGISTERED_0; // start here and use more as needed
  248. SetDlgItemText(ctlid++, m_OS.GetString("RegisteredUser"));
  249. // organization.
  250. SetDlgItemText(ctlid++, m_OS.GetString("Organization"));
  251. //productID
  252. wcscpy(_scr1, (wchar_t *)m_OS.GetString("SerialNumber"));
  253. ConfigureProductID(_scr1);
  254. SetDlgItemText(ctlid++, _scr1);
  255. // another product ID
  256. wcscpy(_scr1, (wchar_t *)m_OS.GetString("PlusProductID"));
  257. ConfigureProductID(_scr1);
  258. SetDlgItemText(ctlid++, _scr1);
  259. // Do machine info
  260. ctlid = IDC_GEN_MACHINE_0; // start here and use controls as needed
  261. //TODO: get this property back.
  262. // if OEM ....
  263. m_manufacturer = m_computer.GetString("Manufacturer");
  264. if(m_manufacturer.length() > 0)
  265. {
  266. SetDlgItemText(ctlid++, m_manufacturer );
  267. SetDlgItemText(ctlid++, m_computer.GetString("Model"));
  268. // if there's support info...
  269. variant_t array;
  270. long LBound = 2147483647;
  271. long UBound = 2147483647;
  272. SAFEARRAY *supportArray = NULL;
  273. m_computer.Get("SupportContactDescription", (variant_t &)array);
  274. if(array.vt == (VT_ARRAY | VT_BSTR))
  275. {
  276. supportArray = V_ARRAY(&array);
  277. SafeArrayGetLBound(supportArray, 1, &LBound);
  278. SafeArrayGetUBound(supportArray, 1, &UBound);
  279. // turn on the button.
  280. HWND wnd = GetDlgItem(IDC_GEN_OEM_SUPPORT );
  281. ::EnableWindow( wnd, TRUE );
  282. ::ShowWindow( wnd, SW_SHOW );
  283. }
  284. #ifdef DOES_NOT_WORK
  285. // Get the OEMLogo array.
  286. HBITMAP hDDBitmap;
  287. HRESULT hr;
  288. if(SUCCEEDED(hr = m_computer.GetDIB("OEMLogoBitmap", GetDC(),
  289. hDDBitmap)))
  290. {
  291. ::SendMessage(GetDlgItem(IDC_GEN_OEM_IMAGE),
  292. STM_SETIMAGE, IMAGE_BITMAP,
  293. (LPARAM)hDDBitmap);
  294. ::ShowWindow(GetDlgItem(IDC_GEN_OEM_NUDGE), SW_SHOWNA);
  295. ::ShowWindow(GetDlgItem(IDC_GEN_MACHINE), SW_HIDE);
  296. }
  297. #endif // DOES_NOT_WORK
  298. } //endif OEM
  299. // Processor
  300. SetDlgItemText(ctlid++, m_processor.GetString("Name"));
  301. // Processor speed
  302. LoadString(HINST_THISDLL,
  303. IDS_XDOTX_MHZ,
  304. _scr2,
  305. ARRAYSIZE(_scr2));
  306. wsprintf(_scr1,
  307. _scr2,
  308. AddCommas(m_processor.GetLong("CurrentClockSpeed"), szNumBuf1));
  309. SetDlgItemText(ctlid++, _scr1);
  310. // Memory
  311. #define ONEMB 1048576 // 1MB == 1048576 bytes.
  312. _int64 nTotalBytes = m_computer.GetI64("TotalPhysicalMemory");
  313. //
  314. // WORKAROUND - NtQuerySystemInformation doesn't really return the
  315. // total available physical memory, it instead just reports the total
  316. // memory seen by the Operating System. Since some amount of memory
  317. // is reserved by BIOS, the total available memory is reported
  318. // incorrectly. To work around this limitation, we convert the total
  319. // bytes to the nearest 4MB value
  320. //
  321. double nTotalMB = (double)(nTotalBytes / ONEMB);
  322. LONGLONG llMem = (LONGLONG)((ceil(ceil(nTotalMB) / 4.0) * 4.0) * ONEMB);
  323. StrFormatByteSize(llMem, szNumBuf1, ARRAYSIZE(szNumBuf1));
  324. LoadString(HINST_THISDLL, IDS_XDOTX_MB, _scr2, ARRAYSIZE(_scr2));
  325. wsprintf(_scr1, _scr2, szNumBuf1);
  326. SetDlgItemText(ctlid++, _scr1);
  327. }
  328. //--------------------------------------------------------------
  329. LRESULT GeneralPage::OnInit(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  330. {
  331. m_serviceThread->Connect(m_pDataObject, m_hWnd);
  332. if(!m_inited)
  333. {
  334. HWND hAnim = GetDlgItem(IDC_ANIMATE);
  335. Animate_Open(hAnim, MAKEINTRESOURCE(IDR_AVIWAIT));
  336. TCHAR msg[50] = {0};
  337. ::LoadString(HINST_THISDLL, IDS_UNAVAILABLE, msg, 50);
  338. SetDlgItemText(IDC_GEN_REGISTERED_0, msg);
  339. }
  340. return S_OK;
  341. }
  342. //--------------------------------------------------------------
  343. LRESULT GeneralPage::OnConnected(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  344. {
  345. if(lParam)
  346. {
  347. IStream *pStream = (IStream *)lParam;
  348. IWbemServices *pServices = 0;
  349. HRESULT hr = CoGetInterfaceAndReleaseStream(pStream,
  350. IID_IWbemServices,
  351. (void**)&pServices);
  352. if(SUCCEEDED(hr))
  353. {
  354. SetWbemService(pServices);
  355. pServices->Release();
  356. // check anyway, just to get the side affects.
  357. if(CimomIsReady())
  358. {
  359. HWND hwnd = GetDlgItem(IDC_GEN_WINDOWS_IMAGE);
  360. SetClearBitmap(hwnd, MAKEINTRESOURCE(IDB_WINDOWS), 0);
  361. ::ShowWindow(hwnd, SW_SHOWNA);
  362. hwnd = GetDlgItem(IDC_ANIMATE);
  363. Animate_Close(hwnd);
  364. ::ShowWindow(hwnd, SW_HIDE);
  365. Init();
  366. m_inited = true;
  367. }
  368. else
  369. {
  370. PropSheet_RemovePage(::GetParent(m_hWnd), 2, 0);
  371. PropSheet_RemovePage(::GetParent(m_hWnd), 1, 0);
  372. }
  373. }
  374. }
  375. else // connection failed.
  376. {
  377. CimomIsReady(); //courtesy call.
  378. PropSheet_RemovePage(::GetParent(m_hWnd), 2, 0);
  379. PropSheet_RemovePage(::GetParent(m_hWnd), 1, 0);
  380. HWND hwnd = GetDlgItem(IDC_GEN_WINDOWS_IMAGE);
  381. SetClearBitmap(hwnd, MAKEINTRESOURCE(IDB_WINDOWS), 0);
  382. ::ShowWindow(hwnd, SW_SHOWNA);
  383. hwnd = GetDlgItem(IDC_ANIMATE);
  384. Animate_Close(hwnd);
  385. ::ShowWindow(hwnd, SW_HIDE);
  386. }
  387. return S_OK;
  388. }
  389. //----------------------------------------------
  390. DWORD aGeneralHelpIds[] = {
  391. IDC_GEN_WINDOWS_IMAGE, IDH_NO_HELP,
  392. IDC_TEXT_1, (IDH_GENERAL + 0),
  393. IDC_GEN_VERSION_0, (IDH_GENERAL + 1),
  394. IDC_GEN_VERSION_1, (IDH_GENERAL + 1),
  395. IDC_GEN_VERSION_2, (IDH_GENERAL + 1),
  396. IDC_GEN_SERVICE_PACK, (IDH_GENERAL + 1),
  397. IDC_TEXT_3, (IDH_GENERAL + 3),
  398. IDC_GEN_REGISTERED_0, (IDH_GENERAL + 3),
  399. IDC_GEN_REGISTERED_1, (IDH_GENERAL + 3),
  400. IDC_GEN_REGISTERED_2, (IDH_GENERAL + 3),
  401. IDC_GEN_REGISTERED_3, (IDH_GENERAL + 3),
  402. IDC_GEN_OEM_IMAGE, IDH_NO_HELP,
  403. IDC_TEXT_4, (IDH_GENERAL + 6),
  404. IDC_GEN_MACHINE_0, (IDH_GENERAL + 7),
  405. IDC_GEN_MACHINE_1, (IDH_GENERAL + 8),
  406. IDC_GEN_MACHINE_2, (IDH_GENERAL + 9),
  407. IDC_GEN_MACHINE_3, (IDH_GENERAL + 10),
  408. IDC_GEN_MACHINE_4, (IDH_GENERAL + 11),
  409. IDC_GEN_MACHINE_5, IDH_NO_HELP,
  410. IDC_GEN_MACHINE_6, IDH_NO_HELP,
  411. IDC_GEN_MACHINE_7, IDH_NO_HELP,
  412. IDC_GEN_MACHINE_8, IDH_NO_HELP,
  413. IDC_GEN_OEM_SUPPORT, (IDH_GENERAL + 12),
  414. IDC_GEN_REGISTERED_2, (IDH_GENERAL + 14),
  415. IDC_GEN_REGISTERED_3, (IDH_GENERAL + 15),
  416. IDC_GEN_MACHINE, (IDH_GENERAL + 7),
  417. IDC_GEN_OEM_NUDGE, IDH_NO_HELP,
  418. 0, 0
  419. };
  420. LRESULT GeneralPage::OnF1Help(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  421. {
  422. ::WinHelp((HWND)((LPHELPINFO)lParam)->hItemHandle,
  423. L"sysdm.hlp",
  424. HELP_WM_HELP,
  425. (ULONG_PTR)(LPSTR)aGeneralHelpIds);
  426. return S_OK;
  427. }
  428. //--------------------------------------------------------------
  429. LRESULT GeneralPage::OnContextHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  430. {
  431. ::WinHelp((HWND)wParam,
  432. L"sysdm.hlp",
  433. HELP_CONTEXTMENU,
  434. (ULONG_PTR)(LPSTR)aGeneralHelpIds);
  435. return S_OK;
  436. }
  437. //--------------------------------------------------------------
  438. LRESULT GeneralPage::OnSupport(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  439. {
  440. TCHAR text[4096] = {0};
  441. BSTR temp;
  442. variant_t array;
  443. SAFEARRAY *supportArray = NULL;
  444. long LBound = 2147483647;
  445. long UBound = 2147483647;
  446. wcscpy(text, _T(""));
  447. m_computer.Get("SupportContactDescription", (variant_t &)array);
  448. supportArray = V_ARRAY(&array);
  449. SafeArrayGetLBound(supportArray, 1, &LBound);
  450. SafeArrayGetUBound(supportArray, 1, &UBound);
  451. for(long i = LBound; i <= UBound; i++)
  452. {
  453. SafeArrayGetElement(supportArray, &i, &temp);
  454. wcscat(text, temp);
  455. wcscat(text, _T("\r\n"));
  456. }
  457. // display the supportContact text.
  458. DialogBoxParam(HINST_THISDLL, MAKEINTRESOURCE(IDD_PHONESUP),
  459. GetParent(), PhoneSupportProc, (LPARAM)text);
  460. return S_OK;
  461. }
  462. //--------------------------------------------------------------
  463. LRESULT GeneralPage::OnSysColorChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  464. {
  465. //TODO: reread the oemLogo property.
  466. // SetClearBitmap(GetDlgItem(IDC_GEN_OEM_IMAGE ), oemfile,
  467. // SCB_FROMFILE | SCB_REPLACEONLY );
  468. SetClearBitmap(GetDlgItem(IDC_GEN_WINDOWS_IMAGE ),
  469. MAKEINTRESOURCE( IDB_WINDOWS ), 0 );
  470. return S_OK;
  471. }
  472. //--------------------------------------------------------------
  473. LRESULT GeneralPage::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  474. {
  475. SetClearBitmap( GetDlgItem(IDC_GEN_OEM_IMAGE ), NULL, 0 );
  476. SetClearBitmap( GetDlgItem(IDC_GEN_WINDOWS_IMAGE ), NULL, 0 );
  477. return S_OK;
  478. }
  479. //--------------------------------------------------------------
  480. BOOL GeneralPage::OnApply()
  481. {
  482. // SetWindowLong(DWL_MSGRESULT, PSNRET_NOERROR);
  483. return TRUE;
  484. }
  485. //----------------------------------------------------------
  486. INT_PTR CALLBACK PhoneSupportProc(HWND hDlg, UINT uMsg,
  487. WPARAM wParam, LPARAM lParam)
  488. {
  489. switch( uMsg )
  490. {
  491. case WM_INITDIALOG:
  492. {
  493. HWND editBox = GetDlgItem(hDlg, IDC_SUPPORT_TEXT);
  494. // load the edit box.
  495. SendMessage (editBox, WM_SETREDRAW, FALSE, 0);
  496. Edit_SetText(editBox, (LPCTSTR)lParam);
  497. SendMessage (editBox, WM_SETREDRAW, TRUE, 0);
  498. } //end case
  499. break;
  500. case WM_COMMAND:
  501. switch(LOWORD(wParam))
  502. {
  503. case IDOK:
  504. case IDCANCEL:
  505. EndDialog( hDlg, 0 );
  506. break;
  507. default:
  508. return FALSE;
  509. }
  510. break;
  511. default:
  512. return FALSE;
  513. }
  514. return TRUE;
  515. }
  516. //----------------------------------------------------------
  517. DWORD GeneralPage::GetServerTypeResourceID(void)
  518. {
  519. // This code was taken from the shell internal api, IsOS,
  520. // located in nt\shell\inc\IsOS.c. This code was derived
  521. // specifically from the following IsOS() switch statements:
  522. // OS_ADVSERVER
  523. // OS_DATACENTER
  524. // OS_EMBEDDED
  525. // OS_PERSONAL
  526. // OS_PROFESSIONAL
  527. // OS_SERVER
  528. // These are the only interesting cases used by system cpl.
  529. //
  530. // Conditions intentionally verbose (not optimized) for sake
  531. // of readability.
  532. //
  533. variant_t var;
  534. LONG ProductType = 0;
  535. LONG fProductSuite = 0;
  536. if (SUCCEEDED(m_OS.Get("ProductType", var)))
  537. {
  538. if (var.vt == VT_I4)
  539. ProductType = var.iVal;
  540. }
  541. if (SUCCEEDED(m_OS.Get("SuiteMask", var)))
  542. {
  543. if (var.vt == VT_I4)
  544. fProductSuite = var.iVal;
  545. }
  546. if ((ProductType == VER_NT_SERVER ||
  547. ProductType == VER_NT_DOMAIN_CONTROLLER) &&
  548. (fProductSuite & VER_SUITE_ENTERPRISE) &&
  549. !(fProductSuite & VER_SUITE_DATACENTER))
  550. {
  551. return IDS_WINVER_ADVANCEDSERVER;
  552. }
  553. else
  554. if ((ProductType == VER_NT_SERVER ||
  555. ProductType == VER_NT_DOMAIN_CONTROLLER) &&
  556. (fProductSuite & VER_SUITE_DATACENTER))
  557. {
  558. return IDS_WINVER_DATACENTER;
  559. }
  560. else
  561. if (fProductSuite & VER_SUITE_EMBEDDEDNT)
  562. {
  563. return IDS_WINVER_EMBEDDED;
  564. }
  565. else
  566. if (fProductSuite & VER_SUITE_PERSONAL)
  567. {
  568. return IDS_WINVER_PERSONAL;
  569. }
  570. else
  571. if (ProductType == VER_NT_WORKSTATION)
  572. {
  573. return IDS_WINVER_PROFESSIONAL;
  574. }
  575. else
  576. if ((ProductType == VER_NT_SERVER ||
  577. ProductType == VER_NT_DOMAIN_CONTROLLER) &&
  578. !(fProductSuite & VER_SUITE_ENTERPRISE) &&
  579. !(fProductSuite & VER_SUITE_DATACENTER))
  580. {
  581. return IDS_WINVER_SERVER;
  582. }
  583. else
  584. {
  585. return IDS_WINVER_SERVER; // Generic catch-all.
  586. }
  587. }